@opengovsg/confetti 0.0.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.
@@ -0,0 +1,427 @@
1
+ import * as react0 from "react";
2
+ import { HTMLAttributes, PropsWithChildren } from "react";
3
+ import { z } from "zod/v4/mini";
4
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
5
+
6
+ //#region ../validators/src/questions/properties.d.ts
7
+ declare const ratingQuestionSchema: z.ZodMiniObject<{
8
+ type: z.ZodMiniLiteral<"rating">;
9
+ scale: z.ZodMiniNumber<number>;
10
+ labels: z.ZodMiniOptional<z.ZodMiniObject<{
11
+ lower: z.ZodMiniString<string>;
12
+ upper: z.ZodMiniString<string>;
13
+ }, z.core.$strip>>;
14
+ display: z.ZodMiniOptional<z.ZodMiniLiteral<"number" | "star" | "emoji">>;
15
+ }, z.core.$strip>;
16
+ type RatingQuestion = z.infer<typeof ratingQuestionSchema>;
17
+ declare const textQuestionSchema: z.ZodMiniObject<{
18
+ type: z.ZodMiniLiteral<"open-ended">;
19
+ max: z.ZodMiniNumber<number>;
20
+ }, z.core.$strip>;
21
+ type TextQuestion = z.infer<typeof textQuestionSchema>;
22
+ declare const singleSelectQuestionSchema: z.ZodMiniObject<{
23
+ type: z.ZodMiniLiteral<"single-select">;
24
+ options: z.ZodMiniArray<z.ZodMiniObject<{
25
+ label: z.ZodMiniString<string>;
26
+ value: z.ZodMiniString<string>;
27
+ }, z.core.$strip>>;
28
+ editable: z.ZodMiniNullable<z.ZodMiniObject<{
29
+ label: z.ZodMiniString<string>;
30
+ max: z.ZodMiniNumber<number>;
31
+ }, z.core.$strip>>;
32
+ }, z.core.$strip>;
33
+ type SingleSelectQuestion = z.infer<typeof singleSelectQuestionSchema>;
34
+ declare const multiSelectQuestionSchema: z.ZodMiniObject<{
35
+ type: z.ZodMiniLiteral<"multi-select">;
36
+ options: z.ZodMiniArray<z.ZodMiniObject<{
37
+ label: z.ZodMiniString<string>;
38
+ value: z.ZodMiniString<string>;
39
+ }, z.core.$strip>>;
40
+ editable: z.ZodMiniNullable<z.ZodMiniObject<{
41
+ label: z.ZodMiniString<string>;
42
+ max: z.ZodMiniNumber<number>;
43
+ }, z.core.$strip>>;
44
+ max: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
45
+ }, z.core.$strip>;
46
+ type MultiSelectQuestion = z.infer<typeof multiSelectQuestionSchema>;
47
+ //#endregion
48
+ //#region ../validators/src/survey.d.ts
49
+ declare const publicGetSurveyOutputSchema: z.ZodMiniObject<{
50
+ title: z.ZodMiniString<string>;
51
+ description: z.ZodMiniNullable<z.ZodMiniString<string>>;
52
+ questions: z.ZodMiniArray<z.ZodMiniObject<{
53
+ id: z.ZodMiniString<string>;
54
+ title: z.ZodMiniString<string>;
55
+ description: z.ZodMiniNullable<z.ZodMiniString<string>>;
56
+ position: z.ZodMiniNumber<number>;
57
+ required: z.ZodMiniBoolean<boolean>;
58
+ properties: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
59
+ type: z.ZodMiniLiteral<"rating">;
60
+ scale: z.ZodMiniNumber<number>;
61
+ labels: z.ZodMiniOptional<z.ZodMiniObject<{
62
+ lower: z.ZodMiniString<string>;
63
+ upper: z.ZodMiniString<string>;
64
+ }, z.core.$strip>>;
65
+ display: z.ZodMiniOptional<z.ZodMiniLiteral<"number" | "star" | "emoji">>;
66
+ }, z.core.$strip>, z.ZodMiniObject<{
67
+ type: z.ZodMiniLiteral<"single-select">;
68
+ options: z.ZodMiniArray<z.ZodMiniObject<{
69
+ label: z.ZodMiniString<string>;
70
+ value: z.ZodMiniString<string>;
71
+ }, z.core.$strip>>;
72
+ editable: z.ZodMiniNullable<z.ZodMiniObject<{
73
+ label: z.ZodMiniString<string>;
74
+ max: z.ZodMiniNumber<number>;
75
+ }, z.core.$strip>>;
76
+ }, z.core.$strip>, z.ZodMiniObject<{
77
+ type: z.ZodMiniLiteral<"open-ended">;
78
+ max: z.ZodMiniNumber<number>;
79
+ }, z.core.$strip>, z.ZodMiniObject<{
80
+ type: z.ZodMiniLiteral<"multi-select">;
81
+ options: z.ZodMiniArray<z.ZodMiniObject<{
82
+ label: z.ZodMiniString<string>;
83
+ value: z.ZodMiniString<string>;
84
+ }, z.core.$strip>>;
85
+ editable: z.ZodMiniNullable<z.ZodMiniObject<{
86
+ label: z.ZodMiniString<string>;
87
+ max: z.ZodMiniNumber<number>;
88
+ }, z.core.$strip>>;
89
+ max: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
90
+ }, z.core.$strip>], "type">;
91
+ routingLogic: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
92
+ type: z.ZodMiniLiteral<"always">;
93
+ target: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
94
+ type: z.ZodMiniLiteral<"next">;
95
+ }, z.core.$strip>, z.ZodMiniObject<{
96
+ type: z.ZodMiniLiteral<"jump">;
97
+ target: z.ZodMiniNumber<number>;
98
+ }, z.core.$strip>, z.ZodMiniObject<{
99
+ type: z.ZodMiniLiteral<"end">;
100
+ }, z.core.$strip>], "type">;
101
+ }, z.core.$strip>, z.ZodMiniObject<{
102
+ type: z.ZodMiniLiteral<"switch">;
103
+ cases: z.ZodMiniArray<z.ZodMiniObject<{
104
+ type: z.ZodMiniLiteral<"binary-operator">;
105
+ 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">]>;
106
+ value: z.ZodMiniObject<{
107
+ type: z.ZodMiniLiteral<"value">;
108
+ value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniNumber<number>]>;
109
+ }, z.core.$strip>;
110
+ target: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
111
+ type: z.ZodMiniLiteral<"next">;
112
+ }, z.core.$strip>, z.ZodMiniObject<{
113
+ type: z.ZodMiniLiteral<"jump">;
114
+ target: z.ZodMiniNumber<number>;
115
+ }, z.core.$strip>, z.ZodMiniObject<{
116
+ type: z.ZodMiniLiteral<"end">;
117
+ }, z.core.$strip>], "type">;
118
+ }, z.core.$strip>>;
119
+ default: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
120
+ type: z.ZodMiniLiteral<"next">;
121
+ }, z.core.$strip>, z.ZodMiniObject<{
122
+ type: z.ZodMiniLiteral<"jump">;
123
+ target: z.ZodMiniNumber<number>;
124
+ }, z.core.$strip>, z.ZodMiniObject<{
125
+ type: z.ZodMiniLiteral<"end">;
126
+ }, z.core.$strip>], "type">;
127
+ }, z.core.$strip>], "type">;
128
+ }, z.core.$strip>>;
129
+ }, z.core.$strip>;
130
+ type PublicGetSurveyOutput = z.infer<typeof publicGetSurveyOutputSchema>;
131
+ //#endregion
132
+ //#region src/types/index.d.ts
133
+ type Question$1 = {
134
+ visible: boolean;
135
+ error?: string;
136
+ } & PublicGetSurveyOutput['questions'][number];
137
+ type Answer = string | number | string[] | undefined;
138
+ interface ConfettiState {
139
+ questions: Question$1[];
140
+ current: number;
141
+ update: ({
142
+ question,
143
+ answer
144
+ }: {
145
+ question: number;
146
+ answer: Answer;
147
+ }) => {
148
+ next?: number;
149
+ error?: string;
150
+ };
151
+ submit: () => void;
152
+ isCompleted: boolean;
153
+ isSubmitted: boolean;
154
+ errors: Record<Question$1['id'], string>;
155
+ }
156
+ //#endregion
157
+ //#region src/components/ConfettiController.d.ts
158
+ interface ConfettiControllerProps {
159
+ children: (props: ConfettiState) => React.ReactElement;
160
+ /**
161
+ * Control the current question index that is being displayed.
162
+ * If not provided, the component will manage it internally.
163
+ */
164
+ current?: number;
165
+ shouldAutoSubmit?: boolean;
166
+ onFinished?: () => void;
167
+ }
168
+ declare const ConfettiController: ({
169
+ current: currentProp,
170
+ shouldAutoSubmit,
171
+ onFinished,
172
+ children
173
+ }: ConfettiControllerProps) => react_jsx_runtime1.JSX.Element;
174
+ //#endregion
175
+ //#region src/components/ConfettiProvider.d.ts
176
+ interface ConfettiContextValue {
177
+ surveyId: string;
178
+ metadata: Record<string, string>;
179
+ submit: ({
180
+ answers
181
+ }: {
182
+ answers: Record<Question$1['id'], Answer>;
183
+ }) => Promise<void>;
184
+ dismiss: () => Promise<void> | void;
185
+ survey: PublicGetSurveyOutput | undefined;
186
+ }
187
+ declare const ConfettiContext: react0.Context<ConfettiContextValue | null>;
188
+ interface ConfettiProviderProps {
189
+ children: React.ReactNode;
190
+ surveyId: string;
191
+ publishableKey: string;
192
+ respondent?: string;
193
+ metadata: Record<string, string>;
194
+ apiBaseUrl?: string;
195
+ isSurveyVisible?: boolean | ((_: {
196
+ lastRespondedAt: Date | null;
197
+ }) => boolean);
198
+ }
199
+ declare const ConfettiProvider: ({
200
+ children,
201
+ surveyId,
202
+ publishableKey,
203
+ respondent,
204
+ metadata,
205
+ isSurveyVisible: isSurveyVisibleInput,
206
+ apiBaseUrl
207
+ }: ConfettiProviderProps) => react_jsx_runtime1.JSX.Element | null;
208
+ declare const useConfetti: () => ConfettiContextValue;
209
+ //#endregion
210
+ //#region src/components/Confetti.d.ts
211
+ interface ConfettiProps extends Omit<ConfettiProviderProps, 'children'>, Pick<ConfettiControllerProps, 'onFinished' | 'shouldAutoSubmit'> {}
212
+ declare const Confetti: ({
213
+ children,
214
+ shouldAutoSubmit,
215
+ ...props
216
+ }: ConfettiProps & Pick<ConfettiControllerProps, "children" | "shouldAutoSubmit">) => react_jsx_runtime1.JSX.Element;
217
+ //#endregion
218
+ //#region src/components/ThankYouMessage.d.ts
219
+ interface ThankYouMessageProps {
220
+ title?: string;
221
+ description?: string;
222
+ classNames?: {
223
+ question?: string;
224
+ header?: string;
225
+ title?: string;
226
+ description?: string;
227
+ };
228
+ }
229
+ declare const ThankYouMessage: ({
230
+ title,
231
+ description,
232
+ classNames
233
+ }: ThankYouMessageProps) => react_jsx_runtime1.JSX.Element;
234
+ //#endregion
235
+ //#region src/components/container/PopoverContainer.d.ts
236
+ interface PopoverContainerProps {
237
+ closeOnFinishMs?: number;
238
+ classNames?: {
239
+ dialog?: string;
240
+ closeButton?: string;
241
+ icon?: string;
242
+ };
243
+ onDismiss?: () => void;
244
+ containerProps?: Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
245
+ children: React.ReactNode | ((props: {
246
+ setIsFinished: () => void;
247
+ }) => React.ReactNode);
248
+ }
249
+ declare const PopoverContainer: ({
250
+ children,
251
+ classNames,
252
+ containerProps,
253
+ onDismiss,
254
+ closeOnFinishMs
255
+ }: PopoverContainerProps) => react_jsx_runtime1.JSX.Element;
256
+ //#endregion
257
+ //#region src/components/questions/types.d.ts
258
+ type Question = PublicGetSurveyOutput['questions'][number];
259
+ interface BaseFieldProps {
260
+ id: string;
261
+ title: string | null | undefined;
262
+ description?: string | null | undefined;
263
+ required?: boolean;
264
+ onChange: (answer: Answer) => void;
265
+ error?: string;
266
+ }
267
+ //#endregion
268
+ //#region src/components/questions/factory.d.ts
269
+ interface SurveyQuestionFactoryProps {
270
+ question: Question;
271
+ onChange: (answer: Answer) => void;
272
+ error?: string;
273
+ }
274
+ declare const SurveyQuestionFactory: ({
275
+ question,
276
+ onChange,
277
+ error
278
+ }: SurveyQuestionFactoryProps) => react_jsx_runtime1.JSX.Element;
279
+ //#endregion
280
+ //#region src/components/questions/Rating.d.ts
281
+ interface RatingProps extends BaseFieldProps {
282
+ properties: RatingQuestion;
283
+ classNames?: {
284
+ question?: string;
285
+ header?: string;
286
+ title?: string;
287
+ description?: string;
288
+ ratingSection?: string;
289
+ ratingDisplay?: string;
290
+ ratingText?: string;
291
+ ratingTextLower?: string;
292
+ ratingTextUpper?: string;
293
+ ratingDisplayStar?: string;
294
+ ratingStar?: string;
295
+ ratingDisplayNumber?: string;
296
+ ratingNumber?: string;
297
+ ratingDisplayEmoji?: string;
298
+ ratingEmoji?: string;
299
+ error?: string;
300
+ };
301
+ }
302
+ declare const Rating: ({
303
+ properties,
304
+ title,
305
+ description,
306
+ classNames,
307
+ onChange,
308
+ id,
309
+ error,
310
+ required
311
+ }: RatingProps) => react_jsx_runtime1.JSX.Element;
312
+ //#endregion
313
+ //#region src/components/questions/FreeText.d.ts
314
+ interface FreeTextProps extends BaseFieldProps {
315
+ properties: TextQuestion;
316
+ classNames?: {
317
+ question?: string;
318
+ header?: string;
319
+ title?: string;
320
+ description?: string;
321
+ textarea?: string;
322
+ error?: string;
323
+ };
324
+ }
325
+ declare const FreeText: ({
326
+ id,
327
+ title,
328
+ description,
329
+ properties,
330
+ onChange,
331
+ classNames,
332
+ required,
333
+ error
334
+ }: FreeTextProps) => react_jsx_runtime1.JSX.Element;
335
+ //#endregion
336
+ //#region src/components/questions/SingleChoice.d.ts
337
+ interface SingleChoiceProps extends BaseFieldProps {
338
+ properties: SingleSelectQuestion;
339
+ classNames?: {
340
+ question?: string;
341
+ header?: string;
342
+ title?: string;
343
+ description?: string;
344
+ group?: string;
345
+ radio?: string;
346
+ indicator?: string;
347
+ othersChoice?: string;
348
+ othersInput?: string;
349
+ error?: string;
350
+ };
351
+ }
352
+ declare const SingleChoice: ({
353
+ title,
354
+ description,
355
+ properties,
356
+ classNames,
357
+ onChange,
358
+ id,
359
+ required,
360
+ error
361
+ }: SingleChoiceProps) => react_jsx_runtime1.JSX.Element;
362
+ //#endregion
363
+ //#region src/components/questions/MultiChoice.d.ts
364
+ interface MultiChoiceProps extends BaseFieldProps {
365
+ properties: MultiSelectQuestion;
366
+ classNames?: {
367
+ question?: string;
368
+ header?: string;
369
+ title?: string;
370
+ description?: string;
371
+ group?: string;
372
+ checkbox?: string;
373
+ indicator?: string;
374
+ svg?: string;
375
+ othersChoice?: string;
376
+ othersInput?: string;
377
+ error?: string;
378
+ };
379
+ }
380
+ declare const MultiChoice: ({
381
+ title,
382
+ description,
383
+ properties,
384
+ classNames,
385
+ onChange,
386
+ id,
387
+ required,
388
+ error
389
+ }: MultiChoiceProps) => react_jsx_runtime1.JSX.Element;
390
+ //#endregion
391
+ //#region src/components/presentation/Flow.d.ts
392
+ type ChildField = ({
393
+ onChange
394
+ }: {
395
+ onChange: (answer: Answer) => void;
396
+ question: Question;
397
+ error?: string;
398
+ }) => React.ReactNode;
399
+ interface FlowProps {
400
+ onSubmit: (answer: Answer) => void;
401
+ children: ChildField;
402
+ question: Question;
403
+ }
404
+ declare const Flow: ({
405
+ onSubmit,
406
+ children,
407
+ question
408
+ }: FlowProps) => react_jsx_runtime1.JSX.Element;
409
+ //#endregion
410
+ //#region src/components/presentation/Embed.d.ts
411
+ declare const Embed: ({
412
+ isCompleted,
413
+ onSubmit,
414
+ children
415
+ }: PropsWithChildren<{
416
+ isCompleted: boolean;
417
+ onSubmit: () => void;
418
+ }>) => react_jsx_runtime1.JSX.Element;
419
+ //#endregion
420
+ //#region src/templates/EmbeddedConfetti.d.ts
421
+ declare const EmbeddedConfetti: (props: ConfettiProps) => react_jsx_runtime1.JSX.Element;
422
+ //#endregion
423
+ //#region src/templates/StepperConfetti.d.ts
424
+ declare const StepperConfetti: (props: ConfettiProps) => react_jsx_runtime1.JSX.Element;
425
+ //#endregion
426
+ export { Confetti, ConfettiContext, ConfettiController, type ConfettiControllerProps, type ConfettiProps, ConfettiProvider, type ConfettiProviderProps, Embed, EmbeddedConfetti, Flow, FreeText, type FreeTextProps, MultiChoice, type MultiChoiceProps, PopoverContainer, type PopoverContainerProps, Rating, type RatingProps, SingleChoice, type SingleChoiceProps, StepperConfetti, SurveyQuestionFactory, type SurveyQuestionFactoryProps, ThankYouMessage, useConfetti };
427
+ //# sourceMappingURL=index.d.ts.map