@clickless/react 0.0.0-stage → 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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1095 -2
  3. package/dist/actions/actionCalls.d.ts +50 -0
  4. package/dist/actions/actionRegistry.d.ts +78 -0
  5. package/dist/components/Adaptive.d.ts +116 -0
  6. package/dist/components/AdaptiveAction.d.ts +4 -0
  7. package/dist/components/AdaptiveProvider.d.ts +38 -0
  8. package/dist/components/AdaptiveRegion.d.ts +60 -0
  9. package/dist/components/ClicklessUiErrorBoundary.d.ts +24 -0
  10. package/dist/components/OriginalToolbar.d.ts +21 -0
  11. package/dist/components/PromptBar.d.ts +21 -0
  12. package/dist/components/PromptPanel.d.ts +103 -0
  13. package/dist/components/WorkingDots.d.ts +4 -0
  14. package/dist/components/focusAfterPromptAction.d.ts +15 -0
  15. package/dist/components/hostColorScheme.d.ts +35 -0
  16. package/dist/components/promptPanelStyles.d.ts +14 -0
  17. package/dist/core/applyOperations.d.ts +21 -0
  18. package/dist/core/colorContrast.d.ts +22 -0
  19. package/dist/core/defaultLayout.d.ts +12 -0
  20. package/dist/core/index.d.ts +8 -0
  21. package/dist/core/ownProperties.d.ts +11 -0
  22. package/dist/core/propValues.d.ts +8 -0
  23. package/dist/core/reconcileLayout.d.ts +59 -0
  24. package/dist/core/schemas.gen.d.ts +427 -0
  25. package/dist/core/validateActionCalls.d.ts +28 -0
  26. package/dist/core/validateManifest.d.ts +11 -0
  27. package/dist/core/validateOperations.d.ts +15 -0
  28. package/dist/engine/engineClient.d.ts +231 -0
  29. package/dist/engine/engineErrorMessages.d.ts +13 -0
  30. package/dist/engine/engineResponses.d.ts +201 -0
  31. package/dist/engine/plainReplies.d.ts +2 -0
  32. package/dist/hooks/useActionRunHistory.d.ts +12 -0
  33. package/dist/hooks/useAdaptiveAction.d.ts +11 -0
  34. package/dist/hooks/useAdaptiveRegion.d.ts +34 -0
  35. package/dist/hooks/useChangeHistory.d.ts +32 -0
  36. package/dist/hooks/useDictation.d.ts +50 -0
  37. package/dist/hooks/useEngineReachable.d.ts +5 -0
  38. package/dist/hooks/usePromptBar.d.ts +163 -0
  39. package/dist/hooks/useRegionGroup.d.ts +15 -0
  40. package/dist/index.d.ts +21 -0
  41. package/dist/index.js +6600 -0
  42. package/dist/presets/mergePresets.d.ts +20 -0
  43. package/dist/presets/propPresets.d.ts +305 -0
  44. package/dist/region/changedComponentIds.d.ts +13 -0
  45. package/dist/region/firstPaintOrder.d.ts +19 -0
  46. package/dist/region/previewRequests.d.ts +21 -0
  47. package/dist/region/regionContext.d.ts +96 -0
  48. package/dist/region/regionGroup.d.ts +189 -0
  49. package/dist/region/regionSnapshot.d.ts +52 -0
  50. package/dist/region/regionStore.d.ts +361 -0
  51. package/dist/region/responsiveColumns.d.ts +35 -0
  52. package/dist/region/retrier.d.ts +22 -0
  53. package/dist/region/savedLayoutParsing.d.ts +7 -0
  54. package/dist/region/settleIntoSavedLayout.d.ts +14 -0
  55. package/dist/region/textDirection.d.ts +12 -0
  56. package/dist/region/unsavedChangeSaver.d.ts +45 -0
  57. package/dist/region/unsavedChanges.d.ts +78 -0
  58. package/dist/region/userFacingTitle.d.ts +7 -0
  59. package/package.json +59 -3
