@domain-first/project-structure 2.9.0 → 2.9.1

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 CHANGED
@@ -184,7 +184,7 @@ Enable `useReact` and choose **Scaffold React module** from the main menu. Modul
184
184
  | ------------------------------ | ---------------------------------------------------------------------------------------------------------- |
185
185
  | New page | `pages/<name>-page.tsx` with a typed props object and a component. |
186
186
  | New widget → monolithic | `widgets/<name>/<name>-widget.tsx` with props and rendering in one file, re-exported from `index.ts`. |
187
- | New widget → with separated ui | `<name>-widget.tsx`, `types.ts`, `ui/<name>-widget-ui.tsx`, `hooks/use-<name>-ui-model.ts`, and `index.ts`. |
187
+ | New widget → with separated ui | `<name>-widget.tsx`, `types.ts`, `ui/<name>-widget-ui.tsx`, `hooks/use-<name>-ui-model.ts`, and `index.ts`; with `storybookFramework`, also `ui/<name>-widget-ui.stories.tsx`. |
188
188
  | New widget → headless | `<name>-widget.tsx`, types, a UI-model hook, and `index.ts`; the rendering component is supplied through the `UI` prop. |
189
189
  | New UI-kit component | `ui-kit/<name>/<name>.tsx` with a typed props object and a component, re-exported from `index.ts`; with `storybookFramework`, also `<name>.stories.tsx`. |
190
190
  | New shared hook | `hooks/use-<name>.ts` with an app-wide hook, such as `use-debounce`; a leading `use-` in the name is not repeated. |
@@ -216,7 +216,7 @@ The project configuration is stored in `domain-first.project-structure.config.js
216
216
  | `domainFirstPackages` | Explicit list of integrations used by templates. An empty array selects basic class templates where supported. |
217
217
  | `defaultPersistenceLayerImplementation` | Suggested implementation label for execution commands and queries. |
218
218
  | `useReact` | Shows or hides the React module menu. |
219
- | `storybookFramework` | Storybook framework package imported by generated stories (`Meta`, `StoryObj`), e.g. `@storybook/react-vite`. Omit this field to skip stories for UI-kit components. Asked during setup only when React is enabled. |
219
+ | `storybookFramework` | Storybook framework package imported by generated stories (`Meta`, `StoryObj`), e.g. `@storybook/react-vite`. Omit this field to skip stories for UI-kit components and widget UI. Asked during setup only when React is enabled. |
220
220
  | `testingLibrary` | Module imported by generated tests. Omit this field to disable test generation. Templates expect helpers such as `describe`, `test`, `expect`, and `beforeEach`. |
221
221
 
222
222
  ### Package integrations
package/dist/index.cjs CHANGED
@@ -1354,12 +1354,13 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1354
1354
  `.trim());
1355
1355
  break;
1356
1356
  case 'with separated ui':
1357
- folder.createFile('types.ts', `
1357
+ {
1358
+ folder.createFile('types.ts', `
1358
1359
  export type ${ClassName}WidgetProps = { }
1359
1360
 
1360
1361
  export type ${ClassName}WidgetUIProps = { }
1361
1362
  `.trim());
1362
- folder.createFile(`${widgetFileName}.tsx`, `
1363
+ folder.createFile(`${widgetFileName}.tsx`, `
1363
1364
  import { type FC } from 'react'
1364
1365
  import type { ${ClassName}WidgetProps } from './types'
1365
1366
  import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
@@ -1372,9 +1373,9 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1372
1373
 
1373
1374
  export type { ${ClassName}WidgetProps }
1374
1375
  `.trim());
1375
- folder.subitem([
1376
- 'ui'
1377
- ]).createFile(`${uiFileName}.tsx`, `
1376
+ folder.subitem([
1377
+ 'ui'
1378
+ ]).createFile(`${uiFileName}.tsx`, `
1378
1379
  import { FC } from 'react'
1379
1380
  import type { ${ClassName}WidgetUIProps } from '../types'
1380
1381
 
@@ -1382,16 +1383,37 @@ export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
1382
1383
  return <></>
1383
1384
  }
1384
1385
  `.trim());
1385
- folder.subitem([
1386
- 'hooks'
1387
- ]).createFile(`${uiModelFileName}.ts`, `
1386
+ const { storybookFramework } = ConfigFile.Instance.data;
1387
+ if (storybookFramework) folder.subitem([
1388
+ 'ui'
1389
+ ]).createFile(`${uiFileName}.stories.tsx`, `
1390
+ import type { Meta, StoryObj } from '${storybookFramework}'
1391
+ import { ${ClassName}WidgetUI } from './${uiFileName}'
1392
+
1393
+ const meta = {
1394
+ title: 'Widgets/${ClassName}',
1395
+ component: ${ClassName}WidgetUI
1396
+ } satisfies Meta<typeof ${ClassName}WidgetUI>
1397
+
1398
+ export default meta
1399
+
1400
+ type Story = StoryObj<typeof meta>
1401
+
1402
+ export const Default: Story = {
1403
+ args: {}
1404
+ }
1405
+ `.trim());
1406
+ folder.subitem([
1407
+ 'hooks'
1408
+ ]).createFile(`${uiModelFileName}.ts`, `
1388
1409
  import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
1389
1410
 
1390
1411
  export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
1391
1412
  return {}
1392
1413
  }
1393
1414
  `.trim());
1394
- break;
1415
+ break;
1416
+ }
1395
1417
  case 'headless':
