@payfit/unity-components 3.4.6 → 3.4.8
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/esm/ai-kit.js +3 -1
- package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerAlert.d.ts +12 -0
- package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerAlert.js +32 -0
- package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerForm.context.d.ts +6 -0
- package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerForm.context.js +9 -0
- package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerForm.d.ts +9 -0
- package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerForm.js +26 -0
- package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerSubmitAction.d.ts +8 -0
- package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerSubmitAction.js +18 -0
- package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerTextArea.d.ts +4 -0
- package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerTextArea.js +34 -0
- package/dist/esm/modules/ai-kit/hooks/ai-kit-form-context.d.ts +1 -0
- package/dist/esm/modules/ai-kit/hooks/ai-kit-form-context.js +5 -0
- package/dist/esm/modules/ai-kit/hooks/use-ai-kit-form.d.ts +1040 -0
- package/dist/esm/modules/ai-kit/hooks/use-ai-kit-form.js +19 -0
- package/dist/esm/modules/ai-kit/index.d.ts +2 -0
- package/i18n/en-GB.json +5 -1
- package/i18n/es-ES.json +5 -1
- package/i18n/fr-FR.json +5 -1
- package/package.json +7 -7
package/dist/esm/ai-kit.js
CHANGED
|
@@ -10,4 +10,6 @@ import { AIComposerActions as l } from "./modules/ai-kit/components/ai-composer/
|
|
|
10
10
|
import { AIComposerAlert as u } from "./modules/ai-kit/components/ai-composer/parts/AIComposerAlert.js";
|
|
11
11
|
import { AIComposerSubmitAction as d } from "./modules/ai-kit/components/ai-composer/parts/AIComposerSubmitAction.js";
|
|
12
12
|
import { AIComposerTextArea as f } from "./modules/ai-kit/components/ai-composer/parts/AIComposerTextArea.js";
|
|
13
|
-
|
|
13
|
+
import { useAIKitFieldContext as p, useAIKitFormContext as m } from "./modules/ai-kit/hooks/ai-kit-form-context.js";
|
|
14
|
+
import { aiKitForm as h, useAIKitForm as g } from "./modules/ai-kit/hooks/use-ai-kit-form.js";
|
|
15
|
+
export { n as AIButton, s as AIComposer, c as AIComposerAction, l as AIComposerActions, u as AIComposerAlert, a as AIComposerAttachment, o as AIComposerAttachmentsGroup, d as AIComposerSubmitAction, f as AIComposerTextArea, i as AITriggerButton, r as PayfitAIBrand, e as aiGradientEffect, t as aiGradientSurfaceEffect, h as aiKitForm, p as useAIKitFieldContext, g as useAIKitForm, m as useAIKitFormContext };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AIComposerAlertProps } from '../parts/AIComposerAlert.js';
|
|
2
|
+
export interface TanstackAIComposerAlertProps extends Omit<AIComposerAlertProps, 'children' | 'id' | 'variant'> {
|
|
3
|
+
/** Names the one field whose validation message occupies the Composer slot. */
|
|
4
|
+
field: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Renders the first relevant validation error for one nominated Composer field.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TanstackAIComposerAlert: {
|
|
10
|
+
({ field, ...props }: TanstackAIComposerAlertProps): import('react/jsx-runtime').JSX.Element;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AIComposerAlert as e } from "../parts/AIComposerAlert.js";
|
|
2
|
+
import { useAIKitFormContext as t } from "../../../hooks/ai-kit-form-context.js";
|
|
3
|
+
import { useTanstackAIComposerFormLayoutContext as n } from "./TanstackAIComposerForm.context.js";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/modules/ai-kit/components/ai-composer/form/TanstackAIComposerAlert.tsx
|
|
6
|
+
var i = (e) => {
|
|
7
|
+
if (typeof e == "object" && e && "message" in e) {
|
|
8
|
+
let { message: t } = e;
|
|
9
|
+
if (typeof t == "string") return t;
|
|
10
|
+
}
|
|
11
|
+
return typeof e == "string" ? e : String(e);
|
|
12
|
+
}, a = ({ field: a, ...o }) => {
|
|
13
|
+
let s = t(), { getAlertId: c } = n();
|
|
14
|
+
return /* @__PURE__ */ r(s.Subscribe, {
|
|
15
|
+
selector: (e) => ({
|
|
16
|
+
fieldMeta: e.fieldMeta[a],
|
|
17
|
+
submissionAttempts: e.submissionAttempts
|
|
18
|
+
}),
|
|
19
|
+
children: ({ fieldMeta: t, submissionAttempts: n }) => {
|
|
20
|
+
let s = t?.errors ?? [];
|
|
21
|
+
return t !== void 0 && !t.isValid && s.length > 0 && (t.isTouched || n > 0) ? /* @__PURE__ */ r(e, {
|
|
22
|
+
...o,
|
|
23
|
+
id: c(a),
|
|
24
|
+
variant: "error",
|
|
25
|
+
children: i(s[0])
|
|
26
|
+
}) : null;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
a.displayName = "TanstackAIComposerAlert";
|
|
31
|
+
//#endregion
|
|
32
|
+
export { a as TanstackAIComposerAlert };
|
package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerForm.context.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface TanstackAIComposerFormLayoutContextValue {
|
|
2
|
+
getAlertId: (field: string) => string;
|
|
3
|
+
}
|
|
4
|
+
export declare const TanstackAIComposerFormLayoutContextProvider: import('react').Provider<TanstackAIComposerFormLayoutContextValue | null>;
|
|
5
|
+
export declare const useTanstackAIComposerFormLayoutContext: () => TanstackAIComposerFormLayoutContextValue;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext as e, useContext as t } from "react";
|
|
2
|
+
//#region src/modules/ai-kit/components/ai-composer/form/TanstackAIComposerForm.context.tsx
|
|
3
|
+
var n = e(null), r = n.Provider, i = () => {
|
|
4
|
+
let e = t(n);
|
|
5
|
+
if (!e) throw Error("AI Kit Composer form parts must be rendered inside ComposerForm");
|
|
6
|
+
return e;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { r as TanstackAIComposerFormLayoutContextProvider, i as useTanstackAIComposerFormLayoutContext };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AIComposerProps } from '../AIComposer.js';
|
|
2
|
+
export type TanstackAIComposerFormProps = Omit<AIComposerProps, 'onSubmit'>;
|
|
3
|
+
/**
|
|
4
|
+
* Connects the native AI Composer form to the current AI Kit TanStack Form.
|
|
5
|
+
*
|
|
6
|
+
* An explicit Composer lifecycle state remains application-owned. Without one,
|
|
7
|
+
* the form's submission state drives the Composer loading treatment.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TanstackAIComposerForm: import('react').ForwardRefExoticComponent<TanstackAIComposerFormProps & import('react').RefAttributes<HTMLFormElement>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AIComposer as e } from "../AIComposer.js";
|
|
2
|
+
import { useAIKitFormContext as t } from "../../../hooks/ai-kit-form-context.js";
|
|
3
|
+
import { TanstackAIComposerFormLayoutContextProvider as n } from "./TanstackAIComposerForm.context.js";
|
|
4
|
+
import { forwardRef as r, useId as i, useMemo as a } from "react";
|
|
5
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
6
|
+
//#region src/modules/ai-kit/components/ai-composer/form/TanstackAIComposerForm.tsx
|
|
7
|
+
var s = (e, t) => `${e}-${t.replace(/[^\\w-]/g, "-")}-alert`, c = r(({ state: r, ...c }, l) => {
|
|
8
|
+
let u = t(), d = i(), f = a(() => ({ getAlertId: (e) => s(d, e) }), [d]);
|
|
9
|
+
return /* @__PURE__ */ o(u.Subscribe, {
|
|
10
|
+
selector: (e) => e.isSubmitting,
|
|
11
|
+
children: (t) => /* @__PURE__ */ o(n, {
|
|
12
|
+
value: f,
|
|
13
|
+
children: /* @__PURE__ */ o(e, {
|
|
14
|
+
...c,
|
|
15
|
+
ref: l,
|
|
16
|
+
state: r ?? (t ? "loading" : "enabled"),
|
|
17
|
+
onSubmit: () => {
|
|
18
|
+
u.handleSubmit();
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
c.displayName = "TanstackAIComposerForm";
|
|
25
|
+
//#endregion
|
|
26
|
+
export { c as TanstackAIComposerForm };
|
package/dist/esm/modules/ai-kit/components/ai-composer/form/TanstackAIComposerSubmitAction.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AIComposerSubmitActionProps } from '../parts/AIComposerSubmitAction.js';
|
|
2
|
+
export type TanstackAIComposerSubmitActionProps = Omit<AIComposerSubmitActionProps, 'onPress'>;
|
|
3
|
+
/**
|
|
4
|
+
* Submits the current AI Kit form from the Composer action region.
|
|
5
|
+
*
|
|
6
|
+
* The base action still owns stop behavior while the parent Composer streams.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TanstackAIComposerSubmitAction: import('react').ForwardRefExoticComponent<TanstackAIComposerSubmitActionProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AIComposerSubmitAction as e } from "../parts/AIComposerSubmitAction.js";
|
|
2
|
+
import { useAIKitFormContext as t } from "../../../hooks/ai-kit-form-context.js";
|
|
3
|
+
import { forwardRef as n } from "react";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/modules/ai-kit/components/ai-composer/form/TanstackAIComposerSubmitAction.tsx
|
|
6
|
+
var i = n((n, i) => {
|
|
7
|
+
let a = t();
|
|
8
|
+
return /* @__PURE__ */ r(e, {
|
|
9
|
+
...n,
|
|
10
|
+
ref: i,
|
|
11
|
+
onPress: () => {
|
|
12
|
+
a.handleSubmit();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
i.displayName = "TanstackAIComposerSubmitAction";
|
|
17
|
+
//#endregion
|
|
18
|
+
export { i as TanstackAIComposerSubmitAction };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AIComposerTextAreaProps } from '../parts/AIComposerTextArea.js';
|
|
2
|
+
export type TanstackAIComposerTextAreaProps = Omit<AIComposerTextAreaProps, 'aria-describedby' | 'aria-invalid' | 'defaultValue' | 'onBlur' | 'onChange' | 'value'>;
|
|
3
|
+
/** Binds the Composer prompt textarea to the current AI Kit form field. */
|
|
4
|
+
export declare const TanstackAIComposerTextArea: import('react').ForwardRefExoticComponent<TanstackAIComposerTextAreaProps & import('react').RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AIComposerTextArea as e } from "../parts/AIComposerTextArea.js";
|
|
2
|
+
import { useAIKitFieldContext as t, useAIKitFormContext as n } from "../../../hooks/ai-kit-form-context.js";
|
|
3
|
+
import { useTanstackAIComposerFormLayoutContext as r } from "./TanstackAIComposerForm.context.js";
|
|
4
|
+
import { forwardRef as i } from "react";
|
|
5
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
6
|
+
//#region src/modules/ai-kit/components/ai-composer/form/TanstackAIComposerTextArea.tsx
|
|
7
|
+
var o = i((i, o) => {
|
|
8
|
+
let s = t(), c = n(), { getAlertId: l } = r();
|
|
9
|
+
return /* @__PURE__ */ a(c.Subscribe, {
|
|
10
|
+
selector: (e) => ({
|
|
11
|
+
fieldMeta: e.fieldMeta[s.name],
|
|
12
|
+
submissionAttempts: e.submissionAttempts
|
|
13
|
+
}),
|
|
14
|
+
children: ({ fieldMeta: t, submissionAttempts: n }) => {
|
|
15
|
+
let r = t !== void 0 && !t.isValid && (t.isTouched || n > 0);
|
|
16
|
+
return /* @__PURE__ */ a(e, {
|
|
17
|
+
...i,
|
|
18
|
+
ref: o,
|
|
19
|
+
value: s.state.value,
|
|
20
|
+
"aria-invalid": r || void 0,
|
|
21
|
+
"aria-describedby": r ? l(s.name) : void 0,
|
|
22
|
+
onChange: (e) => {
|
|
23
|
+
s.handleChange(e.target.value);
|
|
24
|
+
},
|
|
25
|
+
onBlur: () => {
|
|
26
|
+
s.handleBlur();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
o.displayName = "TanstackAIComposerTextArea";
|
|
33
|
+
//#endregion
|
|
34
|
+
export { o as TanstackAIComposerTextArea };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const aiKitFieldContext: import('react').Context<import('@tanstack/form-core').AnyFieldApi>, aiKitFormContext: import('react').Context<import('@tanstack/form-core').AnyFormApi>, useAIKitFieldContext: <TData>() => import('@tanstack/form-core').FieldApi<any, string, TData, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>, useAIKitFormContext: () => import('@tanstack/react-form').ReactFormExtendedApi<Record<string, never>, any, any, any, any, any, any, any, any, any, any, any>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createFormHookContexts as e } from "@tanstack/react-form";
|
|
2
|
+
//#region src/modules/ai-kit/hooks/ai-kit-form-context.tsx
|
|
3
|
+
var { fieldContext: t, formContext: n, useFieldContext: r, useFormContext: i } = e();
|
|
4
|
+
//#endregion
|
|
5
|
+
export { t as aiKitFieldContext, n as aiKitFormContext, r as useAIKitFieldContext, i as useAIKitFormContext };
|