@assistant-ui/react-generative-ui 0.0.21 → 0.0.23
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/LICENSE +1 -1
- package/dist/JSONGenerativeUI.client.d.ts.map +1 -1
- package/dist/JSONGenerativeUI.client.js +30 -13
- package/dist/JSONGenerativeUI.client.js.map +1 -1
- package/dist/RadioGroupScope.d.ts +6 -0
- package/dist/RadioGroupScope.d.ts.map +1 -0
- package/dist/RadioGroupScope.js +25 -0
- package/dist/RadioGroupScope.js.map +1 -0
- package/dist/a2ui/BindingContext.d.ts +11 -0
- package/dist/a2ui/BindingContext.d.ts.map +1 -0
- package/dist/a2ui/BindingContext.js +12 -0
- package/dist/a2ui/BindingContext.js.map +1 -0
- package/dist/a2ui/PresentRenderer.d.ts +11 -0
- package/dist/a2ui/PresentRenderer.d.ts.map +1 -0
- package/dist/a2ui/PresentRenderer.js +39 -0
- package/dist/a2ui/PresentRenderer.js.map +1 -0
- package/dist/a2ui/convert.d.ts +6 -0
- package/dist/a2ui/convert.d.ts.map +1 -1
- package/dist/a2ui/convert.js +363 -85
- package/dist/a2ui/convert.js.map +1 -1
- package/dist/a2ui/dataModel.d.ts +9 -0
- package/dist/a2ui/dataModel.d.ts.map +1 -0
- package/dist/a2ui/dataModel.js +44 -0
- package/dist/a2ui/dataModel.js.map +1 -0
- package/dist/a2ui/reducer.d.ts +5 -0
- package/dist/a2ui/reducer.d.ts.map +1 -1
- package/dist/a2ui/reducer.js +3 -3
- package/dist/a2ui/reducer.js.map +1 -1
- package/dist/a2ui/types.d.ts +8 -2
- package/dist/a2ui/types.d.ts.map +1 -1
- package/dist/a2ui/types.js.map +1 -1
- package/dist/a2ui/valueFunctions.d.ts +16 -0
- package/dist/a2ui/valueFunctions.d.ts.map +1 -0
- package/dist/a2ui/valueFunctions.js +332 -0
- package/dist/a2ui/valueFunctions.js.map +1 -0
- package/dist/actionRegistry.d.ts +1 -1
- package/dist/actionRegistry.js.map +1 -1
- package/dist/answeredValues.d.ts +16 -0
- package/dist/answeredValues.d.ts.map +1 -0
- package/dist/answeredValues.js +37 -0
- package/dist/answeredValues.js.map +1 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -1
- package/dist/constants.js.map +1 -1
- package/dist/fieldReferences.d.ts +9 -0
- package/dist/fieldReferences.d.ts.map +1 -0
- package/dist/fieldReferences.js +53 -0
- package/dist/fieldReferences.js.map +1 -0
- package/dist/generativeUIToJSX.js +3 -3
- package/dist/generativeUIToJSX.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.server.js +2 -2
- package/dist/index.shared.js +2 -2
- package/dist/ir.d.ts +1 -1
- package/dist/ir.js.map +1 -1
- package/dist/renderGenerativeUI.d.ts.map +1 -1
- package/dist/renderGenerativeUI.js +12 -1
- package/dist/renderGenerativeUI.js.map +1 -1
- package/dist/slack/constants.d.ts +2 -0
- package/dist/slack/constants.d.ts.map +1 -1
- package/dist/slack/constants.js +3 -1
- package/dist/slack/constants.js.map +1 -1
- package/dist/slack/decodeBlockAction.d.ts +3 -1
- package/dist/slack/decodeBlockAction.d.ts.map +1 -1
- package/dist/slack/decodeBlockAction.js +96 -7
- package/dist/slack/decodeBlockAction.js.map +1 -1
- package/dist/slack/fromSlackBlocks.d.ts.map +1 -1
- package/dist/slack/fromSlackBlocks.js +43 -3
- package/dist/slack/fromSlackBlocks.js.map +1 -1
- package/dist/slack/toSlackBlocks.d.ts.map +1 -1
- package/dist/slack/toSlackBlocks.js +244 -20
- package/dist/slack/toSlackBlocks.js.map +1 -1
- package/dist/slack/types.d.ts +24 -1
- package/dist/slack/types.d.ts.map +1 -1
- package/dist/slack.d.ts +1 -1
- package/dist/slack.d.ts.map +1 -1
- package/dist/teams/constants.d.ts +1 -1
- package/dist/teams/constants.d.ts.map +1 -1
- package/dist/teams/constants.js +1 -1
- package/dist/teams/constants.js.map +1 -1
- package/dist/teams/decodeSubmitData.d.ts +4 -0
- package/dist/teams/decodeSubmitData.d.ts.map +1 -1
- package/dist/teams/decodeSubmitData.js +29 -3
- package/dist/teams/decodeSubmitData.js.map +1 -1
- package/dist/teams/temporalId.d.ts +5 -0
- package/dist/teams/temporalId.d.ts.map +1 -0
- package/dist/teams/temporalId.js +28 -0
- package/dist/teams/temporalId.js.map +1 -0
- package/dist/teams/toAdaptiveCard.d.ts +5 -4
- package/dist/teams/toAdaptiveCard.d.ts.map +1 -1
- package/dist/teams/toAdaptiveCard.js +136 -18
- package/dist/teams/toAdaptiveCard.js.map +1 -1
- package/dist/teams/toTeamsAttachments.d.ts.map +1 -1
- package/dist/teams/toTeamsAttachments.js.map +1 -1
- package/dist/teams/types.d.ts +23 -2
- package/dist/teams/types.d.ts.map +1 -1
- package/dist/teams.d.ts +1 -1
- package/dist/teams.d.ts.map +1 -1
- package/dist/temporal.d.ts +33 -0
- package/dist/temporal.d.ts.map +1 -0
- package/dist/temporal.js +152 -0
- package/dist/temporal.js.map +1 -0
- package/dist/vocabulary/alert.d.ts +9 -2
- package/dist/vocabulary/alert.d.ts.map +1 -1
- package/dist/vocabulary/alert.js +116 -19
- package/dist/vocabulary/alert.js.map +1 -1
- package/dist/vocabulary/collectFormValues.d.ts +2 -1
- package/dist/vocabulary/collectFormValues.d.ts.map +1 -1
- package/dist/vocabulary/collectFormValues.js +15 -4
- package/dist/vocabulary/collectFormValues.js.map +1 -1
- package/dist/vocabulary/data.d.ts +22 -5
- package/dist/vocabulary/data.d.ts.map +1 -1
- package/dist/vocabulary/data.js +278 -83
- package/dist/vocabulary/data.js.map +1 -1
- package/dist/vocabulary/dispatch.d.ts +3 -2
- package/dist/vocabulary/dispatch.d.ts.map +1 -1
- package/dist/vocabulary/dispatch.js +33 -4
- package/dist/vocabulary/dispatch.js.map +1 -1
- package/dist/vocabulary/fact.d.ts +8 -1
- package/dist/vocabulary/fact.d.ts.map +1 -1
- package/dist/vocabulary/fact.js +37 -11
- package/dist/vocabulary/fact.js.map +1 -1
- package/dist/vocabulary/form.d.ts.map +1 -1
- package/dist/vocabulary/form.js +3 -3
- package/dist/vocabulary/form.js.map +1 -1
- package/dist/vocabulary/formatValue.d.ts +7 -0
- package/dist/vocabulary/formatValue.d.ts.map +1 -0
- package/dist/vocabulary/formatValue.js +76 -0
- package/dist/vocabulary/formatValue.js.map +1 -0
- package/dist/vocabulary/icon.d.ts +1 -1
- package/dist/vocabulary/interactive.d.ts +143 -8
- package/dist/vocabulary/interactive.d.ts.map +1 -1
- package/dist/vocabulary/interactive.js +458 -107
- package/dist/vocabulary/interactive.js.map +1 -1
- package/dist/vocabulary/layout.d.ts.map +1 -1
- package/dist/vocabulary/layout.js +4 -4
- package/dist/vocabulary/layout.js.map +1 -1
- package/dist/vocabulary/list.js +2 -2
- package/dist/vocabulary/list.js.map +1 -1
- package/dist/vocabulary/text.d.ts +1 -1
- package/package.json +8 -5
- package/src/JSONGenerativeUI.client.tsx +84 -40
- package/src/JSONGenerativeUI.test.tsx +964 -68
- package/src/RadioGroupScope.server.test.tsx +24 -0
- package/src/RadioGroupScope.tsx +34 -0
- package/src/a2ui/BindingContext.ts +26 -0
- package/src/a2ui/PresentRenderer.tsx +83 -0
- package/src/a2ui/convert.test.ts +2054 -229
- package/src/a2ui/convert.ts +665 -134
- package/src/a2ui/dataModel.ts +69 -0
- package/src/a2ui/reducer.test.ts +35 -0
- package/src/a2ui/reducer.ts +5 -4
- package/src/a2ui/types.ts +9 -2
- package/src/a2ui/valueFunctions.test.ts +271 -0
- package/src/a2ui/valueFunctions.ts +523 -0
- package/src/actionRegistry.ts +1 -1
- package/src/answeredValues.test.ts +33 -0
- package/src/answeredValues.tsx +70 -0
- package/src/constants.ts +5 -0
- package/src/fieldReferences.test.ts +66 -0
- package/src/fieldReferences.ts +83 -0
- package/src/generativeUIToJSX.test.ts +18 -0
- package/src/generativeUIToJSX.ts +4 -6
- package/src/index.server.test.ts +106 -0
- package/src/ir.ts +1 -1
- package/src/renderGenerativeUI.test.tsx +14 -5
- package/src/renderGenerativeUI.tsx +30 -1
- package/src/slack/a2uiSlack.test.ts +198 -0
- package/src/slack/constants.ts +3 -0
- package/src/slack/datePicker.test.ts +612 -0
- package/src/slack/decodeBlockAction.test.ts +98 -0
- package/src/slack/decodeBlockAction.ts +182 -16
- package/src/slack/fromSlackBlocks.test.ts +222 -3
- package/src/slack/fromSlackBlocks.ts +82 -2
- package/src/slack/toSlackBlocks.test.ts +682 -3
- package/src/slack/toSlackBlocks.ts +463 -25
- package/src/slack/types.ts +28 -0
- package/src/slack.ts +2 -0
- package/src/teams/constants.ts +1 -1
- package/src/teams/decodeSubmitData.test.ts +249 -0
- package/src/teams/decodeSubmitData.ts +57 -4
- package/src/teams/temporal.test.ts +766 -0
- package/src/teams/temporalId.ts +56 -0
- package/src/teams/toAdaptiveCard.test.ts +219 -0
- package/src/teams/toAdaptiveCard.ts +259 -21
- package/src/teams/toTeamsAttachments.ts +4 -1
- package/src/teams/types.ts +21 -1
- package/src/teams.ts +1 -0
- package/src/temporal.test.ts +319 -0
- package/src/temporal.ts +259 -0
- package/src/vocabulary/alert.test.tsx +288 -7
- package/src/vocabulary/alert.tsx +168 -26
- package/src/vocabulary/collectFormValues.test.ts +225 -1
- package/src/vocabulary/collectFormValues.ts +54 -5
- package/src/vocabulary/data.test.tsx +248 -6
- package/src/vocabulary/data.tsx +398 -100
- package/src/vocabulary/datepicker.dom.test.tsx +1148 -0
- package/src/vocabulary/dispatch.ts +63 -2
- package/src/vocabulary/fact.test.tsx +67 -0
- package/src/vocabulary/fact.tsx +40 -9
- package/src/vocabulary/form.tsx +7 -2
- package/src/vocabulary/formatValue.test.ts +72 -0
- package/src/vocabulary/formatValue.ts +127 -0
- package/src/vocabulary/index.test.ts +2 -0
- package/src/vocabulary/interactive.dispatch.test.tsx +167 -79
- package/src/vocabulary/interactive.dom.test.tsx +1747 -0
- package/src/vocabulary/interactive.test.tsx +60 -4
- package/src/vocabulary/interactive.tsx +910 -155
- package/src/vocabulary/layout.test.tsx +6 -4
- package/src/vocabulary/layout.tsx +13 -2
- package/src/vocabulary/list.tsx +2 -2
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { copyBounded } from "../convert/copyBounded";
|
|
2
2
|
import type { Action, UIElement } from "../ir";
|
|
3
|
+
import { formatTemporalUnixSeconds } from "../temporal";
|
|
3
4
|
import {
|
|
4
5
|
ACTIONS_ELEMENT_CAP,
|
|
5
6
|
CARD_ACTIONS_CAP,
|
|
6
7
|
CAROUSEL_CARD_CAP,
|
|
8
|
+
CHECKBOX_OPTION_CAP,
|
|
7
9
|
CONTEXT_ELEMENT_CAP,
|
|
8
10
|
DATA_TABLE_COLUMN_CAP,
|
|
9
11
|
DATA_TABLE_ROW_CAP,
|
|
@@ -212,10 +214,20 @@ const selectFrom = (
|
|
|
212
214
|
"Select",
|
|
213
215
|
`options were clamped to ${SELECT_OPTION_CAP} entries.`,
|
|
214
216
|
);
|
|
217
|
+
const convertedOptions = options.map(optionFrom).filter(isDefined);
|
|
218
|
+
const initialOption = element["initial_option"];
|
|
219
|
+
const defaultValue =
|
|
220
|
+
isRecord(initialOption) && typeof initialOption["value"] === "string"
|
|
221
|
+
? initialOption["value"]
|
|
222
|
+
: undefined;
|
|
215
223
|
const placeholder = element["placeholder"];
|
|
216
224
|
return {
|
|
217
225
|
$type: "Select",
|
|
218
|
-
options:
|
|
226
|
+
options: convertedOptions,
|
|
227
|
+
...(defaultValue !== undefined &&
|
|
228
|
+
convertedOptions.some((option) => option.value === defaultValue)
|
|
229
|
+
? { defaultValue }
|
|
230
|
+
: {}),
|
|
219
231
|
...(isRecord(placeholder) ? { placeholder: textOf(placeholder) } : {}),
|
|
220
232
|
$action: decodeAction(element["action_id"], element["value"]),
|
|
221
233
|
};
|
|
@@ -250,6 +262,40 @@ const checkboxFrom = (element: Record<string, unknown>): UIElement => {
|
|
|
250
262
|
};
|
|
251
263
|
};
|
|
252
264
|
|
|
265
|
+
const checkboxGroupFrom = (
|
|
266
|
+
element: Record<string, unknown>,
|
|
267
|
+
warnings: SlackConversionWarning[],
|
|
268
|
+
): UIElement => {
|
|
269
|
+
const options = boundedArray(
|
|
270
|
+
element["options"],
|
|
271
|
+
CHECKBOX_OPTION_CAP,
|
|
272
|
+
warnings,
|
|
273
|
+
"CheckboxGroup",
|
|
274
|
+
`options were clamped to ${CHECKBOX_OPTION_CAP} entries.`,
|
|
275
|
+
)
|
|
276
|
+
.map(optionFrom)
|
|
277
|
+
.filter(isDefined);
|
|
278
|
+
const defaultValue = clampArray(
|
|
279
|
+
element["initial_options"],
|
|
280
|
+
CHECKBOX_OPTION_CAP,
|
|
281
|
+
).items.flatMap((initialOption) => {
|
|
282
|
+
const value =
|
|
283
|
+
isRecord(initialOption) && typeof initialOption["value"] === "string"
|
|
284
|
+
? initialOption["value"]
|
|
285
|
+
: undefined;
|
|
286
|
+
return value !== undefined &&
|
|
287
|
+
options.some((option) => option.value === value)
|
|
288
|
+
? [value]
|
|
289
|
+
: [];
|
|
290
|
+
});
|
|
291
|
+
return {
|
|
292
|
+
$type: "CheckboxGroup",
|
|
293
|
+
options,
|
|
294
|
+
...(defaultValue.length > 0 ? { defaultValue } : {}),
|
|
295
|
+
$action: decodeAction(element["action_id"], element["value"]),
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
|
|
253
299
|
const radioGroupFrom = (
|
|
254
300
|
element: Record<string, unknown>,
|
|
255
301
|
warnings: SlackConversionWarning[],
|
|
@@ -286,8 +332,32 @@ const actionElementFrom = (
|
|
|
286
332
|
return selectFrom(element, warnings);
|
|
287
333
|
case "datepicker":
|
|
288
334
|
return datePickerFrom(element);
|
|
335
|
+
case "timepicker":
|
|
336
|
+
return {
|
|
337
|
+
$type: "DatePicker",
|
|
338
|
+
inputType: "time",
|
|
339
|
+
...(typeof element["initial_time"] === "string"
|
|
340
|
+
? { value: element["initial_time"] }
|
|
341
|
+
: {}),
|
|
342
|
+
$action: decodeAction(element["action_id"], element["value"]),
|
|
343
|
+
};
|
|
344
|
+
case "datetimepicker": {
|
|
345
|
+
const value =
|
|
346
|
+
typeof element["initial_date_time"] === "number"
|
|
347
|
+
? formatTemporalUnixSeconds(element["initial_date_time"])
|
|
348
|
+
: undefined;
|
|
349
|
+
return {
|
|
350
|
+
$type: "DatePicker",
|
|
351
|
+
inputType: "datetime",
|
|
352
|
+
...(value !== undefined ? { value } : {}),
|
|
353
|
+
$action: decodeAction(element["action_id"], element["value"]),
|
|
354
|
+
};
|
|
355
|
+
}
|
|
289
356
|
case "checkboxes":
|
|
290
|
-
return
|
|
357
|
+
return Array.isArray(element["options"]) &&
|
|
358
|
+
element["options"].length > 1
|
|
359
|
+
? checkboxGroupFrom(element, warnings)
|
|
360
|
+
: checkboxFrom(element);
|
|
291
361
|
case "radio_buttons":
|
|
292
362
|
return radioGroupFrom(element, warnings);
|
|
293
363
|
}
|
|
@@ -324,6 +394,13 @@ const inputFrom = (
|
|
|
324
394
|
warnings: SlackConversionWarning[],
|
|
325
395
|
): UIElement[] => {
|
|
326
396
|
const element = block["element"];
|
|
397
|
+
if (
|
|
398
|
+
isRecord(element) &&
|
|
399
|
+
(element["type"] === "timepicker" || element["type"] === "datetimepicker")
|
|
400
|
+
) {
|
|
401
|
+
const picker = actionElementFrom(element, warnings);
|
|
402
|
+
return picker ? [{ ...picker, label: textOf(block["label"]) }] : [];
|
|
403
|
+
}
|
|
327
404
|
if (!isRecord(element) || element["type"] !== "plain_text_input") {
|
|
328
405
|
warn(
|
|
329
406
|
warnings,
|
|
@@ -340,6 +417,9 @@ const inputFrom = (
|
|
|
340
417
|
label: textOf(block["label"]),
|
|
341
418
|
...(isRecord(placeholder) ? { placeholder: textOf(placeholder) } : {}),
|
|
342
419
|
...(element["multiline"] === true ? { multiline: true } : {}),
|
|
420
|
+
...(typeof element["initial_value"] === "string"
|
|
421
|
+
? { defaultValue: element["initial_value"] }
|
|
422
|
+
: {}),
|
|
343
423
|
$action: decodeAction(element["action_id"], undefined),
|
|
344
424
|
},
|
|
345
425
|
];
|