@assistant-ui/react-generative-ui 0.0.24 → 0.1.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/README.md +2 -0
- package/dist/a2ui.d.ts +1 -4
- package/dist/a2ui.d.ts.map +1 -1
- package/dist/a2ui.js +1 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -10
- package/dist/index.server.d.ts +1 -2
- package/dist/index.server.d.ts.map +1 -1
- package/dist/index.server.js +1 -10
- package/dist/ir.d.ts +1 -111
- package/dist/ir.d.ts.map +1 -1
- package/dist/ir.js +1 -175
- package/dist/slack.d.ts +1 -4
- package/dist/slack.d.ts.map +1 -1
- package/dist/slack.js +1 -4
- package/dist/teams.d.ts +1 -4
- package/dist/teams.d.ts.map +1 -1
- package/dist/teams.js +1 -4
- package/package.json +4 -5
- package/src/a2ui.ts +1 -22
- package/src/index.server.ts +1 -2
- package/src/index.test.ts +75 -0
- package/src/index.ts +1 -2
- package/src/ir.ts +1 -279
- package/src/slack.ts +1 -39
- package/src/teams.ts +1 -35
- package/dist/JSONGenerativeUI.client.d.ts +0 -28
- package/dist/JSONGenerativeUI.client.d.ts.map +0 -1
- package/dist/JSONGenerativeUI.client.js +0 -101
- package/dist/JSONGenerativeUI.client.js.map +0 -1
- package/dist/JSONGenerativeUI.server.d.ts +0 -21
- package/dist/JSONGenerativeUI.server.d.ts.map +0 -1
- package/dist/JSONGenerativeUI.server.js +0 -32
- package/dist/JSONGenerativeUI.server.js.map +0 -1
- package/dist/JSONGenerativeUI.shared.d.ts +0 -63
- package/dist/JSONGenerativeUI.shared.d.ts.map +0 -1
- package/dist/JSONGenerativeUI.shared.js +0 -31
- package/dist/JSONGenerativeUI.shared.js.map +0 -1
- package/dist/RadioGroupScope.d.ts +0 -6
- package/dist/RadioGroupScope.d.ts.map +0 -1
- package/dist/RadioGroupScope.js +0 -25
- package/dist/RadioGroupScope.js.map +0 -1
- package/dist/a2ui/BindingContext.d.ts +0 -11
- package/dist/a2ui/BindingContext.d.ts.map +0 -1
- package/dist/a2ui/BindingContext.js +0 -12
- package/dist/a2ui/BindingContext.js.map +0 -1
- package/dist/a2ui/PresentRenderer.d.ts +0 -11
- package/dist/a2ui/PresentRenderer.d.ts.map +0 -1
- package/dist/a2ui/PresentRenderer.js +0 -39
- package/dist/a2ui/PresentRenderer.js.map +0 -1
- package/dist/a2ui/convert.d.ts +0 -15
- package/dist/a2ui/convert.d.ts.map +0 -1
- package/dist/a2ui/convert.js +0 -728
- package/dist/a2ui/convert.js.map +0 -1
- package/dist/a2ui/dataModel.d.ts +0 -9
- package/dist/a2ui/dataModel.d.ts.map +0 -1
- package/dist/a2ui/dataModel.js +0 -44
- package/dist/a2ui/dataModel.js.map +0 -1
- package/dist/a2ui/reducer.d.ts +0 -8
- package/dist/a2ui/reducer.d.ts.map +0 -1
- package/dist/a2ui/reducer.js +0 -242
- package/dist/a2ui/reducer.js.map +0 -1
- package/dist/a2ui/snapshot.d.ts +0 -3
- package/dist/a2ui/snapshot.d.ts.map +0 -1
- package/dist/a2ui/snapshot.js +0 -33
- package/dist/a2ui/snapshot.js.map +0 -1
- package/dist/a2ui/types.d.ts +0 -88
- package/dist/a2ui/types.d.ts.map +0 -1
- package/dist/a2ui/types.js +0 -6
- package/dist/a2ui/types.js.map +0 -1
- package/dist/a2ui/valueFunctions.d.ts +0 -16
- package/dist/a2ui/valueFunctions.d.ts.map +0 -1
- package/dist/a2ui/valueFunctions.js +0 -332
- package/dist/a2ui/valueFunctions.js.map +0 -1
- package/dist/actionRegistry.d.ts +0 -29
- package/dist/actionRegistry.d.ts.map +0 -1
- package/dist/actionRegistry.js +0 -41
- package/dist/actionRegistry.js.map +0 -1
- package/dist/answeredValues.d.ts +0 -16
- package/dist/answeredValues.d.ts.map +0 -1
- package/dist/answeredValues.js +0 -37
- package/dist/answeredValues.js.map +0 -1
- package/dist/buildPresentParameters.d.ts +0 -21
- package/dist/buildPresentParameters.d.ts.map +0 -1
- package/dist/buildPresentParameters.js +0 -95
- package/dist/buildPresentParameters.js.map +0 -1
- package/dist/constants.d.ts +0 -15
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -19
- package/dist/constants.js.map +0 -1
- package/dist/convert/boundSpec.d.ts +0 -48
- package/dist/convert/boundSpec.d.ts.map +0 -1
- package/dist/convert/boundSpec.js +0 -108
- package/dist/convert/boundSpec.js.map +0 -1
- package/dist/convert/copyBounded.d.ts +0 -25
- package/dist/convert/copyBounded.d.ts.map +0 -1
- package/dist/convert/copyBounded.js +0 -38
- package/dist/convert/copyBounded.js.map +0 -1
- package/dist/convert/isElement.d.ts +0 -3
- package/dist/convert/isElement.d.ts.map +0 -1
- package/dist/convert/isElement.js +0 -6
- package/dist/convert/isElement.js.map +0 -1
- package/dist/convert/takeRun.d.ts +0 -6
- package/dist/convert/takeRun.d.ts.map +0 -1
- package/dist/convert/takeRun.js +0 -20
- package/dist/convert/takeRun.js.map +0 -1
- package/dist/defineGenerativeComponents.d.ts +0 -29
- package/dist/defineGenerativeComponents.d.ts.map +0 -1
- package/dist/defineGenerativeComponents.js +0 -34
- package/dist/defineGenerativeComponents.js.map +0 -1
- package/dist/fieldReferences.d.ts +0 -9
- package/dist/fieldReferences.d.ts.map +0 -1
- package/dist/fieldReferences.js +0 -53
- package/dist/fieldReferences.js.map +0 -1
- package/dist/generativeUIToJSX.d.ts +0 -18
- package/dist/generativeUIToJSX.d.ts.map +0 -1
- package/dist/generativeUIToJSX.js +0 -76
- package/dist/generativeUIToJSX.js.map +0 -1
- package/dist/index.shared.d.ts +0 -15
- package/dist/index.shared.d.ts.map +0 -1
- package/dist/index.shared.js +0 -9
- package/dist/ir.js.map +0 -1
- package/dist/renderGenerativeUI.d.ts +0 -14
- package/dist/renderGenerativeUI.d.ts.map +0 -1
- package/dist/renderGenerativeUI.js +0 -83
- package/dist/renderGenerativeUI.js.map +0 -1
- package/dist/scopeSchema.d.ts +0 -6
- package/dist/scopeSchema.d.ts.map +0 -1
- package/dist/scopeSchema.js +0 -56
- package/dist/scopeSchema.js.map +0 -1
- package/dist/slack/constants.d.ts +0 -93
- package/dist/slack/constants.d.ts.map +0 -1
- package/dist/slack/constants.js +0 -146
- package/dist/slack/constants.js.map +0 -1
- package/dist/slack/decodeBlockAction.d.ts +0 -10
- package/dist/slack/decodeBlockAction.d.ts.map +0 -1
- package/dist/slack/decodeBlockAction.js +0 -129
- package/dist/slack/decodeBlockAction.js.map +0 -1
- package/dist/slack/fromSlackBlocks.d.ts +0 -27
- package/dist/slack/fromSlackBlocks.d.ts.map +0 -1
- package/dist/slack/fromSlackBlocks.js +0 -483
- package/dist/slack/fromSlackBlocks.js.map +0 -1
- package/dist/slack/toSlackBlocks.d.ts +0 -4
- package/dist/slack/toSlackBlocks.d.ts.map +0 -1
- package/dist/slack/toSlackBlocks.js +0 -901
- package/dist/slack/toSlackBlocks.js.map +0 -1
- package/dist/slack/types.d.ts +0 -204
- package/dist/slack/types.d.ts.map +0 -1
- package/dist/slack/types.js +0 -0
- package/dist/teams/constants.d.ts +0 -34
- package/dist/teams/constants.d.ts.map +0 -1
- package/dist/teams/constants.js +0 -68
- package/dist/teams/constants.js.map +0 -1
- package/dist/teams/decodeSubmitData.d.ts +0 -26
- package/dist/teams/decodeSubmitData.d.ts.map +0 -1
- package/dist/teams/decodeSubmitData.js +0 -70
- package/dist/teams/decodeSubmitData.js.map +0 -1
- package/dist/teams/temporalId.d.ts +0 -5
- package/dist/teams/temporalId.d.ts.map +0 -1
- package/dist/teams/temporalId.js +0 -28
- package/dist/teams/temporalId.js.map +0 -1
- package/dist/teams/toAdaptiveCard.d.ts +0 -45
- package/dist/teams/toAdaptiveCard.d.ts.map +0 -1
- package/dist/teams/toAdaptiveCard.js +0 -642
- package/dist/teams/toAdaptiveCard.js.map +0 -1
- package/dist/teams/toTeamsAttachments.d.ts +0 -10
- package/dist/teams/toTeamsAttachments.d.ts.map +0 -1
- package/dist/teams/toTeamsAttachments.js +0 -99
- package/dist/teams/toTeamsAttachments.js.map +0 -1
- package/dist/teams/types.d.ts +0 -224
- package/dist/teams/types.d.ts.map +0 -1
- package/dist/teams/types.js +0 -0
- package/dist/temporal.d.ts +0 -33
- package/dist/temporal.d.ts.map +0 -1
- package/dist/temporal.js +0 -153
- package/dist/temporal.js.map +0 -1
- package/dist/types.d.ts +0 -99
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -0
- package/dist/vocabulary/alert.d.ts +0 -32
- package/dist/vocabulary/alert.d.ts.map +0 -1
- package/dist/vocabulary/alert.js +0 -160
- package/dist/vocabulary/alert.js.map +0 -1
- package/dist/vocabulary/collectFormValues.d.ts +0 -23
- package/dist/vocabulary/collectFormValues.d.ts.map +0 -1
- package/dist/vocabulary/collectFormValues.js +0 -44
- package/dist/vocabulary/collectFormValues.js.map +0 -1
- package/dist/vocabulary/data.d.ts +0 -66
- package/dist/vocabulary/data.d.ts.map +0 -1
- package/dist/vocabulary/data.js +0 -503
- package/dist/vocabulary/data.js.map +0 -1
- package/dist/vocabulary/dispatch.d.ts +0 -9
- package/dist/vocabulary/dispatch.d.ts.map +0 -1
- package/dist/vocabulary/dispatch.js +0 -50
- package/dist/vocabulary/dispatch.js.map +0 -1
- package/dist/vocabulary/fact.d.ts +0 -19
- package/dist/vocabulary/fact.d.ts.map +0 -1
- package/dist/vocabulary/fact.js +0 -51
- package/dist/vocabulary/fact.js.map +0 -1
- package/dist/vocabulary/form.d.ts +0 -11
- package/dist/vocabulary/form.d.ts.map +0 -1
- package/dist/vocabulary/form.js +0 -23
- package/dist/vocabulary/form.js.map +0 -1
- package/dist/vocabulary/formatValue.d.ts +0 -7
- package/dist/vocabulary/formatValue.d.ts.map +0 -1
- package/dist/vocabulary/formatValue.js +0 -76
- package/dist/vocabulary/formatValue.js.map +0 -1
- package/dist/vocabulary/icon.d.ts +0 -41
- package/dist/vocabulary/icon.d.ts.map +0 -1
- package/dist/vocabulary/icon.js +0 -272
- package/dist/vocabulary/icon.js.map +0 -1
- package/dist/vocabulary/index.d.ts +0 -12
- package/dist/vocabulary/index.d.ts.map +0 -1
- package/dist/vocabulary/index.js +0 -36
- package/dist/vocabulary/index.js.map +0 -1
- package/dist/vocabulary/interactive.d.ts +0 -230
- package/dist/vocabulary/interactive.d.ts.map +0 -1
- package/dist/vocabulary/interactive.js +0 -584
- package/dist/vocabulary/interactive.js.map +0 -1
- package/dist/vocabulary/layout.d.ts +0 -79
- package/dist/vocabulary/layout.d.ts.map +0 -1
- package/dist/vocabulary/layout.js +0 -139
- package/dist/vocabulary/layout.js.map +0 -1
- package/dist/vocabulary/list.d.ts +0 -14
- package/dist/vocabulary/list.d.ts.map +0 -1
- package/dist/vocabulary/list.js +0 -50
- package/dist/vocabulary/list.js.map +0 -1
- package/dist/vocabulary/media.d.ts +0 -25
- package/dist/vocabulary/media.d.ts.map +0 -1
- package/dist/vocabulary/media.js +0 -42
- package/dist/vocabulary/media.js.map +0 -1
- package/dist/vocabulary/text.d.ts +0 -57
- package/dist/vocabulary/text.d.ts.map +0 -1
- package/dist/vocabulary/text.js +0 -49
- package/dist/vocabulary/text.js.map +0 -1
- package/dist/vocabulary/toTextContent.d.ts +0 -2
- package/dist/vocabulary/toTextContent.d.ts.map +0 -1
- package/dist/vocabulary/toTextContent.js +0 -6
- package/dist/vocabulary/toTextContent.js.map +0 -1
- package/src/JSONGenerativeUI.client.tsx +0 -168
- package/src/JSONGenerativeUI.server.tsx +0 -39
- package/src/JSONGenerativeUI.shared.ts +0 -90
- package/src/JSONGenerativeUI.test.tsx +0 -1298
- package/src/RadioGroupScope.server.test.tsx +0 -24
- package/src/RadioGroupScope.tsx +0 -34
- package/src/a2ui/BindingContext.ts +0 -26
- package/src/a2ui/PresentRenderer.tsx +0 -83
- package/src/a2ui/convert.test.ts +0 -2923
- package/src/a2ui/convert.ts +0 -1207
- package/src/a2ui/dataModel.ts +0 -69
- package/src/a2ui/reducer.test.ts +0 -422
- package/src/a2ui/reducer.ts +0 -363
- package/src/a2ui/snapshot.test.ts +0 -52
- package/src/a2ui/snapshot.ts +0 -52
- package/src/a2ui/types.ts +0 -114
- package/src/a2ui/valueFunctions.test.ts +0 -271
- package/src/a2ui/valueFunctions.ts +0 -523
- package/src/actionRegistry.test.ts +0 -90
- package/src/actionRegistry.ts +0 -88
- package/src/answeredValues.test.ts +0 -33
- package/src/answeredValues.tsx +0 -70
- package/src/buildPresentParameters.test.ts +0 -246
- package/src/buildPresentParameters.ts +0 -130
- package/src/constants.ts +0 -17
- package/src/convert/boundSpec.test.ts +0 -192
- package/src/convert/boundSpec.ts +0 -134
- package/src/convert/copyBounded.test.ts +0 -131
- package/src/convert/copyBounded.ts +0 -38
- package/src/convert/isElement.ts +0 -6
- package/src/convert/takeRun.test.ts +0 -64
- package/src/convert/takeRun.ts +0 -19
- package/src/defineGenerativeComponents.ts +0 -38
- package/src/fieldReferences.test.ts +0 -66
- package/src/fieldReferences.ts +0 -83
- package/src/generativeUIToJSX.test.ts +0 -268
- package/src/generativeUIToJSX.ts +0 -152
- package/src/index.server.test.ts +0 -106
- package/src/index.shared.ts +0 -61
- package/src/ir.test.ts +0 -203
- package/src/renderGenerativeUI.test.tsx +0 -373
- package/src/renderGenerativeUI.tsx +0 -165
- package/src/scopeSchema.test.ts +0 -72
- package/src/scopeSchema.ts +0 -71
- package/src/slack/a2uiSlack.test.ts +0 -198
- package/src/slack/constants.ts +0 -194
- package/src/slack/datePicker.test.ts +0 -612
- package/src/slack/decodeBlockAction.test.ts +0 -233
- package/src/slack/decodeBlockAction.ts +0 -232
- package/src/slack/fromSlackBlocks.test.ts +0 -1465
- package/src/slack/fromSlackBlocks.ts +0 -789
- package/src/slack/toSlackBlocks.test.ts +0 -3065
- package/src/slack/toSlackBlocks.ts +0 -1818
- package/src/slack/types.ts +0 -264
- package/src/teams/constants.ts +0 -93
- package/src/teams/decodeSubmitData.test.ts +0 -397
- package/src/teams/decodeSubmitData.ts +0 -110
- package/src/teams/temporal.test.ts +0 -766
- package/src/teams/temporalId.ts +0 -56
- package/src/teams/toAdaptiveCard.test.ts +0 -1897
- package/src/teams/toAdaptiveCard.ts +0 -1057
- package/src/teams/toTeamsAttachments.test.ts +0 -74
- package/src/teams/toTeamsAttachments.ts +0 -133
- package/src/teams/types.ts +0 -266
- package/src/temporal.test.ts +0 -337
- package/src/temporal.ts +0 -263
- package/src/types.ts +0 -119
- package/src/vocabulary/alert.test.tsx +0 -427
- package/src/vocabulary/alert.tsx +0 -217
- package/src/vocabulary/collectFormValues.test.ts +0 -389
- package/src/vocabulary/collectFormValues.ts +0 -116
- package/src/vocabulary/data.test.tsx +0 -858
- package/src/vocabulary/data.tsx +0 -819
- package/src/vocabulary/datepicker.dom.test.tsx +0 -1457
- package/src/vocabulary/dispatch.ts +0 -83
- package/src/vocabulary/fact.test.tsx +0 -94
- package/src/vocabulary/fact.tsx +0 -54
- package/src/vocabulary/form.test.tsx +0 -113
- package/src/vocabulary/form.tsx +0 -39
- package/src/vocabulary/formatValue.test.ts +0 -72
- package/src/vocabulary/formatValue.ts +0 -127
- package/src/vocabulary/icon.test.tsx +0 -64
- package/src/vocabulary/icon.tsx +0 -174
- package/src/vocabulary/index.test.ts +0 -65
- package/src/vocabulary/index.ts +0 -33
- package/src/vocabulary/interactive.dispatch.test.tsx +0 -454
- package/src/vocabulary/interactive.dom.test.tsx +0 -1747
- package/src/vocabulary/interactive.test.tsx +0 -377
- package/src/vocabulary/interactive.tsx +0 -1109
- package/src/vocabulary/layout.test.tsx +0 -323
- package/src/vocabulary/layout.tsx +0 -247
- package/src/vocabulary/list.test.tsx +0 -222
- package/src/vocabulary/list.tsx +0 -50
- package/src/vocabulary/media.test.tsx +0 -85
- package/src/vocabulary/media.tsx +0 -56
- package/src/vocabulary/text.test.tsx +0 -102
- package/src/vocabulary/text.tsx +0 -60
- package/src/vocabulary/toTextContent.ts +0 -2
|
@@ -1,584 +0,0 @@
|
|
|
1
|
-
import { useRadioGroupName } from "../RadioGroupScope.js";
|
|
2
|
-
import { CHECKBOX_GROUP_ATTR, FIELD_NAME_ATTR, FIELD_VALUE_ATTR, GENERATED_NAME_ATTR } from "../constants.js";
|
|
3
|
-
import { BUTTON_STYLES } from "../ir.js";
|
|
4
|
-
import { A2uiBindingContext, useA2uiBinding } from "../a2ui/BindingContext.js";
|
|
5
|
-
import { classifyTemporal, fromLocalDateTime, getTemporalInputStep, normalizeTemporalInputValue, toLocalDateTime, toPickerLocalDateTime } from "../temporal.js";
|
|
6
|
-
import { useAnsweredValue } from "../answeredValues.js";
|
|
7
|
-
import { toTextContent } from "./toTextContent.js";
|
|
8
|
-
import { actionAttr, fire } from "./dispatch.js";
|
|
9
|
-
import * as React from "react";
|
|
10
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
//#region src/vocabulary/interactive.tsx
|
|
13
|
-
const optionSchema = z.object({
|
|
14
|
-
label: z.string(),
|
|
15
|
-
value: z.string()
|
|
16
|
-
});
|
|
17
|
-
const describedOptionSchema = optionSchema.extend({ description: z.string().optional() });
|
|
18
|
-
const isOption = (option) => option !== null && typeof option === "object" && "label" in option && typeof option.label === "string" && (!("description" in option) || typeof option.description === "string") && "value" in option && typeof option.value === "string";
|
|
19
|
-
const mapOptions = (options, render) => {
|
|
20
|
-
const occurrences = /* @__PURE__ */ new Map();
|
|
21
|
-
return (Array.isArray(options) ? options : []).map((option) => {
|
|
22
|
-
if (!isOption(option)) return null;
|
|
23
|
-
const occurrence = occurrences.get(option.value) ?? 0;
|
|
24
|
-
occurrences.set(option.value, occurrence + 1);
|
|
25
|
-
return render(option, JSON.stringify([option.value, occurrence]));
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
function RadioGroupRender({ value, options, name, label, defaultValue, children, $action, $dispatch }) {
|
|
29
|
-
const groupName = useRadioGroupName(name);
|
|
30
|
-
const answeredValue = useAnsweredValue(name);
|
|
31
|
-
const updateBinding = useA2uiBinding(name);
|
|
32
|
-
const isBound = updateBinding !== void 0;
|
|
33
|
-
const initialValue = typeof answeredValue === "string" ? answeredValue : defaultValue;
|
|
34
|
-
return /* @__PURE__ */ jsxs("fieldset", {
|
|
35
|
-
"data-aui": "radiogroup",
|
|
36
|
-
"data-aui-action": actionAttr($action),
|
|
37
|
-
"aria-label": label,
|
|
38
|
-
children: [mapOptions(options, (option, key) => /* @__PURE__ */ jsxs("label", {
|
|
39
|
-
"data-aui": "radiogroup-option",
|
|
40
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
41
|
-
type: "radio",
|
|
42
|
-
name: groupName,
|
|
43
|
-
[FIELD_NAME_ATTR]: name,
|
|
44
|
-
...name == null ? { [GENERATED_NAME_ATTR]: "" } : {},
|
|
45
|
-
value: option.value,
|
|
46
|
-
...isBound ? { checked: (answeredValue ?? value) === option.value } : { defaultChecked: initialValue === option.value },
|
|
47
|
-
onChange: (e) => {
|
|
48
|
-
updateBinding?.(option.value);
|
|
49
|
-
fire($action, $dispatch, option.value, e.currentTarget);
|
|
50
|
-
}
|
|
51
|
-
}), option.description ? /* @__PURE__ */ jsxs("span", {
|
|
52
|
-
"data-aui": "option-content",
|
|
53
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
54
|
-
"data-aui": "option-label",
|
|
55
|
-
children: option.label
|
|
56
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
57
|
-
"data-aui": "option-description",
|
|
58
|
-
children: option.description
|
|
59
|
-
})]
|
|
60
|
-
}) : option.label]
|
|
61
|
-
}, key)), children]
|
|
62
|
-
}, initialValue);
|
|
63
|
-
}
|
|
64
|
-
const checkedGroupValues = (input) => Array.from(input.closest("fieldset")?.querySelectorAll(`:scope > label > input[data-aui-checkbox-group]:checked`) ?? [], (checkbox) => checkbox.value);
|
|
65
|
-
function CheckboxGroupRender({ value, options, name, label, defaultValue, children, $action, $dispatch }) {
|
|
66
|
-
const generatedName = React.useId();
|
|
67
|
-
const fieldName = name ?? generatedName;
|
|
68
|
-
const answeredValue = useAnsweredValue(name);
|
|
69
|
-
const updateBinding = useA2uiBinding(name);
|
|
70
|
-
const isBound = updateBinding !== void 0;
|
|
71
|
-
const checkedValues = Array.isArray(answeredValue) && answeredValue.every((value) => typeof value === "string") ? answeredValue : Array.isArray(defaultValue) ? defaultValue : [];
|
|
72
|
-
return /* @__PURE__ */ jsxs("fieldset", {
|
|
73
|
-
"data-aui": "checkboxgroup",
|
|
74
|
-
"data-aui-action": actionAttr($action),
|
|
75
|
-
"aria-label": label,
|
|
76
|
-
children: [mapOptions(options, (option, key) => /* @__PURE__ */ jsxs("label", {
|
|
77
|
-
"data-aui": "checkboxgroup-option",
|
|
78
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
79
|
-
type: "checkbox",
|
|
80
|
-
name: fieldName,
|
|
81
|
-
[CHECKBOX_GROUP_ATTR]: "",
|
|
82
|
-
...name == null ? { [GENERATED_NAME_ATTR]: "" } : {},
|
|
83
|
-
value: option.value,
|
|
84
|
-
...isBound ? { checked: (Array.isArray(answeredValue) ? checkedValues : value ?? []).includes(option.value) } : { defaultChecked: checkedValues.includes(option.value) },
|
|
85
|
-
onChange: (e) => {
|
|
86
|
-
const selected = checkedGroupValues(e.currentTarget);
|
|
87
|
-
updateBinding?.(selected);
|
|
88
|
-
fire($action, $dispatch, selected, e.currentTarget);
|
|
89
|
-
}
|
|
90
|
-
}), option.description ? /* @__PURE__ */ jsxs("span", {
|
|
91
|
-
"data-aui": "option-content",
|
|
92
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
93
|
-
"data-aui": "option-label",
|
|
94
|
-
children: option.label
|
|
95
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
96
|
-
"data-aui": "option-description",
|
|
97
|
-
children: option.description
|
|
98
|
-
})]
|
|
99
|
-
}) : option.label]
|
|
100
|
-
}, key)), children]
|
|
101
|
-
}, JSON.stringify(checkedValues));
|
|
102
|
-
}
|
|
103
|
-
function SelectRender({ value, options, placeholder, label, name, defaultValue, $action, $dispatch, children }) {
|
|
104
|
-
const answeredValue = useAnsweredValue(name);
|
|
105
|
-
const updateBinding = useA2uiBinding(name);
|
|
106
|
-
const isBound = updateBinding !== void 0;
|
|
107
|
-
const placeholderText = toTextContent(placeholder);
|
|
108
|
-
const initialValue = typeof answeredValue === "string" ? answeredValue : typeof defaultValue === "string" ? defaultValue : "";
|
|
109
|
-
return /* @__PURE__ */ jsxs("select", {
|
|
110
|
-
"data-aui": "select",
|
|
111
|
-
"data-aui-action": actionAttr($action),
|
|
112
|
-
name,
|
|
113
|
-
"aria-label": label,
|
|
114
|
-
...isBound ? { value: typeof answeredValue === "string" ? answeredValue : value ?? "" } : { defaultValue: initialValue },
|
|
115
|
-
onChange: (e) => {
|
|
116
|
-
updateBinding?.(e.currentTarget.value);
|
|
117
|
-
fire($action, $dispatch, e.currentTarget.value, e.currentTarget);
|
|
118
|
-
},
|
|
119
|
-
children: [
|
|
120
|
-
placeholderText ? /* @__PURE__ */ jsx("option", {
|
|
121
|
-
value: "",
|
|
122
|
-
disabled: true,
|
|
123
|
-
children: placeholderText
|
|
124
|
-
}) : null,
|
|
125
|
-
mapOptions(options, (option, key) => /* @__PURE__ */ jsx("option", {
|
|
126
|
-
value: option.value,
|
|
127
|
-
children: option.label
|
|
128
|
-
}, key)),
|
|
129
|
-
children
|
|
130
|
-
]
|
|
131
|
-
}, initialValue);
|
|
132
|
-
}
|
|
133
|
-
function InputRender({ value, inputType, placeholder, multiline, label, name, defaultValue, $action, $dispatch }) {
|
|
134
|
-
const answeredValue = useAnsweredValue(name);
|
|
135
|
-
const updateBinding = useA2uiBinding(name);
|
|
136
|
-
const isBound = updateBinding !== void 0;
|
|
137
|
-
const initialValue = typeof answeredValue === "string" ? answeredValue : defaultValue;
|
|
138
|
-
const submit = (control) => fire($action, $dispatch, control.value, control);
|
|
139
|
-
return multiline && (inputType === void 0 || inputType === "text") ? /* @__PURE__ */ jsx("textarea", {
|
|
140
|
-
"data-aui": "input",
|
|
141
|
-
"data-aui-multiline": true,
|
|
142
|
-
"data-aui-action": actionAttr($action),
|
|
143
|
-
name,
|
|
144
|
-
"aria-label": label,
|
|
145
|
-
placeholder,
|
|
146
|
-
...isBound ? { value: typeof answeredValue === "string" ? answeredValue : value ?? "" } : { defaultValue: initialValue },
|
|
147
|
-
onChange: updateBinding ? (e) => updateBinding(e.currentTarget.value) : void 0,
|
|
148
|
-
onKeyDown: (e) => {
|
|
149
|
-
if (e.key !== "Enter" || !(e.ctrlKey || e.metaKey) || e.nativeEvent.isComposing) return;
|
|
150
|
-
if (e.currentTarget.form) {
|
|
151
|
-
e.preventDefault();
|
|
152
|
-
HTMLFormElement.prototype.requestSubmit.call(e.currentTarget.form);
|
|
153
|
-
} else submit(e.currentTarget);
|
|
154
|
-
}
|
|
155
|
-
}, initialValue) : /* @__PURE__ */ jsx("input", {
|
|
156
|
-
type: inputType,
|
|
157
|
-
step: inputType === "number" ? "any" : void 0,
|
|
158
|
-
"data-aui": "input",
|
|
159
|
-
"data-aui-action": actionAttr($action),
|
|
160
|
-
name,
|
|
161
|
-
"aria-label": label,
|
|
162
|
-
placeholder,
|
|
163
|
-
...isBound ? { value: typeof answeredValue === "string" ? answeredValue : value ?? "" } : { defaultValue: initialValue },
|
|
164
|
-
onChange: updateBinding ? (e) => updateBinding(e.currentTarget.value) : void 0,
|
|
165
|
-
onKeyDown: (e) => {
|
|
166
|
-
if (e.key === "Enter" && !e.nativeEvent.isComposing && !e.currentTarget.form) submit(e.currentTarget);
|
|
167
|
-
}
|
|
168
|
-
}, initialValue);
|
|
169
|
-
}
|
|
170
|
-
const subscribeToHydration = () => () => {};
|
|
171
|
-
const clientHydrationSnapshot = () => true;
|
|
172
|
-
const serverHydrationSnapshot = () => false;
|
|
173
|
-
function DatePickerRender({ inputType = "date", value, min, max, label, name, $action, $dispatch }) {
|
|
174
|
-
const answeredValue = useAnsweredValue(name);
|
|
175
|
-
const updateBinding = useA2uiBinding(name);
|
|
176
|
-
const isBound = updateBinding !== void 0;
|
|
177
|
-
const initialValue = typeof answeredValue === "string" ? answeredValue : value;
|
|
178
|
-
const [selection, setSelection] = React.useState({
|
|
179
|
-
initialValue,
|
|
180
|
-
value: initialValue,
|
|
181
|
-
anchor: initialValue,
|
|
182
|
-
committedValue: initialValue,
|
|
183
|
-
edited: false
|
|
184
|
-
});
|
|
185
|
-
if (selection.initialValue !== initialValue) {
|
|
186
|
-
const isEcho = isBound && initialValue === selection.value;
|
|
187
|
-
setSelection({
|
|
188
|
-
initialValue,
|
|
189
|
-
value: initialValue,
|
|
190
|
-
anchor: isEcho ? selection.anchor : initialValue,
|
|
191
|
-
committedValue: isEcho ? selection.committedValue : initialValue,
|
|
192
|
-
edited: isEcho && selection.edited
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
const currentValue = isBound ? initialValue : selection.value;
|
|
196
|
-
const temporal = classifyTemporal(currentValue ?? "");
|
|
197
|
-
const anchor = classifyTemporal(selection.anchor ?? "");
|
|
198
|
-
const hasInstantAnchor = inputType === "datetime" && anchor.kind === "instant";
|
|
199
|
-
const canonicalFieldValue = (value) => {
|
|
200
|
-
const current = value ?? "";
|
|
201
|
-
const kind = classifyTemporal(current).kind;
|
|
202
|
-
if (inputType === "time") return kind === "time" && normalizeTemporalInputValue(current) !== current ? value : void 0;
|
|
203
|
-
if (inputType !== "datetime") return void 0;
|
|
204
|
-
if (kind === "instant") return value;
|
|
205
|
-
if (hasInstantAnchor) return selection.anchor;
|
|
206
|
-
return kind === "floating" && normalizeTemporalInputValue(current) !== current ? value : void 0;
|
|
207
|
-
};
|
|
208
|
-
const minimum = classifyTemporal(min ?? "");
|
|
209
|
-
const maximum = classifyTemporal(max ?? "");
|
|
210
|
-
const hydrated = React.useSyncExternalStore(subscribeToHydration, clientHydrationSnapshot, serverHydrationSnapshot);
|
|
211
|
-
const showRawValue = inputType === "datetime" && temporal.kind === "instant" && !hydrated;
|
|
212
|
-
const displayValue = currentValue === void 0 ? void 0 : inputType === "datetime" && hydrated ? toPickerLocalDateTime(currentValue) : normalizeTemporalInputValue(currentValue);
|
|
213
|
-
const keyboardActive = React.useRef(false);
|
|
214
|
-
const valueFromInput = (input) => {
|
|
215
|
-
const inputValue = normalizeTemporalInputValue(input.value);
|
|
216
|
-
return inputType === "datetime" ? fromLocalDateTime(inputValue, selection.anchor) : inputValue;
|
|
217
|
-
};
|
|
218
|
-
const commit = (input) => {
|
|
219
|
-
if (!selection.edited) return;
|
|
220
|
-
const nextValue = valueFromInput(input);
|
|
221
|
-
setSelection({
|
|
222
|
-
...selection,
|
|
223
|
-
committedValue: nextValue,
|
|
224
|
-
edited: false
|
|
225
|
-
});
|
|
226
|
-
if (nextValue !== selection.committedValue) fire($action, $dispatch, nextValue, input);
|
|
227
|
-
};
|
|
228
|
-
return /* @__PURE__ */ jsx("input", {
|
|
229
|
-
type: showRawValue ? "text" : inputType === "datetime" ? "datetime-local" : inputType,
|
|
230
|
-
readOnly: showRawValue || void 0,
|
|
231
|
-
"data-aui": "datepicker",
|
|
232
|
-
"data-aui-action": actionAttr($action),
|
|
233
|
-
[FIELD_VALUE_ATTR]: canonicalFieldValue(currentValue),
|
|
234
|
-
name,
|
|
235
|
-
"aria-label": label,
|
|
236
|
-
...isBound || inputType === "datetime" ? { value: displayValue ?? "" } : { defaultValue: displayValue },
|
|
237
|
-
min: inputType === "datetime" && hydrated && min !== void 0 ? normalizeTemporalInputValue(toLocalDateTime(min, minimum.kind === "instant" ? minimum.precision : void 0)) : min === void 0 ? void 0 : normalizeTemporalInputValue(min),
|
|
238
|
-
max: inputType === "datetime" && hydrated && max !== void 0 ? normalizeTemporalInputValue(toLocalDateTime(max, maximum.kind === "instant" ? maximum.precision : void 0)) : max === void 0 ? void 0 : normalizeTemporalInputValue(max),
|
|
239
|
-
step: inputType !== "date" ? getTemporalInputStep(selection.anchor, hasInstantAnchor ? displayValue : currentValue, min, max) : void 0,
|
|
240
|
-
onChange: (e) => {
|
|
241
|
-
const nextValue = valueFromInput(e.currentTarget);
|
|
242
|
-
const canonical = canonicalFieldValue(nextValue);
|
|
243
|
-
if (canonical !== void 0) e.currentTarget.setAttribute(FIELD_VALUE_ATTR, canonical);
|
|
244
|
-
else e.currentTarget.removeAttribute(FIELD_VALUE_ATTR);
|
|
245
|
-
const typed = keyboardActive.current;
|
|
246
|
-
keyboardActive.current = false;
|
|
247
|
-
setSelection({
|
|
248
|
-
initialValue,
|
|
249
|
-
value: nextValue,
|
|
250
|
-
anchor: selection.anchor,
|
|
251
|
-
committedValue: typed ? selection.committedValue : nextValue,
|
|
252
|
-
edited: typed
|
|
253
|
-
});
|
|
254
|
-
updateBinding?.(nextValue);
|
|
255
|
-
if (!typed && nextValue !== selection.committedValue) fire($action, $dispatch, nextValue, e.currentTarget);
|
|
256
|
-
},
|
|
257
|
-
onBlur: (e) => {
|
|
258
|
-
keyboardActive.current = false;
|
|
259
|
-
commit(e.currentTarget);
|
|
260
|
-
},
|
|
261
|
-
onKeyDown: (e) => {
|
|
262
|
-
if (e.key === "Enter" && !e.nativeEvent.isComposing && !e.currentTarget.form) {
|
|
263
|
-
commit(e.currentTarget);
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
keyboardActive.current = !e.altKey && !e.ctrlKey && !e.metaKey && (e.key.length === 1 || [
|
|
267
|
-
"ArrowDown",
|
|
268
|
-
"ArrowUp",
|
|
269
|
-
"Backspace",
|
|
270
|
-
"Delete",
|
|
271
|
-
"End",
|
|
272
|
-
"Home",
|
|
273
|
-
"PageDown",
|
|
274
|
-
"PageUp"
|
|
275
|
-
].includes(e.key));
|
|
276
|
-
},
|
|
277
|
-
onKeyUp: () => {
|
|
278
|
-
keyboardActive.current = false;
|
|
279
|
-
},
|
|
280
|
-
onPaste: () => {
|
|
281
|
-
keyboardActive.current = true;
|
|
282
|
-
},
|
|
283
|
-
onCut: () => {
|
|
284
|
-
keyboardActive.current = true;
|
|
285
|
-
}
|
|
286
|
-
}, isBound ? void 0 : initialValue);
|
|
287
|
-
}
|
|
288
|
-
function CheckboxRender({ checked, label, name, defaultChecked, variant = "checkbox", $action, $dispatch }) {
|
|
289
|
-
const answeredValue = useAnsweredValue(name);
|
|
290
|
-
const updateBinding = useA2uiBinding(name);
|
|
291
|
-
const isBound = updateBinding !== void 0;
|
|
292
|
-
const initialChecked = typeof answeredValue === "boolean" ? answeredValue : defaultChecked;
|
|
293
|
-
return /* @__PURE__ */ jsxs("label", {
|
|
294
|
-
"data-aui": "checkbox",
|
|
295
|
-
"data-aui-variant": variant === "switch" ? variant : void 0,
|
|
296
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
297
|
-
type: "checkbox",
|
|
298
|
-
role: variant === "switch" ? "switch" : void 0,
|
|
299
|
-
"data-aui-action": actionAttr($action),
|
|
300
|
-
name,
|
|
301
|
-
...isBound ? { checked: typeof answeredValue === "boolean" ? answeredValue : checked === true } : { defaultChecked: initialChecked },
|
|
302
|
-
onChange: (e) => {
|
|
303
|
-
updateBinding?.(e.currentTarget.checked);
|
|
304
|
-
fire($action, $dispatch, e.currentTarget.checked, e.currentTarget);
|
|
305
|
-
}
|
|
306
|
-
}, String(initialChecked)), /* @__PURE__ */ jsx("span", {
|
|
307
|
-
"data-aui": "checkbox-label",
|
|
308
|
-
children: toTextContent(label)
|
|
309
|
-
})]
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
const finiteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
313
|
-
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
314
|
-
function SliderControl({ controlledValue, name, label, min, max, step, initialValue, unit, $action, $dispatch }) {
|
|
315
|
-
const updateBinding = useA2uiBinding(name);
|
|
316
|
-
const [localValue, setValue] = React.useState(initialValue);
|
|
317
|
-
const value = controlledValue ?? localValue;
|
|
318
|
-
const pointerActive = React.useRef(false);
|
|
319
|
-
const keyboardActive = React.useRef(false);
|
|
320
|
-
const lastCommitted = React.useRef(initialValue);
|
|
321
|
-
const currentValue = (input) => clamp(Number(input.value), min, max);
|
|
322
|
-
const commit = (input) => {
|
|
323
|
-
if (controlledValue !== void 0) return;
|
|
324
|
-
const nextValue = currentValue(input);
|
|
325
|
-
setValue(nextValue);
|
|
326
|
-
if (lastCommitted.current === nextValue) return;
|
|
327
|
-
lastCommitted.current = nextValue;
|
|
328
|
-
fire($action, $dispatch, nextValue, input);
|
|
329
|
-
};
|
|
330
|
-
return /* @__PURE__ */ jsxs("label", {
|
|
331
|
-
"data-aui": "slider-field",
|
|
332
|
-
children: [
|
|
333
|
-
label ? /* @__PURE__ */ jsx("span", {
|
|
334
|
-
"data-aui": "slider-label",
|
|
335
|
-
children: label
|
|
336
|
-
}) : null,
|
|
337
|
-
/* @__PURE__ */ jsx("input", {
|
|
338
|
-
type: "range",
|
|
339
|
-
"data-aui": "slider",
|
|
340
|
-
"data-aui-action": actionAttr($action),
|
|
341
|
-
name,
|
|
342
|
-
"aria-label": label,
|
|
343
|
-
"aria-valuetext": unit ? `${value} ${unit}` : String(value),
|
|
344
|
-
min,
|
|
345
|
-
max,
|
|
346
|
-
step,
|
|
347
|
-
...controlledValue !== void 0 ? { value } : { defaultValue: initialValue },
|
|
348
|
-
onInput: (e) => {
|
|
349
|
-
const nextValue = currentValue(e.currentTarget);
|
|
350
|
-
if (controlledValue !== void 0) updateBinding?.(nextValue);
|
|
351
|
-
else setValue(nextValue);
|
|
352
|
-
},
|
|
353
|
-
onPointerDown: () => {
|
|
354
|
-
pointerActive.current = true;
|
|
355
|
-
},
|
|
356
|
-
onPointerUp: (e) => {
|
|
357
|
-
pointerActive.current = false;
|
|
358
|
-
commit(e.currentTarget);
|
|
359
|
-
},
|
|
360
|
-
onKeyDown: (e) => {
|
|
361
|
-
keyboardActive.current = [
|
|
362
|
-
"ArrowDown",
|
|
363
|
-
"ArrowLeft",
|
|
364
|
-
"ArrowRight",
|
|
365
|
-
"ArrowUp",
|
|
366
|
-
"End",
|
|
367
|
-
"Home",
|
|
368
|
-
"PageDown",
|
|
369
|
-
"PageUp"
|
|
370
|
-
].includes(e.key);
|
|
371
|
-
},
|
|
372
|
-
onKeyUp: (e) => {
|
|
373
|
-
if (!keyboardActive.current) return;
|
|
374
|
-
keyboardActive.current = false;
|
|
375
|
-
commit(e.currentTarget);
|
|
376
|
-
},
|
|
377
|
-
onChange: (e) => {
|
|
378
|
-
if (!pointerActive.current && !keyboardActive.current) commit(e.currentTarget);
|
|
379
|
-
}
|
|
380
|
-
}),
|
|
381
|
-
/* @__PURE__ */ jsxs("output", {
|
|
382
|
-
"data-aui": "slider-value",
|
|
383
|
-
children: [value, unit ? ` ${unit}` : ""]
|
|
384
|
-
})
|
|
385
|
-
]
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
function SliderRender({ value, name, label, min, max, step, defaultValue, unit, $action, $dispatch }) {
|
|
389
|
-
const answeredValue = useAnsweredValue(name);
|
|
390
|
-
const isBound = useA2uiBinding(name) !== void 0;
|
|
391
|
-
const safeMin = finiteNumber(min) ? min : 0;
|
|
392
|
-
const safeMax = finiteNumber(max) ? Math.max(max, safeMin) : safeMin + 100;
|
|
393
|
-
const safeStep = finiteNumber(step) && step > 0 ? step : 1;
|
|
394
|
-
const defaultNumber = finiteNumber(isBound ? value : defaultValue) ? isBound ? value : defaultValue : safeMin;
|
|
395
|
-
const initialValue = clamp(finiteNumber(answeredValue) ? answeredValue : defaultNumber, safeMin, safeMax);
|
|
396
|
-
return /* @__PURE__ */ jsx(SliderControl, {
|
|
397
|
-
...isBound ? { controlledValue: initialValue } : {},
|
|
398
|
-
min: safeMin,
|
|
399
|
-
max: safeMax,
|
|
400
|
-
step: safeStep,
|
|
401
|
-
initialValue,
|
|
402
|
-
...name !== void 0 ? { name } : {},
|
|
403
|
-
...label !== void 0 ? { label } : {},
|
|
404
|
-
...unit !== void 0 ? { unit } : {},
|
|
405
|
-
...$action !== void 0 ? { $action } : {},
|
|
406
|
-
...$dispatch !== void 0 ? { $dispatch } : {}
|
|
407
|
-
}, `${safeMin}:${safeMax}:${safeStep}:${isBound ? "bound" : initialValue}`);
|
|
408
|
-
}
|
|
409
|
-
const UNDO_WINDOW_SECONDS = 5;
|
|
410
|
-
function ButtonRender({ label, buttonStyle, block, submit, undoable, children, $action, $dispatch }) {
|
|
411
|
-
const bindings = React.useContext(A2uiBindingContext)?.fields;
|
|
412
|
-
const bindingsRef = React.useRef(bindings);
|
|
413
|
-
bindingsRef.current = bindings;
|
|
414
|
-
const [remaining, setRemaining] = React.useState(void 0);
|
|
415
|
-
const labelText = String(toTextContent(label) ?? "");
|
|
416
|
-
const undoLabel = labelText.trim();
|
|
417
|
-
const pendingAction = React.useRef(void 0);
|
|
418
|
-
const canUndo = undoable && !submit && $action !== void 0 && $dispatch !== void 0;
|
|
419
|
-
React.useEffect(() => {
|
|
420
|
-
if (remaining === void 0) return;
|
|
421
|
-
const timer = setTimeout(() => {
|
|
422
|
-
if (remaining > 1) {
|
|
423
|
-
setRemaining(remaining - 1);
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
const action = pendingAction.current;
|
|
427
|
-
pendingAction.current = void 0;
|
|
428
|
-
setRemaining(void 0);
|
|
429
|
-
if (action) fire(action.$action, action.$dispatch, void 0, action.source, bindingsRef.current);
|
|
430
|
-
}, 1e3);
|
|
431
|
-
return () => clearTimeout(timer);
|
|
432
|
-
}, [remaining]);
|
|
433
|
-
const cancelUndo = () => {
|
|
434
|
-
pendingAction.current = void 0;
|
|
435
|
-
setRemaining(void 0);
|
|
436
|
-
};
|
|
437
|
-
return /* @__PURE__ */ jsx("button", {
|
|
438
|
-
type: submit ? "submit" : "button",
|
|
439
|
-
"data-aui": "button",
|
|
440
|
-
"data-aui-style": buttonStyle,
|
|
441
|
-
"data-aui-block": block || void 0,
|
|
442
|
-
"data-aui-submit": submit || void 0,
|
|
443
|
-
"data-aui-state": remaining === void 0 ? void 0 : "pending",
|
|
444
|
-
"data-aui-action": actionAttr($action),
|
|
445
|
-
"aria-label": remaining === void 0 ? void 0 : undoLabel ? `Undo ${undoLabel}` : "Undo",
|
|
446
|
-
onClick: submit ? void 0 : canUndo ? (e) => {
|
|
447
|
-
if (remaining !== void 0) {
|
|
448
|
-
cancelUndo();
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
pendingAction.current = {
|
|
452
|
-
$action,
|
|
453
|
-
$dispatch,
|
|
454
|
-
source: e.currentTarget
|
|
455
|
-
};
|
|
456
|
-
setRemaining(UNDO_WINDOW_SECONDS);
|
|
457
|
-
} : (e) => fire($action, $dispatch, void 0, e.currentTarget, bindings),
|
|
458
|
-
onKeyDown: canUndo ? (e) => {
|
|
459
|
-
if (e.key !== "Escape" || remaining === void 0) return;
|
|
460
|
-
e.preventDefault();
|
|
461
|
-
cancelUndo();
|
|
462
|
-
} : void 0,
|
|
463
|
-
children: remaining === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [labelText, children] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
464
|
-
"Undo ",
|
|
465
|
-
/* @__PURE__ */ jsx("span", {
|
|
466
|
-
"data-aui": "button-countdown",
|
|
467
|
-
children: remaining
|
|
468
|
-
}),
|
|
469
|
-
/* @__PURE__ */ jsxs("span", {
|
|
470
|
-
"data-aui": "button-undo-status",
|
|
471
|
-
role: "status",
|
|
472
|
-
children: [
|
|
473
|
-
labelText,
|
|
474
|
-
" in ",
|
|
475
|
-
UNDO_WINDOW_SECONDS,
|
|
476
|
-
" seconds"
|
|
477
|
-
]
|
|
478
|
-
})
|
|
479
|
-
] })
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
const interactiveVocabulary = {
|
|
483
|
-
Button: {
|
|
484
|
-
description: "A clickable button. Carries `$action` describing the side effect or resume value. Set `submit` to submit an ancestor Form/Card instead of firing `$action` on click.",
|
|
485
|
-
properties: z.object({
|
|
486
|
-
label: z.string().describe("Button label."),
|
|
487
|
-
buttonStyle: z.enum(BUTTON_STYLES).optional().describe("Visual style."),
|
|
488
|
-
block: z.boolean().optional().describe("Whether the button spans the full width."),
|
|
489
|
-
submit: z.boolean().optional().describe("Render as a submit button for an ancestor Form/Card instead of a click button."),
|
|
490
|
-
undoable: z.boolean().optional().describe("Delay the action with an undo control, for sends and other hard-to-reverse actions.")
|
|
491
|
-
}),
|
|
492
|
-
render: ButtonRender
|
|
493
|
-
},
|
|
494
|
-
Select: {
|
|
495
|
-
description: "A dropdown selector. Carries `$action` describing the on-select behavior.",
|
|
496
|
-
properties: z.object({
|
|
497
|
-
options: z.array(optionSchema).describe("Selectable options."),
|
|
498
|
-
placeholder: z.string().optional().describe("Placeholder shown when nothing is selected."),
|
|
499
|
-
label: z.string().optional().describe("Accessible label for the control."),
|
|
500
|
-
name: z.string().optional().describe("Field name used inside a Form."),
|
|
501
|
-
defaultValue: z.string().optional().describe("Initially selected value.")
|
|
502
|
-
}),
|
|
503
|
-
render: SelectRender
|
|
504
|
-
},
|
|
505
|
-
Input: {
|
|
506
|
-
description: "A text input. Carries `$action` describing the on-submit behavior.",
|
|
507
|
-
properties: z.object({
|
|
508
|
-
inputType: z.enum([
|
|
509
|
-
"text",
|
|
510
|
-
"password",
|
|
511
|
-
"number"
|
|
512
|
-
]).optional().describe("Single-line input type. Values remain strings."),
|
|
513
|
-
placeholder: z.string().optional().describe("Placeholder text."),
|
|
514
|
-
multiline: z.boolean().optional().describe("Render a textarea instead of a single-line input; ignored when `inputType` is `\"password\"` or `\"number\"`."),
|
|
515
|
-
label: z.string().optional().describe("Accessible label for the control."),
|
|
516
|
-
name: z.string().optional().describe("Field name used inside a Form."),
|
|
517
|
-
defaultValue: z.string().optional().describe("Initial text.")
|
|
518
|
-
}),
|
|
519
|
-
render: InputRender
|
|
520
|
-
},
|
|
521
|
-
DatePicker: {
|
|
522
|
-
description: "A date, datetime, or time input. Carries `$action`, which runs once per committed value: a pick from the picker, or a typed value on blur or Enter.",
|
|
523
|
-
properties: z.object({
|
|
524
|
-
inputType: z.enum([
|
|
525
|
-
"date",
|
|
526
|
-
"datetime",
|
|
527
|
-
"time"
|
|
528
|
-
]).optional().describe("Temporal input type. Defaults to \"date\". Values remain strings."),
|
|
529
|
-
value: z.string().optional().describe("Initial value: YYYY-MM-DD for date, HH:mm or HH:mm:ss with optional fraction of at most 9 digits for time, YYYY-MM-DDTHH:mm with optional :ss and fraction of at most 9 digits for datetime. A datetime with Z or ±HH:mm is an instant, displayed in the viewer's time zone and submitted with the same offset and precision. A datetime without an offset is local and submitted unchanged. An empty datetime submits with the viewer's offset and seconds."),
|
|
530
|
-
min: z.string().optional().describe("Minimum value: YYYY-MM-DD for date, HH:mm or HH:mm:ss with optional fraction of at most 9 digits for time, YYYY-MM-DDTHH:mm with optional :ss and fraction of at most 9 digits for datetime. Datetimes with Z or ±HH:mm are converted to the viewer's time zone."),
|
|
531
|
-
max: z.string().optional().describe("Maximum value: YYYY-MM-DD for date, HH:mm or HH:mm:ss with optional fraction of at most 9 digits for time, YYYY-MM-DDTHH:mm with optional :ss and fraction of at most 9 digits for datetime. Datetimes with Z or ±HH:mm are converted to the viewer's time zone."),
|
|
532
|
-
label: z.string().optional().describe("Accessible label for the control."),
|
|
533
|
-
name: z.string().optional().describe("Field name used inside a Form.")
|
|
534
|
-
}),
|
|
535
|
-
render: DatePickerRender
|
|
536
|
-
},
|
|
537
|
-
Checkbox: {
|
|
538
|
-
description: "A checkbox with a label. Carries `$action` describing the on-change behavior.",
|
|
539
|
-
properties: z.object({
|
|
540
|
-
label: z.string().describe("Label text next to the checkbox."),
|
|
541
|
-
name: z.string().optional().describe("Field name used inside a Form."),
|
|
542
|
-
defaultChecked: z.boolean().optional().describe("Whether the checkbox starts checked."),
|
|
543
|
-
variant: z.enum(["checkbox", "switch"]).optional().describe("Whether to render a checkbox or switch.")
|
|
544
|
-
}),
|
|
545
|
-
render: CheckboxRender
|
|
546
|
-
},
|
|
547
|
-
Slider: {
|
|
548
|
-
description: "A numeric range control. Carries `$action` describing the committed value.",
|
|
549
|
-
properties: z.object({
|
|
550
|
-
name: z.string().optional().describe("Field name used inside a Form."),
|
|
551
|
-
label: z.string().optional().describe("Accessible label for the control."),
|
|
552
|
-
min: z.number().describe("Minimum value."),
|
|
553
|
-
max: z.number().describe("Maximum value."),
|
|
554
|
-
step: z.number().optional().describe("Value increment. Defaults to 1."),
|
|
555
|
-
defaultValue: z.number().optional().describe("Initial value."),
|
|
556
|
-
unit: z.string().optional().describe("Unit shown with the value.")
|
|
557
|
-
}),
|
|
558
|
-
render: SliderRender
|
|
559
|
-
},
|
|
560
|
-
RadioGroup: {
|
|
561
|
-
description: "A group of mutually exclusive radio options. Carries `$action` describing the on-change behavior.",
|
|
562
|
-
properties: z.object({
|
|
563
|
-
options: z.array(describedOptionSchema).describe("Selectable options."),
|
|
564
|
-
name: z.string().optional().describe("Field name used inside a Form."),
|
|
565
|
-
label: z.string().optional().describe("Accessible name for the group."),
|
|
566
|
-
defaultValue: z.string().optional().describe("Initially selected value.")
|
|
567
|
-
}),
|
|
568
|
-
render: RadioGroupRender
|
|
569
|
-
},
|
|
570
|
-
CheckboxGroup: {
|
|
571
|
-
description: "A group of checkbox options where any number can be checked. Carries `$action` describing the on-change behavior.",
|
|
572
|
-
properties: z.object({
|
|
573
|
-
options: z.array(describedOptionSchema).describe("Selectable options."),
|
|
574
|
-
name: z.string().optional().describe("Field name used inside a Form."),
|
|
575
|
-
label: z.string().optional().describe("Accessible name for the group."),
|
|
576
|
-
defaultValue: z.array(z.string()).optional().describe("Initially checked values.")
|
|
577
|
-
}),
|
|
578
|
-
render: CheckboxGroupRender
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
//#endregion
|
|
582
|
-
export { interactiveVocabulary };
|
|
583
|
-
|
|
584
|
-
//# sourceMappingURL=interactive.js.map
|