@jsb188/react 1.1.11 → 1.1.12

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,44 @@ 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
+ name: string;
352
+ preset?: 'tiny';
353
+ type?: 'text' | 'search' | 'email' | 'url' | 'tel' | 'password';
354
+ label?: string;
355
+ ariaLabel?: string;
356
+ placeholder?: string;
357
+ autoFocus?: boolean;
358
+ disabled?: boolean;
359
+ maxLength?: number;
360
+ }
361
+
273
362
  export interface POTextObj extends POItemBase {
274
363
  __type: 'TEXT';
364
+ fontClassName?: string;
275
365
  text: string;
276
366
  className?: POClassNameValue;
277
367
  designClassName?: POClassNameValue;
@@ -280,29 +370,33 @@ export interface POTextObj extends POItemBase {
280
370
  export type POListIfaceItem =
281
371
  | PONavAvatarItemObj
282
372
  | POListSubtitleObj
373
+ | POListBannerItemObj
283
374
  | POListBreakObj
284
375
  | POListItemObj
285
376
  | POCheckListItemObj
286
377
  | POListItemPickerObj
378
+ | POLayoutDesignerObj
287
379
  | POListColorsObj
380
+ | POListBoxItemsObj
288
381
  | POListBorderStylesObj
289
382
  | POListTextFormatControlsObj
290
383
  | POListSubmenuItemObj
291
384
  | POModalItemObj
292
385
  | PODatePickerObj
386
+ | POTimePickerObj
387
+ | PODateTimePickerObj
293
388
  | PODateRangeObj
294
- | POTextObj;
389
+ | POTextObj
390
+ | POInputObj;
295
391
 
296
- export type POCheckListIfaceItem =
297
- | POListSubtitleObj
298
- | POListBreakObj
299
- | POCheckListItemObj;
392
+ export type POCheckListIfaceItem = POListSubtitleObj | POListBreakObj | POCheckListItemObj;
300
393
 
301
394
  /**
302
395
  * Pop over ifaces
303
396
  */
304
397
 
305
398
  export interface POListVariables {
399
+ fontSizeClassName?: string;
306
400
  notReady?: boolean;
307
401
  designClassName?: string;
308
402
  shadowClassName?: string;
@@ -314,6 +408,8 @@ export interface POListVariables {
314
408
  displayName?: string;
315
409
  photoUri?: string | null;
316
410
  initialState?: POFormState | POStateValue[] | POStateValue;
411
+ /** `initial` seeds once per popover instance; `controlled` adopts later `initialState` changes. */
412
+ stateMode?: 'initial' | 'controlled';
317
413
  options: POListIfaceItem[];
318
414
  addFooterButton?: boolean;
319
415
  footerButtonText?: string;
@@ -326,8 +422,7 @@ export interface POListIface {
326
422
  variables: POListVariables;
327
423
  }
328
424
 
329
- export interface POCheckListVariables
330
- extends Omit<POListVariables, 'options' | 'initialState'> {
425
+ export interface POCheckListVariables extends Omit<POListVariables, 'options' | 'initialState'> {
331
426
  options: POCheckListIfaceItem[];
332
427
  initialState?: POItemValue[];
333
428
  }
@@ -376,12 +471,20 @@ export interface POReactiveEventsIface {
376
471
  variables: Record<string, never>;
377
472
  }
378
473
 
474
+ export interface POContentIface {
475
+ name: 'PO_CONTENT';
476
+ variables: {
477
+ children: ReactNode;
478
+ };
479
+ }
480
+
379
481
  export type PopOverIface =
380
482
  | POListIface
381
483
  | POCheckListIface
382
484
  | POImageIface
383
485
  | POLabelsAndValuesIface
384
- | POReactiveEventsIface;
486
+ | POReactiveEventsIface
487
+ | POContentIface;
385
488
  export type PopOverName = PopOverIface['name'];
386
489
  export type PopOverVariables = PopOverIface['variables'];
387
490
 
@@ -406,7 +509,9 @@ export interface PopOverPositionProps {
406
509
 
407
510
  export interface PopOverCommonProps extends PopOverPositionProps {
408
511
  id?: string;
512
+ instanceId?: string;
409
513
  closing?: boolean;
514
+ style?: CSSProperties;
410
515
  zClassName?: string;
411
516
  animationClassName?: string;
412
517
  dismissOnExternalScroll?: boolean;
@@ -414,39 +519,49 @@ export interface PopOverCommonProps extends PopOverPositionProps {
414
519
  doNotFixToBottom?: boolean;
415
520
  doNotRemoveOnPageEvents?: boolean;
416
521
  scrollAreaDOMId?: string | null;
417
- globalState?: PopOverGlobalStateObj | null;
418
522
  }
419
523
 
420
524
  export type PopOverProps = PopOverCommonProps & PopOverIface;
421
525
 
422
- export interface UpdatePopOverParams extends Record<string, POStateValue> {
423
- name: PopOverName;
526
+ export interface UpdatePopOverParams {
527
+ iface: PopOverIface;
424
528
  }
425
529
 
426
- export interface PopOverGlobalStateParams {
530
+ export interface PopOverEventParams {
427
531
  action: 'ITEM' | 'ITEM_AUTO' | 'SUBMIT' | 'MOUNT' | 'UNMOUNT';
428
532
  name?: string | null;
429
533
  value: POStateValue;
430
534
  doNotClosePopOver?: boolean;
431
535
  }
432
536
 
433
- export interface PopOverGlobalStateObj extends PopOverGlobalStateParams {
537
+ export interface PopOverEventObj extends PopOverEventParams {
434
538
  id?: string;
539
+ /** Monotonically increasing identity for deduplicating user events. */
540
+ eventId: number;
541
+ /** Identity of the single open session that emitted this event. */
542
+ instanceId: string;
543
+ }
544
+
545
+ export interface PopOverEventFilter {
546
+ instanceId?: string | null;
547
+ popOverId?: string | null;
435
548
  }
436
549
 
437
550
  export type OpenPopOverFn = (data: PopOverProps) => void;
438
- export type ClosePopOverFn = (dismissIfName?: string) => void;
551
+ export type ClosePopOverFn = (dismissIf?: string | { id?: string; name?: string }) => void;
439
552
  export type UpdatePopOverFn = (data: UpdatePopOverParams) => void;
440
- export type SetPopOverStateFn = (data: PopOverGlobalStateParams | null) => void;
553
+ export type PublishPopOverEventFn = (data: PopOverEventParams) => void;
554
+ export type AcknowledgePopOverEventFn = (eventId: number) => void;
441
555
 
442
556
  export interface PopOverHandlerProps {
443
557
  openPopOver: OpenPopOverFn;
444
558
  closePopOver: ClosePopOverFn;
445
559
  updatePopOver: UpdatePopOverFn;
446
- setPopOverState: SetPopOverStateFn;
560
+ publishPopOverEvent: PublishPopOverEventFn;
447
561
  }
448
562
 
449
563
  export interface PopOverHookProps extends PopOverHandlerProps {
564
+ acknowledgePopOverEvent: AcknowledgePopOverEventFn;
450
565
  pathname?: string;
451
566
  popOver: PopOverProps | null;
452
567
  }
@@ -454,6 +569,7 @@ export interface PopOverHookProps extends PopOverHandlerProps {
454
569
  export interface PopOverButtonProps extends PopOverPositionProps {
455
570
  activeClassName?: string;
456
571
  animationClassName?: string;
572
+ ariaLabel?: string;
457
573
  as?: ElementType;
458
574
  children: ReactNode;
459
575
  className?: string;
@@ -465,9 +581,12 @@ export interface PopOverButtonProps extends PopOverPositionProps {
465
581
  domId?: string;
466
582
  id?: string;
467
583
  iface: PopOverIface;
584
+ /** Build the interface synchronously only when a closed trigger opens. */
585
+ getOpenIface?: () => PopOverIface;
468
586
  leftEdgePosition?: number;
469
587
  leftEdgeThreshold?: number;
470
588
  linkClassName?: string;
589
+ matchTriggerWidth?: boolean;
471
590
  notActiveClassName?: string;
472
591
  offsetX?: number;
473
592
  offsetY?: number;
@@ -477,16 +596,25 @@ export interface PopOverButtonProps extends PopOverPositionProps {
477
596
  rightEdgePosition?: number;
478
597
  rightEdgeThreshold?: number;
479
598
  scrollAreaDOMId?: string | null;
599
+ /** Update the active popover when its trigger-owned interface meaningfully changes. */
600
+ syncOpenIface?: boolean;
601
+ /** Stable semantic value that changes when an already-open interface should be synchronized. */
602
+ syncOpenIfaceKey?: unknown;
603
+ tabIndex?: number;
604
+ title?: string;
480
605
  zClassName?: string;
481
606
  }
482
607
 
483
608
  export interface PopOverMoreButtonProps {
484
609
  allowActiveTransform?: boolean;
610
+ id?: string;
485
611
  size?: 'xxs' | 'xs' | 'sm';
486
612
  disabled?: boolean;
487
613
  editOptions: POListIfaceItem[];
488
614
  zClassName?: string;
489
615
  borderClassName?: string;
616
+ syncOpenIface?: boolean;
617
+ syncOpenIfaceKey?: unknown;
490
618
  }
491
619
 
492
620
  /**
@@ -506,25 +634,32 @@ export interface TooltipProps extends Omit<PopOverPositionProps, 'variables'> {
506
634
  }
507
635
 
508
636
  export interface TooltipButtonProps {
637
+ type?: 'button' | 'submit' | 'reset';
509
638
  __html?: string;
510
639
  absolute?: AbsolutePosition;
640
+ ariaLabel?: string;
511
641
  as?: ElementType;
512
642
  children: ReactNode;
513
643
  className?: string;
514
644
  closeWhilePointerDown?: boolean;
515
645
  disabled?: boolean;
516
646
  fontClassName?: string;
647
+ hideDelayMs?: number;
517
648
  leftIconName?: string;
518
649
  message?: string;
519
650
  messageAfterClick?: string;
520
651
  offsetX?: number;
521
652
  offsetY?: number;
653
+ onBlur?: (e: FocusEvent<HTMLElement>) => void;
522
654
  onClick?: (e: MouseEvent) => void;
655
+ onFocus?: (e: FocusEvent<HTMLElement>) => void;
656
+ onKeyDown?: (e: KeyboardEvent<HTMLElement>) => void;
523
657
  onMouseEnter?: (e: MouseEvent) => void;
524
658
  position?: POPosition;
525
659
  reopenAfterPointerUp?: boolean;
526
660
  rightIconName?: string;
527
661
  showDelayMs?: number;
662
+ showTooltipWhenDisabled?: boolean;
528
663
  style?: CSSProperties;
529
664
  title?: string;
530
665
  tooltipClassName?: string;