@lets-events/react 12.1.13 → 12.2.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
@@ -143,7 +143,7 @@ var require_react_is_development = __commonJS({
143
143
  var ContextProvider = REACT_PROVIDER_TYPE;
144
144
  var Element = REACT_ELEMENT_TYPE;
145
145
  var ForwardRef = REACT_FORWARD_REF_TYPE;
146
- var Fragment6 = REACT_FRAGMENT_TYPE;
146
+ var Fragment5 = REACT_FRAGMENT_TYPE;
147
147
  var Lazy = REACT_LAZY_TYPE;
148
148
  var Memo = REACT_MEMO_TYPE;
149
149
  var Portal = REACT_PORTAL_TYPE;
@@ -202,7 +202,7 @@ var require_react_is_development = __commonJS({
202
202
  exports.ContextProvider = ContextProvider;
203
203
  exports.Element = Element;
204
204
  exports.ForwardRef = ForwardRef;
205
- exports.Fragment = Fragment6;
205
+ exports.Fragment = Fragment5;
206
206
  exports.Lazy = Lazy;
207
207
  exports.Memo = Memo;
208
208
  exports.Portal = Portal;
@@ -9281,9 +9281,9 @@ function Tooltip({
9281
9281
  ] }) });
9282
9282
  }
9283
9283
 
9284
- // src/components/MultiSelect.tsx
9284
+ // src/components/MultiSelect/index.tsx
9285
9285
  import React9, { useCallback as useCallback2, useRef as useRef7, useState as useState7 } from "react";
9286
- import { DropdownMenu as DropdownMenu3, Theme as Theme3 } from "@radix-ui/themes";
9286
+ import { DropdownMenu as DropdownMenu4, Theme as Theme3 } from "@radix-ui/themes";
9287
9287
  import { FontAwesomeIcon as FontAwesomeIcon3 } from "@fortawesome/react-fontawesome";