1396
1418
  folder.createFile('types.ts', `
1397
1419
  import { type FC } from 'react'
package/dist/index.js CHANGED
@@ -1324,12 +1324,13 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1324
1324
  `.trim());
1325
1325
  break;
1326
1326
  case 'with separated ui':
1327
- folder.createFile('types.ts', `
1327
+ {
1328
+ folder.createFile('types.ts', `
1328
1329
  export type ${ClassName}WidgetProps = { }
1329
1330
 
1330
1331
  export type ${ClassName}WidgetUIProps = { }
1331
1332
  `.trim());
1332
- folder.createFile(`${widgetFileName}.tsx`, `
1333
+ folder.createFile(`${widgetFileName}.tsx`, `
1333
1334
  import { type FC } from 'react'
1334
1335
  import type { ${ClassName}WidgetProps } from './types'
1335
1336
  import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
@@ -1342,9 +1343,9 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1342
1343
 
1343
1344
  export type { ${ClassName}WidgetProps }
1344
1345
  `.trim());
1345
- folder.subitem([
1346
- 'ui'
1347
- ]).createFile(`${uiFileName}.tsx`, `
1346
+ folder.subitem([
1347
+ 'ui'
1348
+ ]).createFile(`${uiFileName}.tsx`, `
1348
1349
  import { FC } from 'react'
1349
1350
  import type { ${ClassName}WidgetUIProps } from '../types'
1350
1351
 
@@ -1352,16 +1353,37 @@ export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
1352
1353
  return <></>
1353
1354
  }
1354
1355
  `.trim());
1355
- folder.subitem([
1356
- 'hooks'
1357
- ]).createFile(`${uiModelFileName}.ts`, `
1356
+ const { storybookFramework } = ConfigFile.Instance.data;
1357
+ if (storybookFramework) folder.subitem([
1358
+ 'ui'
1359
+ ]).createFile(`${uiFileName}.stories.tsx`, `
1360
+ import type { Meta, StoryObj } from '${storybookFramework}'
1361
+ import { ${ClassName}WidgetUI } from './${uiFileName}'
1362
+
1363
+ const meta = {
1364
+ title: 'Widgets/${ClassName}',
1365
+ component: ${ClassName}WidgetUI
1366
+ } satisfies Meta<typeof ${ClassName}WidgetUI>
1367
+
1368
+ export default meta
1369
+
1370
+ type Story = StoryObj<typeof meta>
1371
+
1372
+ export const Default: Story = {
1373
+ args: {}
1374
+ }
1375
+ `.trim());
1376
+ folder.subitem([
1377
+ 'hooks'
1378
+ ]).createFile(`${uiModelFileName}.ts`, `
1358
1379
  import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
1359
1380
 
1360
1381
  export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
1361
1382
  return {}
1362
1383
  }
1363
1384
  `.trim());
1364
- break;
1385
+ break;
1386
+ }
1365
1387
  case 'headless':
1366
1388
  folder.createFile('types.ts', `
1367
1389
  import { type FC } from 'react'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@domain-first/project-structure",
3
3
  "description": "Build and manage your Domain-First project structure with CLI",
4
- "version": "2.9.0",
4
+ "version": "2.9.1",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",