@mlw-packages/react-components 1.10.17 → 1.10.18

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
@@ -2572,6 +2572,7 @@ var badgeVariants = classVarianceAuthority.cva(
2572
2572
  function Badge({
2573
2573
  className,
2574
2574
  color,
2575
+ rank,
2575
2576
  size = "md",
2576
2577
  asChild = false,
2577
2578
  children,
@@ -2588,6 +2589,12 @@ function Badge({
2588
2589
  blue: "bg-blue-50 text-blue-500 border-blue-200",
2589
2590
  purple: "bg-purple-50 text-purple-500 border-purple-200"
2590
2591
  };
2592
+ const rankClasses = {
2593
+ diamond: "bg-cyan-100 text-cyan-600 border-cyan-300",
2594
+ gold: "bg-yellow-100 text-yellow-500 border-yellow-300",
2595
+ silver: "bg-gray-100 text-gray-500 border-gray-300",
2596
+ bronze: "bg-orange-100 text-orange-700 border-orange-300"
2597
+ };
2591
2598
  return /* @__PURE__ */ jsxRuntime.jsx(
2592
2599
  Comp,
2593
2600
  {
@@ -2595,6 +2602,7 @@ function Badge({
2595
2602
  className: cn(
2596
2603
  badgeVariants({ size }),
2597
2604
  color ? colorClasses[color] : void 0,
2605
+ rank ? rankClasses[rank] : void 0,
2598
2606
  className
2599
2607
  ),
2600
2608
  style: customStyle,
@@ -7858,7 +7866,8 @@ function DateTimePicker({
7858
7866
  disabled,
7859
7867
  className,
7860
7868
  error,
7861
- hideClear = true
7869
+ hideClear = true,
7870
+ triggerIcon
7862
7871
  }) {
7863
7872
  const [internalDate, setInternalDate] = React32.useState(date);
7864
7873
  const [open, setOpen] = React32.useState(false);
@@ -7908,193 +7917,222 @@ function DateTimePicker({
7908
7917
  const { ref: contentRef, center } = use_auto_center_default(open);
7909
7918
  const basePopoverClass = "w-auto max-w-[calc(100vw-16px)] p-0 border-none shadow-none";
7910
7919
  const centeredPopoverClass = "w-auto max-w-[calc(100vw-16px)] p-0 border-none shadow-none fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-50";
7911
- const renderTriggerButton = () => /* @__PURE__ */ jsxRuntime.jsxs(
7912
- ButtonBase,
7913
- {
7914
- variant: "outline",
7915
- disabled,
7916
- className: cn(
7917
- "w-full justify-start text-left min-w-0 overflow-hidden",
7918
- !date && "text-muted-foreground"
7919
- ),
7920
- children: [
7921
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("truncate flex-1", !date && "text-muted-foreground"), children: date ? dateFns.format(date, getDisplayFormat(), { locale: locale.ptBR }) : "Selecione uma data" }),
7922
- /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.span, { className: "flex items-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-0 items-center ", children: [
7923
- hideClear && (date || internalDate) && /* @__PURE__ */ jsxRuntime.jsx(
7924
- ClearButton,
7925
- {
7926
- onClick: (e) => {
7927
- e?.stopPropagation();
7928
- setInternalDate(null);
7929
- onChange?.(null);
7930
- onConfirm?.(null);
7931
- }
7932
- }
7933
- ),
7934
- /* @__PURE__ */ jsxRuntime.jsx(
7935
- framerMotion.motion.div,
7936
- {
7937
- animate: { rotate: open ? 15 : 0 },
7938
- transition: { duration: 0.03 },
7939
- children: /* @__PURE__ */ jsxRuntime.jsx(react.CalendarBlankIcon, { className: "h-4 w-4" })
7940
- }
7941
- )
7942
- ] }) })
7943
- ]
7920
+ const renderTriggerButton = () => {
7921
+ if (triggerIcon) {
7922
+ return /* @__PURE__ */ jsxRuntime.jsx(
7923
+ ButtonBase,
7924
+ {
7925
+ variant: "outline",
7926
+ size: "icon",
7927
+ disabled,
7928
+ className: cn("no-active-animation", error && "border-red-500"),
7929
+ children: /* @__PURE__ */ jsxRuntime.jsx(react.CalendarBlankIcon, { className: "h-4 w-4" })
7930
+ }
7931
+ );
7944
7932
  }
7945
- );
7946
- const renderPickerContent = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 sm:p-3 border border-border rounded-md", children: [
7947
- isMobile && !hideTime ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-h-0", children: [
7948
- internalDate && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-3 px-4 py-3 rounded-lg ", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-md font-semibold", children: [
7949
- dateFns.format(internalDate, "dd 'de' MMMM 'de' yyyy", {
7950
- locale: locale.ptBR
7951
- }),
7952
- " ",
7953
- "- ",
7954
- dateFns.format(internalDate, hideSeconds ? "HH:mm" : "HH:mm:ss")
7955
- ] }) }),
7956
- /* @__PURE__ */ jsxRuntime.jsxs(TabsBase, { value: activeTab, onValueChange: setActiveTab, children: [
7957
- /* @__PURE__ */ jsxRuntime.jsxs(TabsListBase, { className: "", children: [
7958
- /* @__PURE__ */ jsxRuntime.jsx(TabsTriggerBase, { value: "calendar", className: "flex-1", children: "Data" }),
7959
- /* @__PURE__ */ jsxRuntime.jsx(TabsTriggerBase, { value: "time", className: "flex-1", children: "Hor\xE1rio" })
7960
- ] }),
7961
- /* @__PURE__ */ jsxRuntime.jsx(TabsContentBase, { value: "calendar", className: "mt-0", children: /* @__PURE__ */ jsxRuntime.jsx(
7962
- CalendarBase2,
7963
- {
7964
- mode: "single",
7965
- locale: locale.ptBR,
7966
- selected: internalDate ?? void 0,
7967
- onSelect: (d) => handleSelect(d ?? null),
7968
- autoFocus: true,
7969
- defaultMonth: fromDate ?? toDate ?? internalDate ?? void 0,
7970
- ...fromDate && { startMonth: fromDate },
7971
- ...toDate && { endMonth: toDate },
7972
- ...fromDate || toDate ? {
7973
- disabled: [
7974
- ...fromDate ? [{ before: fromDate }] : [],
7975
- ...toDate ? [{ after: toDate }] : []
7976
- ]
7977
- } : {},
7978
- className: cn("w-full rounded-none border-none")
7979
- }
7980
- ) }),
7981
- /* @__PURE__ */ jsxRuntime.jsx(TabsContentBase, { value: "time", className: "mt-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center justify-center gap-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
7982
- TimeScrollPicker,
7983
- {
7984
- setDate: (d) => handleTimeChange(d ?? null),
7985
- date: internalDate,
7986
- hideSeconds
7987
- }
7988
- ) }) })
7989
- ] })
7990
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(
7991
- "div",
7933
+ return /* @__PURE__ */ jsxRuntime.jsxs(
7934
+ ButtonBase,
7992
7935
  {
7993
- ref: contentRef,
7994
- className: "flex flex-col sm:flex-row max-h-auto overflow-y-auto border-none rounded-md",
7936
+ variant: "outline",
7937
+ disabled,
7938
+ className: cn(
7939
+ "w-full justify-start text-left min-w-0 overflow-hidden",
7940
+ !date && "text-muted-foreground"
7941
+ ),
7995
7942
  children: [
7996
7943
  /* @__PURE__ */ jsxRuntime.jsx(
7997
- CalendarBase2,
7944
+ "span",
7998
7945
  {
7999
- mode: "single",
8000
- locale: locale.ptBR,
8001
- selected: internalDate ?? void 0,
8002
- onSelect: (d) => handleSelect(d ?? null),
8003
- autoFocus: true,
8004
- defaultMonth: fromDate ?? toDate ?? internalDate ?? void 0,
8005
- ...fromDate && { startMonth: fromDate },
8006
- ...toDate && { endMonth: toDate },
8007
- ...fromDate || toDate ? {
8008
- disabled: [
8009
- ...fromDate ? [{ before: fromDate }] : [],
8010
- ...toDate ? [{ after: toDate }] : []
8011
- ]
8012
- } : {},
8013
- className: cn(
8014
- "w-max rounded-none border-none",
8015
- !hideTime && "sm:rounded-r-none"
8016
- )
7946
+ className: cn("truncate flex-1", !date && "text-muted-foreground"),
7947
+ children: date ? dateFns.format(date, getDisplayFormat(), { locale: locale.ptBR }) : "Selecione uma data"
8017
7948
  }
8018
7949
  ),
8019
- !hideTime && /* @__PURE__ */ jsxRuntime.jsxs(
8020
- "div",
8021
- {
8022
- className: cn(
8023
- "flex flex-col items-center justify-center",
8024
- "border-l"
8025
- ),
8026
- children: [
8027
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[clamp(0.85rem,1.4vw,1.125rem)] sm:text-[clamp(0.9rem,1.6vw,1.125rem)] font-semibold capitalize text-left", children: "Hor\xE1rio" }),
8028
- /* @__PURE__ */ jsxRuntime.jsx(
8029
- TimeScrollPicker,
8030
- {
8031
- setDate: (d) => handleTimeChange(d ?? null),
8032
- date: internalDate,
8033
- hideSeconds
8034
- }
8035
- )
8036
- ]
8037
- }
8038
- )
7950
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.span, { className: "flex items-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-0 items-center ", children: [
7951
+ hideClear && (date || internalDate) && /* @__PURE__ */ jsxRuntime.jsx(
7952
+ ClearButton,
7953
+ {
7954
+ onClick: (e) => {
7955
+ e?.stopPropagation();
7956
+ setInternalDate(null);
7957
+ onChange?.(null);
7958
+ onConfirm?.(null);
7959
+ }
7960
+ }
7961
+ ),
7962
+ /* @__PURE__ */ jsxRuntime.jsx(
7963
+ framerMotion.motion.div,
7964
+ {
7965
+ animate: { rotate: open ? 15 : 0 },
7966
+ transition: { duration: 0.03 },
7967
+ children: /* @__PURE__ */ jsxRuntime.jsx(react.CalendarBlankIcon, { className: "h-4 w-4" })
7968
+ }
7969
+ )
7970
+ ] }) })
8039
7971
  ]
8040
7972
  }
