@starodubenko/fsd-gen 0.1.0 → 1.0.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -0
- package/dist/config/defineConfig.d.ts +1 -1
- package/dist/config/defineConfig.d.ts.map +1 -1
- package/dist/config/types.d.ts +59 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/generators/generate.d.ts +1 -5
- package/dist/lib/generators/generate.d.ts.map +1 -1
- package/dist/lib/generators/generate.js +2 -2
- package/dist/lib/helpers/presetHelpers.d.ts +1 -27
- package/dist/lib/helpers/presetHelpers.d.ts.map +1 -1
- package/dist/lib/helpers/presetHelpers.js +24 -9
- package/dist/lib/helpers/presetHelpers.spec.d.ts +2 -0
- package/dist/lib/helpers/presetHelpers.spec.d.ts.map +1 -0
- package/dist/lib/helpers/presetHelpers.spec.js +36 -0
- package/dist/lib/helpers/templateHelpers.d.ts +20 -0
- package/dist/lib/helpers/templateHelpers.d.ts.map +1 -0
- package/dist/lib/helpers/templateHelpers.js +23 -0
- package/dist/lib/jsx/components.d.ts +38 -0
- package/dist/lib/jsx/components.d.ts.map +1 -0
- package/dist/lib/jsx/components.js +40 -0
- package/dist/lib/jsx/jsx-runtime.d.ts +20 -0
- package/dist/lib/jsx/jsx-runtime.d.ts.map +1 -0
- package/dist/lib/jsx/jsx-runtime.js +7 -0
- package/dist/lib/jsx/renderer.d.ts +2 -0
- package/dist/lib/jsx/renderer.d.ts.map +1 -0
- package/dist/lib/jsx/renderer.js +24 -0
- package/dist/lib/preset/actionExecution.d.ts +2 -2
- package/dist/lib/preset/actionExecution.d.ts.map +1 -1
- package/dist/lib/preset/actionExecution.js +39 -4
- package/dist/lib/preset/actionExecution.spec.d.ts +2 -0
- package/dist/lib/preset/actionExecution.spec.d.ts.map +1 -0
- package/dist/lib/preset/actionExecution.spec.js +178 -0
- package/dist/lib/preset/presetDiscovery.d.ts +10 -4
- package/dist/lib/preset/presetDiscovery.d.ts.map +1 -1
- package/dist/lib/preset/presetDiscovery.js +29 -21
- package/dist/lib/preset/presetLoading.d.ts.map +1 -1
- package/dist/lib/preset/presetLoading.js +2 -1
- package/dist/lib/templates/templateLoader.d.ts +7 -5
- package/dist/lib/templates/templateLoader.d.ts.map +1 -1
- package/dist/lib/templates/templateLoader.js +44 -7
- package/package.json +2 -2
- package/templates/entity/model-ui-basic/Component.tsx +18 -7
- package/templates/feature/ui-model-basic/Component.tsx +18 -7
- package/templates/page/ui-basic/Component.tsx +18 -7
- package/templates/preset/table/entity/model.ts +10 -4
- package/templates/preset/table/feature/buttons.tsx +12 -6
- package/templates/preset/table/page/page.tsx +30 -8
- package/templates/preset/table/widget/table.tsx +28 -11
- package/templates/shared/ui-basic/Component.tsx +17 -6
- package/templates/widget/ui-basic/Component.tsx +18 -7
- package/templates/entity/model-ui-basic/Component.styles.ts +0 -1
- package/templates/feature/ui-model-basic/Component.styles.ts +0 -1
- package/templates/page/ui-basic/Component.styles.ts +0 -1
- package/templates/shared/ui-basic/Component.styles.ts +0 -1
- package/templates/widget/ui-basic/Component.styles.ts +0 -1
|
@@ -1,18 +1,29 @@
|
|
|
1
|
+
import type { GeneratorContext } from '../../../src/config/types.js';
|
|
2
|
+
|
|
3
|
+
export default (ctx: GeneratorContext) => {
|
|
4
|
+
const {
|
|
5
|
+
base: { baseName },
|
|
6
|
+
template: { componentName }
|
|
7
|
+
} = ctx;
|
|
8
|
+
|
|
9
|
+
return `
|
|
1
10
|
import styled from '@emotion/styled';
|
|
2
11
|
|
|
3
|
-
export const {
|
|
12
|
+
export const ${componentName}Root = styled.div\`
|
|
4
13
|
padding: 1rem;
|
|
5
14
|
border: 1px solid #ccc;
|
|
6
|
-
|
|
15
|
+
\`;
|
|
7
16
|
|
|
8
|
-
export interface {
|
|
17
|
+
export interface ${componentName}Props {
|
|
9
18
|
className?: string;
|
|
10
19
|
}
|
|
11
20
|
|
|
12
|
-
export const {
|
|
21
|
+
export const ${componentName} = ({ className }: ${componentName}Props) => {
|
|
13
22
|
return (
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
|
|
23
|
+
<${componentName}Root className={className}>
|
|
24
|
+
${componentName} Entity
|
|
25
|
+
</${componentName}Root>
|
|
17
26
|
);
|
|
18
27
|
};
|
|
28
|
+
`;
|
|
29
|
+
};
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
+
import type { GeneratorContext } from '../../../src/config/types.js';
|
|
2
|
+
|
|
3
|
+
export default (ctx: GeneratorContext) => {
|
|
4
|
+
const {
|
|
5
|
+
base: { baseName },
|
|
6
|
+
template: { componentName }
|
|
7
|
+
} = ctx;
|
|
8
|
+
|
|
9
|
+
return `
|
|
1
10
|
import styled from '@emotion/styled';
|
|
2
11
|
|
|
3
|
-
export const {
|
|
12
|
+
export const ${componentName}Root = styled.div\`
|
|
4
13
|
padding: 1rem;
|
|
5
|
-
|
|
14
|
+
\`;
|
|
6
15
|
|
|
7
|
-
export interface {
|
|
16
|
+
export interface ${componentName}Props {
|
|
8
17
|
className?: string;
|
|
9
18
|
}
|
|
10
19
|
|
|
11
|
-
export const {
|
|
20
|
+
export const ${componentName} = ({ className }: ${componentName}Props) => {
|
|
12
21
|
return (
|
|
13
|
-
|
|
14
|
-
Feature: {
|
|
15
|
-
|
|
22
|
+
<${componentName}Root className={className}>
|
|
23
|
+
Feature: ${componentName}
|
|
24
|
+
</${componentName}Root>
|
|
16
25
|
);
|
|
17
26
|
};
|
|
27
|
+
`;
|
|
28
|
+
};
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
+
import type { GeneratorContext } from '../../../src/config/types.js';
|
|
2
|
+
|
|
3
|
+
export default (ctx: GeneratorContext) => {
|
|
4
|
+
const {
|
|
5
|
+
base: { baseName },
|
|
6
|
+
template: { componentName }
|
|
7
|
+
} = ctx;
|
|
8
|
+
|
|
9
|
+
return `
|
|
1
10
|
import styled from '@emotion/styled';
|
|
2
11
|
|
|
3
|
-
export const {
|
|
12
|
+
export const ${componentName}Root = styled.div\`
|
|
4
13
|
min-height: 100vh;
|
|
5
|
-
|
|
14
|
+
\`;
|
|
6
15
|
|
|
7
|
-
export interface {
|
|
16
|
+
export interface ${componentName}Props {
|
|
8
17
|
className?: string;
|
|
9
18
|
}
|
|
10
19
|
|
|
11
|
-
export const {
|
|
20
|
+
export const ${componentName} = ({ className }: ${componentName}Props) => {
|
|
12
21
|
return (
|
|
13
|
-
|
|
14
|
-
<h1>Page: {
|
|
15
|
-
|
|
22
|
+
<${componentName}Root className={className}>
|
|
23
|
+
<h1>Page: ${componentName}</h1>
|
|
24
|
+
</${componentName}Root>
|
|
16
25
|
);
|
|
17
26
|
};
|
|
27
|
+
`;
|
|
28
|
+
};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import type { GeneratorContext } from '../../../../src/config/types.js';
|
|
2
|
+
|
|
3
|
+
export default (ctx: GeneratorContext) => {
|
|
4
|
+
const { base: { baseName } } = ctx;
|
|
5
|
+
return `export interface ${baseName} {
|
|
2
6
|
id: string;
|
|
3
7
|
name: string;
|
|
4
8
|
}
|
|
5
9
|
|
|
6
|
-
export const mock{
|
|
7
|
-
{ id: '1', name: 'Test {
|
|
8
|
-
{ id: '2', name: 'Test {
|
|
10
|
+
export const mock${baseName}Data: ${baseName}[] = [
|
|
11
|
+
{ id: '1', name: 'Test ${baseName} 1' },
|
|
12
|
+
{ id: '2', name: 'Test ${baseName} 2' },
|
|
9
13
|
];
|
|
14
|
+
`;
|
|
15
|
+
};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { GeneratorContext } from '../../../../src/config/types.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default (ctx: GeneratorContext) => {
|
|
4
|
+
const { base: { baseName } } = ctx;
|
|
5
|
+
return `import styled from '@emotion/styled';
|
|
6
|
+
|
|
7
|
+
const Button = styled.button\`
|
|
4
8
|
padding: 8px 16px;
|
|
5
9
|
margin: 0 4px;
|
|
6
10
|
cursor: pointer;
|
|
7
|
-
|
|
11
|
+
\`;
|
|
8
12
|
|
|
9
|
-
export const Create{
|
|
10
|
-
export const Edit{
|
|
11
|
-
export const Delete{
|
|
13
|
+
export const Create${baseName}Button = () => <Button>Create</Button>;
|
|
14
|
+
export const Edit${baseName}Button = () => <Button>Edit</Button>;
|
|
15
|
+
export const Delete${baseName}Button = () => <Button>Delete</Button>;
|
|
16
|
+
`;
|
|
17
|
+
};
|
|
@@ -1,19 +1,41 @@
|
|
|
1
|
+
import type { GeneratorContext } from '../../../../src/config/types.js';
|
|
2
|
+
|
|
3
|
+
export default (ctx: GeneratorContext) => {
|
|
4
|
+
const {
|
|
5
|
+
base: { baseName },
|
|
6
|
+
template: { componentName },
|
|
7
|
+
layer: {
|
|
8
|
+
widget: { importPath: widgetImportPath, slice: widgetSlice }
|
|
9
|
+
}
|
|
10
|
+
} = ctx;
|
|
11
|
+
|
|
12
|
+
// Ideally the widget name would be dynamic, but in this specific preset it's often Table
|
|
13
|
+
// However, the componentName here is the Page component name (e.g. UserPage)
|
|
14
|
+
// The widget slice/component might be UserTable.
|
|
15
|
+
|
|
16
|
+
// We need the widget component name.
|
|
17
|
+
// In the 'table' preset, the widget is typically `${baseName}Table`.
|
|
18
|
+
const widgetComponent = `${baseName}Table`;
|
|
19
|
+
|
|
20
|
+
return `
|
|
1
21
|
import styled from '@emotion/styled';
|
|
2
|
-
import { {
|
|
22
|
+
import { ${widgetComponent} } from '${widgetImportPath}';
|
|
3
23
|
|
|
4
|
-
const PageWrapper = styled.div
|
|
24
|
+
const PageWrapper = styled.div\`
|
|
5
25
|
padding: 2rem;
|
|
6
|
-
|
|
26
|
+
\`;
|
|
7
27
|
|
|
8
|
-
const Title = styled.h1
|
|
28
|
+
const Title = styled.h1\`
|
|
9
29
|
margin-bottom: 2rem;
|
|
10
|
-
|
|
30
|
+
\`;
|
|
11
31
|
|
|
12
|
-
export const {
|
|
32
|
+
export const ${componentName} = () => {
|
|
13
33
|
return (
|
|
14
34
|
<PageWrapper>
|
|
15
|
-
<Title
|
|
16
|
-
|
|
35
|
+
<Title>${baseName} Management</Title>
|
|
36
|
+
<${widgetComponent} />
|
|
17
37
|
</PageWrapper>
|
|
18
38
|
);
|
|
19
39
|
};
|
|
40
|
+
`;
|
|
41
|
+
};
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
import type { GeneratorContext } from '../../../../src/config/types.js';
|
|
2
|
+
|
|
3
|
+
export default (ctx: GeneratorContext) => {
|
|
4
|
+
const {
|
|
5
|
+
base: { baseName },
|
|
6
|
+
template: { componentName },
|
|
7
|
+
layer: {
|
|
8
|
+
entity: { apiPath: entityApiPath },
|
|
9
|
+
features: { importPath: featureImportPath }
|
|
10
|
+
}
|
|
11
|
+
} = ctx;
|
|
12
|
+
|
|
13
|
+
return `
|
|
1
14
|
import styled from '@emotion/styled';
|
|
2
|
-
import { {
|
|
3
|
-
|
|
15
|
+
import { ${baseName}, mock${baseName}Data } from '${entityApiPath}';
|
|
16
|
+
// Note: Assuming specific button names based on feature convention, or should be generic?
|
|
17
|
+
// For the Table preset, it assumes Create/Edit/Delete buttons exist in the feature slice.
|
|
18
|
+
import { Create${baseName}Button, Edit${baseName}Button, Delete${baseName}Button } from '${featureImportPath}';
|
|
4
19
|
|
|
5
|
-
const TableWrapper = styled.div
|
|
20
|
+
const TableWrapper = styled.div\`
|
|
6
21
|
border: 1px solid #eee;
|
|
7
22
|
padding: 1rem;
|
|
8
|
-
|
|
23
|
+
\`;
|
|
9
24
|
|
|
10
|
-
const Table = styled.table
|
|
25
|
+
const Table = styled.table\`
|
|
11
26
|
width: 100%;
|
|
12
27
|
border-collapse: collapse;
|
|
13
28
|
|
|
@@ -16,13 +31,13 @@ const Table = styled.table`
|
|
|
16
31
|
padding: 8px;
|
|
17
32
|
text-align: left;
|
|
18
33
|
}
|
|
19
|
-
|
|
34
|
+
\`;
|
|
20
35
|
|
|
21
|
-
export const {
|
|
36
|
+
export const ${componentName} = () => {
|
|
22
37
|
return (
|
|
23
38
|
<TableWrapper>
|
|
24
39
|
<div style={{ marginBottom: '1rem' }}>
|
|
25
|
-
<Create{
|
|
40
|
+
<Create${baseName}Button />
|
|
26
41
|
</div>
|
|
27
42
|
<Table>
|
|
28
43
|
<thead>
|
|
@@ -33,13 +48,13 @@ export const {{componentName}}Table = () => {
|
|
|
33
48
|
</tr>
|
|
34
49
|
</thead>
|
|
35
50
|
<tbody>
|
|
36
|
-
{mock{
|
|
51
|
+
{mock${baseName}Data.map((item) => (
|
|
37
52
|
<tr key={item.id}>
|
|
38
53
|
<td>{item.id}</td>
|
|
39
54
|
<td>{item.name}</td>
|
|
40
55
|
<td>
|
|
41
|
-
<Edit{
|
|
42
|
-
<Delete{
|
|
56
|
+
<Edit${baseName}Button />
|
|
57
|
+
<Delete${baseName}Button />
|
|
43
58
|
</td>
|
|
44
59
|
</tr>
|
|
45
60
|
))}
|
|
@@ -48,3 +63,5 @@ export const {{componentName}}Table = () => {
|
|
|
48
63
|
</TableWrapper>
|
|
49
64
|
);
|
|
50
65
|
};
|
|
66
|
+
`;
|
|
67
|
+
};
|
|
@@ -1,18 +1,29 @@
|
|
|
1
|
+
import type { GeneratorContext } from '../../../src/config/types.js';
|
|
2
|
+
|
|
3
|
+
export default (ctx: GeneratorContext) => {
|
|
4
|
+
const {
|
|
5
|
+
base: { baseName },
|
|
6
|
+
template: { componentName }
|
|
7
|
+
} = ctx;
|
|
8
|
+
|
|
9
|
+
return `
|
|
1
10
|
import styled from '@emotion/styled';
|
|
2
11
|
|
|
3
|
-
export const {
|
|
12
|
+
export const ${componentName}Root = styled.div\`
|
|
4
13
|
display: flex;
|
|
5
|
-
|
|
14
|
+
\`;
|
|
6
15
|
|
|
7
|
-
export interface {
|
|
16
|
+
export interface ${componentName}Props {
|
|
8
17
|
className?: string;
|
|
9
18
|
children?: React.ReactNode;
|
|
10
19
|
}
|
|
11
20
|
|
|
12
|
-
export const {
|
|
21
|
+
export const ${componentName} = ({ className, children }: ${componentName}Props) => {
|
|
13
22
|
return (
|
|
14
|
-
|
|
23
|
+
<${componentName}Root className={className}>
|
|
15
24
|
{children}
|
|
16
|
-
|
|
25
|
+
</${componentName}Root>
|
|
17
26
|
);
|
|
18
27
|
};
|
|
28
|
+
`;
|
|
29
|
+
};
|
|
@@ -1,18 +1,29 @@
|
|
|
1
|
+
import type { GeneratorContext } from '../../../src/config/types.js';
|
|
2
|
+
|
|
3
|
+
export default (ctx: GeneratorContext) => {
|
|
4
|
+
const {
|
|
5
|
+
base: { baseName },
|
|
6
|
+
template: { componentName }
|
|
7
|
+
} = ctx;
|
|
8
|
+
|
|
9
|
+
return `
|
|
1
10
|
import styled from '@emotion/styled';
|
|
2
11
|
|
|
3
|
-
export const {
|
|
12
|
+
export const ${componentName}Root = styled.div\`
|
|
4
13
|
display: grid;
|
|
5
14
|
gap: 1rem;
|
|
6
|
-
|
|
15
|
+
\`;
|
|
7
16
|
|
|
8
|
-
export interface {
|
|
17
|
+
export interface ${componentName}Props {
|
|
9
18
|
className?: string;
|
|
10
19
|
}
|
|
11
20
|
|
|
12
|
-
export const {
|
|
21
|
+
export const ${componentName} = ({ className }: ${componentName}Props) => {
|
|
13
22
|
return (
|
|
14
|
-
|
|
15
|
-
Widget: {
|
|
16
|
-
|
|
23
|
+
<${componentName}Root className={className}>
|
|
24
|
+
Widget: ${componentName}
|
|
25
|
+
</${componentName}Root>
|
|
17
26
|
);
|
|
18
27
|
};
|
|
28
|
+
`;
|
|
29
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// Styles for {{componentName}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// Styles for Feature {{componentName}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// Styles for Page {{componentName}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// Styles for {{componentName}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// Styles for Widget {{componentName}}
|