@payfit/unity-components 3.23.15 → 3.23.17
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 +19 -9
- package/dist/esm/core/components/radio-button-group/parts/RadioButton.js +9 -9
- package/dist/esm/core/components/select-list/SelectList.context.d.ts +9 -0
- package/dist/esm/core/components/select-list/SelectList.context.js +11 -0
- package/dist/esm/core/components/select-list/SelectList.d.ts +18 -3
- package/dist/esm/core/components/select-list/SelectList.js +71 -62
- package/dist/esm/core/components/select-list/hooks/useSelectedFirstSorting.js +11 -4
- package/dist/esm/core/components/select-list/parts/SelectListOption.d.ts +15 -0
- package/dist/esm/core/components/select-list/parts/SelectListOption.js +74 -35
- package/dist/esm/core/components/select-list/parts/SelectedItemsSection.d.ts +3 -1
- package/dist/esm/core/components/select-list/parts/SelectedItemsSection.js +17 -21
- package/dist/esm/core/index.js +62 -62
- package/dist/esm/index.js +62 -62
- package/dist/esm/modules/ai-kit/components/ai-structured-input/AIStructuredInput.context.d.ts +30 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/AIStructuredInput.context.js +5 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/AIStructuredInput.d.ts +46 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/AIStructuredInput.js +122 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/form/TanstackAIStructuredInputAnswersField.d.ts +48 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/form/TanstackAIStructuredInputAnswersField.js +62 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/form/TanstackAIStructuredInputForm.d.ts +5 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/form/TanstackAIStructuredInputForm.js +21 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/hooks/use-ai-structured-input-navigation.d.ts +89 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/hooks/use-ai-structured-input-navigation.js +39 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputActions.d.ts +25 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputActions.js +14 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputAnswer.d.ts +15 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputAnswer.js +50 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputAnswers.context.d.ts +8 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputAnswers.context.js +8 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputAnswers.d.ts +73 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputAnswers.js +30 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputContent.d.ts +24 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputContent.js +13 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputFreeTextAnswer.d.ts +28 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputFreeTextAnswer.js +125 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputHeader.d.ts +43 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputHeader.js +42 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputStep.d.ts +43 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputStep.js +14 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputStepTitle.d.ts +43 -0
- package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputStepTitle.js +78 -0
- package/dist/esm/modules/ai-kit/hooks/use-ai-kit-form.d.ts +198 -1
- package/dist/esm/modules/ai-kit/hooks/use-ai-kit-form.js +11 -5
- package/dist/esm/modules/ai-kit/index.d.ts +12 -0
- package/i18n/en-GB.json +10 -1
- package/i18n/es-ES.json +10 -1
- package/i18n/fr-FR.json +10 -1
- package/package.json +6 -6
- package/src/agent-references/component-catalog.json +24 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Icon as e } from "../../../../../core/components/icon/Icon.js";
|
|
2
|
+
import { CircularIconButton as t } from "../../../../../core/components/icon-button/CircularIconButton.js";
|
|
3
|
+
import { Text as n } from "../../../../../core/components/text/Text.js";
|
|
4
|
+
import { forwardRef as r, useId as i } from "react";
|
|
5
|
+
import { uyMerge as a, uyTv as o } from "@payfit/unity-themes";
|
|
6
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
|
+
import { useIntl as l } from "react-intl";
|
|
8
|
+
import { TextArea as u } from "react-aria-components/TextArea";
|
|
9
|
+
//#region src/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputFreeTextAnswer.tsx
|
|
10
|
+
var d = o({ slots: {
|
|
11
|
+
base: [
|
|
12
|
+
"uy:group uy:relative uy:flex uy:max-h-[180px] uy:flex-col uy:justify-end uy:gap-100",
|
|
13
|
+
"uy:overflow-hidden uy:rounded-150 uy:border uy:border-solid uy:border-transparent uy:p-125 uy:bg-transparent",
|
|
14
|
+
"uy:hover:border-border-neutral-hover",
|
|
15
|
+
"uy:hover:bg-surface-neutral-enabled",
|
|
16
|
+
"uy:focus-within:border-border-neutral-hover",
|
|
17
|
+
"uy:focus-within:bg-surface-neutral-enabled uy:focus-within:ring-2",
|
|
18
|
+
"uy:focus-within:ring-utility-focus-ring uy:focus-within:ring-offset-2",
|
|
19
|
+
"uy:data-[active=true]:border-border-neutral-active uy:data-[active=true]:bg-surface-neutral-enabled",
|
|
20
|
+
"uy:data-[loading=true]:border-border-neutral-enabled uy:data-[loading=true]:bg-surface-neutral-enabled",
|
|
21
|
+
"uy:data-[invalid=true]:border-border-danger uy:data-[invalid=true]:bg-surface-neutral-enabled",
|
|
22
|
+
"uy:data-[disabled=true]:bg-surface-neutral-disabled"
|
|
23
|
+
],
|
|
24
|
+
row: "uy:flex uy:w-full uy:min-w-0 uy:items-end",
|
|
25
|
+
icon: [
|
|
26
|
+
"uy:mr-100 uy:flex uy:h-300 uy:w-300 uy:shrink-0 uy:items-center uy:justify-center uy:overflow-hidden",
|
|
27
|
+
"uy:text-content-neutral-lowest",
|
|
28
|
+
"uy:group-focus-within:mr-0 uy:group-focus-within:w-0 uy:group-focus-within:opacity-0",
|
|
29
|
+
"uy:group-data-[icon-hidden=true]:mr-0 uy:group-data-[icon-hidden=true]:w-0 uy:group-data-[icon-hidden=true]:opacity-0",
|
|
30
|
+
"uy:motion-safe:transition-[width,margin,opacity] uy:motion-safe:duration-150 uy:motion-safe:ease-out"
|
|
31
|
+
],
|
|
32
|
+
input: [
|
|
33
|
+
"uy:field-sizing-content uy:max-h-[160px] uy:min-h-300 uy:min-w-0 uy:flex-1",
|
|
34
|
+
"uy:resize-none uy:overflow-y-auto uy:bg-transparent uy:p-0",
|
|
35
|
+
"uy:typography-body uy:text-content-neutral uy:placeholder:text-content-neutral-lowest",
|
|
36
|
+
"uy:disabled:cursor-not-allowed uy:disabled:text-content-neutral-disabled",
|
|
37
|
+
"uy:disabled:placeholder:text-content-neutral-disabled uy:outline-none"
|
|
38
|
+
],
|
|
39
|
+
action: ["uy:shrink-0 uy:data-[active=true]:bg-surface-inverted", "uy:data-[active=true]:text-content-inverted-enabled"],
|
|
40
|
+
actionContainer: [
|
|
41
|
+
"uy:ml-100 uy:shrink-0 uy:scale-100 uy:opacity-100",
|
|
42
|
+
"uy:motion-safe:transition-[opacity,scale] uy:motion-safe:duration-150 uy:motion-safe:ease-out",
|
|
43
|
+
"uy:motion-safe:starting:scale-90 uy:motion-safe:starting:opacity-80"
|
|
44
|
+
],
|
|
45
|
+
feedback: "uy:flex uy:w-full uy:items-center uy:gap-50"
|
|
46
|
+
} }), f = r(({ value: r, onChange: o, onSubmit: f, isDisabled: p = !1, isLoading: m = !1, isInvalid: h = !1, feedbackMessage: g, feedbackId: _, submitAriaLabel: v, className: y, onKeyDown: b, "aria-describedby": x, ...S }, C) => {
|
|
47
|
+
let w = l(), T = i(), E = _ ?? T, D = r.trim().length > 0, O = D || p || h || m, { action: k, actionContainer: A, base: j, feedback: M, icon: N, input: P, row: F } = d(), I = w.formatMessage({
|
|
48
|
+
id: "unity:module:ai-kit:structured-input:free-text-submit",
|
|
49
|
+
defaultMessage: "Save answer and continue"
|
|
50
|
+
}), L = (e) => {
|
|
51
|
+
b?.(e), !(e.defaultPrevented || e.key !== "Enter" || e.shiftKey || e.nativeEvent.isComposing) && (e.preventDefault(), D && !p && !m && f());
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ c("div", {
|
|
54
|
+
className: a(j(), y),
|
|
55
|
+
"data-disabled": p || void 0,
|
|
56
|
+
"data-active": D || void 0,
|
|
57
|
+
"data-has-value": D || void 0,
|
|
58
|
+
"data-icon-hidden": D || p || h || m || void 0,
|
|
59
|
+
"data-invalid": h || void 0,
|
|
60
|
+
"data-loading": m || void 0,
|
|
61
|
+
"data-unity-slot": "ai.structured-input.free-text-answer",
|
|
62
|
+
children: [/* @__PURE__ */ c("div", {
|
|
63
|
+
className: F(),
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ s(e, {
|
|
66
|
+
src: "PencilSimpleOutlined",
|
|
67
|
+
size: 20,
|
|
68
|
+
role: "presentation",
|
|
69
|
+
className: N(),
|
|
70
|
+
"aria-hidden": "true"
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ s(u, {
|
|
73
|
+
...S,
|
|
74
|
+
ref: C,
|
|
75
|
+
value: r,
|
|
76
|
+
onChange: o,
|
|
77
|
+
onKeyDown: L,
|
|
78
|
+
disabled: p,
|
|
79
|
+
"aria-invalid": h || void 0,
|
|
80
|
+
"aria-describedby": g ? [x, E].filter(Boolean).join(" ") : x,
|
|
81
|
+
className: P(),
|
|
82
|
+
"data-dd-privacy": "mask",
|
|
83
|
+
"data-unity-slot": "ai.structured-input.free-text-answer-input"
|
|
84
|
+
}),
|
|
85
|
+
O && /* @__PURE__ */ s("span", {
|
|
86
|
+
className: A(),
|
|
87
|
+
children: /* @__PURE__ */ s(t, {
|
|
88
|
+
asElement: "button",
|
|
89
|
+
type: "button",
|
|
90
|
+
icon: "ArrowUpOutlined",
|
|
91
|
+
title: v ?? I,
|
|
92
|
+
"aria-label": v ?? I,
|
|
93
|
+
color: "content.neutral",
|
|
94
|
+
size: "default",
|
|
95
|
+
className: k(),
|
|
96
|
+
isDisabled: p || m || !D,
|
|
97
|
+
isLoading: m,
|
|
98
|
+
onPress: f,
|
|
99
|
+
"data-active": D || void 0,
|
|
100
|
+
"data-unity-slot": "ai.structured-input.free-text-answer-submit"
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
}), g && /* @__PURE__ */ c("div", {
|
|
105
|
+
className: M(),
|
|
106
|
+
role: "alert",
|
|
107
|
+
children: [/* @__PURE__ */ s(e, {
|
|
108
|
+
src: "WarningCircleOutlined",
|
|
109
|
+
size: 20,
|
|
110
|
+
color: "content.danger",
|
|
111
|
+
role: "presentation",
|
|
112
|
+
"aria-hidden": "true"
|
|
113
|
+
}), /* @__PURE__ */ s(n, {
|
|
114
|
+
id: E,
|
|
115
|
+
variant: "bodySmallStrong",
|
|
116
|
+
color: "content.danger",
|
|
117
|
+
children: g
|
|
118
|
+
})]
|
|
119
|
+
})]
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
f.displayName = "AIStructuredInputFreeTextAnswer";
|
|
123
|
+
var p = f;
|
|
124
|
+
//#endregion
|
|
125
|
+
export { p as AIStructuredInputFreeTextAnswer };
|
package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputHeader.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
/** Props for the banner above an `AIStructuredInput` question sequence. */
|
|
3
|
+
export type AIStructuredInputHeaderProps = Omit<ComponentPropsWithoutRef<'header'>, 'children' | 'className' | 'title'> & {
|
|
4
|
+
/** Required header label. */
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
/** Closes the structured-input surface. */
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
/** Adds styling to the banner. */
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Renders the AI label and a close action above an `AIStructuredInput` question card.
|
|
13
|
+
* Pass it through the root's `header` prop so the root can manage the complete
|
|
14
|
+
* surface layout.
|
|
15
|
+
* @param props - Header label, close action, and standard header attributes.
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { AIStructuredInputHeader } from '@payfit/unity-components/ai-kit'
|
|
19
|
+
*
|
|
20
|
+
* <AIStructuredInput
|
|
21
|
+
* aria-label="Bonus questions"
|
|
22
|
+
* header={
|
|
23
|
+
* <AIStructuredInputHeader
|
|
24
|
+
* title="Bonus questions"
|
|
25
|
+
* onClose={closeQuestions}
|
|
26
|
+
* />
|
|
27
|
+
* }
|
|
28
|
+
* >
|
|
29
|
+
* ...
|
|
30
|
+
* </AIStructuredInput>
|
|
31
|
+
* ```
|
|
32
|
+
* @see {@link AIStructuredInputHeaderProps} for all available props.
|
|
33
|
+
* @param props.title - Required configurable label.
|
|
34
|
+
* @see {@link https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library?node-id=25390-31142 Figma design}
|
|
35
|
+
*/
|
|
36
|
+
export declare const AIStructuredInputHeader: import('react').ForwardRefExoticComponent<Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "children" | "className" | "title"> & {
|
|
37
|
+
/** Required header label. */
|
|
38
|
+
title: ReactNode;
|
|
39
|
+
/** Closes the structured-input surface. */
|
|
40
|
+
onClose: () => void;
|
|
41
|
+
/** Adds styling to the banner. */
|
|
42
|
+
className?: string;
|
|
43
|
+
} & import('react').RefAttributes<HTMLElement>>;
|
package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputHeader.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Icon as e } from "../../../../../core/components/icon/Icon.js";
|
|
2
|
+
import { CircularIconButton as t } from "../../../../../core/components/icon-button/CircularIconButton.js";
|
|
3
|
+
import { Text as n } from "../../../../../core/components/text/Text.js";
|
|
4
|
+
import { forwardRef as r } from "react";
|
|
5
|
+
import { uyMerge as i } from "@payfit/unity-themes";
|
|
6
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
|
+
import { useIntl as s } from "react-intl";
|
|
8
|
+
//#region src/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputHeader.tsx
|
|
9
|
+
var c = r(({ title: r, onClose: c, className: l, ...u }, d) => {
|
|
10
|
+
let f = s();
|
|
11
|
+
return /* @__PURE__ */ o("header", {
|
|
12
|
+
...u,
|
|
13
|
+
ref: d,
|
|
14
|
+
className: i("uy:flex uy:w-full uy:items-center uy:justify-between uy:rounded-t-200", "uy:bg-surface-neutral-lowest uy:py-75 uy:pl-150 uy:pr-75", l),
|
|
15
|
+
"data-unity-slot": "ai.structured-input.header",
|
|
16
|
+
children: [/* @__PURE__ */ o("div", {
|
|
17
|
+
className: "uy:flex uy:min-w-0 uy:items-center uy:gap-50",
|
|
18
|
+
children: [/* @__PURE__ */ a(e, {
|
|
19
|
+
src: "InfoOutlined",
|
|
20
|
+
size: 20,
|
|
21
|
+
color: "content.neutral.low",
|
|
22
|
+
"aria-hidden": "true",
|
|
23
|
+
role: "presentation"
|
|
24
|
+
}), /* @__PURE__ */ a(n, {
|
|
25
|
+
asElement: "span",
|
|
26
|
+
variant: "bodySmallStrong",
|
|
27
|
+
color: "content.neutral.low",
|
|
28
|
+
className: "uy:min-w-0",
|
|
29
|
+
isTruncated: !0,
|
|
30
|
+
children: r
|
|
31
|
+
})]
|
|
32
|
+
}), /* @__PURE__ */ a(t, {
|
|
33
|
+
type: "button",
|
|
34
|
+
icon: "CloseOutlined",
|
|
35
|
+
title: f.formatMessage({ id: "unity:component:common:close:label" }),
|
|
36
|
+
onPress: c
|
|
37
|
+
})]
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
c.displayName = "AIStructuredInputHeader";
|
|
41
|
+
//#endregion
|
|
42
|
+
export { c as AIStructuredInputHeader };
|
package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputStep.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
/** Props for one explicitly identified question in an `AIStructuredInput`. */
|
|
3
|
+
export type AIStructuredInputStepProps = Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'className'> & {
|
|
4
|
+
/** Stable, explicit identity for this question and its consumer-owned draft. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Question prompt, answer control, and any other step-specific content. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Adds styles to the step content wrapper. */
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Marks one question and answer region in an `AIStructuredInput` sequence.
|
|
13
|
+
*
|
|
14
|
+
* Give every step a stable, explicit `id`. The root uses it for navigation
|
|
15
|
+
* identity; consumers can use the same value to key answer drafts that must
|
|
16
|
+
* survive when inactive steps unmount. Use `AIStructuredInputStepTitle` as the
|
|
17
|
+
* first child when the sequence should place navigation beside the question.
|
|
18
|
+
* @param props - Step identity, content, and container attributes.
|
|
19
|
+
* @param props.id - Explicit stable identity for this question and its draft.
|
|
20
|
+
* @param props.children - Question content, including its answer control.
|
|
21
|
+
* @param props.className - Additional classes for the step wrapper.
|
|
22
|
+
* @remarks
|
|
23
|
+
* - Inactive steps are unmounted by `AIStructuredInput`.
|
|
24
|
+
* - Keep answer values in consumer-owned state if they must persist across navigation.
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <AIStructuredInputStep id="start-date">
|
|
28
|
+
* <AIStructuredInputStepTitle>Choose the start date</AIStructuredInputStepTitle>
|
|
29
|
+
* <DateCalendar aria-label="Start date" />
|
|
30
|
+
* </AIStructuredInputStep>
|
|
31
|
+
* ```
|
|
32
|
+
* @see {@link AIStructuredInputStepProps} for all available props.
|
|
33
|
+
* @see {@link https://github.com/PayFit/hr-apps/tree/master/libs/shared/unity/components/src/modules/ai-kit/components/ai-structured-input/parts Source code}
|
|
34
|
+
* @see {@link https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library?node-id=25380-10878 Figma design}
|
|
35
|
+
*/
|
|
36
|
+
export declare const AIStructuredInputStep: import('react').ForwardRefExoticComponent<Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children" | "className"> & {
|
|
37
|
+
/** Stable, explicit identity for this question and its consumer-owned draft. */
|
|
38
|
+
id: string;
|
|
39
|
+
/** Question prompt, answer control, and any other step-specific content. */
|
|
40
|
+
children: ReactNode;
|
|
41
|
+
/** Adds styles to the step content wrapper. */
|
|
42
|
+
className?: string;
|
|
43
|
+
} & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { forwardRef as e } from "react";
|
|
2
|
+
import { uyTv as t } from "@payfit/unity-themes";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputStep.tsx
|
|
5
|
+
var r = t({ base: "uy:flex uy:min-w-0 uy:flex-col uy:gap-150" }), i = e(({ id: e, children: t, className: i, ...a }, o) => /* @__PURE__ */ n("div", {
|
|
6
|
+
...a,
|
|
7
|
+
ref: o,
|
|
8
|
+
className: r({ className: i }),
|
|
9
|
+
"data-step-id": e,
|
|
10
|
+
children: t
|
|
11
|
+
}));
|
|
12
|
+
i.displayName = "AIStructuredInputStep";
|
|
13
|
+
//#endregion
|
|
14
|
+
export { i as AIStructuredInputStep };
|
package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputStepTitle.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { ValidTextElements } from '../../../../../core/components/text/Text.js';
|
|
3
|
+
type HeadingElement = Extract<ValidTextElements, 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'>;
|
|
4
|
+
/** Props for a question title in an `AIStructuredInputStep`. */
|
|
5
|
+
export type AIStructuredInputStepTitleProps = Omit<ComponentPropsWithoutRef<'h2'>, 'className'> & {
|
|
6
|
+
/** Semantic heading level used for the question prompt. Defaults to `h2`. */
|
|
7
|
+
asElement?: HeadingElement;
|
|
8
|
+
/** Adds styles to the title. */
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Renders a semantic question heading and places sequence navigation beside it.
|
|
13
|
+
*
|
|
14
|
+
* Use this as the title of each `AIStructuredInputStep`. It renders a
|
|
15
|
+
* configurable heading with Unity's body-strong text style. Previous/next controls and the live
|
|
16
|
+
* question count appear alongside it when the sequence has multiple steps.
|
|
17
|
+
* After navigation, the new heading receives programmatic focus without
|
|
18
|
+
* becoming an extra Tab stop.
|
|
19
|
+
* @param props - Heading content and standard heading attributes.
|
|
20
|
+
* @param props.asElement - Semantic heading level; defaults to `h2`.
|
|
21
|
+
* @param props.className - Adds styles to the heading element.
|
|
22
|
+
* @remarks
|
|
23
|
+
* - The heading receives programmatic focus after sequence navigation.
|
|
24
|
+
* - The heading level can be adjusted to fit the surrounding page hierarchy.
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <AIStructuredInputStep id="effective-date">
|
|
28
|
+
* <AIStructuredInputStepTitle>
|
|
29
|
+
* When should it take effect?
|
|
30
|
+
* </AIStructuredInputStepTitle>
|
|
31
|
+
* <DateCalendar aria-label="Effective date" />
|
|
32
|
+
* </AIStructuredInputStep>
|
|
33
|
+
* ```
|
|
34
|
+
* @see {@link AIStructuredInputStepTitleProps} for all available props.
|
|
35
|
+
* @see {@link https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library?node-id=25380-13051 Figma design}
|
|
36
|
+
*/
|
|
37
|
+
export declare const AIStructuredInputStepTitle: import('react').ForwardRefExoticComponent<Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">, "className"> & {
|
|
38
|
+
/** Semantic heading level used for the question prompt. Defaults to `h2`. */
|
|
39
|
+
asElement?: HeadingElement;
|
|
40
|
+
/** Adds styles to the title. */
|
|
41
|
+
className?: string;
|
|
42
|
+
} & import('react').RefAttributes<HTMLHeadingElement>>;
|
|
43
|
+
export {};
|
package/dist/esm/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputStepTitle.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { CircularIconButton as e } from "../../../../../core/components/icon-button/CircularIconButton.js";
|
|
2
|
+
import { Text as t } from "../../../../../core/components/text/Text.js";
|
|
3
|
+
import { useAIStructuredInputContext as n } from "../AIStructuredInput.context.js";
|
|
4
|
+
import { forwardRef as r } from "react";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import { useIntl as o } from "react-intl";
|
|
7
|
+
//#region src/modules/ai-kit/components/ai-structured-input/parts/AIStructuredInputStepTitle.tsx
|
|
8
|
+
var s = r(({ children: r, tabIndex: s, asElement: c = "h2", ...l }, u) => {
|
|
9
|
+
let d = o(), f = n();
|
|
10
|
+
return /* @__PURE__ */ a("div", {
|
|
11
|
+
className: "uy:flex uy:w-full uy:min-w-0 uy:items-start uy:justify-between uy:gap-50",
|
|
12
|
+
children: [/* @__PURE__ */ i(t, {
|
|
13
|
+
...l,
|
|
14
|
+
ref: (e) => {
|
|
15
|
+
typeof u == "function" ? u(e) : u && (u.current = e), f?.registerStepHeading(f.activeStepId, e);
|
|
16
|
+
},
|
|
17
|
+
asElement: c,
|
|
18
|
+
tabIndex: s ?? -1,
|
|
19
|
+
variant: "bodyStrong",
|
|
20
|
+
color: "content.neutral",
|
|
21
|
+
className: "uy:text-pretty",
|
|
22
|
+
children: r
|
|
23
|
+
}), f && f.totalSteps > 1 && /* @__PURE__ */ a("div", {
|
|
24
|
+
className: "uy:flex uy:shrink-0 uy:items-center",
|
|
25
|
+
role: "group",
|
|
26
|
+
"aria-label": d.formatMessage({
|
|
27
|
+
id: "unity:module:ai-kit:structured-input:navigation",
|
|
28
|
+
defaultMessage: "Question navigation controls"
|
|
29
|
+
}),
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ i(e, {
|
|
32
|
+
asElement: "button",
|
|
33
|
+
type: "button",
|
|
34
|
+
size: "default",
|
|
35
|
+
color: "content.neutral",
|
|
36
|
+
"aria-controls": f.stepPanelId,
|
|
37
|
+
icon: "CaretLeftOutlined",
|
|
38
|
+
title: d.formatMessage({
|
|
39
|
+
id: "unity:module:ai-kit:structured-input:previous-question",
|
|
40
|
+
defaultMessage: "Previous question"
|
|
41
|
+
}),
|
|
42
|
+
isDisabled: !f.canGoToPreviousStep,
|
|
43
|
+
onPress: f.goToPreviousStep
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ i(t, {
|
|
46
|
+
"aria-live": "polite",
|
|
47
|
+
"aria-atomic": "true",
|
|
48
|
+
variant: "bodySmall",
|
|
49
|
+
color: "content.neutral.lowest",
|
|
50
|
+
children: d.formatMessage({
|
|
51
|
+
id: "unity:module:ai-kit:structured-input:question-count",
|
|
52
|
+
defaultMessage: "{current} of {total}"
|
|
53
|
+
}, {
|
|
54
|
+
current: f.activeStepIndex + 1,
|
|
55
|
+
total: f.totalSteps
|
|
56
|
+
})
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ i(e, {
|
|
59
|
+
asElement: "button",
|
|
60
|
+
type: "button",
|
|
61
|
+
size: "default",
|
|
62
|
+
color: "content.neutral",
|
|
63
|
+
"aria-controls": f.stepPanelId,
|
|
64
|
+
icon: "CaretRightOutlined",
|
|
65
|
+
title: d.formatMessage({
|
|
66
|
+
id: "unity:module:ai-kit:structured-input:next-question",
|
|
67
|
+
defaultMessage: "Next question"
|
|
68
|
+
}),
|
|
69
|
+
isDisabled: !f.canGoToNextStep,
|
|
70
|
+
onPress: f.goToNextStep
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
})]
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
s.displayName = "AIStructuredInputStepTitle";
|
|
77
|
+
//#endregion
|
|
78
|
+
export { s as AIStructuredInputStepTitle };
|