@littlepress/renderer-web 0.0.0-stage → 1.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.
Files changed (187) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +20 -0
  3. package/README.md +229 -2
  4. package/dist/answer/answerComponents.d.ts +107 -0
  5. package/dist/answer/answerComponents.js +637 -0
  6. package/dist/answer/download.d.ts +63 -0
  7. package/dist/answer/download.js +109 -0
  8. package/dist/answer/downloadExport.d.ts +44 -0
  9. package/dist/answer/downloadExport.js +266 -0
  10. package/dist/answer/hostValues.d.ts +28 -0
  11. package/dist/answer/hostValues.js +379 -0
  12. package/dist/answer/mapComponent.d.ts +6 -0
  13. package/dist/answer/mapComponent.js +213 -0
  14. package/dist/answer/math.d.ts +57 -0
  15. package/dist/answer/math.js +168 -0
  16. package/dist/answer/surfaceStream.d.ts +51 -0
  17. package/dist/answer/surfaceStream.js +260 -0
  18. package/dist/answer/tableLayout.d.ts +42 -0
  19. package/dist/answer/tableLayout.js +89 -0
  20. package/dist/controls/ActionFeedback.d.ts +5 -0
  21. package/dist/controls/ActionFeedback.js +43 -0
  22. package/dist/controls/actionDispatch.d.ts +51 -0
  23. package/dist/controls/actionDispatch.js +211 -0
  24. package/dist/controls/actionOutcome.generated.d.ts +64 -0
  25. package/dist/controls/actionOutcome.generated.js +64 -0
  26. package/dist/controls/calculationPublisher.d.ts +14 -0
  27. package/dist/controls/calculationPublisher.js +6 -0
  28. package/dist/controls/calculations.d.ts +20 -0
  29. package/dist/controls/calculations.generated.d.ts +73 -0
  30. package/dist/controls/calculations.generated.js +85 -0
  31. package/dist/controls/calculations.js +208 -0
  32. package/dist/controls/controlState.d.ts +84 -0
  33. package/dist/controls/controlState.js +256 -0
  34. package/dist/controls/fieldMessages.d.ts +41 -0
  35. package/dist/controls/fieldMessages.js +81 -0
  36. package/dist/controls/fieldValidation.d.ts +19 -0
  37. package/dist/controls/fieldValidation.js +98 -0
  38. package/dist/controls/formComponents.d.ts +23 -0
  39. package/dist/controls/formComponents.js +738 -0
  40. package/dist/controls/formProgress.d.ts +63 -0
  41. package/dist/controls/formProgress.js +122 -0
  42. package/dist/controls/inputDrafts.d.ts +55 -0
  43. package/dist/controls/inputDrafts.js +183 -0
  44. package/dist/controls/inputValidation.d.ts +33 -0
  45. package/dist/controls/inputValidation.js +119 -0
  46. package/dist/controls/localWrites.d.ts +9 -0
  47. package/dist/controls/localWrites.js +29 -0
  48. package/dist/core/A2uiSurface.d.ts +13 -0
  49. package/dist/core/A2uiSurface.js +15 -0
  50. package/dist/core/AtlasIcon.d.ts +18 -0
  51. package/dist/core/AtlasIcon.js +22 -0
  52. package/dist/core/AtlasMedia.d.ts +22 -0
  53. package/dist/core/AtlasMedia.js +45 -0
  54. package/dist/core/Carousel.d.ts +61 -0
  55. package/dist/core/Carousel.js +183 -0
  56. package/dist/core/CoreMedia.d.ts +19 -0
  57. package/dist/core/CoreMedia.js +25 -0
  58. package/dist/core/FoundationA2uiSurface.d.ts +86 -0
  59. package/dist/core/FoundationA2uiSurface.js +440 -0
  60. package/dist/core/ImagePreview.d.ts +42 -0
  61. package/dist/core/ImagePreview.js +73 -0
  62. package/dist/core/LucideIcon.d.ts +19 -0
  63. package/dist/core/LucideIcon.js +42 -0
  64. package/dist/core/SurfaceLink.d.ts +35 -0
  65. package/dist/core/SurfaceLink.js +60 -0
  66. package/dist/core/appearance/aegis.d.ts +49 -0
  67. package/dist/core/appearance/aegis.js +34 -0
  68. package/dist/core/appearance/colour.d.ts +24 -0
  69. package/dist/core/appearance/colour.js +103 -0
  70. package/dist/core/appearance/css.d.ts +17 -0
  71. package/dist/core/appearance/css.js +153 -0
  72. package/dist/core/appearance/presets.generated.d.ts +4 -0
  73. package/dist/core/appearance/presets.generated.js +1184 -0
  74. package/dist/core/appearance/react.d.ts +29 -0
  75. package/dist/core/appearance/react.js +110 -0
  76. package/dist/core/appearance/resolve.d.ts +76 -0
  77. package/dist/core/appearance/resolve.js +127 -0
  78. package/dist/core/appearance/textScale.d.ts +11 -0
  79. package/dist/core/appearance/textScale.js +51 -0
  80. package/dist/core/appearance/theme.d.ts +138 -0
  81. package/dist/core/appearance/theme.js +274 -0
  82. package/dist/core/baseComponents.d.ts +53 -0
  83. package/dist/core/baseComponents.js +480 -0
  84. package/dist/core/binding.d.ts +46 -0
  85. package/dist/core/binding.js +118 -0
  86. package/dist/core/bundle.d.ts +23 -0
  87. package/dist/core/bundle.js +75 -0
  88. package/dist/core/catalog/catalog-index.generated.d.ts +44 -0
  89. package/dist/core/catalog/catalog-index.generated.js +79 -0
  90. package/dist/core/catalog/icons.generated.d.ts +6 -0
  91. package/dist/core/catalog/icons.generated.js +1788 -0
  92. package/dist/core/catalog.d.ts +6 -0
  93. package/dist/core/catalog.generated.d.ts +50 -0
  94. package/dist/core/catalog.generated.js +2174 -0
  95. package/dist/core/catalog.js +8 -0
  96. package/dist/core/chartRows.d.ts +7 -0
  97. package/dist/core/chartRows.js +38 -0
  98. package/dist/core/component-support.d.ts +39 -0
  99. package/dist/core/component-support.js +127 -0
  100. package/dist/core/components/actions.d.ts +4 -0
  101. package/dist/core/components/actions.js +21 -0
  102. package/dist/core/components/cards.d.ts +9 -0
  103. package/dist/core/components/cards.js +227 -0
  104. package/dist/core/components/charts.d.ts +18 -0
  105. package/dist/core/components/charts.js +412 -0
  106. package/dist/core/components/comparisonTable.d.ts +50 -0
  107. package/dist/core/components/comparisonTable.js +89 -0
  108. package/dist/core/components/content.d.ts +13 -0
  109. package/dist/core/components/content.js +108 -0
  110. package/dist/core/components/seriesCharts.d.ts +531 -0
  111. package/dist/core/components/seriesCharts.js +1053 -0
  112. package/dist/core/components/stepFlow.d.ts +7 -0
  113. package/dist/core/components/stepFlow.js +13 -0
  114. package/dist/core/components.full.d.ts +10 -0
  115. package/dist/core/components.full.js +41 -0
  116. package/dist/core/context.d.ts +207 -0
  117. package/dist/core/context.js +172 -0
  118. package/dist/core/coverage.d.ts +30 -0
  119. package/dist/core/coverage.js +93 -0
  120. package/dist/core/foundation.d.ts +21 -0
  121. package/dist/core/foundation.js +22 -0
  122. package/dist/core/fullTheme.d.ts +5 -0
  123. package/dist/core/fullTheme.js +9 -0
  124. package/dist/core/iconNodes.generated.d.ts +7 -0
  125. package/dist/core/iconNodes.generated.js +5 -0
  126. package/dist/core/lucideIcons.d.ts +5 -0
  127. package/dist/core/lucideIcons.js +7 -0
  128. package/dist/core/messages.d.ts +111 -0
  129. package/dist/core/messages.js +134 -0
  130. package/dist/core/pointer.d.ts +17 -0
  131. package/dist/core/pointer.js +104 -0
  132. package/dist/core/registry.d.ts +12 -0
  133. package/dist/core/registry.js +114 -0
  134. package/dist/core/runtime.d.ts +8 -0
  135. package/dist/core/runtime.js +6 -0
  136. package/dist/core/state.d.ts +73 -0
  137. package/dist/core/state.js +274 -0
  138. package/dist/core/surfaceMotion.d.ts +5 -0
  139. package/dist/core/surfaceMotion.js +46 -0
  140. package/dist/core/theme.d.ts +5 -0
  141. package/dist/core/theme.js +7 -0
  142. package/dist/core/useSurfaceImage.d.ts +20 -0
  143. package/dist/core/useSurfaceImage.js +65 -0
  144. package/dist/graph/RelationshipGraph.d.ts +14 -0
  145. package/dist/graph/RelationshipGraph.js +206 -0
  146. package/dist/graph/model.d.ts +20 -0
  147. package/dist/graph/model.js +36 -0
  148. package/dist/graph/program/assets.d.ts +3 -0
  149. package/dist/graph/program/assets.js +3 -0
  150. package/dist/graph/program/bridge.d.ts +6 -0
  151. package/dist/graph/program/bridge.generated.d.ts +136 -0
  152. package/dist/graph/program/bridge.generated.js +1 -0
  153. package/dist/graph/program/bridge.js +24 -0
  154. package/dist/graph/program/bridge.schema.json +717 -0
  155. package/dist/graph/program/bridgeValidator.cjs +2 -0
  156. package/dist/graph/program/bridgeValidator.d.cts +4 -0
  157. package/dist/graph/program/runner.d.ts +1 -0
  158. package/dist/graph/program/runner.html +2193 -0
  159. package/dist/graph/program/runner.js +157 -0
  160. package/dist/graph/program/runtime-manifest.json +1 -0
  161. package/dist/graph/program/view.d.ts +11 -0
  162. package/dist/graph/program/view.js +210 -0
  163. package/dist/graph/program/worker.d.ts +1 -0
  164. package/dist/graph/program/worker.js +2186 -0
  165. package/dist/index.d.ts +20 -0
  166. package/dist/index.js +45 -0
  167. package/dist/internal/dsh.d.ts +4 -0
  168. package/dist/internal/dsh.js +3 -0
  169. package/dist/internal/relationship-graph.d.ts +4 -0
  170. package/dist/internal/relationship-graph.js +7202 -0
  171. package/dist/page/layoutComponents.d.ts +6 -0
  172. package/dist/page/layoutComponents.js +123 -0
  173. package/dist/page/layoutGeometry.d.ts +68 -0
  174. package/dist/page/layoutGeometry.js +174 -0
  175. package/dist/page/pageFormat.d.ts +34 -0
  176. package/dist/page/pageFormat.js +119 -0
  177. package/dist/page/printFit.d.ts +81 -0
  178. package/dist/page/printFit.js +338 -0
  179. package/dist/react/index.d.ts +5 -0
  180. package/dist/react/index.js +2 -0
  181. package/dist/report/locate.d.ts +42 -0
  182. package/dist/report/locate.js +34 -0
  183. package/dist/styles/renderer.css +4580 -0
  184. package/licenses/LUCIDE-LICENSE.txt +43 -0
  185. package/licenses/QUICKJS-EMSCRIPTEN-LICENSE.txt +21 -0
  186. package/licenses/QUICKJS-VARIANT-LICENSE.txt +47 -0
  187. package/package.json +68 -3
