@kosdev-code/kos-ddk-cli 0.1.0-dev.75 → 0.1.0-dev.87

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.
@@ -5,8 +5,8 @@ description: >-
5
5
  for a need, write the contribution with its tool (including overrides of standard
6
6
  contributions), build its component from DDK components, develop it in Storybook or
7
7
  against a running DDK, and validate it. Use when adding a utility, setup step, nav
8
- view (including a Settings tab), CUI configuration, dashboard card, pump detail, macro summary or
9
- trouble action to a DDK plugin, or replacing a standard one.
8
+ view (including a Settings tab), CUI configuration, dashboard card, pump detail, macro summary,
9
+ dashboard region or trouble action to a DDK plugin, or replacing a standard one.
10
10
  ---
11
11
 
12
12
  # Build a DDK plugin
@@ -58,6 +58,14 @@ component content. Never hand-edit the contributions or experiences the tools wr
58
58
  has none, and pass `descriptorProject` to `add_utility`, `add_setup_step` or
59
59
  `add_nav_view`. `ddk://guide/descriptor-project` lists each layout's entries and what each option adds.
60
60
 
61
+ A whole dashboard region is `add_dashboard_region`: its component renders the
62
+ descriptor region whose `component` (else `name`) is `regionKey`, in place of that
63
+ region's built-in cards. A built-in region name (`micros`, `macros`, `assembly`)
64
+ replaces that region's cards. A region of its own, such as a dispenser map, is
65
+ `descriptorProject`: it adds a region that claims no holders or summaries, so every
66
+ card stays where it was and the component reads the `assembly`; the region shows
67
+ only while a plugin contributes its key.
68
+
61
69
  7. **Register the models it uses.** A model the plugin renders is registered by the
62
70
  plugin's init lifecycle: `register_model` with `app` set to the plugin project (dry
63
71
  run, then `dryRun: false`). It sets `kos.ui.plugin.init: true`, writes