8041
- ),
8042
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex rounded-md p-1.5 gap-2", children: [
8043
- /* @__PURE__ */ jsxRuntime.jsx(
8044
- ButtonBase,
8045
- {
8046
- variant: "outline",
8047
- className: "no-active-animation",
8048
- tooltip: "Hoje",
8049
- size: "icon",
8050
- onClick: () => {
8051
- const now = /* @__PURE__ */ new Date();
8052
- const selected = hideTime ? new Date(
8053
- Date.UTC(
8054
- now.getUTCFullYear(),
8055
- now.getUTCMonth(),
8056
- now.getUTCDate(),
8057
- 0,
8058
- 0,
8059
- 0,
8060
- 0
8061
- )
8062
- ) : now;
8063
- setInternalDate(selected);
8064
- onChange?.(selected);
8065
- onConfirm?.(selected);
8066
- },
8067
- children: /* @__PURE__ */ jsxRuntime.jsx(react.CalendarDotIcon, { className: "h-4 w-4" })
8068
- }
7973
+ );
7974
+ };
7975
+ const renderPickerContent = () => /* @__PURE__ */ jsxRuntime.jsxs(
7976
+ "div",
7977
+ {
7978
+ className: cn(
7979
+ "p-2 sm:p-3",
7980
+ !isMobile && "border border-border rounded-md"
8069
7981
  ),
8070
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 sm:flex-row w-full gap-2", children: [
8071
- /* @__PURE__ */ jsxRuntime.jsx(
8072
- ButtonBase,
7982
+ children: [
7983
+ isMobile && !hideTime ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-h-0", children: [
7984
+ internalDate && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-3 px-4 py-3 rounded-lg ", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-md font-semibold", children: [
7985
+ dateFns.format(internalDate, "dd 'de' MMMM 'de' yyyy", {
7986
+ locale: locale.ptBR
7987
+ }),
7988
+ " ",
7989
+ "- ",
7990
+ dateFns.format(internalDate, hideSeconds ? "HH:mm" : "HH:mm:ss")
7991
+ ] }) }),
7992
+ /* @__PURE__ */ jsxRuntime.jsxs(TabsBase, { value: activeTab, onValueChange: setActiveTab, children: [
7993
+ /* @__PURE__ */ jsxRuntime.jsxs(TabsListBase, { className: "", children: [
7994
+ /* @__PURE__ */ jsxRuntime.jsx(TabsTriggerBase, { value: "calendar", className: "flex-1", children: "Data" }),
7995
+ /* @__PURE__ */ jsxRuntime.jsx(TabsTriggerBase, { value: "time", className: "flex-1", children: "Hor\xE1rio" })
7996
+ ] }),
7997
+ /* @__PURE__ */ jsxRuntime.jsx(TabsContentBase, { value: "calendar", className: "mt-0", children: /* @__PURE__ */ jsxRuntime.jsx(
7998
+ CalendarBase2,
7999
+ {
8000
+ mode: "single",
8001
+ locale: locale.ptBR,
8002
+ selected: internalDate ?? void 0,
8003
+ onSelect: (d) => handleSelect(d ?? null),
8004
+ autoFocus: true,
8005
+ defaultMonth: fromDate ?? toDate ?? internalDate ?? void 0,
8006
+ ...fromDate && { startMonth: fromDate },
8007
+ ...toDate && { endMonth: toDate },
8008
+ ...fromDate || toDate ? {
8009
+ disabled: [
8010
+ ...fromDate ? [{ before: fromDate }] : [],
8011
+ ...toDate ? [{ after: toDate }] : []
8012
+ ]
8013
+ } : {},
8014
+ className: cn("w-full rounded-none border-none")
8015
+ }
8016
+ ) }),
8017
+ /* @__PURE__ */ jsxRuntime.jsx(TabsContentBase, { value: "time", className: "mt-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center justify-center gap-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8018
+ TimeScrollPicker,
8019
+ {
8020
+ setDate: (d) => handleTimeChange(d ?? null),
8021
+ date: internalDate,
8022
+ hideSeconds
8023
+ }
8024
+ ) }) })
8025
+ ] })
8026
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(
8027
+ "div",
8073
8028
  {
8074
- className: "no-active-animation rounded-md bg-background text-primary border hover:bg-muted/50 overflow-hidden flex-1 min-w-0 border-border",
8075
- onClick: () => setOpen(false),
8076
- children: "Cancelar"
8029
+ ref: contentRef,
8030
+ className: "flex flex-col sm:flex-row max-h-auto overflow-y-auto border-none rounded-md",
8031
+ children: [
8032
+ /* @__PURE__ */ jsxRuntime.jsx(
8033
+ CalendarBase2,
8034
+ {
8035
+ mode: "single",
8036
+ locale: locale.ptBR,
8037
+ selected: internalDate ?? void 0,
8038
+ onSelect: (d) => handleSelect(d ?? null),
8039
+ autoFocus: true,
8040
+ defaultMonth: fromDate ?? toDate ?? internalDate ?? void 0,
8041
+ ...fromDate && { startMonth: fromDate },
8042
+ ...toDate && { endMonth: toDate },
8043
+ ...fromDate || toDate ? {
8044
+ disabled: [
8045
+ ...fromDate ? [{ before: fromDate }] : [],
8046
+ ...toDate ? [{ after: toDate }] : []
8047
+ ]
8048
+ } : {},
8049
+ className: cn(
8050
+ "w-max rounded-none border-none",
8051
+ !hideTime && "sm:rounded-r-none"
8052
+ )
8053
+ }
8054
+ ),
8055
+ !hideTime && /* @__PURE__ */ jsxRuntime.jsxs(
8056
+ "div",
8057
+ {
8058
+ className: cn(
8059
+ "flex flex-col items-center justify-center",
8060
+ "border-l"
8061
+ ),
8062
+ children: [
8063
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[clamp(0.85rem,1.4vw,1.125rem)] sm:text-[clamp(0.9rem,1.6vw,1.125rem)] font-semibold capitalize text-left", children: "Hor\xE1rio" }),
8064
+ /* @__PURE__ */ jsxRuntime.jsx(
8065
+ TimeScrollPicker,
8066
+ {
8067
+ setDate: (d) => handleTimeChange(d ?? null),
8068
+ date: internalDate,
8069
+ hideSeconds
8070
+ }
8071
+ )
8072
+ ]
8073
+ }
8074
+ )
8075
+ ]
8077
8076
  }
8078
8077
  ),
