@onekeyfe/react-native-native-list 6.8.0-9 → 6.8.0-alpha.540

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 (49) hide show
  1. package/android/build.gradle +3 -0
  2. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
  3. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +70 -33
  4. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
  5. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
  6. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +21 -4
  7. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
  8. package/android/src/main/java/com/onekey/nativelist/NativeListRowUpdates.kt +34 -0
  9. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
  10. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
  11. package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
  12. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentitySubtitleBindingTest.kt +177 -0
  13. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
  14. package/docs/SPEC.md +127 -2
  15. package/docs/STYLE_SPEC.md +7 -1
  16. package/ios/NativeListAccessoryStack.swift +22 -0
  17. package/ios/NativeListDataRowRenderer.swift +12 -5
  18. package/ios/NativeListIdentityRenderer.swift +36 -58
  19. package/ios/NativeListLeadingVisual.swift +8 -0
  20. package/ios/NativeListMarketRenderer.swift +6 -2
  21. package/ios/NativeListModels.swift +7 -0
  22. package/ios/NativeListResolvedText.swift +9 -7
  23. package/ios/NativeListSectionHeaderRenderer.swift +9 -43
  24. package/ios/NativeListTextStyles.swift +72 -12
  25. package/ios/RNCNativeListView.swift +124 -20
  26. package/ios/tests/NativeListLifecycleTests.swift +105 -0
  27. package/lib/module/validation.js +21 -10
  28. package/lib/module/web/NativeListWebEngine.js +213 -23
  29. package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
  30. package/lib/module/web/templates/IdentityRowRenderer.js +12 -1
  31. package/lib/module/web/templates/MarketRowRenderer.js +2 -0
  32. package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
  33. package/lib/module/web/templates/RowElements.js +2 -2
  34. package/lib/module/web/templates/RowText.js +2 -0
  35. package/lib/typescript/src/models.d.ts +15 -1
  36. package/lib/typescript/src/web/NativeListWebEngine.d.ts +8 -1
  37. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
  38. package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
  39. package/package.json +1 -1
  40. package/src/models.ts +15 -0
  41. package/src/validation.ts +67 -4
  42. package/src/web/NativeListWebEngine.ts +382 -27
  43. package/src/web/templates/ActivityRowRenderer.ts +1 -1
  44. package/src/web/templates/IdentityRowRenderer.ts +23 -1
  45. package/src/web/templates/MarketRowRenderer.ts +2 -0
  46. package/src/web/templates/MediaTileRowRenderer.ts +1 -0
  47. package/src/web/templates/RowElements.ts +3 -2
  48. package/src/web/templates/RowText.ts +6 -0
  49. package/src/web/templates/RowVisual.ts +2 -1
