@kosdev-code/kos-ddk-cli 0.1.0-dev.57 → 0.1.0-dev.61
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/README.md +1 -1
- package/agent-plugin/kos-ddk-tools/.claude-plugin/plugin.json +1 -1
- package/agent-plugin/kos-ddk-tools/plugin.json +1 -1
- package/agent-plugin/kos-ddk-tools/reference/reference.json +6 -1
- package/agent-plugin/kos-ddk-tools/servers/kos-ddk.mjs +2 -2
- package/agent-plugin/kos-ddk-tools/skills/ddk-content-component/SKILL.md +10 -2
- package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.stories.tsx__template__ +30 -5
- package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.tsx__template__ +56 -5
- package/guides/storybook.md +5 -1
- package/package.json +2 -2
- package/reference/reference.json +6 -1
- package/src/codegen/contribution.mjs +16 -4
- package/src/generators/contributions.mjs +13 -0
- package/src/mcp/tools.mjs +8 -1
- package/templates/utility/__nameDashCase__.stories.tsx__template__ +30 -5
- package/templates/utility/__nameDashCase__.tsx__template__ +56 -5
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ workspace or globally, repo roots, and installing the agent plugin and MCP serve
|
|
|
16
16
|
|
|
17
17
|
| Command | Writes |
|
|
18
18
|
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
19
|
-
| `ddk:utility` | a utility (`utilities` contribution, `utilDescriptor`)
|
|
19
|
+
| `ddk:utility` | a utility in a modal (`utilities` contribution, `utilDescriptor`); `--layout maximized` (default) or `fullscreen` |
|
|
20
20
|
| `ddk:setup` | a setup step (`setupStep` contribution, `setupDescriptor`) |
|
|
21
21
|
| `ddk:dashboard-card` | a dashboard summary card and its detail, sharing `--dashboardKey` |
|
|
22
22
|
| `ddk:pump-detail` | a pump detail for holders with `--dashboardKey` |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kos-ddk-tools",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.61",
|
|
4
4
|
"description": "KOS DDK plugin authoring (kos-ddk) MCP server: plugin projects, extension-point contributions and overrides of the standard ones.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kosdev-code"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "kos-ddk-tools",
|
|
4
|
-
"version": "0.1.0-dev.
|
|
4
|
+
"version": "0.1.0-dev.61",
|
|
5
5
|
"description": "KOS DDK plugin authoring (kos-ddk) MCP server: plugin projects, extension-point contributions and overrides of the standard ones.",
|
|
6
6
|
"license": "MIT"
|
|
7
7
|
}
|
|
@@ -18947,6 +18947,11 @@
|
|
|
18947
18947
|
"package": "@kosdev-code/kos-ddk-components",
|
|
18948
18948
|
"file": "src/hooks/router/useNavigate.tsx"
|
|
18949
18949
|
},
|
|
18950
|
+
{
|
|
18951
|
+
"name": "useUtilityModal",
|
|
18952
|
+
"package": "@kosdev-code/kos-ddk-components",
|
|
18953
|
+
"file": "src/components/modal/utility-modal/use-utility-modal.tsx"
|
|
18954
|
+
},
|
|
18950
18955
|
{
|
|
18951
18956
|
"name": "useViewExperience",
|
|
18952
18957
|
"package": "@kosdev-code/kos-ddk-components",
|
|
@@ -19235,7 +19240,7 @@
|
|
|
19235
19240
|
"name": "ddk-guide-storybook",
|
|
19236
19241
|
"title": "Developing DDK contributions in Storybook",
|
|
19237
19242
|
"description": "Running a plugin's Storybook against a simulator or with KosMock story mocks, where model data comes from, the story container per contribution command, render modes and overrides.",
|
|
19238
|
-
"body": "# Developing DDK contributions in Storybook\n\nEvery `ddk:*` contribution command writes a story next to the component, so a contribution\ncan be developed in isolation before the plugin is loaded into a running DDK. Stories render\nagainst live models from a running simulator.\n\n## Run it\n\n```sh\nnpx nx run <plugin>:storybook\n```\n\nStorybook serves on port 4400. The plugin's `serve` target is the module federation dev\nserver used by `kosui ddk:dev`; Storybook has its own `storybook` target.\n\n## Where model data comes from\n\nThe preview (`.storybook/preview.tsx`) wraps every story in the providers the DDK hosts use:\nKosCore, translations (`app/system`, `app/kosdev.ddk`), `AssemblyProvider`,\n`ApplicationProvider` and `ApplicationComponentConfigurationProvider`. KosCore connects to the\nfirst of:\n\n1. the `?host=` query parameter on the Storybook URL;\n2. `KOS_HOST` and `KOS_PORT` in the plugin's `.env` (the generated `.env` sets\n `KOS_PORT=8081`, the simulator's default);\n3. the page's own origin.\n\nTranslations come from the same device: the DDK's namespaces (`app/system`,\n`app/kosdev.ddk`) from its files, and the plugin's own namespace from the plugin's\n`src/assets/locales`, since the device lists it only once the KAB is installed. Each\ncontribution command adds its title key, and the keys its component calls, to\n`src/assets/locales/en/<plugin>.json`.\n\nStart the simulator before Storybook. A story shows what the simulator has: a dashboard card\nneeds an active model at its `dashboardKey`, a trouble action needs an active trouble of its\n`troubleType`.\n\n## Mocking what the simulator lacks\n\nA story can bring its own data with KosMock, the SDK's transport-level mocks\n(`kos://guide/mocking`), instead of waiting for the simulator to reach a state: an active\ntrouble, setup mode, a descriptor entry. It names the mocks as `parameters.kosMock`, and\nthe preview's outermost decorator reloads the page into those boot switches\n(`ensureKosMockBoot`):\n\n```tsx\nexport const ActiveTrouble: Story = {\n parameters: { kosMock: { setups: [\"daily-cleaning-trouble\"] } },\n};\n```\n\n`kosMock` takes `setups` (setup modules in `fixtures/setups/`), `fixture` (a recorded\nfixture), `mode` and `fixtureServer`:\n\n- `mode: \"on\"` (the default) mocks only the named endpoints over the running simulator.\n- `mode: \"standalone\"` boots with no device at all; every endpoint the story reads must\n be mocked.\n\nServe the fixtures beside Storybook:\n\n```sh\nkosui fixtures serve\n```\n\nA story without `kosMock` reloads without switches, so mocks never carry over between\nstories. Every generated story has a commented `kosMock` line to start from.\n\n## Story containers\n\nEach story renders the component inside the container for its extension point, from\n`@kosdev-code/kos-ddk-story-containers`:\n\n| Command | Container | Gives the component |\n| -------------------- | ----------------------------------------------------------------- | ----------------------------------------------------- |\n| `ddk:utility` | `UtilityStoryContainer` | the utility
|
|
19243
|
+
"body": "# Developing DDK contributions in Storybook\n\nEvery `ddk:*` contribution command writes a story next to the component, so a contribution\ncan be developed in isolation before the plugin is loaded into a running DDK. Stories render\nagainst live models from a running simulator.\n\n## Run it\n\n```sh\nnpx nx run <plugin>:storybook\n```\n\nStorybook serves on port 4400. The plugin's `serve` target is the module federation dev\nserver used by `kosui ddk:dev`; Storybook has its own `storybook` target.\n\n## Where model data comes from\n\nThe preview (`.storybook/preview.tsx`) wraps every story in the providers the DDK hosts use:\nKosCore, translations (`app/system`, `app/kosdev.ddk`), `AssemblyProvider`,\n`ApplicationProvider` and `ApplicationComponentConfigurationProvider`. KosCore connects to the\nfirst of:\n\n1. the `?host=` query parameter on the Storybook URL;\n2. `KOS_HOST` and `KOS_PORT` in the plugin's `.env` (the generated `.env` sets\n `KOS_PORT=8081`, the simulator's default);\n3. the page's own origin.\n\nTranslations come from the same device: the DDK's namespaces (`app/system`,\n`app/kosdev.ddk`) from its files, and the plugin's own namespace from the plugin's\n`src/assets/locales`, since the device lists it only once the KAB is installed. Each\ncontribution command adds its title key, and the keys its component calls, to\n`src/assets/locales/en/<plugin>.json`.\n\nStart the simulator before Storybook. A story shows what the simulator has: a dashboard card\nneeds an active model at its `dashboardKey`, a trouble action needs an active trouble of its\n`troubleType`.\n\n## Mocking what the simulator lacks\n\nA story can bring its own data with KosMock, the SDK's transport-level mocks\n(`kos://guide/mocking`), instead of waiting for the simulator to reach a state: an active\ntrouble, setup mode, a descriptor entry. It names the mocks as `parameters.kosMock`, and\nthe preview's outermost decorator reloads the page into those boot switches\n(`ensureKosMockBoot`):\n\n```tsx\nexport const ActiveTrouble: Story = {\n parameters: { kosMock: { setups: [\"daily-cleaning-trouble\"] } },\n};\n```\n\n`kosMock` takes `setups` (setup modules in `fixtures/setups/`), `fixture` (a recorded\nfixture), `mode` and `fixtureServer`:\n\n- `mode: \"on\"` (the default) mocks only the named endpoints over the running simulator.\n- `mode: \"standalone\"` boots with no device at all; every endpoint the story reads must\n be mocked.\n\nServe the fixtures beside Storybook:\n\n```sh\nkosui fixtures serve\n```\n\nA story without `kosMock` reloads without switches, so mocks never carry over between\nstories. Every generated story has a commented `kosMock` line to start from.\n\n## Story containers\n\nEach story renders the component inside the container for its extension point, from\n`@kosdev-code/kos-ddk-story-containers`:\n\n| Command | Container | Gives the component |\n| -------------------- | ----------------------------------------------------------------- | ----------------------------------------------------- |\n| `ddk:utility` | `UtilityStoryContainer` | nothing: the utility opens its own `Modal` |\n| `ddk:setup` | `SetupStepStoryContainer` | the setup step frame |\n| `ddk:nav` | `NavStoryContainer` | the navigation view frame |\n| `ddk:cui` | `CUIStoryContainer` | the CUI frame |\n| `ddk:dashboard-card` | `DashboardSummaryStoryContainer`, `DashboardDetailStoryContainer` | `dashboardKey`, `assembly`, `cardModel`, `onComplete` |\n| `ddk:pump-detail` | `PumpDetailStoryContainer` | the first `holder` with the `dashboardKey` |\n| `ddk:pump-card` | `PumpSummaryStoryContainer`, `PumpDetailStoryContainer` | the first `holder` with the `dashboardKey` |\n| `ddk:macro-summary` | `MacroSummaryStoryContainer` | the first `holder` with the `dashboardKey` |\n| `ddk:trouble-action` | `TroubleActionStoryContainer` | the active `trouble` of the `troubleType` |\n\nWhen the simulator has no matching model, holder or trouble, the container says so in place\nof the story.\n\nA utility story has an `open` control. Closing the utility turns it off and logs\n`onComplete` in the Actions panel; the **Open** button behind the modal, or the\ncontrol, opens it again.\n\n## Standard and compact modes\n\nThe **Render Mode** toolbar switches between `standard` and `compact`. It changes the DDK\nstyles and the component mode; in `compact`, modals render full screen.\n\n## Overrides\n\nA story renders the override on its own, so an override of a standard contribution can be\ndeveloped here first. To see it replace the standard contribution, load the plugin into a\nrunning DDK with `kosui ddk:dev` (see the package README)."
|
|
19239
19244
|
},
|
|
19240
19245
|
{
|
|
19241
19246
|
"uri": "ddk://guide/descriptor-project",
|
|
@@ -48532,9 +48532,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48532
48532
|
|
|
48533
48533
|
`):null}function Ljt(s,a,p){let g=new Set($It(a)),E=new Set($It(p)),A=0,I=[];for(let F of s)g.has(F)?(A+=3,I.push(F)):E.has(F)&&(A+=1,I.push(F));return{total:A,matched:I}}function V7n(s,{limit:a=5}={}){let p=[...new Set($It(s))],{extensionPoints:g,components:E,contributionTools:A}=Ett(),I=Gdt(Udt()),F=ee=>ee.filter(H=>H.total>0).sort((H,le)=>le.total-H.total).slice(0,a).map(({total:H,...le})=>le),z=ee=>Object.values(ee).join(" "),$=new Set(g.map(ee=>ee.contributionKey)),X=[...g.map(ee=>({id:ee.id,contributionKey:ee.contributionKey,resource:`ddk://extension-point/${ee.id}`,...ee.writer?{tool:ee.writer.tool}:{},...Ljt(p,`${ee.id} ${ee.displayName} ${ee.contributionKey}`,[ee.description,ee.category??"",...ee.fields.map(H=>`${H.name} ${H.description??""}`),...I.filter(H=>H.contributionKey===ee.contributionKey).map(H=>`${H.id} ${z(H.keys)}`)].join(" "))})),...Object.entries(A).filter(([ee])=>!$.has(ee)).map(([ee,H])=>({contributionKey:ee,tool:H.tool,...Ljt(p,`${ee} ${H.command}`,I.filter(le=>le.contributionKey===ee).map(le=>`${le.id} ${z(le.keys)}`).join(" "))}))];return{extensionPoints:F(X),standardContributions:F(I.map(ee=>({id:ee.id,contributionKey:ee.contributionKey,keys:ee.keys,...typeof ee.rank=="number"?{rank:ee.rank}:{},...Ljt(p,`${ee.id} ${z(ee.keys)}`,ee.point)}))),components:F(E.map(ee=>({name:ee.name,package:ee.package,...Ljt(p,ee.name,`${ee.file} ${ee.props.map(H=>H.name).join(" ")}`)}))),next:"Write with the point's tool (pass a standard contribution's id as override to replace it), then describe_ddk_component for each component you render."}}import i3n from"node:path";var H7n=F5(IOt(),1),q7n=F5(oMt(),1),SAr=F5(xQt(),1),NSe=F5(Cme(),1),Ctt=F5(mnn(),1);import*as r8e from"fs";import*as fB from"path";var TAr=s=>s.replace(/\\/g,"/");var EAr=s=>fB.posix.dirname(TAr(s));var DAr={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},CAr=DAr;function $7n(){return CAr}function AAr(s,a,p,g){let E=$7n(),A=J7n(a);for(let I of A){let F=fB.relative(a,I),z=PAr(F,g);z.endsWith(".template")&&(z=z.slice(0,-9));let $=fB.join(p,z),X=r8e.readFileSync(I,"utf-8"),ee=H7n.render(X,g,{filename:I});E.debug(`Generating ${$}`),s.write($,ee)}}function PAr(s,a){return s.replace(/__([^_]+)__/g,(p,g)=>g in a?String(a[g]):p)}function J7n(s){let a=[],p=r8e.readdirSync(s,{withFileTypes:!0});for(let g of p){let E=fB.join(s,g.name);g.isDirectory()?a.push(...J7n(E)):a.push(E)}return a}function Vnn(s){let a=$7n(),p=new Map,g=q7n.default.sync("**/project.json",{cwd:s,ignore:["**/node_modules/**","**/dist/**","**/.git/**"],absolute:!1});for(let E of g){let A=fB.join(s,E);try{let I=r8e.readFileSync(A,"utf-8"),F=JSON.parse(I),z=EAr(E),$=F.name??fB.basename(z),X={name:$,root:z,sourceRoot:F.sourceRoot??fB.posix.join(z,"src"),projectType:F.projectType,targets:F.targets,tags:F.tags};p.set($,X),a.debug(`Discovered project: ${$} at ${z}`)}catch(I){a.warn(`Failed to parse ${A}: ${I}`)}}return a.info(`Discovered ${p.size} projects`),p}function RSe(s,a,p){return(p??Vnn(s)).get(a)}function K7n(s,a){let p=s.read(a);if(p===null)throw new Error(`File not found: ${a}`);return JSON.parse(p)}function kAr(s,a,p){s.write(a,JSON.stringify(p,null,2)+`
|
|
48534
48534
|
`)}function Bjt(s,a,p){let g=K7n(s,a),E=p(g);kAr(s,a,E)}function X7n(s){return s.replace(/\s+/g,"-").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function T9e(s){if(s.length===0)return"";let a=s.split(/-|\s+/);a.length>0&&a[0].length>0&&(a[0]=a[0].charAt(0).toLowerCase()+a[0].slice(1));for(let p=1;p<a.length;p++)a[p]=a[p].charAt(0).toUpperCase()+a[p].slice(1);return a.join("")}function wAr(s){if(s.length===0)return"";let a=T9e(s);return a[0].toUpperCase()+a.slice(1)}function IAr(s){let a=s.toLowerCase().replaceAll("-"," ").split(" ").filter(Boolean);for(let p=0;p<a.length;p++)a[p]=a[p][0].toUpperCase()+a[p].slice(1);return a.join("")}function NAr(s){return s.length===0?"":s.toUpperCase().split(/[\s-]+/).filter(Boolean).join("_")}var RAr=(s,a)=>({[`${T9e(s)}CamelCase`]:T9e(a),[`${T9e(s)}ConstantCase`]:NAr(a),[`${T9e(s)}DashCase`]:X7n(a),[`${T9e(s)}PascalCase`]:wAr(a),[`${T9e(s)}ProperCase`]:IAr(a),[`${T9e(s)}LowerCase`]:a.toLowerCase(),[`${s}`]:a}),KIt=s=>{let a={};for(let p in s)if(Object.prototype.hasOwnProperty.call(s,p)){let g=s[p],E=typeof g!="string"||g===""?{[p]:g}:RAr(p,g);a={...a,...E}}return a};function OAr(s,a,p){let g=RSe(s.root,a,p);if(!g)return;let E=fB.join(g.root,".kos.json");if(!s.exists(E)){let I={name:`${X7n(a)}-model`,type:"kos.model",version:"0.1.0",models:{},generator:{defaults:{model:{folder:""}}}};s.write(E,JSON.stringify(I,null,2))}let A=s.read(E);return A?JSON.parse(A):void 0}var MAr="target",FGr=`{projectRoot}/${MAr}/`;function LAr(s,a,p){let g={name:a.name};a.modelName&&(g.modelName=a.modelName),a.companionModel&&(g.companionModel=a.companionModel);let E=KIt(g),A=a.modelProject,I=a.registrationProject||"",F=A!=="__NONE__",z="";if(F){let X=RSe(s.root,A,p);if(X){let ee=fB.join(X.root,"package.json");try{z=K7n(s,ee).name||""}catch{z=""}}}return{...{companion:!1,skipRegistration:!1,futureAware:"none",singleton:!1},...a,...E,modelProject:A,importPath:z,registrationProject:I,template:""}}var BGr={private:NSe.Scope.Private,protected:NSe.Scope.Protected,public:NSe.Scope.Public};var E9e={CONTROL_POUR:"controlPour",CUSTOM:"custom"},FAr={[E9e.CONTROL_POUR]:"control-pour",[E9e.CUSTOM]:"custom"},jGr=new Set([E9e.CONTROL_POUR,E9e.CUSTOM]),Dtt=class{getContributionKey(){return this.contributionKey}requiresLocalization(){return this.requiresI18n}getTemplatePath(){return this.contributionKey}createExperience(a,p){let g=this.getComponentPath(a);return{id:p,component:a.namePascalCase,location:`./src/${g}`}}getComponentPath(a){let p=this.getTargetDirectory?.()||this.contributionKey;return`${a.appDirectory}/${p}/${a.nameDashCase}/${a.nameDashCase}.tsx`}getConfigPrefix(a){return`${a.appProject}.${a.nameCamelCase}`}},znn=class extends Dtt{pluginType=E9e.CONTROL_POUR;contributionKey="control-pour";requiresI18n=!0;createConfiguration(a){let p=this.getConfigPrefix(a),g=`${p}.controlPour.experience`,E={id:`${p}.controlPour`,title:`${p}.controlPour.title`,namespace:a.appProject,experienceId:g},A=this.createExperience(a,g);return{contributions:{controlPour:[E]},experiences:{[g]:A}}}},Fjt=class extends Dtt{pluginType=E9e.CUSTOM;contributionKey="custom";requiresI18n=!0;createConfiguration(a){let p=this.getConfigPrefix(a),g=`${p}.${a.contributionKey||"custom"}.experience`,E=a.contributionKey||"custom",A={id:p,title:`${p}.${E}.title`,namespace:a.appProject,experienceId:g},I=this.createExperience(a,g);return{contributions:{[E]:[A]},experiences:{[g]:I}}}getTargetDirectory(){return"custom"}},Gnn=class extends Dtt{pluginType="component";contributionKey="components";requiresI18n=!1;createConfiguration(a){return{contributions:{},experiences:{}}}getTemplatePath(){return"files"}},n8e=class{static handlers=new Map([[E9e.CONTROL_POUR,znn],[E9e.CUSTOM,Fjt]]);static createHandler(a){if(!a)return new Gnn;let p=this.handlers.get(a)??Fjt;return new p}static isValidPluginType(a){return this.handlers.has(a)}static register(a,p){if(this.handlers.has(a))throw new Error(`Plugin type "${a}" already has a handler`);this.handlers.set(a,p)}};function BAr(s,a,p,g,E){AAr(s,fB.join(a,p),g,E),E.useEmotionCss&&jAr(s,g,E)}function jAr(s,a,p){let g=fB.join(a,`${p.nameDashCase}.css`);s.exists(g)&&s.delete(g)}var Unn=class s{contributions={};experiences={};views={};addPluginConfiguration(a){return Object.entries(a.contributions).forEach(([p,g])=>{this.contributions[p]=[...this.contributions[p]||[],...g]}),Object.assign(this.experiences,a.experiences),a.views&&Object.entries(a.views).forEach(([p,g])=>{this.views[p]=[...this.views[p]||[],...g]}),this}applyToFile(a,p){Bjt(a,p,g=>{let E=this.initializeStructure(g);return Object.entries(this.contributions).forEach(([A,I])=>{E.contributes[A]=[...E.contributes[A]||[],...I]}),E.contributes.experiences={...E.contributes.experiences,...this.experiences},Object.keys(this.views).length>0&&(E.contributes.views=E.contributes.views||{},Object.entries(this.views).forEach(([A,I])=>{E.contributes.views[A]=[...E.contributes.views[A]||[],...I]})),g})}initializeStructure(a){return a.kos??={},a.kos.ui??={},a.kos.ui.plugin??={},a.kos.ui.plugin.contributes??={},a.kos.ui.plugin}static create(){return new s}};function WAr(s,a,p,g){let E=fB.join(a,"assets","locales","en",`${p.appProject}.json`);if(!s.exists(E)){console.warn(`Locale file not found: ${E}`);return}Bjt(s,E,A=>(A[p.appProject]=A[p.appProject]||{},A[p.appProject][p.nameCamelCase]=A[p.appProject][p.nameCamelCase]||{},A[p.appProject][p.nameCamelCase][g]={...A[p.appProject][p.nameCamelCase][g],title:p.nameCamelCase},A))}var JIt=class extends Error{constructor(a){super(a),this.name="ValidationError"}};function zAr(s,a,p){if(!a.name)throw new JIt("Component name is required");if(!a.appProject)throw new JIt("App project is required");if(!RSe(s.root,a.appProject,p))throw new JIt(`Project "${a.appProject}" not found in workspace`);a.pluginType&&!n8e.isValidPluginType(a.pluginType)&&console.warn(`Unknown plugin type "${a.pluginType}". Component will be generated as a custom contribution.`)}function Y7n(s,a,p,g){zAr(s,p,g);let E=GAr(s,p,g),A=RSe(s.root,E.appProject,g);if(!A)throw new Error(`Project "${E.appProject}" not found in workspace`);let I=A.sourceRoot;if(!I)throw new Error(`No source root found for project ${E.appProject}`);UAr(s,a,I,E),p.pluginType&&VAr(s,A,E)}function GAr(s,a,p){let g=LAr(s,{...a,modelProject:"__NONE__"},p),A=OAr(s,a.appProject,p)?.generator?.defaults?.component?.folder||"";g.appDirectory=a.appDirectory||A;let I=a.pluginType?n8e.createHandler(a.pluginType):void 0;return g.type=I?.getTargetDirectory?.()||FAr[a.pluginType||""]||a.type,a.contributionKey&&(g.contributionKey=a.contributionKey),g}function UAr(s,a,p,g){let A=n8e.createHandler(g.pluginType).getTemplatePath(),I=fB.join(p,g.appDirectory,g.type,g.nameDashCase);BAr(s,a,A,I,g)}function VAr(s,a,p){let g=fB.join(a.root,".kos.json");if(!s.exists(g)){console.warn(`No .kos.json found at ${g}`);return}let E=n8e.createHandler(p.pluginType),A=E.createConfiguration(p),I=Unn.create();I.addPluginConfiguration(A),I.applyToFile(s,g),E.requiresLocalization()&&a.sourceRoot&&WAr(s,a.sourceRoot,p,E.getContributionKey())}import Q7n from"node:path";import{fileURLToPath as HAr}from"node:url";var XIt=Q7n.resolve(Q7n.dirname(HAr(import.meta.url)),"../templates"),Att=class extends Dtt{requiresI18n=!0;rankable=!1;getTargetDirectory(){return this.contributionKey}contribute(a,{suffix:p,experienceSuffix:g,key:E,fields:A}){let I=this.getConfigPrefix(a),F=`${I}.${g}.experience`;return{contributions:{[E]:[{id:p?`${I}.${p}`:I,title:`${I}.${A.titleSuffix}.title`,namespace:a.appProject,...A.extra,...this.rankable&&Number.isInteger(a.rank)?{rank:a.rank}:{},experienceId:F}]},experiences:{[F]:this.createExperience(a,F)}}}},Hnn=class extends Att{pluginType="ddk.cui";contributionKey="cui";createConfiguration(a){if(!a.descriptor)throw new Error("A CUI configuration needs its cuiDescriptor (descriptor)");return this.contribute(a,{suffix:"",experienceSuffix:"cui",key:"cui",fields:{titleSuffix:"cui",extra:{cuiDescriptor:a.descriptor}}})}},qnn=class extends Att{pluginType="ddk.setup";contributionKey="setup";rankable=!0;createConfiguration(a){return this.contribute(a,{suffix:"setup",experienceSuffix:"setup",key:"setupStep",fields:{titleSuffix:"setup",extra:{setupDescriptor:a.descriptor||a.nameCamelCase}}})}},$nn=class extends Att{pluginType="ddk.utility";contributionKey="utility";rankable=!0;createConfiguration(a){return this.contribute(a,{suffix:"util",experienceSuffix:"util",key:"utilities",fields:{titleSuffix:"utility",extra:{utilDescriptor:a.descriptor||a.nameCamelCase}}})}},Jnn=class extends Att{pluginType="ddk.nav";contributionKey="nav";rankable=!0;createConfiguration(a){return this.contribute(a,{suffix:"nav",experienceSuffix:"nav",key:"navViews",fields:{titleSuffix:"nav",extra:{navDescriptor:a.descriptor||a.nameLowerCase}}})}},Ptt=class extends Att{rankable=!0;componentName(a){return a.namePascalCase}contributionFields(){return{}}createConfiguration(a){let p=this.contribute(a,{suffix:this.contributionKey,experienceSuffix:this.contributionKey,key:this.kosJsonKey,fields:{titleSuffix:this.contributionKey,extra:{type:this.extensionType,...this.contributionFields(a)}}});for(let g of Object.values(p.experiences))g.component=this.componentName(a);return p}},jjt=class extends Ptt{getTargetDirectory(){return"dashboard"}getComponentPath(a){return`${a.appDirectory}/dashboard/${a.nameDashCase}/${this.part}/${a.nameDashCase}.tsx`}componentName(a){return`${a.namePascalCase}${this.part==="summary"?"Summary":"Detail"}`}contributionFields(a){return{dashboardKey:a.dashboardKey}}},Knn=class extends jjt{pluginType="ddk.dashboardSummary";contributionKey="dashboardSummary";kosJsonKey="dashboardSummary";extensionType="dashboard.summary";part="summary";getTemplatePath(){return"dashboard-summary"}},Xnn=class extends jjt{pluginType="ddk.dashboardDetail";contributionKey="dashboardDetail";kosJsonKey="dashboardDetail";extensionType="dashboard.detail";part="detail";getTemplatePath(){return"dashboard-detail"}},Ynn=class extends Ptt{pluginType="ddk.pumpDetail";contributionKey="dashboardPumpDetail";kosJsonKey="dashboardPumpDetail";extensionType="dashboard.detail.pump";getTargetDirectory(){return"dashboard/pumpDetail"}getTemplatePath(){return"pump-detail"}contributionFields(a){return{dashboardKey:a.dashboardKey}}},Qnn=class extends Ptt{pluginType="ddk.pumpSummary";contributionKey="dashboardPumpSummary";kosJsonKey="dashboardPumpSummary";extensionType="dashboard.summary.pump";getTargetDirectory(){return"dashboard/pumpSummary"}getTemplatePath(){return"pump-summary"}componentName(a){return`${a.namePascalCase}Summary`}contributionFields(a){return{dashboardKey:a.dashboardKey}}},Znn=class extends Ptt{pluginType="ddk.macroSummary";contributionKey="dashboardMacroSummary";kosJsonKey="dashboardMacroSummary";extensionType="dashboard.macro.summary";getTargetDirectory(){return"dashboard/macroSummary"}getTemplatePath(){return"macro-summary"}contributionFields(a){return{dashboardKey:a.dashboardKey}}},ern=class extends Ptt{pluginType="ddk.troubleAction";contributionKey="troubleAction";kosJsonKey="troubleActions";extensionType="trouble.action";getTargetDirectory(){return"trouble-action"}getTemplatePath(){return"trouble-action"}contributionFields(a){return{troubleType:a.troubleType,stateKey:a.stateKey||a.troubleType,stateValue:a.stateValue||a.troubleType}}},qAr=[Hnn,qnn,$nn,Jnn,Knn,Xnn,Ynn,Qnn,Znn,ern];function Z7n(){for(let s of qAr){let a=new s().pluginType;n8e.isValidPluginType(a)||n8e.register(a,s)}}import t3n from"node:path";var Vdt=["standard","compact"],YIt={carb:"carbonation: the carbWater and carbTank setup steps",ice:"ice: the iceSettings setup step and the ice settings tab",beveragePourTest:"the beveragePourTest utility"},trn=["manager","technician"];function $Ar({carb:s,ice:a}){return[{name:"selectCountry",preStep:!0},{name:"selectLanguage",preStep:!0},{name:"plainWater"},...s?[{name:"carbWater"},{name:"carbTank"}]:[],{name:"ns"},{name:"macroAssignment"},{name:"ingredients"},{name:"regions"},{name:"timeSettings"},{name:"dispenserProfile"},{name:"waterSettings"},...a?[{name:"iceSettings"}]:[]]}function JAr(s,{beveragePourTest:a}){let p=[{name:"touchScreenTest",options:{}},{name:"pixelQualityTest",options:{}},{name:"setup",options:{}},{name:"usbUpdate",options:{},roles:trn}],g=[{name:"reboot",options:{},roles:["manager"]},{name:"downloadLogs",options:{},roles:trn},...a?[{name:"beveragePourTest",options:{},roles:trn}]:[]];return s==="compact"?[[...p,...g]]:[p,g]}var Eue=s=>({name:s,roles:["technician"]}),Pme=(s,a=["crew","technician"])=>({name:s,roles:a});function KAr(s,{ice:a}){if(s==="compact")return[Pme("dashboard"),Pme("notifications"),{...Pme("about"),children:[Pme("software"),Pme("hardware")]},Pme("network",["technician","crew"]),Pme("utilities",["technician","manager"]),{...Eue("settings"),children:[Eue("localization"),Eue("time-settings"),Eue("water-settings"),Eue("dispenser-profile"),Eue("cui-selection"),...a?[Eue("ice-settings")]:[]]}];let p=g=>Pme(g,["technician","crew"]);return[Pme("summary"),Pme("dashboard"),Pme("notifications"),{...Pme("about"),options:{embed:!0},children:[p("dispenser-info"),p("hardware"),p("connectivity"),p("software")]},Pme("utilities",["technician","manager"]),{...Eue("settings"),options:{embed:!0},children:[Eue("regions"),Eue("dispenser-profile"),Eue("cui-selection"),Eue("water"),...a?[Eue("ice")]:[],Eue("remote-nns")]}]}function QIt({layout:s="standard",carb:a=!1,ice:p=!1,beveragePourTest:g=!1}={}){if(!Vdt.includes(s))throw new Error(`No "${s}" layout. Choose from ${Vdt.join(", ")}.`);let E={carb:a,ice:p,beveragePourTest:g};return{ncui:{setup:{steps:$Ar(E)},utilities:JAr(s,E),navigations:KAr(s,E)}}}var Wjt="ddk.ncui.descriptor";function Hdt(s){return[...Vnn(s.root).values()].map(a=>({name:a.name,kosJsonPath:t3n.join(a.root,".kos.json")})).filter(({kosJsonPath:a})=>{let p=s.read(a);return p&&JSON.parse(p).type===Wjt})}function XAr(s,a){let p=Hdt(s),g=p.find(E=>E.name===a);if(!g)throw new Error(`No descriptor project "${a}". ${p.length?`Descriptor projects: ${p.map(E=>E.name).join(", ")}.`:"Create one with kosui ddk:descriptor-project."}`);return g}var YAr=s=>(Array.isArray(s)?s:String(s??"").split(",")).map(a=>a.trim()).filter(Boolean);function nrn(s,a,{project:p,slot:g,roles:E,column:A}){let{name:I,kosJsonPath:F}=XAr(s,p),z=JSON.parse(s.read(F)),$=(z.kondra??={}).ncui??={},X=YAr(E),ee=X.length?{roles:X}:{},H;if(a==="utility"){let le=$.utilities??=[[]];if(le.flat().some(ae=>ae.name===g))return`${I} already lists utility "${g}".`;let Q=A===void 0||A===""?le.length-1:Number(A)-1;if(!Number.isInteger(Q)||Q<0||Q>le.length)throw new Error(`column must be 1 to ${le.length+1}; got "${A}"`);(le[Q]??=[]).push({name:g,options:{},...ee}),H=`Listed utility "${g}" in ${I} (column ${Q+1}).`}else if(a==="setup"){let le=($.setup??={}).steps??=[];if(le.some(Q=>Q.name===g))return`${I} already lists setup step "${g}".`;le.push({name:g}),H=`Listed setup step "${g}" last in ${I}; the setup flow runs steps in that order.`}else{let le=g.split("."),Q=$.navigations??=[],ae;for(let ke of le.slice(0,-1)){if(ae=Q.find(Ne=>Ne.name===ke),!ae)throw new Error(`${I} has no navigation "${le.slice(0,le.indexOf(ke)+1).join(".")}" to add "${g}" under`);Q=ae.children??=[]}let Fe=le[le.length-1];if(Q.some(ke=>ke.name===Fe))return`${I} already lists navigation "${g}".`;let Le=X.length?X:ae?.roles;Q.push({name:Fe,...Le?{roles:Le}:{}}),H=`Listed navigation "${g}" in ${I}.`}return s.write(F,JSON.stringify(z,null,2)+`
|
|
48535
|
-
`),H}function e3n(s,a,p){if(a==="utility")return(s.utilities??[]).flat().some(E=>E.name===p);if(a==="setup")return(s.setup?.steps??[]).some(E=>E.name===p);let g=s.navigations??[];for(let E of p.split(".")){let A=g.find(I=>I.name===E);if(!A)return!1;g=A.children??[]}return!0}function zjt(s,a,p){let g=Hdt(s);return g.length?g.some(({kosJsonPath:E})=>e3n(JSON.parse(s.read(E)).kondra?.ncui??{},a,p)):Vdt.some(E=>[!1,!0].some(A=>e3n(QIt({layout:E,...Object.fromEntries(Object.keys(YIt).map(I=>[I,A]))}).ncui,a,p)))}var QAr=[["utilities","utility","utilDescriptor"],["setupStep","setup","setupDescriptor"],["navViews","nav","navDescriptor"]];function n3n(s,{project:a,descriptorProject:p}){let g=RSe(s.root,a)?.root,E=g&&s.read(t3n.join(g,".kos.json"));if(!E)throw new Error(`No plugin project "${a}" with a .kos.json`);let A=JSON.parse(E).kos?.ui?.plugin?.contributes??{},I=[];for(let[F,z,$]of QAr)for(let X of A[F]??[])if(X[$])try{I.push(nrn(s,z,{project:p,slot:X[$]}))}catch(ee){I.push(`${X.id}: ${ee.message}`)}return{label:"DDK descriptor entries",notes:I.length?I:[`${a} contributes no utility, setup step or navigation slot.`]}}var r3n={cui:{pluginType:"ddk.cui",label:"DDK CUI Configuration",required:"cuiDescriptor",description:"Create a CUI configuration; --descriptor is the CUI's appId from /api/app/kosdev.ddk/cui"},setup:{pluginType:"ddk.setup",label:"DDK Setup Step",overridable:"setupDescriptor",listedIn:"kondra.ncui.setup.steps",descriptorType:"setup",description:"Create a setup step; --descriptor is its kondra.ncui.setup.steps entry (default: from the name)"},utility:{pluginType:"ddk.utility",label:"DDK Utility",overridable:"utilDescriptor",listedIn:"kondra.ncui.utilities",descriptorType:"utility",description:"Create a utility; --descriptor is its kondra.ncui.utilities entry (default: from the name)"},nav:{pluginType:"ddk.nav",label:"DDK Navigation View",overridable:"navDescriptor",listedIn:"kondra.ncui.navigations",descriptorType:"nav",slotRequired:!0,description:"Create a navigation view; --descriptor is its kondra.ncui.navigations entry, e.g. settings.water for a Settings tab"}},ZAr={"ddk.cui":{proceed:"Proceed"},"ddk.setup":{proceed:"Proceed"},"ddk.utility":{
|
|
48535
|
+
`),H}function e3n(s,a,p){if(a==="utility")return(s.utilities??[]).flat().some(E=>E.name===p);if(a==="setup")return(s.setup?.steps??[]).some(E=>E.name===p);let g=s.navigations??[];for(let E of p.split(".")){let A=g.find(I=>I.name===E);if(!A)return!1;g=A.children??[]}return!0}function zjt(s,a,p){let g=Hdt(s);return g.length?g.some(({kosJsonPath:E})=>e3n(JSON.parse(s.read(E)).kondra?.ncui??{},a,p)):Vdt.some(E=>[!1,!0].some(A=>e3n(QIt({layout:E,...Object.fromEntries(Object.keys(YIt).map(I=>[I,A]))}).ncui,a,p)))}var QAr=[["utilities","utility","utilDescriptor"],["setupStep","setup","setupDescriptor"],["navViews","nav","navDescriptor"]];function n3n(s,{project:a,descriptorProject:p}){let g=RSe(s.root,a)?.root,E=g&&s.read(t3n.join(g,".kos.json"));if(!E)throw new Error(`No plugin project "${a}" with a .kos.json`);let A=JSON.parse(E).kos?.ui?.plugin?.contributes??{},I=[];for(let[F,z,$]of QAr)for(let X of A[F]??[])if(X[$])try{I.push(nrn(s,z,{project:p,slot:X[$]}))}catch(ee){I.push(`${X.id}: ${ee.message}`)}return{label:"DDK descriptor entries",notes:I.length?I:[`${a} contributes no utility, setup step or navigation slot.`]}}var r3n={cui:{pluginType:"ddk.cui",label:"DDK CUI Configuration",required:"cuiDescriptor",description:"Create a CUI configuration; --descriptor is the CUI's appId from /api/app/kosdev.ddk/cui"},setup:{pluginType:"ddk.setup",label:"DDK Setup Step",overridable:"setupDescriptor",listedIn:"kondra.ncui.setup.steps",descriptorType:"setup",description:"Create a setup step; --descriptor is its kondra.ncui.setup.steps entry (default: from the name)"},utility:{pluginType:"ddk.utility",label:"DDK Utility",overridable:"utilDescriptor",listedIn:"kondra.ncui.utilities",descriptorType:"utility",layouts:["maximized","fullscreen"],description:"Create a utility in a modal; --layout maximized (default) or fullscreen; --descriptor is its kondra.ncui.utilities entry (default: from the name)"},nav:{pluginType:"ddk.nav",label:"DDK Navigation View",overridable:"navDescriptor",listedIn:"kondra.ncui.navigations",descriptorType:"nav",slotRequired:!0,description:"Create a navigation view; --descriptor is its kondra.ncui.navigations entry, e.g. settings.water for a Settings tab"}},ZAr={"ddk.cui":{proceed:"Proceed"},"ddk.setup":{proceed:"Proceed"},"ddk.utility":{back:"Back",close:"Close",done:"Done"},"ddk.dashboardDetail":{close:"Close"},"ddk.troubleAction":{resolve:"Resolve"}};function ePr(s,a,p){let g=ZAr[a],E=RSe(s.root,p)?.sourceRoot;if(!g||!E)return;let A=i3n.join(E,"assets","locales","en",`${p}.json`);s.exists(A)&&Bjt(s,A,I=>({...g,...I}))}function qdt(s,a,p){let g=RSe(s.root,a)?.root,E=g&&s.read(i3n.join(g,".kos.json"));if(!E)return;let A=JSON.parse(E).kos?.ui?.plugin?.contributes?.experiences??{},I=KIt({name:p}).namePascalCase,F=Object.values(A).find(z=>[I,`${I}Summary`,`${I}Detail`].includes(z.component));if(F)throw new Error(`${a} already has a component ${F.component} (${F.location}); components are exposed by name, so choose another --name (kosui ddk:descriptor-entries lists an existing contribution's slot in a descriptor project)`)}function D9e(s,a,{name:p,project:g,...E}){Z7n(),Y7n(s,XIt,{name:p,appProject:g,type:"components",pluginType:a,useEmotionCss:!1,appDirectory:"",modelDirectory:"",...E}),ePr(s,a,g)}function ktt(s,a){if(!s)throw new Error(`${a} is required`)}var $dt=s=>s===void 0?{}:{rank:s};function a3n(s,{type:a,name:p,project:g,descriptor:E,override:A,rank:I,descriptorProject:F,roles:z,column:$,layout:X}){let ee=r3n[a];if(!ee)throw new Error(`Unknown contribution type "${a}". Choose from ${Object.keys(r3n).join(", ")}.`);let H=A||I!==void 0&&I!=="";if(!ee.overridable&&H)throw new Error(`${a} contributions are not ranked; --override and --rank do not apply`);if(ee.required&&ktt(E,`descriptor (${ee.required})`),X&&!ee.layouts)throw new Error(`${a} contributions have no layout; --layout does not apply`);if(X&&!ee.layouts.includes(X))throw new Error(`Unknown layout "${X}". Choose from ${ee.layouts.join(", ")}.`);let le=ee.overridable?Ttt(a,{override:A,rank:I,explicit:{[ee.overridable]:E}}):{fields:{},notes:[]},Q=le.fields[ee.overridable]??E;if(ee.slotRequired&&!Q&&ktt(Q,`descriptor (${ee.overridable}, a kondra.ncui.navigations path such as settings.water)`),qdt(s,g,p),F&&A)throw new Error("--override fills a slot the descriptor already lists; --descriptorProject does not apply");let ae=ee.listedIn&&!Q?[`${ee.overridable} "${KIt({name:p}).nameCamelCase}" comes from the name (--descriptor sets it).`]:[];D9e(s,ee.pluginType,{name:p,project:g,...Q?{descriptor:Q}:{},...$dt(le.rank),...ee.layouts?{layout:X||ee.layouts[0]}:{}});let Fe=ee.descriptorType?tPr(s,ee,{slot:Q||KIt({name:p}).nameCamelCase,override:A,descriptorProject:F,roles:z,column:$}):[];return{label:ee.label,notes:[...le.notes,...ae,...Fe]}}function tPr(s,a,{slot:p,override:g,descriptorProject:E,roles:A,column:I}){if(g)return[];if(E)return[nrn(s,a.descriptorType,{project:E,slot:p,roles:A,column:I})];if(zjt(s,a.descriptorType,p))return[];let z=Hdt(s).map($=>$.name);return[z.length?`No descriptor project lists ${a.overridable} "${p}"; add it with --descriptorProject ${z[0]}.`:`The NCUI shows "${p}" only if its descriptor (${a.listedIn}) lists it: create a descriptor project with kosui ddk:descriptor-project and pass --descriptorProject, or the system app's descriptor must list it.`]}function o3n(s,{name:a,project:p,dashboardKey:g,detail:E=!0,override:A,rank:I}){qdt(s,p,a);let F=Ttt("dashboard-card",{override:A,rank:I,explicit:{dashboardKey:g}}),z=F.fields.dashboardKey??g;ktt(z,"dashboardKey");let $={name:a,project:p,dashboardKey:z,...$dt(F.rank)};return D9e(s,"ddk.dashboardSummary",$),E&&D9e(s,"ddk.dashboardDetail",$),{label:E?"DDK Dashboard Card":"DDK Dashboard Summary",notes:[`The dashboard draws one card per active model at assembly.${z} (or the FreestyleAssembly companion's ${z}); no such model, no card.`,...E?["The detail opens when a technician selects the card."]:[],...F.notes,...Bnn("dashboard-card",{override:A,rank:F.rank,slot:{dashboardKey:z},written:E?["dashboardSummary","dashboardDetail"]:["dashboardSummary"]})]}}function s3n(s,{name:a,project:p,dashboardKey:g,override:E,rank:A}){qdt(s,p,a);let I=Ttt("pump-detail",{override:E,rank:A,explicit:{dashboardKey:g}}),F=I.fields.dashboardKey??g;return ktt(F,"dashboardKey"),D9e(s,"ddk.pumpDetail",{name:a,project:p,dashboardKey:F,...$dt(I.rank)}),{label:"DDK Pump Detail",notes:[`Shown in the holder modal when the dashboard key factory returns "${F}" for the holder (default: its first pump's type), unless the holder has its own content.`,...I.notes]}}function c3n(s,{name:a,project:p,dashboardKey:g,detail:E=!0,override:A,rank:I}){qdt(s,p,a);let F=Ttt("pump-card",{override:A,rank:I,explicit:{dashboardKey:g}}),z=F.fields.dashboardKey??g;ktt(z,"dashboardKey");let $={name:a,project:p,dashboardKey:z,...$dt(F.rank)};return D9e(s,"ddk.pumpSummary",$),E&&D9e(s,"ddk.pumpDetail",$),{label:E?"DDK Pump Card":"DDK Pump Summary",notes:[`Used for holders whose dashboard key factory returns "${z}" (default: the holder's first pump type, which the backend assembly assigns); other holders keep the default card body.`,...E?["The detail shows in the holder modal a technician opens from the card."]:[],...F.notes,...Bnn("pump-card",{override:A,rank:F.rank,slot:{dashboardKey:z},written:E?["dashboardPumpSummary","dashboardPumpDetail"]:["dashboardPumpSummary"]})]}}function l3n(s,{name:a,project:p,dashboardKey:g,override:E,rank:A}){qdt(s,p,a);let I=Ttt("macro-summary",{override:E,rank:A,explicit:{dashboardKey:g}}),F=I.fields.dashboardKey??g;return ktt(F,"dashboardKey"),D9e(s,"ddk.macroSummary",{name:a,project:p,dashboardKey:F,...$dt(I.rank)}),{label:"DDK Macro Summary",notes:[`Matched to a macro holder by holder.name "${F}" first, then by the dashboard key factory.`,...I.notes]}}function u3n(s,{name:a,project:p,troubleType:g,stateKey:E,stateValue:A,override:I,rank:F}){qdt(s,p,a);let z=Ttt("trouble-action",{override:I,rank:F,explicit:{troubleType:g,stateKey:E,stateValue:A}}),$=z.fields.troubleType??g;return ktt($,"troubleType"),D9e(s,"ddk.troubleAction",{name:a,project:p,troubleType:$,stateKey:z.fields.stateKey??(E||$),stateValue:z.fields.stateValue??(A||$),...$dt(z.rank)}),{label:"DDK Trouble Action",notes:[`troubleType "${$}" must be the exact type the device raises; the experience shows while one is active and goes away once it is resolved.`,...z.notes]}}import{spawnSync as nPr}from"node:child_process";import i8e from"node:fs";import Hne from"node:path";var rPr="~3.1.0",p3n="kosdev.ddk",iPr=["@kosdev-code/kos-ddk","@kosdev-code/kos-ddk-components","@kosdev-code/kos-ddk-model-components","@kosdev-code/kos-ddk-models","@kosdev-code/kos-ddk-styles","@kosdev-code/kos-ddk-story-containers"],aPr={cui:[],utilities:[]},Jdt=s=>JSON.parse(i8e.readFileSync(s,"utf-8")),Gjt=(s,a)=>i8e.writeFileSync(s,JSON.stringify(a,null,2)+`
|
|
48536
48536
|
`);function f3n(s){let a=Hne.join(XIt,`${s}-project`);return i8e.readdirSync(a,{recursive:!0,withFileTypes:!0}).filter(p=>p.isFile()).map(p=>Hne.relative(a,Hne.join(p.parentPath,p.name)).replace(/\.template$/,"")).sort()}function _3n(s,a){let p=Hne.join(XIt,`${s}-project`);for(let g of f3n(s)){let E=Hne.join(a,g);i8e.mkdirSync(Hne.dirname(E),{recursive:!0}),i8e.copyFileSync(Hne.join(p,`${g}.template`),E)}}function oPr(s,a){_3n("plugin",a);let p=Hne.join(a,".kos.json"),g=Jdt(p),E=g.kos.ui.plugin;E.contributes={...aPr,...E.contributes},g.test={...g.test,plugin:{...g.test?.plugin,context:p3n}},Gjt(p,g);let A=Hne.join(s,"package.json"),I=Jdt(A),F={...I.dependencies,...I.devDependencies},z=iPr.filter($=>!F[$]);if(z.length){I.dependencies={...I.dependencies};for(let $ of z)I.dependencies[$]=rPr;Gjt(A,I)}}function sPr(s,a){_3n("theme",a),i8e.rmSync(Hne.join(a,"theme","assets",".gitkeep"),{force:!0})}function cPr(s,a,{ncui:p}={}){let g=Hne.join(a,".kos.json"),E=Jdt(g);E.type=Wjt,E.kondra=QIt(p),Gjt(g,E)}var m3n={plugin:{generator:"@kosdev-code/kos-nx-plugin:kos-plugin-project",uiType:"ddk.ncui.plugin",overlay:oPr},theme:{generator:"@kosdev-code/kos-nx-plugin:kos-theme-project",uiType:"ddk.ncui.theme",overlay:sPr},descriptor:{generator:"@kosdev-code/kos-nx-plugin:kos-content-project",overlay:cPr}};function lPr(s,a,p,g={}){m3n[s].overlay(a,p,g)}function d3n(s){let a=Jdt(Hne.join(s,"package.json"));return{...a.dependencies,...a.devDependencies}}var h3n=s=>Hne.join(s,".kos.json");function uPr(s){let a=h3n(s);return i8e.existsSync(a)?Jdt(a).development?.hosts??[]:[]}function dPr(s,a){return a||uPr(s).find(p=>p.pluginContext===p3n)?.name}function pPr(s,a){let p=h3n(s);if(!i8e.existsSync(p))return;let g=Jdt(p),E=!1;for(let A of g.development?.hosts??[]){let I=(A.plugins??[]).filter(F=>F.project!==a);I.length!==(A.plugins??[]).length&&(A.plugins=I,E=!0)}E&&Gjt(p,g)}function g3n(s,{workspaceRoot:a,name:p,directory:g,host:E,ncui:A={},dryRun:I=!1,stdio:F="pipe"}){let z=m3n[s];s==="descriptor"&&QIt(A);let $=d3n(a),X=s==="plugin"?dPr(a,E):void 0,ee=nPr("npx",["nx","generate",z.generator,`--name=${p}`,...z.uiType?[`--uiType=${z.uiType}`]:[],...g?[`--directory=${g}`]:[],...X?[`--host=${X}`]:[],"--no-interactive",...I?["--dry-run"]:[]],{cwd:a,encoding:"utf-8",stdio:F,shell:process.platform==="win32"});if(ee.status!==0)throw new Error(`nx generate exited with ${ee.status}
|
|
48537
|
-
${ee.stderr??""}`);let H=ee.stdout?.trim()??"";if(I)return{output:H,ddkFiles:s==="descriptor"?[`.kos.json: type ${Wjt}, kondra.ncui for the ${A.layout??"standard"} layout`]:f3n(s)};let le=RSe(a,p);if(!le)throw new Error(`nx generate did not create project ${p}`);s==="plugin"&&!X&&pPr(a,p),lPr(s,a,Hne.join(a,le.root),{ncui:A});let Q=Hne.join(a,"node_modules"),ae=Object.keys(d3n(a)).filter(Fe=>!$[Fe]&&!i8e.existsSync(Hne.join(Q,Fe)));return{output:H,root:le.root,toInstall:ae}}import{existsSync as irn,readFileSync as Ujt,readdirSync as gPr}from"node:fs";import C9e from"node:path";import{existsSync as y3n,readFileSync as fPr,readdirSync as _Pr}from"node:fs";import OSe from"node:path";var mPr="ddk.ncui.plugin",hPr=new Set(["node_modules","dist","tmp",".git",".nx"]),pUr=process.env.DEV_LOG_DIR||"/tmp/kos-dev-logs";var rrn=s=>JSON.parse(fPr(s,"utf-8"));function v3n(s,a){for(let p of _Pr(s,{withFileTypes:!0}))p.isDirectory()&&!hPr.has(p.name)?v3n(OSe.join(s,p.name),a):p.name===".kos.json"&&s!==a.root&&a.files.push(OSe.join(s,p.name));return a.files}function b3n(s){let a=y3n(OSe.join(s,".kos.json"))?rrn(OSe.join(s,".kos.json")):{},p=new Map((a.development?.hosts??[]).flatMap(g=>g.plugins??[]).map(g=>[g.project,g.alias]));return v3n(s,{root:s,files:[]}).filter(g=>rrn(g).type===mPr).map(g=>{let E=OSe.join(OSe.dirname(g),"project.json"),A=y3n(E)?rrn(E):{},I=A.name??OSe.basename(OSe.dirname(g));return{project:I,dir:OSe.relative(s,OSe.dirname(g)).split(OSe.sep).join("/"),alias:p.get(I),port:A.targets?.serve?.options?.port}}).sort((g,E)=>g.project.localeCompare(E.project))}var yPr=s=>JSON.parse(Ujt(s,"utf-8")),vPr=Object.fromEntries(Object.values(S9e).flatMap(({contributionKeys:s,keys:a})=>s.map(p=>[p,a])));function x3n(s,a){let p=b3n(s),g=p.find(I=>I.project===a||I.alias===a);if(!g)throw new Error(`No DDK plugin project "${a}". DDK plugin projects: ${p.map(I=>I.project).join(", ")||"none"}.`);let E=C9e.join(s,g.dir),A=yPr(C9e.join(E,".kos.json"));return{...g,absDir:E,block:A.kos?.ui?.plugin??{}}}var bPr=(s,a)=>Object.fromEntries((vPr[s]??[]).filter(p=>a[p]!==void 0).map(p=>[p,a[p]])),xPr=(s,a)=>{let p=Object.keys(s);return p.length>0&&p.length===Object.keys(a).length&&p.every(g=>s[g]===a[g])},SPr=(s,a)=>typeof s=="number"&&(typeof a!="number"||s<a);function arn(s,a){let p=x3n(s,a),{extensionPoints:g}=Ett(),E=Gdt(Udt()),A=p.block.contributes??{},I=A.experiences??{},F=[];for(let[z,$]of Object.entries(A)){if(!Array.isArray($))continue;let X=g.find(ee=>ee.contributionKey===z);for(let ee of $){let H=bPr(z,ee),le=E.filter(ae=>ae.plugin!==p.project&&ae.contributionKey===z&&xPr(H,ae.keys)),Q=I[ee.experienceId];F.push({contributionKey:z,...X?{extensionPoint:X.id}:{},id:ee.id,...Object.keys(H).length?{slot:H}:{},...typeof ee.rank=="number"?{rank:ee.rank}:{},...Q?{component:Q.component,location:Q.location}:{},...le.length?{sharesSlotWith:le.map(ae=>({id:ae.id,...typeof ae.rank=="number"?{rank:ae.rank}:{},wins:SPr(ee.rank,ae.rank)}))}:{}})}}return{project:p.project,dir:p.dir,pluginId:p.block.id,contributions:F}}function S3n(s){return irn(s)?gPr(s,{withFileTypes:!0}).flatMap(a=>{let p=C9e.join(s,a.name);return a.isDirectory()?a.name==="node_modules"?[]:S3n(p):/\.(tsx?|css)$/.test(a.name)?[p]:[]}):[]}var TPr=(s,a)=>/export\s+default\b/.test(s)||new RegExp(`export\\s+(const|let|function|class)\\s+${a}\\b`).test(s)||new RegExp(`export\\s*\\{[^}]*\\b${a}\\b[^}]*\\}`).test(s);function EPr(s,a){return a===void 0||a===""?s.required?`missing required ${s.name}`:null:s.type.startsWith('"')?s.type.split(" | ").map(g=>JSON.parse(g)).includes(a)?null:`${s.name} must be ${s.type}`:["string","number","boolean"].includes(s.type)&&typeof a!==s.type?`${s.name} must be a ${s.type}`:null}function T3n(s,a){let p=x3n(s,a),{extensionPoints:g}=Ett(),E=arn(s,a),A=p.block.contributes??{},I=A.experiences??{},F=[],z=[],$=new Map;for(let[Q,ae]of Object.entries(A)){if(!Array.isArray(ae))continue;let Fe=g.find(Le=>Le.contributionKey===Q);for(let Le of ae){let ke=`contributes.${Q} ${Le.id??"(no id)"}`;Le.id?$.has(Le.id)?F.push(`${ke}: id also used in contributes.${$.get(Le.id)}`):$.set(Le.id,Q):F.push(`${ke}: missing id`);for(let Ne of Fe?.fields??[]){if(Ne.name==="rank")continue;let Ce=EPr(Ne,Le[Ne.name]);Ce&&F.push(`${ke}: ${Ce} (${Fe.id})`)}if(Le.rank!==void 0&&(!Number.isInteger(Le.rank)||Le.rank<0||Le.rank>HIt?F.push(`${ke}: rank must be an integer from 0 to ${HIt}`):Fe&&!Fe.isRankable&&z.push(`${ke}: ${Fe.id} is not ranked, so rank has no effect`)),Le.experienceId!==void 0||Fe?.hasView){let Ne=I[Le.experienceId];if(!Ne)F.push(`${ke}: experience ${Le.experienceId??"(none)"} is not in contributes.experiences`);else{let Ce=C9e.join(p.absDir,Ne.location??"");!Ne.location||!irn(Ce)?F.push(`${ke}: component file ${Ne.location} does not exist`):Ne.component&&!TPr(Ujt(Ce,"utf-8"),Ne.component)&&F.push(`${ke}: ${Ne.location} has no default export and does not export ${Ne.component}`)}}}}let X={root:s,read:Q=>{let ae=C9e.join(s,Q);return irn(ae)?Ujt(ae,"utf-8"):null}},ee=Hdt(X).map(Q=>Q.name);for(let[Q,ae,Fe]of[["utilities","utility","utilDescriptor"],["setupStep","setup","setupDescriptor"],["navViews","nav","navDescriptor"]])for(let Le of A[Q]??[]){let ke=Le[Fe];!ke||zjt(X,ae,ke)||z.push(`contributes.${Q} ${Le.id}: ${Fe} "${ke}" is not in ${ee.length?`descriptor project ${ee.join(", ")}`:"the standard NCUI descriptor (no descriptor project in the workspace)"}, so the NCUI does not show it${ee.length?`; list it with kosui ddk:descriptor-entries --project ${a} --descriptorProject ${ee[0]}`:""}`)}let H=new Map;for(let Q of E.contributions.filter(ae=>ae.slot)){let ae=`${Q.contributionKey} ${JSON.stringify(Q.slot)}`,Fe=H.get(ae);if(Fe&&Fe.rank===Q.rank&&z.push(`contributes.${Q.contributionKey} ${Q.id}: same slot and rank as ${Fe.id}; which renders is not defined`),H.set(ae,Q),!Stt().sources.includes(p.project))for(let Le of Q.sharesSlotWith??[])Le.wins||z.push(`contributes.${Q.contributionKey} ${Q.id}: shares a slot with ${Le.id} (${typeof Le.rank=="number"?`rank ${Le.rank}`:"unranked"}) without a winning rank, so it does not replace it`)}let le=C9e.join(p.absDir,"src");for(let Q of S3n(le)){let ae=Ujt(Q,"utf-8"),Fe=C9e.relative(p.absDir,Q).split(C9e.sep).join("/"),Le=[...new Set([...ae.matchAll(/(--ddk-[\w-]+)\s*:/g)].map(ke=>ke[1]))];Le.length&&F.push(`${Fe}: sets DDK tokens (${Le.join(", ")}); plugins compose DDK components and do not set tokens`)}return{project:p.project,ok:F.length===0,errors:F,warnings:z}}var DPr={type:"string",description:"Component name in kebab-case, e.g. fuel-level."},Hjt={type:"string",description:"DDK plugin project to write into."},lrn={type:"boolean",description:"Default true: return the would-write files. false writes."},Kdt={type:"string",description:"Id of a standard contribution to replace (from list_ddk_contributions). Takes its slot with a winning rank."},Xdt={type:"integer",description:"0-1000; lower wins. Default with override: 100, or one better than a ranked target."},orn={type:"string",description:"Assembly property whose models get the contribution, e.g. carbTank. Taken from override when given."},Ydt={name:DPr,project:Hjt,dryRun:lrn,...zdt};async function wtt(s,a){try{let p=VIt(s),g=await F7n({dryRun:s.dryRun!==!1,cwd:p,generate:a});return t8e(g.dryRun?{...g,hint:"Re-run with dryRun:false to write."}:g)}catch(p){return wAe(p.message)}}function Vjt(s,a,p,g={},E=[]){return{name:s,description:p,inputSchema:{type:"object",properties:{...Ydt,...g},required:["name","project",...E]},handler:A=>wtt(A,I=>a3n(I,{type:a,name:A.name,project:A.project,descriptor:A.descriptor,override:A.override,rank:A.rank,descriptorProject:A.descriptorProject,roles:A.roles,column:A.column}))}}var srn=(s,a,p={})=>({descriptor:{type:"string",description:`${s}; shown only if the NCUI descriptor lists it (${a}). Default: from the name.`},descriptorProject:{type:"string",description:"NCUI descriptor project to list a new slot in (scaffold_ddk_descriptor_project)."},roles:{type:"string",description:"With descriptorProject: comma-separated roles that see it."},...p,override:Kdt,rank:Xdt});function crn(s,a,p){return{name:s,description:p,inputSchema:{type:"object",properties:{name:{type:"string",description:`${{plugin:"Plugin",theme:"Theme",descriptor:"Descriptor"}[a]} project name in kebab-case.`},...a==="descriptor"?{layout:{type:"string",enum:Vdt,description:"NCUI layout. Default: standard."},...Object.fromEntries(Object.entries(YIt).map(([g,E])=>[g,{type:"boolean",description:`Include ${E}.`}]))}:{},...a==="plugin"?{directory:{type:"string",description:"Parent folder of the project. Default: plugins."},host:{type:"string",description:"Workspace host to register with. Default: the host with the kosdev.ddk plugin context, else none."}}:{},dryRun:lrn,...zdt},required:["name"]},handler:async g=>{try{let E=g.dryRun!==!1,A=g3n(a,{workspaceRoot:VIt(g),name:g.name,directory:g.directory,host:g.host,ncui:{layout:g.layout,...Object.fromEntries(Object.keys(YIt).map(I=>[I,!!g[I]]))},dryRun:E});return t8e({dryRun:E,...A})}catch(E){return wAe(E.message)}}}}var E3n=[crn("scaffold_ddk_plugin_project","plugin","Create a DDK plugin project: module federation serve target, DDK Storybook, .kos.json. dryRun lists the files."),crn("scaffold_ddk_theme_project","theme","Create a DDK theme project; its theme-overlay.css overrides the DDK tokens. dryRun lists the files."),crn("scaffold_ddk_descriptor_project","descriptor","Create an NCUI descriptor project (ddk.ncui.descriptor KAB) for a layout and options; list new utility, setup or nav slots in it. dryRun lists the files."),Vjt("add_utility","utility","Add a utility (utilities contribution) with its component, story and i18n title.",srn("utilDescriptor","kondra.ncui.utilities",{column:{type:"integer",description:"With descriptorProject: utilities column, 1-based. Default: the last."}})),Vjt("add_setup_step","setup","Add a setup step (setupStep contribution) with its component, story and i18n title.",srn("setupDescriptor","kondra.ncui.setup.steps")),Vjt("add_nav_view","nav","Add a navigation view (navViews contribution) with its component, story and i18n title.",srn("navDescriptor","kondra.ncui.navigations",{descriptor:{type:"string",description:"navDescriptor, a kondra.ncui.navigations path such as settings.water. Required unless override."}})),Vjt("add_cui_config","cui","Add a CUI configuration (cui contribution) with its component and story.",{descriptor:{type:"string",description:"cuiDescriptor: the CUI's appId from /api/app/kosdev.ddk/cui."}},["descriptor"]),{name:"add_dashboard_card",description:"Add a dashboard summary card and, by default, the detail it opens; both share dashboardKey and rank.",inputSchema:{type:"object",properties:{...Ydt,dashboardKey:orn,detail:{type:"boolean",description:"Also add the detail the card opens. Default true."},override:Kdt,rank:Xdt},required:["name","project"]},handler:s=>wtt(s,a=>o3n(a,{name:s.name,project:s.project,dashboardKey:s.dashboardKey,detail:s.detail!==!1,override:s.override,rank:s.rank}))},{name:"add_pump_detail",description:"Add the pump detail shown in the holder modal for holders with dashboardKey.",inputSchema:{type:"object",properties:{...Ydt,dashboardKey:orn,override:Kdt,rank:Xdt},required:["name","project"]},handler:s=>wtt(s,a=>s3n(a,{name:s.name,project:s.project,dashboardKey:s.dashboardKey,override:s.override,rank:s.rank}))},{name:"add_pump_card",description:"Add a pump card for a pump type: the holder card body and, by default, the pump detail; both share dashboardKey and rank.",inputSchema:{type:"object",properties:{...Ydt,dashboardKey:{type:"string",description:"The pump type the backend assembly assigns (the holder's first pump), e.g. cgp. Taken from override when given."},detail:{type:"boolean",description:"Also add the pump detail. Default true."},override:Kdt,rank:Xdt},required:["name","project"]},handler:s=>wtt(s,a=>c3n(a,{name:s.name,project:s.project,dashboardKey:s.dashboardKey,detail:s.detail!==!1,override:s.override,rank:s.rank}))},{name:"add_macro_summary",description:"Add the macro holder card body for dashboardKey.",inputSchema:{type:"object",properties:{...Ydt,dashboardKey:orn,override:Kdt,rank:Xdt},required:["name","project"]},handler:s=>wtt(s,a=>l3n(a,{name:s.name,project:s.project,dashboardKey:s.dashboardKey,override:s.override,rank:s.rank}))},{name:"add_trouble_action",description:"Add the experience shown while the device has an active trouble of troubleType.",inputSchema:{type:"object",properties:{...Ydt,troubleType:{type:"string",description:"Exact trouble type the device raises. Taken from override when given."},stateKey:{type:"string",description:"Contributions sharing a stateKey share one experience. Default: troubleType."},stateValue:{type:"string",description:"Default: troubleType."},override:Kdt,rank:Xdt},required:["name","project"]},handler:s=>wtt(s,a=>u3n(a,{name:s.name,project:s.project,troubleType:s.troubleType,stateKey:s.stateKey,stateValue:s.stateValue,override:s.override,rank:s.rank}))},{name:"describe_ddk_plugin",description:"A DDK plugin project's contributions from its .kos.json: extension point, slot, rank, component, and which standard contributions it shares a slot with and beats.",inputSchema:{type:"object",properties:{project:Hjt,...zdt},required:["project"]},handler:async s=>{try{return t8e(arn(VIt(s),s.project))}catch(a){return wAe(a.message)}}},{name:"add_descriptor_entries",description:"List a plugin's existing utility, setup step and navigation slots in an NCUI descriptor project.",inputSchema:{type:"object",properties:{project:Hjt,descriptorProject:{type:"string",description:"NCUI descriptor project to list them in."},dryRun:lrn,...zdt},required:["project","descriptorProject"]},handler:s=>wtt(s,a=>n3n(a,{project:s.project,descriptorProject:s.descriptorProject}))},{name:"validate_ddk_plugin",description:"Check a DDK plugin project: contribution fields against each extension point's schema, ranks, experiences and their component files, overrides that do not win, and tokens set in plugin code.",inputSchema:{type:"object",properties:{project:Hjt,...zdt},required:["project"]},handler:async s=>{try{return t8e(T3n(VIt(s),s.project))}catch(a){return wAe(a.message)}}},{name:"find_ddk_capability",description:"Map a plain-language need (e.g. replace the carb tank card) to the DDK extension points and components that cover it, with the resource and tool for each.",inputSchema:{type:"object",properties:{need:{type:"string",description:"What the plugin should do."}},required:["need"]},handler:async s=>{try{return t8e(V7n(s.need))}catch(a){return wAe(a.message)}}},{name:"list_ddk_components",description:"List the DDK components and styled parts plugins render, by name and source file.",inputSchema:{type:"object",properties:{library:{type:"string",enum:Wnn,description:"Only this library."},query:{type:"string",description:"Words every match has in its name or path, e.g. dashboard card."}}},handler:async s=>{try{return t8e({components:G7n(s)})}catch(a){return wAe(a.message)}}},{name:"describe_ddk_component",description:"One DDK component from its source: props, the components and hooks it uses, and each token it reads with its value per theme.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Export name, e.g. HolderDashboardCard."},library:{type:"string",enum:Wnn,description:"Library, when both export the name."}},required:["name"]},handler:async s=>{try{let a=U7n(s.name,s.library);return a?{content:[{type:"text",text:a}]}:wAe(`No DDK component named ${s.name}; list_ddk_components lists them.`)}catch(a){return wAe(a.message)}}},{name:"list_ddk_contributions",description:"List the standard DDK contributions an override can replace, with each one's slot and rank, and the contribution keys each point writes. A pump detail is listed under both pump-detail and pump-card.",inputSchema:{type:"object",properties:{point:{type:"string",enum:Object.keys(S9e),description:"Only this command's contributions."}}},handler:async s=>{try{return t8e({points:W7n(s.point||void 0),contributions:Udt(s.point||void 0)})}catch(a){return wAe(a.message)}}}];await M7n(process.argv.slice(2),{name:"kos-ddk",version:B7n.version,tools:E3n,resources:z7n()});
|
|
48537
|
+
${ee.stderr??""}`);let H=ee.stdout?.trim()??"";if(I)return{output:H,ddkFiles:s==="descriptor"?[`.kos.json: type ${Wjt}, kondra.ncui for the ${A.layout??"standard"} layout`]:f3n(s)};let le=RSe(a,p);if(!le)throw new Error(`nx generate did not create project ${p}`);s==="plugin"&&!X&&pPr(a,p),lPr(s,a,Hne.join(a,le.root),{ncui:A});let Q=Hne.join(a,"node_modules"),ae=Object.keys(d3n(a)).filter(Fe=>!$[Fe]&&!i8e.existsSync(Hne.join(Q,Fe)));return{output:H,root:le.root,toInstall:ae}}import{existsSync as irn,readFileSync as Ujt,readdirSync as gPr}from"node:fs";import C9e from"node:path";import{existsSync as y3n,readFileSync as fPr,readdirSync as _Pr}from"node:fs";import OSe from"node:path";var mPr="ddk.ncui.plugin",hPr=new Set(["node_modules","dist","tmp",".git",".nx"]),pUr=process.env.DEV_LOG_DIR||"/tmp/kos-dev-logs";var rrn=s=>JSON.parse(fPr(s,"utf-8"));function v3n(s,a){for(let p of _Pr(s,{withFileTypes:!0}))p.isDirectory()&&!hPr.has(p.name)?v3n(OSe.join(s,p.name),a):p.name===".kos.json"&&s!==a.root&&a.files.push(OSe.join(s,p.name));return a.files}function b3n(s){let a=y3n(OSe.join(s,".kos.json"))?rrn(OSe.join(s,".kos.json")):{},p=new Map((a.development?.hosts??[]).flatMap(g=>g.plugins??[]).map(g=>[g.project,g.alias]));return v3n(s,{root:s,files:[]}).filter(g=>rrn(g).type===mPr).map(g=>{let E=OSe.join(OSe.dirname(g),"project.json"),A=y3n(E)?rrn(E):{},I=A.name??OSe.basename(OSe.dirname(g));return{project:I,dir:OSe.relative(s,OSe.dirname(g)).split(OSe.sep).join("/"),alias:p.get(I),port:A.targets?.serve?.options?.port}}).sort((g,E)=>g.project.localeCompare(E.project))}var yPr=s=>JSON.parse(Ujt(s,"utf-8")),vPr=Object.fromEntries(Object.values(S9e).flatMap(({contributionKeys:s,keys:a})=>s.map(p=>[p,a])));function x3n(s,a){let p=b3n(s),g=p.find(I=>I.project===a||I.alias===a);if(!g)throw new Error(`No DDK plugin project "${a}". DDK plugin projects: ${p.map(I=>I.project).join(", ")||"none"}.`);let E=C9e.join(s,g.dir),A=yPr(C9e.join(E,".kos.json"));return{...g,absDir:E,block:A.kos?.ui?.plugin??{}}}var bPr=(s,a)=>Object.fromEntries((vPr[s]??[]).filter(p=>a[p]!==void 0).map(p=>[p,a[p]])),xPr=(s,a)=>{let p=Object.keys(s);return p.length>0&&p.length===Object.keys(a).length&&p.every(g=>s[g]===a[g])},SPr=(s,a)=>typeof s=="number"&&(typeof a!="number"||s<a);function arn(s,a){let p=x3n(s,a),{extensionPoints:g}=Ett(),E=Gdt(Udt()),A=p.block.contributes??{},I=A.experiences??{},F=[];for(let[z,$]of Object.entries(A)){if(!Array.isArray($))continue;let X=g.find(ee=>ee.contributionKey===z);for(let ee of $){let H=bPr(z,ee),le=E.filter(ae=>ae.plugin!==p.project&&ae.contributionKey===z&&xPr(H,ae.keys)),Q=I[ee.experienceId];F.push({contributionKey:z,...X?{extensionPoint:X.id}:{},id:ee.id,...Object.keys(H).length?{slot:H}:{},...typeof ee.rank=="number"?{rank:ee.rank}:{},...Q?{component:Q.component,location:Q.location}:{},...le.length?{sharesSlotWith:le.map(ae=>({id:ae.id,...typeof ae.rank=="number"?{rank:ae.rank}:{},wins:SPr(ee.rank,ae.rank)}))}:{}})}}return{project:p.project,dir:p.dir,pluginId:p.block.id,contributions:F}}function S3n(s){return irn(s)?gPr(s,{withFileTypes:!0}).flatMap(a=>{let p=C9e.join(s,a.name);return a.isDirectory()?a.name==="node_modules"?[]:S3n(p):/\.(tsx?|css)$/.test(a.name)?[p]:[]}):[]}var TPr=(s,a)=>/export\s+default\b/.test(s)||new RegExp(`export\\s+(const|let|function|class)\\s+${a}\\b`).test(s)||new RegExp(`export\\s*\\{[^}]*\\b${a}\\b[^}]*\\}`).test(s);function EPr(s,a){return a===void 0||a===""?s.required?`missing required ${s.name}`:null:s.type.startsWith('"')?s.type.split(" | ").map(g=>JSON.parse(g)).includes(a)?null:`${s.name} must be ${s.type}`:["string","number","boolean"].includes(s.type)&&typeof a!==s.type?`${s.name} must be a ${s.type}`:null}function T3n(s,a){let p=x3n(s,a),{extensionPoints:g}=Ett(),E=arn(s,a),A=p.block.contributes??{},I=A.experiences??{},F=[],z=[],$=new Map;for(let[Q,ae]of Object.entries(A)){if(!Array.isArray(ae))continue;let Fe=g.find(Le=>Le.contributionKey===Q);for(let Le of ae){let ke=`contributes.${Q} ${Le.id??"(no id)"}`;Le.id?$.has(Le.id)?F.push(`${ke}: id also used in contributes.${$.get(Le.id)}`):$.set(Le.id,Q):F.push(`${ke}: missing id`);for(let Ne of Fe?.fields??[]){if(Ne.name==="rank")continue;let Ce=EPr(Ne,Le[Ne.name]);Ce&&F.push(`${ke}: ${Ce} (${Fe.id})`)}if(Le.rank!==void 0&&(!Number.isInteger(Le.rank)||Le.rank<0||Le.rank>HIt?F.push(`${ke}: rank must be an integer from 0 to ${HIt}`):Fe&&!Fe.isRankable&&z.push(`${ke}: ${Fe.id} is not ranked, so rank has no effect`)),Le.experienceId!==void 0||Fe?.hasView){let Ne=I[Le.experienceId];if(!Ne)F.push(`${ke}: experience ${Le.experienceId??"(none)"} is not in contributes.experiences`);else{let Ce=C9e.join(p.absDir,Ne.location??"");!Ne.location||!irn(Ce)?F.push(`${ke}: component file ${Ne.location} does not exist`):Ne.component&&!TPr(Ujt(Ce,"utf-8"),Ne.component)&&F.push(`${ke}: ${Ne.location} has no default export and does not export ${Ne.component}`)}}}}let X={root:s,read:Q=>{let ae=C9e.join(s,Q);return irn(ae)?Ujt(ae,"utf-8"):null}},ee=Hdt(X).map(Q=>Q.name);for(let[Q,ae,Fe]of[["utilities","utility","utilDescriptor"],["setupStep","setup","setupDescriptor"],["navViews","nav","navDescriptor"]])for(let Le of A[Q]??[]){let ke=Le[Fe];!ke||zjt(X,ae,ke)||z.push(`contributes.${Q} ${Le.id}: ${Fe} "${ke}" is not in ${ee.length?`descriptor project ${ee.join(", ")}`:"the standard NCUI descriptor (no descriptor project in the workspace)"}, so the NCUI does not show it${ee.length?`; list it with kosui ddk:descriptor-entries --project ${a} --descriptorProject ${ee[0]}`:""}`)}let H=new Map;for(let Q of E.contributions.filter(ae=>ae.slot)){let ae=`${Q.contributionKey} ${JSON.stringify(Q.slot)}`,Fe=H.get(ae);if(Fe&&Fe.rank===Q.rank&&z.push(`contributes.${Q.contributionKey} ${Q.id}: same slot and rank as ${Fe.id}; which renders is not defined`),H.set(ae,Q),!Stt().sources.includes(p.project))for(let Le of Q.sharesSlotWith??[])Le.wins||z.push(`contributes.${Q.contributionKey} ${Q.id}: shares a slot with ${Le.id} (${typeof Le.rank=="number"?`rank ${Le.rank}`:"unranked"}) without a winning rank, so it does not replace it`)}let le=C9e.join(p.absDir,"src");for(let Q of S3n(le)){let ae=Ujt(Q,"utf-8"),Fe=C9e.relative(p.absDir,Q).split(C9e.sep).join("/"),Le=[...new Set([...ae.matchAll(/(--ddk-[\w-]+)\s*:/g)].map(ke=>ke[1]))];Le.length&&F.push(`${Fe}: sets DDK tokens (${Le.join(", ")}); plugins compose DDK components and do not set tokens`)}return{project:p.project,ok:F.length===0,errors:F,warnings:z}}var DPr={type:"string",description:"Component name in kebab-case, e.g. fuel-level."},Hjt={type:"string",description:"DDK plugin project to write into."},lrn={type:"boolean",description:"Default true: return the would-write files. false writes."},Kdt={type:"string",description:"Id of a standard contribution to replace (from list_ddk_contributions). Takes its slot with a winning rank."},Xdt={type:"integer",description:"0-1000; lower wins. Default with override: 100, or one better than a ranked target."},orn={type:"string",description:"Assembly property whose models get the contribution, e.g. carbTank. Taken from override when given."},Ydt={name:DPr,project:Hjt,dryRun:lrn,...zdt};async function wtt(s,a){try{let p=VIt(s),g=await F7n({dryRun:s.dryRun!==!1,cwd:p,generate:a});return t8e(g.dryRun?{...g,hint:"Re-run with dryRun:false to write."}:g)}catch(p){return wAe(p.message)}}function Vjt(s,a,p,g={},E=[]){return{name:s,description:p,inputSchema:{type:"object",properties:{...Ydt,...g},required:["name","project",...E]},handler:A=>wtt(A,I=>a3n(I,{type:a,name:A.name,project:A.project,descriptor:A.descriptor,override:A.override,rank:A.rank,descriptorProject:A.descriptorProject,roles:A.roles,column:A.column,layout:A.layout}))}}var srn=(s,a,p={})=>({descriptor:{type:"string",description:`${s}; shown only if the NCUI descriptor lists it (${a}). Default: from the name.`},descriptorProject:{type:"string",description:"NCUI descriptor project to list a new slot in (scaffold_ddk_descriptor_project)."},roles:{type:"string",description:"With descriptorProject: comma-separated roles that see it."},...p,override:Kdt,rank:Xdt});function crn(s,a,p){return{name:s,description:p,inputSchema:{type:"object",properties:{name:{type:"string",description:`${{plugin:"Plugin",theme:"Theme",descriptor:"Descriptor"}[a]} project name in kebab-case.`},...a==="descriptor"?{layout:{type:"string",enum:Vdt,description:"NCUI layout. Default: standard."},...Object.fromEntries(Object.entries(YIt).map(([g,E])=>[g,{type:"boolean",description:`Include ${E}.`}]))}:{},...a==="plugin"?{directory:{type:"string",description:"Parent folder of the project. Default: plugins."},host:{type:"string",description:"Workspace host to register with. Default: the host with the kosdev.ddk plugin context, else none."}}:{},dryRun:lrn,...zdt},required:["name"]},handler:async g=>{try{let E=g.dryRun!==!1,A=g3n(a,{workspaceRoot:VIt(g),name:g.name,directory:g.directory,host:g.host,ncui:{layout:g.layout,...Object.fromEntries(Object.keys(YIt).map(I=>[I,!!g[I]]))},dryRun:E});return t8e({dryRun:E,...A})}catch(E){return wAe(E.message)}}}}var E3n=[crn("scaffold_ddk_plugin_project","plugin","Create a DDK plugin project: module federation serve target, DDK Storybook, .kos.json. dryRun lists the files."),crn("scaffold_ddk_theme_project","theme","Create a DDK theme project; its theme-overlay.css overrides the DDK tokens. dryRun lists the files."),crn("scaffold_ddk_descriptor_project","descriptor","Create an NCUI descriptor project (ddk.ncui.descriptor KAB) for a layout and options; list new utility, setup or nav slots in it. dryRun lists the files."),Vjt("add_utility","utility","Add a utility (utilities contribution) with its component, story and i18n title. The component renders in a modal through useUtilityModal.",srn("utilDescriptor","kondra.ncui.utilities",{column:{type:"integer",description:"With descriptorProject: utilities column, 1-based. Default: the last."},layout:{type:"string",enum:["maximized","fullscreen"],description:"The utility's modal: maximized (default, a modal over the shell) or fullscreen (covers the display)."}})),Vjt("add_setup_step","setup","Add a setup step (setupStep contribution) with its component, story and i18n title.",srn("setupDescriptor","kondra.ncui.setup.steps")),Vjt("add_nav_view","nav","Add a navigation view (navViews contribution) with its component, story and i18n title.",srn("navDescriptor","kondra.ncui.navigations",{descriptor:{type:"string",description:"navDescriptor, a kondra.ncui.navigations path such as settings.water. Required unless override."}})),Vjt("add_cui_config","cui","Add a CUI configuration (cui contribution) with its component and story.",{descriptor:{type:"string",description:"cuiDescriptor: the CUI's appId from /api/app/kosdev.ddk/cui."}},["descriptor"]),{name:"add_dashboard_card",description:"Add a dashboard summary card and, by default, the detail it opens; both share dashboardKey and rank.",inputSchema:{type:"object",properties:{...Ydt,dashboardKey:orn,detail:{type:"boolean",description:"Also add the detail the card opens. Default true."},override:Kdt,rank:Xdt},required:["name","project"]},handler:s=>wtt(s,a=>o3n(a,{name:s.name,project:s.project,dashboardKey:s.dashboardKey,detail:s.detail!==!1,override:s.override,rank:s.rank}))},{name:"add_pump_detail",description:"Add the pump detail shown in the holder modal for holders with dashboardKey.",inputSchema:{type:"object",properties:{...Ydt,dashboardKey:orn,override:Kdt,rank:Xdt},required:["name","project"]},handler:s=>wtt(s,a=>s3n(a,{name:s.name,project:s.project,dashboardKey:s.dashboardKey,override:s.override,rank:s.rank}))},{name:"add_pump_card",description:"Add a pump card for a pump type: the holder card body and, by default, the pump detail; both share dashboardKey and rank.",inputSchema:{type:"object",properties:{...Ydt,dashboardKey:{type:"string",description:"The pump type the backend assembly assigns (the holder's first pump), e.g. cgp. Taken from override when given."},detail:{type:"boolean",description:"Also add the pump detail. Default true."},override:Kdt,rank:Xdt},required:["name","project"]},handler:s=>wtt(s,a=>c3n(a,{name:s.name,project:s.project,dashboardKey:s.dashboardKey,detail:s.detail!==!1,override:s.override,rank:s.rank}))},{name:"add_macro_summary",description:"Add the macro holder card body for dashboardKey.",inputSchema:{type:"object",properties:{...Ydt,dashboardKey:orn,override:Kdt,rank:Xdt},required:["name","project"]},handler:s=>wtt(s,a=>l3n(a,{name:s.name,project:s.project,dashboardKey:s.dashboardKey,override:s.override,rank:s.rank}))},{name:"add_trouble_action",description:"Add the experience shown while the device has an active trouble of troubleType.",inputSchema:{type:"object",properties:{...Ydt,troubleType:{type:"string",description:"Exact trouble type the device raises. Taken from override when given."},stateKey:{type:"string",description:"Contributions sharing a stateKey share one experience. Default: troubleType."},stateValue:{type:"string",description:"Default: troubleType."},override:Kdt,rank:Xdt},required:["name","project"]},handler:s=>wtt(s,a=>u3n(a,{name:s.name,project:s.project,troubleType:s.troubleType,stateKey:s.stateKey,stateValue:s.stateValue,override:s.override,rank:s.rank}))},{name:"describe_ddk_plugin",description:"A DDK plugin project's contributions from its .kos.json: extension point, slot, rank, component, and which standard contributions it shares a slot with and beats.",inputSchema:{type:"object",properties:{project:Hjt,...zdt},required:["project"]},handler:async s=>{try{return t8e(arn(VIt(s),s.project))}catch(a){return wAe(a.message)}}},{name:"add_descriptor_entries",description:"List a plugin's existing utility, setup step and navigation slots in an NCUI descriptor project.",inputSchema:{type:"object",properties:{project:Hjt,descriptorProject:{type:"string",description:"NCUI descriptor project to list them in."},dryRun:lrn,...zdt},required:["project","descriptorProject"]},handler:s=>wtt(s,a=>n3n(a,{project:s.project,descriptorProject:s.descriptorProject}))},{name:"validate_ddk_plugin",description:"Check a DDK plugin project: contribution fields against each extension point's schema, ranks, experiences and their component files, overrides that do not win, and tokens set in plugin code.",inputSchema:{type:"object",properties:{project:Hjt,...zdt},required:["project"]},handler:async s=>{try{return t8e(T3n(VIt(s),s.project))}catch(a){return wAe(a.message)}}},{name:"find_ddk_capability",description:"Map a plain-language need (e.g. replace the carb tank card) to the DDK extension points and components that cover it, with the resource and tool for each.",inputSchema:{type:"object",properties:{need:{type:"string",description:"What the plugin should do."}},required:["need"]},handler:async s=>{try{return t8e(V7n(s.need))}catch(a){return wAe(a.message)}}},{name:"list_ddk_components",description:"List the DDK components and styled parts plugins render, by name and source file.",inputSchema:{type:"object",properties:{library:{type:"string",enum:Wnn,description:"Only this library."},query:{type:"string",description:"Words every match has in its name or path, e.g. dashboard card."}}},handler:async s=>{try{return t8e({components:G7n(s)})}catch(a){return wAe(a.message)}}},{name:"describe_ddk_component",description:"One DDK component from its source: props, the components and hooks it uses, and each token it reads with its value per theme.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Export name, e.g. HolderDashboardCard."},library:{type:"string",enum:Wnn,description:"Library, when both export the name."}},required:["name"]},handler:async s=>{try{let a=U7n(s.name,s.library);return a?{content:[{type:"text",text:a}]}:wAe(`No DDK component named ${s.name}; list_ddk_components lists them.`)}catch(a){return wAe(a.message)}}},{name:"list_ddk_contributions",description:"List the standard DDK contributions an override can replace, with each one's slot and rank, and the contribution keys each point writes. A pump detail is listed under both pump-detail and pump-card.",inputSchema:{type:"object",properties:{point:{type:"string",enum:Object.keys(S9e),description:"Only this command's contributions."}}},handler:async s=>{try{return t8e({points:W7n(s.point||void 0),contributions:Udt(s.point||void 0)})}catch(a){return wAe(a.message)}}}];await M7n(process.argv.slice(2),{name:"kos-ddk",version:B7n.version,tools:E3n,resources:z7n()});
|
|
48538
48538
|
/*! Bundled license information:
|
|
48539
48539
|
|
|
48540
48540
|
ejs/lib/ejs.js:
|
|
@@ -34,10 +34,18 @@ look of whichever theme the DDK app applies.
|
|
|
34
34
|
`useComponentConfigurationContext`, which switches it to compact mode), and the
|
|
35
35
|
tokens it reads. Pass props; never guess them.
|
|
36
36
|
|
|
37
|
-
4. **
|
|
37
|
+
4. **A utility renders in a modal.** `useUtilityModal({ onComplete, layout, onBack })`
|
|
38
|
+
from `@kosdev-code/kos-ddk-components` gives the `Modal` and `Header` props for the
|
|
39
|
+
standard or compact mode the DDK runs in, and `close()`, which runs `onComplete`
|
|
40
|
+
once the modal has closed. Keep the generated `Modal` / `Header` / `Content` /
|
|
41
|
+
`Footer` and spread its props; do not switch on `componentModeOverride` yourself.
|
|
42
|
+
`layout: "fullscreen"` covers the display (a screen test); in compact mode render
|
|
43
|
+
a Back button in the `Footer` when `showFooterBack` is true.
|
|
44
|
+
|
|
45
|
+
5. **Text** through the typography components (`Heading`, `Subheading`, `BodyMedium`,
|
|
38
46
|
`LabelSmall` and the rest) rather than styled text of your own.
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
6. **Check it** in Storybook (the `ddk-storybook` skill), in both render modes.
|
|
41
49
|
|
|
42
50
|
## Rules
|
|
43
51
|
|
package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.stories.tsx__template__
CHANGED
|
@@ -3,12 +3,19 @@
|
|
|
3
3
|
* Simulator is running in order to retrieve model data, unless the story mocks
|
|
4
4
|
* it with parameters.kosMock (ddk://guide/storybook).
|
|
5
5
|
*/
|
|
6
|
+
import { Button } from "@kosdev-code/kos-ddk-components";
|
|
6
7
|
import { UtilityStoryContainer } from "@kosdev-code/kos-ddk-story-containers";
|
|
7
8
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
9
|
+
import type { ComponentProps } from "react";
|
|
10
|
+
import { useArgs } from "storybook/preview-api";
|
|
11
|
+
import { fn } from "storybook/test";
|
|
8
12
|
import { <%= namePascalCase %> } from "./<%= nameDashCase %>";
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
/** `open` shows the utility; it turns off when the utility closes. */
|
|
15
|
+
type StoryArgs = ComponentProps<typeof <%= namePascalCase %>> & { open: boolean };
|
|
16
|
+
|
|
17
|
+
const meta: Meta<StoryArgs> = {
|
|
18
|
+
args: { onComplete: fn(), open: true },
|
|
12
19
|
component: <%= namePascalCase %>,
|
|
13
20
|
decorators: [
|
|
14
21
|
(Story, context) => (
|
|
@@ -23,10 +30,28 @@ const meta: Meta<typeof <%= namePascalCase %>> = {
|
|
|
23
30
|
|
|
24
31
|
export default meta;
|
|
25
32
|
|
|
26
|
-
type Story = StoryObj<
|
|
33
|
+
type Story = StoryObj<StoryArgs>;
|
|
27
34
|
|
|
28
35
|
export const Default: Story = {
|
|
29
36
|
// parameters: { kosMock: { setups: ["<setup module>"] } },
|
|
30
|
-
render: (
|
|
37
|
+
render: function Render({ open, onComplete, ...props }) {
|
|
38
|
+
const [, updateArgs] = useArgs<StoryArgs>();
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
{/* Behind the modal: reopens the utility after it closes. */}
|
|
42
|
+
<Button onPointerDown={() => updateArgs({ open: true })}>
|
|
43
|
+
Open <%= namePascalCase %>
|
|
44
|
+
</Button>
|
|
45
|
+
{open && (
|
|
46
|
+
<<%= namePascalCase %>
|
|
47
|
+
{...props}
|
|
48
|
+
onComplete={() => {
|
|
49
|
+
onComplete();
|
|
50
|
+
updateArgs({ open: false });
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
)}
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
},
|
|
31
57
|
};
|
|
32
|
-
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import {
|
|
3
|
+
<% if (layout !== "fullscreen") { -%>
|
|
3
4
|
Button,
|
|
5
|
+
Content,
|
|
4
6
|
Footer,
|
|
7
|
+
<% } -%>
|
|
8
|
+
Header,
|
|
9
|
+
Modal,
|
|
10
|
+
useUtilityModal,
|
|
5
11
|
type Experience,
|
|
6
12
|
} from '@kosdev-code/kos-ddk-components';
|
|
7
13
|
import {
|
|
@@ -13,24 +19,69 @@ import {
|
|
|
13
19
|
const log = KosLog.createLogger({name: "<%= nameDashCase %>"})
|
|
14
20
|
log.debug("<%= nameDashCase %> component loaded");
|
|
15
21
|
|
|
16
|
-
const <%= namePascalCase %>Container = styled.
|
|
22
|
+
const <%= namePascalCase %>Container = styled.section`
|
|
17
23
|
align-items: center;
|
|
18
24
|
display: flex;
|
|
19
25
|
flex-direction: column;
|
|
26
|
+
gap: 32px;
|
|
27
|
+
height: 100%;
|
|
28
|
+
justify-content: center;
|
|
20
29
|
width: 100%;
|
|
21
30
|
`;
|
|
22
31
|
|
|
32
|
+
<% if (layout === "fullscreen") { -%>
|
|
33
|
+
/** A fullscreen utility: it covers the display and closes from its header. */
|
|
23
34
|
export const <%= namePascalCase %>: Experience = kosComponent(({ onComplete }) => {
|
|
24
35
|
const { t } = useKosTranslation('<%= appProject %>');
|
|
36
|
+
const { modalProps, headerProps } = useUtilityModal({
|
|
37
|
+
onComplete,
|
|
38
|
+
layout: "fullscreen",
|
|
39
|
+
closeButtonLabel: t('close'),
|
|
40
|
+
});
|
|
25
41
|
return (
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
<Modal {...modalProps}>
|
|
43
|
+
<Header
|
|
44
|
+
{...headerProps}
|
|
45
|
+
title={t('<%= appProject %>.<%= nameCamelCase %>.utility.title')}
|
|
46
|
+
/>
|
|
47
|
+
<<%= namePascalCase %>Container>
|
|
48
|
+
Hello from <%= namePascalCase %> Utility
|
|
49
|
+
</<%= namePascalCase %>Container>
|
|
50
|
+
</Modal>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
<% } else { -%>
|
|
54
|
+
/**
|
|
55
|
+
* A utility in a modal. useUtilityModal fits the modal to the DDK's standard or
|
|
56
|
+
* compact mode; pass onBack (and showBack) for a utility with steps.
|
|
57
|
+
*/
|
|
58
|
+
export const <%= namePascalCase %>: Experience = kosComponent(({ onComplete }) => {
|
|
59
|
+
const { t } = useKosTranslation('<%= appProject %>');
|
|
60
|
+
const { modalProps, headerProps, close } = useUtilityModal({
|
|
61
|
+
onComplete,
|
|
62
|
+
closeButtonLabel: t('close'),
|
|
63
|
+
backButtonLabel: t('back'),
|
|
64
|
+
});
|
|
65
|
+
return (
|
|
66
|
+
<Modal {...modalProps}>
|
|
67
|
+
<Header
|
|
68
|
+
{...headerProps}
|
|
69
|
+
title={t('<%= appProject %>.<%= nameCamelCase %>.utility.title')}
|
|
70
|
+
/>
|
|
71
|
+
<Content align="center">
|
|
72
|
+
<<%= namePascalCase %>Container>
|
|
73
|
+
Hello from <%= namePascalCase %> Utility
|
|
74
|
+
</<%= namePascalCase %>Container>
|
|
75
|
+
</Content>
|
|
28
76
|
<Footer>
|
|
29
|
-
<Button
|
|
77
|
+
<Button mode="primary" onPointerDown={close}>
|
|
78
|
+
{t('done')}
|
|
79
|
+
</Button>
|
|
30
80
|
</Footer>
|
|
31
|
-
|
|
81
|
+
</Modal>
|
|
32
82
|
);
|
|
33
83
|
});
|
|
84
|
+
<% } -%>
|
|
34
85
|
|
|
35
86
|
<%= namePascalCase %>.displayName = "<%= namePascalCase %>"
|
|
36
87
|
|
package/guides/storybook.md
CHANGED
|
@@ -79,7 +79,7 @@ Each story renders the component inside the container for its extension point, f
|
|
|
79
79
|
|
|
80
80
|
| Command | Container | Gives the component |
|
|
81
81
|
| -------------------- | ----------------------------------------------------------------- | ----------------------------------------------------- |
|
|
82
|
-
| `ddk:utility` | `UtilityStoryContainer` | the utility
|
|
82
|
+
| `ddk:utility` | `UtilityStoryContainer` | nothing: the utility opens its own `Modal` |
|
|
83
83
|
| `ddk:setup` | `SetupStepStoryContainer` | the setup step frame |
|
|
84
84
|
| `ddk:nav` | `NavStoryContainer` | the navigation view frame |
|
|
85
85
|
| `ddk:cui` | `CUIStoryContainer` | the CUI frame |
|
|
@@ -92,6 +92,10 @@ Each story renders the component inside the container for its extension point, f
|
|
|
92
92
|
When the simulator has no matching model, holder or trouble, the container says so in place
|
|
93
93
|
of the story.
|
|
94
94
|
|
|
95
|
+
A utility story has an `open` control. Closing the utility turns it off and logs
|
|
96
|
+
`onComplete` in the Actions panel; the **Open** button behind the modal, or the
|
|
97
|
+
control, opens it again.
|
|
98
|
+
|
|
95
99
|
## Standard and compact modes
|
|
96
100
|
|
|
97
101
|
The **Render Mode** toolbar switches between `standard` and `compact`. It changes the DDK
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosdev-code/kos-ddk-cli",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.61",
|
|
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": "
|
|
30
|
+
"gitHash": "edc581166b672e67c4ae900dff675c78908691b1"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
package/reference/reference.json
CHANGED
|
@@ -18947,6 +18947,11 @@
|
|
|
18947
18947
|
"package": "@kosdev-code/kos-ddk-components",
|
|
18948
18948
|
"file": "src/hooks/router/useNavigate.tsx"
|
|
18949
18949
|
},
|
|
18950
|
+
{
|
|
18951
|
+
"name": "useUtilityModal",
|
|
18952
|
+
"package": "@kosdev-code/kos-ddk-components",
|
|
18953
|
+
"file": "src/components/modal/utility-modal/use-utility-modal.tsx"
|
|
18954
|
+
},
|
|
18950
18955
|
{
|
|
18951
18956
|
"name": "useViewExperience",
|
|
18952
18957
|
"package": "@kosdev-code/kos-ddk-components",
|
|
@@ -19235,7 +19240,7 @@
|
|
|
19235
19240
|
"name": "ddk-guide-storybook",
|
|
19236
19241
|
"title": "Developing DDK contributions in Storybook",
|
|
19237
19242
|
"description": "Running a plugin's Storybook against a simulator or with KosMock story mocks, where model data comes from, the story container per contribution command, render modes and overrides.",
|
|
19238
|
-
"body": "# Developing DDK contributions in Storybook\n\nEvery `ddk:*` contribution command writes a story next to the component, so a contribution\ncan be developed in isolation before the plugin is loaded into a running DDK. Stories render\nagainst live models from a running simulator.\n\n## Run it\n\n```sh\nnpx nx run <plugin>:storybook\n```\n\nStorybook serves on port 4400. The plugin's `serve` target is the module federation dev\nserver used by `kosui ddk:dev`; Storybook has its own `storybook` target.\n\n## Where model data comes from\n\nThe preview (`.storybook/preview.tsx`) wraps every story in the providers the DDK hosts use:\nKosCore, translations (`app/system`, `app/kosdev.ddk`), `AssemblyProvider`,\n`ApplicationProvider` and `ApplicationComponentConfigurationProvider`. KosCore connects to the\nfirst of:\n\n1. the `?host=` query parameter on the Storybook URL;\n2. `KOS_HOST` and `KOS_PORT` in the plugin's `.env` (the generated `.env` sets\n `KOS_PORT=8081`, the simulator's default);\n3. the page's own origin.\n\nTranslations come from the same device: the DDK's namespaces (`app/system`,\n`app/kosdev.ddk`) from its files, and the plugin's own namespace from the plugin's\n`src/assets/locales`, since the device lists it only once the KAB is installed. Each\ncontribution command adds its title key, and the keys its component calls, to\n`src/assets/locales/en/<plugin>.json`.\n\nStart the simulator before Storybook. A story shows what the simulator has: a dashboard card\nneeds an active model at its `dashboardKey`, a trouble action needs an active trouble of its\n`troubleType`.\n\n## Mocking what the simulator lacks\n\nA story can bring its own data with KosMock, the SDK's transport-level mocks\n(`kos://guide/mocking`), instead of waiting for the simulator to reach a state: an active\ntrouble, setup mode, a descriptor entry. It names the mocks as `parameters.kosMock`, and\nthe preview's outermost decorator reloads the page into those boot switches\n(`ensureKosMockBoot`):\n\n```tsx\nexport const ActiveTrouble: Story = {\n parameters: { kosMock: { setups: [\"daily-cleaning-trouble\"] } },\n};\n```\n\n`kosMock` takes `setups` (setup modules in `fixtures/setups/`), `fixture` (a recorded\nfixture), `mode` and `fixtureServer`:\n\n- `mode: \"on\"` (the default) mocks only the named endpoints over the running simulator.\n- `mode: \"standalone\"` boots with no device at all; every endpoint the story reads must\n be mocked.\n\nServe the fixtures beside Storybook:\n\n```sh\nkosui fixtures serve\n```\n\nA story without `kosMock` reloads without switches, so mocks never carry over between\nstories. Every generated story has a commented `kosMock` line to start from.\n\n## Story containers\n\nEach story renders the component inside the container for its extension point, from\n`@kosdev-code/kos-ddk-story-containers`:\n\n| Command | Container | Gives the component |\n| -------------------- | ----------------------------------------------------------------- | ----------------------------------------------------- |\n| `ddk:utility` | `UtilityStoryContainer` | the utility
|
|
19243
|
+
"body": "# Developing DDK contributions in Storybook\n\nEvery `ddk:*` contribution command writes a story next to the component, so a contribution\ncan be developed in isolation before the plugin is loaded into a running DDK. Stories render\nagainst live models from a running simulator.\n\n## Run it\n\n```sh\nnpx nx run <plugin>:storybook\n```\n\nStorybook serves on port 4400. The plugin's `serve` target is the module federation dev\nserver used by `kosui ddk:dev`; Storybook has its own `storybook` target.\n\n## Where model data comes from\n\nThe preview (`.storybook/preview.tsx`) wraps every story in the providers the DDK hosts use:\nKosCore, translations (`app/system`, `app/kosdev.ddk`), `AssemblyProvider`,\n`ApplicationProvider` and `ApplicationComponentConfigurationProvider`. KosCore connects to the\nfirst of:\n\n1. the `?host=` query parameter on the Storybook URL;\n2. `KOS_HOST` and `KOS_PORT` in the plugin's `.env` (the generated `.env` sets\n `KOS_PORT=8081`, the simulator's default);\n3. the page's own origin.\n\nTranslations come from the same device: the DDK's namespaces (`app/system`,\n`app/kosdev.ddk`) from its files, and the plugin's own namespace from the plugin's\n`src/assets/locales`, since the device lists it only once the KAB is installed. Each\ncontribution command adds its title key, and the keys its component calls, to\n`src/assets/locales/en/<plugin>.json`.\n\nStart the simulator before Storybook. A story shows what the simulator has: a dashboard card\nneeds an active model at its `dashboardKey`, a trouble action needs an active trouble of its\n`troubleType`.\n\n## Mocking what the simulator lacks\n\nA story can bring its own data with KosMock, the SDK's transport-level mocks\n(`kos://guide/mocking`), instead of waiting for the simulator to reach a state: an active\ntrouble, setup mode, a descriptor entry. It names the mocks as `parameters.kosMock`, and\nthe preview's outermost decorator reloads the page into those boot switches\n(`ensureKosMockBoot`):\n\n```tsx\nexport const ActiveTrouble: Story = {\n parameters: { kosMock: { setups: [\"daily-cleaning-trouble\"] } },\n};\n```\n\n`kosMock` takes `setups` (setup modules in `fixtures/setups/`), `fixture` (a recorded\nfixture), `mode` and `fixtureServer`:\n\n- `mode: \"on\"` (the default) mocks only the named endpoints over the running simulator.\n- `mode: \"standalone\"` boots with no device at all; every endpoint the story reads must\n be mocked.\n\nServe the fixtures beside Storybook:\n\n```sh\nkosui fixtures serve\n```\n\nA story without `kosMock` reloads without switches, so mocks never carry over between\nstories. Every generated story has a commented `kosMock` line to start from.\n\n## Story containers\n\nEach story renders the component inside the container for its extension point, from\n`@kosdev-code/kos-ddk-story-containers`:\n\n| Command | Container | Gives the component |\n| -------------------- | ----------------------------------------------------------------- | ----------------------------------------------------- |\n| `ddk:utility` | `UtilityStoryContainer` | nothing: the utility opens its own `Modal` |\n| `ddk:setup` | `SetupStepStoryContainer` | the setup step frame |\n| `ddk:nav` | `NavStoryContainer` | the navigation view frame |\n| `ddk:cui` | `CUIStoryContainer` | the CUI frame |\n| `ddk:dashboard-card` | `DashboardSummaryStoryContainer`, `DashboardDetailStoryContainer` | `dashboardKey`, `assembly`, `cardModel`, `onComplete` |\n| `ddk:pump-detail` | `PumpDetailStoryContainer` | the first `holder` with the `dashboardKey` |\n| `ddk:pump-card` | `PumpSummaryStoryContainer`, `PumpDetailStoryContainer` | the first `holder` with the `dashboardKey` |\n| `ddk:macro-summary` | `MacroSummaryStoryContainer` | the first `holder` with the `dashboardKey` |\n| `ddk:trouble-action` | `TroubleActionStoryContainer` | the active `trouble` of the `troubleType` |\n\nWhen the simulator has no matching model, holder or trouble, the container says so in place\nof the story.\n\nA utility story has an `open` control. Closing the utility turns it off and logs\n`onComplete` in the Actions panel; the **Open** button behind the modal, or the\ncontrol, opens it again.\n\n## Standard and compact modes\n\nThe **Render Mode** toolbar switches between `standard` and `compact`. It changes the DDK\nstyles and the component mode; in `compact`, modals render full screen.\n\n## Overrides\n\nA story renders the override on its own, so an override of a standard contribution can be\ndeveloped here first. To see it replace the standard contribution, load the plugin into a\nrunning DDK with `kosui ddk:dev` (see the package README)."
|
|
19239
19244
|
},
|
|
19240
19245
|
{
|
|
19241
19246
|
"uri": "ddk://guide/descriptor-project",
|
|
@@ -39,8 +39,9 @@ export const CONTRIBUTION_TYPES = {
|
|
|
39
39
|
overridable: "utilDescriptor",
|
|
40
40
|
listedIn: "kondra.ncui.utilities",
|
|
41
41
|
descriptorType: "utility",
|
|
42
|
+
layouts: ["maximized", "fullscreen"],
|
|
42
43
|
description:
|
|
43
|
-
"Create a utility; --descriptor is its kondra.ncui.utilities entry (default: from the name)",
|
|
44
|
+
"Create a utility in a modal; --layout maximized (default) or fullscreen; --descriptor is its kondra.ncui.utilities entry (default: from the name)",
|
|
44
45
|
},
|
|
45
46
|
nav: {
|
|
46
47
|
pluginType: "ddk.nav",
|
|
@@ -59,7 +60,7 @@ export const CONTRIBUTION_TYPES = {
|
|
|
59
60
|
export const TEMPLATE_KEYS = {
|
|
60
61
|
"ddk.cui": { proceed: "Proceed" },
|
|
61
62
|
"ddk.setup": { proceed: "Proceed" },
|
|
62
|
-
"ddk.utility": {
|
|
63
|
+
"ddk.utility": { back: "Back", close: "Close", done: "Done" },
|
|
63
64
|
"ddk.dashboardDetail": { close: "Close" },
|
|
64
65
|
"ddk.troubleAction": { resolve: "Resolve" },
|
|
65
66
|
};
|
|
@@ -126,9 +127,10 @@ const rankField = (rank) => (rank === undefined ? {} : { rank });
|
|
|
126
127
|
|
|
127
128
|
/**
|
|
128
129
|
* @param {{type: keyof CONTRIBUTION_TYPES, name: string, project: string,
|
|
129
|
-
* descriptor?: string, override?: string, rank?: number|string
|
|
130
|
+
* descriptor?: string, override?: string, rank?: number|string,
|
|
131
|
+
* layout?: string}} options
|
|
130
132
|
* `override` and `rank` apply to the rankable types (setup, utility, nav); `descriptor`
|
|
131
|
-
* to those and to cui, which requires it.
|
|
133
|
+
* to those and to cui, which requires it; `layout` to a utility's modal.
|
|
132
134
|
*/
|
|
133
135
|
export function generateDdkContribution(
|
|
134
136
|
codegenFs,
|
|
@@ -142,6 +144,7 @@ export function generateDdkContribution(
|
|
|
142
144
|
descriptorProject,
|
|
143
145
|
roles,
|
|
144
146
|
column,
|
|
147
|
+
layout,
|
|
145
148
|
}
|
|
146
149
|
) {
|
|
147
150
|
const spec = CONTRIBUTION_TYPES[type];
|
|
@@ -159,6 +162,14 @@ export function generateDdkContribution(
|
|
|
159
162
|
);
|
|
160
163
|
}
|
|
161
164
|
if (spec.required) requireOption(descriptor, `descriptor (${spec.required})`);
|
|
165
|
+
if (layout && !spec.layouts) {
|
|
166
|
+
throw new Error(`${type} contributions have no layout; --layout does not apply`);
|
|
167
|
+
}
|
|
168
|
+
if (layout && !spec.layouts.includes(layout)) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
`Unknown layout "${layout}". Choose from ${spec.layouts.join(", ")}.`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
162
173
|
const resolved = spec.overridable
|
|
163
174
|
? resolveOverride(type, {
|
|
164
175
|
override,
|
|
@@ -192,6 +203,7 @@ export function generateDdkContribution(
|
|
|
192
203
|
project,
|
|
193
204
|
...(slot ? { descriptor: slot } : {}),
|
|
194
205
|
...rankField(resolved.rank),
|
|
206
|
+
...(spec.layouts ? { layout: layout || spec.layouts[0] } : {}),
|
|
195
207
|
});
|
|
196
208
|
const listed = spec.descriptorType
|
|
197
209
|
? descriptorNotes(codegenFs, spec, {
|
|
@@ -33,6 +33,7 @@ export const metadata = Object.entries(CONTRIBUTION_TYPES).map(
|
|
|
33
33
|
...baseArguments,
|
|
34
34
|
...(spec.overridable ? rankArguments : {}),
|
|
35
35
|
...(spec.descriptorType === "utility" ? { column: "column" } : {}),
|
|
36
|
+
...(spec.layouts ? { layout: "layout" } : {}),
|
|
36
37
|
...(spec.required ? { descriptor: "descriptor" } : {}),
|
|
37
38
|
},
|
|
38
39
|
})
|
|
@@ -55,6 +56,7 @@ export async function register(plop, { host }) {
|
|
|
55
56
|
descriptorProject: answers.descriptorProject || undefined,
|
|
56
57
|
roles: answers.roles || undefined,
|
|
57
58
|
column: answers.column || undefined,
|
|
59
|
+
layout: answers.layout || undefined,
|
|
58
60
|
});
|
|
59
61
|
return host.reportCodegen(
|
|
60
62
|
codegenFs,
|
|
@@ -86,6 +88,17 @@ export async function register(plop, { host }) {
|
|
|
86
88
|
message: "Which plugin project should the component be created in?",
|
|
87
89
|
choices: pluginProjects,
|
|
88
90
|
},
|
|
91
|
+
...(spec.layouts
|
|
92
|
+
? [
|
|
93
|
+
{
|
|
94
|
+
type: "list",
|
|
95
|
+
name: "layout",
|
|
96
|
+
message: "Modal layout?",
|
|
97
|
+
choices: spec.layouts,
|
|
98
|
+
default: spec.layouts[0],
|
|
99
|
+
},
|
|
100
|
+
]
|
|
101
|
+
: []),
|
|
89
102
|
...(spec.required
|
|
90
103
|
? [
|
|
91
104
|
{
|
package/src/mcp/tools.mjs
CHANGED
|
@@ -107,6 +107,7 @@ function contributionTool(
|
|
|
107
107
|
descriptorProject: args.descriptorProject,
|
|
108
108
|
roles: args.roles,
|
|
109
109
|
column: args.column,
|
|
110
|
+
layout: args.layout,
|
|
110
111
|
})
|
|
111
112
|
),
|
|
112
113
|
};
|
|
@@ -223,13 +224,19 @@ export const ddkTools = [
|
|
|
223
224
|
contributionTool(
|
|
224
225
|
"add_utility",
|
|
225
226
|
"utility",
|
|
226
|
-
"Add a utility (utilities contribution) with its component, story and i18n title.",
|
|
227
|
+
"Add a utility (utilities contribution) with its component, story and i18n title. The component renders in a modal through useUtilityModal.",
|
|
227
228
|
slot("utilDescriptor", "kondra.ncui.utilities", {
|
|
228
229
|
column: {
|
|
229
230
|
type: "integer",
|
|
230
231
|
description:
|
|
231
232
|
"With descriptorProject: utilities column, 1-based. Default: the last.",
|
|
232
233
|
},
|
|
234
|
+
layout: {
|
|
235
|
+
type: "string",
|
|
236
|
+
enum: ["maximized", "fullscreen"],
|
|
237
|
+
description:
|
|
238
|
+
"The utility's modal: maximized (default, a modal over the shell) or fullscreen (covers the display).",
|
|
239
|
+
},
|
|
233
240
|
})
|
|
234
241
|
),
|
|
235
242
|
contributionTool(
|
|
@@ -3,12 +3,19 @@
|
|
|
3
3
|
* Simulator is running in order to retrieve model data, unless the story mocks
|
|
4
4
|
* it with parameters.kosMock (ddk://guide/storybook).
|
|
5
5
|
*/
|
|
6
|
+
import { Button } from "@kosdev-code/kos-ddk-components";
|
|
6
7
|
import { UtilityStoryContainer } from "@kosdev-code/kos-ddk-story-containers";
|
|
7
8
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
9
|
+
import type { ComponentProps } from "react";
|
|
10
|
+
import { useArgs } from "storybook/preview-api";
|
|
11
|
+
import { fn } from "storybook/test";
|
|
8
12
|
import { <%= namePascalCase %> } from "./<%= nameDashCase %>";
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
/** `open` shows the utility; it turns off when the utility closes. */
|
|
15
|
+
type StoryArgs = ComponentProps<typeof <%= namePascalCase %>> & { open: boolean };
|
|
16
|
+
|
|
17
|
+
const meta: Meta<StoryArgs> = {
|
|
18
|
+
args: { onComplete: fn(), open: true },
|
|
12
19
|
component: <%= namePascalCase %>,
|
|
13
20
|
decorators: [
|
|
14
21
|
(Story, context) => (
|
|
@@ -23,10 +30,28 @@ const meta: Meta<typeof <%= namePascalCase %>> = {
|
|
|
23
30
|
|
|
24
31
|
export default meta;
|
|
25
32
|
|
|
26
|
-
type Story = StoryObj<
|
|
33
|
+
type Story = StoryObj<StoryArgs>;
|
|
27
34
|
|
|
28
35
|
export const Default: Story = {
|
|
29
36
|
// parameters: { kosMock: { setups: ["<setup module>"] } },
|
|
30
|
-
render: (
|
|
37
|
+
render: function Render({ open, onComplete, ...props }) {
|
|
38
|
+
const [, updateArgs] = useArgs<StoryArgs>();
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
{/* Behind the modal: reopens the utility after it closes. */}
|
|
42
|
+
<Button onPointerDown={() => updateArgs({ open: true })}>
|
|
43
|
+
Open <%= namePascalCase %>
|
|
44
|
+
</Button>
|
|
45
|
+
{open && (
|
|
46
|
+
<<%= namePascalCase %>
|
|
47
|
+
{...props}
|
|
48
|
+
onComplete={() => {
|
|
49
|
+
onComplete();
|
|
50
|
+
updateArgs({ open: false });
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
)}
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
},
|
|
31
57
|
};
|
|
32
|
-
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import {
|
|
3
|
+
<% if (layout !== "fullscreen") { -%>
|
|
3
4
|
Button,
|
|
5
|
+
Content,
|
|
4
6
|
Footer,
|
|
7
|
+
<% } -%>
|
|
8
|
+
Header,
|
|
9
|
+
Modal,
|
|
10
|
+
useUtilityModal,
|
|
5
11
|
type Experience,
|
|
6
12
|
} from '@kosdev-code/kos-ddk-components';
|
|
7
13
|
import {
|
|
@@ -13,24 +19,69 @@ import {
|
|
|
13
19
|
const log = KosLog.createLogger({name: "<%= nameDashCase %>"})
|
|
14
20
|
log.debug("<%= nameDashCase %> component loaded");
|
|
15
21
|
|
|
16
|
-
const <%= namePascalCase %>Container = styled.
|
|
22
|
+
const <%= namePascalCase %>Container = styled.section`
|
|
17
23
|
align-items: center;
|
|
18
24
|
display: flex;
|
|
19
25
|
flex-direction: column;
|
|
26
|
+
gap: 32px;
|
|
27
|
+
height: 100%;
|
|
28
|
+
justify-content: center;
|
|
20
29
|
width: 100%;
|
|
21
30
|
`;
|
|
22
31
|
|
|
32
|
+
<% if (layout === "fullscreen") { -%>
|
|
33
|
+
/** A fullscreen utility: it covers the display and closes from its header. */
|
|
23
34
|
export const <%= namePascalCase %>: Experience = kosComponent(({ onComplete }) => {
|
|
24
35
|
const { t } = useKosTranslation('<%= appProject %>');
|
|
36
|
+
const { modalProps, headerProps } = useUtilityModal({
|
|
37
|
+
onComplete,
|
|
38
|
+
layout: "fullscreen",
|
|
39
|
+
closeButtonLabel: t('close'),
|
|
40
|
+
});
|
|
25
41
|
return (
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
<Modal {...modalProps}>
|
|
43
|
+
<Header
|
|
44
|
+
{...headerProps}
|
|
45
|
+
title={t('<%= appProject %>.<%= nameCamelCase %>.utility.title')}
|
|
46
|
+
/>
|
|
47
|
+
<<%= namePascalCase %>Container>
|
|
48
|
+
Hello from <%= namePascalCase %> Utility
|
|
49
|
+
</<%= namePascalCase %>Container>
|
|
50
|
+
</Modal>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
<% } else { -%>
|
|
54
|
+
/**
|
|
55
|
+
* A utility in a modal. useUtilityModal fits the modal to the DDK's standard or
|
|
56
|
+
* compact mode; pass onBack (and showBack) for a utility with steps.
|
|
57
|
+
*/
|
|
58
|
+
export const <%= namePascalCase %>: Experience = kosComponent(({ onComplete }) => {
|
|
59
|
+
const { t } = useKosTranslation('<%= appProject %>');
|
|
60
|
+
const { modalProps, headerProps, close } = useUtilityModal({
|
|
61
|
+
onComplete,
|
|
62
|
+
closeButtonLabel: t('close'),
|
|
63
|
+
backButtonLabel: t('back'),
|
|
64
|
+
});
|
|
65
|
+
return (
|
|
66
|
+
<Modal {...modalProps}>
|
|
67
|
+
<Header
|
|
68
|
+
{...headerProps}
|
|
69
|
+
title={t('<%= appProject %>.<%= nameCamelCase %>.utility.title')}
|
|
70
|
+
/>
|
|
71
|
+
<Content align="center">
|
|
72
|
+
<<%= namePascalCase %>Container>
|
|
73
|
+
Hello from <%= namePascalCase %> Utility
|
|
74
|
+
</<%= namePascalCase %>Container>
|
|
75
|
+
</Content>
|
|
28
76
|
<Footer>
|
|
29
|
-
<Button
|
|
77
|
+
<Button mode="primary" onPointerDown={close}>
|
|
78
|
+
{t('done')}
|
|
79
|
+
</Button>
|
|
30
80
|
</Footer>
|
|
31
|
-
|
|
81
|
+
</Modal>
|
|
32
82
|
);
|
|
33
83
|
});
|
|
84
|
+
<% } -%>
|
|
34
85
|
|
|
35
86
|
<%= namePascalCase %>.displayName = "<%= namePascalCase %>"
|
|
36
87
|
|