@@ -0,0 +1,163 @@
1
+ export type PromptBarStatus = "idle" | "planning" | "saving";
2
+ /** A sentence about something done, shown to the user. */
3
+ export interface PromptBarMessage {
4
+ text: string;
5
+ isError: boolean;
6
+ /** A second line under `text`, such as the request a restore went back to. */
7
+ detail?: string;
8
+ }
9
+ /** One request made since the bar was opened, and what came of it. */
10
+ export interface PromptTurn {
11
+ /**
12
+ * Empty for sentences said here without a request, kept where they were
13
+ * said: that a change was saved or the page put back, or what came of an
14
+ * earlier request's actions once such a sentence came after it. They are in
15
+ * `outcomes`.
16
+ */
17
+ request: string;
18
+ /**
19
+ * What the planner answered: what it previewed or is opening, what could not
20
+ * be done, or a question. Empty when the request was only for changes to
21
+ * confirm, which the confirmation itself describes.
22
+ */
23
+ reply: string;
24
+ /**
25
+ * What happened when actions ran, one sentence each. `text` is what the user
26
+ * is shown. `noteForPlanner` is what later requests tell the planner: the
27
+ * action's title and how it ended, or `text` for an action with
28
+ * `shareResultWithPlanner` that ran.
29
+ */
30
+ outcomes: (PromptBarMessage & {
31
+ noteForPlanner: string;
32
+ })[];
33
+ /** True once its preview was kept, which puts it in the history of saved changes. */
34
+ savedAsChange: boolean;
35
+ /**
36
+ * The point in the history of saved changes the screen was at when it was
37
+ * said, in the numbering of `HistoryEntry.revision`, so it can be shown after
38
+ * the changes saved up to then and before those saved later. For one kept as
39
+ * a change, the point that change made.
40
+ */
41
+ afterRevision: number;
42
+ }
43
+ /**
44
+ * True when the turn says something the user has not heard yet: a request, or
45
+ * what came of one's actions. A sentence moved in from the bar's message was
46
+ * heard when it was said, and tells the planner nothing.
47
+ */
48
+ export declare function saysSomethingNew(promptTurn: PromptTurn): boolean;
49
+ /**
50
+ * State and actions for a prompt bar. Use it to build your own, or render `PromptBar`.
51
+ *
52
+ * Give several region ids when one screen is made of more than one region,
53
+ * such as a page and a sidebar every page shares. A prompt is then planned for
54
+ * all of them at once, and its preview is kept, discarded and undone in all of
55
+ * them together, while each region's layout is still saved on its own.
56
+ */
57
+ export declare function usePromptBar(regionId: string | readonly string[]): {
58
+ prompt: string;
59
+ setPrompt: (nextPrompt: string | ((previousPrompt: string) => string)) => void;
60
+ status: PromptBarStatus;
61
+ /**
62
+ * A sentence about the last thing done here, such as that a change to the
63
+ * screen is saved, what an undo took back, or why it failed, with a `detail`
64
+ * line under it where there is more to say, such as the request a restore
65
+ * went back to.
66
+ */
67
+ message: PromptBarMessage | null;
68
+ /**
69
+ * The request sent and still waiting for its answer, so it can be shown at
70
+ * once rather than when the answer comes. Null otherwise.
71
+ */
72
+ requestInProgress: string | null;
73
+ /**
74
+ * What to show beside a one-line bar: `message`, or else the answer to the
75
+ * latest request while it is still the one being looked at, or what came of
76
+ * its actions. Null when the request was only for changes to confirm.
77
+ */
78
+ latestReply: PromptBarMessage | null;
79
+ /**
80
+ * Until dismissed: that personalising is not available right now, or how a
81
+ * saved layout was carried over to a changed screen.
82
+ */
83
+ notice: string | null;
84
+ dismissNotice: () => void;
85
+ /**
86
+ * False while the engine cannot be reached, so prompts cannot be carried out.
87
+ * The page's own controls still work, and their changes are saved later.
88
+ */
89
+ available: boolean;
90
+ previewing: boolean;
91
+ /** True while the screen shows how it first looked, in place of the user's changes. */
92
+ showingOriginal: boolean;
93
+ /** True when the screen differs from how it first looked, so there is an original to see or go back to. */
94
+ differsFromOriginal: boolean;
95
+ /**
96
+ * Shows the screen as it first looked, before any change, without saving
97
+ * anything, or goes back to the user's changes. A preview, or any change,
98
+ * ends it. To keep the original, `restoreRevision(0)`.
99
+ */
100
+ showOriginal: (shown: boolean) => void;
101
+ /**
102
+ * True when there is a change to the screen to undo, and no action has run
103
+ * since it was made during this visit to the page.
104
+ */
105
+ canUndo: boolean;
106
+ /**
107
+ * The requests made since the bar was opened, and sentences about what was
108
+ * done between them, oldest first, leaving out the requests the history of
109
+ * saved changes shows. One whose preview was kept but
110
+ * whose actions also ran stays, with `savedAsChange` set: the history shows
111
+ * the request and the reply, and only what came of the actions is left to show.
112
+ */
113
+ promptTurns: PromptTurn[];
114
+ /** Changes to the application's data that wait for the user to confirm them, or null. */
115
+ pendingActionCalls: {
116
+ summary: string;
117
+ }[] | null;
118
+ confirmActionCalls: () => void;
119
+ cancelActionCalls: () => void;
120
+ /**
121
+ * What will happen once the preview is kept or discarded, such as opening
122
+ * another page, or null.
123
+ */
124
+ callsAfterPreview: {
125
+ summary: string;
126
+ }[] | null;
127
+ /**
128
+ * What a past action run did, in a line, without the values it was given.
129
+ * Null for one that only changed what was shown, which a history of changes leaves out.
130
+ */
131
+ describeActionRun: (actionRun: {
132
+ actionTitle: string;
133
+ actionMode: "read" | "write";
134
+ }) => string | null;
135
+ /**
136
+ * The engine's numbers for the action runs recorded since the bar was
137
+ * opened. The conversation shows those, so a list of past runs can leave
138
+ * them out, and it changes each time one is recorded.
139
+ */
140
+ recordedActionRunIds: number[];
141
+ /** The screen's name for its records, such as its past action runs. */
142
+ screenId: string;
143
+ /** True when the page offers actions, so a request may do more than change how it looks. */
144
+ offersActions: boolean;
145
+ /** True when an action on the page takes a file, so the user can attach one. */
146
+ acceptsFiles: boolean;
147
+ attachedFiles: File[];
148
+ attachFiles: (newFiles: readonly File[]) => void;
149
+ removeAttachedFile: (position: number) => void;
150
+ submitPrompt: (submitOptions?: {
151
+ viaVoice?: boolean;
152
+ }) => void;
153
+ keepPreview: () => void;
154
+ discardPreview: () => void;
155
+ undoLastChange: () => void;
156
+ /**
157
+ * Returns the screen to how it was after the given saved change. Give the
158
+ * request that made that change as `restoredRequest`, and the sentence saying
159
+ * so names it in its `detail`. Resolves to the number of the saved change the
160
+ * restore made, or null if it did not happen.
161
+ */
162
+ restoreRevision: (revision: number, restoredRequest?: string) => Promise<number | null>;
163
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The regions a prompt bar speaks for: one id, or several for a screen made of
3
+ * more than one region. `regionIdsKey` names the set, for anything that must start
4
+ * again when the bar is pointed at other regions.
5
+ */
6
+ export declare function useRegionGroup(regionId: string | readonly string[]): {
7
+ regionGroup: import("../region/regionGroup.js").RegionGroup;
8
+ groupSnapshot: import("../region/regionGroup.js").RegionGroupSnapshot;
9
+ regionIdsKey: string;
10
+ };
11
+ /**
12
+ * One string naming a set of region ids. An array written in JSX is a new one
13
+ * on every render, so the ids are compared by value through this.
14
+ */
15
+ export declare function regionIdsKeyOf(regionId: string | readonly string[]): string;
@@ -0,0 +1,21 @@
1
+ export { AdaptiveProvider, type AdaptiveProviderProps } from "./components/AdaptiveProvider.js";
2
+ export { AdaptiveRegion, type AdaptiveRegionProps } from "./components/AdaptiveRegion.js";
3
+ export type { RegionColumns } from "./region/responsiveColumns.js";
4
+ export { Adaptive, type AdaptiveControls, type AdaptiveProps } from "./components/Adaptive.js";
5
+ export { propPresets, type ColourReading, type CustomPreset, type PresetSet, type PresetValues, type PropPreset, } from "./presets/propPresets.js";
6
+ export { PromptBar, type PromptBarProps } from "./components/PromptBar.js";
7
+ export type { ColorSchemeSetting } from "./components/hostColorScheme.js";
8
+ export { PromptPanel, type DictationButtonProps, type DictationLabels, type PromptPanelPosition, type PromptPanelProps, } from "./components/PromptPanel.js";
9
+ export { AdaptiveAction, type AdaptiveActionProps } from "./components/AdaptiveAction.js";
10
+ export { useAdaptiveAction } from "./hooks/useAdaptiveAction.js";
11
+ export { ActionError, type ActionArgumentValue, type ActionArguments, type ActionDefinition, } from "./actions/actionRegistry.js";
12
+ export { useAdaptiveRegion } from "./hooks/useAdaptiveRegion.js";
13
+ export { usePromptBar, type PromptBarMessage, type PromptBarStatus, type PromptTurn } from "./hooks/usePromptBar.js";
14
+ export { describeHistoryEntry, useChangeHistory, type ChangeHistoryOptions, } from "./hooks/useChangeHistory.js";
15
+ export { useDictation, type DictationOptions, type DictationStatus } from "./hooks/useDictation.js";
16
+ export { EngineError, type EngineOptions } from "./engine/engineClient.js";
17
+ export type { HistoryEntry, UndoneChange } from "./engine/engineResponses.js";
18
+ export type { RegionSnapshot } from "./region/regionSnapshot.js";
19
+ export type { LayoutChangeHandler, UndoResult } from "./region/regionStore.js";
20
+ export { contrastRatio, ensureReadableTextColor, readableTextColor } from "./core/index.js";
21
+ export type { Action, ActionCall, ActionParameter, ApplyOperationsOutcome, Capabilities, Component, Layout, LayoutChange, LayoutItem, Manifest, Operation, OperationError, PropCapabilities, PropValue, } from "./core/index.js";