@minecraft/server-ui 2.1.0-beta.1.26.10-preview.22 → 2.1.0-beta.1.26.10-preview.24

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 (2) hide show
  1. package/index.d.ts +96 -56
  2. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -252,16 +252,15 @@ export declare class CustomForm {
252
252
  * when the button is pressed.
253
253
  *
254
254
  */
255
- button(label: Observable<string> | string | UIRawMessage, onClick: () => void, options?: ButtonOptions): CustomForm;
256
- /**
257
- * @remarks
258
- * Can this form be shown to the player right now?
259
- *
260
- */
261
- canShow(): boolean;
255
+ button(
256
+ label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
257
+ onClick: () => void,
258
+ options?: ButtonOptions,
259
+ ): CustomForm;
262
260
  /**
263
261
  * @remarks
264
- * Closes the form. Throws an error if the form is not open.
262
+ * Tell the client to close the form. Throws an error if the
263
+ * form is not open.
265
264
  *
266
265
  */
267
266
  close(): void;
@@ -284,26 +283,48 @@ export declare class CustomForm {
284
283
  *
285
284
  */
286
285
  dropdown(
287
- label: Observable<string> | string | UIRawMessage,
286
+ label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
288
287
  value: Observable<number>,
289
288
  items: DropdownItem[],
290
289
  options?: DropdownOptions,
291
290
  ): CustomForm;
291
+ /**
292
+ * @remarks
293
+ * Inserts a header (i.e. large sized text) into the Custom
294
+ * form.
295
+ *
296
+ */
297
+ header(
298
+ text: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
299
+ options?: TextOptions,
300
+ ): CustomForm;
301
+ /**
302
+ * @remarks
303
+ * Returns true if the form is currently being shown to the
304
+ * player.
305
+ *
306
+ */
307
+ isShowing(): boolean;
292
308
  /**
293
309
  * @remarks
294
310
  * Inserts a label (i.e. medium sized text) into the Custom
295
311
  * form.
296
312
  *
297
313
  */
298
- label(text: Observable<string> | string | UIRawMessage, options?: LabelOptions): CustomForm;
314
+ label(
315
+ text: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
316
+ options?: TextOptions,
317
+ ): CustomForm;
299
318
  /**
300
319
  * @remarks
301
- * Shows the form to the player. Will throw errors if the form
302
- * is currently being shown or if another behavior pack is
303
- * showing a form.
320
+ * Shows the form to the player. Will return false if the
321
+ * client was busy (i.e. in another menu or this one is open).
322
+ * Will throw if the user disconnects.
304
323
  *
324
+ * @throws
325
+ * *
305
326
  */
306
- show(): Promise<void>;
327
+ show(): Promise<boolean>;
307
328
  /**
308
329
  * @remarks
309
330
  * Creates a slider that lets players pick a number between
@@ -311,7 +332,7 @@ export declare class CustomForm {
311
332
  *
312
333
  */
313
334
  slider(
314
- label: Observable<string> | string | UIRawMessage,
335
+ label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
315
336
  value: Observable<number>,
316
337
  minValue: Observable<number> | number,
317
338
  maxValue: Observable<number> | number,
@@ -330,7 +351,7 @@ export declare class CustomForm {
330
351
  *
331
352
  */
332
353
  textField(
333
- label: Observable<string> | string | UIRawMessage,
354
+ label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
334
355
  text: Observable<string>,
335
356
  options?: TextFieldOptions,
336
357
  ): CustomForm;
@@ -341,7 +362,7 @@ export declare class CustomForm {
341
362
  *
342
363
  */
343
364
  toggle(
344
- label: Observable<string> | string | UIRawMessage,
365
+ label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
345
366
  toggled: Observable<boolean>,
346
367
  options?: ToggleOptions,
347
368
  ): CustomForm;
@@ -351,7 +372,10 @@ export declare class CustomForm {
351
372
  * instead of a constructor.
352
373
  *
353
374
  */
354
- static create(player: minecraftserver.Player, title: Observable<string> | string | UIRawMessage): CustomForm;
375
+ static create(
376
+ player: minecraftserver.Player,
377
+ title: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
378
+ ): CustomForm;
355
379
  }
356
380
 
357
381
  /**
@@ -381,56 +405,62 @@ export class FormResponse {
381
405
  export declare class MessageBox {
382
406
  /**
383
407
  * @remarks
384
- * Sets the data for the text in the body of the form. It is
385
- * contained within a scroll view to allow for lots of text.
408
+ * Sets the data for the text in the body of the message box.
409
+ * It is contained within a scroll view to allow for lots of
410
+ * text.
386
411
  *
387
412
  */
388
- body(text: Observable<string> | string | UIRawMessage): MessageBox;
413
+ body(text: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage): MessageBox;
389
414
  /**
390
415
  * @remarks
391
- * Sets the data for the top button in the form.
416
+ * Sets the data for the top button in the message box.
392
417
  *
393
418
  */
394
419
  button1(
395
- label: Observable<string> | string | UIRawMessage,
396
- tooltip?: Observable<string> | string | UIRawMessage,
420
+ label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
421
+ tooltip?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
397
422
  ): MessageBox;
398
423
  /**
399
424
  * @remarks
400
- * Sets the data for the bottom button in the form.
425
+ * Sets the data for the bottom button in the message box.
401
426
  *
402
427
  */
403
428
  button2(
404
- label: Observable<string> | string | UIRawMessage,
405
- tooltip?: Observable<string> | string | UIRawMessage,
429
+ label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
430
+ tooltip?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
406
431
  ): MessageBox;
407
432
  /**
408
433
  * @remarks
409
- * Closes the form. Will throw an error if the form is not
410
- * open.
434
+ * Tell the client to close the message box. Throws {@link
435
+ * FormCloseError} if the message box is not open.
411
436
  *
412
437
  */
413
438
  close(): void;
414
439
  /**
415
440
  * @remarks
416
- * Show this modal to the player. Will throw an error if the
417
- * modal is already showing.
441
+ * Returns true if the message box is currently being shown to
442
+ * the player.
418
443
  *
419
444
  */
420
- show(): Promise<MessageBoxResult>;
445
+ isShowing(): boolean;
421
446
  /**
422
447
  * @remarks
423
- * Sets the title of form.
448
+ * Show this message box to the player. Will return a result
449
+ * even if the client was busy (i.e. in another menu). Will
450
+ * throw if the user disconnects.
424
451
  *
425
452
  */
426
- title(text: Observable<string> | string | UIRawMessage): MessageBox;
453
+ show(): Promise<MessageBoxResult>;
427
454
  /**
428
455
  * @remarks
429
- * Creates a message form for a certain player. Use this
430
- * instead of a constructor.
456
+ * Creates a message box for a certain player. Use this instead
457
+ * of a constructor.
431
458
  *
432
459
  */
433
- static create(player: minecraftserver.Player): MessageBox;
460
+ static create(
461
+ player: minecraftserver.Player,
462
+ title: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
463
+ ): MessageBox;
434
464
  }
435
465
 
436
466
  /**
@@ -833,7 +863,7 @@ export class ModalFormResponse extends FormResponse {
833
863
  * A class that represents data that can be Observed.
834
864
  * Extensively used for UI.
835
865
  */
836
- export declare class Observable<T extends string | number | boolean> {
866
+ export declare class Observable<T extends string | number | boolean | UIRawMessage> {
837
867
  /**
838
868
  * @remarks
839
869
  * Gets the data from the Observable.
@@ -868,7 +898,10 @@ export declare class Observable<T extends string | number | boolean> {
868
898
  * Creates an Observable, use this instead of a constructor.
869
899
  *
870
900
  */
871
- static create<T extends string | number | boolean>(data: T, options?: ObservableOptions): Observable<T>;
901
+ static create<T extends string | number | boolean | UIRawMessage>(
902
+ data: T,
903
+ options?: ObservableOptions,
904
+ ): Observable<T>;
872
905
  }
873
906
 
874
907
  export class UIManager {
@@ -898,7 +931,7 @@ export interface ButtonOptions {
898
931
  * The tooltip for this button, shown when hovering the button.
899
932
  *
900
933
  */
901
- tooltip?: Observable<string> | string | UIRawMessage;
934
+ tooltip?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage;
902
935
  /**
903
936
  * @remarks
904
937
  * Whether or not this button is visible.
@@ -972,19 +1005,6 @@ export interface DropdownOptions {
972
1005
  visible?: Observable<boolean> | boolean;
973
1006
  }
974
1007
 
975
- /**
976
- * @beta
977
- * The options for including a label in {@link CustomForm}.
978
- */
979
- export interface LabelOptions {
980
- /**
981
- * @remarks
982
- * Whether or not this label is visible
983
- *
984
- */
985
- visible?: Observable<boolean> | boolean;
986
- }
987
-
988
1008
  /**
989
1009
  * @beta
990
1010
  * The result when a {@link MessageBox} is closed.
@@ -997,6 +1017,12 @@ export interface MessageBoxResult {
997
1017
  *
998
1018
  */
999
1019
  selection?: number;
1020
+ /**
1021
+ * @remarks
1022
+ * Whether the message box was shown
1023
+ *
1024
+ */
1025
+ wasShown: boolean;
1000
1026
  }
1001
1027
 
1002
1028
  /**
@@ -1117,7 +1143,7 @@ export interface SliderOptions {
1117
1143
  * The description of the slider, shown in the UI.
1118
1144
  *
1119
1145
  */
1120
- description?: Observable<string> | string | UIRawMessage;
1146
+ description?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage;
1121
1147
  /**
1122
1148
  * @remarks
1123
1149
  * Whether or not this slider is disabled.
@@ -1163,7 +1189,7 @@ export interface TextFieldOptions {
1163
1189
  * The description for this text field, shown in the UI.
1164
1190
  *
1165
1191
  */
1166
- description?: Observable<string> | string | UIRawMessage;
1192
+ description?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage;
1167
1193
  /**
1168
1194
  * @remarks
1169
1195
  * Whether or not this text field is disabled.
@@ -1178,6 +1204,20 @@ export interface TextFieldOptions {
1178
1204
  visible?: Observable<boolean> | boolean;
1179
1205
  }
1180
1206
 
1207
+ /**
1208
+ * @beta
1209
+ * The options for including a label or header in {@link
1210
+ * CustomForm}.
1211
+ */
1212
+ export interface TextOptions {
1213
+ /**
1214
+ * @remarks
1215
+ * Whether or not this label is visible
1216
+ *
1217
+ */
1218
+ visible?: Observable<boolean> | boolean;
1219
+ }
1220
+
1181
1221
  /**
1182
1222
  * @beta
1183
1223
  * The options for including a toggle in {@link CustomForm}.
@@ -1188,7 +1228,7 @@ export interface ToggleOptions {
1188
1228
  * The description for this toggle, shown in the UI.
1189
1229
  *
1190
1230
  */
1191
- description?: Observable<string> | string | UIRawMessage;
1231
+ description?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage;
1192
1232
  /**
1193
1233
  * @remarks
1194
1234
  * Whether or not this toggle is disabled.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minecraft/server-ui",
3
- "version": "2.1.0-beta.1.26.10-preview.22",
3
+ "version": "2.1.0-beta.1.26.10-preview.24",
4
4
  "description": "",
5
5
  "contributors": [
6
6
  {
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "peerDependencies": {
16
16
  "@minecraft/common": "^1.0.0",
17
- "@minecraft/server": "^2.0.0 || ^2.7.0-beta.1.26.10-preview.22"
17
+ "@minecraft/server": "^2.0.0 || ^2.7.0-beta.1.26.10-preview.24"
18
18
  },
19
19
  "license": "MIT"
20
20
  }