cursedbelt 6.28.0 → 6.30.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 (107) hide show
  1. package/dist/react/canvas-hud/HudControls.d.ts +2 -0
  2. package/dist/react/canvas-hud/HudControls.d.ts.map +1 -1
  3. package/dist/react/canvas-hud/HudControls.js +3 -1
  4. package/dist/react/canvas-hud/HudControls.js.map +1 -1
  5. package/dist/react/components/ColorSwatches.d.ts.map +1 -1
  6. package/dist/react/components/ColorSwatches.js +1 -1
  7. package/dist/react/components/ColorSwatches.js.map +1 -1
  8. package/dist/react/components/DataTable/serverWindowWatch.d.ts +5 -4
  9. package/dist/react/components/DataTable/serverWindowWatch.d.ts.map +1 -1
  10. package/dist/react/components/DataTable/serverWindowWatch.js +7 -9
  11. package/dist/react/components/DataTable/serverWindowWatch.js.map +1 -1
  12. package/dist/react/components/ScrollArea.d.ts +9 -1
  13. package/dist/react/components/ScrollArea.d.ts.map +1 -1
  14. package/dist/react/components/ScrollArea.js +9 -3
  15. package/dist/react/components/ScrollArea.js.map +1 -1
  16. package/dist/react/components/TagsEditor.d.ts +12 -2
  17. package/dist/react/components/TagsEditor.d.ts.map +1 -1
  18. package/dist/react/components/TagsEditor.js +23 -8
  19. package/dist/react/components/TagsEditor.js.map +1 -1
  20. package/dist/react/index.d.ts +1 -0
  21. package/dist/react/index.d.ts.map +1 -1
  22. package/dist/react/index.js +1 -0
  23. package/dist/react/index.js.map +1 -1
  24. package/dist/react/lib/keepAsking.d.ts +30 -0
  25. package/dist/react/lib/keepAsking.d.ts.map +1 -0
  26. package/dist/react/lib/keepAsking.js +57 -0
  27. package/dist/react/lib/keepAsking.js.map +1 -0
  28. package/dist/react/lib/tagList.d.ts +15 -0
  29. package/dist/react/lib/tagList.d.ts.map +1 -1
  30. package/dist/react/lib/tagList.js +29 -0
  31. package/dist/react/lib/tagList.js.map +1 -1
  32. package/dist/react/map-frame/MapFrame.d.ts +11 -1
  33. package/dist/react/map-frame/MapFrame.d.ts.map +1 -1
  34. package/dist/react/map-frame/MapFrame.js +25 -2
  35. package/dist/react/map-frame/MapFrame.js.map +1 -1
  36. package/dist/react/map-frame/geo.d.ts +27 -0
  37. package/dist/react/map-frame/geo.d.ts.map +1 -1
  38. package/dist/react/map-frame/geo.js +38 -0
  39. package/dist/react/map-frame/geo.js.map +1 -1
  40. package/dist/react/map-frame/index.d.ts +4 -4
  41. package/dist/react/map-frame/index.d.ts.map +1 -1
  42. package/dist/react/map-frame/index.js +2 -2
  43. package/dist/react/map-frame/index.js.map +1 -1
  44. package/dist/react/media/DenseGalleryShell.d.ts +7 -1
  45. package/dist/react/media/DenseGalleryShell.d.ts.map +1 -1
  46. package/dist/react/media/DenseGalleryShell.js +2 -2
  47. package/dist/react/media/DenseGalleryShell.js.map +1 -1
  48. package/dist/react/media-gallery/GalleryTable.d.ts +12 -1
  49. package/dist/react/media-gallery/GalleryTable.d.ts.map +1 -1
  50. package/dist/react/media-gallery/GalleryTable.js +37 -6
  51. package/dist/react/media-gallery/GalleryTable.js.map +1 -1
  52. package/dist/react/media-gallery/MediaGallery.d.ts +39 -3
  53. package/dist/react/media-gallery/MediaGallery.d.ts.map +1 -1
  54. package/dist/react/media-gallery/MediaGallery.js +122 -12
  55. package/dist/react/media-gallery/MediaGallery.js.map +1 -1
  56. package/dist/react/media-gallery/index.d.ts +1 -1
  57. package/dist/react/media-gallery/index.d.ts.map +1 -1
  58. package/dist/react/media-gallery/index.js.map +1 -1
  59. package/dist/react/media-gallery/mediaGallery.css +16 -0
  60. package/dist/react/usePrefixList.d.ts +82 -0
  61. package/dist/react/usePrefixList.d.ts.map +1 -0
  62. package/dist/react/usePrefixList.js +139 -0
  63. package/dist/react/usePrefixList.js.map +1 -0
  64. package/dist/styles-areas/core.css +8 -4
  65. package/dist/styles-utilities.css +18 -0
  66. package/dist/testing/shell.d.ts +1 -0
  67. package/dist/testing/shell.d.ts.map +1 -1
  68. package/dist/testing/shell.js +2 -0
  69. package/dist/testing/shell.js.map +1 -1
  70. package/package.json +9 -3
  71. package/scripts/build.spec.ts +39 -0
  72. package/scripts/build.ts +131 -0
  73. package/scripts/styleAreas.ts +2 -0
  74. package/src/buildIsStaged.spec.ts +57 -47
  75. package/src/react/canvas-hud/HudControls.spec.tsx +13 -1
  76. package/src/react/canvas-hud/HudControls.tsx +3 -1
  77. package/src/react/components/ColorSwatches.tsx +5 -1
  78. package/src/react/components/DataTable/serverWindowWatch.ts +8 -9
  79. package/src/react/components/ScrollArea.spec.tsx +25 -0
  80. package/src/react/components/ScrollArea.tsx +18 -1
  81. package/src/react/components/TagsEditor.spec.tsx +66 -0
  82. package/src/react/components/TagsEditor.tsx +31 -7
  83. package/src/react/index.ts +6 -0
  84. package/src/react/lib/keepAsking.spec.ts +89 -0
  85. package/src/react/lib/keepAsking.ts +63 -0
  86. package/src/react/lib/tagList.spec.ts +23 -1
  87. package/src/react/lib/tagList.ts +33 -0
  88. package/src/react/map-frame/MapFrame.tsx +33 -0
  89. package/src/react/map-frame/MapFrame.wheel.spec.tsx +69 -0
  90. package/src/react/map-frame/geo.spec.ts +32 -0
  91. package/src/react/map-frame/geo.ts +54 -0
  92. package/src/react/map-frame/index.ts +5 -2
  93. package/src/react/media/DenseGalleryShell.tsx +8 -0
  94. package/src/react/media-gallery/GalleryTable.tsx +54 -6
  95. package/src/react/media-gallery/MediaGallery.spec.tsx +61 -0
  96. package/src/react/media-gallery/MediaGallery.tsx +170 -12
  97. package/src/react/media-gallery/index.ts +1 -0
  98. package/src/react/media-gallery/mediaGallery.css +16 -0
  99. package/src/react/usePrefixList.spec.tsx +156 -0
  100. package/src/react/usePrefixList.ts +229 -0
  101. package/src/styles-areas/core.css +8 -4
  102. package/src/styles-utilities.css +18 -0
  103. package/src/stylesAreas.spec.ts +2 -1
  104. package/src/stylesStaticMatches.spec.ts +2 -3
  105. package/src/stylesUtilitiesMatches.spec.ts +2 -3
  106. package/src/testing/shell.ts +2 -0
  107. package/src/verifyGraph.spec.ts +22 -6
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, mock, test } from 'bun:test';
2
2
  import { cleanup, fireEvent, render } from '@testing-library/react';