@@ -18,7 +18,9 @@ look of whichever theme the DDK app applies.
18
18
  1. **Its inputs.** The extension point resource (`ddk://extension-point/{id}`, "Props
19
19
  your component receives") lists what the component is given: `assembly` and
20
20
  `cardModel` for dashboard cards, `holder` for pump details and macro summaries,
21
- `trouble` for trouble actions. Read data from those props.
21
+ `trouble` for trouble actions, and for a dashboard region the `holderGroups` and
22
+ `summaries` it claimed, the `assembly`, its card `size` and `flow`. Read data from
23
+ those props.
22
24
 
23
25
  2. **Find the components.** `find_ddk_capability` with what the component must show,
24
26
  then `list_ddk_components` with a query. Two libraries:
@@ -33,7 +33,8 @@ is the reference; this is the order to work in.
33
33
  5. **What the story needs.** Each story renders inside its extension point's story
34
34
  container (the table in the guide). A dashboard card needs an active model at its
35
35
  `dashboardKey`, a pump detail or macro summary a holder with it, a trouble action an
36
- active trouble of its `troubleType`. When the simulator has none, the container says
36
+ active trouble of its `troubleType`. A dashboard region story names the holder
37
+ patterns and summary keys its region claims on the container. When the simulator has none, the container says
37
38
  so in place of the story: change the simulator's state, not the story.
38
39
 
39
40
  6. **Both render modes.** The Render Mode toolbar switches between `standard` and
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Note: The plugin project Storybook configuration requires that the Studio
3
+ * Simulator is running in order to retrieve model data, unless the story mocks
4
+ * it with parameters.kosMock (ddk://guide/storybook).
5
+ */
6
+ import { DashboardRegionStoryContainer } from "@kosdev-code/kos-ddk-story-containers";
7
+ import type { Meta, StoryObj } from "@storybook/react";
8
+ import { <%= namePascalCase %> } from "./<%= nameDashCase %>";
9
+
10
+ const meta: Meta<typeof <%= namePascalCase %>> = {
11
+ args: {},
12
+ component: <%= namePascalCase %>,
13
+ decorators: [
14
+ (Story, context) => (
15
+ <% if (locals.claimsNothing) { -%>
16
+ <DashboardRegionStoryContainer regionKey="<%= regionKey %>">
17
+ <% } else { -%>
18
+ <DashboardRegionStoryContainer
19
+ regionKey="<%= regionKey %>"
20
+ holders={["*"]}
21
+ >
22
+ <% } -%>
23
+ {(props) => <Story args={{ ...context.args, ...props }} />}
24
+ </DashboardRegionStoryContainer>
25
+ ),
26
+ ],
27
+ tags: ["!autodocs"],
28
+ title: "dashboardRegion/<%= namePascalCase %>",
29
+ };
30
+
31
+ export default meta;
32
+
33
+ type Story = StoryObj<typeof <%= namePascalCase %>>;
34
+
35
+ export const Default: Story = {
36
+ // parameters: { kosMock: { setups: ["<setup module>"] } },
37
+ render: (props) => <<%= namePascalCase %> {...props} />,
38
+ };
@@ -0,0 +1,28 @@
1
+ import { LabelSmall } from '@kosdev-code/kos-ddk-components';
2
+ import type { DashboardRegionComponentProps } from '@kosdev-code/kos-ddk-models';
3
+ import { KosLog, kosComponent } from '@kosdev-code/kos-ui-sdk';
4
+
5
+ const log = KosLog.createLogger({ name: "<%= nameDashCase %>" });
6
+ log.debug("<%= nameDashCase %> component loaded");
7
+
8
+ /**
9
+ * Renders the dashboard region "<%= regionKey %>" in place of its built-in cards. The
10
+ * host passes the holders and summaries the region claimed, and the whole assembly.
11
+ */
12
+ export const <%= namePascalCase %>: React.FunctionComponent<DashboardRegionComponentProps> =
13
+ kosComponent(({ holderGroups, summaries }) => {
14
+ return (
15
+ <>
16
+ {holderGroups.map((group) => (
17
+ <LabelSmall key={group.name}>{group.name}</LabelSmall>
18
+ ))}
19
+ {summaries.map((summary) => (
20
+ <LabelSmall key={summary.dashboardKey}>{summary.dashboardKey}</LabelSmall>
21
+ ))}
22
+ </>
23
+ );
24
+ });
25
+
26
+ <%= namePascalCase %>.displayName = "<%= namePascalCase %>";
27
+
28
+ export default <%= namePascalCase %>;
@@ -0,0 +1 @@
1
+ export * from "./<%= nameDashCase %>";
@@ -105,6 +105,7 @@ Each story renders the component inside the container for its extension point, f
105
105
  | `ddk:pump-detail` | `PumpDetailStoryContainer` | the first `holder` with the `dashboardKey` |
106
106
  | `ddk:pump-card` | `PumpSummaryStoryContainer`, `PumpDetailStoryContainer` | the first `holder` with the `dashboardKey` |
107
107
  | `ddk:macro-summary` | `MacroSummaryStoryContainer` | the first `holder` with the `dashboardKey` |
108
+ | `ddk:dashboard-region` | `DashboardRegionStoryContainer` | the region props for its `holders` and `summaries` |
108
109
  | `ddk:trouble-action` | `TroubleActionStoryContainer` | the active `trouble` of the `troubleType` |
109
110
 
110
111
  When the simulator has no matching model, holder or trouble, the container says so in place
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosdev-code/kos-ddk-cli",
3
- "version": "0.1.0-dev.75",
3
+ "version": "0.1.0-dev.87",
4
4
  "description": "DDK commands for kosui: plugin projects and DDK extension-point contributions.",
5
5
  "type": "module",
6
6
  "kosui": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "kos": {
29
29
  "build": {
30
- "gitHash": "94a4601c8d51b3717bb903e93903ed6ce5cf763f"
30
+ "gitHash": "55ee9cd317769b88bf78697a73d71b6f194fbb59"
31
31
  }
32
32
  },
33
33
  "publishConfig": {