@oxy.so/bloom-language-codemod 0.0.0-bootstrap.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,770 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SCREEN = exports.KEPT = exports.REMOVED = exports.TEXT_STYLES = exports.COMPONENT_RULES = exports.SPACE = exports.PLACEMENT_TIERS = exports.DIALOG_PLACEMENT = void 0;
4
+ exports.ruleFor = ruleFor;
5
+ /**
6
+ * Bloom components the language draws as a node of its own, mapped prop by
7
+ * prop as the language's parity cases pair them
8
+ * (`packages/bloom-language/parity/*.cases.tsx`). A prop not listed, or a
9
+ * value in a form its rule does not take, keeps the element JSX. A rule
10
+ * applies only where the language exports its node.
11
+ */
12
+ const node_fs_1 = require("node:fs");
13
+ const node_path_1 = require("node:path");
14
+ const table_1 = require("./table");
15
+ const spec = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(table_1.LANGUAGE_PACKAGE, 'spec/language.json'), 'utf8'));
16
+ /** A spec enum as a token map: a value outside it is no token of the modifier's. */
17
+ function tokens(name) {
18
+ const values = spec.enums[name];
19
+ if (!values)
20
+ throw new Error(`bloom-language-codemod: no enum ${name} in the spec`);
21
+ return Object.fromEntries(values.map((value) => [value, value]));
22
+ }
23
+ /** Bloom Card's `radius` (`radius-16`) as the language's corner rung (`lg`): `resolveCardRadius` turned round. */
24
+ const CARD_RADIUS = Object.fromEntries([
25
+ ...Object.entries(spec.scales.corner)
26
+ .filter(([name]) => !name.startsWith('$'))
27
+ .map(([name, value]) => [`radius-${value}`, name]),
28
+ ['radius-max', 'full'],
29
+ ['panel', 'panel'],
30
+ ['concentric', 'concentric'],
31
+ ]);
32
+ /** A node's densities, as the spec checks them per node. */
33
+ function densities(kind) {
34
+ const values = spec.nodes[kind]?.densities;
35
+ if (!values)
36
+ throw new Error(`bloom-language-codemod: no densities for ${kind} in the spec`);
37
+ return Object.fromEntries(values.map((value) => [value, value]));
38
+ }
39
+ const p = (modifier, form, map) => ({
40
+ modifier,
41
+ form,
42
+ map,
43
+ });
44
+ /** React Native's `keyboardDismissMode` as the language's `.scrollDismissesKeyboard()`. */
45
+ const DISMISS_MODE = {
46
+ none: 'never',
47
+ 'on-drag': 'immediately',
48
+ interactive: 'interactively',
49
+ };
50
+ /** A scroll indicator's boolean prop as `.scrollIndicators()` on its axis. */
51
+ const INDICATOR = { true: 'visible', false: 'hidden' };
52
+ const indicator = (axis) => ({
53
+ ...p('scrollIndicators', 'literal', INDICATOR),
54
+ args: [axis],
55
+ });
56
+ /** Bloom's dialog placements (`bottom`, `center`…), the language's `.presentAt()` tokens. */
57
+ exports.DIALOG_PLACEMENT = tokens('dialogPlacement');
58
+ /** The breakpoints a responsive placement names over its `base`, `.presentAt()`'s tiers. */
59
+ exports.PLACEMENT_TIERS = ['sm', 'md', 'lg', 'xl'];
60
+ /** Bloom's spacing in points (`12`) as the language's space token (`md`), the spec's scale turned round. */
61
+ exports.SPACE = Object.fromEntries(Object.entries(spec.scales.space)
62
+ .filter(([name]) => !name.startsWith('$'))
63
+ .map(([name, value]) => [String(value), name]));
64
+ /** An avatar's diameter in points as its rung. */
65
+ const AVATAR_SIZE = Object.fromEntries(Object.entries(spec.scales.avatarSize)
66
+ .filter(([name]) => !name.startsWith('$'))
67
+ .map(([name, value]) => [String(value), name]));
68
+ /** An icon's size in points as its rung. */
69
+ const ICON_SIZE = Object.fromEntries(Object.entries(spec.scales.iconSize)
70
+ .filter(([name]) => !name.startsWith('$'))
71
+ .flatMap(([name, value]) => [
72
+ [String(value), name],
73
+ [name, name],
74
+ ]));
75
+ /** The text input modifiers every field takes (`textInputProps` in the language's inputs). */
76
+ const TEXT_INPUT = {
77
+ keyboardType: p('keyboard', 'token', tokens('keyboard')),
78
+ autoCapitalize: p('autocapitalize', 'token', tokens('autocapitalize')),
79
+ autoCorrect: p('autocorrect', 'boolean'),
80
+ autoComplete: p('contentType', 'token', tokens('contentType')),
81
+ returnKeyType: p('submitLabel', 'token', tokens('submitLabel')),
82
+ onSubmitEditing: p('onSubmit', 'handler'),
83
+ autoFocus: p('autoFocus', 'mark'),
84
+ maxLength: p('maxLength', 'number'),
85
+ };
86
+ /** The props a node takes from its press and name (`d.props()`). */
87
+ const NAMED = {
88
+ accessibilityLabel: p('label', 'string'),
89
+ accessibilityHint: p('hint', 'string'),
90
+ testID: p('testID', 'string'),
91
+ };
92
+ /** parity/settings.cases.tsx, SettingsSelect: its label, the selection and its choices. */
93
+ const SETTINGS_SELECT = {
94
+ node: 'SettingsSelect',
95
+ params: [
96
+ { prop: 'label', form: 'string' },
97
+ { binding: ['value', 'onChange'], hole: 'string' },
98
+ { prop: 'items', form: 'items' },
99
+ ],
100
+ props: {
101
+ compact: p('compact', 'flag'),
102
+ size: p('size', 'token', tokens('controlSize')),
103
+ disabled: p('disabled', 'flag'),
104
+ testID: p('testID', 'string'),
105
+ },
106
+ };
107
+ /** `module#export` to its rule. */
108
+ exports.COMPONENT_RULES = {
109
+ // parity/overlays.cases.tsx, a presented dialog: its `open` and `onClose` one binding.
110
+ '@oxy.so/bloom/dialog#Dialog': {
111
+ node: 'Dialog',
112
+ children: true,
113
+ props: {
114
+ open: { ...p('presented', 'boolean'), closedBy: 'onClose' },
115
+ title: p('title', 'string'),
116
+ description: p('message', 'string'),
117
+ label: p('label', 'string'),
118
+ actions: p('buttons', 'items'),
119
+ placement: p('presentAt', 'placement'),
120
+ header: p('header', 'items'),
121
+ footer: p('footer', 'view'),
122
+ width: { ...p('frame', 'token', exports.SPACE), key: 'width' },
123
+ maxWidth: { ...p('frame', 'token', exports.SPACE), key: 'maxWidth' },
124
+ contentPadding: p('padding', 'token', exports.SPACE),
125
+ minSideGutter: p('sideGutter', 'token', exports.SPACE),
126
+ maxHeightRatio: p('maxHeightRatio', 'number'),
127
+ dismissOnBackdrop: p('dismissOnBackdrop', 'boolean'),
128
+ scrollable: p('scrollable', 'flag'),
129
+ testID: p('testID', 'string'),
130
+ },
131
+ },
132
+ // parity/inputs.cases.tsx, Toggle (Switch).
133
+ '@oxy.so/bloom/switch#Switch': {
134
+ node: 'Toggle',
135
+ params: [{ binding: ['checked', 'onCheckedChange'], hole: 'boolean' }],
136
+ props: {
137
+ size: p('size', 'token', tokens('controlSize')),
138
+ tone: p('tint', 'token', tokens('tone')),
139
+ disabled: p('disabled', 'flag'),
140
+ accessibilityLabel: p('label', 'string'),
141
+ testID: p('testID', 'string'),
142
+ },
143
+ },
144
+ // parity/containers.cases.tsx, GroupedSection.
145
+ '@oxy.so/bloom/grouped-section#GroupedSection': {
146
+ node: 'GroupedSection',
147
+ children: true,
148
+ props: {
149
+ title: p('title', 'string'),
150
+ footer: p('caption', 'string'),
151
+ variant: p('style', 'token', tokens('groupedSectionStyle')),
152
+ separator: p('separator', 'token', tokens('groupedSeparator')),
153
+ radius: p('radius', 'token', CARD_RADIUS),
154
+ density: p('density', 'token', densities('groupedSection')),
155
+ testID: p('testID', 'string'),
156
+ },
157
+ },
158
+ '@oxy.so/bloom/grouped-section#GroupedSectionItem': {
159
+ node: 'GroupedSectionItem',
160
+ params: [{ prop: 'title', form: 'string' }],
161
+ props: {
162
+ icon: p('leadingView', 'view'),
163
+ description: p('description', 'string'),
164
+ value: p('value', 'string'),
165
+ rightElement: p('trailing', 'view'),
166
+ showChevron: p('chevron', 'flag'),
167
+ titleNumberOfLines: p('lines', 'number'),
168
+ descriptionLines: p('descriptionLines', 'number'),
169
+ wrapControl: p('wrapControl', 'flag'),
170
+ destructive: p('destructive', 'mark'),
171
+ disabled: p('disabled', 'flag'),
172
+ onPress: p('onPress', 'handler'),
173
+ ...NAMED,
174
+ },
175
+ },
176
+ // parity/screen.cases.tsx: a scroll view is the screen's.
177
+ '@oxy.so/bloom/screen#ScreenScrollView': {
178
+ node: 'ScrollView',
179
+ children: true,
180
+ within: '@oxy.so/bloom/screen#Screen',
181
+ props: {
182
+ keyboardShouldPersistTaps: p('keyboardTaps', 'token', tokens('keyboardTaps')),
183
+ onEndReached: { ...p('onEndReached', 'handler'), with: ['onEndReachedThreshold', 'number'] },
184
+ refreshControl: p('refreshable', 'refresh'),
185
+ showsVerticalScrollIndicator: indicator('vertical'),
186
+ showsHorizontalScrollIndicator: indicator('horizontal'),
187
+ contentContainerStyle: p('contentMargins', 'contentStyle'),
188
+ contentContainerClassName: p('contentView', 'className'),
189
+ testID: p('testID', 'string'),
190
+ },
191
+ },
192
+ // parity/settings.cases.tsx.
193
+ '@oxy.so/bloom/settings-modal#SettingsSection': {
194
+ node: 'SettingsSection',
195
+ params: [{ prop: 'label', form: 'string', optional: true }],
196
+ children: true,
197
+ props: {
198
+ description: p('description', 'string'),
199
+ action: p('trailing', 'view'),
200
+ testID: p('testID', 'string'),
201
+ },
202
+ },
203
+ '@oxy.so/bloom/settings-modal#SettingsValueField': {
204
+ node: 'SettingsValue',
205
+ params: [{ text: true }],
206
+ props: {
207
+ icon: p('icon', 'icon'),
208
+ muted: p('muted', 'flag'),
209
+ testID: p('testID', 'string'),
210
+ },
211
+ },
212
+ // parity/inputs.cases.tsx, TextField: a bare TextFieldInput draws the TextField shell itself.
213
+ '@oxy.so/bloom/text-field#TextFieldInput': {
214
+ node: 'TextField',
215
+ params: [
216
+ { binding: ['value', ['onValueChange', 'onChangeText']], hole: 'string' },
217
+ { prop: 'label', form: 'string' },
218
+ ],
219
+ // A bare input draws its own shell, with the enclosing Field's state; the node draws its shell as it is.
220
+ outside: ['@oxy.so/bloom/text-field#TextField', '@oxy.so/bloom/field#Field'],
221
+ props: {
222
+ placeholder: p('placeholder', 'string'),
223
+ size: p('size', 'token', tokens('controlSize')),
224
+ invalid: p('invalid', 'flag'),
225
+ disabled: p('disabled', 'flag'),
226
+ floatingLabel: p('floatingLabel', 'mark'),
227
+ ...TEXT_INPUT,
228
+ accessibilityHint: p('hint', 'string'),
229
+ testID: p('testID', 'string'),
230
+ },
231
+ },
232
+ // parity/inputs.cases.tsx, TextField: the shell an app writes around its input.
233
+ '@oxy.so/bloom/text-field#TextField': {
234
+ node: 'TextField',
235
+ shell: {
236
+ input: '@oxy.so/bloom/text-field#TextFieldInput',
237
+ icon: '@oxy.so/bloom/text-field#TextFieldIcon',
238
+ },
239
+ props: {
240
+ size: p('size', 'token', tokens('controlSize')),
241
+ invalid: p('invalid', 'flag'),
242
+ // Measured: a shell's disabled draws what the node's .disabled() draws.
243
+ disabled: p('disabled', 'flag'),
244
+ },
245
+ },
246
+ // parity/containers.cases.tsx, Card.
247
+ '@oxy.so/bloom/card#Card': {
248
+ node: 'Card',
249
+ children: true,
250
+ props: {
251
+ appearance: p('style', 'token', tokens('appearance')),
252
+ tone: p('tint', 'token', tokens('tone')),
253
+ radius: p('radius', 'token', CARD_RADIUS),
254
+ elevation: p('elevation', 'token', tokens('cardElevation')),
255
+ border: p('outline', 'token', tokens('cardBorder')),
256
+ clipContent: p('clipped', 'mark'),
257
+ disabled: p('disabled', 'flag'),
258
+ onPress: p('onPress', 'handler'),
259
+ ...NAMED,
260
+ },
261
+ },
262
+ // parity/chat.cases.tsx, ChatEmptyState.
263
+ '@oxy.so/bloom/chat-screen#ChatEmptyState': {
264
+ node: 'ChatEmptyState',
265
+ params: [
266
+ {
267
+ options: {
268
+ title: 'string',
269
+ description: 'string',
270
+ notice: 'string',
271
+ illustration: 'view',
272
+ action: 'view',
273
+ },
274
+ },
275
+ ],
276
+ props: { testID: p('testID', 'string') },
277
+ },
278
+ // parity/list.cases.tsx, Row (Bloom Item).
279
+ '@oxy.so/bloom/item#Item': {
280
+ node: 'Row',
281
+ params: [{ prop: 'title', form: 'string', optional: true }],
282
+ props: {
283
+ subtitle: p('subtitle', 'string'),
284
+ leading: p('leadingView', 'view'),
285
+ trailing: p('trailing', 'view'),
286
+ size: p('size', 'token', tokens('controlSize')),
287
+ titleNumberOfLines: p('lines', 'number'),
288
+ disabled: p('disabled', 'flag'),
289
+ destructive: p('destructive', 'mark'),
290
+ selected: p('selected', 'flag'),
291
+ active: p('active', 'boolean'),
292
+ highlighted: p('highlighted', 'flag'),
293
+ contentDensity: p('density', 'token', densities('row')),
294
+ onPress: p('onPress', 'handler'),
295
+ onLongPress: p('onLongPress', 'handler'),
296
+ ...NAMED,
297
+ },
298
+ },
299
+ // parity/inputs.cases.tsx, Field.
300
+ '@oxy.so/bloom/field#Field': {
301
+ node: 'Field',
302
+ params: [{ prop: 'label', form: 'string', optional: true }],
303
+ children: true,
304
+ props: {
305
+ description: p('description', 'string'),
306
+ error: p('error', 'string'),
307
+ required: p('required', 'flag'),
308
+ disabled: p('disabled', 'flag'),
309
+ testID: p('testID', 'string'),
310
+ },
311
+ },
312
+ // parity/inputs.cases.tsx, TextEditor (Textarea).
313
+ '@oxy.so/bloom/textarea#Textarea': {
314
+ node: 'TextEditor',
315
+ params: [
316
+ { binding: ['value', ['onValueChange', 'onChangeText']], hole: 'string' },
317
+ { prop: 'label', form: 'string', optional: true },
318
+ ],
319
+ // Inside a Field, Bloom's Textarea takes the field's state.
320
+ outside: ['@oxy.so/bloom/field#Field'],
321
+ props: {
322
+ placeholder: p('placeholder', 'string'),
323
+ hint: p('description', 'string'),
324
+ size: p('size', 'token', tokens('controlSize')),
325
+ disabled: p('disabled', 'flag'),
326
+ invalid: p('invalid', 'flag'),
327
+ required: p('required', 'flag'),
328
+ rows: p('rows', 'number'),
329
+ autoResize: { ...p('autoResize', 'mark'), with: ['maxRows', 'number'] },
330
+ resize: p('resize', 'token', tokens('textareaResize')),
331
+ showCount: p('showCount', 'mark'),
332
+ ...TEXT_INPUT,
333
+ accessibilityLabel: p('label', 'string'),
334
+ accessibilityHint: p('hint', 'string'),
335
+ testID: p('testID', 'string'),
336
+ },
337
+ },
338
+ // parity/inputs.cases.tsx, Search.
339
+ '@oxy.so/bloom/search#Search': {
340
+ node: 'Search',
341
+ params: [{ binding: ['value', ['onValueChange', 'onChangeText']], hole: 'string' }],
342
+ outside: ['@oxy.so/bloom/field#Field'],
343
+ props: {
344
+ label: p('label', 'string'),
345
+ placeholder: p('placeholder', 'string'),
346
+ size: p('size', 'token', tokens('controlSize')),
347
+ disabled: p('disabled', 'flag'),
348
+ onClearText: p('onClearText', 'handler'),
349
+ ...TEXT_INPUT,
350
+ testID: p('testID', 'string'),
351
+ },
352
+ },
353
+ // parity/inputs.cases.tsx, Checkbox.
354
+ '@oxy.so/bloom/checkbox#Checkbox': {
355
+ node: 'Checkbox',
356
+ params: [
357
+ { binding: ['checked', 'onCheckedChange'], hole: 'boolean' },
358
+ { prop: 'label', form: 'string', optional: true },
359
+ ],
360
+ props: {
361
+ description: p('description', 'string'),
362
+ size: p('size', 'token', tokens('controlSize')),
363
+ tone: p('tint', 'token', tokens('tone')),
364
+ disabled: p('disabled', 'flag'),
365
+ readOnly: p('readOnly', 'mark'),
366
+ indeterminate: p('indeterminate', 'flag'),
367
+ accessibilityLabel: p('label', 'string'),
368
+ testID: p('testID', 'string'),
369
+ },
370
+ },
371
+ // parity/pieces.cases.tsx and material.cases.tsx: the small pieces.
372
+ '@oxy.so/bloom/divider#Divider': {
373
+ node: 'Divider',
374
+ props: {
375
+ variant: p('lineStyle', 'token', tokens('dividerStyle')),
376
+ spacing: p('spacing', 'token', exports.SPACE),
377
+ ...NAMED,
378
+ },
379
+ },
380
+ '@oxy.so/bloom/loading#Loading': {
381
+ node: 'Loading',
382
+ props: {
383
+ variant: p('style', 'token', tokens('loadingStyle')),
384
+ size: p('size', 'token', tokens('controlSize')),
385
+ tone: p('tint', 'token', tokens('tone')),
386
+ ...NAMED,
387
+ },
388
+ },
389
+ '@oxy.so/bloom/badge#Badge': {
390
+ node: 'Badge',
391
+ params: [{ prop: 'content', form: 'string', optional: true }],
392
+ props: {
393
+ variant: p('style', 'token', tokens('badgeStyle')),
394
+ tone: p('tint', 'token', tokens('tone')),
395
+ size: p('size', 'token', tokens('badgeSize')),
396
+ icon: p('icon', 'icon'),
397
+ dot: p('dot', 'mark'),
398
+ max: p('max', 'number'),
399
+ placement: p('placement', 'token', tokens('badgePlacement')),
400
+ color: p('color', 'token', tokens('accentTone')),
401
+ ...NAMED,
402
+ },
403
+ },
404
+ '@oxy.so/bloom/icon-circle#IconCircle': {
405
+ node: 'IconCircle',
406
+ params: [{ prop: 'icon', form: 'icon' }],
407
+ props: { size: p('size', 'token', ICON_SIZE), ...NAMED },
408
+ },
409
+ // parity/avatar.cases.tsx.
410
+ '@oxy.so/bloom/avatar#Avatar': {
411
+ node: 'Avatar',
412
+ params: [
413
+ { prop: 'source', form: 'string', optional: true },
414
+ { options: { variant: 'string', name: 'string', initials: 'string' } },
415
+ ],
416
+ props: {
417
+ size: p('size', 'token', AVATAR_SIZE),
418
+ shape: p('shape', 'token', tokens('shapeName')),
419
+ verified: p('verified', 'flag'),
420
+ live: p('live', 'flag'),
421
+ alt: p('label', 'string'),
422
+ testID: p('testID', 'string'),
423
+ },
424
+ },
425
+ // parity/material.cases.tsx, Grid (ResponsiveGrid).
426
+ '@oxy.so/bloom/grid#ResponsiveGrid': {
427
+ node: 'Grid',
428
+ children: true,
429
+ props: {
430
+ maxColumns: p('columns', 'number'),
431
+ minItemWidth: p('minCellWidth', 'token', exports.SPACE),
432
+ gap: p('spacing', 'token', exports.SPACE),
433
+ flow: p('flow', 'token', tokens('gridFlow')),
434
+ stretchItems: p('stretchItems', 'flag'),
435
+ ...NAMED,
436
+ },
437
+ },
438
+ // parity/engagement.cases.tsx, Action (EngagementAction).
439
+ '@oxy.so/bloom/engagement-bar#EngagementAction': {
440
+ node: 'Action',
441
+ within: '@oxy.so/bloom/engagement-bar#EngagementBar',
442
+ params: [
443
+ { prop: 'icon', form: 'icon' },
444
+ { prop: 'accessibilityLabel', form: 'string' },
445
+ {
446
+ options: {
447
+ activeIcon: 'icon',
448
+ popOnActivate: ['pop', 'boolean'],
449
+ rollCount: 'boolean',
450
+ busy: 'boolean',
451
+ },
452
+ },
453
+ ],
454
+ props: {
455
+ count: p('count', 'number'),
456
+ active: p('active', 'boolean'),
457
+ tone: p('tint', 'token', tokens('engagementTone')),
458
+ onPress: p('onPress', 'handler'),
459
+ onLongPress: p('onLongPress', 'handler'),
460
+ accessibilityHint: p('hint', 'string'),
461
+ testID: p('testID', 'string'),
462
+ },
463
+ },
464
+ // parity/containers.cases.tsx, Chip: an `Icon` before its `Text` leads it, one after trails it.
465
+ '@oxy.so/bloom/chip#Chip': {
466
+ node: 'Chip',
467
+ params: [{ label: { leading: 'leadingIcon', trailing: 'trailingIcon' } }],
468
+ props: {
469
+ // `inverted` is Bloom's chip variant; the appearances are its `appearance`.
470
+ variant: p('style', 'token', { inverted: 'inverted' }),
471
+ appearance: p('style', 'token', tokens('appearance')),
472
+ tone: p('tint', 'token', tokens('tone')),
473
+ size: p('size', 'token', tokens('chipSize')),
474
+ hue: p('hue', 'token', tokens('chipHue')),
475
+ selected: p('selected', 'flag'),
476
+ disabled: p('disabled', 'flag'),
477
+ onPress: p('onPress', 'handler'),
478
+ onLongPress: p('onLongPress', 'handler'),
479
+ ...NAMED,
480
+ },
481
+ },
482
+ // parity/containers.cases.tsx, Admonition: its text as a `Text`, which it draws as its AdmonitionText.
483
+ '@oxy.so/bloom/admonition#Admonition': {
484
+ node: 'Admonition',
485
+ params: [{ label: {} }],
486
+ props: {
487
+ type: p('style', 'token', tokens('admonitionStyle')),
488
+ size: p('size', 'token', tokens('controlSize')),
489
+ },
490
+ },
491
+ // parity/screen.cases.tsx and header cases: Bloom's PageHeader, in the page on every platform.
492
+ '@oxy.so/bloom/page-header#PageHeader': {
493
+ node: 'Header',
494
+ params: [{ prop: 'title', form: 'string', optional: true }],
495
+ always: ['inPage'],
496
+ props: {
497
+ subtitle: p('subtitle', 'string'),
498
+ actions: p('toolbar', 'view'),
499
+ leading: p('toolbarLeading', 'view'),
500
+ onBack: p('onBack', 'handler'),
501
+ backLabel: p('backLabel', 'string'),
502
+ headingLevel: p('headingLevel', 'number'),
503
+ scrim: p('scrollEdge', 'token', tokens('scrollEdge')),
504
+ presentation: p('presentation', 'token', tokens('headerPresentation')),
505
+ safeArea: p('safeArea', 'flag'),
506
+ titleAlign: p('titleAlign', 'token', tokens('titleAlign')),
507
+ accessory: p('accessory', 'view'),
508
+ tone: p('tone', 'token', tokens('headerTone')),
509
+ scrimFalloff: p('scrimFalloff', 'token', tokens('scrimFalloff')),
510
+ titleReveal: p('titleReveal', 'token', tokens('titleReveal')),
511
+ testID: p('testID', 'string'),
512
+ },
513
+ },
514
+ '@oxy.so/bloom/loading#SpinnerIcon': {
515
+ node: 'SpinnerIcon',
516
+ props: { size: p('size', 'token', ICON_SIZE), testID: p('testID', 'string') },
517
+ },
518
+ // parity/slider.cases.tsx.
519
+ '@oxy.so/bloom/slider#Slider': {
520
+ node: 'Slider',
521
+ params: [
522
+ { binding: ['value', 'onValueChange'], hole: 'number' },
523
+ { prop: 'label', form: 'string', optional: true },
524
+ ],
525
+ props: {
526
+ min: { ...p('bounds', 'number'), with: ['max', 'number'] },
527
+ step: p('step', 'number'),
528
+ keyboardStep: p('keyboardStep', 'number'),
529
+ size: p('size', 'token', tokens('controlSize')),
530
+ tone: p('tint', 'token', tokens('tone')),
531
+ disabled: p('disabled', 'flag'),
532
+ showTooltip: p('showsValue', 'boolean'),
533
+ formatValue: p('valueFormat', 'handler'),
534
+ onSlidingComplete: p('onCommit', 'handler'),
535
+ ...NAMED,
536
+ },
537
+ },
538
+ // parity/containers.cases.tsx, Tabs: the strip and its tabs, one node.
539
+ '@oxy.so/bloom/tabs#Tabs': {
540
+ node: 'Tabs',
541
+ params: [{ binding: ['value', 'onValueChange'], hole: 'string' }],
542
+ parts: ['@oxy.so/bloom/tabs#TabsTrigger'],
543
+ props: {
544
+ variant: p('style', 'token', tokens('tabsStyle')),
545
+ fullWidth: p('fullWidth', 'flag'),
546
+ onReorder: p('onReorder', 'handler'),
547
+ label: p('label', 'string'),
548
+ testID: p('testID', 'string'),
549
+ },
550
+ },
551
+ '@oxy.so/bloom/tabs#TabsTrigger': {
552
+ node: 'TabItem',
553
+ partOf: '@oxy.so/bloom/tabs#Tabs',
554
+ params: [
555
+ { prop: 'value', form: 'string' },
556
+ { prop: 'label', form: 'string' },
557
+ ],
558
+ props: {
559
+ leadingIcon: p('icon', 'icon'),
560
+ count: p('count', 'number'),
561
+ disabled: p('disabled', 'flag'),
562
+ iconOnly: p('iconOnly', 'mark'),
563
+ reorderable: p('reorderable', 'flag'),
564
+ trailing: p('trailing', 'view'),
565
+ onLongPress: p('onLongPress', 'handler'),
566
+ testID: p('testID', 'string'),
567
+ },
568
+ },
569
+ // parity/inputs.cases.tsx, Segmented (SegmentedControl): its items are its options.
570
+ '@oxy.so/bloom/segmented-control#SegmentedControl': {
571
+ node: 'Segmented',
572
+ params: [{ binding: ['value', ['onValueChange', 'onChange']], hole: 'string' }],
573
+ parts: ['@oxy.so/bloom/segmented-control#SegmentedControlItem'],
574
+ props: {
575
+ // Bloom's `type` is `radio` by default; the node draws `tabs` with `.tabs()`.
576
+ type: { ...p('tabs', 'mark'), marks: { radio: false, tabs: true } },
577
+ variant: p('style', 'token', tokens('segmentedStyle')),
578
+ size: p('size', 'token', tokens('controlSize')),
579
+ disabled: p('disabled', 'flag'),
580
+ label: p('label', 'string'),
581
+ accessibilityHint: p('hint', 'string'),
582
+ testID: p('testID', 'string'),
583
+ },
584
+ },
585
+ '@oxy.so/bloom/segmented-control#SegmentedControlItem': {
586
+ node: 'Option',
587
+ partOf: '@oxy.so/bloom/segmented-control#SegmentedControl',
588
+ params: [
589
+ { prop: 'value', form: 'string' },
590
+ { text: '@oxy.so/bloom/segmented-control#SegmentedControlItemText' },
591
+ ],
592
+ props: { disabled: p('disabled', 'flag'), testID: p('testID', 'string') },
593
+ },
594
+ // parity/settings.cases.tsx: the settings row's select, from either entry.
595
+ '@oxy.so/bloom/settings-modal#SettingsSelect': SETTINGS_SELECT,
596
+ '@oxy.so/bloom/settings-modal/select#SettingsSelect': SETTINGS_SELECT,
597
+ // parity/avatar.cases.tsx, AvatarGroup.
598
+ '@oxy.so/bloom/avatar-group#AvatarGroup': {
599
+ node: 'AvatarGroup',
600
+ params: [{ prop: 'items', form: 'items' }],
601
+ props: {
602
+ layout: p('layout', 'token', tokens('avatarLayout')),
603
+ size: p('size', 'token', AVATAR_SIZE),
604
+ shape: p('shape', 'token', tokens('shapeName')),
605
+ max: p('max', 'number'),
606
+ total: p('total', 'number'),
607
+ spacing: p('spacing', 'token', exports.SPACE),
608
+ overflow: p('overflow', 'token', tokens('avatarOverflow')),
609
+ showInitials: p('initials', 'mark'),
610
+ onPressItem: p('onPressItem', 'handler'),
611
+ hoverCard: p('hoverCard', 'flag'),
612
+ accessibilityLabel: p('label', 'string'),
613
+ testID: p('testID', 'string'),
614
+ },
615
+ },
616
+ // parity/list.cases.tsx, List: its rows from data.
617
+ '@oxy.so/bloom/list#List': {
618
+ node: 'List',
619
+ params: [{ prop: 'items', form: 'items' }],
620
+ props: {
621
+ separator: p('separator', 'token', tokens('listSeparator')),
622
+ scrollable: p('scrollable', 'flag'),
623
+ stickyHeaders: p('stickyHeaders', 'flag'),
624
+ header: p('headerContent', 'view'),
625
+ footer: p('footerContent', 'view'),
626
+ empty: p('emptyState', 'view'),
627
+ loading: p('loading', 'flag'),
628
+ loadingCount: p('loadingRows', 'number'),
629
+ accessibilityLabel: p('label', 'string'),
630
+ testID: p('testID', 'string'),
631
+ },
632
+ },
633
+ // parity/list.cases.tsx, VirtualList: its data and the row each item draws.
634
+ '@oxy.so/bloom/list#VirtualList': {
635
+ node: 'VirtualList',
636
+ params: [
637
+ { prop: 'data', form: 'items' },
638
+ { prop: 'renderItem', form: 'row' },
639
+ ],
640
+ props: {
641
+ keyExtractor: p('itemKey', 'handler'),
642
+ getItemType: p('itemType', 'handler'),
643
+ estimatedItemSize: p('estimatedItemSize', 'number'),
644
+ numColumns: p('columns', 'number'),
645
+ onEndReached: { ...p('onEndReached', 'handler'), with: ['onEndReachedThreshold', 'number'] },
646
+ restorationKey: p('restorationKey', 'string'),
647
+ ListHeaderComponent: p('headerContent', 'element'),
648
+ ListFooterComponent: p('footerContent', 'element'),
649
+ ListEmptyComponent: p('emptyState', 'element'),
650
+ screen: { ...p('screen', 'empty'), within: '@oxy.so/bloom/screen#Screen' },
651
+ scrollbar: p('scrollbar', 'token', tokens('scrollbarVisibility')),
652
+ keyboardShouldPersistTaps: p('keyboardTaps', 'token', tokens('keyboardTaps')),
653
+ keyboardDismissMode: p('scrollDismissesKeyboard', 'token', DISMISS_MODE),
654
+ testID: p('testID', 'string'),
655
+ },
656
+ // The engine's knobs, as the language's `VirtualListTuning` names them.
657
+ gather: {
658
+ modifier: 'tuning',
659
+ props: {
660
+ overscan: 'number',
661
+ removeClippedSubviews: 'flag',
662
+ maxToRenderPerBatch: 'number',
663
+ windowSize: 'number',
664
+ initialNumToRender: 'number',
665
+ recycleItems: 'flag',
666
+ maintainVisibleContentPosition: 'flag',
667
+ drawDistance: 'number',
668
+ maxItemsInRecyclePool: 'number',
669
+ },
670
+ },
671
+ },
672
+ // parity/chat.cases.tsx, ChatSearchField: the query a binding, the rest its options.
673
+ '@oxy.so/bloom/chat-list#ChatSearchField': {
674
+ node: 'ChatSearchField',
675
+ params: [
676
+ { binding: ['value', 'onChangeText'], hole: 'string' },
677
+ {
678
+ options: {
679
+ placeholder: 'string',
680
+ clearLabel: 'string',
681
+ onClear: 'handler',
682
+ onSubmit: 'handler',
683
+ onFocus: 'handler',
684
+ onBlur: 'handler',
685
+ trailing: 'view',
686
+ autoFocus: 'boolean',
687
+ },
688
+ },
689
+ ],
690
+ props: { accessibilityLabel: p('label', 'string'), testID: p('testID', 'string') },
691
+ },
692
+ };
693
+ /**
694
+ * Bloom's typography components, each its Text in a text style
695
+ * (parity/text.cases.tsx, `textStyle`). `Blockquote` is a View around its Text.
696
+ */
697
+ exports.TEXT_STYLES = {
698
+ Title: 'title',
699
+ Subtitle: 'subtitle',
700
+ H1: 'h1',
701
+ H2: 'h2',
702
+ H3: 'h3',
703
+ H4: 'h4',
704
+ H5: 'h5',
705
+ H6: 'h6',
706
+ P: 'paragraph',
707
+ Lead: 'lead',
708
+ Large: 'large',
709
+ Small: 'small',
710
+ Muted: 'muted',
711
+ };
712
+ /** Components removed in Bloom 22 that apps on 21 still draw, and what replaces each (docs/migrating-to-22.mdx). */
713
+ exports.REMOVED = {
714
+ '@oxy.so/bloom/settings-modal#SettingsRow': '`GroupedSectionItem` (its `title` and `rightElement`) in a `GroupedSection`',
715
+ '@oxy.so/bloom/settings-modal#SettingsCard': '`GroupedSection`',
716
+ '@oxy.so/bloom/button#GlyphButton': '`Button appearance="plain" tone="neutral"` (`glyphSize` is `iconSize`, `busy` is `loading`)',
717
+ '@oxy.so/bloom/button#CloseButton': '`Button icon={CloseIcon}` with an `accessibilityLabel`',
718
+ '@oxy.so/bloom/button-group#ButtonGroup': '`Button.Group` holding ordinary `Button`s',
719
+ '@oxy.so/bloom/button-group#ButtonGroupItem': 'a `Button` in a `Button.Group`',
720
+ };
721
+ /**
722
+ * Bloom components that stay JSX whatever their props, and why: the language
723
+ * draws them, but not as a node a region can hold in their place.
724
+ */
725
+ exports.KEPT = {
726
+ '@oxy.so/bloom/dropdown-menu#DropdownMenu': 'the language’s `Menu` is the platform’s menu (the lens menu on Android, SwiftUI’s on iOS), Bloom’s DropdownMenu only on the web and as a fallback; no parity case pairs it with a DropdownMenu and its parts',
727
+ '@oxy.so/bloom/screen#Screen': 'a Bloom Screen is a route’s `screen()` body in the language, its chrome the modifiers of the body’s root: only a default-exported function component whose every return is a Screen converts (`SCREEN`)',
728
+ '@oxy.so/bloom/app-shell#AppShell': 'a Bloom AppShell is a layout route’s `AppLayout(navigator)` in the language (`.shellLayout()`, `.panels(Panel(…))`); no node a region holds draws one',
729
+ '@oxy.so/bloom/app-shell#AppShellPanels': 'Bloom’s AppShellPanels are an `AppLayout`’s `.panels(Panel(…))` in the language, not a node a region holds',
730
+ '@oxy.so/bloom/app-shell#AppShellPanel': 'a Bloom AppShellPanel is a `Panel(id, content)` of an `AppLayout`’s `.panels()` in the language, not a node a region holds',
731
+ };
732
+ /** Bloom Screen's `bottomBarKeyboardBehavior`, the footer's `keyboard`: the same names. */
733
+ const FOOTER_KEYBOARD = { hide: 'hide', visible: 'visible', follow: 'follow' };
734
+ /**
735
+ * A Bloom `Screen` returned by a route (parity/screen.cases.tsx, `ScreenHost`):
736
+ * its one child is the body's root, and several (a fragment's included) are a
737
+ * `Group`'s; its props are the root's screen modifiers. Its header element is
738
+ * its view: Bloom's PageHeader is `Header(…).inPage()`, the Screen's own header
739
+ * on every platform (a bare `Header` would be the system bar on iOS in a native
740
+ * stack). Its bottom bar is the screen's `.footer()`.
741
+ */
742
+ exports.SCREEN = {
743
+ node: 'screen',
744
+ children: true,
745
+ fragments: true,
746
+ props: {
747
+ header: p('header', 'element'),
748
+ bottomBar: {
749
+ ...p('footer', 'element'),
750
+ options: {
751
+ bottomBarPlacement: ['placement', 'token', tokens('chromePlacement')],
752
+ bottomBarKeyboardBehavior: ['keyboard', 'token', FOOTER_KEYBOARD],
753
+ },
754
+ },
755
+ scroll: p('screenScroll', 'token', tokens('screenScroll')),
756
+ kind: p('screenKind', 'token', tokens('screenKind')),
757
+ documentScroll: p('documentScroll', 'flag'),
758
+ headerPlacement: p('headerPlacement', 'token', tokens('chromePlacement')),
759
+ contentClearance: p('contentClearance', 'token', exports.SPACE),
760
+ navigationScope: p('navigationScope', 'token', tokens('navigationScope')),
761
+ colorPreset: p('colorPreset', 'token', tokens('colorPreset')),
762
+ testID: p('testID', 'string'),
763
+ },
764
+ };
765
+ const exported = (0, node_fs_1.readFileSync)((0, node_path_1.join)(table_1.LANGUAGE_PACKAGE, 'src/index.ts'), 'utf8');
766
+ /** The rule for a Bloom component, when the checked-out language draws its node. */
767
+ function ruleFor(module, imported) {
768
+ const rule = exports.COMPONENT_RULES[`${module}#${imported}`];
769
+ return rule && new RegExp(`\\b${rule.node}\\b`).test(exported) ? rule : undefined;
770
+ }