3
3
  import { CanvasMinimap } from './CanvasMinimap.js';
4
4
  import { CanvasSearchField } from './CanvasSearchField.js';
5
- import { HudButton, HudZoomControls } from './HudControls.js';
5
+ import { CanvasZoomHint, HudButton, HudZoomControls } from './HudControls.js';
6
6
  import { readWheel } from './useCanvasWheel.js';
7
7
 
8
8
  afterEach(cleanup);
@@ -169,3 +169,15 @@ describe('readWheel (CNV-1: one gesture, one meaning)', () => {
169
169
  expect(readWheel('embedded', wheel())).toBe('page');
170
170
  });
171
171
  });
172
+
173
+ describe('CanvasZoomHint (CNV-1)', () => {
174
+ test('neither the overlay nor its pill takes a pointer, so a hidden hint never covers what is under it', () => {
175
+ const { getByTestId } = render(<CanvasZoomHint show={false} />);
176
+ const hint = getByTestId('canvas-zoom-hint');
177
+ expect(hint.getAttribute('aria-hidden')).toBe('true');
178
+ expect(hint.className).toContain('pointer-events-none');
179
+ const pill = hint.firstElementChild as HTMLElement;
180
+ expect(pill.className).toContain('pointer-events-none');
181
+ expect(pill.className).not.toContain('pointer-events-auto');
182
+ });
183
+ });
@@ -136,6 +136,8 @@ export interface CanvasZoomHintProps {
136
136
  /**
137
137
  * CNV-1's "Hold ⌘ to zoom" — what an embedded canvas says when a plain wheel scrolled the page
138
138
  * instead of zooming it, the way an embedded Google Map does. Says Ctrl off a Mac.
139
+ * 🔴 The pill is `pointer-events-none` too: HudPill defaults to `pointer-events-auto`, and a hidden pill left so sat
140
+ * over the canvas's middle, taking every click and wheel aimed there (photos' pin at the map's center).
139
141
  */
140
142
  export function CanvasZoomHint({ show, className, ...rest }: CanvasZoomHintProps) {
141
143
  const kt = useKeyText();
@@ -150,7 +152,7 @@ export function CanvasZoomHint({ show, className, ...rest }: CanvasZoomHintProps
150
152
  className,
151
153
  )}
152
154
  >
153
- <HudPill className='px-3 py-1.5 text-sm'>Hold {kt('$mod')} to zoom</HudPill>
155
+ <HudPill className='pointer-events-none px-3 py-1.5 text-sm'>Hold {kt('$mod')} to zoom</HudPill>
154
156
  </div>
155
157
  );
156
158
  }
@@ -64,8 +64,12 @@ export function ColorSwatches({
64
64
  if (well.current && wellHex && well.current.value !== wellHex) well.current.value = wellHex;
65
65
  }, [wellHex]);
