@payfit/unity-components 2.68.14 → 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
@@ -158,7 +158,7 @@ export type AIButtonProps = PropsWithChildren<Omit<AriaButtonProps, 'children' |
158
158
  * - `AIButton` applies a glowing, rotating gradient effect on hover and focus.
159
159
  * For users with reduced motion activated, the rotation is disabled.
160
160
  */
161
- export declare const AIButton: import('react').ForwardRefExoticComponent<Omit<AriaButtonProps, "style" | "children" | "className"> & {
161
+ export declare const AIButton: import('react').ForwardRefExoticComponent<Omit<AriaButtonProps, "children" | "className" | "style"> & {
162
162
  /**
163
163
  * Selects the AI button appearance.
164
164
  * - `outlined` keeps a visible AI gradient border while idle.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payfit/unity-components",
3
- "version": "2.68.14",
3
+ "version": "2.68.16",
4
4
  "module": "./dist/esm/index.js",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -77,7 +77,7 @@
77
77
  "@hookform/resolvers": "5.2.1",
78
78
  "@internationalized/date": "3.12.4",
79
79
  "minimatch": "10.2.5",
80
- "@payfit/unity-illustrations": "2.68.14",
80
+ "@payfit/unity-illustrations": "2.68.16",
81
81
  "@radix-ui/react-avatar": "1.2.6",
82
82
  "@radix-ui/react-slot": "1.3.3",
83
83
  "@react-aria/interactions": "3.28.1",
@@ -87,7 +87,7 @@
87
87
  "@tanstack/form-core": "1.33.5",
88
88
  "@tanstack/react-form": "1.33.5",
89
89
  "@tanstack/react-store": "0.11.1",
90
- "@tanstack/react-virtual": "3.14.11",
90
+ "@tanstack/react-virtual": "3.14.12",
91
91
  "@use-gesture/react": "10.3.1",
92
92
  "embla-carousel": "9.0.0-rc03",
93
93
  "embla-carousel-accessibility": "9.0.0-rc01",
@@ -98,7 +98,6 @@
98
98
  "react-aria": "3.52.1",
99
99
  "react-aria-components": "1.21.1",
100
100
  "react-dom": "18.3.1",
101
- "react-hook-form": "7.62.0",
102
101
  "react-hot-toast": "2.5.1",
103
102
  "react-hotkeys-hook": "5.1.0",
104
103
  "react-intersection-observer": "9.5.3",
@@ -112,14 +111,13 @@
112
111
  },
113
112
  "peerDependencies": {
114
113
  "@hookform/devtools": "^4",
115
- "@payfit/unity-icons": "2.68.14",
116
- "@payfit/unity-themes": "2.68.14",
114
+ "@payfit/unity-icons": "2.68.16",
115
+ "@payfit/unity-themes": "2.68.16",
117
116
  "@storybook/react-vite": "^10",
118
117
  "@tanstack/react-query": "^5",
119
118
  "@tanstack/react-router": "^1.131",
120
119
  "@tanstack/react-router-devtools": "^1.131",
121
120
  "@tanstack/react-table": "^9",
122
- "react-hook-form": "^7",
123
121
  "react-router-dom": "^5",
124
122
  "zod": "^3 || ^4"
125
123
  },
@@ -133,16 +131,15 @@
133
131
  "@payfit/storybook-addon-console-errors": "0.0.0-use.local",
134
132
  "@payfit/storybook-addon-datadog-rum": "0.0.0-use.local",
135
133
  "@payfit/storybook-config": "0.0.0-use.local",
136
- "@payfit/unity-icons": "2.68.14",
137
- "@payfit/unity-illustrations": "2.68.14",
138
- "@payfit/unity-themes": "2.68.14",
134
+ "@payfit/unity-icons": "2.68.16",
135
+ "@payfit/unity-illustrations": "2.68.16",
136
+ "@payfit/unity-themes": "2.68.16",
139
137
  "@payfit/vite-configs": "0.0.0-use.local",
140
138
  "@storybook/addon-a11y": "10.6.0",
141
139
  "@storybook/addon-designs": "11.1.4",
142
140
  "@storybook/addon-docs": "10.6.0",
143
141
  "@storybook/addon-links": "10.6.0",
144
142
  "@storybook/addon-mcp": "0.7.0",
145
- "@storybook/addon-themes": "10.6.0",
146
143
  "@storybook/addon-vitest": "10.6.0",
147
144
  "@storybook/react-vite": "10.6.0",
148
145
  "@tanstack/intent": "0.4.0",
@@ -20,7 +20,7 @@ look like a link.
20
20
 
21
21
  > Cross-package targets: `Icon` lives in `@payfit/unity-icons`;
22
22
  > `Illustration` and `LazyIllustration` live in
23
- > `@payfit/unity-illustrations`; `UnityThemeProvider` lives in
23
+ > `@payfit/unity-illustrations`; theme selection is handled by the generated CSS
24
24
  > `@payfit/unity-themes`. Everything else is `@payfit/unity-components`.
25
25
 
26
26
  ## Layout & containers
@@ -154,12 +154,12 @@ look like a link.
154
154
 
155
155
  ## Misc
156
156
 
157
- | Midnight | Unity | Note |
158
- | ------------------ | --------------------------------------------- | ------------------------------------------------------------------- |
159
- | `Accordion` | `Collapsible` | Unity `Collapsible` is single-item; no multi-item accordion |
160
- | `MidnightProvider` | `UnityThemeProvider` (`@payfit/unity-themes`) | Mount once at app root |
161
- | `Overlay` | — | Internal Midnight primitive; use `Dialog`/`Popover`/`Menu` directly |
162
- | `Transition` | `uy:transition-*` / `uy:duration-*` classes | No JS helper; use TailwindCSS utilities |
157
+ | Midnight | Unity | Note |
158
+ | ------------------ | ---------------------------------------------------------- | ------------------------------------------------------------------- |
159
+ | `Accordion` | `Collapsible` | Unity `Collapsible` is single-item; no multi-item accordion |
160
+ | `MidnightProvider` | Generated Unity CSS (`@payfit/unity-themes/css/unity.css`) | Import once at the app entry point |
161
+ | `Overlay` | — | Internal Midnight primitive; use `Dialog`/`Popover`/`Menu` directly |
162
+ | `Transition` | `uy:transition-*` / `uy:duration-*` classes | No JS helper; use TailwindCSS utilities |
163
163
 
164
164
  ## v2 components
165
165
 
@@ -126,30 +126,6 @@ Correct:
126
126
 
127
127
  Source: TanstackForm.tsx:36; TanstackFormField.tsx:63 (useFormContext/useFieldContext)
128
128
 
129
- ### CRITICAL Mix Tanstack field with react-hook-form Controller
130
-
131
- Wrong:
132
-
133
- ```tsx
134
- const { control } = useForm()
135
- <Controller control={control} name="email" render={() => (
136
- <TanstackTextField label="Email" />
137
- )} />
138
- ```
139
-
140
- Correct:
141
-
142
- ```tsx
143
- const form = useTanstackUnityForm({ validators: { onBlur: schema } })
144
- <form.AppForm><form.AppField name="email">
145
- {field => <field.TextField label="Email" />}
146
- </form.AppField></form.AppForm>
147
- ```
148
-
149
- RHF and Tanstack Form contexts do not interoperate; wrapping a Tanstack field in a Controller produces unmounted state and no validation.
150
-
151
- Source: conceptual; RHF and Tanstack contexts do not interoperate
152
-
153
129
  ### HIGH Subscribe to whole form state instead of a selector
154
130
 
155
131
  Wrong:
@@ -247,7 +223,7 @@ Source: TanstackTextField.tsx; TanstackFormField.tsx and its parts
247
223
  ## References
248
224
 
249
225
  - [Bound field components](references/bound-field-components.md) — full inventory of `field.*` Composed components and their underlying base components.
250
- - [Schema adapters](references/schema-adapters.md) — StandardSchemaAdapter, ZodV3SchemaAdapter, ZodV4SchemaAdapter and how `isFieldRequired` consumes them.
226
+ - [Schema adapters](references/schema-adapters.md) — StandardSchemaAdapter, ZodV3SchemaAdapter, and ZodV4SchemaAdapter.
251
227
 
252
228
  ## See also
253
229
 
@@ -71,33 +71,6 @@ const adapter = createSchemaAdapter(schema)
71
71
  // otherwise → null
72
72
  ```
73
73
 
74
- You rarely call this directly: every Composed field organism (e.g. `TanstackTextField`, `TanstackCheckboxField`, `TanstackToggleSwitchGroupField`) calls `createSchemaAdapter` + `isFieldRequired` internally to render the required indicator on the label.
75
-
76
- ## isFieldRequired
77
-
78
- Consumer of the adapter, used inside every Composed field to decide whether to mark the label as required.
79
-
80
- ```ts
81
- // src/components/form-field/utils/isFieldRequired.ts
82
- export function isFieldRequired(
83
- schema: StandardSchema | null | undefined,
84
- fieldPath: string,
85
- ): boolean {
86
- if (!schema) return false
87
- const field = schema.getField(fieldPath)
88
- return field ? !field.isOptional : false
89
- }
90
- ```
91
-
92
- Behavior:
93
-
94
- - No schema → `false` (no required indicator).
95
- - Path not found in schema → `false` (treat as not required rather than crashing).
96
- - Field is `ZodOptional` → `false`.
97
- - Field is anything else → `true`.
98
-
99
- This is why `<form.AppField name="email">{field => <field.TextField label="Email" />}</form.AppField>` automatically gets a required asterisk when `email` is `z.email()` and no asterisk when it's `z.email().optional()` — without any prop wiring.
100
-
101
74
  ## When to import an adapter explicitly
102
75
 
103
76
  Almost never. The Composed field components call `createSchemaAdapter(schema)` themselves. Import an adapter directly only when:
@@ -1,19 +0,0 @@
1
- //#region src/adapters/standardSchemaAdapter.ts
2
- var e = class {
3
- constructor(e) {
4
- this.standardSchema = e;
5
- }
6
- getField(e) {
7
- try {
8
- return this.standardSchema ? {
9
- isOptional: !1,
10
- type: "unknown",
11
- shape: void 0
12
- } : null;
13
- } catch {
14
- return null;
15
- }
16
- }
17
- };
18
- //#endregion
19
- export { e as StandardSchemaAdapter };
@@ -1,60 +0,0 @@
1
- import { z as e } from "zod/v3";
2
- import { z as t } from "zod/v4";
3
- //#region src/adapters/zodAdapter.ts
4
- var n = class {
5
- constructor(e) {
6
- this.zodSchema = e;
7
- }
8
- getField(t) {
9
- try {
10
- if (!this.zodSchema) return null;
11
- let n = t.split("."), r = this.zodSchema.shape, i;
12
- for (let t = 0; t < n.length; t++) {
13
- let a = n[t];
14
- if (i = r[a], !i) return null;
15
- if (t < n.length - 1) {
16
- let t = i instanceof e.ZodOptional ? i._def.innerType.shape : i.shape;
17
- if (!t) return null;
18
- r = t;
19
- }
20
- }
21
- let a = i instanceof e.ZodOptional, o = a ? i._def.innerType : i;
22
- return {
23
- isOptional: a,
24
- type: o._def?.typeName || "unknown",
25
- shape: o instanceof e.ZodObject ? o.shape : void 0
26
- };
27
- } catch {
28
- return null;
29
- }
30
- }
31
- }, r = class {
32
- constructor(e) {
33
- this.zodSchema = e;
34
- }
35
- getField(e) {
36
- try {
37
- if (!this.zodSchema) return null;
38
- let n = e.split("."), r = this.zodSchema.shape, i;
39
- for (let e = 0; e < n.length; e++) {
40
- let a = n[e];
41
- if (i = r[a], !i) return null;
42
- if (e < n.length - 1) {
43
- let e = i instanceof t.ZodOptional ? i.def.innerType.shape : i.shape;
44
- if (!e) return null;
45
- r = e;
46
- }
47
- }
48
- let a = i instanceof t.ZodOptional, o = a ? i.def.innerType : i;
49
- return {
50
- isOptional: a,
51
- type: o.def?.typeName || "unknown",
52
- shape: o instanceof t.ZodObject ? o.shape : void 0
53
- };
54
- } catch {
55
- return null;
56
- }
57
- }
58
- };
59
- //#endregion
60
- export { n as ZodV3SchemaAdapter, r as ZodV4SchemaAdapter };
@@ -1,76 +0,0 @@
1
- import { StandardSchemaV1 } from '@standard-schema/spec';
2
- import { ForwardedRef, JSX, 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
- interface FieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Pick<LabelProps, 'isRequired' | 'requiredVariant'> {
7
- /** The name of the field, which should match the form schema. */
8
- name: TName;
9
- /** The label for the checkbox. */
10
- children: ReactNode;
11
- /** Helper text to display below the checkbox. */
12
- helperText?: ReactNode;
13
- /** A contextual link to display below the checkbox. */
14
- contextualLink?: ReactNode;
15
- /** The default selected value of the checkbox. */
16
- defaultSelected?: boolean;
17
- /** Whether the checkbox is disabled. */
18
- isDisabled?: boolean;
19
- /** Whether the checkbox is read-only. */
20
- isReadOnly?: boolean;
21
- /** Whether the checkbox is invalid. */
22
- isInvalid?: boolean;
23
- /** Whether the checkbox is loading. */
24
- isLoading?: boolean;
25
- }
26
- export type CheckboxFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = FieldProps<TFieldValues, TName>;
27
- type CheckboxFieldComponent = (<TSchema extends Schema>(props: CheckboxFieldProps<StandardSchemaV1.InferOutput<TSchema>> & {
28
- ref?: ForwardedRef<HTMLLabelElement>;
29
- }) => JSX.Element) & {
30
- displayName?: string;
31
- };
32
- /**
33
- * The `CheckboxField` component enhances the base Checkbox with form integration capabilities,
34
- * making it easy to handle boolean values in forms with proper validation and feedback.
35
- *
36
- * It provides form validation, helper text, and error feedback while maintaining the same
37
- * API as the base Checkbox component. The component automatically integrates with Unity's
38
- * form context and handles value updates through the form's state management.
39
- * @param {CheckboxFieldProps} props - Props for the CheckboxField component
40
- * @see {@link CheckboxFieldProps} for all available props
41
- * @example
42
- * ```tsx
43
- * import { useUnityForm, CheckboxField } from '@payfit/unity-components'
44
- * import * as z from 'zod'
45
- *
46
- * function Example() {
47
- * const schema = z.object({
48
- * acceptTerms: z.boolean().refine(Boolean, {
49
- * message: 'You must accept the terms',
50
- * }),
51
- * })
52
- *
53
- * const { Form } = useUnityForm(schema)
54
- *
55
- * return (
56
- * <Form action={handleSubmit}>
57
- * <CheckboxField<typeof schema>
58
- * name="acceptTerms"
59
- * helperText="Please read our terms carefully"
60
- * >
61
- * Accept terms and conditions
62
- * </CheckboxField>
63
- * </Form>
64
- * )
65
- * }
66
- * ```
67
- * @remarks
68
- * [API](/?path=/docs/forms-checkboxfield--docs) • [Demo](/?path=/story/forms-checkboxfield--primary)
69
- * @note The schema type parameter is needed to ensure type safety with the form's
70
- schema.
71
- * If you omit it, the `name` prop will not be type-safe.
72
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
73
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
74
- */
75
- declare const CheckboxField: CheckboxFieldComponent;
76
- export { CheckboxField };
@@ -1,40 +0,0 @@
1
- import { Checkbox as e } from "../checkbox/Checkbox.js";
2
- import { useUnityFormProvider as t } from "../form/Form.context.js";
3
- import { createSchemaAdapter as n } from "../../utils/createSchemaAdapter.js";
4
- import { isFieldRequired as r } from "../form-field/utils/isFieldRequired.js";
5
- import { FormField as i } from "../form-field/FormField.js";
6
- import { FormControl as a } from "../form-field/parts/FormControl.js";
7
- import { FormFeedbackText as o } from "../form-field/parts/FormFeedbackText.js";
8
- import { forwardRef as s, useMemo as c } from "react";
9
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
10
- import { useFormContext as d } from "react-hook-form";
11
- //#region src/components/checkbox-field/CheckboxField.tsx
12
- function f({ name: s, children: f, defaultSelected: p, helperText: m, contextualLink: h, isRequired: g, isInvalid: _, isLoading: v, isDisabled: y, isReadOnly: b, requiredVariant: x, ...S }, C) {
13
- let { control: w, watch: T } = d(), { schema: E } = t(), D = c(() => r(n(E), s), [E, s]);
14
- return /* @__PURE__ */ u(i, {
15
- control: w,
16
- name: s,
17
- className: "uy:flex uy:flex-col uy:gap-100",
18
- isInvalid: _,
19
- isLoading: v,
20
- isDisabled: y,
21
- isReadOnly: b,
22
- children: [/* @__PURE__ */ l(a, { children: /* @__PURE__ */ l(e, {
23
- ref: C,
24
- defaultSelected: p,
25
- isSelected: T(s),
26
- requiredVariant: x,
27
- helperText: m,
28
- feedbackText: /* @__PURE__ */ l(o, {}),
29
- ...S,
30
- isRequired: D ?? g,
31
- children: f
32
- }) }), h]
33
- });
34
- }
35
- var p = s(function(e, t) {
36
- return f(e, t);
37
- });
38
- p.displayName = "CheckboxField";
39
- //#endregion
40
- export { p as CheckboxField };
@@ -1,81 +0,0 @@
1
- import { StandardSchemaV1 } from '@standard-schema/spec';
2
- import { ForwardedRef, JSX, PropsWithChildren, ReactNode } from 'react';
3
- import { FieldPath, FieldValues } from 'react-hook-form';
4
- import { Schema } from '../../hooks/use-form.types.js';
5
- import { CheckboxGroupProps } from '../checkbox-group/CheckboxGroup.js';
6
- import { LabelProps } from '../label/Label.js';
7
- interface FieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends PropsWithChildren<Pick<LabelProps, 'isRequired' | 'requiredVariant'>> {
8
- /** The name of the field, which should match the form schema. */
9
- name: TName;
10
- /** The label for the checkbox group. */
11
- label: string;
12
- /** Helper text to display below the checkbox group. */
13
- helperText?: ReactNode;
14
- /** A contextual link to display below the checkbox group. */
15
- contextualLink?: ReactNode;
16
- /** The default selected values of the checkbox group. */
17
- defaultValue?: string[];
18
- /** Whether the checkbox group is disabled. */
19
- isDisabled?: boolean;
20
- /** Whether the checkbox group is read-only. */
21
- isReadOnly?: boolean;
22
- /** Whether the checkbox group is invalid. */
23
- isInvalid?: boolean;
24
- /** Whether the checkbox group is loading. */
25
- isLoading?: boolean;
26
- /** Callback when the selection changes. */
27
- onChange?: (value: string[]) => void;
28
- /**
29
- * Handler called when the checkbox receives focus.
30
- */
31
- onFocus?: CheckboxGroupProps['onFocus'];
32
- /**
33
- * Handler called when the checkbox loses focus.
34
- */
35
- onBlur?: CheckboxGroupProps['onBlur'];
36
- /**
37
- * Handler that is called when the element's focus status changes.
38
- * @param isFocused
39
- */
40
- onFocusChange?: (isFocused: boolean) => void;
41
- }
42
- export type CheckboxGroupFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = FieldProps<TFieldValues, TName>;
43
- type CheckboxGroupFieldComponent = (<TSchema extends Schema>(props: CheckboxGroupFieldProps<StandardSchemaV1.InferOutput<TSchema>> & {
44
- ref?: ForwardedRef<HTMLDivElement>;
45
- }) => JSX.Element) & {
46
- displayName?: string;
47
- };
48
- /**
49
- * The `CheckboxGroupField` component renders a group of related checkboxes that can be used in forms.
50
- * It integrates with the `Form` component automatically and provides form validation, helper text,
51
- * and error feedback.
52
- * @example
53
- * ```tsx
54
- * const schema = z.object({
55
- * preferences: z.array(z.string())
56
- * })
57
- *
58
- * function MyForm() {
59
- * const { Form } = useUnityForm(schema)
60
- *
61
- * return (
62
- * <Form action={handleSubmit}>
63
- * <CheckboxGroupField<typeof schema>
64
- * name="preferences"
65
- * label="Select your preferences"
66
- * helperText="Choose all that apply"
67
- * >
68
- * <Checkbox value="email">Email notifications</Checkbox>
69
- * <Checkbox value="sms">SMS notifications</Checkbox>
70
- * </CheckboxGroupField>
71
- * </Form>
72
- * )
73
- * }
74
- * ```
75
- * @note The schema type parameter is needed to ensure type safety with the form's schema.
76
- * If you omit it, the `name` prop will not be type-safe.
77
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
78
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
79
- */
80
- declare const CheckboxGroupField: CheckboxGroupFieldComponent;
81
- export { CheckboxGroupField };
@@ -1,37 +0,0 @@
1
- import { CheckboxGroup as e } from "../checkbox-group/CheckboxGroup.js";
2
- import { FormField as t } from "../form-field/FormField.js";
3
- import { FormControl as n } from "../form-field/parts/FormControl.js";
4
- import { FormFeedbackText as r } from "../form-field/parts/FormFeedbackText.js";
5
- import { forwardRef as i } from "react";
6
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
7
- import { useFormContext as s } from "react-hook-form";
8
- //#region src/components/checkbox-group-field/CheckboxGroupField.tsx
9
- function c({ name: i, label: c, defaultValue: l, helperText: u, contextualLink: d, isRequired: f, isInvalid: p, isLoading: m, isDisabled: h, isReadOnly: g, requiredVariant: _, children: v, ...y }, b) {
10
- let { control: x, watch: S } = s();
11
- return /* @__PURE__ */ o(t, {
12
- control: x,
13
- name: i,
14
- isRequired: f,
15
- isInvalid: p,
16
- isLoading: m,
17
- isDisabled: h,
18
- isReadOnly: g,
19
- children: [/* @__PURE__ */ a(n, { children: /* @__PURE__ */ a(e, {
20
- ref: b,
21
- label: c,
22
- defaultValue: l,
23
- value: S(i),
24
- helperText: u,
25
- feedbackText: /* @__PURE__ */ a(r, {}),
26
- requiredVariant: _,
27
- ...y,
28
- children: v
29
- }) }), d]
30
- });
31
- }
32
- var l = i(function(e, t) {
33
- return c(e, t);
34
- });
35
- l.displayName = "CheckboxGroupField";
36
- //#endregion
37
- export { l as CheckboxGroupField };
@@ -1,85 +0,0 @@
1
- import { CalendarDate } from '@internationalized/date';
2
- import { StandardSchemaV1 } from '@standard-schema/spec';
3
- import { ForwardedRef, ReactNode } from 'react';
4
- import { FieldPath, FieldValues } from 'react-hook-form';
5
- import { Schema } from '../../hooks/use-form.types.js';
6
- import { DatePickerProps } from '../date-picker/DatePicker.js';
7
- import { LabelProps } from '../label/Label.js';
8
- export interface DatePickerFieldProps extends Pick<LabelProps, 'isRequired' | 'requiredVariant'>, DatePickerProps {
9
- /** The name of the field, which should match the form schema. */
10
- name: string;
11
- /** The label for the date picker field. */
12
- label: string;
13
- /** The default value of the date picker field. */
14
- defaultValue?: CalendarDate;
15
- /** Helper text to display below the date picker field. */
16
- helperText?: ReactNode;
17
- /** Feedback text to display below the date picker field. */
18
- feedbackText?: ReactNode;
19
- /** A contextual link to display below the date picker field. */
20
- contextualLink?: ReactNode;
21
- /** Whether the field is in an invalid state. */
22
- isInvalid?: boolean;
23
- /** Whether the field is in a loading state. */
24
- isLoading?: boolean;
25
- /** Whether the field is disabled. */
26
- isDisabled?: boolean;
27
- /** Whether the field is read-only. */
28
- isReadOnly?: boolean;
29
- /** The minimum selectable date. */
30
- minValue?: CalendarDate;
31
- /** The maximum selectable date. */
32
- maxValue?: CalendarDate;
33
- /** Function to determine if a date should be disabled. */
34
- isDateUnavailable?: (date: CalendarDate) => boolean;
35
- /** Handler called when the clear button is pressed. */
36
- onClearButtonPress?: () => void;
37
- /** Handler called when the calendar overlay opens or closes. */
38
- onOpenChange?: (isOpen: boolean) => void;
39
- /** Handler called when the field loses focus. */
40
- onBlur?: () => void;
41
- /** Handler called when the field gains focus. */
42
- onFocus?: () => void;
43
- }
44
- export type TypedDatePickerFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Omit<DatePickerFieldProps, 'name'> & {
45
- name: TName;
46
- };
47
- type DatePickerFieldComponent = {
48
- <TSchema extends Schema>(props: TypedDatePickerFieldProps<StandardSchemaV1.InferOutput<TSchema>> & {
49
- ref?: ForwardedRef<HTMLDivElement>;
50
- }): React.JSX.Element;
51
- displayName?: string;
52
- };
53
- /**
54
- * The `DatePickerField` component renders a full field that can accept date input, integrating with the `Form` component automatically.
55
- * It provides a calendar overlay for date selection and supports direct text input for dates.
56
- * @example
57
- * ```tsx
58
- * const schema = z.object({
59
- * birthDate: z.custom<CalendarDate>(),
60
- * startDate: z.custom<CalendarDate>()
61
- * })
62
- *
63
- * function MyForm() {
64
- * const { Form } = useUnityForm(schema)
65
- *
66
- * return (
67
- * <Form action={handleSubmit}>
68
- * <DatePickerField<typeof schema>
69
- * name="birthDate" // Only "birthDate" | "startDate" allowed
70
- * label="Birth Date"
71
- * />
72
- * </Form>
73
- * )
74
- * }
75
- * ```
76
- * @remarks
77
- * [API & Docs](https://master--66fe6715241b661107117e47.chromatic.com/?path=/docs/forms-datepickerfield--docs) • [Design Guidelines](https://www.payfit.design/24f360409/p/719ac2-date-picker)
78
- * @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.
79
- * @note
80
- * This component requires `@internationalized/date` as a peer dependency. Make sure to install it in your project: `pnpm add @internationalized/date`
81
- * @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
82
- * @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
83
- */
84
- declare const DatePickerField: DatePickerFieldComponent;
85
- export { DatePickerField };
@@ -1,54 +0,0 @@
1
- import { DatePicker as e } from "../date-picker/DatePicker.js";
2
- import { FormHelperText as t } from "../form-field/parts/FormHelperText.js";
3
- import { FormField as n } from "../form-field/FormField.js";
4
- import { FormControl as r } from "../form-field/parts/FormControl.js";
5
- import { FormFeedbackText as i } from "../form-field/parts/FormFeedbackText.js";
6
- import { FormLabel as a } from "../form-field/parts/FormLabel.js";
7
- import { forwardRef as o } from "react";
8
- import { uyTv as s } from "@payfit/unity-themes";
9
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
10
- import { useFormContext as u } from "react-hook-form";
11
- //#region src/components/date-picker-field/DatePickerField.tsx
12
- var d = s({ base: "uy:flex uy:flex-col uy:gap-100" });
13
- function f({ name: o, label: s, defaultValue: f, helperText: p, feedbackText: m, contextualLink: h, isRequired: g, isInvalid: _, isLoading: v, isDisabled: y, isReadOnly: b, requiredVariant: x, ...S }, C) {
14
- let { control: w, resetField: T, setValue: E } = u(), D = {
15
- isRequired: g,
16
- isInvalid: _,
17
- isLoading: v,
18
- isDisabled: y,
19
- isReadOnly: b
20
- }, O = S.onClearButtonPress ?? (() => {
21
- T(o, {
22
- keepTouched: !1,
23
- keepDirty: !1,
24
- keepError: !1
25
- }), E(o, null, { shouldValidate: !1 });
26
- });
27
- return /* @__PURE__ */ l(n, {
28
- control: w,
29
- name: o,
30
- className: d(),
31
- ...D,
32
- children: [
33
- /* @__PURE__ */ c(a, {
34
- requiredVariant: x,
35
- children: s
36
- }),
37
- p && /* @__PURE__ */ c(t, { children: p }),
38
- /* @__PURE__ */ c(r, { children: /* @__PURE__ */ c(e, {
39
- ref: C,
40
- defaultValue: f,
41
- onClearButtonPress: O,
42
- ...S
43
- }) }),
44
- /* @__PURE__ */ c(i, { children: m }),
45
- h
46
- ]
47
- });
48
- }
49
- var p = o(function(e, t) {
50
- return f(e, t);
51
- });
52
- p.displayName = "DatePickerField";
53
- //#endregion
54
- export { p as DatePickerField };
@@ -1,9 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- import { Schema } from '../../hooks/use-form.types.js';
3
- interface UnityFormContextValue<TSchema extends Schema> {
4
- schema: TSchema;
5
- }
6
- export declare const UnityFormContext: import('react').Context<UnityFormContextValue<Schema> | null>;
7
- export declare function UnityFormProvider<TSchema extends Schema>({ children, schema, }: PropsWithChildren<UnityFormContextValue<TSchema>>): import("react/jsx-runtime").JSX.Element;
8
- export declare function useUnityFormProvider<TSchema extends Schema>(): UnityFormContextValue<TSchema>;
9
- export {};