@jsb188/react 1.1.11 → 1.1.13

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.
@@ -1,5 +1,5 @@
1
1
  import type { ColorEnum } from '@jsb188/app/types/app.d.ts';
2
- import type { CSSProperties, ElementType, MouseEvent, ReactNode } from 'react';
2
+ import type { AriaAttributes, CSSProperties, ElementType, FocusEvent, KeyboardEvent, MouseEvent, ReactNode } from 'react';
3
3
 
4
4
  /**
5
5
  * Utility types
@@ -18,31 +18,25 @@ export interface ClientRectValues {
18
18
 
19
19
  export type POPosition =
20
20
  | 'top'
21
+ /** Above the anchor and centered on it, flipping below when the viewport top would clip it; `top` keeps its left-aligned placement. */
22
+ | 'top_center'
21
23
  | 'left'
22
24
  | 'right'
23
25
  | 'bottom'
24
26
  | 'bottom_left'
25
27
  | 'bottom_right';
26
- export type AbsolutePosition = Pick<
27
- CSSProperties,
28
- 'left' | 'right' | 'top' | 'bottom'
29
- >;
28
+ export type AbsolutePosition = Pick<CSSProperties, 'left' | 'right' | 'top' | 'bottom'>;
30
29
 
31
30
  export type POItemValue = string | number | boolean | null;
32
31
  export type POPrimitiveStateValue = POItemValue | undefined;
33
32
  export interface POStateRecord {
34
33
  [key: string]: POStateValue;
35
34
  }
36
- export type POStateValue = any;
35
+ export type POStateValue = POPrimitiveStateValue | Date | readonly POStateValue[] | POStateRecord | object;
37
36
  export type POFormState = Record<string, POStateValue>;
38
37
  export type POClassNameValue = string | false | null | undefined;
39
38
  export type POListItemClickFn = {
40
- bivarianceHack(
41
- name: string | null,
42
- value?: POStateValue,
43
- notEventBased?: boolean,
44
- dismissOnClick?: boolean,
45
- ): void;
39
+ bivarianceHack(name: string | null, value?: POStateValue, notEventBased?: boolean, dismissOnClick?: boolean): void;
46
40
  }['bivarianceHack'];
47
41
 
