@vritti/quantum-ui 0.1.18 → 0.1.19

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.
@@ -25,6 +25,8 @@ export declare const OnboardingProvider: default_2.FC<OnboardingProviderProps>;
25
25
 
26
26
  declare interface OnboardingProviderProps {
27
27
  children: default_2.ReactNode;
28
+ onboardingToken?: string;
29
+ onUnauthorized?: () => void;
28
30
  }
29
31
 
30
32
  export declare const useOnboarding: () => OnboardingContextType;
package/dist/Form.d.ts CHANGED
@@ -105,7 +105,7 @@ export declare function FieldGroup({ className, ...props }: React.ComponentProps
105
105
  <div
106
106
  data-slot="field-group"
107
107
  className={cn(
108
- "group/field-group @container/field-group flex w-full flex-col gap-4 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
108
+ "group/field-group @container/field-group flex w-full flex-col gap-2 data-[slot=checkbox-group]:gap-1 [&>[data-slot=field-group]]:gap-2",
109
109
  className
110
110
  )}
111
111
  {...props}
@@ -232,7 +232,7 @@ declare const fieldVariants = cva(
232
232
  }
233
233
  );
234
234
 
235
- export declare function Form<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = TFieldValues>({ form, onSubmit, children, showRootError, rootErrorPosition, rootErrorClassName, ...props }: FormProps<TFieldValues, TContext, TTransformedValues>): JSX.Element;
235
+ export declare function Form<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = TFieldValues>({ form, onSubmit, children, showRootError, rootErrorPosition, rootErrorClassName, csrfEndpoint, ...props }: FormProps<TFieldValues, TContext, TTransformedValues>): JSX.Element;
236
236
 
237
237
  export declare namespace Form {
238
238
  var displayName: string;
@@ -245,6 +245,7 @@ export declare interface FormProps<TFieldValues extends FieldValues = FieldValue
245
245
  showRootError?: boolean;
246
246
  rootErrorPosition?: 'top' | 'bottom';
247
247
  rootErrorClassName?: string;
248
+ csrfEndpoint?: string;
248
249
  }
249
250
 
250
251
  declare function Label({ className, ...props }: React_2.ComponentProps<typeof LabelPrimitive.Root>) {
package/dist/Form.js CHANGED
@@ -3,6 +3,7 @@ import React__default from 'react';
3
3
  import { C as Checkbox } from './Checkbox.js';
4
4
  import { c as FieldError } from './field.js';
5
5
  import { c as cn } from './utils.js';
6
+ import { axios, setCsrfToken, clearCsrfToken } from './utils/axios.js';
6
7
 
7
8
  var isCheckBoxInput = (element) => element.type === 'checkbox';
8
9
 
@@ -655,9 +656,29 @@ function Form({
655
656
  showRootError = true,
656
657
  rootErrorPosition = "bottom",
657
658
  rootErrorClassName,
659
+ csrfEndpoint,
658
660
  ...props
659
661
  }) {
660
662
  const handleSubmit = form.handleSubmit(onSubmit);
663
+ React__default.useEffect(() => {
664
+ if (csrfEndpoint) {
665
+ axios.get(csrfEndpoint).then((response) => {
666
+ const token = response.data?.csrfToken;
667
+ if (token) {
668
+ setCsrfToken(token);
669
+ } else {
670
+ console.warn("[Form] CSRF endpoint did not return a csrfToken field");
671
+ }
672
+ }).catch((error) => {
673
+ console.error("[Form] Failed to fetch CSRF token:", error);
674
+ });
675
+ }
676
+ return () => {
677
+ if (csrfEndpoint) {
678
+ clearCsrfToken();
679
+ }
680
+ };
681
+ }, [csrfEndpoint]);
661
682
  const processedChildren = processChildren(children, form.control);
662
683
  return /* @__PURE__ */ jsx(FormProvider, { ...form, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, ...props, children: [
663
684
  showRootError && rootErrorPosition === "top" && form.formState.errors.root && /* @__PURE__ */ jsx(