@happyvertical/smrt-ui 0.53.1 → 0.53.2

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 (205) hide show
  1. package/package.json +3 -3
  2. package/dist/actions/__tests__/ripple.test.js +0 -82
  3. package/dist/actions/__tests__/swipe-dismiss.test.js +0 -69
  4. package/dist/components/calendar/__tests__/CalendarView.test.js +0 -226
  5. package/dist/components/calendar/__tests__/calendar-model.test.js +0 -138
  6. package/dist/components/chat/__tests__/chat-primitives.test.js +0 -118
  7. package/dist/components/data/__tests__/CollectionList.test.js +0 -37
  8. package/dist/components/data/__tests__/DataTable.test.js +0 -807
  9. package/dist/components/data/__tests__/DataTableConformance.test.js +0 -212
  10. package/dist/components/data/__tests__/DataTableController.test.js +0 -371
  11. package/dist/components/data/__tests__/DataTableIdentity.test.js +0 -29
  12. package/dist/components/data/__tests__/DataTableLayout.test.js +0 -195
  13. package/dist/components/data/__tests__/DataTablePerformance.test.js +0 -21
  14. package/dist/components/data/__tests__/DataTableResponsive.test.js +0 -80
  15. package/dist/components/data/__tests__/DataTableVirtualization.test.js +0 -80
  16. package/dist/components/data/__tests__/DataTableVirtualizationComponent.test.js +0 -255
  17. package/dist/components/data/__tests__/SortableHeader.test.js +0 -101
  18. package/dist/components/data/__tests__/data-surface.test.js +0 -746
  19. package/dist/components/data/__tests__/data-table-helpers.test.js +0 -36
  20. package/dist/components/data/__tests__/data-table-surface.test.js +0 -49
  21. package/dist/components/data/__tests__/link-step-surface.test.js +0 -172
  22. package/dist/components/data/__tests__/list-sort-state.svelte.test.js +0 -71
  23. package/dist/components/data/__tests__/list-sort.test.js +0 -91
  24. package/dist/components/data/__tests__/mounted-data-surface.test.js +0 -794
  25. package/dist/components/data/__tests__/responsive-table.fixture.svelte +0 -29
  26. package/dist/components/data/__tests__/responsive-table.fixture.svelte.d.ts +0 -7
  27. package/dist/components/data/__tests__/responsive-table.fixture.svelte.d.ts.map +0 -1
  28. package/dist/components/data/__tests__/surface-navigation.test.js +0 -121
  29. package/dist/components/display/__tests__/ConfidenceBadge.test.js +0 -109
  30. package/dist/components/display/__tests__/CurrencyDisplay.test.js +0 -304
  31. package/dist/components/display/__tests__/CurrencyDisplayI18nHarness.svelte +0 -20
  32. package/dist/components/display/__tests__/CurrencyDisplayI18nHarness.svelte.d.ts +0 -19
  33. package/dist/components/display/__tests__/CurrencyDisplayI18nHarness.svelte.d.ts.map +0 -1
  34. package/dist/components/display/__tests__/CurrencyDisplaySsrHarness.svelte +0 -7
  35. package/dist/components/display/__tests__/CurrencyDisplaySsrHarness.svelte.d.ts +0 -19
  36. package/dist/components/display/__tests__/CurrencyDisplaySsrHarness.svelte.d.ts.map +0 -1
  37. package/dist/components/display/__tests__/DateDisplay.test.js +0 -195
  38. package/dist/components/display/__tests__/Icon.test.js +0 -223
  39. package/dist/components/display/__tests__/StatusBadge.test.js +0 -191
  40. package/dist/components/feedback/__tests__/ConfirmDialog.test.js +0 -181
  41. package/dist/components/feedback/__tests__/LoadingOverlay.test.js +0 -113
  42. package/dist/components/feedback/__tests__/Modal.test.js +0 -72
  43. package/dist/components/feedback/__tests__/PhoneSheet.test.js +0 -101
  44. package/dist/components/feedback/__tests__/ProgressBar.test.js +0 -89
  45. package/dist/components/feedback/__tests__/WorkingStrip.test.js +0 -172
  46. package/dist/components/feedback/__tests__/confirm-message.fixture.svelte +0 -9
  47. package/dist/components/feedback/__tests__/confirm-message.fixture.svelte.d.ts +0 -19
  48. package/dist/components/feedback/__tests__/confirm-message.fixture.svelte.d.ts.map +0 -1
  49. package/dist/components/feedback/__tests__/toast.test.js +0 -190
  50. package/dist/components/forms/__tests__/CameraCapture.test.js +0 -504
  51. package/dist/components/forms/__tests__/Combobox.test.js +0 -354
  52. package/dist/components/forms/__tests__/ControlHitArea.test.js +0 -73
  53. package/dist/components/forms/__tests__/DictationButton.test.js +0 -176
  54. package/dist/components/forms/__tests__/Fieldset.test.js +0 -37
  55. package/dist/components/forms/__tests__/Form.test.js +0 -201
  56. package/dist/components/forms/__tests__/FormActionBar.test.js +0 -22
  57. package/dist/components/forms/__tests__/FormGroup.test.js +0 -48
  58. package/dist/components/forms/__tests__/Input.test.js +0 -49
  59. package/dist/components/forms/__tests__/Listbox.test.js +0 -303
  60. package/dist/components/forms/__tests__/MultiSelect.test.js +0 -281
  61. package/dist/components/forms/__tests__/SearchInput.test.js +0 -92
  62. package/dist/components/forms/__tests__/Select.test.js +0 -37
  63. package/dist/components/forms/__tests__/SignaturePad.test.js +0 -338
  64. package/dist/components/forms/__tests__/StagedControlReview.test.js +0 -702
  65. package/dist/components/forms/__tests__/Textarea.test.js +0 -39
  66. package/dist/components/forms/__tests__/Toggle.test.js +0 -87
  67. package/dist/components/forms/__tests__/camera-capture-session.test.js +0 -207
  68. package/dist/components/forms/__tests__/capture-form-retry.test.js +0 -166
  69. package/dist/components/forms/__tests__/capture-form.fixture.svelte +0 -38
  70. package/dist/components/forms/__tests__/capture-form.fixture.svelte.d.ts +0 -10
  71. package/dist/components/forms/__tests__/capture-form.fixture.svelte.d.ts.map +0 -1
  72. package/dist/components/forms/__tests__/capture-test-env.d.ts +0 -70
  73. package/dist/components/forms/__tests__/capture-test-env.d.ts.map +0 -1
  74. package/dist/components/forms/__tests__/capture-test-env.js +0 -122
  75. package/dist/components/forms/__tests__/capture-touch.fixture.svelte +0 -15
  76. package/dist/components/forms/__tests__/capture-touch.fixture.svelte.d.ts +0 -8
  77. package/dist/components/forms/__tests__/capture-touch.fixture.svelte.d.ts.map +0 -1
  78. package/dist/components/forms/__tests__/combobox-form.fixture.svelte +0 -29
  79. package/dist/components/forms/__tests__/combobox-form.fixture.svelte.d.ts +0 -14
  80. package/dist/components/forms/__tests__/combobox-form.fixture.svelte.d.ts.map +0 -1
  81. package/dist/components/forms/__tests__/combobox-labels.fixture.svelte +0 -19
  82. package/dist/components/forms/__tests__/combobox-labels.fixture.svelte.d.ts +0 -11
  83. package/dist/components/forms/__tests__/combobox-labels.fixture.svelte.d.ts.map +0 -1
  84. package/dist/components/forms/__tests__/composite-controls.fixture.svelte +0 -47
  85. package/dist/components/forms/__tests__/composite-controls.fixture.svelte.d.ts +0 -12
  86. package/dist/components/forms/__tests__/composite-controls.fixture.svelte.d.ts.map +0 -1
  87. package/dist/components/forms/__tests__/composite-controls.test.js +0 -128
  88. package/dist/components/forms/__tests__/composite-registration.fixture.svelte +0 -29
  89. package/dist/components/forms/__tests__/composite-registration.fixture.svelte.d.ts +0 -8
  90. package/dist/components/forms/__tests__/composite-registration.fixture.svelte.d.ts.map +0 -1
  91. package/dist/components/forms/__tests__/composite-user-edit.fixture.svelte +0 -41
  92. package/dist/components/forms/__tests__/composite-user-edit.fixture.svelte.d.ts +0 -13
  93. package/dist/components/forms/__tests__/composite-user-edit.fixture.svelte.d.ts.map +0 -1
  94. package/dist/components/forms/__tests__/control-interaction.test.js +0 -3421
  95. package/dist/components/forms/__tests__/control-proposals.test.js +0 -63
  96. package/dist/components/forms/__tests__/core-controls.fixture.svelte +0 -50
  97. package/dist/components/forms/__tests__/core-controls.fixture.svelte.d.ts +0 -9
  98. package/dist/components/forms/__tests__/core-controls.fixture.svelte.d.ts.map +0 -1
  99. package/dist/components/forms/__tests__/core-controls.test.js +0 -311
  100. package/dist/components/forms/__tests__/decimal-sliders.fixture.svelte +0 -25
  101. package/dist/components/forms/__tests__/decimal-sliders.fixture.svelte.d.ts +0 -8
  102. package/dist/components/forms/__tests__/decimal-sliders.fixture.svelte.d.ts.map +0 -1
  103. package/dist/components/forms/__tests__/dictation-recording.test.js +0 -582
  104. package/dist/components/forms/__tests__/dictation.test.js +0 -486
  105. package/dist/components/forms/__tests__/form-attachment.fixture.svelte +0 -28
  106. package/dist/components/forms/__tests__/form-attachment.fixture.svelte.d.ts +0 -11
  107. package/dist/components/forms/__tests__/form-attachment.fixture.svelte.d.ts.map +0 -1
  108. package/dist/components/forms/__tests__/form-group-input.fixture.svelte +0 -16
  109. package/dist/components/forms/__tests__/form-group-input.fixture.svelte.d.ts +0 -9
  110. package/dist/components/forms/__tests__/form-group-input.fixture.svelte.d.ts.map +0 -1
  111. package/dist/components/forms/__tests__/form-retry-form.fixture.svelte +0 -31
  112. package/dist/components/forms/__tests__/form-retry-form.fixture.svelte.d.ts +0 -13
  113. package/dist/components/forms/__tests__/form-retry-form.fixture.svelte.d.ts.map +0 -1
  114. package/dist/components/forms/__tests__/form-retry-form.test.js +0 -107
  115. package/dist/components/forms/__tests__/hidden-controls-form-retry.test.js +0 -69
  116. package/dist/components/forms/__tests__/hidden-controls-form.fixture.svelte +0 -29
  117. package/dist/components/forms/__tests__/hidden-controls-form.fixture.svelte.d.ts +0 -9
  118. package/dist/components/forms/__tests__/hidden-controls-form.fixture.svelte.d.ts.map +0 -1
  119. package/dist/components/forms/__tests__/listbox-form.fixture.svelte +0 -27
  120. package/dist/components/forms/__tests__/listbox-form.fixture.svelte.d.ts +0 -13
  121. package/dist/components/forms/__tests__/listbox-form.fixture.svelte.d.ts.map +0 -1
  122. package/dist/components/forms/__tests__/long-press.test.js +0 -175
  123. package/dist/components/forms/__tests__/multiselect-form.fixture.svelte +0 -27
  124. package/dist/components/forms/__tests__/multiselect-form.fixture.svelte.d.ts +0 -13
  125. package/dist/components/forms/__tests__/multiselect-form.fixture.svelte.d.ts.map +0 -1
  126. package/dist/components/forms/__tests__/native-file-field.test.js +0 -177
  127. package/dist/components/forms/__tests__/place-picker.fixture.svelte +0 -33
  128. package/dist/components/forms/__tests__/place-picker.fixture.svelte.d.ts +0 -12
  129. package/dist/components/forms/__tests__/place-picker.fixture.svelte.d.ts.map +0 -1
  130. package/dist/components/forms/__tests__/segmented-posting.fixture.svelte +0 -28
  131. package/dist/components/forms/__tests__/segmented-posting.fixture.svelte.d.ts +0 -12
  132. package/dist/components/forms/__tests__/segmented-posting.fixture.svelte.d.ts.map +0 -1
  133. package/dist/components/forms/__tests__/segmented-posting.test.js +0 -92
  134. package/dist/components/forms/__tests__/select-interaction.fixture.svelte +0 -25
  135. package/dist/components/forms/__tests__/select-interaction.fixture.svelte.d.ts +0 -9
  136. package/dist/components/forms/__tests__/select-interaction.fixture.svelte.d.ts.map +0 -1
  137. package/dist/components/forms/__tests__/signature-pad-logic.test.js +0 -54
  138. package/dist/components/forms/__tests__/staged-review-fieldset.fixture.svelte +0 -21
  139. package/dist/components/forms/__tests__/staged-review-fieldset.fixture.svelte.d.ts +0 -8
  140. package/dist/components/forms/__tests__/staged-review-fieldset.fixture.svelte.d.ts.map +0 -1
  141. package/dist/components/forms/__tests__/staged-review-outer-fieldset.fixture.svelte +0 -23
  142. package/dist/components/forms/__tests__/staged-review-outer-fieldset.fixture.svelte.d.ts +0 -8
  143. package/dist/components/forms/__tests__/staged-review-outer-fieldset.fixture.svelte.d.ts.map +0 -1
  144. package/dist/components/forms/__tests__/staged-review.fixture.svelte +0 -56
  145. package/dist/components/forms/__tests__/staged-review.fixture.svelte.d.ts +0 -12
  146. package/dist/components/forms/__tests__/staged-review.fixture.svelte.d.ts.map +0 -1
  147. package/dist/components/forms/__tests__/touch-density.fixture.svelte +0 -34
  148. package/dist/components/forms/__tests__/touch-density.fixture.svelte.d.ts +0 -8
  149. package/dist/components/forms/__tests__/touch-density.fixture.svelte.d.ts.map +0 -1
  150. package/dist/components/forms/__tests__/touch-density.test.js +0 -66
  151. package/dist/components/forms/form-retry/__tests__/boundaries.test.js +0 -23
  152. package/dist/components/forms/form-retry/__tests__/content-digest.test.js +0 -70
  153. package/dist/components/forms/form-retry/__tests__/controller.test.js +0 -802
  154. package/dist/components/forms/form-retry/__tests__/fake-kit.d.ts +0 -82
  155. package/dist/components/forms/form-retry/__tests__/fake-kit.d.ts.map +0 -1
  156. package/dist/components/forms/form-retry/__tests__/fake-kit.js +0 -180
  157. package/dist/components/forms/form-retry/__tests__/form-draft.test.js +0 -169
  158. package/dist/components/forms/form-retry/__tests__/ssr.test.js +0 -37
  159. package/dist/components/forms/form-retry/__tests__/storage.d.ts +0 -26
  160. package/dist/components/forms/form-retry/__tests__/storage.d.ts.map +0 -1
  161. package/dist/components/forms/form-retry/__tests__/storage.js +0 -63
  162. package/dist/components/forms/form-retry/__tests__/submission-key.test.js +0 -236
  163. package/dist/components/forms/form-retry/__tests__/submitted-draft.test.js +0 -334
  164. package/dist/components/layout/__tests__/Container.test.js +0 -62
  165. package/dist/components/layout/__tests__/EmptyState.test.js +0 -83
  166. package/dist/components/layout/__tests__/Footer.test.js +0 -50
  167. package/dist/components/layout/__tests__/Grid.test.js +0 -121
  168. package/dist/components/layout/__tests__/Header.test.js +0 -48
  169. package/dist/components/layout/__tests__/Masthead.test.js +0 -93
  170. package/dist/components/layout/__tests__/PageHeader.test.js +0 -166
  171. package/dist/components/layout/__tests__/SummaryCard.test.js +0 -104
  172. package/dist/components/nav/__tests__/FilterChips.test.js +0 -94
  173. package/dist/components/nav/__tests__/LinkTabs.test.js +0 -117
  174. package/dist/components/nav/__tests__/Tabs.test.js +0 -128
  175. package/dist/components/roles/__tests__/RoleSelector.test.js +0 -134
  176. package/dist/components/ui/__tests__/Badge.test.js +0 -76
  177. package/dist/components/ui/__tests__/Button.test.js +0 -166
  178. package/dist/components/ui/__tests__/Card.test.js +0 -103
  179. package/dist/components/ui/__tests__/IconToggle.test.js +0 -59
  180. package/dist/components/ui/__tests__/IconToggleGroup.test.js +0 -30
  181. package/dist/components/ui/__tests__/Pagination.test.js +0 -113
  182. package/dist/components/ui/__tests__/Popover.test.js +0 -44
  183. package/dist/components/ui/__tests__/dropdown-popover-icon.test.js +0 -125
  184. package/dist/components/ui/__tests__/gap-primitives-interactive.test.js +0 -112
  185. package/dist/components/ui/__tests__/gap-primitives.test.js +0 -84
  186. package/dist/components/ui/__tests__/interaction-primitives.fixture.svelte +0 -13
  187. package/dist/components/ui/__tests__/interaction-primitives.fixture.svelte.d.ts +0 -19
  188. package/dist/components/ui/__tests__/interaction-primitives.fixture.svelte.d.ts.map +0 -1
  189. package/dist/components/ui/__tests__/interaction-primitives.test.js +0 -31
  190. package/dist/components/ui/__tests__/phone-touch-targets.test.js +0 -39
  191. package/dist/i18n/__tests__/i18n.test.js +0 -74
  192. package/dist/i18n/__tests__/render-parity.spec.js +0 -37
  193. package/dist/svelte/__tests__/playground.test.js +0 -20
  194. package/dist/themes/__tests__/control-boundary-contrast.test.js +0 -112
  195. package/dist/themes/__tests__/create-theme.test.js +0 -79
  196. package/dist/themes/__tests__/css-generator.test.js +0 -129
  197. package/dist/themes/__tests__/happyvertical-theme.test.js +0 -231
  198. package/dist/themes/__tests__/registry.test.js +0 -43
  199. package/dist/themes/__tests__/styles-lockstep.test.js +0 -32
  200. package/dist/themes/__tests__/theme-provider.test.js +0 -147
  201. package/dist/themes/__tests__/theme-script.test.js +0 -130
  202. package/dist/themes/__tests__/token-aliases.test.js +0 -178
  203. package/dist/utils/forms/__tests__/formatters.test.js +0 -27
  204. package/dist/utils/theme/__tests__/color.test.js +0 -89
  205. package/dist/utils/theme/__tests__/typography.test.js +0 -11