9288
9288
  import {
9289
9289
  faChevronDown as faChevronDown2,
@@ -9291,7 +9291,9 @@ import {
9291
9291
  faSquareXmark
9292
9292
  } from "@fortawesome/free-solid-svg-icons";
9293
9293
  import { useMemo } from "react";
9294
- import { Fragment as Fragment2, jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
9294
+
9295
+ // src/components/MultiSelect/styledComponents.ts
9296
+ import { DropdownMenu as DropdownMenu3 } from "@radix-ui/themes";
9295
9297
  var StyledContent = styled(DropdownMenu3.Content, {
9296
9298
  backgroundColor: "$dark50",
9297
9299
  borderRadius: "$sm",
@@ -9375,12 +9377,67 @@ var StyledFlexWithMaxHeight = styled(Flex2, {
9375
9377
  hasMaxHeight: false
9376
9378
  }
9377
9379
  });
9380
+ var StyledFlexSelectedItems = styled(Flex2, {
9381
+ overflowY: "auto",
9382
+ margin: "8px 0",
9383
+ "&::-webkit-scrollbar": {
9384
+ width: "4px"
9385
+ },
9386
+ "&::-webkit-scrollbar-track": {
9387
+ backgroundColor: "$dark100",
9388
+ borderRadius: "2px"
9389
+ },
9390
+ "&::-webkit-scrollbar-thumb": {
9391
+ backgroundColor: "$dark300",
9392
+ borderRadius: "2px",
9393
+ "&:hover": {
9394
+ backgroundColor: "$dark400"
9395
+ }
9396
+ }
9397
+ });
9378
9398
  var StyledText = styled(Text, {
9379
9399
  flex: 1,
9380
9400
  overflow: "hidden",
9381
9401
  whiteSpace: "nowrap",
9382
9402
  textOverflow: "ellipsis"
9383
9403
  });
9404
+ var ButtonSelectAllStyled = styled("button", {
9405
+ display: "flex !important",
9406
+ alignItems: "center",
9407
+ justifyContent: "flex-start",
9408
+ gap: "$8",
9409
+ border: "none",
9410
+ "div": {
9411
+ backgroundCcolor: "#fff",
9412
+ borderRadius: "2px",
9413
+ height: "$16",
9414
+ width: "$16",
9415
+ position: "relative",
9416
+ border: "2px solid $dark300",
9417
+ cursor: "pointer",
9418
+ boxSizing: "border-box",
9419
+ "&.checked::before": {
9420
+ backgroundImage: `url("data:image/svg+xml,%3Csvg%20width='16'%20height='16'%20viewBox='0%200%2014%2014'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M2%200C0.896875%200%200%200.896875%200%202V12C0%2013.1031%200.896875%2014%202%2014H12C13.1031%2014%2014%2013.1031%2014%2012V2C14%200.896875%2013.1031%200%2012%200H2ZM10.5312%205.53125L6.53125%209.53125C6.2375%209.825%205.7625%209.825%205.47188%209.53125L3.47187%207.53125C3.17812%207.2375%203.17812%206.7625%203.47187%206.47188C3.76562%206.18125%204.24062%206.17813%204.53125%206.47188L6%207.94063L9.46875%204.46875C9.7625%204.175%2010.2375%204.175%2010.5281%204.46875C10.8187%204.7625%2010.8219%205.2375%2010.5281%205.52812L10.5312%205.53125Z'%20fill='%23004ED2'/%3E%3C/svg%3E")`,
9421
+ content: "",
9422
+ width: "1rem",
9423
+ height: "1rem",
9424
+ position: "absolute",
9425
+ top: "-1px",
9426
+ right: "-2px",
9427
+ zIndex: "2",
9428
+ backgroundRepeat: "no-repeat"
9429
+ }
9430
+ },
9431
+ "&:hover": {
9432
+ "div": {
9433
+ transition: "all 300ms ease-out",
9434
+ boxShadow: "rgba(56, 129, 255, 0.5) 0px 0px 0px 4px"
9435
+ }
9436
+ }
9437
+ });
9438
+
9439
+ // src/components/MultiSelect/index.tsx
9440
+ import { jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
9384
9441
  var MultiSelect = React9.forwardRef(
9385
9442
  ({
9386
9443
  placeholder,
@@ -9394,10 +9451,14 @@ var MultiSelect = React9.forwardRef(
9394
9451
  singleSelect = false,
9395
9452
  selectedOrientation = "column",
9396
9453
  disabled = false,
9397
- maxHeight
9454
+ maxHeight,
9455
+ selectedAllOptions = false,
9456
+ selectedAllText,
9457
+ selectedScroll = false
9398
9458
  }, fowardedRef) => {
9399
9459
  const [isOpen, setIsOpen] = useState7(false);
9400
9460
  const triggerRef = useRef7(null);
9461
+ const [allOptionsSelected, setAllOptionsSelected] = useState7(false);
9401
9462
  const labelByValue = useMemo(() => {
9402
9463
  return options.reduce((prev, curr) => {
9403
9464
  return __spreadProps(__spreadValues({}, prev), {
@@ -9412,6 +9473,21 @@ var MultiSelect = React9.forwardRef(
9412
9473
  },
9413
9474
  [selectedValues, onValueChange]
9414
9475
  );
9476
+ const handleSelectAll = useCallback2(
9477
+ (e) => {
9478
+ e.preventDefault();
9479
+ e.stopPropagation();
9480
+ const allSelected = selectedValues.length === options.length;
9481
+ if (allSelected) {
9482
+ onValueChange == null ? void 0 : onValueChange([]);
9483
+ setAllOptionsSelected(false);
9484
+ } else {
9485
+ onValueChange == null ? void 0 : onValueChange(options.map((o) => o.value));
9486
+ setAllOptionsSelected(true);
9487
+ }
9488
+ },
9489
+ [selectedValues, options, onValueChange]
9490
+ );
9415
9491
  const text = useMemo(() => {
9416
9492
  if (selectedValues.length > 0 && singleSelect) {
9417
9493
  const value = selectedValues[0];
@@ -9432,9 +9508,9 @@ var MultiSelect = React9.forwardRef(
9432
9508
  },
9433
9509
  [disabled]
9434
9510
  );
9435
- return /* @__PURE__ */ jsxs14(Theme3, { children: [
9436
- /* @__PURE__ */ jsxs14(DropdownMenu3.Root, { children: [
9437
- /* @__PURE__ */ jsx26(DropdownMenu3.Trigger, { children: /* @__PURE__ */ jsxs14(
9511
+ return /* @__PURE__ */ jsxs14(Theme3, { style: width !== "100%" ? { width } : void 0, children: [
9512
+ /* @__PURE__ */ jsxs14(DropdownMenu4.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
9513
+ /* @__PURE__ */ jsx26(DropdownMenu4.Trigger, { children: /* @__PURE__ */ jsxs14(
9438
9514
  StyledTrigger,
9439
9515
  {
9440
9516
  ref: (r) => {
@@ -9442,9 +9518,7 @@ var MultiSelect = React9.forwardRef(
9442
9518
  triggerRef.current = r;
9443
9519
  if (fowardedRef) {
9444
9520
  if (typeof fowardedRef === "function") fowardedRef(r);
9445
- else {
9446
- fowardedRef.current = r;
9447
- }
9521
+ else fowardedRef.current = r;
9448
9522
  }
9449
9523
  },
9450
9524
  color,
@@ -9484,15 +9558,31 @@ var MultiSelect = React9.forwardRef(
9484
9558
  value: selectedValues,
9485
9559
  onValueChange: (v) => {
9486
9560
  onValueChange == null ? void 0 : onValueChange(v);
9561
+ if (allOptionsSelected) {
9562
+ setAllOptionsSelected(false);
9563
+ }
9487
9564
  },
9488
- children: /* @__PURE__ */ jsx26(
9565
+ children: /* @__PURE__ */ jsxs14(
9489
9566
  StyledFlexWithMaxHeight,
9490
9567
  {
9491
9568
  direction: "column",
9492
9569
  gap: 8,
9493
9570
  hasMaxHeight: !!maxHeight,
9494
9571
  style: maxHeight ? { maxHeight } : void 0,
9495
- children: options.map(({ value, label }, i) => /* @__PURE__ */ jsx26(CheckboxItem, { value, css: itemStyle, children: /* @__PURE__ */ jsx26(Text, { typography: "labelSmall", children: label }) }, i))
9572
+ children: [
9573
+ selectedAllOptions && /* @__PURE__ */ jsxs14(
9574
+ ButtonSelectAllStyled,
9575
+ {
9576
+ css: itemStyle,
9577
+ onClick: (e) => handleSelectAll(e),
9578
+ children: [
9579
+ /* @__PURE__ */ jsx26("div", { className: allOptionsSelected ? "checked" : "" }),
9580
+ /* @__PURE__ */ jsx26(Text, { typography: "labelSmall", children: selectedAllText ? selectedAllText : "Selecionar Todos" })
9581
+ ]
9582
+ }
9583
+ ),
9584
+ options.map(({ value, label }, i) => /* @__PURE__ */ jsx26(CheckboxItem, { value, css: itemStyle, children: /* @__PURE__ */ jsx26(Text, { typography: "labelSmall", children: label }) }, i))
9585
+ ]
9496
9586
  }
9497
9587
  )
9498
9588
  }
@@ -9509,14 +9599,14 @@ var MultiSelect = React9.forwardRef(
9509
9599
  }
9510
9600
  )
9511
9601
  ] }),
9512
- selectedValues.length > 0 && showSelectedValues && /* @__PURE__ */ jsx26(Fragment2, { children: /* @__PURE__ */ jsx26(
9513
- Flex2,
9602
+ selectedValues.length > 0 && showSelectedValues && /* @__PURE__ */ jsx26(
9603
+ StyledFlexSelectedItems,
9514
9604
  {
9515
9605
  direction: selectedOrientation,
9516
9606
  gap: 8,
9517
9607
  align: selectedOrientation === "column" ? "start" : "center",
9518
9608
  justify: "start",
9519
- css: { margin: "8px 0" },
9609
+ css: __spreadValues({}, selectedScroll && { maxHeight: maxHeight || "400px" }),
9520
9610
  children: selectedValues.map((value) => /* @__PURE__ */ jsxs14(
9521
9611
  Flex2,
9522
9612
  {
@@ -9549,7 +9639,7 @@ var MultiSelect = React9.forwardRef(
9549
9639
  value
9550
9640
  ))
9551
9641
  }
9552
- ) })
9642
+ )
9553
9643
  ] });
9554
9644
  }
9555
9645
  );
@@ -10055,7 +10145,7 @@ var PhoneFormField = ({
10055
10145
  };
10056
10146
 
10057
10147
  // src/components/FormFields/CPFFormField.tsx
10058
- import { useFormContext as useFormContext4, useWatch } from "react-hook-form";
10148
+ import { useFormContext as useFormContext3, useWatch } from "react-hook-form";
10059
10149
  import { jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
10060
10150
  var isValidCPF = (cpf) => {
10061
10151
  cpf = cpf.replace(/[^\d]+/g, "");
@@ -10080,7 +10170,7 @@ var CPFFormField = ({
10080
10170
  validationErrorMessage,
10081
10171
  foreignerLabel
10082
10172
  }) => {
10083
- const { control, setValue } = useFormContext4();
10173
+ const { control, setValue } = useFormContext3();
10084
10174
  const foreigner = useWatch({ name: "foreigner", control });
10085
10175
  return /* @__PURE__ */ jsxs20(Flex2, { direction: "column", children: [
10086
10176
  /* @__PURE__ */ jsx37(
@@ -10274,10 +10364,10 @@ var IdentityDocumentNumberFormField = ({
10274
10364
  };
10275
10365
 
10276
10366
  // src/components/FormFields/AddressFormFields/index.tsx
10277
- import { useFormContext as useFormContext7, useWatch as useWatch2, useFormState } from "react-hook-form";
10367
+ import { useFormContext as useFormContext6, useWatch as useWatch2, useFormState } from "react-hook-form";
10278
10368
 
10279
10369
  // src/components/FormFields/SelectFormField.tsx
10280
- import { useFormContext as useFormContext5, Controller } from "react-hook-form";
10370
+ import { useFormContext as useFormContext4, Controller } from "react-hook-form";
10281
10371
 
10282
10372
  // src/utils/getNestedValue.ts
10283
10373
  function getNestedValue(obj, path) {
@@ -10299,7 +10389,7 @@ var SelectFormField = ({
10299
10389
  const {
10300
10390
  control,
10301
10391
  formState: { errors }
10302
- } = useFormContext5();
10392
+ } = useFormContext4();
10303
10393
  const fieldError = getNestedValue(errors, name);
10304
10394
  const haveError = !!fieldError;
10305
10395
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
@@ -10464,14 +10554,14 @@ var brazilianStates = [
10464
10554
  ];
10465
10555
 
10466
10556
  // src/components/FormFields/AddressFormFields/StateFormField.tsx
10467
- import { Fragment as Fragment3, jsx as jsx44 } from "react/jsx-runtime";
10557
+ import { Fragment as Fragment2, jsx as jsx44 } from "react/jsx-runtime";
10468
10558
  function StateFormField({
10469
10559
  name,
10470
10560
  label,
10471
10561
  required,
10472
10562
  isBrazil
10473
10563
  }) {
10474
- return /* @__PURE__ */ jsx44(Fragment3, { children: isBrazil ? /* @__PURE__ */ jsx44(
10564
+ return /* @__PURE__ */ jsx44(Fragment2, { children: isBrazil ? /* @__PURE__ */ jsx44(
10475
10565
  SelectFormField,
10476
10566
  {
10477
10567
  name,
@@ -10484,8 +10574,8 @@ function StateFormField({
10484
10574
 
10485
10575
  // src/components/FormFields/AddressFormFields/CityFormField.tsx
10486
10576
  import { useEffect as useEffect5, useState as useState8 } from "react";
10487
- import { useFormContext as useFormContext6, Controller as Controller2 } from "react-hook-form";
10488
- import { Fragment as Fragment4, jsx as jsx45 } from "react/jsx-runtime";
10577
+ import { useFormContext as useFormContext5, Controller as Controller2 } from "react-hook-form";
10578
+ import { Fragment as Fragment3, jsx as jsx45 } from "react/jsx-runtime";
10489
10579
  function CityFormField({
10490
10580
  name,
10491
10581
  label,
@@ -10494,7 +10584,7 @@ function CityFormField({
10494
10584
  isBrazil,
10495
10585
  placeholder
10496
10586
  }) {
10497
- const { control, watch } = useFormContext6();
10587
+ const { control, watch } = useFormContext5();
10498
10588
  const selectedState = watch(stateName);
10499
10589
  const [cities, setCities] = useState8([]);
10500
10590
  const [loading, setLoading] = useState8(false);
@@ -10537,7 +10627,7 @@ function CityFormField({
10537
10627
  }
10538
10628
  fetchCities();
10539
10629
  }, [selectedState, isBrazil]);
10540
- return /* @__PURE__ */ jsx45(Fragment4, { children: isBrazil && cities.length > 0 ? /* @__PURE__ */ jsx45(
10630
+ return /* @__PURE__ */ jsx45(Fragment3, { children: isBrazil && cities.length > 0 ? /* @__PURE__ */ jsx45(
10541
10631
  Controller2,
10542
10632
  {
10543
10633
  name,
@@ -10598,7 +10688,7 @@ function AddressFormFields({
10598
10688
  required,
10599
10689
  layout = "column"
10600
10690
  }) {
10601
- const { control, setValue } = useFormContext7();
10691
+ const { control, setValue } = useFormContext6();
10602
10692
  const { errors } = useFormState({ control });
10603
10693
  const selectedCountry = useWatch2({ control, name: `${name}.country` });
10604
10694
  const isBrazil = selectedCountry === "Brasil";
@@ -10697,7 +10787,7 @@ function AddressFormFields({
10697
10787
  }
10698
10788
 
10699
10789
  // src/components/FormFields/RadioGroupFormField.tsx
10700
- import { Controller as Controller3, useFormContext as useFormContext8 } from "react-hook-form";
10790
+ import { Controller as Controller3, useFormContext as useFormContext7 } from "react-hook-form";
10701
10791
  import { jsx as jsx47, jsxs as jsxs23 } from "react/jsx-runtime";
10702
10792
  var RadioGroupFormField = ({
10703
10793
  name,
@@ -10713,7 +10803,7 @@ var RadioGroupFormField = ({
10713
10803
  const {
10714
10804
  control,
10715
10805
  formState: { errors }
10716
- } = useFormContext8();
10806
+ } = useFormContext7();
10717
10807
  const fieldError = getNestedValue(errors, name);
10718
10808
  const haveError = !!fieldError;
10719
10809
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
@@ -10758,7 +10848,7 @@ var RadioGroupFormField = ({
10758
10848
  };
10759
10849
 
10760
10850
  // src/components/FormFields/CheckboxGroupFormField.tsx
10761
- import { Controller as Controller4, useFormContext as useFormContext9 } from "react-hook-form";
10851
+ import { Controller as Controller4, useFormContext as useFormContext8 } from "react-hook-form";
10762
10852
  import { jsx as jsx48, jsxs as jsxs24 } from "react/jsx-runtime";
10763
10853
  var CheckboxGroupFormField = ({
10764
10854
  name,
@@ -10774,7 +10864,7 @@ var CheckboxGroupFormField = ({
10774
10864
  const {
10775
10865
  control,
10776
10866
  formState: { errors }
10777
- } = useFormContext9();
10867
+ } = useFormContext8();
10778
10868
  const fieldError = getNestedValue(errors, name);
10779
10869
  const haveError = !!fieldError;
10780
10870
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
@@ -10826,7 +10916,7 @@ var CheckboxGroupFormField = ({
10826
10916
  };
10827
10917
 
10828
10918
  // src/components/FormFields/SwitchFormField.tsx
10829
- import { useFormContext as useFormContext10, Controller as Controller5 } from "react-hook-form";
10919
+ import { useFormContext as useFormContext9, Controller as Controller5 } from "react-hook-form";
10830
10920
  import { jsx as jsx49, jsxs as jsxs25 } from "react/jsx-runtime";
10831
10921
  var SwitchFormField = ({
10832
10922
  name,
@@ -10837,7 +10927,7 @@ var SwitchFormField = ({
10837
10927
  const {
10838
10928
  control,
10839
10929
  watch: watchForm
10840
- } = useFormContext10();
10930
+ } = useFormContext9();
10841
10931
  if (watch) {
10842
10932
  watchForm(name);
10843
10933
  }
@@ -12343,7 +12433,7 @@ var RichEditor_default = RichEditor;
12343
12433
 
12344
12434
  // src/components/FormFields/RichEditorFormField.tsx
12345
12435
  import { useState as useState11 } from "react";
12346
- import { Fragment as Fragment5, jsx as jsx53, jsxs as jsxs27 } from "react/jsx-runtime";
12436
+ import { Fragment as Fragment4, jsx as jsx53, jsxs as jsxs27 } from "react/jsx-runtime";
12347
12437
  var RichEditorFormField = (_a) => {
12348
12438
  var _b = _a, {
12349
12439
  name,
@@ -12394,7 +12484,7 @@ var RichEditorFormField = (_a) => {
12394
12484
  }
12395
12485
  ),
12396
12486
  /* @__PURE__ */ jsx53(Badge, { color: "grey", size: "xs", children: caracterQuantity })
12397
- ] }) : /* @__PURE__ */ jsx53(Fragment5, { children: label && /* @__PURE__ */ jsx53(
12487
+ ] }) : /* @__PURE__ */ jsx53(Fragment4, { children: label && /* @__PURE__ */ jsx53(
12398
12488
  FormLabel,
12399
12489
  {
12400
12490
  name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lets-events/react",
3
- "version": "12.1.13",
3
+ "version": "12.2.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,4 +1,4 @@
1
- import { useController, useFormContext } from "react-hook-form";
1
+ import { useController } from "react-hook-form";
2
2
  import { Flex } from "../Flex";
3
3
  import { FormLabel } from "./subComponents/FormLabel";
4
4
  import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";