@@ -0,0 +1,19 @@
1
+ import { type InputBoundError } from "./controlState.ts";
2
+ import { type InputValidationErrorCode } from "./inputValidation.ts";
3
+ /**
4
+ * Local checks every Foundation renderer runs on a form control.
5
+ *
6
+ * Web runs them as the user types; Compose and SwiftUI run the same rules when a form is
7
+ * submitted and keep them live afterwards. `contracts/fixtures/renderer/field-validation.json`
8
+ * is the shared case table all three renderers assert, so a rule changes in all of them or
9
+ * in none. The Host-supplied `error` prop is display-only and never changes this result, and
10
+ * a disabled control is never checked, matching HTML constraint validation.
11
+ */
12
+ export type FieldValidationComponent = "lp.input-field" | "lp.select" | "lp.checkbox" | "lp.choice-group" | "lp.slider";
13
+ export type FieldValidationErrorCode = InputValidationErrorCode | InputBoundError | "invalid_slider_value" | "integer_range" | "integer_step";
14
+ export type FieldValidationError = {
15
+ errorCode: FieldValidationErrorCode;
16
+ message: string;
17
+ };
18
+ export declare function inputBoundMessage(bound: InputBoundError, min?: string, max?: string): string;
19
+ export declare function validateFieldValue(component: FieldValidationComponent, props: Record<string, unknown>, value: unknown): FieldValidationError | null;
@@ -0,0 +1,98 @@
1
+ import { inputBoundError, sliderValueIsValid } from "./controlState.js";
2
+ import { inputValidationMessage, isDecimalNumber, isInputValidationProfile, isIsoDate, isIsoTime, validateInputValue, } from "./inputValidation.js";
3
+ const boundedInputTypes = new Set(["date", "time", "datetime-local"]);
4
+ function error(errorCode, message) {
5
+ return { errorCode, message };
6
+ }
7
+ function inputTypeError(value, inputType) {
8
+ if (inputType === "date")
9
+ return isIsoDate(value) ? null : "invalid_iso_date";
10
+ if (inputType === "time")
11
+ return isIsoTime(value) ? null : "invalid_time";
12
+ if (inputType === "datetime-local") {
13
+ const separator = value.indexOf("T");
14
+ const valid = separator > 0 && isIsoDate(value.slice(0, separator)) && isIsoTime(value.slice(separator + 1));
15
+ return valid ? null : "invalid_datetime";
16
+ }
17
+ if (inputType === "number")
18
+ return isDecimalNumber(value) ? null : "invalid_number";
19
+ return null;
20
+ }
21
+ export function inputBoundMessage(bound, min, max) {
22
+ return bound === "below_min"
23
+ ? `Choose a value on or after ${min ?? "the minimum"}.`
24
+ : `Choose a value on or before ${max ?? "the maximum"}.`;
25
+ }
26
+ function finiteNumber(value, fallback) {
27
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
28
+ }
29
+ function validateInputField(props, value) {
30
+ const text = typeof value === "string"
31
+ ? value
32
+ : typeof value === "number" && Number.isFinite(value) ? String(value) : "";
33
+ const trimmed = text.trim();
34
+ const required = props.required === true;
35
+ if (trimmed.length === 0)
36
+ return required ? error("required", inputValidationMessage("required")) : null;
37
+ const profile = isInputValidationProfile(props.validation) ? props.validation : "none";
38
+ const profileResult = validateInputValue(profile === "integer" ? text : trimmed, { profile });
39
+ if (profileResult.errorCode)
40
+ return error(profileResult.errorCode, inputValidationMessage(profileResult.errorCode));
41
+ if (profile === "integer") {
42
+ const current = Number(text);
43
+ const minimum = props.min === undefined ? undefined : Number(props.min);
44
+ const maximum = props.max === undefined ? undefined : Number(props.max);
45
+ const declaredStep = props.step === undefined ? 1 : Number(props.step);
46
+ const step = Number.isSafeInteger(declaredStep) && declaredStep > 0 ? declaredStep : 1;
47
+ if ((minimum !== undefined && (!Number.isSafeInteger(minimum) || current < minimum))
48
+ || (maximum !== undefined && (!Number.isSafeInteger(maximum) || current > maximum))) {
49
+ return error("integer_range", minimum !== undefined && maximum !== undefined
50
+ ? `Enter a whole number from ${minimum} to ${maximum}.`
51
+ : minimum !== undefined ? `Enter a whole number of at least ${minimum}.` : `Enter a whole number of at most ${maximum}.`);
52
+ }
53
+ if ((BigInt(current) - BigInt(minimum ?? 0)) % BigInt(step) !== 0n) {
54
+ return error("integer_step", `Enter a whole number in steps of ${step}, starting at ${minimum ?? 0}.`);
55
+ }
56
+ }
57
+ const inputType = typeof props.inputType === "string" ? props.inputType : "text";
58
+ const typeError = inputTypeError(trimmed, inputType);
59
+ if (typeError)
60
+ return error(typeError, inputValidationMessage(typeError));
61
+ if (!boundedInputTypes.has(inputType))
62
+ return null;
63
+ const min = typeof props.min === "string" ? props.min : undefined;
64
+ const max = typeof props.max === "string" ? props.max : undefined;
65
+ const bound = inputBoundError(trimmed, inputType, min, max);
66
+ return bound ? error(bound, inputBoundMessage(bound, min, max)) : null;
67
+ }
68
+ export function validateFieldValue(component, props, value) {
69
+ if (props.disabled === true)
70
+ return null;
71
+ const required = props.required === true;
72
+ switch (component) {
73
+ case "lp.input-field":
74
+ return validateInputField(props, value);
75
+ case "lp.select":
76
+ return required && (typeof value !== "string" || value.length === 0)
77
+ ? error("required", inputValidationMessage("required"))
78
+ : null;
79
+ case "lp.checkbox":
80
+ return required && value !== true ? error("required", inputValidationMessage("required")) : null;
81
+ case "lp.choice-group": {
82
+ const missing = props.multiple === true
83
+ ? !Array.isArray(value) || !value.some((entry) => typeof entry === "string")
84
+ : typeof value !== "string" || value.length === 0;
85
+ return required && missing ? error("required", "Choose at least one option.") : null;
86
+ }
87
+ case "lp.slider": {
88
+ const min = finiteNumber(props.min, 0);
89
+ const max = finiteNumber(props.max, 100);
90
+ const step = finiteNumber(props.step, 1);
91
+ // A slider with no value starts at `min`, so an absent value is not an error.
92
+ const current = finiteNumber(value, min);
93
+ return sliderValueIsValid(current, min, max, step)
94
+ ? null
95
+ : error("invalid_slider_value", "Choose a value within the allowed range.");
96
+ }
97
+ }
98
+ }
@@ -0,0 +1,23 @@
1
+ import { type A2uiComponent } from "../core/messages.ts";
2
+ import { type A2uiInputValue, type ComponentRenderer, type RenderContext } from "../core/context.ts";
3
+ export declare function isControlDisabled(component: A2uiComponent, context: RenderContext): boolean;
4
+ export declare function emitInputChange(component: A2uiComponent, context: RenderContext, fieldId: string, path: string | null, value: A2uiInputValue, valid: boolean, errorCode: string | null): void;
5
+ /**
6
+ * Shows or hides a password field's value. Its name says what pressing it does, so a screen
7
+ * reader hears "Show password" or "Hide password" and never the value itself.
8
+ */
9
+ export declare function PasswordToggle({ controlId, revealed, disabled, context, onToggle }: {
10
+ controlId: string;
11
+ revealed: boolean;
12
+ disabled: boolean;
13
+ context: RenderContext;
14
+ onToggle: () => void;
15
+ }): import("react/jsx-runtime").JSX.Element;
16
+ export declare const renderInputField: ComponentRenderer;
17
+ export declare const renderSelect: ComponentRenderer;
18
+ export declare const renderCheckbox: ComponentRenderer;
19
+ export declare const renderChoiceGroup: ComponentRenderer;
20
+ export declare const renderSlider: ComponentRenderer;
21
+ export declare const renderForm: ComponentRenderer;
22
+ export declare const renderTabs: ComponentRenderer;
23
+ export declare const renderPopover: ComponentRenderer;