48
42
  export interface POLabelsAndValuesInputObj {
@@ -58,6 +52,7 @@ export interface POLabelsAndValuesInputObj {
58
52
 
59
53
  export interface POItemBase {
60
54
  __type: string;
55
+ id?: string;
61
56
  hidden?: boolean;
62
57
  }
63
58
 
@@ -70,18 +65,44 @@ export interface POListSubtitleObj extends POItemBase {
70
65
 
71
66
  export type PONListSubtitleObj = POListSubtitleObj;
72
67
 
68
+ export interface POListBannerActionObj {
69
+ name: string;
70
+ text: string;
71
+ value?: POStateValue;
72
+ designClassName?: POClassNameValue;
73
+ disabled?: boolean;
74
+ loading?: boolean;
75
+ }
76
+
77
+ export interface POListBannerItemObj extends POItemBase {
78
+ __type: 'LIST_BANNER_ITEM';
79
+ title: string;
80
+ subtitle: string;
81
+ description: string;
82
+ actions?: POListBannerActionObj[];
83
+ bannerClassName?: POClassNameValue;
84
+ bannerDesignClassName?: POClassNameValue;
85
+ titleDotColorClassName?: POClassNameValue;
86
+ }
87
+
73
88
  export interface POListBreakObj extends POItemBase {
74
89
  __type: 'BREAK';
75
90
  }
76
91
 
77
92
  export interface POActionListItemBase extends POItemBase {
93
+ ariaControls?: string;
94
+ ariaExpanded?: boolean;
95
+ ariaHasPopup?: AriaAttributes['aria-haspopup'];
78
96
  name?: string;
79
97
  value?: POStateValue;
80
98
  text: string;
99
+ secondaryText?: string | null;
81
100
  description?: string | null;
82
101
  className?: POClassNameValue;
83
102
  textClassName?: POClassNameValue;
84
103
  colorIndicator?: ColorEnum;
104
+ /** CSS color rendered as an icon-sized square after any leading icon. */
105
+ colorValue?: string | null;
85
106
  avatarDisplayName?: string;
86
107
  photoUri?: string | null;
87
108
  LinkComponent?: ElementType;
@@ -89,19 +110,24 @@ export interface POActionListItemBase extends POItemBase {
89
110
  iconName?: string;
90
111
  rightIconName?: string;
91
112
  rightIconClassName?: POClassNameValue;
113
+ rightText?: ReactNode;
92
114
  selected?: boolean;
93
115
  disabled?: boolean;
116
+ loading?: boolean;
117
+ preserveStyleWhenDisabled?: boolean;
94
118
  onClick?: POListItemClickFn;
95
- preset?: 'small' | 'default';
119
+ preset?: 'delete' | 'delete_hover' | 'small' | 'default';
96
120
  to?: string;
97
121
  }
98
122
 
99
123
  export interface POListItemObj extends POActionListItemBase {
100
124
  __type: 'LIST_ITEM' | 'LIST_ITEM_COPY';
125
+ /** Defaults to mt_4; an empty string removes the description's added spacing. */
126
+ descriptionSpacingClassName?: string;
127
+ truncateText?: boolean;
101
128
  }
102
129
 
103
- export interface POCheckListItemObj
104
- extends Omit<POActionListItemBase, 'onClick' | 'value'> {
130
+ export interface POCheckListItemObj extends Omit<POActionListItemBase, 'onClick' | 'value'> {
105
131
  __type: 'CHECK_LIST_ITEM' | 'SINGLE_OPTION_LIST_ITEM';
106
132
  value?: POItemValue;
107
133
  }
@@ -116,10 +142,28 @@ export interface POModalVariables {
116
142
  export interface POModalItemObj extends Omit<POActionListItemBase, 'onClick'> {
117
143
  __type: 'LIST_ITEM_POPUP' | 'LIST_ITEM_MODAL';
118
144
  variables: POModalVariables;
119
- useMutationArgs?: POStateValue[];
120
145
  }
121
146
 
122
147
  export type POListColorValue = ColorEnum | (string & {}) | null;
148
+
149
+ export interface POLayoutDesignerObj extends POItemBase {
150
+ __type: 'LAYOUT_DESIGNER';
151
+ canvasColor: string;
152
+ contentColor: string;
153
+ contentWidth: number;
154
+ contentWidthMax: number;
155
+ contentWidthMin: number;
156
+ disabled: boolean;
157
+ fontFamily: string;
158
+ linkColor: string;
159
+ onChangeCanvasColor: (value: string) => void;
160
+ onChangeContentColor: (value: string) => void;
161
+ onChangeContentWidth: (value: number) => void;
162
+ onChangePadding: (value: string) => void;
163
+ padding: string;
164
+ textColor: string;
165
+ }
166
+
123
167
  export type POListBorderStyleValue =
124
168
  | 'outlineAllCells'
125
169
  | 'outlineInnerCells'
@@ -133,36 +177,21 @@ export type POListBorderStyleValue =
133
177
  | 'outlineNone';
134
178
 
135
179
  export interface POListItemPickerOptionObj {
180
+ ariaLabel: string;
136
181
  iconName: string;
137
182
  selectedIconName: string;
138
183
  className?: string;
139
184
  value: POStateValue;
140
185
  }
141
186
 
142
- export type POListMutationHandler = (params: {
143
- variables?: Record<string, POStateValue>;
144
- }) => void;
145
-
146
- export interface POListMutationResult {
147
- allowEdit?: boolean;
148
- [mutationName: string]: POListMutationHandler | POStateValue;
149
- }
150
-
151
- export interface POListItemPickerObj
152
- extends Omit<
153
- POActionListItemBase,
154
- '__type' | 'text' | 'value' | 'iconName' | 'onClick'
155
- > {
187
+ export interface POListItemPickerObj extends Omit<POActionListItemBase, '__type' | 'text' | 'value' | 'iconName' | 'onClick'> {
156
188
  __type: 'LIST_ITEM_PICKER';
157
189
  label: string;
158
190
  options: POListItemPickerOptionObj[];
159
191
  selectedValue?: POStateValue;
160
- mutationName: string;
161
- useMutation?: (...args: POStateValue[]) => POListMutationResult;
162
- useMutationArgs?: POStateValue[];
163
- mutationVariables?:
164
- | Record<string, POStateValue>
165
- | ((value: POStateValue) => Record<string, POStateValue>);
192
+ allowEdit?: boolean;
193
+ /** Return false or reject to keep the picker open without committing its selection. */
194
+ onSelect: (value: POStateValue) => boolean | undefined | Promise<boolean | undefined>;
166
195
  }
167
196
 
168
197
  export interface POListColorsObj extends POItemBase {
@@ -172,9 +201,31 @@ export interface POListColorsObj extends POItemBase {
172
201
  label?: ReactNode;
173
202
  onClickCustomize?: POListItemClickFn;
174
203
  colors?: readonly POListColorValue[];
204
+ colorsPerRow?: number;
205
+ hideReset?: boolean;
175
206
  selectedValue?: POListColorValue | null;
176
207
  className?: POClassNameValue;
177
208
  disabled?: boolean;
209
+ stretchToFit?: boolean;
210
+ }
211
+
212
+ export interface POListBoxItemOptionObj {
213
+ className?: POClassNameValue;
214
+ iconName?: string;
215
+ text: ReactNode;
216
+ value: POItemValue;
217
+ }
218
+
219
+ export interface POListBoxItemsObj extends POItemBase {
220
+ __type: 'LIST_BOX_ITEMS';
221
+ boxesPerRow: number;
222
+ name?: string;
223
+ options: readonly POListBoxItemOptionObj[];
224
+ selectedClassName?: POClassNameValue;
225
+ selectedValue?: POItemValue;
226
+ unselectedClassName?: POClassNameValue;
227
+ className?: POClassNameValue;
228
+ disabled?: boolean;
178
229
  }
179
230
 
180
231
  export interface POListBorderStylesObj extends POItemBase {
@@ -225,17 +276,23 @@ export interface POListSubmenuObj
225
276
  POListVariables,
226
277
  | 'notReady'
227
278
  | 'designClassName'
279
+ | 'fontSizeClassName'
228
280
  | 'shadowClassName'
229
281
  | 'className'
230
282
  | 'savingValue'
283
+ | 'addFooterButton'
284
+ | 'footerButtonText'
231
285
  > {
232
286
  initialState?: POFormState | null;
287
+ /** `initial` seeds once per mounted submenu; `controlled` adopts later `initialState` changes. */
288
+ stateMode?: 'initial' | 'controlled';
233
289
  options: POListIfaceItem[];
234
290
  }
235
291
 
236
- export interface POListSubmenuItemObj
237
- extends Omit<POActionListItemBase, '__type' | 'onClick'> {
292
+ export interface POListSubmenuItemObj extends Omit<POActionListItemBase, '__type' | 'onClick'> {
238
293
  __type: 'LIST_SUBMENU_ITEM';
294
+ /** Stable identity used to reconcile this submenu while its definition changes. */
295
+ id: string;
239
296
  submenu: POListSubmenuObj;
240
297
  }
241
298
 
@@ -253,11 +310,12 @@ export interface PONavAvatarItemObj extends POItemBase {
253
310
  rightIconName?: string;
254
311
  square?: boolean;
255
312
  disabled?: boolean;
313
+ loading?: boolean;
256
314
  to?: string;
257
315
  }
258
316
 
259
317
  export interface PODateItemBase extends POItemBase {
260
- name?: string;
318
+ name: string;
261
319
  minDate?: Date;
262
320
  maxDate?: Date;
263
321
  }
@@ -266,12 +324,45 @@ export interface PODatePickerObj extends PODateItemBase {
266
324
  __type: 'DATE_PICKER';
267
325
  }
268
326
 
327
+ export interface POTimePickerObj extends POItemBase {
328
+ __type: 'TIME_PICKER';
329
+ name: string;
330
+ minTime?: string;
331
+ maxTime?: string;
332
+ }
333
+
334
+ export interface PODateTimePickerObj extends PODateItemBase {
335
+ __type: 'DATE_TIME_PICKER';
336
+ disabled?: boolean;
337
+ defaultHour?: number;
338
+ defaultMinute?: number;
339
+ defaultPeriod?: 'AM' | 'PM';
340
+ minTime?: string;
341
+ maxTime?: string;
342
+ submitText?: ReactNode;
343
+ }
344
+
269
345
  export interface PODateRangeObj extends PODateItemBase {
270
346
  __type: 'DATE_RANGE';
271
347
  }
272
348
 
349
+ export interface POInputObj extends POItemBase {
350
+ __type: 'INPUT';
351
+ inputClassName?: string;
352
+ name: string;
353
+ preset?: 'tiny' | 'smaller';
354
+ type?: 'text' | 'search' | 'email' | 'url' | 'tel' | 'password';
355
+ label?: string;
356
+ ariaLabel?: string;
357
+ placeholder?: string;
358
+ autoFocus?: boolean;
359
+ disabled?: boolean;
360
+ maxLength?: number;
361
+ }
362
+
273
363
  export interface POTextObj extends POItemBase {
274
364
  __type: 'TEXT';
365
+ fontClassName?: string;
275
366
  text: string;
276
367
  className?: POClassNameValue;
277
368
  designClassName?: POClassNameValue;
@@ -280,29 +371,33 @@ export interface POTextObj extends POItemBase {
280
371
  export type POListIfaceItem =
281
372
  | PONavAvatarItemObj
282
373
  | POListSubtitleObj
374
+ | POListBannerItemObj
283
375
  | POListBreakObj
284
376
  | POListItemObj
285
377
  | POCheckListItemObj
286
378
  | POListItemPickerObj
379
+ | POLayoutDesignerObj
287
380
  | POListColorsObj
381
+ | POListBoxItemsObj
288
382
  | POListBorderStylesObj
289
383
  | POListTextFormatControlsObj
290
384
  | POListSubmenuItemObj
291
385
  | POModalItemObj
292
386
  | PODatePickerObj
387
+ | POTimePickerObj
388
+ | PODateTimePickerObj
293
389
  | PODateRangeObj
294
- | POTextObj;
390
+ | POTextObj
391
+ | POInputObj;
295
392
 
296
- export type POCheckListIfaceItem =
297
- | POListSubtitleObj
298
- | POListBreakObj
299
- | POCheckListItemObj;
393
+ export type POCheckListIfaceItem = POListSubtitleObj | POListBreakObj | POCheckListItemObj;
300
394
 
301
395
  /**
302
396
  * Pop over ifaces
303
397
  */
304
398
 
305
399
  export interface POListVariables {
400
+ fontSizeClassName?: string;
306
401
  notReady?: boolean;
307
402
  designClassName?: string;
308
403
  shadowClassName?: string;
@@ -314,6 +409,8 @@ export interface POListVariables {
314
409
  displayName?: string;
315
410
  photoUri?: string | null;
316
411
  initialState?: POFormState | POStateValue[] | POStateValue;
412
+ /** `initial` seeds once per popover instance; `controlled` adopts later `initialState` changes. */
413
+ stateMode?: 'initial' | 'controlled';
317
414
  options: POListIfaceItem[];
318
415
  addFooterButton?: boolean;
319
416
  footerButtonText?: string;
@@ -326,8 +423,7 @@ export interface POListIface {
326
423
  variables: POListVariables;
327
424
  }
328
425
 
329
- export interface POCheckListVariables
330
- extends Omit<POListVariables, 'options' | 'initialState'> {
426
+ export interface POCheckListVariables extends Omit<POListVariables, 'options' | 'initialState'> {
331
427
  options: POCheckListIfaceItem[];
332
428
  initialState?: POItemValue[];
333
429
  }
@@ -371,17 +467,14 @@ export interface POLabelsAndValuesIface {
371
467
  variables: POLabelsAndValuesVariables;
372
468
  }
373
469
 
374
- export interface POReactiveEventsIface {
375
- name: 'PO_REACTIVE_EVENTS';
376
- variables: Record<string, never>;
470
+ export interface POContentIface {
471
+ name: 'PO_CONTENT';
472
+ variables: {
473
+ children: ReactNode;
474
+ };
377
475
  }
378
476
 
379
- export type PopOverIface =
380
- | POListIface
381
- | POCheckListIface
382
- | POImageIface
383
- | POLabelsAndValuesIface
384
- | POReactiveEventsIface;
477
+ export type PopOverIface = POListIface | POCheckListIface | POImageIface | POLabelsAndValuesIface | POContentIface;
385
478
  export type PopOverName = PopOverIface['name'];
386
479
  export type PopOverVariables = PopOverIface['variables'];
387
480
 
@@ -406,7 +499,9 @@ export interface PopOverPositionProps {
406
499
 
407
500
  export interface PopOverCommonProps extends PopOverPositionProps {
408
501
  id?: string;
502
+ instanceId?: string;
409
503
  closing?: boolean;
504
+ style?: CSSProperties;
410
505
  zClassName?: string;
411
506
  animationClassName?: string;
412
507
  dismissOnExternalScroll?: boolean;
@@ -414,39 +509,49 @@ export interface PopOverCommonProps extends PopOverPositionProps {
414
509
  doNotFixToBottom?: boolean;
415
510
  doNotRemoveOnPageEvents?: boolean;
416
511
  scrollAreaDOMId?: string | null;
417
- globalState?: PopOverGlobalStateObj | null;
418
512
  }
419
513
 
420
514
  export type PopOverProps = PopOverCommonProps & PopOverIface;
421
515
 
422
- export interface UpdatePopOverParams extends Record<string, POStateValue> {
423
- name: PopOverName;
516
+ export interface UpdatePopOverParams {
517
+ iface: PopOverIface;
424
518
  }
425
519
 
426
- export interface PopOverGlobalStateParams {
520
+ export interface PopOverEventParams {
427
521
  action: 'ITEM' | 'ITEM_AUTO' | 'SUBMIT' | 'MOUNT' | 'UNMOUNT';
428
522
  name?: string | null;
429
523
  value: POStateValue;
430
524
  doNotClosePopOver?: boolean;
431
525
  }
432
526
 
433
- export interface PopOverGlobalStateObj extends PopOverGlobalStateParams {
527
+ export interface PopOverEventObj extends PopOverEventParams {
434
528
  id?: string;
529
+ /** Monotonically increasing identity for deduplicating user events. */
530
+ eventId: number;
531
+ /** Identity of the single open session that emitted this event. */
532
+ instanceId: string;
533
+ }
534
+
535
+ export interface PopOverEventFilter {
536
+ instanceId?: string | null;
537
+ popOverId?: string | null;
435
538
  }
436
539
 
437
540
  export type OpenPopOverFn = (data: PopOverProps) => void;
438
- export type ClosePopOverFn = (dismissIfName?: string) => void;
541
+ export type ClosePopOverFn = (dismissIf?: string | { id?: string; name?: string }) => void;
439
542
  export type UpdatePopOverFn = (data: UpdatePopOverParams) => void;
440
- export type SetPopOverStateFn = (data: PopOverGlobalStateParams | null) => void;
543
+ export type PublishPopOverEventFn = (data: PopOverEventParams) => void;
544
+ export type AcknowledgePopOverEventFn = (eventId: number) => void;
441
545
 
442
546
  export interface PopOverHandlerProps {
443
547
  openPopOver: OpenPopOverFn;
444
548
  closePopOver: ClosePopOverFn;
445
549
  updatePopOver: UpdatePopOverFn;
446
- setPopOverState: SetPopOverStateFn;
550
+ publishPopOverEvent: PublishPopOverEventFn;
447
551
  }
448
552
 
449
553
  export interface PopOverHookProps extends PopOverHandlerProps {
554
+ acknowledgePopOverEvent: AcknowledgePopOverEventFn;
450
555
  pathname?: string;
451
556
  popOver: PopOverProps | null;
452
557
  }
@@ -454,6 +559,7 @@ export interface PopOverHookProps extends PopOverHandlerProps {
454
559
  export interface PopOverButtonProps extends PopOverPositionProps {
455
560
  activeClassName?: string;
456
561
  animationClassName?: string;
562
+ ariaLabel?: string;
457
563
  as?: ElementType;
458
564
  children: ReactNode;
459
565
  className?: string;
@@ -465,9 +571,12 @@ export interface PopOverButtonProps extends PopOverPositionProps {
465
571
  domId?: string;
466
572
  id?: string;
467
573
  iface: PopOverIface;
574
+ /** Build the interface synchronously only when a closed trigger opens. */
575
+ getOpenIface?: () => PopOverIface;
468
576
  leftEdgePosition?: number;
469
577
  leftEdgeThreshold?: number;
470
578
  linkClassName?: string;
579
+ matchTriggerWidth?: boolean;
471
580
  notActiveClassName?: string;
472
581
  offsetX?: number;
473
582
  offsetY?: number;
@@ -477,16 +586,25 @@ export interface PopOverButtonProps extends PopOverPositionProps {
477
586
  rightEdgePosition?: number;
478
587
  rightEdgeThreshold?: number;
479
588
  scrollAreaDOMId?: string | null;
589
+ /** Update the active popover when its trigger-owned interface meaningfully changes. */
590
+ syncOpenIface?: boolean;
591
+ /** Stable semantic value that changes when an already-open interface should be synchronized. */
592
+ syncOpenIfaceKey?: unknown;
593
+ tabIndex?: number;
594
+ title?: string;
480
595
  zClassName?: string;
481
596
  }
482
597
 
483
598
  export interface PopOverMoreButtonProps {
484
599
  allowActiveTransform?: boolean;
600
+ id?: string;
485
601
  size?: 'xxs' | 'xs' | 'sm';
486
602
  disabled?: boolean;
487
603
  editOptions: POListIfaceItem[];
488
604
  zClassName?: string;
489
605
  borderClassName?: string;
606
+ syncOpenIface?: boolean;
607
+ syncOpenIfaceKey?: unknown;
490
608
  }
491
609
 
492
610
  /**
@@ -506,25 +624,32 @@ export interface TooltipProps extends Omit<PopOverPositionProps, 'variables'> {
506
624
  }
507
625
 
508
626
  export interface TooltipButtonProps {
627
+ type?: 'button' | 'submit' | 'reset';
509
628
  __html?: string;
510
629
  absolute?: AbsolutePosition;
630
+ ariaLabel?: string;
511
631
  as?: ElementType;
512
632
  children: ReactNode;
513
633
  className?: string;
514
634
  closeWhilePointerDown?: boolean;
515
635
  disabled?: boolean;
516
636
  fontClassName?: string;
637
+ hideDelayMs?: number;
517
638
  leftIconName?: string;
518
639
  message?: string;
519
640
  messageAfterClick?: string;
520
641
  offsetX?: number;
521
642
  offsetY?: number;
643
+ onBlur?: (e: FocusEvent<HTMLElement>) => void;
522
644
  onClick?: (e: MouseEvent) => void;
645
+ onFocus?: (e: FocusEvent<HTMLElement>) => void;
646
+ onKeyDown?: (e: KeyboardEvent<HTMLElement>) => void;
523
647
  onMouseEnter?: (e: MouseEvent) => void;
524
648
  position?: POPosition;
525
649
  reopenAfterPointerUp?: boolean;
526
650
  rightIconName?: string;
527
651
  showDelayMs?: number;
652
+ showTooltipWhenDisabled?: boolean;
528
653
  style?: CSSProperties;
529
654
  title?: string;
530
655
  tooltipClassName?: string;