@payfit/unity-components 2.68.15 → 2.68.16

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.
Files changed (129) hide show
  1. package/README.md +6 -0
  2. package/dist/esm/components/action-bar/parts/ActionBarButton.d.ts +1 -15
  3. package/dist/esm/components/action-bar/parts/ActionBarButton.js +1 -2
  4. package/dist/esm/components/actionable/Actionable.d.ts +1 -1
  5. package/dist/esm/components/app-menu/parts/AppMenuHeader.js +30 -31
  6. package/dist/esm/components/avatar/parts/AvatarFallback.js +6 -6
  7. package/dist/esm/components/avatar-group/parts/AvatarGroupCount.d.ts +1 -1
  8. package/dist/esm/components/badge/Badge.js +1 -1
  9. package/dist/esm/components/breadcrumbs/parts/RawBreadcrumbLink.d.ts +1 -1
  10. package/dist/esm/components/button/Button.d.ts +1 -1
  11. package/dist/esm/components/button/Button.js +42 -48
  12. package/dist/esm/components/button/Button.variants.js +15 -17
  13. package/dist/esm/components/carousel/parts/CarouselHeader.d.ts +3 -3
  14. package/dist/esm/components/checkbox/Checkbox.variants.js +1 -1
  15. package/dist/esm/components/checkbox/parts/CheckboxIndicator.js +4 -4
  16. package/dist/esm/components/date-calendar/DateCalendar.js +74 -74
  17. package/dist/esm/components/date-calendar/DateCalendar.variants.js +3 -3
  18. package/dist/esm/components/date-picker/parts/DateInput.js +2 -3
  19. package/dist/esm/components/date-range-calendar/DateRangeCalendar.js +85 -85
  20. package/dist/esm/components/date-range-picker/parts/DateRangeInput.js +1 -1
  21. package/dist/esm/components/filter/parts/FilterPopover.js +27 -27
  22. package/dist/esm/components/form-field/parts/TanstackRawFormContextualLink.d.ts +1 -1
  23. package/dist/esm/components/form-field/parts/TanstackRawFormContextualLink.js +19 -20
  24. package/dist/esm/components/funnel-layout/FunnelLayout.d.ts +1 -1
  25. package/dist/esm/components/funnel-layout/parts/FunnelPageAction.d.ts +2 -2
  26. package/dist/esm/components/funnel-layout/parts/FunnelPageAction.js +24 -28
  27. package/dist/esm/components/funnel-layout/parts/FunnelSidebar.d.ts +0 -17
  28. package/dist/esm/components/funnel-layout/parts/FunnelSidebar.js +14 -23
  29. package/dist/esm/components/funnel-layout/parts/FunnelTopBar.d.ts +1 -27
  30. package/dist/esm/components/funnel-layout/parts/FunnelTopBar.js +43 -53
  31. package/dist/esm/components/icon-button/IconButton.d.ts +1 -1
  32. package/dist/esm/components/icon-button/IconButton.js +60 -66
  33. package/dist/esm/components/icon-button/IconButton.variants.js +15 -17
  34. package/dist/esm/components/link/RawLink.d.ts +1 -1
  35. package/dist/esm/components/link/RawLink.js +3 -3
  36. package/dist/esm/components/link-button/LinkButton.variants.js +12 -17
  37. package/dist/esm/components/link-button/RawLinkButton.js +41 -46
  38. package/dist/esm/components/menu/parts/MenuContent.d.ts +1 -10
  39. package/dist/esm/components/menu/parts/MenuContent.js +6 -6
  40. package/dist/esm/components/nav/parts/NavGroup.js +4 -4
  41. package/dist/esm/components/nav/parts/RawNavItem.js +9 -9
  42. package/dist/esm/components/navigation-card/NavigationCard.d.ts +1 -1
  43. package/dist/esm/components/navigation-card/NavigationCard.variants.js +2 -2
  44. package/dist/esm/components/page/parts/PageHeader.d.ts +3 -54
  45. package/dist/esm/components/page/parts/PageHeader.js +18 -28
  46. package/dist/esm/components/payfit-brand/PayFitBrand.d.ts +1 -11
  47. package/dist/esm/components/payfit-brand/PayFitBrand.js +48 -73
  48. package/dist/esm/components/payfit-brand/PayFitPreprod.d.ts +2 -6
  49. package/dist/esm/components/payfit-brand/PayFitPreprod.js +35 -44
  50. package/dist/esm/components/pill/Pill.d.ts +3 -3
  51. package/dist/esm/components/pill/Pill.js +1 -1
  52. package/dist/esm/components/radio-button-group/parts/RadioButton.js +23 -24
  53. package/dist/esm/components/radio-button-group/parts/RadioIndicator.d.ts +1 -2
  54. package/dist/esm/components/radio-button-group/parts/RadioIndicator.js +7 -38
  55. package/dist/esm/components/selectable-card/selectable-card-radio-group/parts/SelectableCardRadio.js +20 -22
  56. package/dist/esm/components/spinner/Spinner.js +1 -1
  57. package/dist/esm/components/tabs/Tabs.variant.js +6 -6
  58. package/dist/esm/components/tabs/parts/NavigationButton.js +2 -2
  59. package/dist/esm/components/task-menu/parts/RawSubTask.js +3 -3
  60. package/dist/esm/components/task-menu/parts/TaskGroup.js +3 -3
  61. package/dist/esm/components/task-menu/parts/task.variants.js +7 -7
  62. package/dist/esm/components/timeline/Timeline.variants.js +4 -4
  63. package/dist/esm/components/toast/UnityToast.js +2 -2
  64. package/dist/esm/components/toast/parts/ToastAction.js +10 -12
  65. package/dist/esm/components/toggle-switch/ToggleSwitch.js +4 -7
  66. package/dist/esm/hooks/use-tanstack-form.d.ts +6 -6
  67. package/dist/esm/index.d.ts +0 -21
  68. package/dist/esm/index.js +222 -243
  69. package/dist/esm/integrations/tanstack-router/components/form-contextual-link/TanstackFormContextualLink.js +7 -0
  70. package/dist/esm/integrations/tanstack-router/index.d.ts +1 -1
  71. package/dist/esm/integrations/tanstack-router.js +2 -2
  72. package/dist/esm/modules/ai-kit/components/ai-button/AIButton.d.ts +1 -1
  73. package/package.json +8 -11
  74. package/skills/unity-migrate-from-midnight/references/midnight-component-map.md +7 -7
  75. package/skills/unity-tanstack-form/SKILL.md +1 -25
  76. package/skills/unity-tanstack-form/references/schema-adapters.md +0 -27
  77. package/dist/esm/adapters/standardSchemaAdapter.js +0 -19
  78. package/dist/esm/adapters/zodAdapter.js +0 -60
  79. package/dist/esm/components/checkbox-field/CheckboxField.d.ts +0 -76
  80. package/dist/esm/components/checkbox-field/CheckboxField.js +0 -40
  81. package/dist/esm/components/checkbox-group-field/CheckboxGroupField.d.ts +0 -81
  82. package/dist/esm/components/checkbox-group-field/CheckboxGroupField.js +0 -37
  83. package/dist/esm/components/date-picker-field/DatePickerField.d.ts +0 -85
  84. package/dist/esm/components/date-picker-field/DatePickerField.js +0 -54
  85. package/dist/esm/components/form/Form.context.d.ts +0 -9
  86. package/dist/esm/components/form/Form.context.js +0 -17
  87. package/dist/esm/components/form/Form.d.ts +0 -43
  88. package/dist/esm/components/form/Form.js +0 -41
  89. package/dist/esm/components/form-field/FormField.context.d.ts +0 -33
  90. package/dist/esm/components/form-field/FormField.context.js +0 -47
  91. package/dist/esm/components/form-field/FormField.d.ts +0 -61
  92. package/dist/esm/components/form-field/FormField.js +0 -50
  93. package/dist/esm/components/form-field/parts/FormControl.d.ts +0 -32
  94. package/dist/esm/components/form-field/parts/FormControl.js +0 -42
  95. package/dist/esm/components/form-field/parts/FormFeedbackText.d.ts +0 -9
  96. package/dist/esm/components/form-field/parts/FormFeedbackText.js +0 -24
  97. package/dist/esm/components/form-field/parts/FormHelperText.d.ts +0 -9
  98. package/dist/esm/components/form-field/parts/FormHelperText.js +0 -21
  99. package/dist/esm/components/form-field/parts/FormLabel.d.ts +0 -10
  100. package/dist/esm/components/form-field/parts/FormLabel.js +0 -21
  101. package/dist/esm/components/form-field/parts/RawFormContextualLink.d.ts +0 -22
  102. package/dist/esm/components/form-field/parts/RawFormContextualLink.js +0 -33
  103. package/dist/esm/components/form-field/utils/isFieldRequired.d.ts +0 -8
  104. package/dist/esm/components/form-field/utils/isFieldRequired.js +0 -8
  105. package/dist/esm/components/multi-select-field/MultiSelectField.d.ts +0 -92
  106. package/dist/esm/components/multi-select-field/MultiSelectField.js +0 -57
  107. package/dist/esm/components/number-field/NumberField.d.ts +0 -49
  108. package/dist/esm/components/number-field/NumberField.js +0 -50
  109. package/dist/esm/components/radio-button-group-field/RadioButtonGroupField.d.ts +0 -49
  110. package/dist/esm/components/radio-button-group-field/RadioButtonGroupField.js +0 -37
  111. package/dist/esm/components/select-field/SelectField.d.ts +0 -52
  112. package/dist/esm/components/select-field/SelectField.js +0 -45
  113. package/dist/esm/components/selectable-button-group-field/SelectableButtonGroupField.d.ts +0 -61
  114. package/dist/esm/components/selectable-button-group-field/SelectableButtonGroupField.js +0 -42
  115. package/dist/esm/components/selectable-card-checkbox-group-field/SelectableCardCheckboxGroupField.d.ts +0 -33
  116. package/dist/esm/components/selectable-card-checkbox-group-field/SelectableCardCheckboxGroupField.js +0 -38
  117. package/dist/esm/components/selectable-card-radio-group-field/SelectableCardRadioGroupField.d.ts +0 -33
  118. package/dist/esm/components/selectable-card-radio-group-field/SelectableCardRadioGroupField.js +0 -38
  119. package/dist/esm/components/text-field/TextField.d.ts +0 -65
  120. package/dist/esm/components/text-field/TextField.js +0 -55
  121. package/dist/esm/components/toggle-switch-field/ToggleSwitchField.d.ts +0 -70
  122. package/dist/esm/components/toggle-switch-field/ToggleSwitchField.js +0 -35
  123. package/dist/esm/components/toggle-switch-group-field/ToggleSwitchGroupField.d.ts +0 -84
  124. package/dist/esm/components/toggle-switch-group-field/ToggleSwitchGroupField.js +0 -43
  125. package/dist/esm/hooks/use-form.d.ts +0 -50
  126. package/dist/esm/hooks/use-form.js +0 -38
  127. package/dist/esm/integrations/tanstack-router/components/form-contextual-link/FormContextualLink.d.ts +0 -45
  128. package/dist/esm/integrations/tanstack-router/components/form-contextual-link/FormContextualLink.js +0 -7
  129. package/dist/esm/utils/createSchemaAdapter.js +0 -8
