@nullplatform/ui-plugin-sdk 0.12.0 → 0.14.0

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/dist/bridge.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Plugin-side client of the host bridge. The only way out of the sandbox.
3
3
  */
4
- import { type ApiRequest, type BridgeMethodName, type BridgeMethods, type HostMessage, type HttpRequest, type HttpResponse, type NavigationTarget, type PluginContext, type SnackbarOptions, type WorkerMessage } from './protocol.js';
4
+ import { type ConfirmOptions, type ApiRequest, type BridgeMethodName, type BridgeMethods, type HostMessage, type HttpRequest, type HttpResponse, type NavigationTarget, type PluginContext, type SnackbarOptions, type WorkerMessage } from './protocol.js';
5
5
  import { topics as topicsApi } from './topics.js';
6
6
  export declare class BridgeClient {
7
7
  private readonly timeoutMs;
@@ -36,6 +36,12 @@ export declare const nullplatform: {
36
36
  };
37
37
  ui: {
38
38
  snackbar(options: SnackbarOptions): Promise<void>;
39
+ /**
40
+ * Asks the host to confirm with its own dialog, since a plugin cannot draw over the page. Resolves `true` only
41
+ * when the person confirms, `false` when they cancel or the host has no dialog. Waits up to 10 minutes; one at a
42
+ * time per plugin (a second one rejects with `BUSY`). A host older than the call rejects with `UNKNOWN_METHOD`.
43
+ */
44
+ confirm(options: ConfirmOptions): Promise<boolean>;
39
45
  };
40
46
  context: {
41
47
  get(): Promise<PluginContext>;
package/dist/bridge.js CHANGED
@@ -1,8 +1,13 @@
1
1
  /**
2
2
  * Plugin-side client of the host bridge. The only way out of the sandbox.
3
3
  */
4
- import { BridgeError, deserializeError, } from './protocol.js';
4
+ import { BridgeError, BRIDGE_CALL_DEADLINES_MS, deserializeError, } from './protocol.js';
5
5
  import { topics as topicsApi } from './topics.js';
6
+ /**
7
+ * Margin over a long host deadline, so the host's own answer (`TIMEOUT`, or the person's) arrives before this side
8
+ * gives up on the call.
9
+ */
10
+ const LONG_CALL_SLACK_MS = 5000;
6
11
  export class BridgeClient {
7
12
  timeoutMs;
8
13
  port = null;
@@ -35,7 +40,9 @@ export class BridgeClient {
35
40
  reject(new BridgeError('Too many pending calls', 'RATE_LIMIT'));
36
41
  return;
37
42
  }
38
- const timer = setTimeout(() => { this.pending.delete(id); reject(new BridgeError('Bridge call timed out', 'TIMEOUT')); }, this.timeoutMs);
43
+ const longDeadline = BRIDGE_CALL_DEADLINES_MS[method];
44
+ const timeoutMs = longDeadline ? Math.max(this.timeoutMs, longDeadline + LONG_CALL_SLACK_MS) : this.timeoutMs;
45
+ const timer = setTimeout(() => { this.pending.delete(id); reject(new BridgeError('Bridge call timed out', 'TIMEOUT')); }, timeoutMs);
39
46
  this.pending.set(id, { resolve, reject, timer });
40
47
  try {
41
48
  this.post({ type: 'call', id, method, args });
@@ -96,6 +103,14 @@ export const nullplatform = {
96
103
  snackbar(options) {
97
104
  return bridge.call('ui.snackbar', options);
98
105
  },
106
+ /**
107
+ * Asks the host to confirm with its own dialog, since a plugin cannot draw over the page. Resolves `true` only
108
+ * when the person confirms, `false` when they cancel or the host has no dialog. Waits up to 10 minutes; one at a
109
+ * time per plugin (a second one rejects with `BUSY`). A host older than the call rejects with `UNKNOWN_METHOD`.
110
+ */
111
+ confirm(options) {
112
+ return bridge.call('ui.confirm', options);
113
+ },
99
114
  },
100
115
  context: {
101
116
  get() {
package/dist/catalog.js CHANGED
@@ -227,10 +227,11 @@ const OWN_CATALOG = [
227
227
  children: true,
228
228
  },
229
229
  {
230
+ // `actionLabel` draws one action button at the alert's end; pressing it sends `action`.
230
231
  tag: "np-alert",
231
232
  component: "Alert",
232
- properties: { severity: "string", title: "string" },
233
- events: {},
233
+ properties: { severity: "string", title: "string", actionLabel: "string" },
234
+ events: { action: "onAction" },
234
235
  values: CATALOG_PROP_VALUES.Alert,
235
236
  children: true,
236
237
  defaults: { severity: "info" },
@@ -427,6 +428,33 @@ const OWN_CATALOG = [
427
428
  events: {},
428
429
  cssValues: ["color"],
429
430
  },
431
+ {
432
+ // Picks one platform resource (organization, account, namespace or application) by searching the ones the viewer
433
+ // can list. The app draws it with its own selector and data: a host without one shows it as unavailable, see
434
+ // `hostRenders`. `levels` narrows which kinds it offers; `change` sends `{ nrn, resource: { nrn, name, entity } }`.
435
+ tag: "np-resource-selector",
436
+ component: "ResourceSelector",
437
+ properties: {
438
+ label: "string",
439
+ value: "string",
440
+ levels: "array",
441
+ placeholder: "string",
442
+ error: "string",
443
+ helperText: "string",
444
+ disabled: "boolean",
445
+ },
446
+ events: { change: "onChange" },
447
+ },
448
+ {
449
+ // Shows one platform resource by its NRN: kind badge, name and, with `showPath`, where it lives
450
+ // (`organization / account / namespace`); `copyable` adds a button that copies the NRN. The app draws it with its
451
+ // own data (resolved with the viewer's session, never returned to the plugin): a host without one shows it as
452
+ // unavailable, see `hostRenders`.
453
+ tag: "np-resource-display",
454
+ component: "ResourceDisplay",
455
+ properties: { nrn: "string", showPath: "boolean", copyable: "boolean" },
456
+ events: {},
457
+ },
430
458
  ];
431
459
  /**
432
460
  * Every element a plugin can render: the SDK's own, then the design-system components whose contracts
@@ -166,6 +166,9 @@ export declare const Empty: import("react").ComponentType<{
166
166
  export declare const Alert: import("react").ComponentType<{
167
167
  severity?: AlertSeverity;
168
168
  title?: string;
169
+ /** Draws one action button at the alert's end, such as "Ver en el calendario". Needs `onAction`. */
170
+ actionLabel?: string;
171
+ onAction?: () => void;
169
172
  } & {
170
173
  children?: ReactNode;
171
174
  }>;
@@ -429,3 +432,45 @@ export declare const ProgressBar: import("react").ComponentType<{
429
432
  } & {
430
433
  children?: ReactNode;
431
434
  }>;
435
+ /** A kind of platform resource `ResourceSelector` can offer. */
436
+ export type ResourceLevel = "organization" | "account" | "namespace" | "application";
437
+ /** The resource a person picked in `ResourceSelector`. */
438
+ export interface SelectedResource {
439
+ nrn: string;
440
+ name: string;
441
+ entity: string;
442
+ }
443
+ /**
444
+ * Picks one platform resource by searching the ones the viewer can list, drawn by the app with its own selector.
445
+ * Not every host draws it: check `hostRenders(ResourceSelector)`.
446
+ */
447
+ export declare const ResourceSelector: import("react").ComponentType<{
448
+ label?: string;
449
+ /** The chosen resource's NRN. */
450
+ value?: string | null;
451
+ /** Which kinds to offer; organization, account, namespace and application when left out. */
452
+ levels?: ResourceLevel[];
453
+ placeholder?: string;
454
+ error?: string;
455
+ helperText?: string;
456
+ disabled?: boolean;
457
+ onChange?: (change: {
458
+ nrn: string | null;
459
+ resource: SelectedResource | null;
460
+ }) => void;
461
+ } & {
462
+ children?: ReactNode;
463
+ }>;
464
+ /**
465
+ * Shows one platform resource by its NRN (kind badge and name), drawn by the app with its own data: the plugin never
466
+ * gets the resolved name back. Not every host draws it: check `hostRenders(ResourceDisplay)`.
467
+ */
468
+ export declare const ResourceDisplay: import("react").ComponentType<{
469
+ nrn: string;
470
+ /** Also shows where it lives: `organization / account / namespace`. */
471
+ showPath?: boolean;
472
+ /** Adds a button that copies the NRN. */
473
+ copyable?: boolean;
474
+ } & {
475
+ children?: ReactNode;
476
+ }>;
@@ -129,6 +129,18 @@ export declare const FilterDropdownMultiple: import("react").ComponentType<{
129
129
  } & {} & {
130
130
  children?: import("react").ReactNode;
131
131
  }>;
132
+ export declare const FilterBar: import("react").ComponentType<{
133
+ attributes?: readonly unknown[] | undefined;
134
+ value?: Readonly<Record<string, unknown>> | undefined;
135
+ config?: Readonly<Record<string, unknown>> | undefined;
136
+ localeText?: Readonly<Record<string, unknown>> | undefined;
137
+ liveApply?: boolean | undefined;
138
+ loading?: boolean | undefined;
139
+ } & {
140
+ readonly onChange?: ((payload: unknown) => void) | undefined;
141
+ } & {} & {
142
+ children?: import("react").ReactNode;
143
+ }>;
132
144
  export declare const FilterName: import("react").ComponentType<{
133
145
  filterName?: string | undefined;
134
146
  placeholder?: string | undefined;
@@ -161,6 +173,7 @@ export declare const RelativeDate: import("react").ComponentType<{
161
173
  showTooltip?: boolean | undefined;
162
174
  emptyText?: string | undefined;
163
175
  live?: boolean | undefined;
176
+ muted?: boolean | undefined;
164
177
  } & {} & {} & {
165
178
  children?: import("react").ReactNode;
166
179
  }>;
@@ -416,6 +429,7 @@ export declare const RadioCard: import("react").ComponentType<{
416
429
  export declare const CodeHighlighter: import("react").ComponentType<{
417
430
  code?: string | undefined;
418
431
  lang?: "bash" | "hcl" | "json" | "sql" | "yaml" | undefined;
432
+ maxHeight?: number | undefined;
419
433
  } & {} & {} & {
420
434
  children?: import("react").ReactNode;
421
435
  }>;
@@ -432,3 +446,98 @@ export declare const Markdown: import("react").ComponentType<{
432
446
  } & {} & {} & {
433
447
  children?: import("react").ReactNode;
434
448
  }>;
449
+ export declare const CalendarMonth: import("react").ComponentType<{
450
+ month?: string | undefined;
451
+ timeZone?: string | undefined;
452
+ weekStartsOn?: number | undefined;
453
+ today?: string | undefined;
454
+ events?: readonly unknown[] | undefined;
455
+ selectedId?: string | undefined;
456
+ maxLanes?: number | undefined;
457
+ locale?: string | undefined;
458
+ } & {
459
+ readonly onEventPress?: ((payload: unknown) => void) | undefined;
460
+ readonly onDayPress?: ((payload: unknown) => void) | undefined;
461
+ readonly onMorePress?: ((payload: unknown) => void) | undefined;
462
+ } & {} & {
463
+ children?: import("react").ReactNode;
464
+ }>;
465
+ export declare const CalendarWeek: import("react").ComponentType<{
466
+ weekStart?: string | undefined;
467
+ timeZone?: string | undefined;
468
+ startHour?: number | undefined;
469
+ endHour?: number | undefined;
470
+ events?: readonly unknown[] | undefined;
471
+ selectedId?: string | undefined;
472
+ now?: string | undefined;
473
+ locale?: string | undefined;
474
+ allDayLabel?: string | undefined;
475
+ } & {
476
+ readonly onEventPress?: ((payload: unknown) => void) | undefined;
477
+ readonly onSlotPress?: ((payload: unknown) => void) | undefined;
478
+ } & {} & {
479
+ children?: import("react").ReactNode;
480
+ }>;
481
+ export declare const CalendarTimeline: import("react").ComponentType<{
482
+ from?: string | undefined;
483
+ to?: string | undefined;
484
+ timeZone?: string | undefined;
485
+ rows?: readonly unknown[] | undefined;
486
+ bars?: readonly unknown[] | undefined;
487
+ selectedId?: string | undefined;
488
+ now?: string | undefined;
489
+ locale?: string | undefined;
490
+ resourceLabel?: string | undefined;
491
+ } & {
492
+ readonly onBarPress?: ((payload: unknown) => void) | undefined;
493
+ } & {} & {
494
+ children?: import("react").ReactNode;
495
+ }>;
496
+ export declare const ToggleButtonBar: import("react").ComponentType<{
497
+ options?: readonly unknown[] | undefined;
498
+ value?: string | undefined;
499
+ size?: "small" | "medium" | "large" | undefined;
500
+ "aria-label"?: string | undefined;
501
+ multiple?: boolean | undefined;
502
+ values?: readonly unknown[] | undefined;
503
+ } & {
504
+ readonly onChange?: ((payload: unknown) => void) | undefined;
505
+ } & {} & {
506
+ children?: import("react").ReactNode;
507
+ }>;
508
+ export declare const IconActionButton: import("react").ComponentType<{
509
+ icon?: string | undefined;
510
+ "aria-label"?: string | undefined;
511
+ color?: "default" | "success" | "error" | "warning" | "info" | "primary" | "secondary" | "inherit" | undefined;
512
+ size?: "small" | "medium" | "large" | undefined;
513
+ disabled?: boolean | undefined;
514
+ } & {
515
+ readonly onPress?: ((payload: unknown) => void) | undefined;
516
+ } & {} & {
517
+ children?: import("react").ReactNode;
518
+ }>;
519
+ export declare const AutocompleteSelect: import("react").ComponentType<{
520
+ options?: readonly unknown[] | undefined;
521
+ value?: string | undefined;
522
+ label?: string | undefined;
523
+ placeholder?: string | undefined;
524
+ disabled?: boolean | undefined;
525
+ } & {
526
+ readonly onChange?: ((payload: unknown) => void) | undefined;
527
+ } & {} & {
528
+ children?: import("react").ReactNode;
529
+ }>;
530
+ export declare const DateTimeRangeField: import("react").ComponentType<{
531
+ start?: string | undefined;
532
+ end?: string | undefined;
533
+ allDay?: boolean | undefined;
534
+ timeZone?: string | undefined;
535
+ locale?: string | undefined;
536
+ label?: string | undefined;
537
+ error?: string | undefined;
538
+ disabled?: boolean | undefined;
539
+ } & {
540
+ readonly onChange?: ((payload: unknown) => void) | undefined;
541
+ } & {} & {
542
+ children?: import("react").ReactNode;
543
+ }>;
@@ -1,4 +1,4 @@
1
- // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.15.18. Don't edit: change the contract in
1
+ // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.16.0. Don't edit: change the contract in
2
2
  // react-ui-components, bump `uiComponentsContracts` in package.json and run `pnpm sync:contracts`.
3
3
  import { component } from "./component.js";
4
4
  export const Badge = component("np-badge");
@@ -16,6 +16,7 @@ export const DetailColumn = component("np-detail-column");
16
16
  export const DetailRow = component("np-detail-row");
17
17
  export const FilterDropdown = component("np-filter-dropdown");
18
18
  export const FilterDropdownMultiple = component("np-filter-dropdown-multiple");
19
+ export const FilterBar = component("np-filter-bar");
19
20
  export const FilterName = component("np-filter-name");
20
21
  export const ListItemIcon = component("np-list-item-icon");
21
22
  export const ListItemAvatar = component("np-list-item-avatar");
@@ -46,3 +47,10 @@ export const RadioCard = component("np-radio-card");
46
47
  export const CodeHighlighter = component("np-code-highlighter");
47
48
  export const PageEmptyState = component("np-page-empty-state");
48
49
  export const Markdown = component("np-markdown");
50
+ export const CalendarMonth = component("np-calendar-month");
51
+ export const CalendarWeek = component("np-calendar-week");
52
+ export const CalendarTimeline = component("np-calendar-timeline");
53
+ export const ToggleButtonBar = component("np-toggle-button-group");
54
+ export const IconActionButton = component("np-icon-button");
55
+ export const AutocompleteSelect = component("np-autocomplete");
56
+ export const DateTimeRangeField = component("np-date-time-range-picker");
@@ -52,3 +52,13 @@ export const Scatter = component("np-scatter");
52
52
  export const ClusterMap = component("np-cluster-map");
53
53
  /** Horizontal share bar, `value` in 0..1. */
54
54
  export const ProgressBar = component("np-progress-bar");
55
+ /**
56
+ * Picks one platform resource by searching the ones the viewer can list, drawn by the app with its own selector.
57
+ * Not every host draws it: check `hostRenders(ResourceSelector)`.
58
+ */
59
+ export const ResourceSelector = component("np-resource-selector");
60
+ /**
61
+ * Shows one platform resource by its NRN (kind badge and name), drawn by the app with its own data: the plugin never
62
+ * gets the resolved name back. Not every host draws it: check `hostRenders(ResourceDisplay)`.
63
+ */
64
+ export const ResourceDisplay = component("np-resource-display");
package/dist/context.d.ts CHANGED
@@ -32,6 +32,7 @@ export declare function useNullplatform(): {
32
32
  };
33
33
  ui: {
34
34
  snackbar(options: import("./protocol").SnackbarOptions): Promise<void>;
35
+ confirm(options: import("./protocol").ConfirmOptions): Promise<boolean>;
35
36
  };
36
37
  context: {
37
38
  get(): Promise<PluginContext>;
@@ -12,9 +12,9 @@ import sift from 'sift';
12
12
  export const CONTEXT_ROOTS = ['nrn', 'organization', 'account', 'namespace', 'application', 'user'];
13
13
  /**
14
14
  * In the plugin context, but not usable in a condition yet. Installations resolve for the application's NRN, so the
15
- * platform never loads a scope or a deployment and a condition on either would silently never match.
15
+ * platform never loads a scope, a deployment or a build and a condition on any would silently never match.
16
16
  */
17
- const UNSUPPORTED_ROOTS = new Set(['scope', 'deployment']);
17
+ const UNSUPPORTED_ROOTS = new Set(['scope', 'deployment', 'build']);
18
18
  /** Operators that would execute code or are meaningless outside MongoDB. */
19
19
  const ALLOWED_OPERATORS = new Set(['$eq', '$ne', '$gt', '$gte', '$lt', '$lte', '$in', '$nin', '$exists', '$size', '$all', '$elemMatch', '$not', '$and', '$or', '$nor', '$mod']);
20
20
  export const WHEN_LIMITS = { depth: 16, nodes: 512, array: 100, string: 1024 };
@@ -22,9 +22,9 @@ const sift_1 = __importDefault(require("sift"));
22
22
  exports.CONTEXT_ROOTS = ['nrn', 'organization', 'account', 'namespace', 'application', 'user'];
23
23
  /**
24
24
  * In the plugin context, but not usable in a condition yet. Installations resolve for the application's NRN, so the
25
- * platform never loads a scope or a deployment and a condition on either would silently never match.
25
+ * platform never loads a scope, a deployment or a build and a condition on any would silently never match.
26
26
  */
27
- const UNSUPPORTED_ROOTS = new Set(['scope', 'deployment']);
27
+ const UNSUPPORTED_ROOTS = new Set(['scope', 'deployment', 'build']);
28
28
  /** Operators that would execute code or are meaningless outside MongoDB. */
29
29
  const ALLOWED_OPERATORS = new Set(['$eq', '$ne', '$gt', '$gte', '$lt', '$lte', '$in', '$nin', '$exists', '$size', '$all', '$elemMatch', '$not', '$and', '$or', '$nor', '$mod']);
30
30
  exports.WHEN_LIMITS = { depth: 16, nodes: 512, array: 100, string: 1024 };
@@ -190,6 +190,23 @@ export declare const UI_COMPONENTS_CONTRACTS: readonly [{
190
190
  readonly events: {
191
191
  readonly change: "onChange";
192
192
  };
193
+ }, {
194
+ readonly tag: "np-filter-bar";
195
+ readonly component: "FilterBar";
196
+ readonly properties: {
197
+ readonly attributes: "array";
198
+ readonly value: "object";
199
+ readonly config: "object";
200
+ readonly localeText: "object";
201
+ readonly liveApply: "boolean";
202
+ readonly loading: "boolean";
203
+ };
204
+ readonly events: {
205
+ readonly change: "onChange";
206
+ };
207
+ readonly values: {
208
+ readonly "attributes[].editor": readonly ["multiSelect", "enum"];
209
+ };
193
210
  }, {
194
211
  readonly tag: "np-filter-name";
195
212
  readonly component: "FilterName";
@@ -239,6 +256,7 @@ export declare const UI_COMPONENTS_CONTRACTS: readonly [{
239
256
  readonly showTooltip: "boolean";
240
257
  readonly emptyText: "string";
241
258
  readonly live: "boolean";
259
+ readonly muted: "boolean";
242
260
  };
243
261
  readonly events: {};
244
262
  }, {
@@ -585,6 +603,7 @@ export declare const UI_COMPONENTS_CONTRACTS: readonly [{
585
603
  readonly properties: {
586
604
  readonly code: "string";
587
605
  readonly lang: "string";
606
+ readonly maxHeight: "number";
588
607
  };
589
608
  readonly events: {};
590
609
  readonly values: {
@@ -609,4 +628,141 @@ export declare const UI_COMPONENTS_CONTRACTS: readonly [{
609
628
  readonly defaults: {
610
629
  readonly content: "";
611
630
  };
631
+ }, {
632
+ readonly tag: "np-calendar-month";
633
+ readonly component: "CalendarMonth";
634
+ readonly properties: {
635
+ readonly month: "string";
636
+ readonly timeZone: "string";
637
+ readonly weekStartsOn: "number";
638
+ readonly today: "string";
639
+ readonly events: "array";
640
+ readonly selectedId: "string";
641
+ readonly maxLanes: "number";
642
+ readonly locale: "string";
643
+ };
644
+ readonly events: {
645
+ readonly eventPress: "onEventPress";
646
+ readonly dayPress: "onDayPress";
647
+ readonly morePress: "onMorePress";
648
+ };
649
+ readonly values: {
650
+ readonly "events[].kind": readonly ["freeze", "window"];
651
+ readonly "events[].state": readonly ["active", "upcoming", "past"];
652
+ };
653
+ readonly defaults: {
654
+ readonly weekStartsOn: 1;
655
+ readonly maxLanes: 2;
656
+ };
657
+ }, {
658
+ readonly tag: "np-calendar-week";
659
+ readonly component: "CalendarWeek";
660
+ readonly properties: {
661
+ readonly weekStart: "string";
662
+ readonly timeZone: "string";
663
+ readonly startHour: "number";
664
+ readonly endHour: "number";
665
+ readonly events: "array";
666
+ readonly selectedId: "string";
667
+ readonly now: "string";
668
+ readonly locale: "string";
669
+ readonly allDayLabel: "string";
670
+ };
671
+ readonly events: {
672
+ readonly eventPress: "onEventPress";
673
+ readonly slotPress: "onSlotPress";
674
+ };
675
+ readonly values: {
676
+ readonly "events[].kind": readonly ["freeze", "window"];
677
+ readonly "events[].state": readonly ["active", "upcoming", "past"];
678
+ };
679
+ readonly defaults: {
680
+ readonly startHour: 0;
681
+ readonly endHour: 24;
682
+ };
683
+ }, {
684
+ readonly tag: "np-calendar-timeline";
685
+ readonly component: "CalendarTimeline";
686
+ readonly properties: {
687
+ readonly from: "string";
688
+ readonly to: "string";
689
+ readonly timeZone: "string";
690
+ readonly rows: "array";
691
+ readonly bars: "array";
692
+ readonly selectedId: "string";
693
+ readonly now: "string";
694
+ readonly locale: "string";
695
+ readonly resourceLabel: "string";
696
+ };
697
+ readonly events: {
698
+ readonly barPress: "onBarPress";
699
+ };
700
+ readonly values: {
701
+ readonly "rows[].kind": readonly ["organization", "account", "namespace", "application"];
702
+ readonly "bars[].kind": readonly ["freeze", "window"];
703
+ readonly "bars[].state": readonly ["active", "upcoming", "past"];
704
+ };
705
+ }, {
706
+ readonly tag: "np-toggle-button-group";
707
+ readonly component: "ToggleButtonBar";
708
+ readonly properties: {
709
+ readonly options: "array";
710
+ readonly value: "string";
711
+ readonly size: "string";
712
+ readonly "aria-label": "string";
713
+ readonly multiple: "boolean";
714
+ readonly values: "array";
715
+ };
716
+ readonly events: {
717
+ readonly change: "onChange";
718
+ };
719
+ readonly values: {
720
+ readonly size: readonly ["small", "medium", "large"];
721
+ };
722
+ }, {
723
+ readonly tag: "np-icon-button";
724
+ readonly component: "IconActionButton";
725
+ readonly properties: {
726
+ readonly icon: "string";
727
+ readonly "aria-label": "string";
728
+ readonly color: "string";
729
+ readonly size: "string";
730
+ readonly disabled: "boolean";
731
+ };
732
+ readonly events: {
733
+ readonly press: "onPress";
734
+ };
735
+ readonly values: {
736
+ readonly color: readonly ["default", "inherit", "primary", "secondary", "error", "info", "success", "warning"];
737
+ readonly size: readonly ["small", "medium", "large"];
738
+ };
739
+ }, {
740
+ readonly tag: "np-autocomplete";
741
+ readonly component: "AutocompleteSelect";
742
+ readonly properties: {
743
+ readonly options: "array";
744
+ readonly value: "string";
745
+ readonly label: "string";
746
+ readonly placeholder: "string";
747
+ readonly disabled: "boolean";
748
+ };
749
+ readonly events: {
750
+ readonly change: "onChange";
751
+ };
752
+ }, {
753
+ readonly tag: "np-date-time-range-picker";
754
+ readonly component: "DateTimeRangeField";
755
+ readonly properties: {
756
+ readonly start: "string";
757
+ readonly end: "string";
758
+ readonly allDay: "boolean";
759
+ readonly timeZone: "string";
760
+ readonly locale: "string";
761
+ readonly label: "string";
762
+ readonly error: "string";
763
+ readonly disabled: "boolean";
764
+ };
765
+ readonly events: {
766
+ readonly change: "onChange";
767
+ };
612
768
  }];
@@ -1,4 +1,4 @@
1
- // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.15.18. Don't edit: change the contract in
1
+ // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.16.0. Don't edit: change the contract in
2
2
  // react-ui-components, bump `uiComponentsContracts` in package.json and run `pnpm sync:contracts`.
3
3
  export const UI_COMPONENTS_CONTRACTS = [
4
4
  {
@@ -112,6 +112,13 @@ export const UI_COMPONENTS_CONTRACTS = [
112
112
  properties: { "label": "string", "elements": "array", "selected": "array", "loading": "boolean", "disabled": "boolean", "showActions": "boolean" },
113
113
  events: { "change": "onChange" },
114
114
  },
115
+ {
116
+ tag: "np-filter-bar",
117
+ component: "FilterBar",
118
+ properties: { "attributes": "array", "value": "object", "config": "object", "localeText": "object", "liveApply": "boolean", "loading": "boolean" },
119
+ events: { "change": "onChange" },
120
+ values: { "attributes[].editor": ["multiSelect", "enum"] },
121
+ },
115
122
  {
116
123
  tag: "np-filter-name",
117
124
  component: "FilterName",
@@ -143,7 +150,7 @@ export const UI_COMPONENTS_CONTRACTS = [
143
150
  {
144
151
  tag: "np-relative-date",
145
152
  component: "RelativeDate",
146
- properties: { "date": "string", "icon": "string", "label": "string", "hideLabel": "boolean", "options": "object", "showTooltip": "boolean", "emptyText": "string", "live": "boolean" },
153
+ properties: { "date": "string", "icon": "string", "label": "string", "hideLabel": "boolean", "options": "object", "showTooltip": "boolean", "emptyText": "string", "live": "boolean", "muted": "boolean" },
147
154
  events: {},
148
155
  },
149
156
  {
@@ -304,7 +311,7 @@ export const UI_COMPONENTS_CONTRACTS = [
304
311
  {
305
312
  tag: "np-code-highlighter",
306
313
  component: "CodeHighlighter",
307
- properties: { "code": "string", "lang": "string" },
314
+ properties: { "code": "string", "lang": "string", "maxHeight": "number" },
308
315
  events: {},
309
316
  values: { "lang": ["bash", "hcl", "json", "sql", "yaml"] },
310
317
  },
@@ -322,4 +329,53 @@ export const UI_COMPONENTS_CONTRACTS = [
322
329
  events: {},
323
330
  defaults: { "content": "" },
324
331
  },
332
+ {
333
+ tag: "np-calendar-month",
334
+ component: "CalendarMonth",
335
+ properties: { "month": "string", "timeZone": "string", "weekStartsOn": "number", "today": "string", "events": "array", "selectedId": "string", "maxLanes": "number", "locale": "string" },
336
+ events: { "eventPress": "onEventPress", "dayPress": "onDayPress", "morePress": "onMorePress" },
337
+ values: { "events[].kind": ["freeze", "window"], "events[].state": ["active", "upcoming", "past"] },
338
+ defaults: { "weekStartsOn": 1, "maxLanes": 2 },
339
+ },
340
+ {
341
+ tag: "np-calendar-week",
342
+ component: "CalendarWeek",
343
+ properties: { "weekStart": "string", "timeZone": "string", "startHour": "number", "endHour": "number", "events": "array", "selectedId": "string", "now": "string", "locale": "string", "allDayLabel": "string" },
344
+ events: { "eventPress": "onEventPress", "slotPress": "onSlotPress" },
345
+ values: { "events[].kind": ["freeze", "window"], "events[].state": ["active", "upcoming", "past"] },
346
+ defaults: { "startHour": 0, "endHour": 24 },
347
+ },
348
+ {
349
+ tag: "np-calendar-timeline",
350
+ component: "CalendarTimeline",
351
+ properties: { "from": "string", "to": "string", "timeZone": "string", "rows": "array", "bars": "array", "selectedId": "string", "now": "string", "locale": "string", "resourceLabel": "string" },
352
+ events: { "barPress": "onBarPress" },
353
+ values: { "rows[].kind": ["organization", "account", "namespace", "application"], "bars[].kind": ["freeze", "window"], "bars[].state": ["active", "upcoming", "past"] },
354
+ },
355
+ {
356
+ tag: "np-toggle-button-group",
357
+ component: "ToggleButtonBar",
358
+ properties: { "options": "array", "value": "string", "size": "string", "aria-label": "string", "multiple": "boolean", "values": "array" },
359
+ events: { "change": "onChange" },
360
+ values: { "size": ["small", "medium", "large"] },
361
+ },
362
+ {
363
+ tag: "np-icon-button",
364
+ component: "IconActionButton",
365
+ properties: { "icon": "string", "aria-label": "string", "color": "string", "size": "string", "disabled": "boolean" },
366
+ events: { "press": "onPress" },
367
+ values: { "color": ["default", "inherit", "primary", "secondary", "error", "info", "success", "warning"], "size": ["small", "medium", "large"] },
368
+ },
369
+ {
370
+ tag: "np-autocomplete",
371
+ component: "AutocompleteSelect",
372
+ properties: { "options": "array", "value": "string", "label": "string", "placeholder": "string", "disabled": "boolean" },
373
+ events: { "change": "onChange" },
374
+ },
375
+ {
376
+ tag: "np-date-time-range-picker",
377
+ component: "DateTimeRangeField",
378
+ properties: { "start": "string", "end": "string", "allDay": "boolean", "timeZone": "string", "locale": "string", "label": "string", "error": "string", "disabled": "boolean" },
379
+ events: { "change": "onChange" },
380
+ },
325
381
  ];
package/dist/elements.js CHANGED
@@ -11,7 +11,9 @@ const registry = new Map();
11
11
  function defineElement(spec) {
12
12
  const properties = {};
13
13
  for (const [name, type] of Object.entries(spec.properties)) {
14
- const ctor = type === 'number' ? Number : type === 'boolean' ? Boolean : type === 'string' ? String : Object;
14
+ // Not `Boolean` for booleans: remote-dom starts those at `false`, which would override a component whose default
15
+ // is `true` for every plugin that leaves the prop out. The host checks each value against the catalog's type.
16
+ const ctor = type === 'number' ? Number : type === 'string' ? String : Object;
15
17
  properties[name] = { type: ctor, attribute: false };
16
18
  }
17
19
  const events = {};
package/dist/index.d.ts CHANGED
@@ -5,5 +5,5 @@ export { nullplatform, type NullplatformBridge } from './bridge.js';
5
5
  export { useTopic, useSetTopic, type UseTopicOptions, type UseTopicResult, type UseSetTopicOptions, type SetTopicState, type TopicMap, type ServiceDraftV1, } from './topics.js';
6
6
  export * from './components.js';
7
7
  export { hostRenders } from './host.js';
8
- export type { PluginContext, ApiRequest, HttpRequest, HttpResponse, NavigationTarget, SnackbarOptions, TopicSnapshot, TopicStatus } from './protocol.js';
8
+ export type { PluginContext, ApiRequest, HttpRequest, HttpResponse, NavigationTarget, SnackbarOptions, ConfirmOptions, TopicSnapshot, TopicStatus } from './protocol.js';
9
9
  export { BridgeError } from './protocol.js';
@@ -45,6 +45,10 @@ export interface PluginContext {
45
45
  deployment?: {
46
46
  id: number | string;
47
47
  };
48
+ /** Set on build pages. Not usable in `when` yet (see `CONTEXT_ROOTS`). */
49
+ build?: {
50
+ id: number | string;
51
+ };
48
52
  nrn?: string;
49
53
  user?: {
50
54
  id: number | string;
@@ -89,6 +93,27 @@ export interface SnackbarOptions {
89
93
  title: string;
90
94
  variant?: 'default' | 'success' | 'error' | 'warning' | 'info';
91
95
  }
96
+ /**
97
+ * A confirmation the host draws with its own dialog: a plugin cannot draw over the page. The host caps every
98
+ * field (see `CONFIRM_LIMITS`) and rejects options over a cap rather than truncating what the person reads.
99
+ */
100
+ export interface ConfirmOptions {
101
+ title: string;
102
+ message: string;
103
+ confirmLabel?: string;
104
+ cancelLabel?: string;
105
+ /** Draws the confirm action as destructive: the dashboard uses its deletion dialog. */
106
+ destructive?: boolean;
107
+ /** When set, the person must type it to confirm (the dashboard's DeletionModal does this). */
108
+ confirmationToken?: string;
109
+ }
110
+ /** Maximum length of each `ConfirmOptions` string. */
111
+ export declare const CONFIRM_LIMITS: {
112
+ readonly title: 200;
113
+ readonly message: 1000;
114
+ readonly label: 40;
115
+ readonly confirmationToken: 100;
116
+ };
92
117
  /** Methods a plugin can call on the host. */
93
118
  export interface BridgeMethods {
94
119
  'assets.url': (path: string) => Promise<string>;
@@ -96,6 +121,8 @@ export interface BridgeMethods {
96
121
  'http.request': (request: HttpRequest) => Promise<HttpResponse>;
97
122
  'navigation.push': (target: NavigationTarget) => Promise<void>;
98
123
  'ui.snackbar': (options: SnackbarOptions) => Promise<void>;
124
+ /** Resolves `true` only when the person confirms; `false` when they cancel or the host draws no dialog. */
125
+ 'ui.confirm': (options: ConfirmOptions) => Promise<boolean>;
99
126
  'context.get': () => Promise<PluginContext>;
100
127
  'topics.get': (topic: string) => Promise<TopicSnapshot>;
101
128
  'topics.subscribe': (topic: string) => Promise<TopicSnapshot>;
@@ -104,6 +131,12 @@ export interface BridgeMethods {
104
131
  'topics.clear': (topic: string) => Promise<void>;
105
132
  }
106
133
  export type BridgeMethodName = keyof BridgeMethods;
134
+ /** How long the host gives a bridge call before it answers `TIMEOUT`. */
135
+ export declare const BRIDGE_CALL_DEADLINE_MS = 30000;
136
+ /** Calls that wait for a person, not a machine, and so get longer than `BRIDGE_CALL_DEADLINE_MS`. */
137
+ export declare const BRIDGE_CALL_DEADLINES_MS: Readonly<Partial<Record<BridgeMethodName, number>>>;
138
+ /** The host's deadline for one call. */
139
+ export declare function bridgeCallDeadline(method: BridgeMethodName): number;
107
140
  /**
108
141
  * Whether a topic has a value on this page: `waiting` when something on the page provides it but has not
109
142
  * set a value yet, `no-provider` when nothing on the page provides it.
package/dist/protocol.js CHANGED
@@ -7,6 +7,18 @@
7
7
  * host side; the host invokes them with a `fn` message.
8
8
  */
9
9
  export const PROTOCOL_VERSION = 1;
10
+ /** Maximum length of each `ConfirmOptions` string. */
11
+ export const CONFIRM_LIMITS = { title: 200, message: 1000, label: 40, confirmationToken: 100 };
12
+ /** How long the host gives a bridge call before it answers `TIMEOUT`. */
13
+ export const BRIDGE_CALL_DEADLINE_MS = 30000;
14
+ /** Calls that wait for a person, not a machine, and so get longer than `BRIDGE_CALL_DEADLINE_MS`. */
15
+ export const BRIDGE_CALL_DEADLINES_MS = {
16
+ 'ui.confirm': 10 * 60 * 1000,
17
+ };
18
+ /** The host's deadline for one call. */
19
+ export function bridgeCallDeadline(method) {
20
+ return BRIDGE_CALL_DEADLINES_MS[method] ?? BRIDGE_CALL_DEADLINE_MS;
21
+ }
10
22
  export class BridgeError extends Error {
11
23
  code;
12
24
  status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nullplatform/ui-plugin-sdk",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "SDK for nullplatform UI plugins: catalog components, bridge client and defineUI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -42,7 +42,7 @@
42
42
  "test": "vitest run --passWithNoTests",
43
43
  "sync:contracts": "node scripts/sync-contracts.mjs"
44
44
  },
45
- "uiComponentsContracts": "0.15.18",
45
+ "uiComponentsContracts": "0.16.0",
46
46
  "dependencies": {
47
47
  "@remote-dom/core": "^1.11.1",
48
48
  "@remote-dom/react": "^1.2.2",