8079
- /* @__PURE__ */ jsxRuntime.jsx(
8080
- ButtonBase,
8081
- {
8082
- className: cn(
8083
- "no-active-animation rounded-md bg-emerald-600",
8084
- internalDate ? "hover:bg-emerald-700" : "opacity-50 cursor-not-allowed"
8078
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex rounded-md p-1.5 gap-2", children: [
8079
+ /* @__PURE__ */ jsxRuntime.jsx(
8080
+ ButtonBase,
8081
+ {
8082
+ variant: "outline",
8083
+ className: "no-active-animation",
8084
+ tooltip: "Hoje",
8085
+ size: "icon",
8086
+ onClick: () => {
8087
+ const now = /* @__PURE__ */ new Date();
8088
+ const selected = hideTime ? new Date(
8089
+ Date.UTC(
8090
+ now.getUTCFullYear(),
8091
+ now.getUTCMonth(),
8092
+ now.getUTCDate(),
8093
+ 0,
8094
+ 0,
8095
+ 0,
8096
+ 0
8097
+ )
8098
+ ) : now;
8099
+ setInternalDate(selected);
8100
+ onChange?.(selected);
8101
+ onConfirm?.(selected);
8102
+ },
8103
+ children: /* @__PURE__ */ jsxRuntime.jsx(react.CalendarDotIcon, { className: "h-4 w-4" })
8104
+ }
8105
+ ),
8106
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 sm:flex-row w-full gap-2", children: [
8107
+ /* @__PURE__ */ jsxRuntime.jsx(
8108
+ ButtonBase,
8109
+ {
8110
+ className: "no-active-animation rounded-md bg-background text-primary border hover:bg-muted/50 overflow-hidden flex-1 min-w-0 border-border",
8111
+ onClick: () => setOpen(false),
8112
+ children: "Cancelar"
8113
+ }
8085
8114
  ),
8086
- disabled: !internalDate,
8087
- onClick: () => {
8088
- if (!internalDate) return;
8089
- setOpen(false);
8090
- onConfirm?.(internalDate);
8091
- },
8092
- children: "Confirmar"
8093
- }
8094
- )
8095
- ] })
8096
- ] })
8097
- ] });
8115
+ /* @__PURE__ */ jsxRuntime.jsx(
8116
+ ButtonBase,
8117
+ {
8118
+ className: cn(
8119
+ "no-active-animation rounded-md bg-emerald-600",
8120
+ internalDate ? "hover:bg-emerald-700" : "opacity-50 cursor-not-allowed"
8121
+ ),
8122
+ disabled: !internalDate,
8123
+ onClick: () => {
8124
+ if (!internalDate) return;
8125
+ setOpen(false);
8126
+ onConfirm?.(internalDate);
8127
+ },
8128
+ children: "Confirmar"
8129
+ }
8130
+ )
8131
+ ] })
8132
+ ] })
8133
+ ]
8134
+ }
8135
+ );
8098
8136
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full sm:w-auto", className), children: [
8099
8137
  label && /* @__PURE__ */ jsxRuntime.jsx(LabelBase_default, { children: label }),
