@opengovsg/confetti 0.5.2 → 0.6.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.
@@ -1,333 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { z } from "zod/v4/mini";
3
-
4
- //#region ../validators/dist/questions/routing.d.ts
5
- declare const binaryOperatorConditionSchema: z.ZodMiniObject<{
6
- type: z.ZodMiniLiteral<"binary-operator">;
7
- operator: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"equal">, z.ZodMiniLiteral<"not-equal">, z.ZodMiniLiteral<"greater">, z.ZodMiniLiteral<"greater-or-equal">, z.ZodMiniLiteral<"less">, z.ZodMiniLiteral<"less-or-equal">, z.ZodMiniLiteral<"contains">, z.ZodMiniLiteral<"not-contains">]>;
8
- value: z.ZodMiniObject<{
9
- type: z.ZodMiniLiteral<"value">;
10
- value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniNumber<number>]>;
11
- }, z.core.$strip>;
12
- target: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
13
- type: z.ZodMiniLiteral<"next">;
14
- }, z.core.$strip>, z.ZodMiniObject<{
15
- type: z.ZodMiniLiteral<"jump">;
16
- target: z.ZodMiniNumber<number>;
17
- }, z.core.$strip>, z.ZodMiniObject<{
18
- type: z.ZodMiniLiteral<"end">;
19
- }, z.core.$strip>], "type">;
20
- }, z.core.$strip>;
21
- type BinaryOperatorCondition = z.infer<typeof binaryOperatorConditionSchema>;
22
- //#endregion
23
- //#region ../validators/dist/questions/properties.d.ts
24
- declare const ratingQuestionPropertiesSchema: z.ZodMiniObject<{
25
- type: z.ZodMiniLiteral<"rating">;
26
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
27
- shouldAutoProgress: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
28
- scale: z.ZodMiniNumber<number>;
29
- labels: z.ZodMiniOptional<z.ZodMiniObject<{
30
- lower: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string | undefined, string>>>;
31
- upper: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string | undefined, string>>>;
32
- }, z.core.$strip>>;
33
- display: z.ZodMiniOptional<z.ZodMiniLiteral<"number" | "star" | "emoji">>;
34
- }, z.core.$strip>;
35
- type RatingQuestionProperties = z.infer<typeof ratingQuestionPropertiesSchema>;
36
- declare const textQuestionPropertiesSchema: z.ZodMiniObject<{
37
- type: z.ZodMiniLiteral<"open-ended">;
38
- placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
39
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
40
- max: z.ZodMiniNumber<number>;
41
- }, z.core.$strip>;
42
- type TextQuestionProperties = z.infer<typeof textQuestionPropertiesSchema>;
43
- declare const singleSelectQuestionPropertiesSchema: z.ZodMiniObject<{
44
- type: z.ZodMiniLiteral<"single-select">;
45
- shouldAutoProgress: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
46
- options: z.ZodMiniArray<z.ZodMiniObject<{
47
- value: z.ZodMiniString<string>;
48
- description: z.ZodMiniOptional<z.ZodMiniString<string>>;
49
- }, z.core.$strip>>;
50
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
51
- editable: z.ZodMiniNullable<z.ZodMiniObject<{
52
- label: z.ZodMiniString<string>;
53
- max: z.ZodMiniNumber<number>;
54
- description: z.ZodMiniOptional<z.ZodMiniString<string>>;
55
- }, z.core.$strip>>;
56
- }, z.core.$strip>;
57
- type SingleSelectQuestionProperties = z.infer<typeof singleSelectQuestionPropertiesSchema>;
58
- declare const multiSelectQuestionPropertiesSchema: z.ZodMiniObject<{
59
- type: z.ZodMiniLiteral<"multi-select">;
60
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
61
- options: z.ZodMiniArray<z.ZodMiniObject<{
62
- value: z.ZodMiniString<string>;
63
- description: z.ZodMiniOptional<z.ZodMiniString<string>>;
64
- }, z.core.$strip>>;
65
- editable: z.ZodMiniNullable<z.ZodMiniObject<{
66
- label: z.ZodMiniString<string>;
67
- max: z.ZodMiniNumber<number>;
68
- description: z.ZodMiniOptional<z.ZodMiniString<string>>;
69
- }, z.core.$strip>>;
70
- max: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
71
- display: z.ZodMiniOptional<z.ZodMiniLiteral<"checkbox" | "tag">>;
72
- }, z.core.$strip>;
73
- type MultiSelectQuestionProperties = z.infer<typeof multiSelectQuestionPropertiesSchema>;
74
- declare const statementQuestionPropertiesSchema: z.ZodMiniObject<{
75
- type: z.ZodMiniLiteral<"statement">;
76
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
77
- buttonUrl: z.ZodMiniOptional<z.ZodMiniString<string>>;
78
- }, z.core.$strip>;
79
- type StatementQuestionProperties = z.infer<typeof statementQuestionPropertiesSchema>;
80
- //#endregion
81
- //#region ../validators/dist/questions/answers.d.ts
82
- declare const bugReportAnswerSchema: z.ZodMiniObject<{
83
- title: z.ZodMiniString<string>;
84
- description: z.ZodMiniOptional<z.ZodMiniString<string>>;
85
- screenshotDataUrl: z.ZodMiniOptional<z.ZodMiniString<string>>;
86
- recordingEventsJson: z.ZodMiniOptional<z.ZodMiniString<string>>;
87
- metadata: z.ZodMiniOptional<z.ZodMiniObject<{
88
- userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
89
- screenResolution: z.ZodMiniOptional<z.ZodMiniString<string>>;
90
- viewportSize: z.ZodMiniOptional<z.ZodMiniString<string>>;
91
- pageUrl: z.ZodMiniOptional<z.ZodMiniString<string>>;
92
- pageTitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
93
- referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
94
- datadogTraceId: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniString<string>>>;
95
- datadogSessionId: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniString<string>>>;
96
- datadogSessionReplayLink: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniString<string>>>;
97
- }, z.core.$catchall<z.ZodMiniOptional<z.ZodMiniString<string>>>>>;
98
- }, z.core.$strip>;
99
- type BugReportAnswer = z.infer<typeof bugReportAnswerSchema>;
100
- declare const ratingAnswerSchemaFactory: ({
101
- scale
102
- }: {
103
- scale: number;
104
- }, {
105
- required
106
- }: {
107
- required: boolean;
108
- }) => z.ZodMiniNumber<number> | z.ZodMiniOptional<z.ZodMiniNumber<number>>;
109
- type RatingAnswer = z.infer<ReturnType<typeof ratingAnswerSchemaFactory>>;
110
- declare const singleSelectAnswerSchemaFactory: ({
111
- maxLength
112
- }: {
113
- maxLength?: number;
114
- }, {
115
- required
116
- }: {
117
- required: boolean;
118
- }) => z.ZodMiniString<string> | z.ZodMiniOptional<z.ZodMiniString<string>>;
119
- type SingleSelectAnswer = z.infer<ReturnType<typeof singleSelectAnswerSchemaFactory>>;
120
- declare const multiSelectAnswerSchemaFactory: ({
121
- maxSelected,
122
- maxLength
123
- }: {
124
- maxSelected?: number;
125
- maxLength?: number;
126
- }, {
127
- required
128
- }: {
129
- required: boolean;
130
- }) => z.ZodMiniArray<z.ZodMiniString<string>>;
131
- type MultiSelectAnswer = z.infer<ReturnType<typeof multiSelectAnswerSchemaFactory>>;
132
- //#endregion
133
- //#region ../validators/dist/survey.d.ts
134
- declare const publicGetSurveyOutputSchema: z.ZodMiniObject<{
135
- title: z.ZodMiniString<string>;
136
- description: z.ZodMiniNullable<z.ZodMiniString<string>>;
137
- questions: z.ZodMiniArray<z.ZodMiniObject<{
138
- id: z.ZodMiniString<string>;
139
- title: z.ZodMiniString<string>;
140
- description: z.ZodMiniNullable<z.ZodMiniString<string>>;
141
- position: z.ZodMiniNumber<number>;
142
- required: z.ZodMiniBoolean<boolean>;
143
- properties: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
144
- type: z.ZodMiniLiteral<"rating">;
145
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
146
- shouldAutoProgress: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
147
- scale: z.ZodMiniNumber<number>;
148
- labels: z.ZodMiniOptional<z.ZodMiniObject<{
149
- lower: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string | undefined, string>>>;
150
- upper: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string | undefined, string>>>;
151
- }, z.core.$strip>>;
152
- display: z.ZodMiniOptional<z.ZodMiniLiteral<"number" | "star" | "emoji">>;
153
- }, z.core.$strip>, z.ZodMiniObject<{
154
- type: z.ZodMiniLiteral<"single-select">;
155
- shouldAutoProgress: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
156
- options: z.ZodMiniArray<z.ZodMiniObject<{
157
- value: z.ZodMiniString<string>;
158
- description: z.ZodMiniOptional<z.ZodMiniString<string>>;
159
- }, z.core.$strip>>;
160
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
161
- editable: z.ZodMiniNullable<z.ZodMiniObject<{
162
- label: z.ZodMiniString<string>;
163
- max: z.ZodMiniNumber<number>;
164
- description: z.ZodMiniOptional<z.ZodMiniString<string>>;
165
- }, z.core.$strip>>;
166
- }, z.core.$strip>, z.ZodMiniObject<{
167
- type: z.ZodMiniLiteral<"open-ended">;
168
- placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
169
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
170
- max: z.ZodMiniNumber<number>;
171
- }, z.core.$strip>, z.ZodMiniObject<{
172
- type: z.ZodMiniLiteral<"multi-select">;
173
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
174
- options: z.ZodMiniArray<z.ZodMiniObject<{
175
- value: z.ZodMiniString<string>;
176
- description: z.ZodMiniOptional<z.ZodMiniString<string>>;
177
- }, z.core.$strip>>;
178
- editable: z.ZodMiniNullable<z.ZodMiniObject<{
179
- label: z.ZodMiniString<string>;
180
- max: z.ZodMiniNumber<number>;
181
- description: z.ZodMiniOptional<z.ZodMiniString<string>>;
182
- }, z.core.$strip>>;
183
- max: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
184
- display: z.ZodMiniOptional<z.ZodMiniLiteral<"checkbox" | "tag">>;
185
- }, z.core.$strip>, z.ZodMiniObject<{
186
- type: z.ZodMiniLiteral<"statement">;
187
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
188
- buttonUrl: z.ZodMiniOptional<z.ZodMiniString<string>>;
189
- }, z.core.$strip>, z.ZodMiniObject<{
190
- type: z.ZodMiniLiteral<"bug-report">;
191
- placeholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
192
- buttonLabel: z.ZodMiniOptional<z.ZodMiniString<string>>;
193
- enableScreenshot: z.ZodMiniBoolean<boolean>;
194
- enableRecording: z.ZodMiniBoolean<boolean>;
195
- detailsLabel: z.ZodMiniString<string>;
196
- detailsPlaceholder: z.ZodMiniOptional<z.ZodMiniString<string>>;
197
- redactClasses: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
198
- }, z.core.$strip>], "type">;
199
- routingLogic: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
200
- type: z.ZodMiniLiteral<"always">;
201
- target: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
202
- type: z.ZodMiniLiteral<"next">;
203
- }, z.core.$strip>, z.ZodMiniObject<{
204
- type: z.ZodMiniLiteral<"jump">;
205
- target: z.ZodMiniNumber<number>;
206
- }, z.core.$strip>, z.ZodMiniObject<{
207
- type: z.ZodMiniLiteral<"end">;
208
- }, z.core.$strip>], "type">;
209
- }, z.core.$strip>, z.ZodMiniObject<{
210
- type: z.ZodMiniLiteral<"switch">;
211
- cases: z.ZodMiniArray<z.ZodMiniObject<{
212
- type: z.ZodMiniLiteral<"binary-operator">;
213
- operator: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"equal">, z.ZodMiniLiteral<"not-equal">, z.ZodMiniLiteral<"greater">, z.ZodMiniLiteral<"greater-or-equal">, z.ZodMiniLiteral<"less">, z.ZodMiniLiteral<"less-or-equal">, z.ZodMiniLiteral<"contains">, z.ZodMiniLiteral<"not-contains">]>;
214
- value: z.ZodMiniObject<{
215
- type: z.ZodMiniLiteral<"value">;
216
- value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniNumber<number>]>;
217
- }, z.core.$strip>;
218
- target: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
219
- type: z.ZodMiniLiteral<"next">;
220
- }, z.core.$strip>, z.ZodMiniObject<{
221
- type: z.ZodMiniLiteral<"jump">;
222
- target: z.ZodMiniNumber<number>;
223
- }, z.core.$strip>, z.ZodMiniObject<{
224
- type: z.ZodMiniLiteral<"end">;
225
- }, z.core.$strip>], "type">;
226
- }, z.core.$strip>>;
227
- default: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
228
- type: z.ZodMiniLiteral<"next">;
229
- }, z.core.$strip>, z.ZodMiniObject<{
230
- type: z.ZodMiniLiteral<"jump">;
231
- target: z.ZodMiniNumber<number>;
232
- }, z.core.$strip>, z.ZodMiniObject<{
233
- type: z.ZodMiniLiteral<"end">;
234
- }, z.core.$strip>], "type">;
235
- }, z.core.$strip>], "type">;
236
- }, z.core.$strip>>;
237
- confirmation: z.ZodMiniObject<{
238
- title: z.ZodMiniString<string>;
239
- description: z.ZodMiniString<string>;
240
- buttonText: z.ZodMiniString<string>;
241
- }, z.core.$strip>;
242
- }, z.core.$strip>;
243
- type PublicGetSurveyOutput = z.infer<typeof publicGetSurveyOutputSchema>;
244
- //#endregion
245
- //#region src/core/types.d.ts
246
- type Question = {
247
- visible: boolean;
248
- error?: string;
249
- } & PublicGetSurveyOutput['questions'][number];
250
- type Answer = BugReportAnswer | RatingAnswer | MultiSelectAnswer | SingleSelectAnswer;
251
- interface ConfettiState {
252
- questions: Question[];
253
- current: number;
254
- update: ({
255
- question,
256
- answer
257
- }: {
258
- question: number;
259
- answer: Answer;
260
- }) => {
261
- next?: number;
262
- error?: string;
263
- };
264
- submit: () => void;
265
- isCompleted: boolean;
266
- isSubmitted: boolean;
267
- errors: Record<Question['id'], string>;
268
- }
269
- interface Proxyable {
270
- /**
271
- * Origin of the proxy that forwards Confetti API requests. The hosted
272
- * templates also load the widget bundle and stylesheet from it.
273
- */
274
- proxyUrl?: string;
275
- }
276
- type WithProxyable<T> = Omit<T, 'apiBaseUrl'> & Proxyable;
277
- interface Finishable {
278
- /**
279
- * Callback is invoked after the survey response is submitted and the
280
- * submission network call settles.
281
- */
282
- onFinished?: () => void;
283
- }
284
- interface Closable {
285
- /**
286
- * Callback is invoked whenever the survey closes, regardless of how it was closed.
287
- */
288
- onClose?: () => void;
289
- }
290
- /**
291
- * Wraps the rendered survey in a consumer-provided container. Receives an
292
- * object holding the survey node and returns the wrapped tree. The object
293
- * shape leaves room to pass extra render data in the future.
294
- */
295
- type ConfettiContainer = (props: {
296
- survey: ReactNode;
297
- }) => ReactNode;
298
- interface Containable {
299
- /**
300
- * Wraps the rendered survey in a consumer-provided container for theming.
301
- * Only invoked once the survey passes its visibility gates, so the container
302
- * never renders while the survey is hidden, and unmounts when the survey
303
- * closes.
304
- *
305
- * Prefer an inline function. To carry state or animation, render your own
306
- * component inside it: `container={({ survey }) => <BrandShell>{survey}</BrandShell>}`.
307
- */
308
- container?: ConfettiContainer;
309
- }
310
- interface Dismissable extends Closable {
311
- /**
312
- * The widget will automatically close this many milliseconds
313
- * after the survey is finished.
314
- * Set to `null` to disable automatic closing.
315
- * @default 3000
316
- */
317
- closeOnFinishMs?: number | null;
318
- /**
319
- * Callback is invoked when the user dismisses the survey before submitting.
320
- * Closing after submission is not a dismissal and does not invoke this.
321
- */
322
- onDismiss?: () => void;
323
- }
324
- interface OptionallyDismissable extends Dismissable {
325
- /**
326
- * Allows the user to dismiss the modal via the close button and the
327
- * overlay.
328
- * @default true
329
- */
330
- isDismissable?: boolean;
331
- }
332
- //#endregion
333
- export { TextQuestionProperties as _, Containable as a, OptionallyDismissable as c, WithProxyable as d, PublicGetSurveyOutput as f, StatementQuestionProperties as g, SingleSelectQuestionProperties as h, ConfettiState as i, Proxyable as l, RatingQuestionProperties as m, Closable as n, Dismissable as o, MultiSelectQuestionProperties as p, ConfettiContainer as r, Finishable as s, Answer as t, Question as u, BinaryOperatorCondition as v };