@@ -1,82 +0,0 @@
1
- /**
2
- * A structural fake of SvelteKit's `use:enhance` and of a form action guarded
3
- * by `runOnce()`, for the form-retry tests.
4
- *
5
- * `fakeEnhance` follows `@sveltejs/kit` 2.x `enhance()`
6
- * (`src/runtime/app/forms.js`) step for step: build `FormData` from the form,
7
- * await the submit function with `cancel`/`controller`, stop if cancelled,
8
- * post, turn a thrown fetch into `{ type: 'error' }` (and return silently on
9
- * an `AbortError`), then call the returned callback — or the default one —
10
- * with an `update()` that resets the form on success unless `reset: false`
11
- * and then applies the result. "Applying" an error result is recorded as
12
- * `unmounted`, because kit's `applyAction` renders the error boundary and the
13
- * form goes with it.
14
- *
15
- * `fakeRunOnceServer` records rows the way an action using `runOnce()` does:
16
- * one claim per (key, content digest), replaying the stored row id for a
17
- * repeat. It digests with the same algorithm `runOnce()` uses.
18
- */
19
- import type { FormRetryActionResult, FormRetrySubmitFunction } from '../types.js';
20
- /** How the fake server answers one request. */
21
- export type ServerBehaviour = 'ok' | 'fail' | 'redirect'
22
- /** Commits the write, then the response is lost on the way back. */
23
- | 'lost-response'
24
- /** The request never reaches the server. */
25
- | 'unreachable';
26
- export interface FakeRunOnceServer {
27
- /** Rows written, in order. */
28
- rows: Array<{
29
- id: number;
30
- fields: Record<string, string[]>;
31
- }>;
32
- /** Every request that reached the action. */
33
- requests: FormData[];
34
- /** Queue behaviours for the next requests (default `ok`). */
35
- next(...behaviours: ServerBehaviour[]): void;
36
- /** Hold the next request until `release()` is called. */
37
- hold(): {
38
- release: () => void;
39
- };
40
- handle(formData: FormData, signal: AbortSignal): Promise<FormRetryActionResult>;
41
- }
42
- /** A form action whose write is guarded by a runOnce-style claim. */
43
- export declare function fakeRunOnceServer(keyField?: string): FakeRunOnceServer;
44
- export interface FakeEnhanced {
45
- /**
46
- * Submit the form as a click on its submit button would. `chosen` stands in
47
- * for the browser adding files picked in a file input (jsdom cannot set
48
- * `input.files`).
49
- */
50
- submit(chosen?: (formData: FormData) => void): Promise<void>;
51
- /** Abort controllers of submits in flight, in order. */
52
- controllers: AbortController[];
53
- /** Submits cancelled before sending. */
54
- cancelled: number;
55
- /** Results applied through `update()`/the default callback. */
56
- applied: FormRetryActionResult['type'][];
57
- /** Error results that, in kit, would render the error boundary. */
58
- unmounted: number;
59
- /** `update()` calls, with their options. */
60
- updates: Array<{
61
- reset?: boolean;
62
- invalidateAll?: boolean;
63
- } | undefined>;
64
- destroy(): void;
65
- }
66
- /** Wire `submit` to `form` the way `use:enhance={submit}` does. */
67
- export declare function fakeEnhance(form: HTMLFormElement, submit: FormRetrySubmitFunction, server: FakeRunOnceServer): FakeEnhanced;
68
- /**
69
- * `enhance` as the Svelte action SvelteKit exports: `(form, submit?)`, wired to
70
- * the form's real `submit` event (kit prevents the native submission and
71
- * handles it), so it can be attached through `fromAction(enhance, () =>
72
- * submit)` exactly as an app would. `settle()` awaits every submission the
73
- * action has started.
74
- */
75
- export declare function fakeEnhanceAction(server: FakeRunOnceServer): {
76
- action: (form: HTMLFormElement, submit?: FormRetrySubmitFunction) => {
77
- destroy(): void;
78
- };
79
- readonly enhanced: FakeEnhanced;
80
- settle(): Promise<void>;
81
- };
82
- //# sourceMappingURL=fake-kit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fake-kit.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/form-retry/__tests__/fake-kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,aAAa,CAAC;AAErB,+CAA+C;AAC/C,MAAM,MAAM,eAAe,GACvB,IAAI,GACJ,MAAM,GACN,UAAU;AACZ,oEAAoE;GAClE,eAAe;AACjB,4CAA4C;GAC1C,aAAa,CAAC;AAElB,MAAM,WAAW,iBAAiB;IAChC,8BAA8B;IAC9B,IAAI,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IAC9D,6CAA6C;IAC7C,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,6DAA6D;IAC7D,IAAI,CAAC,GAAG,UAAU,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IAC7C,yDAAyD;IACzD,IAAI,IAAI;QAAE,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;IAChC,MAAM,CACJ,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACnC;AAED,qEAAqE;AACrE,wBAAgB,iBAAiB,CAC/B,QAAQ,SAAkB,GACzB,iBAAiB,CA0DnB;AAED,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,wDAAwD;IACxD,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC;IACzC,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IACzE,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,mEAAmE;AACnE,wBAAgB,WAAW,CACzB,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,iBAAiB,GACxB,YAAY,CA+Dd;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG;IAC5D,MAAM,EAAE,CACN,IAAI,EAAE,eAAe,EACrB,MAAM,CAAC,EAAE,uBAAuB,KAC7B;QAAE,OAAO,IAAI,IAAI,CAAA;KAAE,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB,CA0BA"}
@@ -1,180 +0,0 @@
1
- /**
2
- * A structural fake of SvelteKit's `use:enhance` and of a form action guarded
3
- * by `runOnce()`, for the form-retry tests.
4
- *
5
- * `fakeEnhance` follows `@sveltejs/kit` 2.x `enhance()`
6
- * (`src/runtime/app/forms.js`) step for step: build `FormData` from the form,
7
- * await the submit function with `cancel`/`controller`, stop if cancelled,
8
- * post, turn a thrown fetch into `{ type: 'error' }` (and return silently on
9
- * an `AbortError`), then call the returned callback — or the default one —
10
- * with an `update()` that resets the form on success unless `reset: false`
11
- * and then applies the result. "Applying" an error result is recorded as
12
- * `unmounted`, because kit's `applyAction` renders the error boundary and the
13
- * form goes with it.
14
- *
15
- * `fakeRunOnceServer` records rows the way an action using `runOnce()` does:
16
- * one claim per (key, content digest), replaying the stored row id for a
17
- * repeat. It digests with the same algorithm `runOnce()` uses.
18
- */
19
- import { digestSubmissionContent } from '../content-digest.js';
20
- /** A form action whose write is guarded by a runOnce-style claim. */
21
- export function fakeRunOnceServer(keyField = 'submissionKey') {
22
- const claims = new Map();
23
- const rows = [];
24
- const requests = [];
25
- const queue = [];
26
- const holds = [];
27
- return {
28
- rows,
29
- requests,
30
- next(...behaviours) {
31
- queue.push(...behaviours);
32
- },
33
- hold() {
34
- let release;
35
- holds.push(new Promise((resolve) => {
36
- release = resolve;
37
- }));
38
- return { release };
39
- },
40
- async handle(formData, signal) {
41
- const behaviour = queue.shift() ?? 'ok';
42
- const held = holds.shift();
43
- if (held)
44
- await held;
45
- if (signal.aborted) {
46
- throw new DOMException('aborted', 'AbortError');
47
- }
48
- if (behaviour === 'unreachable')
49
- throw new TypeError('Failed to fetch');
50
- requests.push(formData);
51
- if (behaviour === 'fail')
52
- return { type: 'failure', status: 400 };
53
- const token = formData.get(keyField);
54
- if (typeof token !== 'string' || token === '') {
55
- throw new Error('the form posted no submission key');
56
- }
57
- const content = new FormData();
58
- formData.forEach((value, name) => {
59
- if (name !== keyField)
60
- content.append(name, value);
61
- });
62
- const claim = `${token}:${await digestSubmissionContent(content)}`;
63
- if (!claims.has(claim)) {
64
- const fields = {};
65
- content.forEach((value, name) => {
66
- const text = typeof value === 'string' ? value : `file:${value.name}`;
67
- fields[name] = [...(fields[name] ?? []), text];
68
- });
69
- const id = rows.length + 1;
70
- rows.push({ id, fields });
71
- claims.set(claim, id);
72
- }
73
- if (behaviour === 'lost-response')
74
- throw new TypeError('network dropped');
75
- if (behaviour === 'redirect') {
76
- return { type: 'redirect', status: 303, location: '/done' };
77
- }
78
- return { type: 'success', status: 200, data: { id: claims.get(claim) } };
79
- },
80
- };
81
- }
82
- /** Wire `submit` to `form` the way `use:enhance={submit}` does. */
83
- export function fakeEnhance(form, submit, server) {
84
- const action = new URL('http://localhost/report?/create');
85
- const state = {
86
- controllers: [],
87
- cancelled: 0,
88
- applied: [],
89
- unmounted: 0,
90
- updates: [],
91
- submit: (chosen) => handle(chosen),
92
- destroy: () => { },
93
- };
94
- async function fallback(result, reset = true) {
95
- if (result.type === 'success' && reset) {
96
- HTMLFormElement.prototype.reset.call(form);
97
- }
98
- state.applied.push(result.type);
99
- if (result.type === 'error')
100
- state.unmounted += 1;
101
- }
102
- async function handle(chosen) {
103
- const formData = new FormData(form);
104
- chosen?.(formData);
105
- const controller = new AbortController();
106
- let cancelled = false;
107
- const callback = (await submit({
108
- action,
109
- cancel: () => {
110
- cancelled = true;
111
- },
112
- controller,
113
- formData,
114
- formElement: form,
115
- submitter: null,
116
- })) ??
117
- (async ({ result }) => fallback(result));
118
- if (cancelled) {
119
- state.cancelled += 1;
120
- return;
121
- }
122
- state.controllers.push(controller);
123
- let result;
124
- try {
125
- result = await server.handle(formData, controller.signal);
126
- }
127
- catch (error) {
128
- if (error?.name === 'AbortError')
129
- return;
130
- result = { type: 'error', error };
131
- }
132
- await callback({
133
- action,
134
- formData,
135
- formElement: form,
136
- result,
137
- update: async (options) => {
138
- state.updates.push(options);
139
- await fallback(result, options?.reset);
140
- },
141
- });
142
- }
143
- return state;
144
- }
145
- /**
146
- * `enhance` as the Svelte action SvelteKit exports: `(form, submit?)`, wired to
147
- * the form's real `submit` event (kit prevents the native submission and
148
- * handles it), so it can be attached through `fromAction(enhance, () =>
149
- * submit)` exactly as an app would. `settle()` awaits every submission the
150
- * action has started.
151
- */
152
- export function fakeEnhanceAction(server) {
153
- const pending = [];
154
- let enhanced = null;
155
- return {
156
- action(form, submit = () => { }) {
157
- const state = fakeEnhance(form, submit, server);
158
- enhanced = state;
159
- const onSubmit = (event) => {
160
- event.preventDefault();
161
- pending.push(state.submit());
162
- };
163
- form.addEventListener('submit', onSubmit);
164
- return {
165
- destroy() {
166
- form.removeEventListener('submit', onSubmit);
167
- },
168
- };
169
- },
170
- get enhanced() {
171
- if (!enhanced)
172
- throw new Error('enhance was never attached');
173
- return enhanced;
174
- },
175
- async settle() {
176
- while (pending.length > 0)
177
- await pending.shift();
178
- },
179
- };
180
- }
@@ -1,169 +0,0 @@
1
- /**
2
- * The conditional reset that keeps a typed next entry alive (#3291).
3
- */
4
- import { describe, expect, it } from 'vitest';
5
- import { draftChanged, draftOf, formWasCleared } from '../form-draft.js';
6
- function formOf(html) {
7
- document.body.innerHTML = `<form>${html}</form>`;
8
- const form = document.body.querySelector('form');
9
- if (!form)
10
- throw new Error('no form');
11
- return form;
12
- }
13
- const ENTRY_FORM = `
14
- <input type="hidden" name="submissionKey" value="aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa" />
15
- <input type="text" name="reference" value="R-1" />
16
- <input type="text" name="grade" value="A36" />
17
- <textarea name="notes">from bay 2</textarea>
18
- <select name="unit"><option value="pcs" selected>pcs</option><option value="ft">ft</option></select>
19
- <select name="tags" multiple><option value="a" selected>a</option><option value="b">b</option></select>
20
- <input type="checkbox" name="urgent" />
21
- <button type="submit">Record</button>
22
- `;
23
- const field = (form, selector) => {
24
- const element = form.querySelector(selector);
25
- if (!element)
26
- throw new Error(`no ${selector}`);
27
- return element;
28
- };
29
- describe('draftChanged', () => {
30
- it('is false for a form nobody has touched', () => {
31
- const form = formOf(ENTRY_FORM);
32
- expect(draftChanged(form, draftOf(form))).toBe(false);
33
- });
34
- it('is true once any visible field is edited', () => {
35
- const form = formOf(ENTRY_FORM);
36
- const submitted = draftOf(form);
37
- field(form, '[name=reference]').value = 'R-2';
38
- expect(draftChanged(form, submitted)).toBe(true);
39
- });
40
- it('sees a textarea, a select, a multi-select and a checkbox', () => {
41
- const edits = [
42
- (form) => {
43
- field(form, 'textarea').value = 'from bay 3';
44
- },
45
- (form) => {
46
- field(form, '[name=unit]').value = 'ft';
47
- },
48
- (form) => {
49
- field(form, '[name=tags]').options[1].selected =
50
- true;
51
- },
52
- (form) => {
53
- field(form, '[name=urgent]').checked = true;
54
- },
55
- ];
56
- for (const edit of edits) {
57
- const form = formOf(ENTRY_FORM);
58
- const submitted = draftOf(form);
59
- edit(form);
60
- expect(draftChanged(form, submitted)).toBe(true);
61
- }
62
- });
63
- it('IGNORES the rotated hidden key, or nothing would ever reset', () => {
64
- const form = formOf(ENTRY_FORM);
65
- const submitted = draftOf(form);
66
- field(form, '[name=submissionKey]').value =
67
- 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb';
68
- expect(draftChanged(form, submitted)).toBe(false);
69
- });
70
- it('sees a hidden input a control posts through (a Listbox selection)', () => {
71
- const form = formOf(`${ENTRY_FORM}<input type="hidden" name="choice" value="a" />`);
72
- const submitted = draftOf(form);
73
- field(form, '[name=choice]').value = 'b';
74
- expect(draftChanged(form, submitted)).toBe(true);
75
- });
76
- it('ignores exactly the fields it is told to — the configured key field', () => {
77
- const form = formOf(`
78
- <input type="hidden" name="retryKey" value="k-1" />
79
- <input type="hidden" name="choice" value="a" />
80
- `);
81
- const ignore = new Set(['retryKey']);
82
- const submitted = draftOf(form, ignore);
83
- field(form, '[name=retryKey]').value = 'k-2';
84
- expect(draftChanged(form, submitted, ignore)).toBe(false);
85
- expect(formWasCleared(form, submitted, ignore)).toBe(true);
86
- field(form, '[name=choice]').value = 'b';
87
- expect(draftChanged(form, submitted, ignore)).toBe(true);
88
- });
89
- it('notices a field being cleared, a control removed, and a repeated name', () => {
90
- let form = formOf(ENTRY_FORM);
91
- let submitted = draftOf(form);
92
- field(form, '[name=grade]').value = '';
93
- expect(draftChanged(form, submitted)).toBe(true);
94
- form = formOf(ENTRY_FORM);
95
- submitted = draftOf(form);
96
- field(form, '[name=grade]').remove();
97
- expect(draftChanged(form, submitted)).toBe(true);
98
- form = formOf('<input name="qty" value="1" /><input name="qty" value="2" />');
99
- submitted = draftOf(form);
100
- form.querySelectorAll('[name=qty]')[1].value = '3';
101
- expect(draftChanged(form, submitted)).toBe(true);
102
- });
103
- });
104
- describe('formWasCleared', () => {
105
- it('is true only for a form still in the document and unchanged', () => {
106
- const form = formOf(ENTRY_FORM);
107
- expect(formWasCleared(form, draftOf(form))).toBe(true);
108
- const edited = formOf(ENTRY_FORM);
109
- const submitted = draftOf(edited);
110
- field(edited, '[name=reference]').value = 'R-2';
111
- expect(formWasCleared(edited, submitted)).toBe(false);
112
- });
113
- it('is false for a DETACHED form, however unchanged it looks', () => {
114
- const form = formOf(ENTRY_FORM);
115
- const submitted = draftOf(form);
116
- form.remove();
117
- expect(draftChanged(form, submitted)).toBe(false);
118
- expect(formWasCleared(form, submitted)).toBe(false);
119
- });
120
- });
121
- describe('posted files', () => {
122
- /** Browsers fire `formdata` while `new FormData(form)` builds; jsdom does not. */
123
- function fireFormDataOnConstruct() {
124
- const Native = globalThis.FormData;
125
- class BrowserFormData extends Native {
126
- constructor(form) {
127
- super(form);
128
- if (!form)
129
- return;
130
- const event = new Event('formdata');
131
- Object.defineProperty(event, 'formData', { value: this });
132
- form.dispatchEvent(event);
133
- }
134
- }
135
- globalThis.FormData = BrowserFormData;
136
- return () => {
137
- globalThis.FormData = Native;
138
- };
139
- }
140
- it('sees a file a formdata listener appends, though no element shows it', () => {
141
- const restore = fireFormDataOnConstruct();
142
- try {
143
- const form = formOf('<input type="file" hidden />');
144
- let file = new File(['first'], 'photo.jpg', {
145
- type: 'image/jpeg',
146
- });
147
- form.addEventListener('formdata', (event) => {
148
- const formData = event.formData;
149
- formData.append('photo', file ?? new File([], ''));
150
- });
151
- const submitted = draftOf(form);
152
- expect(draftChanged(form, submitted)).toBe(false);
153
- file = new File(['second photo'], 'photo.jpg', { type: 'image/jpeg' });
154
- expect(draftChanged(form, submitted)).toBe(true);
155
- file = null;
156
- expect(draftChanged(form, submitted)).toBe(true);
157
- }
158
- finally {
159
- restore();
160
- }
161
- });
162
- it('ignores the fresh "no file chosen" entry of an empty file input', async () => {
163
- const form = formOf('<input type="file" name="photo" />');
164
- const submitted = draftOf(form);
165
- // The empty entry is re-minted with a new lastModified on every build.
166
- await new Promise((resolve) => setTimeout(resolve, 5));
167
- expect(draftChanged(form, submitted)).toBe(false);
168
- });
169
- });
@@ -1,37 +0,0 @@
1
- /**
2
- * Off the browser (SSR), the helper must never share a key between requests:
3
- * no module-level memory, and not Node 25+'s process-wide `sessionStorage`
4
- * global either. The package's test setup needs jsdom, so SSR is simulated by
5
- * removing `window` — the signal the helper uses to tell it is off the browser.
6
- */
7
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
8
- import { createFormRetry } from '../controller.js';
9
- import { readSubmissionKey } from '../submission-key.js';
10
- import { memoryStorage } from './storage.js';
11
- beforeEach(() => {
12
- vi.stubGlobal('window', undefined);
13
- });
14
- afterEach(() => {
15
- vi.unstubAllGlobals();
16
- });
17
- describe('form retry during SSR', () => {
18
- it('mints an unshared key per read, never from a process-wide store', () => {
19
- const processWide = memoryStorage();
20
- vi.stubGlobal('sessionStorage', processWide);
21
- const one = readSubmissionKey({ form: 'po' });
22
- const two = readSubmissionKey({ form: 'po' });
23
- expect(one).not.toBe(two);
24
- expect(processWide.store.size).toBe(0);
25
- });
26
- it('creates a controller that renders a key and restores nothing', () => {
27
- const retry = createFormRetry({ form: 'po', restore: { owner: 'u1' } });
28
- expect(retry.token).toMatch(/^[0-9a-f-]{36}$/);
29
- expect(retry.restored).toBeNull();
30
- expect(retry.state).toMatchObject({
31
- status: 'idle',
32
- persistent: false,
33
- restored: false,
34
- });
35
- expect(createFormRetry({ form: 'po' }).token).not.toBe(retry.token);
36
- });
37
- });
@@ -1,26 +0,0 @@
1
- /**
2
- * Storage doubles for the form-retry tests: a working per-test store, one that
3
- * refuses everything (a private window), and one that reads but refuses writes
4
- * (a full quota).
5
- */
6
- import type { FormRetryStorage } from '../submission-key.js';
7
- /** A `sessionStorage` that behaves like the real one. */
8
- export declare function memoryStorage(): FormRetryStorage & {
9
- store: Map<string, string>;
10
- };
11
- /** Every access throws, as `sessionStorage` does in a private window. */
12
- export declare function refusingStorage(): FormRetryStorage;
13
- /** Reads work; writes throw `QuotaExceededError`. */
14
- export declare function fullStorage(): FormRetryStorage & {
15
- store: Map<string, string>;
16
- };
17
- /**
18
- * Reads work; `removeItem` throws, and so does `setItem` while `refuseWrites`
19
- * is set (a store that cannot let go of a value already in it). The flag can
20
- * be flipped mid-test to model a store that wrote earlier and refuses now.
21
- */
22
- export declare function stickyStorage(refuseWrites?: boolean): FormRetryStorage & {
23
- store: Map<string, string>;
24
- refuseWrites: boolean;
25
- };
26
- //# sourceMappingURL=storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/form-retry/__tests__/storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,yDAAyD;AACzD,wBAAgB,aAAa,IAAI,gBAAgB,GAAG;IAClD,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,CAYA;AAED,yEAAyE;AACzE,wBAAgB,eAAe,IAAI,gBAAgB,CAKlD;AAED,qDAAqD;AACrD,wBAAgB,WAAW,IAAI,gBAAgB,GAAG;IAChD,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,CAYA;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,YAAY,UAAQ,GAAG,gBAAgB,GAAG;IACtE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;CACvB,CAiBA"}
@@ -1,63 +0,0 @@
1
- /**
2
- * Storage doubles for the form-retry tests: a working per-test store, one that
3
- * refuses everything (a private window), and one that reads but refuses writes
4
- * (a full quota).
5
- */
6
- /** A `sessionStorage` that behaves like the real one. */
7
- export function memoryStorage() {
8
- const store = new Map();
9
- return {
10
- store,
11
- getItem: (key) => store.get(key) ?? null,
12
- setItem: (key, value) => {
13
- store.set(key, value);
14
- },
15
- removeItem: (key) => {
16
- store.delete(key);
17
- },
18
- };
19
- }
20
- /** Every access throws, as `sessionStorage` does in a private window. */
21
- export function refusingStorage() {
22
- const refuse = () => {
23
- throw new DOMException('The operation is insecure.', 'SecurityError');
24
- };
25
- return { getItem: refuse, setItem: refuse, removeItem: refuse };
26
- }
27
- /** Reads work; writes throw `QuotaExceededError`. */
28
- export function fullStorage() {
29
- const store = new Map();
30
- return {
31
- store,
32
- getItem: (key) => store.get(key) ?? null,
33
- setItem: () => {
34
- throw new DOMException('Quota exceeded', 'QuotaExceededError');
35
- },
36
- removeItem: (key) => {
37
- store.delete(key);
38
- },
39
- };
40
- }
41
- /**
42
- * Reads work; `removeItem` throws, and so does `setItem` while `refuseWrites`
43
- * is set (a store that cannot let go of a value already in it). The flag can
44
- * be flipped mid-test to model a store that wrote earlier and refuses now.
45
- */
46
- export function stickyStorage(refuseWrites = false) {
47
- const store = new Map();
48
- const storage = {
49
- store,
50
- refuseWrites,
51
- getItem: (key) => store.get(key) ?? null,
52
- setItem: (key, value) => {
53
- if (storage.refuseWrites) {
54
- throw new DOMException('Quota exceeded', 'QuotaExceededError');
55
- }
56
- store.set(key, value);
57
- },
58
- removeItem: () => {
59
- throw new DOMException('The operation is insecure.', 'SecurityError');
60
- },
61
- };
62
- return storage;
63
- }