@aleph-alpha/chat-kit 5.10.1 → 5.11.0
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/{CkHistory.vue_vue_type_script_setup_true_lang-CKM3MwF_.js → CkHistory.vue_vue_type_script_setup_true_lang-SL1vOAd9.js} +6 -2
- package/dist/chat-kit.css +8 -8
- package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.d.ts +5 -0
- package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.d.ts.map +1 -1
- package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.vue.d.ts.map +1 -1
- package/dist/components/base/CkFeedbackDialog/types.d.ts +9 -0
- package/dist/components/base/CkFeedbackDialog/types.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -5
- package/src/components/base/CkConversationLayout/CkConversationLayout.spec.ts +1 -1
- package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.spec.ts +31 -0
- package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.ts +15 -0
- package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.vue +8 -4
- package/src/components/base/CkFeedbackDialog/types.ts +9 -0
|
@@ -1204,6 +1204,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
1204
1204
|
responseText: { default: "" },
|
|
1205
1205
|
reasons: {},
|
|
1206
1206
|
maxFreeTextLength: { default: 250 },
|
|
1207
|
+
reasonRequired: { type: Boolean, default: true },
|
|
1207
1208
|
submitting: { type: Boolean, default: false },
|
|
1208
1209
|
disabled: { type: Boolean, default: false },
|
|
1209
1210
|
titlePositive: {},
|
|
@@ -1263,8 +1264,11 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
1263
1264
|
() => typeof __props.responseText === "string" && __props.responseText !== ""
|
|
1264
1265
|
);
|
|
1265
1266
|
const characterCount = computed(() => freeText.value.length);
|
|
1267
|
+
const hasInput = computed(
|
|
1268
|
+
() => selectedReasons.value.length > 0 || freeText.value.trim() !== ""
|
|
1269
|
+
);
|
|
1266
1270
|
const canSubmit = computed(
|
|
1267
|
-
() => !__props.disabled && !__props.submitting && (
|
|
1271
|
+
() => !__props.disabled && !__props.submitting && (!__props.reasonRequired || hasInput.value)
|
|
1268
1272
|
);
|
|
1269
1273
|
function handleOpenChange(next) {
|
|
1270
1274
|
if (!next && (__props.submitting || __props.disabled)) {
|
|
@@ -1420,7 +1424,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
1420
1424
|
};
|
|
1421
1425
|
}
|
|
1422
1426
|
});
|
|
1423
|
-
const CkFeedbackDialog = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-
|
|
1427
|
+
const CkFeedbackDialog = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-bdf7bf3d"]]);
|
|
1424
1428
|
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
1425
1429
|
...{
|
|
1426
1430
|
name: "CkFileItemRow",
|
package/dist/chat-kit.css
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
.ck-feedback-dialog__chip[data-v-
|
|
48
|
+
.ck-feedback-dialog__chip[data-v-bdf7bf3d] {
|
|
49
49
|
width: 100%;
|
|
50
50
|
min-height: 36px;
|
|
51
51
|
height: auto;
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
* emitted by the consumer's UnoCSS build. The :hover selector holds the
|
|
60
60
|
* styling when hovering a selected chip (the outline variant ships a
|
|
61
61
|
* data-[state=on]:hover override of equal specificity otherwise). */
|
|
62
|
-
.ck-feedback-dialog__chip[data-state='on'][data-v-
|
|
63
|
-
.ck-feedback-dialog__chip[data-state='on'][data-v-
|
|
62
|
+
.ck-feedback-dialog__chip[data-state='on'][data-v-bdf7bf3d],
|
|
63
|
+
.ck-feedback-dialog__chip[data-state='on'][data-v-bdf7bf3d]:hover {
|
|
64
64
|
border-color: oklch(var(--accent-default));
|
|
65
65
|
background-color: oklch(var(--background-accent-soft));
|
|
66
66
|
color: oklch(var(--content-on-accent-soft));
|
|
@@ -70,17 +70,17 @@
|
|
|
70
70
|
* The free-text field stays vertically resizable, but cap its height so
|
|
71
71
|
* dragging the resize handle can't push it past the dialog bounds.
|
|
72
72
|
*/
|
|
73
|
-
.ck-feedback-dialog__freetext[data-v-
|
|
73
|
+
.ck-feedback-dialog__freetext[data-v-bdf7bf3d] {
|
|
74
74
|
max-height: 11rem;
|
|
75
75
|
}
|
|
76
|
-
.ck-feedback-dialog__response[data-v-
|
|
77
|
-
.ck-feedback-dialog__response[data-v-
|
|
76
|
+
.ck-feedback-dialog__response[data-v-bdf7bf3d] p,
|
|
77
|
+
.ck-feedback-dialog__response[data-v-bdf7bf3d] li {
|
|
78
78
|
line-height: 1.5rem;
|
|
79
79
|
}
|
|
80
|
-
.ck-feedback-dialog__response[data-v-
|
|
80
|
+
.ck-feedback-dialog__response[data-v-bdf7bf3d] p {
|
|
81
81
|
margin: 0 0 0.5rem 0;
|
|
82
82
|
}
|
|
83
|
-
.ck-feedback-dialog__response[data-v-
|
|
83
|
+
.ck-feedback-dialog__response[data-v-bdf7bf3d] p:last-child {
|
|
84
84
|
margin-bottom: 0;
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -17,6 +17,11 @@ export declare const Negative: Story;
|
|
|
17
17
|
* + free-text input fill the dialog.
|
|
18
18
|
*/
|
|
19
19
|
export declare const NoResponseColumn: Story;
|
|
20
|
+
/**
|
|
21
|
+
* With `reasonRequired: false` the reasons and free text are both optional —
|
|
22
|
+
* Submit is enabled immediately and submits the bare sentiment.
|
|
23
|
+
*/
|
|
24
|
+
export declare const OptionalInput: Story;
|
|
20
25
|
/**
|
|
21
26
|
* Submit shows a busy state while the host persists the payload; both actions
|
|
22
27
|
* are non-interactive.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CkFeedbackDialog.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,wBAAwB,CAAC;AAOtD,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AA2D3D,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,gBAAgB,
|
|
1
|
+
{"version":3,"file":"CkFeedbackDialog.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,wBAAwB,CAAC;AAOtD,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AA2D3D,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,gBAAgB,CAiBvC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAoEnC;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,KAOtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,KAOtB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAO9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,KAQ3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAQxB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAO1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAqEhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CkFeedbackDialog.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkFeedbackDialog/CkFeedbackDialog.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CkFeedbackDialog.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkFeedbackDialog/CkFeedbackDialog.vue"],"names":[],"mappings":"AAqUA,OAAO,KAAK,EACV,qBAAqB,EACrB,6BAA6B,EAC9B,MAAM,SAAS,CAAC;AAwhBjB,QAAA,MAAM,YAAY;;;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -77,6 +77,15 @@ export interface CkFeedbackDialogProps {
|
|
|
77
77
|
* @default 250
|
|
78
78
|
*/
|
|
79
79
|
maxFreeTextLength?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the user must provide at least one signal before submitting. When
|
|
82
|
+
* `true` (the default) Submit stays disabled until a reason chip is selected
|
|
83
|
+
* or the free-text field is non-empty, so an empty qualitative payload is
|
|
84
|
+
* never sent. Set to `false` to let the user submit the bare sentiment — the
|
|
85
|
+
* payload then carries an empty `reasons` array and an empty `reasonText`.
|
|
86
|
+
* @default true
|
|
87
|
+
*/
|
|
88
|
+
reasonRequired?: boolean;
|
|
80
89
|
/**
|
|
81
90
|
* When `true`, the Submit button shows a busy state and clicks are ignored.
|
|
82
91
|
* Use while the parent is awaiting the backend POST.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkFeedbackDialog/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,UAAU,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,6BAA6B;IAC5C,+CAA+C;IAC/C,SAAS,EAAE,mBAAmB,CAAC;IAC/B;;;;OAIG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,SAAS,EAAE,mBAAmB,CAAC;IAC/B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC;;;;OAIG;IACH,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC5D;;;OAGG;IACH,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CACrB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkFeedbackDialog/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,UAAU,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,6BAA6B;IAC5C,+CAA+C;IAC/C,SAAS,EAAE,mBAAmB,CAAC;IAC/B;;;;OAIG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,SAAS,EAAE,mBAAmB,CAAC;IAC/B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC;;;;OAIG;IACH,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC5D;;;OAGG;IACH,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CACrB"}
|
package/dist/components/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _, a, C, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z } from "../CkHistory.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { _, a, C, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z } from "../CkHistory.vue_vue_type_script_setup_true_lang-SL1vOAd9.js";
|
|
2
2
|
export {
|
|
3
3
|
_ as CkAgentMessage,
|
|
4
4
|
a as CkAgentMessageHeader,
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { u } from "./useMessageHandler-Tellov3w.js";
|
|
2
2
|
import { C, d, p, u as u2, b } from "./useChatKitLabels-CMOr3Kjq.js";
|
|
3
3
|
import { S, c, d as d2, f, u as u3, a, b as b2, e } from "./index-Dn4ctxk8.js";
|
|
4
|
-
import { _, a as a2, C as C2, b as b3, c as c2, d as d3, e as e2, f as f2, g, h, i, j, k, l, m, n, o, p as p2, q, r, s, t, u as u4, v, w, x, y, z, A } from "./CkHistory.vue_vue_type_script_setup_true_lang-
|
|
4
|
+
import { _, a as a2, C as C2, b as b3, c as c2, d as d3, e as e2, f as f2, g, h, i, j, k, l, m, n, o, p as p2, q, r, s, t, u as u4, v, w, x, y, z, A } from "./CkHistory.vue_vue_type_script_setup_true_lang-SL1vOAd9.js";
|
|
5
5
|
export {
|
|
6
6
|
C as CHAT_KIT_LABELS,
|
|
7
7
|
_ as CkAgentMessage,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aleph-alpha/chat-kit",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"description": "Chat kit package for building chat interfaces with Vue",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -107,14 +107,14 @@
|
|
|
107
107
|
"vue": "^3.5.27",
|
|
108
108
|
"vue-tsc": "^3.2.4",
|
|
109
109
|
"wait-on": "9.0.3",
|
|
110
|
-
"@aleph-alpha/eslint-config-frontend": "0.7.
|
|
111
|
-
"@aleph-alpha/tsconfig-frontend": "0.7.
|
|
112
|
-
"@aleph-alpha/prettier-config-frontend": "2.1.
|
|
110
|
+
"@aleph-alpha/eslint-config-frontend": "0.7.1",
|
|
111
|
+
"@aleph-alpha/tsconfig-frontend": "0.7.2",
|
|
112
|
+
"@aleph-alpha/prettier-config-frontend": "2.1.1"
|
|
113
113
|
},
|
|
114
114
|
"scripts": {
|
|
115
115
|
"build": "vite build && vue-tsc --project tsconfig.build.json --declaration --emitDeclarationOnly --outDir dist",
|
|
116
116
|
"dev": "vite build --watch",
|
|
117
|
-
"
|
|
117
|
+
"typecheck": "vue-tsc --noEmit",
|
|
118
118
|
"test": "vitest run",
|
|
119
119
|
"format": "prettier --write .",
|
|
120
120
|
"lint": "prettier --check . && eslint --fix src",
|
|
@@ -261,7 +261,7 @@ describe('CkConversationLayout', () => {
|
|
|
261
261
|
});
|
|
262
262
|
|
|
263
263
|
describe('scroll fade indicators', () => {
|
|
264
|
-
function getFadeElements(container:
|
|
264
|
+
function getFadeElements(container: Element) {
|
|
265
265
|
return {
|
|
266
266
|
topFade: container.querySelector('.bg-gradient-to-b') as HTMLElement,
|
|
267
267
|
bottomFade: container.querySelector('.bg-gradient-to-t') as HTMLElement,
|
|
@@ -148,6 +148,37 @@ describe('CkFeedbackDialog', () => {
|
|
|
148
148
|
});
|
|
149
149
|
});
|
|
150
150
|
|
|
151
|
+
// With `reasonRequired: false` the bare sentiment is a valid submission, so
|
|
152
|
+
// Submit is enabled from the start.
|
|
153
|
+
it('allows submitting with no input when reasonRequired is false', async () => {
|
|
154
|
+
const user = userEvent.setup();
|
|
155
|
+
const { emitted } = renderDialog({
|
|
156
|
+
sentiment: 'negative',
|
|
157
|
+
reasonRequired: false,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const submit = await screen.findByRole('button', { name: SUBMIT });
|
|
161
|
+
expect(submit).not.toBeDisabled();
|
|
162
|
+
|
|
163
|
+
await user.click(submit);
|
|
164
|
+
|
|
165
|
+
const submitEvents = emitted('submit') as [CkFeedbackDialogSubmitPayload][];
|
|
166
|
+
expect(submitEvents).toHaveLength(1);
|
|
167
|
+
expect(submitEvents[0][0]).toEqual({
|
|
168
|
+
sentiment: 'negative',
|
|
169
|
+
reasons: [],
|
|
170
|
+
reasonText: '',
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// `reasonRequired: false` only relaxes the gate — submitting/disabled still
|
|
175
|
+
// freeze the action.
|
|
176
|
+
it('keeps submit disabled while submitting even when reasonRequired is false', async () => {
|
|
177
|
+
renderDialog({ reasonRequired: false, submitting: true });
|
|
178
|
+
|
|
179
|
+
expect(await screen.findByRole('button', { name: SUBMIT })).toBeDisabled();
|
|
180
|
+
});
|
|
181
|
+
|
|
151
182
|
// Edge case: reasons + free text combine into one payload, free text trimmed.
|
|
152
183
|
it('emits both reasons and free text when given', async () => {
|
|
153
184
|
const user = userEvent.setup();
|
|
@@ -77,6 +77,7 @@ const meta: Meta<typeof CkFeedbackDialog> = {
|
|
|
77
77
|
responseText: { control: 'text' },
|
|
78
78
|
reasons: { control: 'object' },
|
|
79
79
|
maxFreeTextLength: { control: 'number' },
|
|
80
|
+
reasonRequired: { control: 'boolean' },
|
|
80
81
|
submitting: { control: 'boolean' },
|
|
81
82
|
disabled: { control: 'boolean' },
|
|
82
83
|
},
|
|
@@ -189,6 +190,20 @@ export const NoResponseColumn: Story = {
|
|
|
189
190
|
},
|
|
190
191
|
};
|
|
191
192
|
|
|
193
|
+
/**
|
|
194
|
+
* With `reasonRequired: false` the reasons and free text are both optional —
|
|
195
|
+
* Submit is enabled immediately and submits the bare sentiment.
|
|
196
|
+
*/
|
|
197
|
+
export const OptionalInput: Story = {
|
|
198
|
+
args: {
|
|
199
|
+
open: true,
|
|
200
|
+
sentiment: 'negative',
|
|
201
|
+
reasons: NEGATIVE_REASONS,
|
|
202
|
+
responseText: SAMPLE_RESPONSE,
|
|
203
|
+
reasonRequired: false,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
|
|
192
207
|
/**
|
|
193
208
|
* Submit shows a busy state while the host persists the payload; both actions
|
|
194
209
|
* are non-interactive.
|
|
@@ -31,6 +31,7 @@ const {
|
|
|
31
31
|
responseText = '',
|
|
32
32
|
reasons,
|
|
33
33
|
maxFreeTextLength = 250,
|
|
34
|
+
reasonRequired = true,
|
|
34
35
|
submitting = false,
|
|
35
36
|
disabled = false,
|
|
36
37
|
titlePositive,
|
|
@@ -132,11 +133,14 @@ const showResponseColumn = computed(
|
|
|
132
133
|
() => typeof responseText === 'string' && responseText !== '',
|
|
133
134
|
);
|
|
134
135
|
const characterCount = computed(() => freeText.value.length);
|
|
136
|
+
const hasInput = computed(
|
|
137
|
+
() => selectedReasons.value.length > 0 || freeText.value.trim() !== '',
|
|
138
|
+
);
|
|
139
|
+
// With `reasonRequired` (the default) the user must give at least one signal —
|
|
140
|
+
// a reason chip or some free text — so we never submit an empty qualitative
|
|
141
|
+
// payload. When it's off, the bare sentiment is a valid submission.
|
|
135
142
|
const canSubmit = computed(
|
|
136
|
-
() =>
|
|
137
|
-
!disabled &&
|
|
138
|
-
!submitting &&
|
|
139
|
-
(selectedReasons.value.length > 0 || freeText.value.trim() !== ''),
|
|
143
|
+
() => !disabled && !submitting && (!reasonRequired || hasInput.value),
|
|
140
144
|
);
|
|
141
145
|
|
|
142
146
|
function handleOpenChange(next: boolean): void {
|
|
@@ -80,6 +80,15 @@ export interface CkFeedbackDialogProps {
|
|
|
80
80
|
* @default 250
|
|
81
81
|
*/
|
|
82
82
|
maxFreeTextLength?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Whether the user must provide at least one signal before submitting. When
|
|
85
|
+
* `true` (the default) Submit stays disabled until a reason chip is selected
|
|
86
|
+
* or the free-text field is non-empty, so an empty qualitative payload is
|
|
87
|
+
* never sent. Set to `false` to let the user submit the bare sentiment — the
|
|
88
|
+
* payload then carries an empty `reasons` array and an empty `reasonText`.
|
|
89
|
+
* @default true
|
|
90
|
+
*/
|
|
91
|
+
reasonRequired?: boolean;
|
|
83
92
|
/**
|
|
84
93
|
* When `true`, the Submit button shows a busy state and clicks are ignored.
|
|
85
94
|
* Use while the parent is awaiting the backend POST.
|