@the12company/ui 0.1.8 → 0.1.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.d.ts CHANGED
@@ -617,7 +617,7 @@ declare const useFormField: () => {
617
617
  isDirty: boolean;
618
618
  isTouched: boolean;
619
619
  isValidating: boolean;
620
- error?: react_hook_form.FieldError;
620
+ error?: react_hook_form.FieldError | undefined;
621
621
  id: string;
622
622
  name: string;
623
623
  formItemId: string;
@@ -636,7 +636,7 @@ declare const HoverCard: React$1.FC<HoverCardPrimitive.HoverCardProps>;
636
636
  declare const HoverCardTrigger: React$1.ForwardRefExoticComponent<HoverCardPrimitive.HoverCardTriggerProps & React$1.RefAttributes<HTMLAnchorElement>>;
637
637
  declare const HoverCardContent: React$1.ForwardRefExoticComponent<Omit<HoverCardPrimitive.HoverCardContentProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
638
638
 
639
- declare const InputOTP: React$1.ForwardRefExoticComponent<(Omit<Omit<React$1.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
639
+ declare const InputOTP: React$1.ForwardRefExoticComponent<(Omit<Omit<React$1.InputHTMLAttributes<HTMLInputElement>, "nonce" | "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
640
640
  value?: string;
641
641
  onChange?: (newValue: string) => unknown;
642
642
  maxLength: number;
@@ -646,10 +646,11 @@ declare const InputOTP: React$1.ForwardRefExoticComponent<(Omit<Omit<React$1.Inp
646
646
  pasteTransformer?: (pasted: string) => string;
647
647
  containerClassName?: string;
648
648
  noScriptCSSFallback?: string | null;
649
+ nonce?: string;
649
650
  } & {
650
651
  render: (props: input_otp.RenderProps) => React$1.ReactNode;
651
652
  children?: never;
652
- } & React$1.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<React$1.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
653
+ } & React$1.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<React$1.InputHTMLAttributes<HTMLInputElement>, "nonce" | "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
653
654
  value?: string;
654
655
  onChange?: (newValue: string) => unknown;
655
656
  maxLength: number;
@@ -659,6 +660,7 @@ declare const InputOTP: React$1.ForwardRefExoticComponent<(Omit<Omit<React$1.Inp
659
660
  pasteTransformer?: (pasted: string) => string;
660
661
  containerClassName?: string;
661
662
  noScriptCSSFallback?: string | null;
663
+ nonce?: string;
662
664
  } & {
663
665
  render?: never;
664
666
  children: React$1.ReactNode;
@@ -853,7 +855,7 @@ type SearchableSelectLoadResult = {
853
855
  };
854
856
  type SearchableSelectProps = {
855
857
  value: string;
856
- onChange: (id: string) => void;
858
+ onChange: (id: string, item?: SearchableSelectItem) => void;
857
859
  /** Sentinel value meaning “no filter / all”. @default "all" */
858
860
  allValue?: string;
859
861
  allLabel: string;
@@ -875,6 +877,10 @@ type SearchableSelectProps = {
875
877
  disabled?: boolean;
876
878
  /** When this changes, cached items/labels are cleared. */
877
879
  resetKey?: string | number;
880
+ /** Treat the trigger as filtered even when value is still `allValue`. */
881
+ forceActive?: boolean;
882
+ /** Called when a display label is known for the current (or newly selected) id. */
883
+ onResolvedLabel?: (id: string, label: string) => void;
878
884
  emptyLabel?: string;
879
885
  loadingLabel?: string;
880
886
  loadingMoreLabel?: string;
@@ -884,7 +890,7 @@ type SearchableSelectProps = {
884
890
  * Async searchable combobox with infinite scroll.
885
891
  * Data loading is injected via `loadItems` — no product API coupling.
886
892
  */
887
- declare function SearchableSelect({ value, onChange, allValue, allLabel, searchPlaceholder, loadItems, resolveLabel, pageSize, triggerClassName, icon, nestedInPopover, disabled, resetKey, emptyLabel, loadingLabel, loadingMoreLabel, debounceMs, }: SearchableSelectProps): React$1.JSX.Element;
893
+ declare function SearchableSelect({ value, onChange, allValue, allLabel, searchPlaceholder, loadItems, resolveLabel, pageSize, triggerClassName, icon, nestedInPopover, disabled, resetKey, forceActive, onResolvedLabel, emptyLabel, loadingLabel, loadingMoreLabel, debounceMs, }: SearchableSelectProps): React$1.JSX.Element;
888
894
 
889
895
  declare const Select: React$1.FC<SelectPrimitive.SelectProps>;
890
896
  declare const SelectGroup: React$1.ForwardRefExoticComponent<SelectPrimitive.SelectGroupProps & React$1.RefAttributes<HTMLDivElement>>;
@@ -1011,6 +1017,7 @@ declare const Toaster$1: ({ duration, toastOptions, ...props }: ToasterProps) =>
1011
1017
 
1012
1018
  declare const Switch: React$1.ForwardRefExoticComponent<Omit<SwitchPrimitives.SwitchProps & React$1.RefAttributes<HTMLButtonElement>, "ref"> & {
1013
1019
  thumbClassName?: string;
1020
+ loading?: boolean;
1014
1021
  } & React$1.RefAttributes<HTMLButtonElement>>;
1015
1022
 
1016
1023
  interface TableProps extends React$1.HTMLAttributes<HTMLTableElement> {
package/dist/index.js CHANGED
@@ -2426,7 +2426,7 @@ function ChartCard({
2426
2426
  glass ? "bg-content-glass" : "bg-card border border-border"
2427
2427
  ),
2428
2428
  children: [
2429
- /* @__PURE__ */ jsxs("div", { className: "mb-4 flex items-center justify-between gap-3", children: [
2429
+ /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between gap-3", children: [
2430
2430
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
2431
2431
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
2432
2432
  /* @__PURE__ */ jsx(
@@ -2527,7 +2527,7 @@ var DialogContent = React11.forwardRef(({ className, children, ...props }, ref)
2527
2527
  {
2528
2528
  ref,
2529
2529
  className: cn(
2530
- "fixed left-[50%] top-[50%] z-50 grid w-[calc(100%-2rem)] outline-none max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 md:gap-6 border bg-background p-6 shadow-lg duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",
2530
+ "fixed left-[50%] top-[50%] z-50 grid max-h-[calc(100dvh-2rem)] scrollbar-thin overflow-y-auto overscroll-contain w-[calc(100%-2rem)] outline-none max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 md:gap-6 border bg-background p-6 shadow-lg duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",
2531
2531
  className
2532
2532
  ),
2533
2533
  ...props,
@@ -4105,6 +4105,8 @@ function SearchableSelect({
4105
4105
  nestedInPopover = false,
4106
4106
  disabled = false,
4107
4107
  resetKey,
4108
+ forceActive = false,
4109
+ onResolvedLabel,
4108
4110
  emptyLabel = "Nenhum resultado.",
4109
4111
  loadingLabel = "Buscando\u2026",
4110
4112
  loadingMoreLabel = "Carregando...",
@@ -4124,12 +4126,16 @@ function SearchableSelect({
4124
4126
  const loadMoreLockRef = React11.useRef(false);
4125
4127
  const loadItemsRef = React11.useRef(loadItems);
4126
4128
  const resolveLabelRef = React11.useRef(resolveLabel);
4129
+ const onResolvedLabelRef = React11.useRef(onResolvedLabel);
4127
4130
  React11.useEffect(() => {
4128
4131
  loadItemsRef.current = loadItems;
4129
4132
  }, [loadItems]);
4130
4133
  React11.useEffect(() => {
4131
4134
  resolveLabelRef.current = resolveLabel;
4132
4135
  }, [resolveLabel]);
4136
+ React11.useEffect(() => {
4137
+ onResolvedLabelRef.current = onResolvedLabel;
4138
+ }, [onResolvedLabel]);
4133
4139
  React11.useEffect(() => {
4134
4140
  const t = window.setTimeout(() => setDebouncedSearch(search), debounceMs);
4135
4141
  return () => window.clearTimeout(t);
@@ -4225,6 +4231,7 @@ function SearchableSelect({
4225
4231
  setLabelById(
4226
4232
  (prev) => prev[value] ? prev : { ...prev, [value]: label }
4227
4233
  );
4234
+ onResolvedLabelRef.current?.(value, label);
4228
4235
  return;
4229
4236
  }
4230
4237
  const { items: list } = await loadItemsRef.current({
@@ -4238,6 +4245,7 @@ function SearchableSelect({
4238
4245
  setLabelById(
4239
4246
  (prev) => prev[value] ? prev : { ...prev, [value]: hit.label }
4240
4247
  );
4248
+ onResolvedLabelRef.current?.(value, hit.label);
4241
4249
  }
4242
4250
  })();
4243
4251
  return () => {
@@ -4262,7 +4270,7 @@ function SearchableSelect({
4262
4270
  React11.useEffect(() => {
4263
4271
  if (disabled) setOpen(false);
4264
4272
  }, [disabled]);
4265
- const isFiltered = value !== allValue && value.trim() !== "";
4273
+ const isFiltered = forceActive || value !== allValue && value.trim() !== "";
4266
4274
  return /* @__PURE__ */ jsxs(
4267
4275
  Popover,
4268
4276
  {
@@ -4301,7 +4309,7 @@ function SearchableSelect({
4301
4309
  "span",
4302
4310
  {
4303
4311
  className: cn("truncate", isFiltered && "text-foreground"),
4304
- title: value !== allValue ? triggerLabel : void 0,
4312
+ title: isFiltered ? triggerLabel : void 0,
4305
4313
  children: triggerLabel
4306
4314
  }
4307
4315
  )
@@ -4359,11 +4367,14 @@ function SearchableSelect({
4359
4367
  value === item.id && "bg-primary/45"
4360
4368
  ),
4361
4369
  onSelect: () => {
4362
- onChange(item.id);
4370
+ onChange(item.id, item);
4363
4371
  setLabelById((prev) => ({
4364
4372
  ...prev,
4365
4373
  [item.id]: item.label || item.id
4366
4374
  }));
4375
+ if (item.label) {
4376
+ onResolvedLabelRef.current?.(item.id, item.label);
4377
+ }
4367
4378
  setOpen(false);
4368
4379
  },
4369
4380
  children: [
@@ -4599,21 +4610,44 @@ var Toaster = ({ duration = 4e3, toastOptions, ...props }) => {
4599
4610
  }
4600
4611
  );
4601
4612
  };
4602
- var Switch = React11.forwardRef(({ className, thumbClassName, ...props }, ref) => /* @__PURE__ */ jsx(
4613
+ var Switch = React11.forwardRef(({ className, thumbClassName, loading = false, disabled, ...props }, ref) => /* @__PURE__ */ jsx(
4603
4614
  SwitchPrimitives.Root,
4604
4615
  {
4605
4616
  className: cn(
4606
- "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",
4617
+ "peer group inline-flex h-6 w-11 shrink-0 items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
4618
+ loading ? "cursor-wait disabled:cursor-wait disabled:opacity-100" : "cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
4607
4619
  className
4608
4620
  ),
4609
4621
  ...props,
4622
+ disabled: disabled || loading,
4623
+ "aria-busy": loading || void 0,
4610
4624
  ref,
4611
4625
  children: /* @__PURE__ */ jsx(
4612
4626
  SwitchPrimitives.Thumb,
4613
4627
  {
4614
4628
  className: cn(
4615
- "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
4629
+ "pointer-events-none relative flex h-5 w-5 items-center justify-center rounded-full bg-background shadow-lg ring-0 transition-[transform,background-color,box-shadow] duration-300 ease-out data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
4630
+ loading && "bg-transparent shadow-none",
4616
4631
  thumbClassName
4632
+ ),
4633
+ children: /* @__PURE__ */ jsx(
4634
+ "span",
4635
+ {
4636
+ className: cn(
4637
+ "absolute inset-0 transition-[opacity,transform] duration-300 ease-out",
4638
+ loading ? "scale-100 opacity-100" : "scale-75 opacity-0"
4639
+ ),
4640
+ "aria-hidden": true,
4641
+ children: /* @__PURE__ */ jsx(
4642
+ "span",
4643
+ {
4644
+ className: cn(
4645
+ "absolute inset-0 rounded-full border-2 border-primary border-t-transparent group-data-[state=checked]:border-background group-data-[state=checked]:border-t-transparent",
4646
+ loading && "animate-spin"
4647
+ )
4648
+ }
4649
+ )
4650
+ }
4617
4651
  )
4618
4652
  }
4619
4653
  )