@@ -139,7 +139,7 @@ export declare class NativeListWebEngine {
139
139
  private reorderSettlingKey;
140
140
  private reorderCompactKey;
141
141
  private reorderExpandingKey;
142
- private suppressClickUntil;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-list",
3
- "version": "6.8.0-9",
3
+ "version": "6.8.0-alpha.540",
4
4
  "description": "Template-driven native RecyclerView and UICollectionView for React Native",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
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;
@@ -1064,6 +1072,12 @@ export type NativeListSnapshot = Readonly<{
1064
1072
  }>;
1065
1073
  capabilities?: Readonly<{
1066
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';
1067
1081
  pullToRefresh?: boolean;
1068
1082
  refreshing?: boolean;
1069
1083
  refreshTriggerDistance?: number;
@@ -1112,6 +1126,7 @@ export type RowPatch =
1112
1126
  | 'titleImage'
1113
1127
  | 'subtitle'
1114
1128
  | 'subtitleLines'
1129
+ | 'collapseEmptyTrailing'
1115
1130
  | 'contentHeight'
1116
1131
  | 'longPressActionKey'
1117
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 {
@@ -1518,6 +1531,15 @@ function assertLeadingVisual(
1518
1531
  !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(visual.fallbackTextColor))
1519
1532
  )
1520
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]');
1521
1543
  if (
1522
1544
  visual.fallbackIcon?.size !== undefined &&
1523
1545
  (!Number.isFinite(visual.fallbackIcon.size) ||
@@ -2468,6 +2490,7 @@ const ROW_FIELDS: Readonly<Record<string, readonly string[]>> = {
2468
2490
  'tertiaryTone',
2469
2491
  'titleLines',
2470
2492
  'subtitleLines',
2493
+ 'collapseEmptyTrailing',
2471
2494
  'badges',
2472
2495
  'trailing',
2473
2496
  'draggable',
@@ -2645,6 +2668,7 @@ const PATCH_FIELDS: Readonly<Record<string, readonly string[]>> = {
2645
2668
  'tertiary',
2646
2669
  'tertiaryTone',
2647
2670
  'subtitleLines',
2671
+ 'collapseEmptyTrailing',
2648
2672
  'badges',
2649
2673
  'trailing',
2650
2674
  ],
@@ -2807,6 +2831,7 @@ const PROTOCOL_NUMBER_FIELDS = new Set([
2807
2831
  'opacity',
2808
2832
  'offsetY',
2809
2833
  'offsetX',
2834
+ 'letterSpacing',
2810
2835
  'cornerRadius',
2811
2836
  'borderWidth',
2812
2837
  'horizontalPadding',
@@ -2919,7 +2944,7 @@ function assertProtocolFields(
2919
2944
  PROTOCOL_NUMBER_FIELDS.has(field) &&
2920
2945
  typeof item === 'number' &&
2921
2946
  item < 0 &&
2922
- !['offsetX', 'offsetY'].includes(field)
2947
+ !['offsetX', 'offsetY', 'letterSpacing'].includes(field)
2923
2948
  )
2924
2949
  fail(fieldPath, 'must be non-negative');
2925
2950
  if (
@@ -2930,7 +2955,10 @@ function assertProtocolFields(
2930
2955
  fail(fieldPath, 'must be regular, medium, semibold, or bold');
2931
2956
  if (field === 'buttonStyle' && item !== 'tertiary')
2932
2957
  fail(fieldPath, 'must be tertiary');
2933
- if (field === 'hideLeading' && typeof item !== 'boolean')
2958
+ if (
2959
+ (field === 'hideLeading' || field === 'collapseEmptyTrailing') &&
2960
+ typeof item !== 'boolean'
2961
+ )
2934
2962
  fail(fieldPath, 'must be boolean');
2935
2963
  if (
2936
2964
  field === 'key' ||
@@ -3138,6 +3166,17 @@ function assertRowProtocol(row: RowModel, path: string): void {
3138
3166
 
3139
3167
  function assertSnapshotProtocol(snapshot: NativeListSnapshot): void {
3140
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
+ }
3141
3180
  if (snapshot.disclosure !== undefined) {
3142
3181
  protocolObject(snapshot.disclosure, 'snapshot.disclosure');
3143
3182
  if (typeof snapshot.disclosure.expanded !== 'boolean')
@@ -3280,6 +3319,7 @@ const VISUAL_FIELDS = [
3280
3319
  'overlays',
3281
3320
  'borderStyle',
3282
3321
  'borderColor',
3322
+ 'borderWidth',
3283
3323
  'cornerIcon',
3284
3324
  ];
3285
3325
  const TEXT_STYLE_FIELDS = [
@@ -3293,6 +3333,8 @@ const TEXT_STYLE_FIELDS = [
3293
3333
  'alignment',
3294
3334
  'verticalAlignment',
3295
3335
  'offsetY',
3336
+ 'letterSpacing',
3337
+ 'tabularNumbers',
3296
3338
  ];
3297
3339
  const ACCESSORY_FIELDS: Readonly<Record<string, readonly string[]>> = {
3298
3340
  value: ['kind', 'text', 'secondary', 'textSegments'],
@@ -3679,6 +3721,9 @@ function sanitizeDecoration(value: unknown, field: string): unknown {
3679
3721
  : items.filter((item) => item !== undefined);
3680
3722
  }
3681
3723
  if (!isRecord(value)) return value;
3724
+ const isLeadingVisual = ['leading', 'visual', 'secondaryLeading'].includes(
3725
+ field
3726
+ );
3682
3727
  let object = value;
3683
3728
  if (field === 'titleImage') {
3684
3729
  const image = sanitizeImage(value.image);
@@ -3702,7 +3747,7 @@ function sanitizeDecoration(value: unknown, field: string): unknown {
3702
3747
  ) {
3703
3748
  if (typeof value.name !== 'string' || !value.name.trim()) return undefined;
3704
3749
  object = pickFields(value, ICON_FIELDS);
3705
- } else if (['leading', 'visual', 'secondaryLeading'].includes(field)) {
3750
+ } else if (isLeadingVisual) {
3706
3751
  object = pickFields(value, VISUAL_FIELDS);
3707
3752
  } else if (field === 'media') {
3708
3753
  object = pickFields(value, ['source', 'probeOrder']);
@@ -3801,6 +3846,24 @@ function sanitizeDecoration(value: unknown, field: string): unknown {
3801
3846
  const next: Record<string, unknown> = {};
3802
3847
  for (const [key, item] of Object.entries(object)) {
3803
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;
3804
3867
  if (
3805
3868
  (/color$/i.test(key) || /background$/i.test(key)) &&
3806
3869
  (typeof item !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(item))
@@ -3865,7 +3928,7 @@ function sanitizeDecoration(value: unknown, field: string): unknown {
3865
3928
  typeof item !== 'object' &&
3866
3929
  typeof item === 'number' &&
3867
3930
  (!Number.isFinite(item) ||
3868
- (item < 0 && !['offsetX', 'offsetY'].includes(key)))
3931
+ (item < 0 && !['offsetX', 'offsetY', 'letterSpacing'].includes(key)))
3869
3932
  )
3870
3933
  continue;
3871
3934
  if (