66
66
  return (
67
- <div {...rest} data-slot='color-swatches' className={cn('flex flex-wrap items-center gap-1.5', className)}>
67
+ // No wrap on the outer row (task 5729): when the presets do not fit, THEY wrap among
68
+ // themselves (`min-w-0` lets the picker shrink below its one-row width) and the well stays at
69
+ // the end of the first row — a wrapping outer row dropped the well alone onto a row of its own.
70
+ <div {...rest} data-slot='color-swatches' className={cn('flex items-start gap-1.5', className)}>
68
71
  <SwatchPicker
72
+ className='min-w-0'
69
73
  aria-label={ariaLabel}
70
74
  size={size}
71
75
  options={presets.map((color) => ({ value: color.toLowerCase(), color, label: color }))}
@@ -20,6 +20,8 @@
20
20
  * request answers it), which is the contract `onReachEnd` always had.
21
21
  */
22
22
 
23
+ import { RETRY_CEILING_MS, RETRY_FIRST_MS, retryDelayMs } from '../../lib/keepAsking.js';
24
+
23
25
  /** What is on screen, as absolute row numbers over the whole result set; `last` is EXCLUSIVE. */
24
26
  export interface ShownRows {
25
27
  first: number;
@@ -48,17 +50,14 @@ export function windowAsk(shown: ShownRows, loaded: LoadedWindow): WindowAsk {
48
50
  return null;
49
51
  }
50
52
 
51
- /** The first re-ask waits this long — longer than a healthy window takes to arrive, so a request
52
- * still on its way is not asked for twice. */
53
- export const WINDOW_RETRY_FIRST_MS = 2_000;
54
- /** …doubling to this, and holding there for as long as the placeholders stay up. */
55
- export const WINDOW_RETRY_CEILING_MS = 30_000;
53
+ /** The pacing is `cursedbelt/react/keep-asking`'s, so a table's rows and a page's first load re-ask alike:
54
+ * 2 s (longer than a healthy window takes to arrive, so a request still on its way is not asked for
55
+ * twice), doubling to 30 s and holding there for as long as the placeholders stay up. */
56
+ export const WINDOW_RETRY_FIRST_MS = RETRY_FIRST_MS;
57
+ export const WINDOW_RETRY_CEILING_MS = RETRY_CEILING_MS;
56
58
 
57
59
  /** The pause before the `attempt`-th re-ask (1-based): 2 s, 4 s, 8 s, 16 s, then 30 s for good. */
58
- export function windowRetryDelayMs(attempt: number): number {
59
- const n = Number.isFinite(attempt) ? Math.max(1, Math.floor(attempt)) : 1;
60
- return Math.min(WINDOW_RETRY_CEILING_MS, WINDOW_RETRY_FIRST_MS * 2 ** (n - 1));
61
- }
60
+ export const windowRetryDelayMs = retryDelayMs;
62
61
 
63
62
  /** The first and one-past-last rows inside `[top, bottom)` — what `onChange` and the watch both read. */
64
63
  export function shownRows(items: readonly { index: number; start: number; end: number }[], top: number, bottom: number): ShownRows | null {
@@ -124,6 +124,31 @@ describe('ScrollArea height — a bounded region by token (LAY-8, task 2461)', (
124
124
  expect(el?.className).not.toContain('flex-1');
125
125
  });
126
126
 
127
+ test.each(['sm', 'md', 'lg'] as const)('%s with fit makes the token a ceiling, so a short list shrinks (task 5676)', (h) => {
128
+ const { container } = render(
129
+ <ScrollArea height={h} fit>
130
+ x
131
+ </ScrollArea>,
132
+ );
133
+ const el = scrollDiv(container);
134
+ expect(el?.dataset.cbRegionHeight).toBe(h);
135
+ expect(el?.dataset.cbRegionFit).toBe('');
136
+ expect(el?.className).toContain(`max-h-[min(var(--region-h-${h}),var(--region-h-phone))]`);
137
+ expect(el?.className).toContain(`sm:max-h-[var(--region-h-${h})]`);
138
+ // No fixed height: the box takes the list's own height under the ceiling.
139
+ expect(el?.className.split(/\s+/).some((c) => /^(sm:)?h-\[/.test(c))).toBe(false);
140
+ expect(el?.className).toContain('flex-none');
141
+ expect(el?.className).not.toContain('flex-1');
142
+ });
143
+
144
+ test('fit without a height changes nothing', () => {
145
+ const { container } = render(<ScrollArea fit>x</ScrollArea>);
146
+ const el = scrollDiv(container);
147
+ expect(el?.dataset.cbRegionFit).toBeUndefined();
148
+ expect(el?.className).toContain('flex-1');
149
+ expect(el?.className).not.toContain('max-h-');
150
+ });
151
+
127
152
  test('unset, the area fills its flex parent as before', () => {
128
153
  const { container } = render(<ScrollArea>x</ScrollArea>);
129
154
  const el = scrollDiv(container);
@@ -75,6 +75,14 @@ export interface ScrollAreaProps extends Omit<HTMLAttributes<HTMLDivElement>, 's
75
75
  * `--region-h-phone` (60dvh) on a phone. Unset, the area fills its flex parent.
76
76
  */
77
77
  height?: ScrollAreaHeight;
78
+ /**
79
+ * With `height`, make the token a CEILING instead of a fixed box: a short list takes
80
+ * its own height and a long one stops at the token and scrolls (task 5676). Use it for
81
+ * a list that is often short (a merge plan's few rows); leave it off for a feed or log
82
+ * that fills over time, where a steady box keeps the page from jumping as rows arrive.
83
+ * No effect without `height`.
84
+ */
85
+ fit?: boolean;
78
86
  className?: string;
79
87
  }
80
88
 
@@ -87,6 +95,13 @@ const REGION_HEIGHT: Record<ScrollAreaHeight, string> = {
87
95
  lg: 'flex-none h-[min(var(--region-h-lg),var(--region-h-phone))] sm:h-[var(--region-h-lg)]',
88
96
  };
89
97
 
98
+ // The same tokens as a ceiling (`fit`): the box shrinks to a short list.
99
+ const REGION_MAX_HEIGHT: Record<ScrollAreaHeight, string> = {
100
+ sm: 'flex-none max-h-[min(var(--region-h-sm),var(--region-h-phone))] sm:max-h-[var(--region-h-sm)]',
101
+ md: 'flex-none max-h-[min(var(--region-h-md),var(--region-h-phone))] sm:max-h-[var(--region-h-md)]',
102
+ lg: 'flex-none max-h-[min(var(--region-h-lg),var(--region-h-phone))] sm:max-h-[var(--region-h-lg)]',
103
+ };
104
+
90
105
  /**
91
106
  * THE single keyboard-/safe-area-aware scroll container — the ONLY way to make a
92
107
  * scroll region in cursedbelt.
@@ -120,6 +135,7 @@ export function ScrollArea({
120
135
  scrollRef,
121
136
  fade = false,
122
137
  height,
138
+ fit = false,
123
139
  className,
124
140
  ...rest
125
141
  }: ScrollAreaProps) {
@@ -149,6 +165,7 @@ export function ScrollArea({
149
165
  }}
150
166
  data-cb-scrollarea=''
151
167
  data-cb-region-height={height}
168
+ data-cb-region-fit={height && fit ? '' : undefined}
152
169
  data-cb-scroll-fade={fade ? (mask ? 'on' : 'idle') : undefined}
153
170
  onFocusCapture={onFocusCapture}
154
171
  style={style}
@@ -170,7 +187,7 @@ export function ScrollArea({
170
187
  axis === 'x' && 'overflow-x-auto',
171
188
  // guardrails-ignore no-raw-overflow: this IS the ScrollArea primitive.
172
189
  axis === 'both' && 'overflow-auto',
173
- height && REGION_HEIGHT[height],
190
+ height && (fit ? REGION_MAX_HEIGHT[height] : REGION_HEIGHT[height]),
174
191
  className,
175
192
  )}
176
193
  >
@@ -0,0 +1,66 @@
1
+ /**
2
+ * A TYPED tag goes through the app's spelling rule and its refusal, exactly as a pasted one does
3
+ * (forge task 5798): photos' owner got a chip "007" the server then answered with a bare "bad tag",
4
+ * because only a paste was normalized.
5
+ */
6
+ import { afterEach, describe, expect, jest, spyOn, test } from 'bun:test';
7
+ import { cleanup, fireEvent, render } from '@testing-library/react';
8
+ import { toast } from '../Toast.js';
9
+ import { TagsEditor } from './TagsEditor.js';
10
+
11
+ afterEach(() => {
12
+ cleanup();
13
+ jest.restoreAllMocks();
14
+ });
15
+
16
+ const lower = (raw: string) => raw.trim().toLowerCase();
17
+ const whyNot = (raw: string) => (raw.trim().length < 2 ? `“${raw.trim()}” is one character — a tag needs at least two` : null);
18
+
19
+ function mount(value: string[], props: Partial<Parameters<typeof TagsEditor>[0]> = {}) {
20
+ const onChange = jest.fn();
21
+ const error = spyOn(toast, 'error').mockImplementation(() => '' as never);
22
+ const view = render(<TagsEditor value={value} onChange={onChange} aria-label='Tags' {...props} />);
23
+ const input = view.getByLabelText('Tags') as HTMLInputElement;
24
+ const type = (text: string) => {
25
+ fireEvent.change(input, { target: { value: text } });
26
+ fireEvent.keyDown(input, { key: 'Enter' });
27
+ };
28
+ return { onChange, error, input, type };
29
+ }
30
+
31
+ describe('TagsEditor — a typed tag is checked, not only a paste', () => {
32
+ test('a typed tag is respelled by normalize before it becomes a chip', () => {
33
+ const { onChange, error, type } = mount(['Kept'], { normalize: lower, whyNot });
34
+ type('Boats');
35
+ expect(onChange).toHaveBeenCalledWith(['Kept', 'boats']);
36
+ expect(error).not.toHaveBeenCalled();
37
+ });
38
+
39
+ test('a typed tag whyNot refuses never becomes a chip, and the toast says why', () => {
40
+ const { onChange, error, type } = mount(['kept'], { normalize: lower, whyNot });
41
+ type('x');
42
+ expect(onChange).not.toHaveBeenCalled();
43
+ expect(error).toHaveBeenCalledWith('“x” is one character — a tag needs at least two');
44
+ });
45
+
46
+ test('a typed tag normalize answers "" for is refused with the default reason', () => {
47
+ const { onChange, error, type } = mount([], { normalize: (raw) => raw.replace(/[^a-z]/gi, '') });
48
+ type('007');
49
+ expect(onChange).not.toHaveBeenCalled();
50
+ expect(error).toHaveBeenCalledWith('“007” can\'t be a tag');
51
+ });
52
+
53
+ test('a paste is refused the same way, in one toast', () => {
54
+ const { onChange, error, input } = mount(['kept'], { normalize: lower, whyNot });
55
+ fireEvent.paste(input, { clipboardData: { getData: () => 'Sea, x, y' } });
56
+ expect(onChange).toHaveBeenCalledWith(['kept', 'sea']);
57
+ expect(error).toHaveBeenCalledTimes(1);
58
+ expect(error.mock.calls[0]![0]).toStartWith('2 tags left out — ');
59
+ });
60
+
61
+ test('removing a chip still reaches onChange', () => {
62
+ const { onChange } = mount(['a', 'bb'], { normalize: lower, whyNot });
63
+ fireEvent.click(document.querySelector('button[aria-label^="Remove"]') as HTMLButtonElement);
64
+ expect(onChange).toHaveBeenCalledTimes(1);
65
+ });
66
+ });
@@ -14,7 +14,7 @@ import { Copy } from 'lucide-react';
14
14
  import { type ClipboardEvent, type ComponentPropsWithoutRef, type KeyboardEvent, useEffect, useState } from 'react';
15
15
  import { toast } from '../Toast.js';
16
16
  import { cn } from '../lib/cn.js';
17
- import { mergeTagLists, parseTagList, tagListText } from '../lib/tagList.js';
17
+ import { acceptTagList, mergeTagLists, parseTagList, tagListText } from '../lib/tagList.js';
18
18
  import { useKeyText } from '../workspace-shell/keyChoice.js';
19
19
  import { IconButton } from './IconButton.js';
20
20
  import { TagsInput } from './TagsInput.js';
@@ -27,8 +27,18 @@ export interface TagsEditorProps
27
27
  placeholder?: string;
28
28
  'aria-label'?: string;
29
29
  className?: string;
30
- /** The app's one spelling rule for a pasted tag (photos lower-cases and folds synonyms). Default: trim. */
30
+ /**
31
+ * The app's one spelling rule for a tag (photos lower-cases and folds synonyms). Default: trim.
32
+ * Every tag a commit ADDS — typed with Enter or a comma, or pasted — is spelled by it before it
33
+ * becomes a chip, so the chip reads what the app keeps; one it turns into "" is refused.
34
+ */
31
35
  normalize?: (raw: string) => string;
36
+ /**
37
+ * Why a tag cannot be one, or null when it can — said in an error toast when a typed or pasted
38
+ * tag is refused. Asked before `normalize`. Default: “<raw>” can't be a tag (when `normalize`
39
+ * answers "").
40
+ */
41
+ whyNot?: (raw: string) => string | null;
32
42
  /** What the tags are on, for the copy toast and tooltip: "paste them onto another {item}". Default `item`. */
33
43
  item?: string;
34
44
  }
@@ -55,6 +65,7 @@ export function TagsEditor({
55
65
  'aria-label': ariaLabel = 'Tags',
56
66
  className,
57
67
  normalize,
68
+ whyNot,
58
69
  item = 'item',
59
70
  ...rest
60
71
  }: TagsEditorProps) {
@@ -95,14 +106,27 @@ export function TagsEditor({
95
106
  event.preventDefault();
96
107
  copied(picked.length);
97
108
  };
109
+ /** One toast for whatever a commit refused: the reason, or the first reason and how many more. */
110
+ const refuse = (refused: readonly string[]): void => {
111
+ if (!refused.length) return;
112
+ toast.error(refused.length === 1 ? refused[0]! : `${refused.length} tags left out — ${refused[0]}, and more`);
113
+ };
114
+ // Every commit TagsInput makes (Enter, a comma, a removed chip) is checked here, so a typed tag is
115
+ // spelled and refused exactly as a pasted one is (forge task 5798).
116
+ const change = (next: string[]): void => {
117
+ const { tags, refused } = acceptTagList(value, next, normalize, whyNot);
118
+ refuse(refused);
119
+ if (tags.length !== value.length || tags.some((tag, i) => tag !== value[i])) onChange(tags);
120
+ };
98
121
  const onPaste = (event: ClipboardEvent<HTMLDivElement>): void => {
99
122
  if ((event.target as HTMLElement).tagName !== 'INPUT') return;
100
- const pasted = parseTagList(event.clipboardData.getData('text/plain'), normalize);
123
+ const pasted = parseTagList(event.clipboardData.getData('text/plain'));
101
124
  if (!pasted.length) return;
102
125
  event.preventDefault();
103
- const next = mergeTagLists(value, pasted);
104
- if (next.length !== value.length) onChange(next);
105
- else toast.success(`Every pasted tag is on it already`);
126
+ const { tags, refused } = acceptTagList(value, mergeTagLists(value, pasted), normalize, whyNot);
127
+ refuse(refused);
128
+ if (tags.length !== value.length) onChange(tags);
129
+ else if (!refused.length) toast.success(`Every pasted tag is on it already`);
106
130
  };
107
131
 
108
132
  return (
@@ -118,7 +142,7 @@ export function TagsEditor({
118
142
  >
119
143
  <div className='flex items-start gap-1'>
120
144
  <div className={cn('min-w-0 flex-1 rounded-field', all && 'ring-2 ring-accent ring-offset-2 ring-offset-background')}>
121
- <TagsInput value={value} onChange={onChange} placeholder={placeholder} aria-label={ariaLabel} suggestions={suggestions} />
145
+ <TagsInput value={value} onChange={change} placeholder={placeholder} aria-label={ariaLabel} suggestions={suggestions} />
122
146
  </div>
123
147
  <IconButton
124
148
  label='Copy all tags'
@@ -1020,6 +1020,12 @@ export {
1020
1020
  type UsePagedListOptions,
1021
1021
  usePagedList,
1022
1022
  } from './usePagedList.js';
1023
+ export {
1024
+ type PrefixList,
1025
+ type PrefixListWindow,
1026
+ type UsePrefixListOptions,
1027
+ usePrefixList,
1028
+ } from './usePrefixList.js';
1023
1029
  export {
1024
1030
  type UseWindowedListOptions,
1025
1031
  useWindowedList,
@@ -0,0 +1,89 @@
1
+ /**
2
+ * keepAsking (forge task 5643, moved from music): the owner's music library
3
+ * went stale mid-session because a failed load was dropped and nothing asked twice.
4
+ */
5
+ import { afterEach, beforeEach, describe, expect, jest, test } from "bun:test";
6
+ import { keepAsking, retryDelayMs } from "./keepAsking.js";
7
+
8
+ beforeEach(() => {
9
+ jest.useFakeTimers();
10
+ });
11
+ afterEach(() => {
12
+ jest.useRealTimers();
13
+ });
14
+
15
+ /** Let a settled promise's handlers run. */
16
+ const tick = async (): Promise<void> => {
17
+ for (let i = 0; i < 5; i++) await Promise.resolve();
18
+ };
19
+
20
+ describe("keepAsking", () => {
21
+ test("🔴 a failed ask is asked again on the pause, and stops once one answers", async () => {
22
+ const outcomes = [false, false, true];
23
+ let asks = 0;
24
+ keepAsking(async () => {
25
+ const ok = outcomes[asks++];
26
+ if (!ok) throw new Error("ERR_HTTP2_PROTOCOL_ERROR");
27
+ }, new EventTarget());
28
+ await tick();
29
+ expect(asks).toBe(1);
30
+ jest.advanceTimersByTime(retryDelayMs(1));
31
+ await tick();
32
+ expect(asks).toBe(2);
33
+ jest.advanceTimersByTime(retryDelayMs(2));
34
+ await tick();
35
+ expect(asks).toBe(3);
36
+ jest.advanceTimersByTime(60_000);
37
+ await tick();
38
+ expect(asks, "an answered ask was asked again").toBe(3);
39
+ });
40
+
41
+ test("the network coming back asks at once", async () => {
42
+ const target = new EventTarget();
43
+ let asks = 0;
44
+ keepAsking(async () => {
45
+ asks += 1;
46
+ if (asks === 1) throw new Error("offline");
47
+ }, target);
48
+ await tick();
49
+ target.dispatchEvent(new Event("online"));
50
+ await tick();
51
+ expect(asks).toBe(2);
52
+ });
53
+
54
+ test("canceled, it asks no more and tells the ask out to throw its answer away", async () => {
55
+ let asks = 0;
56
+ let seenCanceled: (() => boolean) | null = null;
57
+ const stop = keepAsking(async (canceled) => {
58
+ asks += 1;
59
+ seenCanceled = canceled;
60
+ throw new Error("down");
61
+ }, new EventTarget());
62
+ await tick();
63
+ stop();
64
+ jest.advanceTimersByTime(60_000);
65
+ await tick();
66
+ expect(asks).toBe(1);
67
+ expect((seenCanceled as (() => boolean) | null)?.()).toBe(true);
68
+ });
69
+
70
+ test("the pause doubles from 2 s and holds at 30 s", () => {
71
+ expect([1, 2, 3, 4, 5, 9].map(retryDelayMs)).toEqual([2_000, 4_000, 8_000, 16_000, 30_000, 30_000]);
72
+ expect(retryDelayMs(Number.NaN)).toBe(2_000);
73
+ });
74
+ });
75
+
76
+ test("a resolved answer — even an empty one — ends the asking and stops listening for the network", async () => {
77
+ jest.useFakeTimers();
78
+ const target = new EventTarget();
79
+ let asks = 0;
80
+ keepAsking(async () => {
81
+ asks += 1;
82
+ return null;
83
+ }, target);
84
+ await tick();
85
+ target.dispatchEvent(new Event("online"));
86
+ jest.advanceTimersByTime(60_000);
87
+ await tick();
88
+ expect(asks).toBe(1);
89
+ });
@@ -0,0 +1,63 @@
1
+ /**
2
+ * `cursedbelt/react/keep-asking` — ask until it answers: a request that failed is asked again on a
3
+ * doubling pause, and at once when the network comes back (forge task 5643; moved here from music so
4
+ * collections and the next app share one copy).
5
+ *
6
+ * 2026-11-19, the owner: music's library *"all of a sudden"* stale or empty mid-session after a
7
+ * burst of `ERR_HTTP2_PROTOCOL_ERROR`, because page one of the view was asked for ONCE and a failure
8
+ * was dropped. The same mistake read a reset stream as "this item has no media" in collections'
9
+ * compare panel. A rejection is a dropped connection, not an answer: ask again. A RESOLVED answer —
10
+ * even an empty one — is the truth, and ends the asking.
11
+ *
12
+ * DataTable's server window re-asks rows on the same pacing (`windowRetryDelayMs` is this
13
+ * `retryDelayMs`).
14
+ */
15
+
16
+ /** The first re-ask waits this long — longer than a healthy request takes, so one still on its way is not asked twice. */
17
+ export const RETRY_FIRST_MS = 2_000;
18
+ /** …doubling to this, and holding there for good. */
19
+ export const RETRY_CEILING_MS = 30_000;
20
+
21
+ /** The pause before the `attempt`-th re-ask (1-based): 2 s, 4 s, 8 s, 16 s, then 30 s for good. */
22
+ export function retryDelayMs(attempt: number): number {
23
+ const n = Number.isFinite(attempt) ? Math.max(1, Math.floor(attempt)) : 1;
24
+ return Math.min(RETRY_CEILING_MS, RETRY_FIRST_MS * 2 ** (n - 1));
25
+ }
26
+
27
+ /** What `keepAsking` listens on for the network coming back — `window` in a page, anything with the two methods in a test. */
28
+ export type OnlineTarget = Pick<EventTarget, 'addEventListener' | 'removeEventListener'>;
29
+
30
+ /**
31
+ * Run `ask` now, and again after each rejection until one resolves or the returned canceler runs.
32
+ * `ask` gets whether it has been canceled, so a late answer can be thrown away rather than shown.
33
+ * A retry that is WAITING is brought forward when the network comes back; one already out is left
34
+ * to answer. Cancel on unmount and whenever what is being asked for changes.
35
+ */
36
+ export function keepAsking(ask: (canceled: () => boolean) => Promise<unknown>, target: OnlineTarget = window): () => void {
37
+ let canceled = false;
38
+ let attempt = 0;
39
+ let timer: ReturnType<typeof setTimeout> | undefined;
40
+ const isCanceled = (): boolean => canceled;
41
+ const run = (): void => {
42
+ clearTimeout(timer);
43
+ timer = undefined;
44
+ ask(isCanceled).then(
45
+ () => target.removeEventListener('online', onOnline),
46
+ () => {
47
+ if (canceled) return;
48
+ attempt += 1;
49
+ timer = setTimeout(run, retryDelayMs(attempt));
50
+ },
51
+ );
52
+ };
53
+ const onOnline = (): void => {
54
+ if (timer !== undefined) run();
55
+ };
56
+ target.addEventListener('online', onOnline);
57
+ run();
58
+ return () => {
59
+ canceled = true;
60
+ clearTimeout(timer);
61
+ target.removeEventListener('online', onOnline);
62
+ };
63
+ }
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, test } from 'bun:test';
2
- import { mergeTagLists, parseTagList, tagListText } from './tagList.js';
2
+ import { acceptTagList, cantBeATag, mergeTagLists, parseTagList, tagListText } from './tagList.js';
3
3
 
4
4
  describe('tags on the clipboard', () => {
5
5
  test('out as a comma line, back from commas, semicolons or lines — trimmed, each once', () => {
@@ -17,3 +17,25 @@ describe('tags on the clipboard', () => {
17
17
  expect(mergeTagLists(['dog'], ['beach', 'dog', 'sunset'])).toEqual(['dog', 'beach', 'sunset']);
18
18
  });
19
19
  });
20
+
21
+ describe('acceptTagList — a typed or pasted tag is spelled and checked like the app keeps it (forge task 5798)', () => {
22
+ const lower = (raw: string) => raw.trim().toLowerCase().replace(/[^a-z0-9 ]/g, '');
23
+ const whyNot = (raw: string) => (lower(raw).length < 2 ? `“${raw.trim()}” is too short` : null);
24
+
25
+ test('an added tag is respelled; the ones already there are kept exactly', () => {
26
+ expect(acceptTagList(['Kept As Is'], ['Kept As Is', ' Boats! '], lower)).toEqual({ tags: ['Kept As Is', 'boats'], refused: [] });
27
+ });
28
+
29
+ test('a tag whyNot refuses is left out with its reason', () => {
30
+ expect(acceptTagList(['a'], ['a', 'x'], lower, whyNot)).toEqual({ tags: ['a'], refused: ['“x” is too short'] });
31
+ });
32
+
33
+ test('a tag normalize turns into "" is refused with the default reason when there is no whyNot', () => {
34
+ expect(acceptTagList([], ['!!!'], lower)).toEqual({ tags: [], refused: [cantBeATag('!!!')] });
35
+ });
36
+
37
+ test('two spellings of one tag land once; a removal passes through', () => {
38
+ expect(acceptTagList([], ['Boat', 'boat'], lower).tags).toEqual(['boat']);
39
+ expect(acceptTagList(['a', 'b'], ['b']).tags).toEqual(['b']);
40
+ });
41
+ });
@@ -27,3 +27,36 @@ export function mergeTagLists(current: readonly string[], pasted: readonly strin
27
27
  for (const tag of pasted) if (!next.includes(tag)) next.push(tag);
28
28
  return next;
29
29
  }
30
+
31
+ /** The default refusal, when the app gives no `whyNot`. */
32
+ export const cantBeATag = (raw: string): string => `“${raw.trim()}” can't be a tag`;
33
+
34
+ /**
35
+ * A tag list as the tag field hands it over, checked (forge task 5798): every tag `next` ADDS over
36
+ * `current` asked `whyNot` (the app's reason a tag is refused, or null) and then spelled by
37
+ * `normalize`; one refused, or normalized to "", is left out with its reason. Tags already in
38
+ * `current` are kept exactly as they are, in `next`'s order, each once.
39
+ *
40
+ * Before this only a PASTE was normalized, so a TYPED chip showed text the app would refuse or
41
+ * respell — photos' "007" chip that the server answered with a bare "bad tag" (task 5797).
42
+ */
43
+ export function acceptTagList(
44
+ current: readonly string[],
45
+ next: readonly string[],
46
+ normalize: (raw: string) => string = (raw) => raw.trim(),
47
+ whyNot?: (raw: string) => string | null,
48
+ ): { tags: string[]; refused: string[] } {
49
+ const tags: string[] = [];
50
+ const refused: string[] = [];
51
+ for (const raw of next) {
52
+ if (current.includes(raw)) {
53
+ if (!tags.includes(raw)) tags.push(raw);
54
+ continue;
55
+ }
56
+ const problem = whyNot?.(raw) ?? null;
57
+ const tag = problem ? '' : normalize(raw);
58
+ if (!tag) refused.push(problem ?? cantBeATag(raw));
59
+ else if (!tags.includes(tag)) tags.push(tag);
60
+ }
61
+ return { tags, refused };
62
+ }
@@ -119,6 +119,8 @@
119
119
  * who went where; refusing to draw would be worse.
120
120
  */
121
121
  import React from "react";
122
+ import { CanvasZoomHint } from "../canvas-hud/HudControls.js";
123
+ import { readWheel } from "../canvas-hud/useCanvasWheel.js";
122
124
  import {
123
125
  type LatLng,
124
126
  MAX_ZOOM,
@@ -282,8 +284,20 @@ export interface MapFrameProps extends Omit<React.HTMLAttributes<HTMLDivElement>
282
284
  /** The URL of one rendered viewport. Defaults to {@link mapImageSource} — the app's own
283
285
  * `/api/map` proxy, which `cursedbelt-server/maps-static` serves the shared half of. */
284
286
  imageSource?: (center: LatLng, zoom: number, theme: "light" | "dark") => string;
287
+ /**
288
+ * What a plain wheel means (DESIGN CNV-1, forge task 5761). `"fullscreen"` (the default) —
289
+ * a map that IS the page, like family's atlas — zooms on every wheel. `"embedded"` — a map
290
+ * inside a scrolling page — zooms only on a pinch or with ⌘/Ctrl held; a plain wheel is left
291
+ * to scroll the page (no `preventDefault`) and the frame shows "Hold ⌘ to zoom" over itself.
292
+ */
293
+ wheel?: MapWheelMode;
285
294
  }
286
295
 
296
+ export type MapWheelMode = "embedded" | "fullscreen";
297
+
298
+ /** How long the embedded "Hold ⌘ to zoom" hint stays up after the last plain wheel. */
299
+ export const WHEEL_HINT_MS = 1200;
300
+
287
301
  /*
288
302
  * 🔴 Every style is INLINE, so an app mounts the frame with no stylesheet to import and no
289
303
  * class to keep in step (family's `.ft-map*` rules were the frame's whole CSS). A consumer
@@ -312,11 +326,17 @@ export function MapFrame({
312
326
  className,
313
327
  style,
314
328
  imageSource = mapImageSource,
329
+ wheel = "fullscreen",
315
330
  ...rest
316
331
  }: MapFrameProps) {
317
332
  /** Per instance: two frames on one page must not share one `<pattern>` id. */
318
333
  const graticuleId = `cb-map-graticule-${React.useId().replace(/:/g, "")}`;
319
334
  const svgRef = React.useRef<SVGSVGElement | null>(null);
335
+ // Read through a ref by the once-bound wheel listener, so a changed mode never re-binds it.
336
+ const wheelModeRef = React.useRef(wheel);
337
+ wheelModeRef.current = wheel;
338
+ const [wheelHint, setWheelHint] = React.useState(false);
339
+ const hintTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);
320
340
 
321
341
  /**
322
342
  * The viewport the reader is manipulating right now, fractional zoom and all.
@@ -514,6 +534,17 @@ export function MapFrame({
514
534
  if (!svg) return;
515
535
  const onWheel = (event: WheelEvent): void => {
516
536
  if (!committedRef.current.onViewChange) return;
537
+ // CNV-1: embedded, a plain wheel belongs to the page. Return BEFORE preventDefault so
538
+ // it scrolls, and say how to zoom instead.
539
+ if (wheelModeRef.current === "embedded" && readWheel("embedded", event) === "page") {
540
+ setWheelHint(true);
541
+ if (hintTimer.current) clearTimeout(hintTimer.current);
542
+ hintTimer.current = setTimeout(() => {
543
+ hintTimer.current = null;
544
+ setWheelHint(false);
545
+ }, WHEEL_HINT_MS);
546
+ return;
547
+ }
517
548
  event.preventDefault();
518
549
  stopGlide();
519
550
  const point = toViewportUnits(event);
@@ -556,6 +587,7 @@ export function MapFrame({
556
587
  React.useEffect(
557
588
  () => () => {
558
589
  if (wheelTimer.current) clearTimeout(wheelTimer.current);
590
+ if (hintTimer.current) clearTimeout(hintTimer.current);
559
591
  if (glide.current !== null) cancelAnimationFrame(glide.current);
560
592
  },
561
593
  [],
@@ -882,6 +914,7 @@ export function MapFrame({
882
914
  </g>
883
915
  <ScaleKey view={view} />
884
916
  </svg>
917
+ {wheel === "embedded" && onViewChange ? <CanvasZoomHint show={wheelHint} /> : null}
885
918
  </div>
886
919
  );
887
920
  }