@@ -1,17 +0,0 @@
1
- import { createContext as e, useContext as t } from "react";
2
- import { jsx as n } from "react/jsx-runtime";
3
- //#region src/components/form/Form.context.tsx
4
- var r = e(null);
5
- function i({ children: e, schema: t }) {
6
- return /* @__PURE__ */ n(r.Provider, {
7
- value: { schema: t },
8
- children: e
9
- });
10
- }
11
- function a() {
12
- let e = t(r);
13
- if (!e) throw Error("useFormContext must be used within a Form component");
14
- return e;
15
- }
16
- //#endregion
17
- export { r as UnityFormContext, i as UnityFormProvider, a as useUnityFormProvider };
@@ -1,43 +0,0 @@
1
- import { default as React, PropsWithChildren, Ref } from 'react';
2
- import { StandardSchemaV1 } from '@standard-schema/spec';
3
- import { FormProps as AriaFormProps } from 'react-aria-components/Form';
4
- import { FieldErrors, UseFormReturn } from 'react-hook-form';
5
- import { Schema, TFormValues } from '../../hooks/use-form.types.js';
6
- type AllowedAriaFormProps = Omit<AriaFormProps, 'action' | 'onSubmit' | 'method' | 'target' | 'validationErrors' | 'onInvalid'>;
7
- export interface FormProps<TSchema extends Schema, TFormInputValues extends TFormValues = StandardSchemaV1.InferInput<TSchema>, TFormOutputs extends TFormValues = StandardSchemaV1.InferOutput<TSchema>, TActionResult = unknown> extends PropsWithChildren<AllowedAriaFormProps> {
8
- /** The form instance from react-hook-form */
9
- form: UseFormReturn<TFormInputValues, any, TFormOutputs>;
10
- /** The schema to validate the form data */
11
- schema: TSchema;
12
- /** The operations to execute when the form is submitted and the input data is valid */
13
- action: (values: TFormOutputs) => Promise<TActionResult> | TActionResult;
14
- /** Handle successful form submission (when the `action` callback resolves its promise or does not throw an error) */
15
- onSuccess?: (result: TActionResult, data: TFormOutputs) => void;
16
- /** Handle form submission errors (when the `action` callback rejects its promise or throws an error) */
17
- onError?: (error: unknown, data: TFormOutputs) => void;
18
- /** Handle form validation errors (when form data is invalid) */
19
- onInvalid?: (errors: FieldErrors<TFormInputValues>) => void;
20
- /** Enable or disable `react-hook-form`'s devtools (only in development mode) */
21
- debug?: boolean;
22
- }
23
- type FormComponent = {
24
- <TSchema extends Schema, TFormInputValues extends TFormValues = StandardSchemaV1.InferInput<TSchema>, TFormOutputs extends TFormValues = StandardSchemaV1.InferOutput<TSchema>, TActionResult = unknown>(props: FormProps<TSchema, TFormInputValues, TFormOutputs, TActionResult> & {
25
- ref?: Ref<HTMLFormElement>;
26
- }): React.JSX.Element;
27
- displayName?: string;
28
- };
29
- /**
30
- * The `Form` component provides full state management for complex forms with validation by following a schema-based approach.
31
- *
32
- * Use this component to create complex forms with validation and error handling, alongside the [`FormField` component](/?path=/docs/forms-formfield--docs).
33
- *
34
- * Under the hood, the `Form` component is a wrapper around the `react-hook-form` library, which takes care of form state management. Additionally, it uses the `zod` library to define a schema used for form data validation. To use the `Form` component correctly, **you must install Zod and react-hook-form** as dependencies in your project:
35
- *
36
- * ```bash
37
- * $ pnpm add zod react-hook-form
38
- * ```
39
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
40
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
41
- */
42
- declare const Form: FormComponent;
43
- export { Form };
@@ -1,41 +0,0 @@
1
- import { UnityFormProvider as e } from "./Form.context.js";
2
- import { Suspense as t, forwardRef as n, lazy as r } from "react";
3
- import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
4
- import { FormProvider as s } from "react-hook-form";
5
- //#region src/components/form/Form.tsx
6
- var c = r(() => import("@hookform/devtools").then((e) => ({ default: e.DevTool }))), l = ({ form: n, schema: r, onSuccess: l, onError: u, onInvalid: d, action: f, children: p, className: m, onReset: h, debug: g = !1, ..._ }, v) => {
7
- let y = n.handleSubmit((e) => {
8
- Promise.resolve().then(() => f(e)).then((t) => {
9
- l?.(t, e);
10
- }).catch((t) => {
11
- u?.(t, e);
12
- });
13
- }, (e) => {
14
- d?.(e);
15
- });
16
- return /* @__PURE__ */ a(e, {
17
- schema: r,
18
- children: /* @__PURE__ */ o(s, {
19
- ...n,
20
- children: [g && /* @__PURE__ */ a(t, {
21
- fallback: /* @__PURE__ */ a(i, {}),
22
- children: /* @__PURE__ */ a(c, { control: n.control })
23
- }), /* @__PURE__ */ a("form", {
24
- ..._,
25
- ref: v,
26
- onSubmit: (e) => {
27
- y(e);
28
- },
29
- className: m,
30
- onReset: h,
31
- "data-dd-privacy": "mask",
32
- children: p
33
- })]
34
- })
35
- });
36
- }, u = n(function(e, t) {
37
- return l(e, t);
38
- });
39
- u.displayName = "Form";
40
- //#endregion
41
- export { u as Form };
@@ -1,33 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- import { FieldPath, FieldValues } from 'react-hook-form';
3
- interface FormFieldContextValue<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> {
4
- id: string;
5
- name: TName;
6
- isRequired?: boolean;
7
- isLoading?: boolean;
8
- isReadOnly?: boolean;
9
- isDisabled?: boolean;
10
- hasHelperText?: boolean;
11
- hasContextualLink?: boolean;
12
- }
13
- export declare const FormFieldContext: import('react').Context<FormFieldContextValue<FieldValues, string>>;
14
- export declare function FormFieldProvider({ children, id, name, isRequired, isLoading, isReadOnly, isDisabled, hasHelperText, hasContextualLink, }: PropsWithChildren<FormFieldContextValue>): import("react/jsx-runtime").JSX.Element;
15
- export declare function useFormField(): {
16
- fieldState: {
17
- isRequired: boolean | undefined;
18
- isLoading: boolean | undefined;
19
- isReadOnly: boolean | undefined;
20
- isDisabled: boolean | undefined;
21
- };
22
- formState: import('react-hook-form').UseFormStateReturn<FieldValues>;
23
- id: string;
24
- name: string;
25
- hasHelperText: boolean | undefined;
26
- hasContextualLink: boolean | undefined;
27
- formLabelId: string;
28
- formItemId: string;
29
- formDescriptionId: string | undefined;
30
- formMessageId: string;
31
- formContextualLinkId: string | undefined;
32
- };
33
- export {};
@@ -1,47 +0,0 @@
1
- import { createContext as e, useContext as t } from "react";
2
- import { jsx as n } from "react/jsx-runtime";
3
- import { useFormState as r } from "react-hook-form";
4
- //#region src/components/form-field/FormField.context.tsx
5
- var i = e({
6
- id: "",
7
- name: ""
8
- });
9
- function a({ children: e, id: t, name: r, isRequired: a, isLoading: o, isReadOnly: s, isDisabled: c, hasHelperText: l, hasContextualLink: u }) {
10
- return /* @__PURE__ */ n(i.Provider, {
11
- value: {
12
- id: t,
13
- name: r,
14
- isRequired: a,
15
- isLoading: o,
16
- isReadOnly: s,
17
- isDisabled: c,
18
- hasHelperText: l,
19
- hasContextualLink: u
20
- },
21
- children: e
22
- });
23
- }
24
- function o() {
25
- let e = t(i), n = r({ name: e.name }), { id: a, isRequired: o, isLoading: s, isReadOnly: c, isDisabled: l, hasHelperText: u, hasContextualLink: d } = e;
26
- if (!e) throw Error("useFormField should be used within <FormField> component");
27
- return {
28
- id: a,
29
- name: e.name,
30
- hasHelperText: u,
31
- hasContextualLink: d,
32
- formLabelId: `${a}-form-field-label`,
33
- formItemId: `${a}-form-item`,
34
- formDescriptionId: u ? `${a}-form-field-description` : void 0,
35
- formMessageId: `${a}-form-field-feedback-text`,
36
- formContextualLinkId: d ? `${a}-form-field-contextual-link` : void 0,
37
- fieldState: {
38
- isRequired: o,
39
- isLoading: s,
40
- isReadOnly: c,
41
- isDisabled: l
42
- },
43
- formState: n
44
- };
45
- }
46
- //#endregion
47
- export { i as FormFieldContext, a as FormFieldProvider, o as useFormField };
@@ -1,61 +0,0 @@
1
- import { default as React } from 'react';
2
- import { Control, FieldPath, FieldValues } from 'react-hook-form';
3
- export interface FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends React.PropsWithChildren<object> {
4
- /** The form control from react-hook-form */
5
- control: Control<TFieldValues>;
6
- /** The name of the field in the form */
7
- name: TName;
8
- /** Whether the field is required */
9
- isRequired?: boolean;
10
- /** Whether the field is in a loading state */
11
- isLoading?: boolean;
12
- /** Whether the field is disabled */
13
- isDisabled?: boolean;
14
- /** Whether the field is read-only */
15
- isReadOnly?: boolean;
16
- /** Additional class name */
17
- className?: string;
18
- }
19
- /**
20
- * The `FormField` component represents a single field in a Unity form. It provides a set of features to manage the state of the field and its interactions, as well as a deep integration with its parent `Form` component.
21
- * Use this component to create a field in a form with a schema-based approach. It will only work if it is a child of a [`Form` component](/?path=/docs/forms-formfield--docs).
22
- * @param {FormFieldProps} props - component props to control the field name, and the reference to its form control
23
- * @see {@link FormFieldProps} for all available props
24
- * @example
25
- * ```tsx
26
- * import { Button, Input, FormLabel, FormControl, FormHelperText, FormFeedbackText } from '@payfit/unity-components'
27
- * import { useUnityForm } from '@payfit/unity-components'
28
- * import { z } from 'zod'
29
- *
30
- * const loginSchema = z.object({
31
- * email: z.string().email('Invalid email address'),
32
- * password: z.string().min(8, 'Password must be at least 8 characters'),
33
- * })
34
- *
35
- * const MyForm = () => {
36
- * const { Form, FormField } = useUnityForm(loginSchema)
37
- *
38
- * const submitForm = (values: z.infer<typeof loginSchema>) => {
39
- * console.log(values)
40
- * }
41
- *
42
- * return (
43
- * <Form action={submitForm}>
44
- * <FormField name="email">
45
- * <FormLabel>Email</FormLabel>
46
- * <FormHelperText>Enter your primary email address</FormHelperText>
47
- * <FormControl>
48
- * <Input type="email"/>
49
- * </FormControl>
50
- * <FormFeedbackText/>
51
- * </FormField>
52
- * </Form>
53
- * )
54
- * }
55
- * ```
56
- * @note Use this component directly from the `useUnityForm` hook to have type-safety based on the form schema.
57
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
58
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
59
- */
60
- declare const FormField: React.ForwardRefExoticComponent<FormFieldProps<FieldValues, string> & React.RefAttributes<HTMLDivElement>>;
61
- export { FormField };
@@ -1,50 +0,0 @@
1
- import e from "../../hooks/use-id.js";
2
- import { useUnityFormProvider as t } from "../form/Form.context.js";
3
- import { createSchemaAdapter as n } from "../../utils/createSchemaAdapter.js";
4
- import { FormFieldProvider as r } from "./FormField.context.js";
5
- import { FormHelperText as i } from "./parts/FormHelperText.js";
6
- import { RawFormContextualLink as a } from "./parts/RawFormContextualLink.js";
7
- import { isFieldRequired as o } from "./utils/isFieldRequired.js";
8
- import s, { forwardRef as c, useMemo as l } from "react";
9
- import { uyTv as u } from "@payfit/unity-themes";
10
- import { jsx as d } from "react/jsx-runtime";
11
- import { useController as f } from "react-hook-form";
12
- //#region src/components/form-field/FormField.tsx
13
- var p = u({ slots: { base: "uy:flex uy:flex-col uy:gap-100" } }), m = c(({ children: c, control: u, name: m, isLoading: h, isReadOnly: g, className: _, isRequired: v, isDisabled: y }, b) => {
14
- let x = e(), { schema: S } = t(), { formState: C } = f({
15
- name: m,
16
- control: u
17
- }), w = l(() => o(n(S), m), [S, m]), { hasHelperText: T, hasContextualLink: E } = l(() => {
18
- let e = !1, t = !1, n = (r) => {
19
- s.Children.forEach(r, (r) => {
20
- if (!s.isValidElement(r)) return;
21
- let o = r;
22
- o.type === i ? e = !0 : o.type === a && (t = !0), o.props && typeof o.props == "object" && "children" in o.props && n(o.props.children);
23
- });
24
- };
25
- return n(c), {
26
- hasHelperText: e,
27
- hasContextualLink: t
28
- };
29
- }, [c]), D = {
30
- name: m,
31
- isLoading: h,
32
- isReadOnly: g,
33
- hasHelperText: T,
34
- hasContextualLink: E,
35
- id: x,
36
- isRequired: v ?? w,
37
- isDisabled: y ?? (C.isSubmitting || C.disabled)
38
- }, { base: O } = p();
39
- return /* @__PURE__ */ d("div", {
40
- ref: b,
41
- className: O({ className: _ }),
42
- children: /* @__PURE__ */ d(r, {
43
- ...D,
44
- children: c
45
- })
46
- });
47
- });
48
- m.displayName = "FormField";
49
- //#endregion
50
- export { m as FormField };
@@ -1,32 +0,0 @@
1
- import { Slot } from '@radix-ui/react-slot';
2
- export type FormControlProps = React.ComponentProps<typeof Slot>;
3
- /**
4
- * FormControl is a wrapper component that connects input components to form state within a FormField.
5
- * It handles accessibility concerns like proper ARIA attributes and focus states.
6
- *
7
- * This component is required when building custom form fields - it must wrap the actual input element
8
- * to connect it properly to the form state.
9
- * @example
10
- * ```tsx
11
- * import { FormControl, FormField, Input } from '@payfit/unity-components'
12
- *
13
- * function MyFormField() {
14
- * return (
15
- * <FormField name="email">
16
- * <FormControl>
17
- * <Input />
18
- * </FormControl>
19
- * </FormField>
20
- * )
21
- * }
22
- * ```
23
- * @remarks
24
- * [API & Docs](https://unity-components.payfit.io/?path=/docs/forms-formfield-formcontrol--docs)
25
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
26
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
27
- */
28
- declare function FormControl({ ...props }: FormControlProps): import("react/jsx-runtime").JSX.Element;
29
- declare namespace FormControl {
30
- var displayName: string;
31
- }
32
- export { FormControl };
@@ -1,42 +0,0 @@
1
- import { useFormField as e } from "../FormField.context.js";
2
- import { useMemo as t } from "react";
3
- import { jsx as n } from "react/jsx-runtime";
4
- import { Slot as r } from "@radix-ui/react-slot";
5
- import { mergeProps as i } from "react-aria/mergeProps";
6
- import { useController as a, useFormContext as o } from "react-hook-form";
7
- //#region src/components/form-field/parts/FormControl.tsx
8
- function s({ ...s }) {
9
- let { name: c, hasHelperText: l, hasContextualLink: u, fieldState: d, formLabelId: f, formItemId: p, formDescriptionId: m, formMessageId: h, formContextualLinkId: g } = e(), { control: _ } = o(), { field: { ref: v, ...y }, fieldState: { invalid: b, error: x } } = a({
10
- name: c,
11
- control: _
12
- }), S = t(() => [x ? h : void 0, l ? m : void 0].filter(Boolean).join(" "), [
13
- x,
14
- l,
15
- m,
16
- h
17
- ]), C = {
18
- isInvalid: b,
19
- isDisabled: d.isDisabled,
20
- isLoading: d.isLoading,
21
- isReadOnly: d.isReadOnly
22
- };
23
- return /* @__PURE__ */ n(r, {
24
- ...i(s, C, y),
25
- ref: v,
26
- "data-slot": "form-control",
27
- id: p,
28
- "aria-labelledby": f,
29
- "aria-describedby": S,
30
- "aria-details": u ? g : void 0,
31
- "aria-invalid": C.isInvalid,
32
- "data-invalid": C.isInvalid,
33
- "aria-disabled": C.isDisabled,
34
- "data-disabled": C.isDisabled,
35
- "aria-readonly": C.isReadOnly,
36
- "data-readonly": C.isReadOnly,
37
- "aria-busy": C.isLoading
38
- });
39
- }
40
- s.displayName = "FormControl";
41
- //#endregion
42
- export { s as FormControl };
@@ -1,9 +0,0 @@
1
- /**
2
- * FormErrorText is a component that displays error text for a form field.
3
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
4
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
5
- */
6
- declare const FormFeedbackText: import('react').ForwardRefExoticComponent<{
7
- children?: import('react').ReactNode | undefined;
8
- } & import('react').RefAttributes<HTMLParagraphElement>>;
9
- export { FormFeedbackText };
@@ -1,24 +0,0 @@
1
- import { Text as e } from "../../text/Text.js";
2
- import { useFormField as t } from "../FormField.context.js";
3
- import { forwardRef as n } from "react";
4
- import { jsx as r } from "react/jsx-runtime";
5
- import { useController as i, useFormContext as a } from "react-hook-form";
6
- //#region src/components/form-field/parts/FormFeedbackText.tsx
7
- var o = n(({ children: n, ...o }, s) => {
8
- let { name: c, formMessageId: l } = t(), u = i({
9
- name: c,
10
- control: a().control
11
- }), d = u.fieldState.error, f = u.fieldState.invalid, p = d ? String(d.message) : n;
12
- return !f || !p ? null : /* @__PURE__ */ r(e, {
13
- ...o,
14
- id: l,
15
- ref: s,
16
- "data-unity-slot": "form-feedback-text",
17
- className: "uy:typography-body-small-strong uy:text-content-form-invalid",
18
- "data-dd-privacy": "allow",
19
- children: p
20
- });
21
- });
22
- o.displayName = "FormFeedbackText";
23
- //#endregion
24
- export { o as FormFeedbackText };
@@ -1,9 +0,0 @@
1
- /**
2
- * FormHelperText is a component that displays helper text for a form field.
3
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
4
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
5
- */
6
- declare const FormHelperText: import('react').ForwardRefExoticComponent<{
7
- children?: import('react').ReactNode | undefined;
8
- } & import('react').RefAttributes<HTMLElement>>;
9
- export { FormHelperText };
@@ -1,21 +0,0 @@
1
- import { Text as e } from "../../text/Text.js";
2
- import { useFormField as t } from "../FormField.context.js";
3
- import { forwardRef as n } from "react";
4
- import { jsx as r } from "react/jsx-runtime";
5
- //#region src/components/form-field/parts/FormHelperText.tsx
6
- var i = n(({ children: n, ...i }, a) => {
7
- let { formDescriptionId: o } = t();
8
- return /* @__PURE__ */ r(e, {
9
- ...i,
10
- id: o,
11
- "data-unity-slot": "helper-text",
12
- variant: "bodySmall",
13
- color: "content.neutral.low",
14
- ref: a,
15
- "data-dd-privacy": "allow",
16
- children: n
17
- });
18
- });
19
- i.displayName = "HelperText";
20
- //#endregion
21
- export { i as FormHelperText };
@@ -1,10 +0,0 @@
1
- import { LabelProps } from '../../label/Label.js';
2
- export type FormLabelProps = Omit<LabelProps, 'isRequired'>;
3
- /**
4
- * FormLabel is a component that displays a label for a form field.
5
- * It is used to provide context for the form field.
6
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
7
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
8
- */
9
- declare const FormLabel: import('react').ForwardRefExoticComponent<FormLabelProps & import('react').RefAttributes<HTMLLabelElement>>;
10
- export { FormLabel };
@@ -1,21 +0,0 @@
1
- import { Label as e } from "../../label/Label.js";
2
- import { useFormField as t } from "../FormField.context.js";
3
- import { forwardRef as n } from "react";
4
- import { jsx as r } from "react/jsx-runtime";
5
- //#region src/components/form-field/parts/FormLabel.tsx
6
- var i = n(({ children: n, ...i }, a) => {
7
- let { requiredVariant: o } = i, { formLabelId: s, formItemId: c, fieldState: { isRequired: l } } = t();
8
- return /* @__PURE__ */ r(e, {
9
- ref: a,
10
- id: s,
11
- isRequired: l,
12
- requiredVariant: o,
13
- htmlFor: c,
14
- className: "uy:leading-[1]!",
15
- ...i,
16
- children: n
17
- });
18
- });
19
- i.displayName = "Label";
20
- //#endregion
21
- export { i as FormLabel };
@@ -1,22 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- interface FormContextualLinkProps {
3
- /**
4
- * The href of the contextual link
5
- */
6
- href: string;
7
- onPress?: never;
8
- }
9
- interface FormContextualLinkActionProps {
10
- /**
11
- * A function to open a contextual panel
12
- */
13
- onPress: () => void;
14
- href?: never;
15
- }
16
- /**
17
- * FormContextualLink is a component that displays a contextual link for a form field.
18
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
19
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
20
- */
21
- declare const RawFormContextualLink: import('react').ForwardRefExoticComponent<PropsWithChildren<FormContextualLinkProps | FormContextualLinkActionProps> & import('react').RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
22
- export { RawFormContextualLink };
@@ -1,33 +0,0 @@
1
- import { RawLink as e } from "../../link/RawLink.js";
2
- import { useFormField as t } from "../FormField.context.js";
3
- import { forwardRef as n } from "react";
4
- import { jsx as r } from "react/jsx-runtime";
5
- import { Button as i } from "react-aria-components/Button";
6
- //#region src/components/form-field/parts/RawFormContextualLink.tsx
7
- var a = n((n, a) => {
8
- let { children: o, href: s, onPress: c, ...l } = n, { formContextualLinkId: u } = t();
9
- return s ? /* @__PURE__ */ r(e, {
10
- id: u,
11
- size: "small",
12
- color: "secondary",
13
- variant: "standalone",
14
- "data-unity-slot": "contextual-link",
15
- href: s,
16
- ref: a,
17
- "data-dd-privacy": "allow",
18
- ...l,
19
- children: o
20
- }) : /* @__PURE__ */ r(i, {
21
- id: u,
22
- onPress: c,
23
- "data-unity-slot": "contextual-link",
24
- className: "uy:typography-body-small uy:w-fit",
25
- ref: a,
26
- "data-dd-privacy": "allow",
27
- ...l,
28
- children: o
29
- });
30
- });
31
- a.displayName = "RawFormContextualLink";
32
- //#endregion
33
- export { a as RawFormContextualLink };
@@ -1,8 +0,0 @@
1
- import { StandardSchema } from '../../../types/schema.js';
2
- /**
3
- * Determines if a field is required based on its path in a schema
4
- * @param schema - The schema adapter object
5
- * @param fieldPath - The path to the field (e.g., "preferences.marketing")
6
- * @returns true if the field is required, false if optional or not found
7
- */
8
- export declare function isFieldRequired(schema: StandardSchema | null | undefined, fieldPath: string): boolean;
@@ -1,8 +0,0 @@
1
- //#region src/components/form-field/utils/isFieldRequired.ts
2
- function e(e, t) {
3
- if (!e) return !1;
4
- let n = e.getField(t);
5
- return n ? !n.isOptional : !1;
6
- }
7
- //#endregion
8
- export { e as isFieldRequired };
@@ -1,92 +0,0 @@
1
- import { StandardSchemaV1 } from '@standard-schema/spec';
2
- import { ForwardedRef, ReactNode } from 'react';
3
- import { FieldPath, FieldValues } from 'react-hook-form';
4
- import { Schema } from '../../hooks/use-form.types.js';
5
- import { LabelProps } from '../label/Label.js';
6
- import { MultiSelectProps } from '../multi-select/MultiselectTypes.js';
7
- interface FieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Pick<LabelProps, 'isRequired' | 'requiredVariant'> {
8
- /** The name of the field, which should match the form schema. */
9
- name: TName;
10
- /** The label for the multi-select field. */
11
- label: string;
12
- /** Helper text to display below the multi-select field. */
13
- helperText?: ReactNode;
14
- /** Feedback text to display below the multi-select field. */
15
- feedbackText?: ReactNode;
16
- /** A contextual link to display below the multi-select field. */
17
- contextualLink?: ReactNode;
18
- }
19
- type BaseMultiSelectProps<TItems = undefined> = Omit<MultiSelectProps<TItems>, 'value' | 'defaultValue' | 'onChange' | 'aria-labelledby' | 'aria-label'>;
20
- export type MultiSelectFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TItems = undefined> = FieldProps<TFieldValues, TName> & BaseMultiSelectProps<TItems>;
21
- /**
22
- * The `MultiSelectField` component renders a full field that allows selecting multiple items from a dropdown list, and integrates with the `Form` component automatically.
23
- *
24
- * The component uses a single generic parameter `TItems` that infers the item type from the `items` prop
25
- * for the dynamic API, or defaults to `undefined` for the static API (using `children` directly).
26
- * @example Static API
27
- * ```tsx
28
- * const schema = z.object({
29
- * fruits: z.set(z.string()),
30
- * })
31
- *
32
- * function MyForm() {
33
- * const { Form } = useUnityForm(schema)
34
- *
35
- * return (
36
- * <Form action={handleSubmit}>
37
- * <MultiSelectField<typeof schema>
38
- * name="fruits"
39
- * label="Select fruits"
40
- * >
41
- * <MultiSelectOption value="apple">Apple</MultiSelectOption>
42
- * <MultiSelectOption value="banana">Banana</MultiSelectOption>
43
- * <MultiSelectOption value="orange">Orange</MultiSelectOption>
44
- * </MultiSelectField>
45
- * </Form>
46
- * )
47
- * }
48
- * ```
49
- * @example Dynamic API
50
- * ```tsx
51
- * interface Fruit { id: string; name: string }
52
- * const fruits = new Set<Fruit>([...])
53
- *
54
- * const schema = z.object({
55
- * fruits: z.set(z.string()),
56
- * })
57
- *
58
- * function MyForm() {
59
- * const { Form } = useUnityForm(schema)
60
- *
61
- * return (
62
- * <Form action={handleSubmit}>
63
- * <MultiSelectField<typeof schema, Set<Fruit>>
64
- * name="fruits"
65
- * label="Select fruits"
66
- * items={fruits}
67
- * getItemValue={fruit => fruit.id}
68
- * >
69
- * {fruit => (
70
- * <MultiSelectOption value={fruit.id}>{fruit.name}</MultiSelectOption>
71
- * )}
72
- * </MultiSelectField>
73
- * </Form>
74
- * )
75
- * }
76
- * ```
77
- * @note The schema type parameter is needed to ensure type safety with the form's schema. If you omit it, the `name` prop will not be type-safe.
78
- * @remarks
79
- * [API & Docs](https://unity-components.payfit.io/?path=/docs/forms-multiselectfield--docs) • [Design Guidelines](https://www.payfit.design/24f360409/p/928776-multiselect)
80
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
81
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
82
- */
83
- /**
84
- * Component type for MultiSelectField with proper generic support
85
- */
86
- type MultiSelectFieldComponent = <TSchema extends Schema = Schema, TItems = undefined>(props: MultiSelectFieldProps<StandardSchemaV1.InferOutput<TSchema>, FieldPath<StandardSchemaV1.InferOutput<TSchema>>, TItems> & {
87
- ref?: ForwardedRef<HTMLButtonElement>;
88
- }) => React.JSX.Element;
89
- export declare const MultiSelectField: MultiSelectFieldComponent & {
90
- displayName: string;
91
- };
92
- export {};