@mlw-packages/react-components 1.9.8 → 1.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -29,7 +29,6 @@ var HoverCardPrimitive = require('@radix-ui/react-hover-card');
29
29
  var inputOtp = require('input-otp');
30
30
  var SliderPrimitive = require('@radix-ui/react-slider');
31
31
  var SwitchPrimitives = require('@radix-ui/react-switch');
32
- var useEmblaCarousel = require('embla-carousel-react');
33
32
  var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
34
33
  var SeparatorPrimitive = require('@radix-ui/react-separator');
35
34
  var TabsPrimitive = require('@radix-ui/react-tabs');
@@ -79,7 +78,6 @@ var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespace(Collapsible
79
78
  var HoverCardPrimitive__namespace = /*#__PURE__*/_interopNamespace(HoverCardPrimitive);
80
79
  var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
81
80
  var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
82
- var useEmblaCarousel__default = /*#__PURE__*/_interopDefault(useEmblaCarousel);
83
81
  var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
84
82
  var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
85
83
  var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
@@ -1893,7 +1891,8 @@ var InputBase = React33__namespace.forwardRef(
1893
1891
  className: cn(
1894
1892
  "flex items-center rounded-md transition h-9 bg-background overflow-hidden",
1895
1893
  type !== "file" && "border border-input",
1896
- error ? "border-destructive focus:ring-1 focus:ring-destructive" : "border-input"
1894
+ error ? "border-destructive focus:ring-1 focus:ring-destructive" : "border-input",
1895
+ className
1897
1896
  ),
1898
1897
  children: [
1899
1898
  leftIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center px-2", children: leftIcon }),
@@ -1921,6 +1920,65 @@ var InputBase = React33__namespace.forwardRef(
1921
1920
  }
1922
1921
  );
1923
1922
  InputBase.displayName = "Input";
1923
+ var DebouncedInput = React33.forwardRef(
1924
+ ({
1925
+ value: initialValue,
1926
+ onChange,
1927
+ debounce: debounce2 = 500,
1928
+ label,
1929
+ labelClassname,
1930
+ leftIcon,
1931
+ rightIcon,
1932
+ showLoadingIndicator = false,
1933
+ className,
1934
+ error,
1935
+ ...props
1936
+ }, ref) => {
1937
+ const [value, setValue] = React33.useState(initialValue);
1938
+ const [isDebouncing, setIsDebouncing] = React33.useState(false);
1939
+ React33.useEffect(() => {
1940
+ setValue(initialValue);
1941
+ }, [initialValue]);
1942
+ React33.useEffect(() => {
1943
+ if (value === initialValue) {
1944
+ setIsDebouncing(false);
1945
+ return;
1946
+ }
1947
+ setIsDebouncing(true);
1948
+ const timeout = setTimeout(() => {
1949
+ onChange(value);
1950
+ setIsDebouncing(false);
1951
+ }, debounce2);
1952
+ return () => {
1953
+ clearTimeout(timeout);
1954
+ setIsDebouncing(false);
1955
+ };
1956
+ }, [debounce2, initialValue, onChange, value]);
1957
+ const renderRightIcon = () => {
1958
+ if (showLoadingIndicator && isDebouncing) {
1959
+ return /* @__PURE__ */ jsxRuntime.jsx(react.CircleNotchIcon, { className: "h-4 w-4 animate-spin text-muted-foreground" });
1960
+ }
1961
+ return rightIcon;
1962
+ };
1963
+ return /* @__PURE__ */ jsxRuntime.jsx(
1964
+ InputBase,
1965
+ {
1966
+ ...props,
1967
+ ref,
1968
+ label,
1969
+ labelClassname,
1970
+ leftIcon,
1971
+ rightIcon: renderRightIcon(),
1972
+ className: cn("transition-all duration-200", className),
1973
+ value,
1974
+ onChange: (e) => setValue(e.target.value),
1975
+ error
1976
+ }
1977
+ );
1978
+ }
1979
+ );
1980
+ DebouncedInput.displayName = "DebouncedInput";
1981
+ var DebouncedInput_default = DebouncedInput;
1924
1982
  var CommandBase = React33__namespace.forwardRef(({ className, testid: dataTestId = "command-base", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1925
1983
  cmdk.Command,
1926
1984
  {
@@ -1977,29 +2035,47 @@ var CommandInputBase = React33__namespace.forwardRef(({ className, testid: dataT
1977
2035
  }
1978
2036
  ));
1979
2037
  CommandInputBase.displayName = cmdk.Command.Input.displayName;
1980
- var CommandDebouncedInputBase = React33__namespace.forwardRef(({ className, testid: dataTestId = "command-input", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1981
- "div",
1982
- {
1983
- className: "flex items-center border-b px-3 border-border",
1984
- "cmdk-input-wrapper": "",
1985
- children: [
1986
- /* @__PURE__ */ jsxRuntime.jsx(react.MagnifyingGlassIcon, { className: "mr-2 h-4 w-4 shrink-0 text-primary" }),
1987
- /* @__PURE__ */ jsxRuntime.jsx(
1988
- cmdk.Command.Input,
1989
- {
1990
- ref,
1991
- className: cn(
1992
- "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none text-primary placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
1993
- className
1994
- ),
1995
- "data-testid": dataTestId,
1996
- ...props
1997
- }
1998
- )
1999
- ]
2000
- }
2001
- ));
2002
- CommandDebouncedInputBase.displayName = cmdk.Command.Input.displayName;
2038
+ var CommandDebouncedInputBase = React33__namespace.forwardRef(
2039
+ ({
2040
+ className,
2041
+ testid: dataTestId = "command-input",
2042
+ onValueChange,
2043
+ value: propValue,
2044
+ onChange: propOnChange,
2045
+ search,
2046
+ onSearch,
2047
+ ...props
2048
+ }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
2049
+ "div",
2050
+ {
2051
+ className: "flex items-center px-3 border-border border-b",
2052
+ "cmdk-input-wrapper": "",
2053
+ children: [
2054
+ /* @__PURE__ */ jsxRuntime.jsx(react.MagnifyingGlassIcon, { className: "mr-2 h-4 w-4 shrink-0 text-primary" }),
2055
+ /* @__PURE__ */ jsxRuntime.jsx(
2056
+ DebouncedInput_default,
2057
+ {
2058
+ ref,
2059
+ className: cn(
2060
+ "flex h-10 border-transparent w-full rounded-md bg-transparent text-sm outline-none text-primary placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
2061
+ className
2062
+ ),
2063
+ "data-testid": dataTestId,
2064
+ "cmdk-input": "",
2065
+ value: search ?? propValue ?? "",
2066
+ ...props,
2067
+ onChange: (value) => {
2068
+ onValueChange?.(value);
2069
+ propOnChange?.(value);
2070
+ onSearch?.(value);
2071
+ }
2072
+ }
2073
+ )
2074
+ ]
2075
+ }
2076
+ )
2077
+ );
2078
+ CommandDebouncedInputBase.displayName = "CommandDebouncedInputBase";
2003
2079
  var CommandListBase = React33__namespace.forwardRef(
2004
2080
  ({ className, testid: dataTestId = "command-list", onEndReached, ...props }, ref) => {
2005
2081
  const listRef = React33__namespace.useRef(null);
@@ -3679,7 +3755,7 @@ var FileUploader = React33__namespace.forwardRef(
3679
3755
  showPreview = true,
3680
3756
  dropzoneText = "Arraste arquivos aqui ou clique para selecionar",
3681
3757
  dropzoneSubtext,
3682
- animate = true,
3758
+ animate: animate2 = true,
3683
3759
  ...props
3684
3760
  }, ref) => {
3685
3761
  const [isDragging, setIsDragging] = React33__namespace.useState(false);
@@ -3887,7 +3963,7 @@ var FileUploader = React33__namespace.forwardRef(
3887
3963
  framerMotion.motion.p,
3888
3964
  {
3889
3965
  className: "mb-2 text-base font-semibold text-foreground",
3890
- initial: animate ? { opacity: 0, y: -10 } : false,
3966
+ initial: animate2 ? { opacity: 0, y: -10 } : false,
3891
3967
  animate: { opacity: 1, y: 0 },
3892
3968
  transition: { delay: 0.1 },
3893
3969
  children: dropzoneText
@@ -3897,7 +3973,7 @@ var FileUploader = React33__namespace.forwardRef(
3897
3973
  framerMotion.motion.p,
3898
3974
  {
3899
3975
  className: "text-sm text-muted-foreground",
3900
- initial: animate ? { opacity: 0, y: -10 } : false,
3976
+ initial: animate2 ? { opacity: 0, y: -10 } : false,
3901
3977
  animate: { opacity: 1, y: 0 },
3902
3978
  transition: { delay: 0.2 },
3903
3979
  children: defaultSubtext
@@ -3941,7 +4017,7 @@ var FileUploader = React33__namespace.forwardRef(
3941
4017
  framerMotion.motion.div,
3942
4018
  {
3943
4019
  className: "mt-6 w-full",
3944
- initial: animate ? { opacity: 0, y: 10 } : false,
4020
+ initial: animate2 ? { opacity: 0, y: 10 } : false,
3945
4021
  animate: { opacity: 1, y: 0 },
3946
4022
  transition: { delay: 0.3 },
3947
4023
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
@@ -3956,7 +4032,7 @@ var FileUploader = React33__namespace.forwardRef(
3956
4032
  framerMotion.motion.div,
3957
4033
  {
3958
4034
  layout: true,
3959
- initial: animate ? { opacity: 0, x: -20 } : false,
4035
+ initial: animate2 ? { opacity: 0, x: -20 } : false,
3960
4036
  animate: { opacity: 1, x: 0 },
3961
4037
  exit: {
3962
4038
  opacity: 0,
@@ -3964,7 +4040,7 @@ var FileUploader = React33__namespace.forwardRef(
3964
4040
  transition: { duration: 0.2 }
3965
4041
  },
3966
4042
  transition: {
3967
- delay: animate ? index * 0.05 : 0,
4043
+ delay: animate2 ? index * 0.05 : 0,
3968
4044
  layout: { duration: 0.2 }
3969
4045
  },
3970
4046
  className: cn(
@@ -5202,201 +5278,6 @@ var TextAreaBase = React33__namespace.forwardRef(
5202
5278
  }
5203
5279
  );
5204
5280
  TextAreaBase.displayName = "TextAreaBase";
5205
- var CarouselContext = React33__namespace.createContext(null);
5206
- function useCarousel() {
5207
- const context = React33__namespace.useContext(CarouselContext);
5208
- if (!context) {
5209
- throw new Error("useCarousel must be used within a <CarouselBase />");
5210
- }
5211
- return context;
5212
- }
5213
- function CarouselBase({
5214
- orientation = "horizontal",
5215
- opts,
5216
- setApi,
5217
- plugins,
5218
- className,
5219
- children,
5220
- ...props
5221
- }) {
5222
- const [carouselRef, api] = useEmblaCarousel__default.default(
5223
- {
5224
- ...opts,
5225
- axis: orientation === "horizontal" ? "x" : "y"
5226
- },
5227
- plugins
5228
- );
5229
- const [canScrollPrev, setCanScrollPrev] = React33__namespace.useState(false);
5230
- const [canScrollNext, setCanScrollNext] = React33__namespace.useState(false);
5231
- const onSelect = React33__namespace.useCallback((api2) => {
5232
- if (!api2) return;
5233
- setCanScrollPrev(api2.canScrollPrev());
5234
- setCanScrollNext(api2.canScrollNext());
5235
- }, []);
5236
- const scrollPrev = React33__namespace.useCallback(() => {
5237
- api?.scrollPrev();
5238
- }, [api]);
5239
- const scrollNext = React33__namespace.useCallback(() => {
5240
- api?.scrollNext();
5241
- }, [api]);
5242
- const handleKeyDown = React33__namespace.useCallback(
5243
- (event) => {
5244
- if (event.key === "ArrowLeft") {
5245
- event.preventDefault();
5246
- scrollPrev();
5247
- } else if (event.key === "ArrowRight") {
5248
- event.preventDefault();
5249
- scrollNext();
5250
- }
5251
- },
5252
- [scrollPrev, scrollNext]
5253
- );
5254
- React33__namespace.useEffect(() => {
5255
- if (!api || !setApi) return;
5256
- setApi(api);
5257
- }, [api, setApi]);
5258
- React33__namespace.useEffect(() => {
5259
- if (!api) return;
5260
- onSelect(api);
5261
- api.on("reInit", onSelect);
5262
- api.on("select", onSelect);
5263
- return () => {
5264
- api?.off("select", onSelect);
5265
- };
5266
- }, [api, onSelect]);
5267
- return /* @__PURE__ */ jsxRuntime.jsx(
5268
- CarouselContext.Provider,
5269
- {
5270
- value: {
5271
- carouselRef,
5272
- api,
5273
- opts,
5274
- orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
5275
- scrollPrev,
5276
- scrollNext,
5277
- canScrollPrev,
5278
- canScrollNext
5279
- },
5280
- children: /* @__PURE__ */ jsxRuntime.jsx(
5281
- "div",
5282
- {
5283
- onKeyDownCapture: handleKeyDown,
5284
- className: cn("relative", className),
5285
- role: "region",
5286
- "aria-roledescription": "carousel",
5287
- "data-slot": "carousel",
5288
- ...props,
5289
- children
5290
- }
5291
- )
5292
- }
5293
- );
5294
- }
5295
- function CarouselContentBase({
5296
- className,
5297
- ...props
5298
- }) {
5299
- const { carouselRef, orientation } = useCarousel();
5300
- return /* @__PURE__ */ jsxRuntime.jsx(
5301
- "div",
5302
- {
5303
- ref: carouselRef,
5304
- className: "overflow-hidden",
5305
- "data-slot": "carousel-content",
5306
- children: /* @__PURE__ */ jsxRuntime.jsx(
5307
- "div",
5308
- {
5309
- className: cn(
5310
- "flex",
5311
- orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
5312
- className
5313
- ),
5314
- ...props
5315
- }
5316
- )
5317
- }
5318
- );
5319
- }
5320
- function CarouselItemBase({
5321
- className,
5322
- ...props
5323
- }) {
5324
- const { orientation } = useCarousel();
5325
- return /* @__PURE__ */ jsxRuntime.jsx(
5326
- "div",
5327
- {
5328
- role: "group",
5329
- "aria-roledescription": "slide",
5330
- "data-slot": "carousel-item",
5331
- className: cn(
5332
- "min-w-0 shrink-0 grow-0 basis-full",
5333
- orientation === "horizontal" ? "pl-4" : "pt-4",
5334
- className
5335
- ),
5336
- ...props
5337
- }
5338
- );
5339
- }
5340
- function CarouselPreviousBase({
5341
- className,
5342
- variant = "outline",
5343
- size = "icon",
5344
- ...props
5345
- }) {
5346
- const { orientation, scrollPrev, canScrollPrev } = useCarousel();
5347
- const btnRef = React33__namespace.useRef(null);
5348
- return /* @__PURE__ */ jsxRuntime.jsxs(
5349
- ButtonBase,
5350
- {
5351
- "data-slot": "carousel-previous",
5352
- variant,
5353
- size,
5354
- ref: btnRef,
5355
- className: cn(
5356
- "absolute size-8 rounded-l-3xl px-6",
5357
- orientation === "horizontal" ? "top-2 right-1" : "bottom-64 left-1/3 rotate-90",
5358
- className
5359
- ),
5360
- disabled: !canScrollPrev,
5361
- onClick: scrollPrev,
5362
- ...props,
5363
- children: [
5364
- /* @__PURE__ */ jsxRuntime.jsx(react.ArrowLeftIcon, {}),
5365
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Previous slide" })
5366
- ]
5367
- }
5368
- );
5369
- }
5370
- function CarouselNextBase({
5371
- className,
5372
- variant = "outline",
5373
- size = "icon",
5374
- ...props
5375
- }) {
5376
- const { orientation, scrollNext, canScrollNext } = useCarousel();
5377
- const btnRef = React33__namespace.useRef(null);
5378
- return /* @__PURE__ */ jsxRuntime.jsxs(
5379
- ButtonBase,
5380
- {
5381
- "data-slot": "carousel-next",
5382
- variant,
5383
- size,
5384
- ref: btnRef,
5385
- className: cn(
5386
- "absolute size-8 rounded-r-3xl px-6",
5387
- orientation === "horizontal" ? "top-2" : "left-14 -translate-x-1/2 rotate-90",
5388
- className
5389
- ),
5390
- disabled: !canScrollNext,
5391
- onClick: scrollNext,
5392
- ...props,
5393
- children: [
5394
- /* @__PURE__ */ jsxRuntime.jsx(react.ArrowRightIcon, {}),
5395
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Next slide" })
5396
- ]
5397
- }
5398
- );
5399
- }
5400
5281
  var ScrollAreaBase = React33__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
5401
5282
  ScrollAreaPrimitive__namespace.Root,
5402
5283
  {
@@ -7366,62 +7247,6 @@ function StatusIndicator({
7366
7247
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0", children })
7367
7248
  ] });
7368
7249
  }
7369
- var DebouncedInput = React33.forwardRef(
7370
- ({
7371
- value: initialValue,
7372
- onChange,
7373
- debounce: debounce2 = 500,
7374
- label,
7375
- labelClassname,
7376
- leftIcon,
7377
- rightIcon,
7378
- showLoadingIndicator = false,
7379
- className,
7380
- error,
7381
- ...props
7382
- }, ref) => {
7383
- const [value, setValue] = React33.useState(initialValue);
7384
- const [isDebouncing, setIsDebouncing] = React33.useState(false);
7385
- React33.useEffect(() => {
7386
- setValue(initialValue);
7387
- }, [initialValue]);
7388
- React33.useEffect(() => {
7389
- if (value !== initialValue) {
7390
- setIsDebouncing(true);
7391
- }
7392
- const timeout = setTimeout(() => {
7393
- onChange(value);
7394
- setIsDebouncing(false);
7395
- }, debounce2);
7396
- return () => {
7397
- clearTimeout(timeout);
7398
- setIsDebouncing(false);
7399
- };
7400
- }, [debounce2, initialValue, onChange, value]);
7401
- const renderRightIcon = () => {
7402
- if (showLoadingIndicator && isDebouncing) {
7403
- return /* @__PURE__ */ jsxRuntime.jsx(react.CircleNotchIcon, { className: "h-4 w-4 animate-spin text-muted-foreground" });
7404
- }
7405
- return rightIcon;
7406
- };
7407
- return /* @__PURE__ */ jsxRuntime.jsx(
7408
- InputBase,
7409
- {
7410
- ...props,
7411
- ref,
7412
- label,
7413
- labelClassname,
7414
- leftIcon,
7415
- rightIcon: renderRightIcon(),
7416
- className: cn("transition-all duration-200", className),
7417
- value,
7418
- onChange: (e) => setValue(e.target.value),
7419
- error
7420
- }
7421
- );
7422
- }
7423
- );
7424
- DebouncedInput.displayName = "DebouncedInput";
7425
7250
  function useCheckboxTree(initialTree) {
7426
7251
  const initialCheckedNodes = React33.useMemo(() => {
7427
7252
  const checkedSet = /* @__PURE__ */ new Set();
@@ -18865,11 +18690,6 @@ exports.CardDescriptionBase = CardDescriptionBase;
18865
18690
  exports.CardFooterBase = CardFooterBase;
18866
18691
  exports.CardHeaderBase = CardHeaderBase;
18867
18692
  exports.CardTitleBase = CardTitleBase;
18868
- exports.CarouselBase = CarouselBase;
18869
- exports.CarouselContentBase = CarouselContentBase;
18870
- exports.CarouselItemBase = CarouselItemBase;
18871
- exports.CarouselNextBase = CarouselNextBase;
18872
- exports.CarouselPreviousBase = CarouselPreviousBase;
18873
18693
  exports.ChangeButton = ChangeButton;
18874
18694
  exports.Chart = Chart_default;
18875
18695
  exports.ChartControls = ChartControls;
@@ -18886,6 +18706,7 @@ exports.CollapsibleContentBase = CollapsibleContentBase;
18886
18706
  exports.CollapsibleTriggerBase = CollapsibleTriggerBase;
18887
18707
  exports.Combobox = Combobox;
18888
18708
  exports.CommandBase = CommandBase;
18709
+ exports.CommandDebouncedInputBase = CommandDebouncedInputBase;
18889
18710
  exports.CommandDialogBase = CommandDialogBase;
18890
18711
  exports.CommandEmptyBase = CommandEmptyBase;
18891
18712
  exports.CommandGroupBase = CommandGroupBase;