@onekeyfe/react-native-native-list 6.8.0-2 → 6.8.0-20
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.
- package/android/build.gradle +3 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +70 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +21 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListRowUpdates.kt +34 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
- package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentitySubtitleBindingTest.kt +177 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
- package/docs/ROW_TEMPLATES.md +3 -1
- package/docs/SPEC.md +165 -4
- package/docs/STYLE_SPEC.md +7 -1
- package/ios/NativeListAccessoryStack.swift +22 -0
- package/ios/NativeListDataRowRenderer.swift +12 -5
- package/ios/NativeListIdentityRenderer.swift +36 -58
- package/ios/NativeListLeadingVisual.swift +8 -0
- package/ios/NativeListMarketRenderer.swift +6 -2
- package/ios/NativeListModels.swift +7 -0
- package/ios/NativeListResolvedText.swift +9 -7
- package/ios/NativeListSectionHeaderRenderer.swift +9 -43
- package/ios/NativeListTextStyles.swift +72 -12
- package/ios/RNCNativeListView.swift +203 -45
- package/ios/tests/NativeListLifecycleTests.swift +298 -24
- package/lib/module/validation.js +55 -12
- package/lib/module/web/NativeListGeneratedIcons.js +1 -0
- package/lib/module/web/NativeListWebEngine.js +213 -23
- package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
- package/lib/module/web/templates/DataRowRenderer.js +38 -1
- package/lib/module/web/templates/IdentityRowRenderer.js +12 -1
- package/lib/module/web/templates/MarketRowRenderer.js +2 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
- package/lib/module/web/templates/RowElements.js +2 -2
- package/lib/module/web/templates/RowText.js +2 -0
- package/lib/typescript/src/models.d.ts +24 -1
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +8 -1
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
- package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
- package/package.json +1 -1
- package/scripts/generate-icons.test.mjs +1 -0
- package/scripts/native-list-icons.json +1 -1
- package/src/models.ts +24 -0
- package/src/validation.ts +129 -5
- package/src/web/NativeListGeneratedIcons.ts +1 -0
- package/src/web/NativeListWebEngine.ts +382 -27
- package/src/web/templates/ActivityRowRenderer.ts +1 -1
- package/src/web/templates/DataRowRenderer.ts +48 -1
- package/src/web/templates/IdentityRowRenderer.ts +23 -1
- package/src/web/templates/MarketRowRenderer.ts +2 -0
- package/src/web/templates/MediaTileRowRenderer.ts +1 -0
- package/src/web/templates/RowElements.ts +3 -2
- package/src/web/templates/RowText.ts +6 -0
- package/src/web/templates/RowVisual.ts +2 -1
|
@@ -51,6 +51,10 @@ export type NativeListTextStyle = Readonly<{
|
|
|
51
51
|
verticalAlignment?: 'top' | 'center' | 'bottom';
|
|
52
52
|
/** Optical translation in logical units; does not affect layout. */
|
|
53
53
|
offsetY?: number;
|
|
54
|
+
/** Extra spacing between glyphs in logical units. An explicit 0 turns off the platform's pair kerning on iOS, matching React Native `letterSpacing: 0`. */
|
|
55
|
+
letterSpacing?: number;
|
|
56
|
+
/** Equal-width (tabular) digits, matching the App's `SizableText` default. Omission keeps each template's current digits. */
|
|
57
|
+
tabularNumbers?: boolean;
|
|
54
58
|
}>;
|
|
55
59
|
/** Retained alias: Market shipped this name before the style surface was shared. */
|
|
56
60
|
export type MarketTextStyle = NativeListTextStyle;
|
|
@@ -254,6 +258,8 @@ type VisualWithImage = Readonly<{
|
|
|
254
258
|
overlays?: readonly VisualOverlay[];
|
|
255
259
|
borderStyle?: 'dashed';
|
|
256
260
|
borderColor?: string;
|
|
261
|
+
/** Solid border width in logical units (0 < width <= 4); defaults to 1. Use the host's hairline width for a hairline. */
|
|
262
|
+
borderWidth?: number;
|
|
257
263
|
image?: ImageSource;
|
|
258
264
|
fallbackText?: string;
|
|
259
265
|
fallbackTextColor?: string;
|
|
@@ -441,6 +447,8 @@ export type IdentityRow = RowBase & Readonly<{
|
|
|
441
447
|
titleLines?: 1 | 2;
|
|
442
448
|
/** Zero displays the complete subtitle. */
|
|
443
449
|
subtitleLines?: 0 | 1 | 2;
|
|
450
|
+
/** Drop the trailing column (and its gap) when the row has no trailing accessories. Omitted keeps the legacy 12-point reservation. */
|
|
451
|
+
collapseEmptyTrailing?: boolean;
|
|
444
452
|
badges?: readonly BadgeModel[];
|
|
445
453
|
trailing?: readonly TrailingAccessory[];
|
|
446
454
|
draggable?: boolean;
|
|
@@ -524,6 +532,15 @@ export type DataColumn = Readonly<{
|
|
|
524
532
|
textSegments?: readonly ValueTextSegment[];
|
|
525
533
|
titleIcon?: IdentityRow['titleIcon'];
|
|
526
534
|
secondaryTitleIcon?: IdentityRow['titleIcon'];
|
|
535
|
+
/**
|
|
536
|
+
* Web-only passive label before the primary column text. The caller supplies
|
|
537
|
+
* both colors as #RRGGBB or #RRGGBBAA; native renderers ignore the field.
|
|
538
|
+
*/
|
|
539
|
+
webLeadingBadge?: Readonly<{
|
|
540
|
+
text: string;
|
|
541
|
+
textColor: string;
|
|
542
|
+
backgroundColor: string;
|
|
543
|
+
}>;
|
|
527
544
|
secondaryLeadingText?: string;
|
|
528
545
|
secondaryText?: string;
|
|
529
546
|
secondaryTextSegments?: readonly ValueTextSegment[];
|
|
@@ -868,6 +885,12 @@ export type NativeListSnapshot = Readonly<{
|
|
|
868
885
|
}>;
|
|
869
886
|
capabilities?: Readonly<{
|
|
870
887
|
reorderable?: boolean;
|
|
888
|
+
/**
|
|
889
|
+
* `row` (default) starts a reorder from a long press anywhere on a
|
|
890
|
+
* reorderable row. `handle` starts it only from a long press on the
|
|
891
|
+
* row's trailing `drag` accessory.
|
|
892
|
+
*/
|
|
893
|
+
reorderActivation?: 'row' | 'handle';
|
|
871
894
|
pullToRefresh?: boolean;
|
|
872
895
|
refreshing?: boolean;
|
|
873
896
|
refreshTriggerDistance?: number;
|
|
@@ -888,7 +911,7 @@ export type PatchClearableChanges<Row, Keys extends keyof Row> = Readonly<{
|
|
|
888
911
|
export type RowPatch = Readonly<{
|
|
889
912
|
type: 'identity';
|
|
890
913
|
key: string;
|
|
891
|
-
changes: PatchClearableChanges<IdentityRow, CommonPatchFields | 'title' | 'titleSuffixes' | 'titleIcon' | 'secondaryTitleIcon' | 'titleImage' | 'subtitle' | 'subtitleLines' | 'contentHeight' | 'longPressActionKey' | 'tertiary' | 'tertiaryTone' | 'badges' | 'trailing' | 'leading' | 'leadingAction' | 'titleMatch' | 'titleActionKey' | 'titleActionOnHover' | 'subtitleSegments'>;
|
|
914
|
+
changes: PatchClearableChanges<IdentityRow, CommonPatchFields | 'title' | 'titleSuffixes' | 'titleIcon' | 'secondaryTitleIcon' | 'titleImage' | 'subtitle' | 'subtitleLines' | 'collapseEmptyTrailing' | 'contentHeight' | 'longPressActionKey' | 'tertiary' | 'tertiaryTone' | 'badges' | 'trailing' | 'leading' | 'leadingAction' | 'titleMatch' | 'titleActionKey' | 'titleActionOnHover' | 'subtitleSegments'>;
|
|
892
915
|
}> | Readonly<{
|
|
893
916
|
type: 'rail';
|
|
894
917
|
key: string;
|
|
@@ -139,7 +139,7 @@ export declare class NativeListWebEngine {
|
|
|
139
139
|
private reorderSettlingKey;
|
|
140
140
|
private reorderCompactKey;
|
|
141
141
|
private reorderExpandingKey;
|
|
142
|
-
private
|
|
142
|
+
private readonly reorderClickPointers;
|
|
143
143
|
private pullStartY;
|
|
144
144
|
private pullDistance;
|
|
145
145
|
private virtualizationEnabled;
|
|
@@ -271,12 +271,18 @@ export declare class NativeListWebEngine {
|
|
|
271
271
|
private emitHoverAction;
|
|
272
272
|
private handleIconHelpPointerDown;
|
|
273
273
|
private handleTitlePointerOut;
|
|
274
|
+
private clearReorderClick;
|
|
275
|
+
private reorderClickTarget;
|
|
276
|
+
private trackReorderPress;
|
|
277
|
+
private trackReorderRelease;
|
|
278
|
+
private legacyClickPointerId;
|
|
274
279
|
private handleClick;
|
|
275
280
|
private handleKeyDown;
|
|
276
281
|
private startKeyboardReorder;
|
|
277
282
|
private moveKeyboardReorder;
|
|
278
283
|
private finishKeyboardReorder;
|
|
279
284
|
private cancelKeyboardReorder;
|
|
285
|
+
private focusMountedRow;
|
|
280
286
|
private handleExternalScroll;
|
|
281
287
|
private handleScroll;
|
|
282
288
|
private handleWindowResize;
|
|
@@ -293,6 +299,7 @@ export declare class NativeListWebEngine {
|
|
|
293
299
|
private handlePullEnd;
|
|
294
300
|
private updateRefreshIndicator;
|
|
295
301
|
private handleReorderPointerDown;
|
|
302
|
+
private canStartPointerReorder;
|
|
296
303
|
private activatePointerReorder;
|
|
297
304
|
private captureReorderPointer;
|
|
298
305
|
private releaseReorderPointer;
|
|
@@ -6,7 +6,7 @@ export declare function rowRenderer(row: RowModel): {
|
|
|
6
6
|
create: (document: Document, primitives: Readonly<{
|
|
7
7
|
background: string;
|
|
8
8
|
icon: (element: HTMLElement, name: string) => void;
|
|
9
|
-
iconAction: (name: string, actionKey: string | undefined, disabled?: boolean, tintColor?: string) => HTMLElement;
|
|
9
|
+
iconAction: (name: string, actionKey: string | undefined, disabled?: boolean, tintColor?: string, accessibilityLabel?: string) => HTMLElement;
|
|
10
10
|
accessory: (rowKey: string, descriptor: import("../..").TrailingAccessory, slot: number) => HTMLElement;
|
|
11
11
|
visual: (source: import("../..").LeadingVisual | undefined, presentation?: string) => HTMLElement | undefined;
|
|
12
12
|
thumbnail: (source: Readonly<{
|
|
@@ -35,13 +35,15 @@ export declare function rowRenderer(row: RowModel): {
|
|
|
35
35
|
alignment?: "start" | "center" | "end";
|
|
36
36
|
verticalAlignment?: "top" | "center" | "bottom";
|
|
37
37
|
offsetY?: number;
|
|
38
|
+
letterSpacing?: number;
|
|
39
|
+
tabularNumbers?: boolean;
|
|
38
40
|
}>, defaultLines?: number) => void;
|
|
39
41
|
dispose: (element: HTMLElement) => void;
|
|
40
42
|
}>) => HTMLElement;
|
|
41
43
|
bind: (body: HTMLElement, primitives: Readonly<{
|
|
42
44
|
background: string;
|
|
43
45
|
icon: (element: HTMLElement, name: string) => void;
|
|
44
|
-
iconAction: (name: string, actionKey: string | undefined, disabled?: boolean, tintColor?: string) => HTMLElement;
|
|
46
|
+
iconAction: (name: string, actionKey: string | undefined, disabled?: boolean, tintColor?: string, accessibilityLabel?: string) => HTMLElement;
|
|
45
47
|
accessory: (rowKey: string, descriptor: import("../..").TrailingAccessory, slot: number) => HTMLElement;
|
|
46
48
|
visual: (source: import("../..").LeadingVisual | undefined, presentation?: string) => HTMLElement | undefined;
|
|
47
49
|
thumbnail: (source: Readonly<{
|
|
@@ -70,6 +72,8 @@ export declare function rowRenderer(row: RowModel): {
|
|
|
70
72
|
alignment?: "start" | "center" | "end";
|
|
71
73
|
verticalAlignment?: "top" | "center" | "bottom";
|
|
72
74
|
offsetY?: number;
|
|
75
|
+
letterSpacing?: number;
|
|
76
|
+
tabularNumbers?: boolean;
|
|
73
77
|
}>, defaultLines?: number) => void;
|
|
74
78
|
dispose: (element: HTMLElement) => void;
|
|
75
79
|
}>) => void;
|
|
@@ -2,7 +2,7 @@ import type { TrailingAccessory, ImageSource, LeadingVisual, NativeListTextStyle
|
|
|
2
2
|
export type RowPrimitives = Readonly<{
|
|
3
3
|
background: string;
|
|
4
4
|
icon: (element: HTMLElement, name: string) => void;
|
|
5
|
-
iconAction: (name: string, actionKey: string | undefined, disabled?: boolean, tintColor?: string) => HTMLElement;
|
|
5
|
+
iconAction: (name: string, actionKey: string | undefined, disabled?: boolean, tintColor?: string, accessibilityLabel?: string) => HTMLElement;
|
|
6
6
|
accessory: (rowKey: string, descriptor: TrailingAccessory, slot: number) => HTMLElement;
|
|
7
7
|
visual: (source: LeadingVisual | undefined, presentation?: string) => HTMLElement | undefined;
|
|
8
8
|
thumbnail: (source: ImageSource) => HTMLElement | undefined;
|
package/package.json
CHANGED
package/src/models.ts
CHANGED
|
@@ -66,6 +66,10 @@ export type NativeListTextStyle = Readonly<{
|
|
|
66
66
|
verticalAlignment?: 'top' | 'center' | 'bottom';
|
|
67
67
|
/** Optical translation in logical units; does not affect layout. */
|
|
68
68
|
offsetY?: number;
|
|
69
|
+
/** Extra spacing between glyphs in logical units. An explicit 0 turns off the platform's pair kerning on iOS, matching React Native `letterSpacing: 0`. */
|
|
70
|
+
letterSpacing?: number;
|
|
71
|
+
/** Equal-width (tabular) digits, matching the App's `SizableText` default. Omission keeps each template's current digits. */
|
|
72
|
+
tabularNumbers?: boolean;
|
|
69
73
|
}>;
|
|
70
74
|
|
|
71
75
|
/** Retained alias: Market shipped this name before the style surface was shared. */
|
|
@@ -372,6 +376,8 @@ type VisualWithImage = Readonly<{
|
|
|
372
376
|
overlays?: readonly VisualOverlay[];
|
|
373
377
|
borderStyle?: 'dashed';
|
|
374
378
|
borderColor?: string;
|
|
379
|
+
/** Solid border width in logical units (0 < width <= 4); defaults to 1. Use the host's hairline width for a hairline. */
|
|
380
|
+
borderWidth?: number;
|
|
375
381
|
image?: ImageSource;
|
|
376
382
|
fallbackText?: string;
|
|
377
383
|
fallbackTextColor?: string;
|
|
@@ -557,6 +563,8 @@ export type IdentityRow = RowBase &
|
|
|
557
563
|
titleLines?: 1 | 2;
|
|
558
564
|
/** Zero displays the complete subtitle. */
|
|
559
565
|
subtitleLines?: 0 | 1 | 2;
|
|
566
|
+
/** Drop the trailing column (and its gap) when the row has no trailing accessories. Omitted keeps the legacy 12-point reservation. */
|
|
567
|
+
collapseEmptyTrailing?: boolean;
|
|
560
568
|
badges?: readonly BadgeModel[];
|
|
561
569
|
trailing?: readonly TrailingAccessory[];
|
|
562
570
|
draggable?: boolean;
|
|
@@ -650,6 +658,15 @@ export type DataColumn = Readonly<{
|
|
|
650
658
|
textSegments?: readonly ValueTextSegment[];
|
|
651
659
|
titleIcon?: IdentityRow['titleIcon'];
|
|
652
660
|
secondaryTitleIcon?: IdentityRow['titleIcon'];
|
|
661
|
+
/**
|
|
662
|
+
* Web-only passive label before the primary column text. The caller supplies
|
|
663
|
+
* both colors as #RRGGBB or #RRGGBBAA; native renderers ignore the field.
|
|
664
|
+
*/
|
|
665
|
+
webLeadingBadge?: Readonly<{
|
|
666
|
+
text: string;
|
|
667
|
+
textColor: string;
|
|
668
|
+
backgroundColor: string;
|
|
669
|
+
}>;
|
|
653
670
|
secondaryLeadingText?: string;
|
|
654
671
|
secondaryText?: string;
|
|
655
672
|
secondaryTextSegments?: readonly ValueTextSegment[];
|
|
@@ -1055,6 +1072,12 @@ export type NativeListSnapshot = Readonly<{
|
|
|
1055
1072
|
}>;
|
|
1056
1073
|
capabilities?: Readonly<{
|
|
1057
1074
|
reorderable?: boolean;
|
|
1075
|
+
/**
|
|
1076
|
+
* `row` (default) starts a reorder from a long press anywhere on a
|
|
1077
|
+
* reorderable row. `handle` starts it only from a long press on the
|
|
1078
|
+
* row's trailing `drag` accessory.
|
|
1079
|
+
*/
|
|
1080
|
+
reorderActivation?: 'row' | 'handle';
|
|
1058
1081
|
pullToRefresh?: boolean;
|
|
1059
1082
|
refreshing?: boolean;
|
|
1060
1083
|
refreshTriggerDistance?: number;
|
|
@@ -1103,6 +1126,7 @@ export type RowPatch =
|
|
|
1103
1126
|
| 'titleImage'
|
|
1104
1127
|
| 'subtitle'
|
|
1105
1128
|
| 'subtitleLines'
|
|
1129
|
+
| 'collapseEmptyTrailing'
|
|
1106
1130
|
| 'contentHeight'
|
|
1107
1131
|
| 'longPressActionKey'
|
|
1108
1132
|
| 'tertiary'
|
package/src/validation.ts
CHANGED
|
@@ -282,6 +282,8 @@ function assertTextStyle(
|
|
|
282
282
|
'alignment',
|
|
283
283
|
'verticalAlignment',
|
|
284
284
|
'offsetY',
|
|
285
|
+
'letterSpacing',
|
|
286
|
+
'tabularNumbers',
|
|
285
287
|
...additionalKeys,
|
|
286
288
|
],
|
|
287
289
|
path,
|
|
@@ -333,6 +335,17 @@ function assertTextStyle(
|
|
|
333
335
|
fail(`${path}.verticalAlignment`, 'must be top, center, or bottom');
|
|
334
336
|
}
|
|
335
337
|
assertBoundedStyleNumber(style.offsetY, `${path}.offsetY`, -8, 8);
|
|
338
|
+
assertBoundedStyleNumber(
|
|
339
|
+
style.letterSpacing,
|
|
340
|
+
`${path}.letterSpacing`,
|
|
341
|
+
-4,
|
|
342
|
+
10
|
|
343
|
+
);
|
|
344
|
+
if (
|
|
345
|
+
style.tabularNumbers !== undefined &&
|
|
346
|
+
typeof style.tabularNumbers !== 'boolean'
|
|
347
|
+
)
|
|
348
|
+
fail(`${path}.tabularNumbers`, 'must be a boolean');
|
|
336
349
|
}
|
|
337
350
|
|
|
338
351
|
function assertBoxStyle(style: RowBoxStyle, path: string): void {
|
|
@@ -1344,6 +1357,32 @@ function assertButtonGroup(
|
|
|
1344
1357
|
});
|
|
1345
1358
|
}
|
|
1346
1359
|
|
|
1360
|
+
// A passive label: its text and two caller colors, with no action or style slot.
|
|
1361
|
+
function assertWebLeadingBadge(value: unknown, path: string): void {
|
|
1362
|
+
if (value === undefined) return;
|
|
1363
|
+
const badge = protocolObject(value, path);
|
|
1364
|
+
assertUnknownKeys(
|
|
1365
|
+
badge,
|
|
1366
|
+
['text', 'textColor', 'backgroundColor'],
|
|
1367
|
+
path,
|
|
1368
|
+
'web leading badge key'
|
|
1369
|
+
);
|
|
1370
|
+
if (
|
|
1371
|
+
typeof badge.text !== 'string' ||
|
|
1372
|
+
!badge.text.trim() ||
|
|
1373
|
+
badge.text.length > MAX_TEXT_LENGTH
|
|
1374
|
+
)
|
|
1375
|
+
fail(`${path}.text`, 'must be non-blank within the text limit');
|
|
1376
|
+
for (const field of ['textColor', 'backgroundColor']) {
|
|
1377
|
+
const color = badge[field];
|
|
1378
|
+
if (
|
|
1379
|
+
typeof color !== 'string' ||
|
|
1380
|
+
!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(color)
|
|
1381
|
+
)
|
|
1382
|
+
fail(`${path}.${field}`, 'must be #RRGGBB or #RRGGBBAA');
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1347
1386
|
function assertIdentityExtras(
|
|
1348
1387
|
row: Pick<
|
|
1349
1388
|
IdentityRow,
|
|
@@ -1492,6 +1531,15 @@ function assertLeadingVisual(
|
|
|
1492
1531
|
!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(visual.fallbackTextColor))
|
|
1493
1532
|
)
|
|
1494
1533
|
fail(`${path}.fallbackTextColor`, 'must be a hex color');
|
|
1534
|
+
if (
|
|
1535
|
+
'borderWidth' in visual &&
|
|
1536
|
+
visual.borderWidth !== undefined &&
|
|
1537
|
+
(typeof visual.borderWidth !== 'number' ||
|
|
1538
|
+
!Number.isFinite(visual.borderWidth) ||
|
|
1539
|
+
visual.borderWidth <= 0 ||
|
|
1540
|
+
visual.borderWidth > 4)
|
|
1541
|
+
)
|
|
1542
|
+
fail(`${path}.borderWidth`, 'must be within (0, 4]');
|
|
1495
1543
|
if (
|
|
1496
1544
|
visual.fallbackIcon?.size !== undefined &&
|
|
1497
1545
|
(!Number.isFinite(visual.fallbackIcon.size) ||
|
|
@@ -1939,6 +1987,10 @@ function assertRow(
|
|
|
1939
1987
|
assertKey(column.key, `${path}.columns[${columnIndex}].key`);
|
|
1940
1988
|
assertText(column.text, `${path}.columns[${columnIndex}].text`);
|
|
1941
1989
|
assertIdentityExtras(column, `${path}.columns[${columnIndex}]`);
|
|
1990
|
+
assertWebLeadingBadge(
|
|
1991
|
+
column.webLeadingBadge,
|
|
1992
|
+
`${path}.columns[${columnIndex}].webLeadingBadge`
|
|
1993
|
+
);
|
|
1942
1994
|
for (const field of [
|
|
1943
1995
|
'textSegments',
|
|
1944
1996
|
'secondaryTextSegments',
|
|
@@ -2438,6 +2490,7 @@ const ROW_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
|
2438
2490
|
'tertiaryTone',
|
|
2439
2491
|
'titleLines',
|
|
2440
2492
|
'subtitleLines',
|
|
2493
|
+
'collapseEmptyTrailing',
|
|
2441
2494
|
'badges',
|
|
2442
2495
|
'trailing',
|
|
2443
2496
|
'draggable',
|
|
@@ -2615,6 +2668,7 @@ const PATCH_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
|
2615
2668
|
'tertiary',
|
|
2616
2669
|
'tertiaryTone',
|
|
2617
2670
|
'subtitleLines',
|
|
2671
|
+
'collapseEmptyTrailing',
|
|
2618
2672
|
'badges',
|
|
2619
2673
|
'trailing',
|
|
2620
2674
|
],
|
|
@@ -2777,6 +2831,7 @@ const PROTOCOL_NUMBER_FIELDS = new Set([
|
|
|
2777
2831
|
'opacity',
|
|
2778
2832
|
'offsetY',
|
|
2779
2833
|
'offsetX',
|
|
2834
|
+
'letterSpacing',
|
|
2780
2835
|
'cornerRadius',
|
|
2781
2836
|
'borderWidth',
|
|
2782
2837
|
'horizontalPadding',
|
|
@@ -2889,7 +2944,7 @@ function assertProtocolFields(
|
|
|
2889
2944
|
PROTOCOL_NUMBER_FIELDS.has(field) &&
|
|
2890
2945
|
typeof item === 'number' &&
|
|
2891
2946
|
item < 0 &&
|
|
2892
|
-
!['offsetX', 'offsetY'].includes(field)
|
|
2947
|
+
!['offsetX', 'offsetY', 'letterSpacing'].includes(field)
|
|
2893
2948
|
)
|
|
2894
2949
|
fail(fieldPath, 'must be non-negative');
|
|
2895
2950
|
if (
|
|
@@ -2900,7 +2955,10 @@ function assertProtocolFields(
|
|
|
2900
2955
|
fail(fieldPath, 'must be regular, medium, semibold, or bold');
|
|
2901
2956
|
if (field === 'buttonStyle' && item !== 'tertiary')
|
|
2902
2957
|
fail(fieldPath, 'must be tertiary');
|
|
2903
|
-
if (
|
|
2958
|
+
if (
|
|
2959
|
+
(field === 'hideLeading' || field === 'collapseEmptyTrailing') &&
|
|
2960
|
+
typeof item !== 'boolean'
|
|
2961
|
+
)
|
|
2904
2962
|
fail(fieldPath, 'must be boolean');
|
|
2905
2963
|
if (
|
|
2906
2964
|
field === 'key' ||
|
|
@@ -3048,7 +3106,13 @@ function assertRowProtocol(row: RowModel, path: string): void {
|
|
|
3048
3106
|
row.columns.forEach((column, index) => {
|
|
3049
3107
|
const columnPath = `${path}.columns[${index}]`;
|
|
3050
3108
|
protocolObject(column, columnPath);
|
|
3051
|
-
if (isDevelopment())
|
|
3109
|
+
if (isDevelopment()) {
|
|
3110
|
+
assertIdentityExtras(column, columnPath);
|
|
3111
|
+
assertWebLeadingBadge(
|
|
3112
|
+
column.webLeadingBadge,
|
|
3113
|
+
`${columnPath}.webLeadingBadge`
|
|
3114
|
+
);
|
|
3115
|
+
}
|
|
3052
3116
|
});
|
|
3053
3117
|
if (isDevelopment())
|
|
3054
3118
|
assertTrailingAccessories(row.trailing, `${path}.trailing`);
|
|
@@ -3102,6 +3166,17 @@ function assertRowProtocol(row: RowModel, path: string): void {
|
|
|
3102
3166
|
|
|
3103
3167
|
function assertSnapshotProtocol(snapshot: NativeListSnapshot): void {
|
|
3104
3168
|
protocolObject(snapshot, 'snapshot');
|
|
3169
|
+
const reorderActivation = snapshot.capabilities?.reorderActivation;
|
|
3170
|
+
if (
|
|
3171
|
+
reorderActivation !== undefined &&
|
|
3172
|
+
reorderActivation !== 'row' &&
|
|
3173
|
+
reorderActivation !== 'handle'
|
|
3174
|
+
) {
|
|
3175
|
+
fail(
|
|
3176
|
+
'snapshot.capabilities.reorderActivation',
|
|
3177
|
+
"must be 'row' or 'handle'"
|
|
3178
|
+
);
|
|
3179
|
+
}
|
|
3105
3180
|
if (snapshot.disclosure !== undefined) {
|
|
3106
3181
|
protocolObject(snapshot.disclosure, 'snapshot.disclosure');
|
|
3107
3182
|
if (typeof snapshot.disclosure.expanded !== 'boolean')
|
|
@@ -3244,6 +3319,7 @@ const VISUAL_FIELDS = [
|
|
|
3244
3319
|
'overlays',
|
|
3245
3320
|
'borderStyle',
|
|
3246
3321
|
'borderColor',
|
|
3322
|
+
'borderWidth',
|
|
3247
3323
|
'cornerIcon',
|
|
3248
3324
|
];
|
|
3249
3325
|
const TEXT_STYLE_FIELDS = [
|
|
@@ -3257,6 +3333,8 @@ const TEXT_STYLE_FIELDS = [
|
|
|
3257
3333
|
'alignment',
|
|
3258
3334
|
'verticalAlignment',
|
|
3259
3335
|
'offsetY',
|
|
3336
|
+
'letterSpacing',
|
|
3337
|
+
'tabularNumbers',
|
|
3260
3338
|
];
|
|
3261
3339
|
const ACCESSORY_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
3262
3340
|
value: ['kind', 'text', 'secondary', 'textSegments'],
|
|
@@ -3507,6 +3585,7 @@ const NESTED_DECORATION_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
|
3507
3585
|
'textSegments',
|
|
3508
3586
|
'titleIcon',
|
|
3509
3587
|
'secondaryTitleIcon',
|
|
3588
|
+
'webLeadingBadge',
|
|
3510
3589
|
'secondaryLeadingText',
|
|
3511
3590
|
'secondaryText',
|
|
3512
3591
|
'secondaryTextSegments',
|
|
@@ -3581,6 +3660,26 @@ const NESTED_DECORATION_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
|
3581
3660
|
|
|
3582
3661
|
function sanitizeDecoration(value: unknown, field: string): unknown {
|
|
3583
3662
|
if (value === undefined || value === null) return undefined;
|
|
3663
|
+
// All or nothing: a badge without valid text and both colors is dropped, and
|
|
3664
|
+
// only its three declared fields are kept.
|
|
3665
|
+
if (field === 'webLeadingBadge') {
|
|
3666
|
+
if (
|
|
3667
|
+
!isRecord(value) ||
|
|
3668
|
+
typeof value.text !== 'string' ||
|
|
3669
|
+
!value.text.trim() ||
|
|
3670
|
+
value.text.length > MAX_TEXT_LENGTH
|
|
3671
|
+
)
|
|
3672
|
+
return undefined;
|
|
3673
|
+
const { textColor, backgroundColor } = value;
|
|
3674
|
+
if (
|
|
3675
|
+
typeof textColor !== 'string' ||
|
|
3676
|
+
!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(textColor) ||
|
|
3677
|
+
typeof backgroundColor !== 'string' ||
|
|
3678
|
+
!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(backgroundColor)
|
|
3679
|
+
)
|
|
3680
|
+
return undefined;
|
|
3681
|
+
return { text: value.text, textColor, backgroundColor };
|
|
3682
|
+
}
|
|
3584
3683
|
if (
|
|
3585
3684
|
!Array.isArray(value) &&
|
|
3586
3685
|
[
|
|
@@ -3622,6 +3721,9 @@ function sanitizeDecoration(value: unknown, field: string): unknown {
|
|
|
3622
3721
|
: items.filter((item) => item !== undefined);
|
|
3623
3722
|
}
|
|
3624
3723
|
if (!isRecord(value)) return value;
|
|
3724
|
+
const isLeadingVisual = ['leading', 'visual', 'secondaryLeading'].includes(
|
|
3725
|
+
field
|
|
3726
|
+
);
|
|
3625
3727
|
let object = value;
|
|
3626
3728
|
if (field === 'titleImage') {
|
|
3627
3729
|
const image = sanitizeImage(value.image);
|
|
@@ -3645,7 +3747,7 @@ function sanitizeDecoration(value: unknown, field: string): unknown {
|
|
|
3645
3747
|
) {
|
|
3646
3748
|
if (typeof value.name !== 'string' || !value.name.trim()) return undefined;
|
|
3647
3749
|
object = pickFields(value, ICON_FIELDS);
|
|
3648
|
-
} else if (
|
|
3750
|
+
} else if (isLeadingVisual) {
|
|
3649
3751
|
object = pickFields(value, VISUAL_FIELDS);
|
|
3650
3752
|
} else if (field === 'media') {
|
|
3651
3753
|
object = pickFields(value, ['source', 'probeOrder']);
|
|
@@ -3744,6 +3846,24 @@ function sanitizeDecoration(value: unknown, field: string): unknown {
|
|
|
3744
3846
|
const next: Record<string, unknown> = {};
|
|
3745
3847
|
for (const [key, item] of Object.entries(object)) {
|
|
3746
3848
|
if (item === undefined || item === null) continue;
|
|
3849
|
+
if (
|
|
3850
|
+
isLeadingVisual &&
|
|
3851
|
+
key === 'borderWidth' &&
|
|
3852
|
+
(typeof item !== 'number' ||
|
|
3853
|
+
!Number.isFinite(item) ||
|
|
3854
|
+
item <= 0 ||
|
|
3855
|
+
item > 4)
|
|
3856
|
+
)
|
|
3857
|
+
continue;
|
|
3858
|
+
if (
|
|
3859
|
+
key === 'letterSpacing' &&
|
|
3860
|
+
(typeof item !== 'number' ||
|
|
3861
|
+
!Number.isFinite(item) ||
|
|
3862
|
+
item < -4 ||
|
|
3863
|
+
item > 10)
|
|
3864
|
+
)
|
|
3865
|
+
continue;
|
|
3866
|
+
if (key === 'tabularNumbers' && typeof item !== 'boolean') continue;
|
|
3747
3867
|
if (
|
|
3748
3868
|
(/color$/i.test(key) || /background$/i.test(key)) &&
|
|
3749
3869
|
(typeof item !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(item))
|
|
@@ -3808,7 +3928,7 @@ function sanitizeDecoration(value: unknown, field: string): unknown {
|
|
|
3808
3928
|
typeof item !== 'object' &&
|
|
3809
3929
|
typeof item === 'number' &&
|
|
3810
3930
|
(!Number.isFinite(item) ||
|
|
3811
|
-
(item < 0 && !['offsetX', 'offsetY'].includes(key)))
|
|
3931
|
+
(item < 0 && !['offsetX', 'offsetY', 'letterSpacing'].includes(key)))
|
|
3812
3932
|
)
|
|
3813
3933
|
continue;
|
|
3814
3934
|
if (
|
|
@@ -4401,6 +4521,10 @@ function assertPatchChanges(patch: PatchValues, index: number): void {
|
|
|
4401
4521
|
assertKey(column.key, `${path}.columns[${columnIndex}].key`);
|
|
4402
4522
|
assertText(column.text, `${path}.columns[${columnIndex}].text`);
|
|
4403
4523
|
assertIdentityExtras(column, `${path}.columns[${columnIndex}]`);
|
|
4524
|
+
assertWebLeadingBadge(
|
|
4525
|
+
column.webLeadingBadge,
|
|
4526
|
+
`${path}.columns[${columnIndex}].webLeadingBadge`
|
|
4527
|
+
);
|
|
4404
4528
|
for (const field of [
|
|
4405
4529
|
'textSegments',
|
|
4406
4530
|
'secondaryTextSegments',
|
|
@@ -18,6 +18,7 @@ export const nativeListGeneratedIcons: Readonly<Record<string, string>> = {
|
|
|
18
18
|
GasSolid: 'GasSolid',
|
|
19
19
|
GlobusOutline: 'GlobusOutline',
|
|
20
20
|
GoogleIllus: 'GoogleIllus',
|
|
21
|
+
InfoCircleOutline: 'InfoCircleOutline',
|
|
21
22
|
LockSolid: 'LockSolid',
|
|
22
23
|
PencilOutline: 'PencilOutline',
|
|
23
24
|
PlusLargeOutline: 'PlusLargeOutline',
|