@lets-events/react 12.10.6 → 12.10.8
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +87 -31
- package/dist/index.mjs +133 -77
- package/package.json +1 -1
- package/src/components/Drawer/index.tsx +8 -3
- package/src/components/FormFields/RichEditorFormField.tsx +25 -3
- package/src/components/RichEditor/QuillComponent.tsx +6 -2
- package/src/components/TextField.tsx +71 -20
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @lets-events/react@12.10.
|
|
3
|
+
> @lets-events/react@12.10.8 build
|
|
4
4
|
> tsup src/index.tsx --format esm,cjs --dts --external react
|
|
5
5
|
|
|
6
6
|
[1G[0K[34mCLI[39m Building entry: src/index.tsx
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
[34mCLI[39m Target: es6
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m431.62 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 301ms
|
|
15
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m415.97 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 301ms
|
|
17
17
|
DTS Build start
|
|
18
|
-
DTS ⚡️ Build success in
|
|
19
|
-
DTS dist/index.d.mts 405.
|
|
20
|
-
DTS dist/index.d.ts 405.
|
|
18
|
+
DTS ⚡️ Build success in 6076ms
|
|
19
|
+
DTS dist/index.d.mts 405.30 KB
|
|
20
|
+
DTS dist/index.d.ts 405.30 KB
|
|
21
21
|
[1G[0K⠙[1G[0K
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -5142,8 +5142,9 @@ type DrawerProps = ComponentProps<typeof DrawerOverlayStyled> & {
|
|
|
5142
5142
|
goBackAction?: () => void;
|
|
5143
5143
|
zIndex?: number;
|
|
5144
5144
|
clickOutsideAvailable?: boolean;
|
|
5145
|
+
actionButton?: ReactNode;
|
|
5145
5146
|
};
|
|
5146
|
-
declare function Drawer({ isOpen, onClose, width, backgroundColor, title, children, goBackIcon, goBackAction, zIndex, clickOutsideAvailable, }: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
5147
|
+
declare function Drawer({ isOpen, onClose, width, backgroundColor, title, children, goBackIcon, goBackAction, zIndex, clickOutsideAvailable, actionButton, }: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
5147
5148
|
|
|
5148
5149
|
declare const TimePickerStyled: _stitches_react_types_styled_component.StyledComponent<"div", {
|
|
5149
5150
|
expand?: boolean | "true" | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -5142,8 +5142,9 @@ type DrawerProps = ComponentProps<typeof DrawerOverlayStyled> & {
|
|
|
5142
5142
|
goBackAction?: () => void;
|
|
5143
5143
|
zIndex?: number;
|
|
5144
5144
|
clickOutsideAvailable?: boolean;
|
|
5145
|
+
actionButton?: ReactNode;
|
|
5145
5146
|
};
|
|
5146
|
-
declare function Drawer({ isOpen, onClose, width, backgroundColor, title, children, goBackIcon, goBackAction, zIndex, clickOutsideAvailable, }: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
5147
|
+
declare function Drawer({ isOpen, onClose, width, backgroundColor, title, children, goBackIcon, goBackAction, zIndex, clickOutsideAvailable, actionButton, }: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
5147
5148
|
|
|
5148
5149
|
declare const TimePickerStyled: _stitches_react_types_styled_component.StyledComponent<"div", {
|
|
5149
5150
|
expand?: boolean | "true" | undefined;
|
package/dist/index.js
CHANGED
|
@@ -2812,7 +2812,10 @@ var TextField = import_react3.default.forwardRef(
|
|
|
2812
2812
|
textAlign = "left",
|
|
2813
2813
|
mask,
|
|
2814
2814
|
maxLength,
|
|
2815
|
-
hasError
|
|
2815
|
+
hasError,
|
|
2816
|
+
value,
|
|
2817
|
+
defaultValue,
|
|
2818
|
+
onInput
|
|
2816
2819
|
} = _b, props = __objRest(_b, [
|
|
2817
2820
|
"children",
|
|
2818
2821
|
"isValid",
|
|
@@ -2824,21 +2827,58 @@ var TextField = import_react3.default.forwardRef(
|
|
|
2824
2827
|
"textAlign",
|
|
2825
2828
|
"mask",
|
|
2826
2829
|
"maxLength",
|
|
2827
|
-
"hasError"
|
|
2830
|
+
"hasError",
|
|
2831
|
+
"value",
|
|
2832
|
+
"defaultValue",
|
|
2833
|
+
"onInput"
|
|
2828
2834
|
]);
|
|
2835
|
+
const _a2 = props, { ref: propRef } = _a2, restProps = __objRest(_a2, ["ref"]);
|
|
2829
2836
|
const maskRef = mask ? (0, import_mask.useMask)(mask) : void 0;
|
|
2830
2837
|
const inputRef = import_react3.default.useRef(null);
|
|
2831
|
-
const
|
|
2832
|
-
const
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2838
|
+
const getTextLength = (text) => String(text != null ? text : "").length;
|
|
2839
|
+
const updateRemaining = (currentLength) => {
|
|
2840
|
+
if (maxLength !== void 0) {
|
|
2841
|
+
setRemaining(maxLength - currentLength);
|
|
2842
|
+
}
|
|
2843
|
+
};
|
|
2844
|
+
const getCurrentLength = (inputElement) => {
|
|
2845
|
+
var _a3, _b2, _c;
|
|
2846
|
+
if (value !== void 0 && value !== null) {
|
|
2847
|
+
return getTextLength(value);
|
|
2848
|
+
}
|
|
2849
|
+
return (_c = (_b2 = inputElement == null ? void 0 : inputElement.value.length) != null ? _b2 : (_a3 = inputRef.current) == null ? void 0 : _a3.value.length) != null ? _c : getTextLength(defaultValue);
|
|
2850
|
+
};
|
|
2851
|
+
const [remaining, setRemaining] = (0, import_react3.useState)(
|
|
2852
|
+
() => maxLength !== void 0 ? maxLength - getTextLength(value != null ? value : defaultValue) : 0
|
|
2853
|
+
);
|
|
2854
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
2855
|
+
if (maxLength === void 0) return;
|
|
2856
|
+
updateRemaining(getCurrentLength());
|
|
2857
|
+
}, [maxLength, value, defaultValue]);
|
|
2858
|
+
const assignRef = (element) => {
|
|
2859
|
+
inputRef.current = element;
|
|
2860
|
+
if (maskRef && element) {
|
|
2861
|
+
maskRef.current = element;
|
|
2862
|
+
}
|
|
2863
|
+
if (typeof propRef === "function") {
|
|
2864
|
+
propRef(element);
|
|
2865
|
+
} else if (propRef) {
|
|
2866
|
+
propRef.current = element;
|
|
2867
|
+
}
|
|
2868
|
+
if (typeof fowardedRef === "function") {
|
|
2869
|
+
fowardedRef(element);
|
|
2870
|
+
} else if (fowardedRef) {
|
|
2871
|
+
fowardedRef.current = element;
|
|
2872
|
+
}
|
|
2873
|
+
if (element && maxLength !== void 0) {
|
|
2874
|
+
updateRemaining(getCurrentLength(element));
|
|
2875
|
+
}
|
|
2837
2876
|
};
|
|
2838
2877
|
const handleInput = (e) => {
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2878
|
+
if (maxLength !== void 0) {
|
|
2879
|
+
updateRemaining(e.currentTarget.value.length);
|
|
2880
|
+
}
|
|
2881
|
+
onInput == null ? void 0 : onInput(e);
|
|
2842
2882
|
};
|
|
2843
2883
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Flex, { direction: "column", css: { width: "100%", position: "relative" }, children: [
|
|
2844
2884
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Flex, { gap: "0", css: { width: "100%" }, children: [
|
|
@@ -2852,7 +2892,7 @@ var TextField = import_react3.default.forwardRef(
|
|
|
2852
2892
|
),
|
|
2853
2893
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2854
2894
|
TextFieldStyled,
|
|
2855
|
-
__spreadProps(__spreadValues({
|
|
2895
|
+
__spreadProps(__spreadValues({}, restProps), {
|
|
2856
2896
|
color: hasError ? "error" : color || "default",
|
|
2857
2897
|
isValid: isValid2,
|
|
2858
2898
|
name,
|
|
@@ -2860,17 +2900,10 @@ var TextField = import_react3.default.forwardRef(
|
|
|
2860
2900
|
fontWeight,
|
|
2861
2901
|
textAlign,
|
|
2862
2902
|
maxLength,
|
|
2863
|
-
ref:
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
if (fowardedRef) {
|
|
2868
|
-
if (typeof fowardedRef === "function") fowardedRef(r);
|
|
2869
|
-
else fowardedRef.current = r;
|
|
2870
|
-
}
|
|
2871
|
-
},
|
|
2872
|
-
onInput: handleInput
|
|
2873
|
-
}, props), {
|
|
2903
|
+
ref: assignRef,
|
|
2904
|
+
onInput: handleInput,
|
|
2905
|
+
value,
|
|
2906
|
+
defaultValue,
|
|
2874
2907
|
style: addon ? {
|
|
2875
2908
|
borderTopLeftRadius: "0px",
|
|
2876
2909
|
borderBottomLeftRadius: "0px"
|
|
@@ -2893,7 +2926,7 @@ var TextField = import_react3.default.forwardRef(
|
|
|
2893
2926
|
})
|
|
2894
2927
|
)
|
|
2895
2928
|
] }),
|
|
2896
|
-
maxLength && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TextFieldLimitIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", {
|
|
2929
|
+
maxLength && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TextFieldLimitIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: remaining }) })
|
|
2897
2930
|
] });
|
|
2898
2931
|
}
|
|
2899
2932
|
);
|
|
@@ -8737,7 +8770,8 @@ function Drawer({
|
|
|
8737
8770
|
goBackIcon,
|
|
8738
8771
|
goBackAction,
|
|
8739
8772
|
zIndex = 1e3,
|
|
8740
|
-
clickOutsideAvailable = true
|
|
8773
|
+
clickOutsideAvailable = true,
|
|
8774
|
+
actionButton = null
|
|
8741
8775
|
}) {
|
|
8742
8776
|
(0, import_react10.useEffect)(() => {
|
|
8743
8777
|
if (isOpen) {
|
|
@@ -8789,7 +8823,10 @@ function Drawer({
|
|
|
8789
8823
|
goBackIcon && goBackIcon && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GoBackButtonStyled, { type: "button", onClick: goBackAction, children: goBackIcon }),
|
|
8790
8824
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DrawerHeaderTitle, { children: title })
|
|
8791
8825
|
] }),
|
|
8792
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.
|
|
8826
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Flex, { gap: 8, children: [
|
|
8827
|
+
actionButton && actionButton,
|
|
8828
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DrawerHeaderCloseButton, { onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Icon_default, { size: "xl", color: "$dark600", name: "xmark" }) })
|
|
8829
|
+
] })
|
|
8793
8830
|
] }),
|
|
8794
8831
|
isOpen ? children : null
|
|
8795
8832
|
]
|
|
@@ -13128,7 +13165,8 @@ var QuillComponent = ({
|
|
|
13128
13165
|
[disabled, quill, addToast, removeToast, uploadConfig, onChange]
|
|
13129
13166
|
);
|
|
13130
13167
|
(0, import_react23.useEffect)(() => {
|
|
13131
|
-
if (quill
|
|
13168
|
+
if (!quill) return;
|
|
13169
|
+
if (value !== void 0 && value !== null) {
|
|
13132
13170
|
const currentContent = quill.root.innerHTML;
|
|
13133
13171
|
if (currentContent !== value) {
|
|
13134
13172
|
const selection = quill.getSelection();
|
|
@@ -13140,7 +13178,8 @@ var QuillComponent = ({
|
|
|
13140
13178
|
}
|
|
13141
13179
|
}
|
|
13142
13180
|
}
|
|
13143
|
-
|
|
13181
|
+
onCharacterCountChange == null ? void 0 : onCharacterCountChange(quill.getText().trim().length);
|
|
13182
|
+
}, [quill, value, onCharacterCountChange]);
|
|
13144
13183
|
(0, import_react23.useEffect)(() => {
|
|
13145
13184
|
if (quill) {
|
|
13146
13185
|
quill.on("text-change", (delta, oldDelta, source) => {
|
|
@@ -13456,6 +13495,19 @@ var RichTextPresenter_default = RichTextPresenter;
|
|
|
13456
13495
|
// src/components/FormFields/RichEditorFormField.tsx
|
|
13457
13496
|
var import_react25 = require("react");
|
|
13458
13497
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
13498
|
+
var getPlainTextLengthFromHtml = (html) => {
|
|
13499
|
+
var _a, _b;
|
|
13500
|
+
if (!html.trim()) return 0;
|
|
13501
|
+
if (typeof document === "undefined") {
|
|
13502
|
+
return html.replace(/<[^>]*>/g, "").trim().length;
|
|
13503
|
+
}
|
|
13504
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
13505
|
+
return (_b = (_a = doc.body.textContent) == null ? void 0 : _a.trim().length) != null ? _b : 0;
|
|
13506
|
+
};
|
|
13507
|
+
var getRemainingCharacters = (maxLength, value) => {
|
|
13508
|
+
if (maxLength === void 0) return maxLength;
|
|
13509
|
+
return Math.max(0, maxLength - getPlainTextLengthFromHtml(value != null ? value : ""));
|
|
13510
|
+
};
|
|
13459
13511
|
var RichEditorFormField = (_a) => {
|
|
13460
13512
|
var _b = _a, {
|
|
13461
13513
|
name,
|
|
@@ -13488,15 +13540,19 @@ var RichEditorFormField = (_a) => {
|
|
|
13488
13540
|
return true;
|
|
13489
13541
|
return (_a2 = validate == null ? void 0 : validate(value)) != null ? _a2 : true;
|
|
13490
13542
|
}
|
|
13491
|
-
}
|
|
13492
|
-
defaultValue: ""
|
|
13543
|
+
}
|
|
13493
13544
|
});
|
|
13494
|
-
const [caracterQuantity, setCaracterQuantity] = (0, import_react25.useState)(
|
|
13545
|
+
const [caracterQuantity, setCaracterQuantity] = (0, import_react25.useState)(
|
|
13546
|
+
() => getRemainingCharacters(maxLength, field.value)
|
|
13547
|
+
);
|
|
13495
13548
|
const handleCharacterCountChange = (count) => {
|
|
13496
13549
|
if (maxLength !== void 0) {
|
|
13497
13550
|
setCaracterQuantity(Math.max(0, maxLength - count));
|
|
13498
13551
|
}
|
|
13499
13552
|
};
|
|
13553
|
+
(0, import_react25.useEffect)(() => {
|
|
13554
|
+
setCaracterQuantity(getRemainingCharacters(maxLength, field.value));
|
|
13555
|
+
}, [field.value, maxLength]);
|
|
13500
13556
|
const fieldError = fieldState.error;
|
|
13501
13557
|
const haveError = !!fieldError;
|
|
13502
13558
|
const errorMsg = fieldError == null ? void 0 : fieldError.message;
|
package/dist/index.mjs
CHANGED
|
@@ -2484,7 +2484,7 @@ function Avatar(_a) {
|
|
|
2484
2484
|
}
|
|
2485
2485
|
|
|
2486
2486
|
// src/components/TextField.tsx
|
|
2487
|
-
import React from "react";
|
|
2487
|
+
import React, { useLayoutEffect, useState } from "react";
|
|
2488
2488
|
import { TextField as TextFieldRadix } from "@radix-ui/themes";
|
|
2489
2489
|
import { format, useMask, unformat } from "@react-input/mask";
|
|
2490
2490
|
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -2691,7 +2691,10 @@ var TextField = React.forwardRef(
|
|
|
2691
2691
|
textAlign = "left",
|
|
2692
2692
|
mask,
|
|
2693
2693
|
maxLength,
|
|
2694
|
-
hasError
|
|
2694
|
+
hasError,
|
|
2695
|
+
value,
|
|
2696
|
+
defaultValue,
|
|
2697
|
+
onInput
|
|
2695
2698
|
} = _b, props = __objRest(_b, [
|
|
2696
2699
|
"children",
|
|
2697
2700
|
"isValid",
|
|
@@ -2703,21 +2706,58 @@ var TextField = React.forwardRef(
|
|
|
2703
2706
|
"textAlign",
|
|
2704
2707
|
"mask",
|
|
2705
2708
|
"maxLength",
|
|
2706
|
-
"hasError"
|
|
2709
|
+
"hasError",
|
|
2710
|
+
"value",
|
|
2711
|
+
"defaultValue",
|
|
2712
|
+
"onInput"
|
|
2707
2713
|
]);
|
|
2714
|
+
const _a2 = props, { ref: propRef } = _a2, restProps = __objRest(_a2, ["ref"]);
|
|
2708
2715
|
const maskRef = mask ? useMask(mask) : void 0;
|
|
2709
2716
|
const inputRef = React.useRef(null);
|
|
2710
|
-
const
|
|
2711
|
-
const
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2717
|
+
const getTextLength = (text) => String(text != null ? text : "").length;
|
|
2718
|
+
const updateRemaining = (currentLength) => {
|
|
2719
|
+
if (maxLength !== void 0) {
|
|
2720
|
+
setRemaining(maxLength - currentLength);
|
|
2721
|
+
}
|
|
2722
|
+
};
|
|
2723
|
+
const getCurrentLength = (inputElement) => {
|
|
2724
|
+
var _a3, _b2, _c;
|
|
2725
|
+
if (value !== void 0 && value !== null) {
|
|
2726
|
+
return getTextLength(value);
|
|
2727
|
+
}
|
|
2728
|
+
return (_c = (_b2 = inputElement == null ? void 0 : inputElement.value.length) != null ? _b2 : (_a3 = inputRef.current) == null ? void 0 : _a3.value.length) != null ? _c : getTextLength(defaultValue);
|
|
2729
|
+
};
|
|
2730
|
+
const [remaining, setRemaining] = useState(
|
|
2731
|
+
() => maxLength !== void 0 ? maxLength - getTextLength(value != null ? value : defaultValue) : 0
|
|
2732
|
+
);
|
|
2733
|
+
useLayoutEffect(() => {
|
|
2734
|
+
if (maxLength === void 0) return;
|
|
2735
|
+
updateRemaining(getCurrentLength());
|
|
2736
|
+
}, [maxLength, value, defaultValue]);
|
|
2737
|
+
const assignRef = (element) => {
|
|
2738
|
+
inputRef.current = element;
|
|
2739
|
+
if (maskRef && element) {
|
|
2740
|
+
maskRef.current = element;
|
|
2741
|
+
}
|
|
2742
|
+
if (typeof propRef === "function") {
|
|
2743
|
+
propRef(element);
|
|
2744
|
+
} else if (propRef) {
|
|
2745
|
+
propRef.current = element;
|
|
2746
|
+
}
|
|
2747
|
+
if (typeof fowardedRef === "function") {
|
|
2748
|
+
fowardedRef(element);
|
|
2749
|
+
} else if (fowardedRef) {
|
|
2750
|
+
fowardedRef.current = element;
|
|
2751
|
+
}
|
|
2752
|
+
if (element && maxLength !== void 0) {
|
|
2753
|
+
updateRemaining(getCurrentLength(element));
|
|
2754
|
+
}
|
|
2716
2755
|
};
|
|
2717
2756
|
const handleInput = (e) => {
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2757
|
+
if (maxLength !== void 0) {
|
|
2758
|
+
updateRemaining(e.currentTarget.value.length);
|
|
2759
|
+
}
|
|
2760
|
+
onInput == null ? void 0 : onInput(e);
|
|
2721
2761
|
};
|
|
2722
2762
|
return /* @__PURE__ */ jsxs2(Flex, { direction: "column", css: { width: "100%", position: "relative" }, children: [
|
|
2723
2763
|
/* @__PURE__ */ jsxs2(Flex, { gap: "0", css: { width: "100%" }, children: [
|
|
@@ -2731,7 +2771,7 @@ var TextField = React.forwardRef(
|
|
|
2731
2771
|
),
|
|
2732
2772
|
/* @__PURE__ */ jsxs2(
|
|
2733
2773
|
TextFieldStyled,
|
|
2734
|
-
__spreadProps(__spreadValues({
|
|
2774
|
+
__spreadProps(__spreadValues({}, restProps), {
|
|
2735
2775
|
color: hasError ? "error" : color || "default",
|
|
2736
2776
|
isValid: isValid2,
|
|
2737
2777
|
name,
|
|
@@ -2739,17 +2779,10 @@ var TextField = React.forwardRef(
|
|
|
2739
2779
|
fontWeight,
|
|
2740
2780
|
textAlign,
|
|
2741
2781
|
maxLength,
|
|
2742
|
-
ref:
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
if (fowardedRef) {
|
|
2747
|
-
if (typeof fowardedRef === "function") fowardedRef(r);
|
|
2748
|
-
else fowardedRef.current = r;
|
|
2749
|
-
}
|
|
2750
|
-
},
|
|
2751
|
-
onInput: handleInput
|
|
2752
|
-
}, props), {
|
|
2782
|
+
ref: assignRef,
|
|
2783
|
+
onInput: handleInput,
|
|
2784
|
+
value,
|
|
2785
|
+
defaultValue,
|
|
2753
2786
|
style: addon ? {
|
|
2754
2787
|
borderTopLeftRadius: "0px",
|
|
2755
2788
|
borderBottomLeftRadius: "0px"
|
|
@@ -2772,7 +2805,7 @@ var TextField = React.forwardRef(
|
|
|
2772
2805
|
})
|
|
2773
2806
|
)
|
|
2774
2807
|
] }),
|
|
2775
|
-
maxLength && /* @__PURE__ */ jsx7(TextFieldLimitIndicator, { children: /* @__PURE__ */ jsx7("span", {
|
|
2808
|
+
maxLength && /* @__PURE__ */ jsx7(TextFieldLimitIndicator, { children: /* @__PURE__ */ jsx7("span", { children: remaining }) })
|
|
2776
2809
|
] });
|
|
2777
2810
|
}
|
|
2778
2811
|
);
|
|
@@ -3301,7 +3334,7 @@ function FilterItem(_a) {
|
|
|
3301
3334
|
|
|
3302
3335
|
// src/components/Dropdown.tsx
|
|
3303
3336
|
import React2, {
|
|
3304
|
-
useState,
|
|
3337
|
+
useState as useState2,
|
|
3305
3338
|
useRef,
|
|
3306
3339
|
useEffect
|
|
3307
3340
|
} from "react";
|
|
@@ -3435,7 +3468,7 @@ function DropdownMenu2(_a) {
|
|
|
3435
3468
|
"onOpenChange",
|
|
3436
3469
|
"defaultOpen"
|
|
3437
3470
|
]);
|
|
3438
|
-
const [internalOpen, setInternalOpen] =
|
|
3471
|
+
const [internalOpen, setInternalOpen] = useState2(defaultOpen);
|
|
3439
3472
|
const dropdownRef = useRef(null);
|
|
3440
3473
|
const isControlled = controlledOpen !== void 0;
|
|
3441
3474
|
const isOpen = isControlled ? controlledOpen : internalOpen;
|
|
@@ -3859,7 +3892,7 @@ function MenuDropdown({
|
|
|
3859
3892
|
}
|
|
3860
3893
|
|
|
3861
3894
|
// src/components/Calendar/index.tsx
|
|
3862
|
-
import { useRef as useRef3, useEffect as useEffect3, useState as
|
|
3895
|
+
import { useRef as useRef3, useEffect as useEffect3, useState as useState3 } from "react";
|
|
3863
3896
|
import { DayPicker } from "react-day-picker";
|
|
3864
3897
|
|
|
3865
3898
|
// ../../node_modules/date-fns/locale/_lib/buildFormatLongFn.js
|
|
@@ -8255,8 +8288,8 @@ function Calendar(_a) {
|
|
|
8255
8288
|
"maxYearsFromNow",
|
|
8256
8289
|
"disabled"
|
|
8257
8290
|
]);
|
|
8258
|
-
const [inputValue, setInputValue] =
|
|
8259
|
-
const [showContainer, setShowCalendar] =
|
|
8291
|
+
const [inputValue, setInputValue] = useState3("");
|
|
8292
|
+
const [showContainer, setShowCalendar] = useState3(false);
|
|
8260
8293
|
const dropdownRef = useRef3(null);
|
|
8261
8294
|
useOnClickOutside(dropdownRef, () => {
|
|
8262
8295
|
setShowCalendar(false);
|
|
@@ -8352,7 +8385,7 @@ function Calendar(_a) {
|
|
|
8352
8385
|
}
|
|
8353
8386
|
|
|
8354
8387
|
// src/components/DoubleCalendar/index.tsx
|
|
8355
|
-
import { useRef as useRef4, useEffect as useEffect4, useState as
|
|
8388
|
+
import { useRef as useRef4, useEffect as useEffect4, useState as useState4 } from "react";
|
|
8356
8389
|
import { DayPicker as DayPicker2 } from "react-day-picker";
|
|
8357
8390
|
import { jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
8358
8391
|
function DoubleCalendar(_a) {
|
|
@@ -8385,9 +8418,9 @@ function DoubleCalendar(_a) {
|
|
|
8385
8418
|
"maxDate",
|
|
8386
8419
|
"disabled"
|
|
8387
8420
|
]);
|
|
8388
|
-
const [startValue, setStartValue] =
|
|
8389
|
-
const [endValue, setEndValue] =
|
|
8390
|
-
const [showContainer, setShowCalendar] =
|
|
8421
|
+
const [startValue, setStartValue] = useState4("");
|
|
8422
|
+
const [endValue, setEndValue] = useState4("");
|
|
8423
|
+
const [showContainer, setShowCalendar] = useState4(false);
|
|
8391
8424
|
const initialSelectedRef = useRef4(void 0);
|
|
8392
8425
|
const dropdownRef = useRef4(null);
|
|
8393
8426
|
useOnClickOutside(dropdownRef, () => {
|
|
@@ -8620,7 +8653,8 @@ function Drawer({
|
|
|
8620
8653
|
goBackIcon,
|
|
8621
8654
|
goBackAction,
|
|
8622
8655
|
zIndex = 1e3,
|
|
8623
|
-
clickOutsideAvailable = true
|
|
8656
|
+
clickOutsideAvailable = true,
|
|
8657
|
+
actionButton = null
|
|
8624
8658
|
}) {
|
|
8625
8659
|
useEffect5(() => {
|
|
8626
8660
|
if (isOpen) {
|
|
@@ -8672,7 +8706,10 @@ function Drawer({
|
|
|
8672
8706
|
goBackIcon && goBackIcon && /* @__PURE__ */ jsx17(GoBackButtonStyled, { type: "button", onClick: goBackAction, children: goBackIcon }),
|
|
8673
8707
|
/* @__PURE__ */ jsx17(DrawerHeaderTitle, { children: title })
|
|
8674
8708
|
] }),
|
|
8675
|
-
/* @__PURE__ */
|
|
8709
|
+
/* @__PURE__ */ jsxs9(Flex, { gap: 8, children: [
|
|
8710
|
+
actionButton && actionButton,
|
|
8711
|
+
/* @__PURE__ */ jsx17(DrawerHeaderCloseButton, { onClick: onClose, children: /* @__PURE__ */ jsx17(Icon_default, { size: "xl", color: "$dark600", name: "xmark" }) })
|
|
8712
|
+
] })
|
|
8676
8713
|
] }),
|
|
8677
8714
|
isOpen ? children : null
|
|
8678
8715
|
]
|
|
@@ -8684,7 +8721,7 @@ function Drawer({
|
|
|
8684
8721
|
}
|
|
8685
8722
|
|
|
8686
8723
|
// src/components/TimePicker.tsx
|
|
8687
|
-
import { useCallback, useEffect as useEffect6, useRef as useRef6, useState as
|
|
8724
|
+
import { useCallback, useEffect as useEffect6, useRef as useRef6, useState as useState5 } from "react";
|
|
8688
8725
|
import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
8689
8726
|
var TimePickerStyled = styled("div", {
|
|
8690
8727
|
position: "relative",
|
|
@@ -8823,11 +8860,11 @@ function TimePicker({
|
|
|
8823
8860
|
expand = false,
|
|
8824
8861
|
disabled = false
|
|
8825
8862
|
}) {
|
|
8826
|
-
const [hours, setHours] =
|
|
8827
|
-
const [minutes, setMinutes] =
|
|
8828
|
-
const [rawHours, setRawHours] =
|
|
8829
|
-
const [rawMinutes, setRawMinutes] =
|
|
8830
|
-
const [isOpen, setIsOpen] =
|
|
8863
|
+
const [hours, setHours] = useState5("00");
|
|
8864
|
+
const [minutes, setMinutes] = useState5("00");
|
|
8865
|
+
const [rawHours, setRawHours] = useState5("00");
|
|
8866
|
+
const [rawMinutes, setRawMinutes] = useState5("00");
|
|
8867
|
+
const [isOpen, setIsOpen] = useState5(false);
|
|
8831
8868
|
const dropdownRef = useRef6(null);
|
|
8832
8869
|
useOnClickOutside(dropdownRef, () => setIsOpen(false));
|
|
8833
8870
|
useEffect6(() => {
|
|
@@ -9571,7 +9608,7 @@ function Card(_a) {
|
|
|
9571
9608
|
|
|
9572
9609
|
// src/components/TextareaField.tsx
|
|
9573
9610
|
import { TextArea as TextAreaRadix } from "@radix-ui/themes";
|
|
9574
|
-
import React9, { useRef as useRef7, useState as
|
|
9611
|
+
import React9, { useRef as useRef7, useState as useState6, useEffect as useEffect7 } from "react";
|
|
9575
9612
|
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
9576
9613
|
var TextareaFieldStyle = styled(TextAreaRadix, {
|
|
9577
9614
|
display: "flex",
|
|
@@ -9625,7 +9662,7 @@ var TextareaContainer = styled("div", {
|
|
|
9625
9662
|
var TextareaField = React9.forwardRef((_a, forwardedRef) => {
|
|
9626
9663
|
var _b = _a, { maxLength, color, top = "-1.75rem" } = _b, props = __objRest(_b, ["maxLength", "color", "top"]);
|
|
9627
9664
|
const inputRef = useRef7(null);
|
|
9628
|
-
const [remaining, setRemaining] =
|
|
9665
|
+
const [remaining, setRemaining] = useState6(maxLength);
|
|
9629
9666
|
useEffect7(() => {
|
|
9630
9667
|
var _a2;
|
|
9631
9668
|
if (maxLength && inputRef.current) {
|
|
@@ -9661,7 +9698,7 @@ var TextareaField = React9.forwardRef((_a, forwardedRef) => {
|
|
|
9661
9698
|
});
|
|
9662
9699
|
|
|
9663
9700
|
// src/components/Toast/components/ToastItem.tsx
|
|
9664
|
-
import { useState as
|
|
9701
|
+
import { useState as useState7 } from "react";
|
|
9665
9702
|
|
|
9666
9703
|
// src/components/Toast/styles/index.ts
|
|
9667
9704
|
import { keyframes as keyframes2 } from "@stitches/react";
|
|
@@ -9792,7 +9829,7 @@ function ToastItem({
|
|
|
9792
9829
|
toast,
|
|
9793
9830
|
onRemove
|
|
9794
9831
|
}) {
|
|
9795
|
-
const [open, setOpen] =
|
|
9832
|
+
const [open, setOpen] = useState7(true);
|
|
9796
9833
|
const handleOpenChange = (open2) => {
|
|
9797
9834
|
setOpen(open2);
|
|
9798
9835
|
if (!open2) {
|
|
@@ -9816,7 +9853,7 @@ function ToastItem({
|
|
|
9816
9853
|
}
|
|
9817
9854
|
|
|
9818
9855
|
// src/components/Toast/components/ToastProvider.tsx
|
|
9819
|
-
import { createContext, useState as
|
|
9856
|
+
import { createContext, useState as useState8 } from "react";
|
|
9820
9857
|
import * as ToastPrimitive2 from "@radix-ui/react-toast";
|
|
9821
9858
|
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
9822
9859
|
var ToastContext = createContext(null);
|
|
@@ -9826,7 +9863,7 @@ function ToastProvider({
|
|
|
9826
9863
|
maxToasts = 5,
|
|
9827
9864
|
swipeDirection = "right"
|
|
9828
9865
|
}) {
|
|
9829
|
-
const [toasts, setToasts] =
|
|
9866
|
+
const [toasts, setToasts] = useState8([]);
|
|
9830
9867
|
const addToast = (toastData) => {
|
|
9831
9868
|
const id = Math.random().toString(36).substr(2, 9);
|
|
9832
9869
|
const newToast = __spreadProps(__spreadValues({
|
|
@@ -9922,7 +9959,7 @@ function Tooltip({
|
|
|
9922
9959
|
}
|
|
9923
9960
|
|
|
9924
9961
|
// src/components/MultiSelect/index.tsx
|
|
9925
|
-
import React10, { useCallback as useCallback2, useRef as useRef8, useState as
|
|
9962
|
+
import React10, { useCallback as useCallback2, useRef as useRef8, useState as useState9 } from "react";
|
|
9926
9963
|
import { DropdownMenu as DropdownMenu4, Theme as Theme3 } from "@radix-ui/themes";
|
|
9927
9964
|
import { FontAwesomeIcon as FontAwesomeIcon3 } from "@fortawesome/react-fontawesome";
|
|
9928
9965
|
import {
|
|
@@ -10101,9 +10138,9 @@ var MultiSelect = React10.forwardRef(
|
|
|
10101
10138
|
showMoreButtonLabel = "Carregar mais",
|
|
10102
10139
|
showMoreButtonOnClick
|
|
10103
10140
|
}, fowardedRef) => {
|
|
10104
|
-
const [isOpen, setIsOpen] =
|
|
10141
|
+
const [isOpen, setIsOpen] = useState9(false);
|
|
10105
10142
|
const triggerRef = useRef8(null);
|
|
10106
|
-
const [allOptionsSelected, setAllOptionsSelected] =
|
|
10143
|
+
const [allOptionsSelected, setAllOptionsSelected] = useState9(false);
|
|
10107
10144
|
const labelByValue = useMemo2(() => {
|
|
10108
10145
|
return options.reduce((prev, curr) => {
|
|
10109
10146
|
return __spreadProps(__spreadValues({}, prev), {
|
|
@@ -10361,7 +10398,7 @@ var Divider = styled("div", {
|
|
|
10361
10398
|
});
|
|
10362
10399
|
|
|
10363
10400
|
// src/components/ToggleElement/index.tsx
|
|
10364
|
-
import { useState as
|
|
10401
|
+
import { useState as useState10 } from "react";
|
|
10365
10402
|
import { Fragment as Fragment3, jsx as jsx28, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
10366
10403
|
function ToggleElement({
|
|
10367
10404
|
children,
|
|
@@ -10373,7 +10410,7 @@ function ToggleElement({
|
|
|
10373
10410
|
buttonProps,
|
|
10374
10411
|
onOpenChange
|
|
10375
10412
|
}) {
|
|
10376
|
-
const [internalOpen, setInternalOpen] =
|
|
10413
|
+
const [internalOpen, setInternalOpen] = useState10(defaultOpen);
|
|
10377
10414
|
const isControlled = open !== void 0;
|
|
10378
10415
|
const isOpen = isControlled ? open : internalOpen;
|
|
10379
10416
|
const handleClick = () => {
|
|
@@ -11357,7 +11394,7 @@ function StateFormField({
|
|
|
11357
11394
|
}
|
|
11358
11395
|
|
|
11359
11396
|
// src/components/FormFields/AddressFormFields/CityFormField.tsx
|
|
11360
|
-
import { useEffect as useEffect8, useState as
|
|
11397
|
+
import { useEffect as useEffect8, useState as useState11 } from "react";
|
|
11361
11398
|
import { useFormContext as useFormContext5, Controller as Controller2 } from "react-hook-form";
|
|
11362
11399
|
import { Fragment as Fragment5, jsx as jsx47 } from "react/jsx-runtime";
|
|
11363
11400
|
function CityFormField({
|
|
@@ -11370,8 +11407,8 @@ function CityFormField({
|
|
|
11370
11407
|
}) {
|
|
11371
11408
|
const { control, watch } = useFormContext5();
|
|
11372
11409
|
const selectedState = watch(stateName);
|
|
11373
|
-
const [cities, setCities] =
|
|
11374
|
-
const [loading, setLoading] =
|
|
11410
|
+
const [cities, setCities] = useState11([]);
|
|
11411
|
+
const [loading, setLoading] = useState11(false);
|
|
11375
11412
|
useEffect8(() => {
|
|
11376
11413
|
if (!isBrazil) {
|
|
11377
11414
|
setCities([]);
|
|
@@ -11757,10 +11794,10 @@ var EmailFormField = ({
|
|
|
11757
11794
|
import { useController as useController3 } from "react-hook-form";
|
|
11758
11795
|
|
|
11759
11796
|
// src/components/RichEditor/RichEditor.tsx
|
|
11760
|
-
import { useEffect as useEffect10, useState as
|
|
11797
|
+
import { useEffect as useEffect10, useState as useState13 } from "react";
|
|
11761
11798
|
|
|
11762
11799
|
// src/components/RichEditor/QuillComponent.tsx
|
|
11763
|
-
import { useState as
|
|
11800
|
+
import { useState as useState12, useRef as useRef9, useEffect as useEffect9, useCallback as useCallback4 } from "react";
|
|
11764
11801
|
import { useQuill } from "react-quilljs";
|
|
11765
11802
|
|
|
11766
11803
|
// src/utils/uploadService.ts
|
|
@@ -12963,10 +13000,10 @@ var QuillComponent = ({
|
|
|
12963
13000
|
onCharacterCountChange,
|
|
12964
13001
|
maxLength
|
|
12965
13002
|
}) => {
|
|
12966
|
-
const [showVideoModal, setShowVideoModal] =
|
|
12967
|
-
const [videoUrl, setVideoUrl] =
|
|
12968
|
-
const [showLinkModal, setShowLinkModal] =
|
|
12969
|
-
const [linkUrl, setLinkUrl] =
|
|
13003
|
+
const [showVideoModal, setShowVideoModal] = useState12(false);
|
|
13004
|
+
const [videoUrl, setVideoUrl] = useState12("");
|
|
13005
|
+
const [showLinkModal, setShowLinkModal] = useState12(false);
|
|
13006
|
+
const [linkUrl, setLinkUrl] = useState12("");
|
|
12970
13007
|
const videoModalRef = useRef9(null);
|
|
12971
13008
|
const linkModalRef = useRef9(null);
|
|
12972
13009
|
const { addToast, removeToast } = useToast();
|
|
@@ -13020,7 +13057,8 @@ var QuillComponent = ({
|
|
|
13020
13057
|
[disabled, quill, addToast, removeToast, uploadConfig, onChange]
|
|
13021
13058
|
);
|
|
13022
13059
|
useEffect9(() => {
|
|
13023
|
-
if (quill
|
|
13060
|
+
if (!quill) return;
|
|
13061
|
+
if (value !== void 0 && value !== null) {
|
|
13024
13062
|
const currentContent = quill.root.innerHTML;
|
|
13025
13063
|
if (currentContent !== value) {
|
|
13026
13064
|
const selection = quill.getSelection();
|
|
@@ -13032,7 +13070,8 @@ var QuillComponent = ({
|
|
|
13032
13070
|
}
|
|
13033
13071
|
}
|
|
13034
13072
|
}
|
|
13035
|
-
|
|
13073
|
+
onCharacterCountChange == null ? void 0 : onCharacterCountChange(quill.getText().trim().length);
|
|
13074
|
+
}, [quill, value, onCharacterCountChange]);
|
|
13036
13075
|
useEffect9(() => {
|
|
13037
13076
|
if (quill) {
|
|
13038
13077
|
quill.on("text-change", (delta, oldDelta, source) => {
|
|
@@ -13323,7 +13362,7 @@ var QuillComponent_default = QuillComponent;
|
|
|
13323
13362
|
// src/components/RichEditor/RichEditor.tsx
|
|
13324
13363
|
import { jsx as jsx54 } from "react/jsx-runtime";
|
|
13325
13364
|
var RichEditor = (props) => {
|
|
13326
|
-
const [isClient, setIsClient] =
|
|
13365
|
+
const [isClient, setIsClient] = useState13(false);
|
|
13327
13366
|
useEffect10(() => {
|
|
13328
13367
|
setIsClient(typeof window !== "undefined");
|
|
13329
13368
|
}, []);
|
|
@@ -13346,8 +13385,21 @@ var RichTextPresenter = ({ richText }) => {
|
|
|
13346
13385
|
var RichTextPresenter_default = RichTextPresenter;
|
|
13347
13386
|
|
|
13348
13387
|
// src/components/FormFields/RichEditorFormField.tsx
|
|
13349
|
-
import { useState as
|
|
13388
|
+
import { useEffect as useEffect11, useState as useState14 } from "react";
|
|
13350
13389
|
import { Fragment as Fragment6, jsx as jsx56, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
13390
|
+
var getPlainTextLengthFromHtml = (html) => {
|
|
13391
|
+
var _a, _b;
|
|
13392
|
+
if (!html.trim()) return 0;
|
|
13393
|
+
if (typeof document === "undefined") {
|
|
13394
|
+
return html.replace(/<[^>]*>/g, "").trim().length;
|
|
13395
|
+
}
|
|
13396
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
13397
|
+
return (_b = (_a = doc.body.textContent) == null ? void 0 : _a.trim().length) != null ? _b : 0;
|
|
13398
|
+
};
|
|
13399
|
+
var getRemainingCharacters = (maxLength, value) => {
|
|
13400
|
+
if (maxLength === void 0) return maxLength;
|
|
13401
|
+
return Math.max(0, maxLength - getPlainTextLengthFromHtml(value != null ? value : ""));
|
|
13402
|
+
};
|
|
13351
13403
|
var RichEditorFormField = (_a) => {
|
|
13352
13404
|
var _b = _a, {
|
|
13353
13405
|
name,
|
|
@@ -13380,15 +13432,19 @@ var RichEditorFormField = (_a) => {
|
|
|
13380
13432
|
return true;
|
|
13381
13433
|
return (_a2 = validate == null ? void 0 : validate(value)) != null ? _a2 : true;
|
|
13382
13434
|
}
|
|
13383
|
-
}
|
|
13384
|
-
defaultValue: ""
|
|
13435
|
+
}
|
|
13385
13436
|
});
|
|
13386
|
-
const [caracterQuantity, setCaracterQuantity] =
|
|
13437
|
+
const [caracterQuantity, setCaracterQuantity] = useState14(
|
|
13438
|
+
() => getRemainingCharacters(maxLength, field.value)
|
|
13439
|
+
);
|
|
13387
13440
|
const handleCharacterCountChange = (count) => {
|
|
13388
13441
|
if (maxLength !== void 0) {
|
|
13389
13442
|
setCaracterQuantity(Math.max(0, maxLength - count));
|
|
13390
13443
|
}
|
|
13391
13444
|
};
|
|
13445
|
+
useEffect11(() => {
|
|
13446
|
+
setCaracterQuantity(getRemainingCharacters(maxLength, field.value));
|
|
13447
|
+
}, [field.value, maxLength]);
|
|
13392
13448
|
const fieldError = fieldState.error;
|
|
13393
13449
|
const haveError = !!fieldError;
|
|
13394
13450
|
const errorMsg = fieldError == null ? void 0 : fieldError.message;
|
|
@@ -13660,7 +13716,7 @@ var TimePickerFormField = (_a) => {
|
|
|
13660
13716
|
|
|
13661
13717
|
// src/components/FormFields/DateAndTimeFormField.tsx
|
|
13662
13718
|
import { useController as useController7 } from "react-hook-form";
|
|
13663
|
-
import { useCallback as useCallback8, useEffect as
|
|
13719
|
+
import { useCallback as useCallback8, useEffect as useEffect12, useMemo as useMemo4, useState as useState15 } from "react";
|
|
13664
13720
|
import { jsx as jsx60, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
13665
13721
|
var DateAndTimeFormField = (_a) => {
|
|
13666
13722
|
var _b = _a, {
|
|
@@ -13748,9 +13804,9 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13748
13804
|
return { selectedDateFromIso: void 0, selectedTimeFromIso: void 0 };
|
|
13749
13805
|
}
|
|
13750
13806
|
}, [isoValue]);
|
|
13751
|
-
const [draftDate, setDraftDate] =
|
|
13752
|
-
const [draftTime, setDraftTime] =
|
|
13753
|
-
|
|
13807
|
+
const [draftDate, setDraftDate] = useState15(selectedDateFromIso);
|
|
13808
|
+
const [draftTime, setDraftTime] = useState15(selectedTimeFromIso);
|
|
13809
|
+
useEffect12(() => {
|
|
13754
13810
|
setDraftDate(selectedDateFromIso);
|
|
13755
13811
|
setDraftTime(selectedTimeFromIso);
|
|
13756
13812
|
}, [selectedDateFromIso, selectedTimeFromIso]);
|
|
@@ -13841,11 +13897,11 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13841
13897
|
};
|
|
13842
13898
|
|
|
13843
13899
|
// src/hooks/useImageUpload.ts
|
|
13844
|
-
import { useState as
|
|
13900
|
+
import { useState as useState16, useCallback as useCallback9 } from "react";
|
|
13845
13901
|
var useImageUpload = (options) => {
|
|
13846
|
-
const [isUploading, setIsUploading] =
|
|
13847
|
-
const [progress, setProgress] =
|
|
13848
|
-
const [error, setError] =
|
|
13902
|
+
const [isUploading, setIsUploading] = useState16(false);
|
|
13903
|
+
const [progress, setProgress] = useState16(null);
|
|
13904
|
+
const [error, setError] = useState16(null);
|
|
13849
13905
|
const {
|
|
13850
13906
|
onSuccess,
|
|
13851
13907
|
onError,
|
package/package.json
CHANGED
|
@@ -24,6 +24,7 @@ export type DrawerProps = ComponentProps<typeof DrawerOverlayStyled> & {
|
|
|
24
24
|
goBackAction?: () => void;
|
|
25
25
|
zIndex?: number;
|
|
26
26
|
clickOutsideAvailable?: boolean;
|
|
27
|
+
actionButton?: ReactNode;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export function Drawer({
|
|
@@ -37,6 +38,7 @@ export function Drawer({
|
|
|
37
38
|
goBackAction,
|
|
38
39
|
zIndex = 1000,
|
|
39
40
|
clickOutsideAvailable = true,
|
|
41
|
+
actionButton = null,
|
|
40
42
|
}: DrawerProps) {
|
|
41
43
|
useEffect(() => {
|
|
42
44
|
if (isOpen) {
|
|
@@ -91,9 +93,12 @@ export function Drawer({
|
|
|
91
93
|
)}
|
|
92
94
|
<DrawerHeaderTitle>{title}</DrawerHeaderTitle>
|
|
93
95
|
</Flex>
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
<Flex gap={8}>
|
|
97
|
+
{actionButton && actionButton}
|
|
98
|
+
<DrawerHeaderCloseButton onClick={onClose}>
|
|
99
|
+
<Icon size={"xl"} color="$dark600" name="xmark" />
|
|
100
|
+
</DrawerHeaderCloseButton>
|
|
101
|
+
</Flex>
|
|
97
102
|
</DrawerHeaderDiv>
|
|
98
103
|
{isOpen ? children : null}
|
|
99
104
|
</DrawerContainerStyled>
|
|
@@ -3,9 +3,25 @@ import { Flex } from "../Flex";
|
|
|
3
3
|
import { FormLabel } from "./subComponents/FormLabel";
|
|
4
4
|
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
5
|
import { RichEditor, RichEditorProps } from "../RichEditor";
|
|
6
|
-
import { useState } from "react";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
7
|
import { Badge } from "../Badge";
|
|
8
8
|
import { RichEditorElement } from "../RichEditor/types";
|
|
9
|
+
|
|
10
|
+
const getPlainTextLengthFromHtml = (html: string) => {
|
|
11
|
+
if (!html.trim()) return 0;
|
|
12
|
+
|
|
13
|
+
if (typeof document === "undefined") {
|
|
14
|
+
return html.replace(/<[^>]*>/g, "").trim().length;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
18
|
+
return doc.body.textContent?.trim().length ?? 0;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getRemainingCharacters = (maxLength: number | undefined, value?: string) => {
|
|
22
|
+
if (maxLength === undefined) return maxLength;
|
|
23
|
+
return Math.max(0, maxLength - getPlainTextLengthFromHtml(value ?? ""));
|
|
24
|
+
};
|
|
9
25
|
export type RichEditorFormFieldProps = Omit<
|
|
10
26
|
RichEditorProps,
|
|
11
27
|
"value" | "onChange"
|
|
@@ -48,14 +64,20 @@ export const RichEditorFormField = ({
|
|
|
48
64
|
return validate?.(value) ?? true;
|
|
49
65
|
},
|
|
50
66
|
},
|
|
51
|
-
defaultValue: "",
|
|
52
67
|
});
|
|
53
|
-
const [caracterQuantity, setCaracterQuantity] = useState(
|
|
68
|
+
const [caracterQuantity, setCaracterQuantity] = useState(() =>
|
|
69
|
+
getRemainingCharacters(maxLength, field.value),
|
|
70
|
+
);
|
|
71
|
+
|
|
54
72
|
const handleCharacterCountChange = (count: number) => {
|
|
55
73
|
if (maxLength !== undefined) {
|
|
56
74
|
setCaracterQuantity(Math.max(0, maxLength - count));
|
|
57
75
|
}
|
|
58
76
|
};
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
setCaracterQuantity(getRemainingCharacters(maxLength, field.value));
|
|
80
|
+
}, [field.value, maxLength]);
|
|
59
81
|
const fieldError = fieldState.error;
|
|
60
82
|
const haveError = !!fieldError;
|
|
61
83
|
const errorMsg = fieldError?.message;
|
|
@@ -90,7 +90,9 @@ const QuillComponent: React.FC<RichEditorProps> = ({
|
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
useEffect(() => {
|
|
93
|
-
if (quill
|
|
93
|
+
if (!quill) return;
|
|
94
|
+
|
|
95
|
+
if (value !== undefined && value !== null) {
|
|
94
96
|
const currentContent = quill.root.innerHTML;
|
|
95
97
|
if (currentContent !== value) {
|
|
96
98
|
const selection = quill.getSelection();
|
|
@@ -103,7 +105,9 @@ const QuillComponent: React.FC<RichEditorProps> = ({
|
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
|
-
|
|
108
|
+
|
|
109
|
+
onCharacterCountChange?.(quill.getText().trim().length);
|
|
110
|
+
}, [quill, value, onCharacterCountChange]);
|
|
107
111
|
|
|
108
112
|
useEffect(() => {
|
|
109
113
|
if (quill) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ComponentProps, ReactNode } from "react";
|
|
1
|
+
import React, { ComponentProps, ReactNode, useLayoutEffect, useState } from "react";
|
|
2
2
|
import { styled } from "../styles";
|
|
3
3
|
import { TextField as TextFieldRadix } from "@radix-ui/themes";
|
|
4
4
|
import Icon from "./Icon";
|
|
@@ -250,23 +250,81 @@ export const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
250
250
|
mask,
|
|
251
251
|
maxLength,
|
|
252
252
|
hasError,
|
|
253
|
+
value,
|
|
254
|
+
defaultValue,
|
|
255
|
+
onInput,
|
|
253
256
|
...props
|
|
254
257
|
},
|
|
255
258
|
fowardedRef
|
|
256
259
|
) => {
|
|
260
|
+
const { ref: propRef, ...restProps } = props as typeof props & {
|
|
261
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
262
|
+
};
|
|
257
263
|
const maskRef = mask ? useMask(mask) : undefined;
|
|
258
264
|
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
259
|
-
const badgeRef = React.useRef<HTMLSpanElement>(null);
|
|
260
265
|
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
266
|
+
const getTextLength = (
|
|
267
|
+
text?: string | number | readonly string[] | null,
|
|
268
|
+
) => String(text ?? "").length;
|
|
269
|
+
|
|
270
|
+
const updateRemaining = (currentLength: number) => {
|
|
271
|
+
if (maxLength !== undefined) {
|
|
272
|
+
setRemaining(maxLength - currentLength);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const getCurrentLength = (inputElement?: HTMLInputElement | null) => {
|
|
277
|
+
if (value !== undefined && value !== null) {
|
|
278
|
+
return getTextLength(value);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
inputElement?.value.length ??
|
|
283
|
+
inputRef.current?.value.length ??
|
|
284
|
+
getTextLength(defaultValue)
|
|
285
|
+
);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const [remaining, setRemaining] = useState(() =>
|
|
289
|
+
maxLength !== undefined
|
|
290
|
+
? maxLength - getTextLength(value ?? defaultValue)
|
|
291
|
+
: 0,
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
useLayoutEffect(() => {
|
|
295
|
+
if (maxLength === undefined) return;
|
|
296
|
+
updateRemaining(getCurrentLength());
|
|
297
|
+
}, [maxLength, value, defaultValue]);
|
|
298
|
+
|
|
299
|
+
const assignRef = (element: HTMLInputElement | null) => {
|
|
300
|
+
inputRef.current = element;
|
|
301
|
+
|
|
302
|
+
if (maskRef && element) {
|
|
303
|
+
maskRef.current = element;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (typeof propRef === "function") {
|
|
307
|
+
propRef(element);
|
|
308
|
+
} else if (propRef) {
|
|
309
|
+
propRef.current = element;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (typeof fowardedRef === "function") {
|
|
313
|
+
fowardedRef(element);
|
|
314
|
+
} else if (fowardedRef) {
|
|
315
|
+
fowardedRef.current = element;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (element && maxLength !== undefined) {
|
|
319
|
+
updateRemaining(getCurrentLength(element));
|
|
320
|
+
}
|
|
265
321
|
};
|
|
266
322
|
|
|
267
323
|
const handleInput = (e: React.FormEvent<HTMLInputElement>) => {
|
|
268
|
-
|
|
269
|
-
|
|
324
|
+
if (maxLength !== undefined) {
|
|
325
|
+
updateRemaining(e.currentTarget.value.length);
|
|
326
|
+
}
|
|
327
|
+
onInput?.(e);
|
|
270
328
|
};
|
|
271
329
|
|
|
272
330
|
return (
|
|
@@ -282,6 +340,7 @@ export const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
282
340
|
)}
|
|
283
341
|
|
|
284
342
|
<TextFieldStyled
|
|
343
|
+
{...restProps}
|
|
285
344
|
color={hasError ? "error" : color || "default"}
|
|
286
345
|
isValid={isValid}
|
|
287
346
|
name={name}
|
|
@@ -289,18 +348,10 @@ export const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
289
348
|
fontWeight={fontWeight}
|
|
290
349
|
textAlign={textAlign}
|
|
291
350
|
maxLength={maxLength}
|
|
292
|
-
ref={
|
|
293
|
-
if (!r) return;
|
|
294
|
-
inputRef.current = r;
|
|
295
|
-
if (maskRef) maskRef.current = r;
|
|
296
|
-
|
|
297
|
-
if (fowardedRef) {
|
|
298
|
-
if (typeof fowardedRef === "function") fowardedRef(r);
|
|
299
|
-
else fowardedRef.current = r;
|
|
300
|
-
}
|
|
301
|
-
}}
|
|
351
|
+
ref={assignRef}
|
|
302
352
|
onInput={handleInput}
|
|
303
|
-
{
|
|
353
|
+
value={value}
|
|
354
|
+
defaultValue={defaultValue}
|
|
304
355
|
style={
|
|
305
356
|
addon
|
|
306
357
|
? {
|
|
@@ -329,7 +380,7 @@ export const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
329
380
|
</Flex>
|
|
330
381
|
{maxLength && (
|
|
331
382
|
<TextFieldLimitIndicator>
|
|
332
|
-
<span
|
|
383
|
+
<span>{remaining}</span>
|
|
333
384
|
</TextFieldLimitIndicator>
|
|
334
385
|
)}
|
|
335
386
|
</Flex>
|