@lets-events/react 12.10.17 → 12.11.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.
- package/.eslintrc.json +2 -2
- package/.turbo/turbo-build.log +21 -19
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +19 -7
- package/dist/index.d.ts +19 -7
- package/dist/index.js +422 -264
- package/dist/index.mjs +432 -274
- package/package.json +1 -1
- package/src/components/Alert.tsx +303 -303
- package/src/components/Avatar.tsx +55 -55
- package/src/components/Badge.tsx +132 -132
- package/src/components/Box.tsx +3 -3
- package/src/components/Button/index.tsx +85 -85
- package/src/components/Button/styledComponents.ts +361 -361
- package/src/components/ButtonGroup.tsx +484 -484
- package/src/components/Calendar/index.tsx +168 -168
- package/src/components/Calendar/styledComponents.ts +480 -480
- package/src/components/Card.tsx +74 -74
- package/src/components/CheckboxGroup.tsx +176 -176
- package/src/components/Container.tsx +39 -39
- package/src/components/Divider.tsx +7 -7
- package/src/components/DoubleCalendar/index.tsx +204 -204
- package/src/components/Drawer/index.tsx +113 -113
- package/src/components/Drawer/styledComponents.ts +97 -97
- package/src/components/Dropdown.tsx +302 -302
- package/src/components/Filter.tsx +164 -164
- package/src/components/Flex.tsx +130 -130
- package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -111
- package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
- package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -39
- package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
- package/src/components/FormFields/AddressFormFields/index.tsx +141 -141
- package/src/components/FormFields/BirthDateFormField.tsx +84 -84
- package/src/components/FormFields/CNPJFormField.tsx +87 -87
- package/src/components/FormFields/CPFFormField.tsx +78 -78
- package/src/components/FormFields/CalendarFormField.tsx +98 -98
- package/src/components/FormFields/CheckboxGroupFormField.tsx +91 -91
- package/src/components/FormFields/DateAndTimeFormField.tsx +217 -217
- package/src/components/FormFields/DoubleCalendarFormField.tsx +96 -96
- package/src/components/FormFields/EmailFormField.tsx +27 -27
- package/src/components/FormFields/Form.tsx +39 -39
- package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +32 -32
- package/src/components/FormFields/MultiSelectFormField.tsx +64 -64
- package/src/components/FormFields/PhoneFormField.tsx +40 -40
- package/src/components/FormFields/RadioGroupFormField.tsx +88 -88
- package/src/components/FormFields/RichEditorFormField.tsx +128 -128
- package/src/components/FormFields/SelectFormField.tsx +113 -113
- package/src/components/FormFields/SwitchFormField.tsx +46 -46
- package/src/components/FormFields/TextAreaFormField.tsx +61 -61
- package/src/components/FormFields/TextFormField.tsx +112 -112
- package/src/components/FormFields/TimePickerFormField.tsx +88 -88
- package/src/components/FormFields/subComponents/ErrorFormMessage.tsx +36 -36
- package/src/components/FormFields/subComponents/FormLabel.tsx +36 -36
- package/src/components/FormFields/utils/validation.ts +23 -23
- package/src/components/Grid.tsx +137 -137
- package/src/components/Icon.tsx +47 -47
- package/src/components/MenuDropdown/index.tsx +38 -38
- package/src/components/MenuDropdown/styledComponents.ts +31 -31
- package/src/components/Modal.tsx +131 -114
- package/src/components/MultiSelect/index.tsx +417 -305
- package/src/components/MultiSelect/styledComponents.ts +176 -160
- package/src/components/RadioGroup.tsx +210 -210
- package/src/components/RichEditor/QuillComponent.tsx +419 -419
- package/src/components/RichEditor/RichEditor.tsx +53 -53
- package/src/components/RichEditor/RichTextPresenter.tsx +18 -18
- package/src/components/RichEditor/editorConfig.ts +149 -149
- package/src/components/RichEditor/index.ts +3 -3
- package/src/components/RichEditor/styledComponents.ts +1175 -1175
- package/src/components/RichEditor/types.ts +12 -12
- package/src/components/Section.tsx +33 -33
- package/src/components/Step.tsx +164 -164
- package/src/components/Switch.tsx +108 -108
- package/src/components/Text.tsx +54 -54
- package/src/components/TextField.tsx +423 -423
- package/src/components/TextareaField.tsx +116 -116
- package/src/components/TimePicker.tsx +357 -357
- package/src/components/Toast/components/ToastItem.tsx +41 -41
- package/src/components/Toast/components/ToastProvider.tsx +63 -63
- package/src/components/Toast/hooks/useToast.ts +12 -12
- package/src/components/Toast/index.tsx +5 -5
- package/src/components/Toast/styles/index.ts +135 -135
- package/src/components/Toast/types/index.ts +46 -46
- package/src/components/ToggleElement/index.tsx +58 -58
- package/src/components/Tooltip/index.tsx +126 -73
- package/src/components/Tooltip/styles.ts +77 -77
- package/src/hooks/useCountries.ts +41 -41
- package/src/hooks/useHasHover.ts +21 -0
- package/src/hooks/useImageUpload.ts +139 -139
- package/src/hooks/useMediaQuery.ts +19 -0
- package/src/hooks/useOnClickOutside.tsx +42 -42
- package/src/index.tsx +72 -72
- package/src/styles/index.ts +41 -41
- package/src/types/typographyValues.ts +178 -178
- package/src/utils/getNestedValue.ts +3 -3
- package/src/utils/states.ts +29 -29
- package/src/utils/uploadService.ts +180 -180
- package/tsconfig.json +3 -3
- package/tsup.config.ts +38 -38
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
|
|
146
|
+
var Fragment8 = 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 =
|
|
205
|
+
exports.Fragment = Fragment8;
|
|
206
206
|
exports.Lazy = Lazy;
|
|
207
207
|
exports.Memo = Memo;
|
|
208
208
|
exports.Portal = Portal;
|
|
@@ -420,7 +420,7 @@ var require_factoryWithTypeCheckers = __commonJS({
|
|
|
420
420
|
function emptyFunctionThatReturnsNull() {
|
|
421
421
|
return null;
|
|
422
422
|
}
|
|
423
|
-
module.exports = function(
|
|
423
|
+
module.exports = function(isValidElement2, throwOnDirectAccess) {
|
|
424
424
|
var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
|
|
425
425
|
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
|
426
426
|
function getIteratorFn(maybeIterable) {
|
|
@@ -548,7 +548,7 @@ var require_factoryWithTypeCheckers = __commonJS({
|
|
|
548
548
|
function createElementTypeChecker() {
|
|
549
549
|
function validate(props, propName, componentName, location, propFullName) {
|
|
550
550
|
var propValue = props[propName];
|
|
551
|
-
if (!
|
|
551
|
+
if (!isValidElement2(propValue)) {
|
|
552
552
|
var propType = getPropType(propValue);
|
|
553
553
|
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement."));
|
|
554
554
|
}
|
|
@@ -736,7 +736,7 @@ var require_factoryWithTypeCheckers = __commonJS({
|
|
|
736
736
|
if (Array.isArray(propValue)) {
|
|
737
737
|
return propValue.every(isNode);
|
|
738
738
|
}
|
|
739
|
-
if (propValue === null ||
|
|
739
|
+
if (propValue === null || isValidElement2(propValue)) {
|
|
740
740
|
return true;
|
|
741
741
|
}
|
|
742
742
|
var iteratorFn = getIteratorFn(propValue);
|
|
@@ -3760,7 +3760,8 @@ var ModalTitleStyled = styled(ModalRadix.Title, {
|
|
|
3760
3760
|
fontSize: "$18",
|
|
3761
3761
|
fontWeight: "medium",
|
|
3762
3762
|
fontStyle: "normal",
|
|
3763
|
-
textTransform: "uppercase"
|
|
3763
|
+
textTransform: "uppercase",
|
|
3764
|
+
width: "calc(100% - 48px)"
|
|
3764
3765
|
});
|
|
3765
3766
|
function Modal(_a) {
|
|
3766
3767
|
var _b = _a, {
|
|
@@ -3768,13 +3769,21 @@ function Modal(_a) {
|
|
|
3768
3769
|
title,
|
|
3769
3770
|
trigger,
|
|
3770
3771
|
zIndex,
|
|
3771
|
-
maxWidth
|
|
3772
|
+
maxWidth,
|
|
3773
|
+
maxHeight,
|
|
3774
|
+
height,
|
|
3775
|
+
preventAutoFocus = false,
|
|
3776
|
+
fitContent = false
|
|
3772
3777
|
} = _b, props = __objRest(_b, [
|
|
3773
3778
|
"children",
|
|
3774
3779
|
"title",
|
|
3775
3780
|
"trigger",
|
|
3776
3781
|
"zIndex",
|
|
3777
|
-
"maxWidth"
|
|
3782
|
+
"maxWidth",
|
|
3783
|
+
"maxHeight",
|
|
3784
|
+
"height",
|
|
3785
|
+
"preventAutoFocus",
|
|
3786
|
+
"fitContent"
|
|
3778
3787
|
]);
|
|
3779
3788
|
const { onOpenChange } = props;
|
|
3780
3789
|
return /* @__PURE__ */ jsxs5(ModalRadix.Root, __spreadProps(__spreadValues({}, props), { children: [
|
|
@@ -3788,9 +3797,14 @@ function Modal(_a) {
|
|
|
3788
3797
|
children: /* @__PURE__ */ jsxs5(
|
|
3789
3798
|
ModalContentStyled,
|
|
3790
3799
|
{
|
|
3791
|
-
|
|
3792
|
-
|
|
3800
|
+
onOpenAutoFocus: (event) => {
|
|
3801
|
+
if (preventAutoFocus) {
|
|
3802
|
+
event.preventDefault();
|
|
3803
|
+
}
|
|
3793
3804
|
},
|
|
3805
|
+
css: __spreadValues(__spreadValues(__spreadValues({
|
|
3806
|
+
maxWidth
|
|
3807
|
+
}, maxHeight !== void 0 && { maxHeight }), height !== void 0 && { height }), fitContent && height === void 0 && { height: "fit-content" }),
|
|
3794
3808
|
children: [
|
|
3795
3809
|
title && /* @__PURE__ */ jsxs5(ModalHeaderStyled, { children: [
|
|
3796
3810
|
/* @__PURE__ */ jsx13(ModalTitleStyled, { asChild: true, children: /* @__PURE__ */ jsx13(Text, { typography: "headline6", fontWeight: "medium", children: title }) }),
|
|
@@ -9919,7 +9933,26 @@ var useToast = () => {
|
|
|
9919
9933
|
};
|
|
9920
9934
|
|
|
9921
9935
|
// src/components/Tooltip/index.tsx
|
|
9936
|
+
import * as React10 from "react";
|
|
9922
9937
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
9938
|
+
|
|
9939
|
+
// src/hooks/useHasHover.ts
|
|
9940
|
+
import { useEffect as useEffect8, useState as useState9 } from "react";
|
|
9941
|
+
function useHasHover() {
|
|
9942
|
+
const [hasHover, setHasHover] = useState9(true);
|
|
9943
|
+
useEffect8(() => {
|
|
9944
|
+
const media = window.matchMedia("(hover: hover)");
|
|
9945
|
+
setHasHover(media.matches);
|
|
9946
|
+
const listener = (event) => {
|
|
9947
|
+
setHasHover(event.matches);
|
|
9948
|
+
};
|
|
9949
|
+
media.addEventListener("change", listener);
|
|
9950
|
+
return () => media.removeEventListener("change", listener);
|
|
9951
|
+
}, []);
|
|
9952
|
+
return hasHover;
|
|
9953
|
+
}
|
|
9954
|
+
|
|
9955
|
+
// src/components/Tooltip/index.tsx
|
|
9923
9956
|
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
9924
9957
|
var TooltipProvider = TooltipPrimitive.Provider;
|
|
9925
9958
|
var TooltipRoot = TooltipPrimitive.Root;
|
|
@@ -9953,23 +9986,66 @@ var TooltipContent = styled(TooltipPrimitive.Content, {
|
|
|
9953
9986
|
var TooltipArrow = styled(TooltipPrimitive.Arrow, {
|
|
9954
9987
|
fill: "$dark800"
|
|
9955
9988
|
});
|
|
9989
|
+
function mergeTouchTriggerProps(child, onToggle) {
|
|
9990
|
+
return React10.cloneElement(child, {
|
|
9991
|
+
onClick: (event) => {
|
|
9992
|
+
var _a, _b;
|
|
9993
|
+
(_b = (_a = child.props).onClick) == null ? void 0 : _b.call(_a, event);
|
|
9994
|
+
if (!event.defaultPrevented) {
|
|
9995
|
+
onToggle();
|
|
9996
|
+
}
|
|
9997
|
+
}
|
|
9998
|
+
});
|
|
9999
|
+
}
|
|
9956
10000
|
function Tooltip({
|
|
9957
10001
|
children,
|
|
9958
10002
|
content,
|
|
9959
10003
|
delayDuration = 200,
|
|
9960
|
-
side = "top"
|
|
10004
|
+
side = "top",
|
|
10005
|
+
supportMobileTap = true
|
|
9961
10006
|
}) {
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
10007
|
+
const hasHover = useHasHover();
|
|
10008
|
+
const [open, setOpen] = React10.useState(false);
|
|
10009
|
+
const isTouchToggleRef = React10.useRef(false);
|
|
10010
|
+
const useTouchBehavior = supportMobileTap && !hasHover;
|
|
10011
|
+
const handleTouchOpenChange = React10.useCallback((nextOpen) => {
|
|
10012
|
+
if (isTouchToggleRef.current) {
|
|
10013
|
+
isTouchToggleRef.current = false;
|
|
10014
|
+
return;
|
|
10015
|
+
}
|
|
10016
|
+
setOpen(nextOpen);
|
|
10017
|
+
}, []);
|
|
10018
|
+
const triggerChild = React10.useMemo(() => {
|
|
10019
|
+
if (!useTouchBehavior || !React10.isValidElement(children)) {
|
|
10020
|
+
return children;
|
|
10021
|
+
}
|
|
10022
|
+
return mergeTouchTriggerProps(
|
|
10023
|
+
children,
|
|
10024
|
+
() => {
|
|
10025
|
+
isTouchToggleRef.current = true;
|
|
10026
|
+
setOpen((prev) => !prev);
|
|
10027
|
+
}
|
|
10028
|
+
);
|
|
10029
|
+
}, [children, useTouchBehavior]);
|
|
10030
|
+
const tooltipContent = typeof content === "string" ? /* @__PURE__ */ jsx26(Text, { typography: "tooltip", color: "grey50", children: content }) : content;
|
|
10031
|
+
return /* @__PURE__ */ jsx26(TooltipProvider, { children: /* @__PURE__ */ jsxs15(
|
|
10032
|
+
TooltipRoot,
|
|
10033
|
+
__spreadProps(__spreadValues({
|
|
10034
|
+
delayDuration: useTouchBehavior ? 0 : delayDuration
|
|
10035
|
+
}, useTouchBehavior ? { open, onOpenChange: handleTouchOpenChange } : {}), {
|
|
10036
|
+
children: [
|
|
10037
|
+
/* @__PURE__ */ jsx26(TooltipTrigger, { asChild: true, children: triggerChild }),
|
|
10038
|
+
/* @__PURE__ */ jsxs15(TooltipContent, { side, sideOffset: 5, children: [
|
|
10039
|
+
tooltipContent,
|
|
10040
|
+
/* @__PURE__ */ jsx26(TooltipArrow, {})
|
|
10041
|
+
] })
|
|
10042
|
+
]
|
|
10043
|
+
})
|
|
10044
|
+
) });
|
|
9969
10045
|
}
|
|
9970
10046
|
|
|
9971
10047
|
// src/components/MultiSelect/index.tsx
|
|
9972
|
-
import
|
|
10048
|
+
import React11, { useCallback as useCallback3, useRef as useRef9, useState as useState12 } from "react";
|
|
9973
10049
|
import { DropdownMenu as DropdownMenu4, Theme as Theme3 } from "@radix-ui/themes";
|
|
9974
10050
|
import { FontAwesomeIcon as FontAwesomeIcon3 } from "@fortawesome/react-fontawesome";
|
|
9975
10051
|
import {
|
|
@@ -9977,7 +10053,23 @@ import {
|
|
|
9977
10053
|
faChevronUp as faChevronUp2,
|
|
9978
10054
|
faSquareXmark
|
|
9979
10055
|
} from "@fortawesome/free-solid-svg-icons";
|
|
9980
|
-
import { useMemo as
|
|
10056
|
+
import { useMemo as useMemo3 } from "react";
|
|
10057
|
+
|
|
10058
|
+
// src/hooks/useMediaQuery.ts
|
|
10059
|
+
import { useEffect as useEffect9, useState as useState11 } from "react";
|
|
10060
|
+
function useMediaQuery(query) {
|
|
10061
|
+
const [matches, setMatches] = useState11(
|
|
10062
|
+
() => typeof window !== "undefined" ? window.matchMedia(query).matches : false
|
|
10063
|
+
);
|
|
10064
|
+
useEffect9(() => {
|
|
10065
|
+
const media = window.matchMedia(query);
|
|
10066
|
+
const listener = (event) => setMatches(event.matches);
|
|
10067
|
+
setMatches(media.matches);
|
|
10068
|
+
media.addEventListener("change", listener);
|
|
10069
|
+
return () => media.removeEventListener("change", listener);
|
|
10070
|
+
}, [query]);
|
|
10071
|
+
return matches;
|
|
10072
|
+
}
|
|
9981
10073
|
|
|
9982
10074
|
// src/components/MultiSelect/styledComponents.ts
|
|
9983
10075
|
import { DropdownMenu as DropdownMenu3 } from "@radix-ui/themes";
|
|
@@ -10090,6 +10182,19 @@ var StyledText = styled(Text, {
|
|
|
10090
10182
|
whiteSpace: "nowrap",
|
|
10091
10183
|
textOverflow: "ellipsis"
|
|
10092
10184
|
});
|
|
10185
|
+
var StyledSectionDivider = styled("div", {
|
|
10186
|
+
borderBottom: "1px solid #CFCFCF",
|
|
10187
|
+
margin: "0 16px"
|
|
10188
|
+
});
|
|
10189
|
+
var StyledSectionTitle = styled(Text, {
|
|
10190
|
+
padding: "$8 $16 $4"
|
|
10191
|
+
});
|
|
10192
|
+
var StyledModalOptionsWrapper = styled("div", {
|
|
10193
|
+
overflowY: "auto",
|
|
10194
|
+
padding: "$16 0",
|
|
10195
|
+
width: "100%",
|
|
10196
|
+
boxSizing: "border-box"
|
|
10197
|
+
});
|
|
10093
10198
|
var ButtonSelectAllStyled = styled("button", {
|
|
10094
10199
|
display: "flex !important",
|
|
10095
10200
|
alignItems: "center",
|
|
@@ -10126,13 +10231,17 @@ var ButtonSelectAllStyled = styled("button", {
|
|
|
10126
10231
|
});
|
|
10127
10232
|
|
|
10128
10233
|
// src/components/MultiSelect/index.tsx
|
|
10129
|
-
import { jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
10130
|
-
var
|
|
10234
|
+
import { Fragment as Fragment3, jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
10235
|
+
var MOBILE_MODAL_MAX_HEIGHT = "90vh";
|
|
10236
|
+
var MOBILE_MODAL_HEADER_OFFSET = "65px";
|
|
10237
|
+
var MOBILE_BREAKPOINT = "(max-width: 840px)";
|
|
10238
|
+
var MultiSelect = React11.forwardRef(
|
|
10131
10239
|
({
|
|
10132
10240
|
placeholder,
|
|
10133
10241
|
value: selectedValues = [],
|
|
10134
10242
|
onValueChange,
|
|
10135
|
-
options,
|
|
10243
|
+
options = [],
|
|
10244
|
+
optionsBySection,
|
|
10136
10245
|
color,
|
|
10137
10246
|
width = "100%",
|
|
10138
10247
|
zIndex = "auto",
|
|
@@ -10146,52 +10255,64 @@ var MultiSelect = React10.forwardRef(
|
|
|
10146
10255
|
selectedScroll = false,
|
|
10147
10256
|
showMoreButton = false,
|
|
10148
10257
|
showMoreButtonLabel = "Carregar mais",
|
|
10149
|
-
showMoreButtonOnClick
|
|
10258
|
+
showMoreButtonOnClick,
|
|
10259
|
+
helperTextAfterField = ""
|
|
10150
10260
|
}, fowardedRef) => {
|
|
10151
|
-
const [isOpen, setIsOpen] =
|
|
10152
|
-
const triggerRef =
|
|
10153
|
-
const [allOptionsSelected, setAllOptionsSelected] =
|
|
10154
|
-
const
|
|
10155
|
-
|
|
10261
|
+
const [isOpen, setIsOpen] = useState12(false);
|
|
10262
|
+
const triggerRef = useRef9(null);
|
|
10263
|
+
const [allOptionsSelected, setAllOptionsSelected] = useState12(false);
|
|
10264
|
+
const isMobile = useMediaQuery(MOBILE_BREAKPOINT);
|
|
10265
|
+
const hasSections = !!(optionsBySection == null ? void 0 : optionsBySection.length);
|
|
10266
|
+
const resolvedOptions = useMemo3(() => {
|
|
10267
|
+
if (hasSections) {
|
|
10268
|
+
return optionsBySection.reduce(
|
|
10269
|
+
(acc, section) => acc.concat(section.options),
|
|
10270
|
+
[]
|
|
10271
|
+
);
|
|
10272
|
+
}
|
|
10273
|
+
return options;
|
|
10274
|
+
}, [hasSections, options, optionsBySection]);
|
|
10275
|
+
const labelByValue = useMemo3(() => {
|
|
10276
|
+
return resolvedOptions.reduce((prev, curr) => {
|
|
10156
10277
|
return __spreadProps(__spreadValues({}, prev), {
|
|
10157
10278
|
[curr.value]: curr.label
|
|
10158
10279
|
});
|
|
10159
10280
|
}, {});
|
|
10160
|
-
}, [
|
|
10161
|
-
const handleRemove =
|
|
10281
|
+
}, [resolvedOptions]);
|
|
10282
|
+
const handleRemove = useCallback3(
|
|
10162
10283
|
(value) => {
|
|
10163
10284
|
const newValue = selectedValues.filter((v) => v !== value);
|
|
10164
10285
|
onValueChange == null ? void 0 : onValueChange(newValue);
|
|
10165
10286
|
},
|
|
10166
10287
|
[selectedValues, onValueChange]
|
|
10167
10288
|
);
|
|
10168
|
-
const handleSelectAll =
|
|
10289
|
+
const handleSelectAll = useCallback3(
|
|
10169
10290
|
(e) => {
|
|
10170
10291
|
e.preventDefault();
|
|
10171
10292
|
e.stopPropagation();
|
|
10172
|
-
const allSelected = selectedValues.length ===
|
|
10293
|
+
const allSelected = selectedValues.length === resolvedOptions.length;
|
|
10173
10294
|
if (allSelected) {
|
|
10174
10295
|
onValueChange == null ? void 0 : onValueChange([]);
|
|
10175
10296
|
setAllOptionsSelected(false);
|
|
10176
10297
|
} else {
|
|
10177
|
-
onValueChange == null ? void 0 : onValueChange(
|
|
10298
|
+
onValueChange == null ? void 0 : onValueChange(resolvedOptions.map((o) => o.value));
|
|
10178
10299
|
setAllOptionsSelected(true);
|
|
10179
10300
|
}
|
|
10180
10301
|
},
|
|
10181
|
-
[selectedValues,
|
|
10302
|
+
[selectedValues, resolvedOptions, onValueChange]
|
|
10182
10303
|
);
|
|
10183
|
-
const text =
|
|
10304
|
+
const text = useMemo3(() => {
|
|
10184
10305
|
if (selectedValues.length > 0 && singleSelect) {
|
|
10185
10306
|
const value = selectedValues[0];
|
|
10186
10307
|
return labelByValue[value];
|
|
10187
10308
|
}
|
|
10188
10309
|
return placeholder != null ? placeholder : "Selecione";
|
|
10189
|
-
}, [selectedValues, placeholder, singleSelect]);
|
|
10310
|
+
}, [selectedValues, placeholder, singleSelect, labelByValue]);
|
|
10190
10311
|
const handleItemClick = (v) => {
|
|
10191
10312
|
onValueChange == null ? void 0 : onValueChange([v]);
|
|
10192
10313
|
setIsOpen(false);
|
|
10193
10314
|
};
|
|
10194
|
-
const handleToggle =
|
|
10315
|
+
const handleToggle = useCallback3(
|
|
10195
10316
|
(e) => {
|
|
10196
10317
|
e.preventDefault();
|
|
10197
10318
|
e.stopPropagation();
|
|
@@ -10200,43 +10321,153 @@ var MultiSelect = React10.forwardRef(
|
|
|
10200
10321
|
},
|
|
10201
10322
|
[disabled]
|
|
10202
10323
|
);
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
|
|
10206
|
-
|
|
10324
|
+
const triggerElement = /* @__PURE__ */ jsxs16(
|
|
10325
|
+
StyledTrigger,
|
|
10326
|
+
{
|
|
10327
|
+
ref: (r) => {
|
|
10328
|
+
if (!r) return;
|
|
10329
|
+
triggerRef.current = r;
|
|
10330
|
+
if (fowardedRef) {
|
|
10331
|
+
if (typeof fowardedRef === "function") fowardedRef(r);
|
|
10332
|
+
else fowardedRef.current = r;
|
|
10333
|
+
}
|
|
10334
|
+
},
|
|
10335
|
+
color,
|
|
10336
|
+
disabled,
|
|
10337
|
+
style: width !== "100%" ? { width } : void 0,
|
|
10338
|
+
onClick: !isMobile ? handleToggle : void 0,
|
|
10339
|
+
children: [
|
|
10340
|
+
/* @__PURE__ */ jsx27(
|
|
10341
|
+
StyledText,
|
|
10342
|
+
{
|
|
10343
|
+
typography: "labelMedium",
|
|
10344
|
+
color: disabled ? "dark400" : void 0,
|
|
10345
|
+
children: text
|
|
10346
|
+
}
|
|
10347
|
+
),
|
|
10348
|
+
/* @__PURE__ */ jsx27(
|
|
10349
|
+
FontAwesomeIcon3,
|
|
10350
|
+
{
|
|
10351
|
+
icon: isOpen ? faChevronUp2 : faChevronDown2,
|
|
10352
|
+
size: "sm",
|
|
10353
|
+
color: disabled ? colors.dark400 : colors.dark600
|
|
10354
|
+
}
|
|
10355
|
+
)
|
|
10356
|
+
]
|
|
10357
|
+
}
|
|
10358
|
+
);
|
|
10359
|
+
const selectAllBlock = selectedAllOptions && /* @__PURE__ */ jsxs16(Fragment3, { children: [
|
|
10360
|
+
/* @__PURE__ */ jsxs16(
|
|
10361
|
+
ButtonSelectAllStyled,
|
|
10362
|
+
{
|
|
10363
|
+
css: itemStyle,
|
|
10364
|
+
onClick: (e) => {
|
|
10365
|
+
handleSelectAll(e);
|
|
10366
|
+
setIsOpen(false);
|
|
10367
|
+
},
|
|
10368
|
+
type: "button",
|
|
10369
|
+
children: [
|
|
10370
|
+
/* @__PURE__ */ jsx27("div", { className: allOptionsSelected ? "checked" : "" }),
|
|
10371
|
+
/* @__PURE__ */ jsx27(Text, { typography: "labelSmall", children: selectedAllText ? selectedAllText : "Selecionar Todos" })
|
|
10372
|
+
]
|
|
10373
|
+
}
|
|
10374
|
+
),
|
|
10375
|
+
/* @__PURE__ */ jsx27(StyledSectionDivider, {})
|
|
10376
|
+
] });
|
|
10377
|
+
const showMoreButtonBlock = showMoreButton && showMoreButtonOnClick && /* @__PURE__ */ jsx27(
|
|
10378
|
+
Button,
|
|
10379
|
+
{
|
|
10380
|
+
variant: "menuDropdownItem",
|
|
10381
|
+
color: "brand",
|
|
10382
|
+
onClick: showMoreButtonOnClick,
|
|
10383
|
+
fontWeight: "semibold",
|
|
10384
|
+
type: "button",
|
|
10385
|
+
css: {
|
|
10386
|
+
justifyContent: "flex-start",
|
|
10387
|
+
color: "var(--colors-brand500)!important"
|
|
10388
|
+
},
|
|
10389
|
+
children: showMoreButtonLabel
|
|
10390
|
+
}
|
|
10391
|
+
);
|
|
10392
|
+
const renderCheckboxOptions = () => {
|
|
10393
|
+
if (hasSections) {
|
|
10394
|
+
return optionsBySection.map((section, sectionIndex) => /* @__PURE__ */ jsxs16(React11.Fragment, { children: [
|
|
10395
|
+
sectionIndex > 0 && /* @__PURE__ */ jsx27(StyledSectionDivider, {}),
|
|
10396
|
+
/* @__PURE__ */ jsx27(StyledSectionTitle, { typography: "labelSmall", fontWeight: "semibold", color: "dark600", children: section.name }),
|
|
10397
|
+
section.options.map(({ value, label }, i) => /* @__PURE__ */ jsx27(CheckboxItem, { value, css: itemStyle, children: /* @__PURE__ */ jsx27(Text, { typography: "labelSmall", children: label }) }, `${section.name}-${i}`))
|
|
10398
|
+
] }, section.name));
|
|
10399
|
+
}
|
|
10400
|
+
return resolvedOptions.map(({ value, label }, i) => /* @__PURE__ */ jsx27(CheckboxItem, { value, css: itemStyle, children: /* @__PURE__ */ jsx27(Text, { typography: "labelSmall", children: label }) }, i));
|
|
10401
|
+
};
|
|
10402
|
+
const renderSingleSelectOptions = () => {
|
|
10403
|
+
if (hasSections) {
|
|
10404
|
+
return optionsBySection.map((section, sectionIndex) => /* @__PURE__ */ jsxs16(React11.Fragment, { children: [
|
|
10405
|
+
sectionIndex > 0 && /* @__PURE__ */ jsx27(StyledSectionDivider, {}),
|
|
10406
|
+
/* @__PURE__ */ jsx27(StyledSectionTitle, { typography: "labelSmall", fontWeight: "semibold", color: "dark600", children: section.name }),
|
|
10407
|
+
section.options.map(({ value, label }, i) => /* @__PURE__ */ jsx27(StyledItem2, { onClick: () => handleItemClick(value), children: /* @__PURE__ */ jsx27(Text, { typography: "labelSmall", children: label }) }, `${section.name}-${i}`))
|
|
10408
|
+
] }, section.name));
|
|
10409
|
+
}
|
|
10410
|
+
return resolvedOptions.map(({ value, label }, i) => /* @__PURE__ */ jsx27(StyledItem2, { onClick: () => handleItemClick(value), children: /* @__PURE__ */ jsx27(Text, { typography: "labelSmall", children: label }) }, i));
|
|
10411
|
+
};
|
|
10412
|
+
const optionsContent = !singleSelect ? /* @__PURE__ */ jsx27(
|
|
10413
|
+
CheckboxGroup,
|
|
10414
|
+
{
|
|
10415
|
+
value: selectedValues,
|
|
10416
|
+
onValueChange: (v) => {
|
|
10417
|
+
onValueChange == null ? void 0 : onValueChange(v);
|
|
10418
|
+
setAllOptionsSelected((v || []).length === resolvedOptions.length);
|
|
10419
|
+
},
|
|
10420
|
+
children: /* @__PURE__ */ jsxs16(
|
|
10421
|
+
StyledFlexWithMaxHeight,
|
|
10207
10422
|
{
|
|
10208
|
-
|
|
10209
|
-
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
if (typeof fowardedRef === "function") fowardedRef(r);
|
|
10213
|
-
else fowardedRef.current = r;
|
|
10214
|
-
}
|
|
10215
|
-
},
|
|
10216
|
-
color,
|
|
10217
|
-
disabled,
|
|
10218
|
-
style: width !== "100%" ? { width } : void 0,
|
|
10219
|
-
onClick: handleToggle,
|
|
10423
|
+
direction: "column",
|
|
10424
|
+
gap: 8,
|
|
10425
|
+
hasMaxHeight: !!maxHeight && !isMobile,
|
|
10426
|
+
style: maxHeight && !isMobile ? { maxHeight } : void 0,
|
|
10220
10427
|
children: [
|
|
10221
|
-
|
|
10222
|
-
|
|
10223
|
-
|
|
10224
|
-
typography: "labelMedium",
|
|
10225
|
-
color: disabled ? "dark400" : void 0,
|
|
10226
|
-
children: text
|
|
10227
|
-
}
|
|
10228
|
-
),
|
|
10229
|
-
/* @__PURE__ */ jsx27(
|
|
10230
|
-
FontAwesomeIcon3,
|
|
10231
|
-
{
|
|
10232
|
-
icon: isOpen ? faChevronUp2 : faChevronDown2,
|
|
10233
|
-
size: "sm",
|
|
10234
|
-
color: disabled ? colors.dark400 : colors.dark600
|
|
10235
|
-
}
|
|
10236
|
-
)
|
|
10428
|
+
selectAllBlock,
|
|
10429
|
+
renderCheckboxOptions(),
|
|
10430
|
+
showMoreButtonBlock
|
|
10237
10431
|
]
|
|
10238
10432
|
}
|
|
10239
|
-
)
|
|
10433
|
+
)
|
|
10434
|
+
}
|
|
10435
|
+
) : /* @__PURE__ */ jsxs16(
|
|
10436
|
+
StyledFlexWithMaxHeight,
|
|
10437
|
+
{
|
|
10438
|
+
direction: "column",
|
|
10439
|
+
gap: 8,
|
|
10440
|
+
hasMaxHeight: !!maxHeight && !isMobile,
|
|
10441
|
+
style: maxHeight && !isMobile ? { maxHeight } : void 0,
|
|
10442
|
+
children: [
|
|
10443
|
+
renderSingleSelectOptions(),
|
|
10444
|
+
showMoreButtonBlock
|
|
10445
|
+
]
|
|
10446
|
+
}
|
|
10447
|
+
);
|
|
10448
|
+
const modalZIndex = zIndex === "auto" ? void 0 : Number(zIndex);
|
|
10449
|
+
return /* @__PURE__ */ jsxs16(Theme3, { style: width !== "100%" ? { width } : void 0, children: [
|
|
10450
|
+
isMobile ? /* @__PURE__ */ jsx27(
|
|
10451
|
+
Modal,
|
|
10452
|
+
{
|
|
10453
|
+
open: disabled ? false : isOpen,
|
|
10454
|
+
onOpenChange: (open) => !disabled && setIsOpen(open),
|
|
10455
|
+
trigger: triggerElement,
|
|
10456
|
+
title: placeholder != null ? placeholder : "Selecione",
|
|
10457
|
+
maxHeight: MOBILE_MODAL_MAX_HEIGHT,
|
|
10458
|
+
zIndex: modalZIndex,
|
|
10459
|
+
preventAutoFocus: true,
|
|
10460
|
+
fitContent: true,
|
|
10461
|
+
children: /* @__PURE__ */ jsx27(
|
|
10462
|
+
StyledModalOptionsWrapper,
|
|
10463
|
+
{
|
|
10464
|
+
css: { maxHeight: `calc(${MOBILE_MODAL_MAX_HEIGHT} - ${MOBILE_MODAL_HEADER_OFFSET})` },
|
|
10465
|
+
children: optionsContent
|
|
10466
|
+
}
|
|
10467
|
+
)
|
|
10468
|
+
}
|
|
10469
|
+
) : /* @__PURE__ */ jsxs16(DropdownMenu4.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
|
|
10470
|
+
/* @__PURE__ */ jsx27(DropdownMenu4.Trigger, { children: triggerElement }),
|
|
10240
10471
|
/* @__PURE__ */ jsx27(
|
|
10241
10472
|
StyledContent,
|
|
10242
10473
|
{
|
|
@@ -10244,158 +10475,85 @@ var MultiSelect = React10.forwardRef(
|
|
|
10244
10475
|
width: "100%",
|
|
10245
10476
|
zIndex: zIndex === "auto" ? 999999 : zIndex
|
|
10246
10477
|
},
|
|
10247
|
-
children:
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
selectedAllOptions && /* @__PURE__ */ jsxs16(
|
|
10264
|
-
ButtonSelectAllStyled,
|
|
10265
|
-
{
|
|
10266
|
-
css: itemStyle,
|
|
10267
|
-
onClick: (e) => {
|
|
10268
|
-
handleSelectAll(e), setIsOpen(false);
|
|
10269
|
-
},
|
|
10270
|
-
type: "button",
|
|
10271
|
-
children: [
|
|
10272
|
-
/* @__PURE__ */ jsx27("div", { className: allOptionsSelected ? "checked" : "" }),
|
|
10273
|
-
/* @__PURE__ */ jsx27(Text, { typography: "labelSmall", children: selectedAllText ? selectedAllText : "Selecionar Todos" })
|
|
10274
|
-
]
|
|
10275
|
-
}
|
|
10276
|
-
),
|
|
10277
|
-
options.map(({ value, label }, i) => /* @__PURE__ */ jsx27(CheckboxItem, { value, css: itemStyle, children: /* @__PURE__ */ jsx27(Text, { typography: "labelSmall", children: label }) }, i)),
|
|
10278
|
-
showMoreButton && showMoreButtonOnClick && /* @__PURE__ */ jsx27(
|
|
10279
|
-
Button,
|
|
10280
|
-
{
|
|
10281
|
-
variant: "menuDropdownItem",
|
|
10282
|
-
color: "brand",
|
|
10283
|
-
onClick: showMoreButtonOnClick,
|
|
10284
|
-
fontWeight: "semibold",
|
|
10285
|
-
type: "button",
|
|
10286
|
-
css: {
|
|
10287
|
-
justifyContent: "flex-start",
|
|
10288
|
-
color: "var(--colors-brand500)!important"
|
|
10289
|
-
},
|
|
10290
|
-
children: showMoreButtonLabel
|
|
10291
|
-
}
|
|
10292
|
-
)
|
|
10293
|
-
]
|
|
10294
|
-
}
|
|
10295
|
-
)
|
|
10296
|
-
}
|
|
10297
|
-
) : /* @__PURE__ */ jsxs16(
|
|
10298
|
-
StyledFlexWithMaxHeight,
|
|
10478
|
+
children: optionsContent
|
|
10479
|
+
}
|
|
10480
|
+
)
|
|
10481
|
+
] }),
|
|
10482
|
+
/* @__PURE__ */ jsxs16("div", { style: { padding: "4px 8px 0 0" }, children: [
|
|
10483
|
+
helperTextAfterField && /* @__PURE__ */ jsx27(Text, { typography: "captionMedium", fontWeight: "regular", color: "dark600", children: helperTextAfterField }),
|
|
10484
|
+
selectedValues.length > 0 && showSelectedValues && /* @__PURE__ */ jsx27(
|
|
10485
|
+
StyledFlexSelectedItems,
|
|
10486
|
+
{
|
|
10487
|
+
direction: selectedOrientation,
|
|
10488
|
+
gap: 8,
|
|
10489
|
+
align: selectedOrientation === "column" ? "start" : "center",
|
|
10490
|
+
justify: "start",
|
|
10491
|
+
css: __spreadValues({}, selectedScroll && { maxHeight: maxHeight || "400px" }),
|
|
10492
|
+
children: allOptionsSelected ? /* @__PURE__ */ jsxs16(
|
|
10493
|
+
Flex,
|
|
10299
10494
|
{
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
style: maxHeight ? { maxHeight } : void 0,
|
|
10495
|
+
gap: 4,
|
|
10496
|
+
align: "center",
|
|
10497
|
+
css: { flexWrap: "wrap" },
|
|
10304
10498
|
children: [
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
Button,
|
|
10499
|
+
/* @__PURE__ */ jsx27(
|
|
10500
|
+
CloseBtnStyled,
|
|
10308
10501
|
{
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10502
|
+
onClick: (e) => {
|
|
10503
|
+
e.stopPropagation();
|
|
10504
|
+
onValueChange == null ? void 0 : onValueChange([]);
|
|
10505
|
+
setAllOptionsSelected(false);
|
|
10506
|
+
},
|
|
10313
10507
|
type: "button",
|
|
10314
|
-
|
|
10315
|
-
|
|
10316
|
-
|
|
10508
|
+
children: /* @__PURE__ */ jsx27(FontAwesomeIcon3, { icon: faSquareXmark, size: "sm" })
|
|
10509
|
+
}
|
|
10510
|
+
),
|
|
10511
|
+
/* @__PURE__ */ jsx27(
|
|
10512
|
+
Text,
|
|
10513
|
+
{
|
|
10514
|
+
typography: "captionMedium",
|
|
10515
|
+
fontWeight: "regular",
|
|
10516
|
+
color: "dark600",
|
|
10517
|
+
children: "Todos selecionados"
|
|
10518
|
+
}
|
|
10519
|
+
)
|
|
10520
|
+
]
|
|
10521
|
+
},
|
|
10522
|
+
"all-selected"
|
|
10523
|
+
) : selectedValues.map((value) => /* @__PURE__ */ jsxs16(
|
|
10524
|
+
Flex,
|
|
10525
|
+
{
|
|
10526
|
+
gap: 4,
|
|
10527
|
+
align: "center",
|
|
10528
|
+
css: { flexWrap: "wrap" },
|
|
10529
|
+
children: [
|
|
10530
|
+
/* @__PURE__ */ jsx27(
|
|
10531
|
+
CloseBtnStyled,
|
|
10532
|
+
{
|
|
10533
|
+
onClick: (e) => {
|
|
10534
|
+
e.stopPropagation();
|
|
10535
|
+
handleRemove(value);
|
|
10317
10536
|
},
|
|
10318
|
-
|
|
10537
|
+
type: "button",
|
|
10538
|
+
children: /* @__PURE__ */ jsx27(FontAwesomeIcon3, { icon: faSquareXmark, size: "sm" })
|
|
10539
|
+
}
|
|
10540
|
+
),
|
|
10541
|
+
/* @__PURE__ */ jsx27(
|
|
10542
|
+
Text,
|
|
10543
|
+
{
|
|
10544
|
+
typography: "captionMedium",
|
|
10545
|
+
fontWeight: "regular",
|
|
10546
|
+
color: "dark600",
|
|
10547
|
+
children: labelByValue[value]
|
|
10319
10548
|
}
|
|
10320
10549
|
)
|
|
10321
10550
|
]
|
|
10322
|
-
}
|
|
10323
|
-
|
|
10551
|
+
},
|
|
10552
|
+
value
|
|
10553
|
+
))
|
|
10324
10554
|
}
|
|
10325
10555
|
)
|
|
10326
|
-
] })
|
|
10327
|
-
selectedValues.length > 0 && showSelectedValues && /* @__PURE__ */ jsx27(
|
|
10328
|
-
StyledFlexSelectedItems,
|
|
10329
|
-
{
|
|
10330
|
-
direction: selectedOrientation,
|
|
10331
|
-
gap: 8,
|
|
10332
|
-
align: selectedOrientation === "column" ? "start" : "center",
|
|
10333
|
-
justify: "start",
|
|
10334
|
-
css: __spreadValues({}, selectedScroll && { maxHeight: maxHeight || "400px" }),
|
|
10335
|
-
children: allOptionsSelected ? /* @__PURE__ */ jsxs16(
|
|
10336
|
-
Flex,
|
|
10337
|
-
{
|
|
10338
|
-
gap: 4,
|
|
10339
|
-
align: "center",
|
|
10340
|
-
css: { flexWrap: "wrap" },
|
|
10341
|
-
children: [
|
|
10342
|
-
/* @__PURE__ */ jsx27(
|
|
10343
|
-
CloseBtnStyled,
|
|
10344
|
-
{
|
|
10345
|
-
onClick: (e) => {
|
|
10346
|
-
e.stopPropagation();
|
|
10347
|
-
onValueChange == null ? void 0 : onValueChange([]);
|
|
10348
|
-
setAllOptionsSelected(false);
|
|
10349
|
-
},
|
|
10350
|
-
type: "button",
|
|
10351
|
-
children: /* @__PURE__ */ jsx27(FontAwesomeIcon3, { icon: faSquareXmark, size: "sm" })
|
|
10352
|
-
}
|
|
10353
|
-
),
|
|
10354
|
-
/* @__PURE__ */ jsx27(
|
|
10355
|
-
Text,
|
|
10356
|
-
{
|
|
10357
|
-
typography: "captionMedium",
|
|
10358
|
-
fontWeight: "regular",
|
|
10359
|
-
color: "dark600",
|
|
10360
|
-
children: "Todos selecionados"
|
|
10361
|
-
}
|
|
10362
|
-
)
|
|
10363
|
-
]
|
|
10364
|
-
},
|
|
10365
|
-
"all-selected"
|
|
10366
|
-
) : selectedValues.map((value) => /* @__PURE__ */ jsxs16(
|
|
10367
|
-
Flex,
|
|
10368
|
-
{
|
|
10369
|
-
gap: 4,
|
|
10370
|
-
align: "center",
|
|
10371
|
-
css: { flexWrap: "wrap" },
|
|
10372
|
-
children: [
|
|
10373
|
-
/* @__PURE__ */ jsx27(
|
|
10374
|
-
CloseBtnStyled,
|
|
10375
|
-
{
|
|
10376
|
-
onClick: (e) => {
|
|
10377
|
-
e.stopPropagation();
|
|
10378
|
-
handleRemove(value);
|
|
10379
|
-
},
|
|
10380
|
-
type: "button",
|
|
10381
|
-
children: /* @__PURE__ */ jsx27(FontAwesomeIcon3, { icon: faSquareXmark, size: "sm" })
|
|
10382
|
-
}
|
|
10383
|
-
),
|
|
10384
|
-
/* @__PURE__ */ jsx27(
|
|
10385
|
-
Text,
|
|
10386
|
-
{
|
|
10387
|
-
typography: "captionMedium",
|
|
10388
|
-
fontWeight: "regular",
|
|
10389
|
-
color: "dark600",
|
|
10390
|
-
children: labelByValue[value]
|
|
10391
|
-
}
|
|
10392
|
-
)
|
|
10393
|
-
]
|
|
10394
|
-
},
|
|
10395
|
-
value
|
|
10396
|
-
))
|
|
10397
|
-
}
|
|
10398
|
-
)
|
|
10556
|
+
] })
|
|
10399
10557
|
] });
|
|
10400
10558
|
}
|
|
10401
10559
|
);
|
|
@@ -10408,8 +10566,8 @@ var Divider = styled("div", {
|
|
|
10408
10566
|
});
|
|
10409
10567
|
|
|
10410
10568
|
// src/components/ToggleElement/index.tsx
|
|
10411
|
-
import { useState as
|
|
10412
|
-
import { Fragment as
|
|
10569
|
+
import { useState as useState13 } from "react";
|
|
10570
|
+
import { Fragment as Fragment4, jsx as jsx28, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
10413
10571
|
function ToggleElement({
|
|
10414
10572
|
children,
|
|
10415
10573
|
label,
|
|
@@ -10420,7 +10578,7 @@ function ToggleElement({
|
|
|
10420
10578
|
buttonProps,
|
|
10421
10579
|
onOpenChange
|
|
10422
10580
|
}) {
|
|
10423
|
-
const [internalOpen, setInternalOpen] =
|
|
10581
|
+
const [internalOpen, setInternalOpen] = useState13(defaultOpen);
|
|
10424
10582
|
const isControlled = open !== void 0;
|
|
10425
10583
|
const isOpen = isControlled ? open : internalOpen;
|
|
10426
10584
|
const handleClick = () => {
|
|
@@ -10430,7 +10588,7 @@ function ToggleElement({
|
|
|
10430
10588
|
}
|
|
10431
10589
|
onOpenChange == null ? void 0 : onOpenChange(nextOpen);
|
|
10432
10590
|
};
|
|
10433
|
-
return /* @__PURE__ */ jsxs17(
|
|
10591
|
+
return /* @__PURE__ */ jsxs17(Fragment4, { children: [
|
|
10434
10592
|
(!isOpen || !hideButtonWhenOpen) && /* @__PURE__ */ jsxs17(
|
|
10435
10593
|
Button,
|
|
10436
10594
|
__spreadProps(__spreadValues({
|
|
@@ -10744,7 +10902,7 @@ var TextAreaFormField = (_a) => {
|
|
|
10744
10902
|
import {
|
|
10745
10903
|
useController
|
|
10746
10904
|
} from "react-hook-form";
|
|
10747
|
-
import { useCallback as
|
|
10905
|
+
import { useCallback as useCallback4, useMemo as useMemo4 } from "react";
|
|
10748
10906
|
import { format as format3, unformat as unformat2 } from "@react-input/mask";
|
|
10749
10907
|
import { jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
10750
10908
|
var TextFormField = (_a) => {
|
|
@@ -10767,7 +10925,7 @@ var TextFormField = (_a) => {
|
|
|
10767
10925
|
"onChange",
|
|
10768
10926
|
"valueFormatter"
|
|
10769
10927
|
]);
|
|
10770
|
-
const handleValidate =
|
|
10928
|
+
const handleValidate = useCallback4(
|
|
10771
10929
|
(value) => {
|
|
10772
10930
|
var _a2;
|
|
10773
10931
|
if (value === void 0 || value === null || !required && value.trim() === "")
|
|
@@ -10789,7 +10947,7 @@ var TextFormField = (_a) => {
|
|
|
10789
10947
|
const haveError = !!fieldError;
|
|
10790
10948
|
const errorMsg = fieldError == null ? void 0 : fieldError.message;
|
|
10791
10949
|
const { value: formValue, onChange: formChange } = field;
|
|
10792
|
-
const formattedValue =
|
|
10950
|
+
const formattedValue = useMemo4(() => {
|
|
10793
10951
|
let value = formValue;
|
|
10794
10952
|
if (valueFormatter) value = valueFormatter.format(value);
|
|
10795
10953
|
if (mask) value = format3(value != null ? value : "", mask);
|
|
@@ -11385,14 +11543,14 @@ var brazilianStates = [
|
|
|
11385
11543
|
];
|
|
11386
11544
|
|
|
11387
11545
|
// src/components/FormFields/AddressFormFields/StateFormField.tsx
|
|
11388
|
-
import { Fragment as
|
|
11546
|
+
import { Fragment as Fragment5, jsx as jsx46 } from "react/jsx-runtime";
|
|
11389
11547
|
function StateFormField({
|
|
11390
11548
|
name,
|
|
11391
11549
|
label,
|
|
11392
11550
|
required,
|
|
11393
11551
|
isBrazil
|
|
11394
11552
|
}) {
|
|
11395
|
-
return /* @__PURE__ */ jsx46(
|
|
11553
|
+
return /* @__PURE__ */ jsx46(Fragment5, { children: isBrazil ? /* @__PURE__ */ jsx46(
|
|
11396
11554
|
SelectFormField,
|
|
11397
11555
|
{
|
|
11398
11556
|
name,
|
|
@@ -11404,9 +11562,9 @@ function StateFormField({
|
|
|
11404
11562
|
}
|
|
11405
11563
|
|
|
11406
11564
|
// src/components/FormFields/AddressFormFields/CityFormField.tsx
|
|
11407
|
-
import { useEffect as
|
|
11565
|
+
import { useEffect as useEffect10, useState as useState14 } from "react";
|
|
11408
11566
|
import { useFormContext as useFormContext5, Controller as Controller2 } from "react-hook-form";
|
|
11409
|
-
import { Fragment as
|
|
11567
|
+
import { Fragment as Fragment6, jsx as jsx47 } from "react/jsx-runtime";
|
|
11410
11568
|
function CityFormField({
|
|
11411
11569
|
name,
|
|
11412
11570
|
label,
|
|
@@ -11417,9 +11575,9 @@ function CityFormField({
|
|
|
11417
11575
|
}) {
|
|
11418
11576
|
const { control, watch } = useFormContext5();
|
|
11419
11577
|
const selectedState = watch(stateName);
|
|
11420
|
-
const [cities, setCities] =
|
|
11421
|
-
const [loading, setLoading] =
|
|
11422
|
-
|
|
11578
|
+
const [cities, setCities] = useState14([]);
|
|
11579
|
+
const [loading, setLoading] = useState14(false);
|
|
11580
|
+
useEffect10(() => {
|
|
11423
11581
|
if (!isBrazil) {
|
|
11424
11582
|
setCities([]);
|
|
11425
11583
|
return;
|
|
@@ -11458,7 +11616,7 @@ function CityFormField({
|
|
|
11458
11616
|
}
|
|
11459
11617
|
fetchCities();
|
|
11460
11618
|
}, [selectedState, isBrazil]);
|
|
11461
|
-
return /* @__PURE__ */ jsx47(
|
|
11619
|
+
return /* @__PURE__ */ jsx47(Fragment6, { children: isBrazil && cities.length > 0 ? /* @__PURE__ */ jsx47(
|
|
11462
11620
|
Controller2,
|
|
11463
11621
|
{
|
|
11464
11622
|
name,
|
|
@@ -11805,10 +11963,10 @@ var EmailFormField = ({
|
|
|
11805
11963
|
import { useController as useController3 } from "react-hook-form";
|
|
11806
11964
|
|
|
11807
11965
|
// src/components/RichEditor/RichEditor.tsx
|
|
11808
|
-
import { useEffect as
|
|
11966
|
+
import { useEffect as useEffect12, useState as useState16 } from "react";
|
|
11809
11967
|
|
|
11810
11968
|
// src/components/RichEditor/QuillComponent.tsx
|
|
11811
|
-
import { useState as
|
|
11969
|
+
import { useState as useState15, useRef as useRef10, useEffect as useEffect11, useCallback as useCallback5 } from "react";
|
|
11812
11970
|
import { useQuill } from "react-quilljs";
|
|
11813
11971
|
|
|
11814
11972
|
// src/utils/uploadService.ts
|
|
@@ -13011,12 +13169,12 @@ var QuillComponent = ({
|
|
|
13011
13169
|
onCharacterCountChange,
|
|
13012
13170
|
maxLength
|
|
13013
13171
|
}) => {
|
|
13014
|
-
const [showVideoModal, setShowVideoModal] =
|
|
13015
|
-
const [videoUrl, setVideoUrl] =
|
|
13016
|
-
const [showLinkModal, setShowLinkModal] =
|
|
13017
|
-
const [linkUrl, setLinkUrl] =
|
|
13018
|
-
const videoModalRef =
|
|
13019
|
-
const linkModalRef =
|
|
13172
|
+
const [showVideoModal, setShowVideoModal] = useState15(false);
|
|
13173
|
+
const [videoUrl, setVideoUrl] = useState15("");
|
|
13174
|
+
const [showLinkModal, setShowLinkModal] = useState15(false);
|
|
13175
|
+
const [linkUrl, setLinkUrl] = useState15("");
|
|
13176
|
+
const videoModalRef = useRef10(null);
|
|
13177
|
+
const linkModalRef = useRef10(null);
|
|
13020
13178
|
const { addToast, removeToast } = useToast();
|
|
13021
13179
|
const formatHTML = (html) => {
|
|
13022
13180
|
const parser = new DOMParser();
|
|
@@ -13035,7 +13193,7 @@ var QuillComponent = ({
|
|
|
13035
13193
|
placeholder,
|
|
13036
13194
|
readOnly: disabled
|
|
13037
13195
|
});
|
|
13038
|
-
const handleImageUpload =
|
|
13196
|
+
const handleImageUpload = useCallback5(
|
|
13039
13197
|
(file) => __async(null, null, function* () {
|
|
13040
13198
|
if (disabled || !quill || !uploadConfig) return;
|
|
13041
13199
|
try {
|
|
@@ -13067,7 +13225,7 @@ var QuillComponent = ({
|
|
|
13067
13225
|
}),
|
|
13068
13226
|
[disabled, quill, addToast, removeToast, uploadConfig, onChange]
|
|
13069
13227
|
);
|
|
13070
|
-
|
|
13228
|
+
useEffect11(() => {
|
|
13071
13229
|
if (!quill) return;
|
|
13072
13230
|
if (value !== void 0 && value !== null) {
|
|
13073
13231
|
const currentContent = quill.root.innerHTML;
|
|
@@ -13083,7 +13241,7 @@ var QuillComponent = ({
|
|
|
13083
13241
|
}
|
|
13084
13242
|
onCharacterCountChange == null ? void 0 : onCharacterCountChange(quill.getText().trim().length);
|
|
13085
13243
|
}, [quill, value, onCharacterCountChange]);
|
|
13086
|
-
|
|
13244
|
+
useEffect11(() => {
|
|
13087
13245
|
if (quill) {
|
|
13088
13246
|
quill.on("text-change", (delta, oldDelta, source) => {
|
|
13089
13247
|
if (source === "user") {
|
|
@@ -13144,7 +13302,7 @@ var QuillComponent = ({
|
|
|
13144
13302
|
}, 2e3);
|
|
13145
13303
|
}
|
|
13146
13304
|
}, [quill, onChange, handleImageUpload, onCharacterCountChange, formats]);
|
|
13147
|
-
|
|
13305
|
+
useEffect11(() => {
|
|
13148
13306
|
if (quill) {
|
|
13149
13307
|
quill.enable(!disabled);
|
|
13150
13308
|
if (!disabled) {
|
|
@@ -13155,11 +13313,11 @@ var QuillComponent = ({
|
|
|
13155
13313
|
}
|
|
13156
13314
|
}
|
|
13157
13315
|
}, [quill, disabled]);
|
|
13158
|
-
const handleLinkCancel =
|
|
13316
|
+
const handleLinkCancel = useCallback5(() => {
|
|
13159
13317
|
setLinkUrl("");
|
|
13160
13318
|
setShowLinkModal(false);
|
|
13161
13319
|
}, []);
|
|
13162
|
-
const handleLinkSubmit =
|
|
13320
|
+
const handleLinkSubmit = useCallback5(() => {
|
|
13163
13321
|
if (!linkUrl.trim() || !quill) return;
|
|
13164
13322
|
const url = linkUrl.trim();
|
|
13165
13323
|
const selection = quill.getSelection();
|
|
@@ -13174,11 +13332,11 @@ var QuillComponent = ({
|
|
|
13174
13332
|
setLinkUrl("");
|
|
13175
13333
|
setShowLinkModal(false);
|
|
13176
13334
|
}, [linkUrl, quill]);
|
|
13177
|
-
const handleVideoCancel =
|
|
13335
|
+
const handleVideoCancel = useCallback5(() => {
|
|
13178
13336
|
setVideoUrl("");
|
|
13179
13337
|
setShowVideoModal(false);
|
|
13180
13338
|
}, []);
|
|
13181
|
-
const handleVideoSubmit =
|
|
13339
|
+
const handleVideoSubmit = useCallback5(() => {
|
|
13182
13340
|
var _a, _b;
|
|
13183
13341
|
if (!videoUrl.trim() || !quill) return;
|
|
13184
13342
|
let processedUrl = videoUrl.trim();
|
|
@@ -13211,7 +13369,7 @@ var QuillComponent = ({
|
|
|
13211
13369
|
setVideoUrl("");
|
|
13212
13370
|
setShowVideoModal(false);
|
|
13213
13371
|
}, [videoUrl, quill]);
|
|
13214
|
-
|
|
13372
|
+
useEffect11(() => {
|
|
13215
13373
|
const handleClickOutside = (event) => {
|
|
13216
13374
|
if (showVideoModal && videoModalRef.current && !videoModalRef.current.contains(event.target)) {
|
|
13217
13375
|
handleVideoCancel();
|
|
@@ -13373,8 +13531,8 @@ var QuillComponent_default = QuillComponent;
|
|
|
13373
13531
|
// src/components/RichEditor/RichEditor.tsx
|
|
13374
13532
|
import { jsx as jsx54 } from "react/jsx-runtime";
|
|
13375
13533
|
var RichEditor = (props) => {
|
|
13376
|
-
const [isClient, setIsClient] =
|
|
13377
|
-
|
|
13534
|
+
const [isClient, setIsClient] = useState16(false);
|
|
13535
|
+
useEffect12(() => {
|
|
13378
13536
|
setIsClient(typeof window !== "undefined");
|
|
13379
13537
|
}, []);
|
|
13380
13538
|
if (!isClient) return null;
|
|
@@ -13396,8 +13554,8 @@ var RichTextPresenter = ({ richText }) => {
|
|
|
13396
13554
|
var RichTextPresenter_default = RichTextPresenter;
|
|
13397
13555
|
|
|
13398
13556
|
// src/components/FormFields/RichEditorFormField.tsx
|
|
13399
|
-
import { useEffect as
|
|
13400
|
-
import { Fragment as
|
|
13557
|
+
import { useEffect as useEffect13, useState as useState17 } from "react";
|
|
13558
|
+
import { Fragment as Fragment7, jsx as jsx56, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
13401
13559
|
var getPlainTextLengthFromHtml = (html) => {
|
|
13402
13560
|
var _a, _b;
|
|
13403
13561
|
if (!html.trim()) return 0;
|
|
@@ -13445,7 +13603,7 @@ var RichEditorFormField = (_a) => {
|
|
|
13445
13603
|
}
|
|
13446
13604
|
}
|
|
13447
13605
|
});
|
|
13448
|
-
const [caracterQuantity, setCaracterQuantity] =
|
|
13606
|
+
const [caracterQuantity, setCaracterQuantity] = useState17(
|
|
13449
13607
|
() => getRemainingCharacters(maxLength, field.value)
|
|
13450
13608
|
);
|
|
13451
13609
|
const handleCharacterCountChange = (count) => {
|
|
@@ -13453,7 +13611,7 @@ var RichEditorFormField = (_a) => {
|
|
|
13453
13611
|
setCaracterQuantity(Math.max(0, maxLength - count));
|
|
13454
13612
|
}
|
|
13455
13613
|
};
|
|
13456
|
-
|
|
13614
|
+
useEffect13(() => {
|
|
13457
13615
|
setCaracterQuantity(getRemainingCharacters(maxLength, field.value));
|
|
13458
13616
|
}, [field.value, maxLength]);
|
|
13459
13617
|
const fieldError = fieldState.error;
|
|
@@ -13471,7 +13629,7 @@ var RichEditorFormField = (_a) => {
|
|
|
13471
13629
|
}
|
|
13472
13630
|
),
|
|
13473
13631
|
/* @__PURE__ */ jsx56(Badge, { color: "grey", size: "xs", children: caracterQuantity })
|
|
13474
|
-
] }) : /* @__PURE__ */ jsx56(
|
|
13632
|
+
] }) : /* @__PURE__ */ jsx56(Fragment7, { children: label && /* @__PURE__ */ jsx56(
|
|
13475
13633
|
FormLabel,
|
|
13476
13634
|
{
|
|
13477
13635
|
name,
|
|
@@ -13499,7 +13657,7 @@ var RichEditorFormField = (_a) => {
|
|
|
13499
13657
|
|
|
13500
13658
|
// src/components/FormFields/CalendarFormField.tsx
|
|
13501
13659
|
import { useController as useController4 } from "react-hook-form";
|
|
13502
|
-
import { useCallback as
|
|
13660
|
+
import { useCallback as useCallback6 } from "react";
|
|
13503
13661
|
import { jsx as jsx57, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
13504
13662
|
var CalendarFormField = (_a) => {
|
|
13505
13663
|
var _b = _a, {
|
|
@@ -13525,7 +13683,7 @@ var CalendarFormField = (_a) => {
|
|
|
13525
13683
|
"maxYearsFromNow",
|
|
13526
13684
|
"maxDate"
|
|
13527
13685
|
]);
|
|
13528
|
-
const handleValidate =
|
|
13686
|
+
const handleValidate = useCallback6(
|
|
13529
13687
|
(value) => {
|
|
13530
13688
|
var _a2;
|
|
13531
13689
|
if (value === void 0 || value === null) {
|
|
@@ -13580,7 +13738,7 @@ var CalendarFormField = (_a) => {
|
|
|
13580
13738
|
};
|
|
13581
13739
|
|
|
13582
13740
|
// src/components/FormFields/DoubleCalendarFormField.tsx
|
|
13583
|
-
import { useCallback as
|
|
13741
|
+
import { useCallback as useCallback7 } from "react";
|
|
13584
13742
|
import { useController as useController5 } from "react-hook-form";
|
|
13585
13743
|
import { jsx as jsx58, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
13586
13744
|
var DoubleCalendarFormField = (_a) => {
|
|
@@ -13607,7 +13765,7 @@ var DoubleCalendarFormField = (_a) => {
|
|
|
13607
13765
|
"maxDate",
|
|
13608
13766
|
"disabled"
|
|
13609
13767
|
]);
|
|
13610
|
-
const handleValidate =
|
|
13768
|
+
const handleValidate = useCallback7(
|
|
13611
13769
|
(value) => {
|
|
13612
13770
|
var _a2;
|
|
13613
13771
|
if (value === void 0 || value === null) {
|
|
@@ -13656,7 +13814,7 @@ var DoubleCalendarFormField = (_a) => {
|
|
|
13656
13814
|
|
|
13657
13815
|
// src/components/FormFields/TimePickerFormField.tsx
|
|
13658
13816
|
import { useController as useController6 } from "react-hook-form";
|
|
13659
|
-
import { useCallback as
|
|
13817
|
+
import { useCallback as useCallback8 } from "react";
|
|
13660
13818
|
import { jsx as jsx59, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
13661
13819
|
var TimePickerFormField = (_a) => {
|
|
13662
13820
|
var _b = _a, {
|
|
@@ -13674,7 +13832,7 @@ var TimePickerFormField = (_a) => {
|
|
|
13674
13832
|
"validationErrorMessage",
|
|
13675
13833
|
"rules"
|
|
13676
13834
|
]);
|
|
13677
|
-
const handleValidate =
|
|
13835
|
+
const handleValidate = useCallback8(
|
|
13678
13836
|
(value) => {
|
|
13679
13837
|
var _a2;
|
|
13680
13838
|
if (value === void 0 || value === null || value === "") {
|
|
@@ -13727,7 +13885,7 @@ var TimePickerFormField = (_a) => {
|
|
|
13727
13885
|
|
|
13728
13886
|
// src/components/FormFields/DateAndTimeFormField.tsx
|
|
13729
13887
|
import { useController as useController7 } from "react-hook-form";
|
|
13730
|
-
import { useCallback as
|
|
13888
|
+
import { useCallback as useCallback9, useEffect as useEffect14, useMemo as useMemo5, useState as useState18 } from "react";
|
|
13731
13889
|
import { jsx as jsx60, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
13732
13890
|
var DateAndTimeFormField = (_a) => {
|
|
13733
13891
|
var _b = _a, {
|
|
@@ -13756,7 +13914,7 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13756
13914
|
"maxDate"
|
|
13757
13915
|
]);
|
|
13758
13916
|
const { addToast } = useToast();
|
|
13759
|
-
const handleDisabledClick =
|
|
13917
|
+
const handleDisabledClick = useCallback9(
|
|
13760
13918
|
(event) => {
|
|
13761
13919
|
if (!disabled) return;
|
|
13762
13920
|
event.preventDefault();
|
|
@@ -13769,7 +13927,7 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13769
13927
|
},
|
|
13770
13928
|
[addToast, disabled, disabledInfo]
|
|
13771
13929
|
);
|
|
13772
|
-
const handleDisabledMouseDown =
|
|
13930
|
+
const handleDisabledMouseDown = useCallback9(
|
|
13773
13931
|
(event) => {
|
|
13774
13932
|
if (!disabled) return;
|
|
13775
13933
|
event.preventDefault();
|
|
@@ -13777,7 +13935,7 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13777
13935
|
},
|
|
13778
13936
|
[disabled]
|
|
13779
13937
|
);
|
|
13780
|
-
const handleValidate =
|
|
13938
|
+
const handleValidate = useCallback9(
|
|
13781
13939
|
(value) => {
|
|
13782
13940
|
var _a2;
|
|
13783
13941
|
if (value === void 0 || value === null || value === "") {
|
|
@@ -13800,7 +13958,7 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13800
13958
|
const haveError = !!fieldError;
|
|
13801
13959
|
const errorMsg = fieldError == null ? void 0 : fieldError.message;
|
|
13802
13960
|
const { value: isoValue, onChange: setIsoValue } = field;
|
|
13803
|
-
const { selectedDateFromIso, selectedTimeFromIso } =
|
|
13961
|
+
const { selectedDateFromIso, selectedTimeFromIso } = useMemo5(() => {
|
|
13804
13962
|
if (!isoValue) return { selectedDateFromIso: void 0, selectedTimeFromIso: void 0 };
|
|
13805
13963
|
try {
|
|
13806
13964
|
const date = new Date(isoValue);
|
|
@@ -13815,13 +13973,13 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13815
13973
|
return { selectedDateFromIso: void 0, selectedTimeFromIso: void 0 };
|
|
13816
13974
|
}
|
|
13817
13975
|
}, [isoValue]);
|
|
13818
|
-
const [draftDate, setDraftDate] =
|
|
13819
|
-
const [draftTime, setDraftTime] =
|
|
13820
|
-
|
|
13976
|
+
const [draftDate, setDraftDate] = useState18(selectedDateFromIso);
|
|
13977
|
+
const [draftTime, setDraftTime] = useState18(selectedTimeFromIso);
|
|
13978
|
+
useEffect14(() => {
|
|
13821
13979
|
setDraftDate(selectedDateFromIso);
|
|
13822
13980
|
setDraftTime(selectedTimeFromIso);
|
|
13823
13981
|
}, [selectedDateFromIso, selectedTimeFromIso]);
|
|
13824
|
-
const combineDateTime =
|
|
13982
|
+
const combineDateTime = useCallback9(
|
|
13825
13983
|
(date, time) => {
|
|
13826
13984
|
if (!date) {
|
|
13827
13985
|
setIsoValue("");
|
|
@@ -13908,11 +14066,11 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13908
14066
|
};
|
|
13909
14067
|
|
|
13910
14068
|
// src/hooks/useImageUpload.ts
|
|
13911
|
-
import { useState as
|
|
14069
|
+
import { useState as useState19, useCallback as useCallback10 } from "react";
|
|
13912
14070
|
var useImageUpload = (options) => {
|
|
13913
|
-
const [isUploading, setIsUploading] =
|
|
13914
|
-
const [progress, setProgress] =
|
|
13915
|
-
const [error, setError] =
|
|
14071
|
+
const [isUploading, setIsUploading] = useState19(false);
|
|
14072
|
+
const [progress, setProgress] = useState19(null);
|
|
14073
|
+
const [error, setError] = useState19(null);
|
|
13916
14074
|
const {
|
|
13917
14075
|
onSuccess,
|
|
13918
14076
|
onError,
|
|
@@ -13922,7 +14080,7 @@ var useImageUpload = (options) => {
|
|
|
13922
14080
|
allowedTypes = ["image/jpeg", "image/png", "image/gif", "image/webp"],
|
|
13923
14081
|
uploadConfig
|
|
13924
14082
|
} = options;
|
|
13925
|
-
const validateFile =
|
|
14083
|
+
const validateFile = useCallback10(
|
|
13926
14084
|
(file) => {
|
|
13927
14085
|
if (!allowedTypes.includes(file.type)) {
|
|
13928
14086
|
const errorMsg = "Tipo de arquivo n\xE3o suportado";
|
|
@@ -13940,7 +14098,7 @@ var useImageUpload = (options) => {
|
|
|
13940
14098
|
},
|
|
13941
14099
|
[allowedTypes, maxFileSize, onError]
|
|
13942
14100
|
);
|
|
13943
|
-
const uploadFile =
|
|
14101
|
+
const uploadFile = useCallback10(
|
|
13944
14102
|
(file) => __async(null, null, function* () {
|
|
13945
14103
|
if (!validateFile(file)) {
|
|
13946
14104
|
return null;
|
|
@@ -13993,7 +14151,7 @@ var useImageUpload = (options) => {
|
|
|
13993
14151
|
}),
|
|
13994
14152
|
[validateFile, onSuccess, onError, onProgress]
|
|
13995
14153
|
);
|
|
13996
|
-
const reset =
|
|
14154
|
+
const reset = useCallback10(() => {
|
|
13997
14155
|
setIsUploading(false);
|
|
13998
14156
|
setProgress(null);
|
|
13999
14157
|
setError(null);
|