@riducms/plugin 0.1.4 → 0.2.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/src/row-label.ts CHANGED
@@ -12,26 +12,37 @@ export type RowLabelValue =
12
12
  | readonly RowLabelValue[]
13
13
  | { readonly [key: string]: RowLabelValue };
14
14
 
15
- /** A detached, deeply frozen view of the current array or blocks row. */
15
+ /** A read-only copy of an array/block row, frozen recursively. Use it to display a heading, not edit data. */
16
16
  export type RowLabelSnapshot = Readonly<Record<string, RowLabelValue>>;
17
17
 
18
+ /** Props for a paired plugin's custom array/block row heading. */
18
19
  export interface RowLabelComponentProps {
20
+ /** The containing array/block field's resolved definition. */
19
21
  field: SchemaField;
22
+ /** Current row data. The component receives updated snapshots when the row changes. */
20
23
  row: RowLabelSnapshot;
21
24
  /** The current visual position, starting at one. */
22
25
  rowNumber: number;
23
26
  i18n: AdminI18n;
24
- /** Deterministic JSON from field.nested.rowLabelComponent.config. */
25
- config: unknown;
27
+ /** Go `field.Admin{RowLabel: field.PluginComponent(pluginKey, componentKey, config)}` settings, when supplied. This API supplies unknown data; validate it before use. */
28
+ config?: unknown;
26
29
  }
27
30
 
28
- /** One exact plugin-owned component available to array and blocks headings. */
31
+ /** A named array/block heading selected by Go `field.Admin.RowLabel` using `field.PluginComponent`. */
29
32
  export interface RowLabelPlugin {
33
+ /** Owning plugin key; must match the containing `defineAdminPlugin` registration. */
30
34
  key: string;
35
+ /** Component name selected by the Go component reference, for example `"ReviewHeading"`. */
31
36
  componentKey: string;
32
37
  component: Component<RowLabelComponentProps>;
33
38
  }
34
39
 
40
+ /**
41
+ * Register a paired plugin's read-only row heading in its `rowLabels` array.
42
+ * Go selects the same `key` and `componentKey` with `field.Admin{RowLabel: field.PluginComponent(key, componentKey, config)}`.
43
+ * Your component checks its unknown config. Application-local headings instead
44
+ * use `defineRowLabel` from `@riducms/plugin/admin`, which accepts a config decoder.
45
+ */
35
46
  export function defineRowLabelPlugin<const Plugin extends RowLabelPlugin>(plugin: Plugin): Plugin {
36
47
  return plugin;
37
48
  }