8100
8138
  isMobile ? /* @__PURE__ */ jsxRuntime.jsxs(DialogBase, { open, onOpenChange: setOpen, children: [
@@ -8108,7 +8146,7 @@ function DateTimePicker({
8108
8146
  }
8109
8147
  ),
8110
8148
  /* @__PURE__ */ jsxRuntime.jsx(ErrorMessage_default, { error }),
8111
- /* @__PURE__ */ jsxRuntime.jsx(DialogContentBase, { className: "p-0 max-h-[95vh] w-3/6 overflow-hidden flex flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto flex-1", children: renderPickerContent() }) })
8149
+ /* @__PURE__ */ jsxRuntime.jsx(DialogContentBase, { className: "p-0 max-h-[95vh] w-[95%] sm:max-w-lg overflow-hidden flex flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto flex-1", children: renderPickerContent() }) })
8112
8150
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(PopoverBase, { open, onOpenChange: setOpen, children: [
8113
8151
  /* @__PURE__ */ jsxRuntime.jsx(
8114
8152
  PopoverTriggerBase,
@@ -21766,7 +21804,7 @@ function useCommandPalette({
21766
21804
  React32.useEffect(() => {
21767
21805
  setActiveIndex(0);
21768
21806
  }, [page]);
21769
- const displayedGroups = React32__namespace.useMemo(() => {
21807
+ const displayedGroups = React32.useMemo(() => {
21770
21808
  const start = page * PAGE_SIZE;
21771
21809
  const end = start + PAGE_SIZE;
21772
21810
  let count = 0;
@@ -21785,12 +21823,12 @@ function useCommandPalette({
21785
21823
  }
21786
21824
  return result;
21787
21825
  }, [allMatchedGroups, page]);
21788
- const flatItems = React32__namespace.useMemo(
21826
+ const flatItems = React32.useMemo(
21789
21827
  () => displayedGroups.flatMap((g) => g.items),
21790
21828
  [displayedGroups]
21791
21829
  );
21792
21830
  const pageItemCount = flatItems.length;
21793
- React32__namespace.useEffect(() => {
21831
+ React32.useEffect(() => {
21794
21832
  setActiveIndex((i) => Math.min(i, Math.max(pageItemCount - 1, 0)));
21795
21833
  }, [pageItemCount]);
21796
21834
  function handleSelect(item) {