@tpitre/story-ui 3.10.5 → 3.10.6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-adapter.d.ts","sourceRoot":"","sources":["../../../story-generator/framework-adapters/angular-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,qBAAa,cAAe,SAAQ,oBAAoB;IACtD,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAa;IACzC,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,cAAc,EAAE,CAGjD;IACF,QAAQ,CAAC,gBAAgB,iBAAiB;IAE1C,oBAAoB,CAClB,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM;
|
|
1
|
+
{"version":3,"file":"angular-adapter.d.ts","sourceRoot":"","sources":["../../../story-generator/framework-adapters/angular-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,qBAAa,cAAe,SAAQ,oBAAoB;IACtD,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAa;IACzC,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,cAAc,EAAE,CAGjD;IACF,QAAQ,CAAC,gBAAgB,iBAAiB;IAE1C,oBAAoB,CAClB,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM;IAsJT,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;IAmL/C,mBAAmB,CACjB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,GAChC,MAAM;IAqDT,gBAAgB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM;IA4B1D;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACH,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAkBzC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE;CA+CrE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAErD"}
|
|
@@ -45,6 +45,26 @@ CRITICAL RULES:
|
|
|
45
45
|
- Use Angular template syntax in render functions
|
|
46
46
|
- Event bindings use (event) syntax
|
|
47
47
|
|
|
48
|
+
TYPESCRIPT STRICT MODE COMPATIBILITY (CRITICAL):
|
|
49
|
+
- NEVER use "this.property" syntax in render functions or templates
|
|
50
|
+
- NEVER try to manage state with "this.isEnabled", "this.clickCount++", etc.
|
|
51
|
+
- Angular Storybook stories should be STATELESS - show component states via args
|
|
52
|
+
- For interactive demos, use argTypes with action: 'actionName' for event logging
|
|
53
|
+
- The args object has an index signature - direct property access causes TS4111 errors
|
|
54
|
+
|
|
55
|
+
CORRECT PATTERNS FOR INTERACTIVITY:
|
|
56
|
+
1. For events - use argTypes actions, NOT state management:
|
|
57
|
+
argTypes: { onChange: { action: 'changed' } }
|
|
58
|
+
|
|
59
|
+
2. For showing states - create separate stories:
|
|
60
|
+
export const Enabled: Story = { args: { checked: true } };
|
|
61
|
+
export const Disabled: Story = { args: { checked: false } };
|
|
62
|
+
|
|
63
|
+
3. NEVER generate code like:
|
|
64
|
+
- this.isEnabled = event.checked; // TS4111 ERROR
|
|
65
|
+
- this.clickCount++; // TS4111 ERROR
|
|
66
|
+
- props.someValue = newValue; // Will not work
|
|
67
|
+
|
|
48
68
|
Example structure (Standalone Components):
|
|
49
69
|
\`\`\`typescript
|
|
50
70
|
import type { Meta, StoryObj } from '@storybook/angular';
|
|
@@ -231,7 +251,7 @@ export const ProductCard: Story = {
|
|
|
231
251
|
};
|
|
232
252
|
\`\`\`
|
|
233
253
|
|
|
234
|
-
### With Event Handling
|
|
254
|
+
### With Event Handling (STATELESS - CORRECT PATTERN)
|
|
235
255
|
\`\`\`typescript
|
|
236
256
|
import type { Meta, StoryObj } from '@storybook/angular';
|
|
237
257
|
import { applicationConfig } from '@storybook/angular';
|
|
@@ -246,14 +266,16 @@ const meta: Meta<ButtonComponent> = {
|
|
|
246
266
|
}),
|
|
247
267
|
],
|
|
248
268
|
argTypes: {
|
|
249
|
-
// Use argTypes with action for event logging
|
|
269
|
+
// Use argTypes with action for event logging - DO NOT manage state
|
|
250
270
|
onClick: { action: 'clicked' },
|
|
271
|
+
onToggle: { action: 'toggled' },
|
|
251
272
|
},
|
|
252
273
|
};
|
|
253
274
|
|
|
254
275
|
export default meta;
|
|
255
276
|
type Story = StoryObj<ButtonComponent>;
|
|
256
277
|
|
|
278
|
+
// CORRECT: Events logged via argTypes actions
|
|
257
279
|
export const WithClick: Story = {
|
|
258
280
|
render: (args) => ({
|
|
259
281
|
props: args,
|
|
@@ -264,6 +286,23 @@ export const WithClick: Story = {
|
|
|
264
286
|
\`,
|
|
265
287
|
}),
|
|
266
288
|
};
|
|
289
|
+
|
|
290
|
+
// CORRECT: Show different states via separate stories
|
|
291
|
+
export const EnabledState: Story = {
|
|
292
|
+
args: { disabled: false },
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export const DisabledState: Story = {
|
|
296
|
+
args: { disabled: true },
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// WRONG - DO NOT DO THIS (causes TS4111 error):
|
|
300
|
+
// export const Interactive: Story = {
|
|
301
|
+
// render: (args) => ({
|
|
302
|
+
// props: { ...args, isEnabled: false },
|
|
303
|
+
// template: \`<mat-slide-toggle (change)="this.isEnabled = $event.checked">\`,
|
|
304
|
+
// }),
|
|
305
|
+
// };
|
|
267
306
|
\`\`\`
|
|
268
307
|
|
|
269
308
|
### With Forms
|
|
@@ -422,6 +461,22 @@ export const Default: Story = {
|
|
|
422
461
|
!storyContent.includes('component:')) {
|
|
423
462
|
errors.push('Missing moduleMetadata or applicationConfig decorator');
|
|
424
463
|
}
|
|
464
|
+
// Check for TS4111-causing patterns (noPropertyAccessFromIndexSignature)
|
|
465
|
+
// These patterns cause errors when strict TypeScript is enabled
|
|
466
|
+
const ts4111Patterns = [
|
|
467
|
+
/this\.\w+\s*=\s*\w+/g, // this.property = value
|
|
468
|
+
/this\.\w+\+\+/g, // this.property++
|
|
469
|
+
/this\.\w+--/g, // this.property--
|
|
470
|
+
/\+\+this\.\w+/g, // ++this.property
|
|
471
|
+
/--this\.\w+/g, // --this.property
|
|
472
|
+
];
|
|
473
|
+
for (const pattern of ts4111Patterns) {
|
|
474
|
+
if (pattern.test(storyContent)) {
|
|
475
|
+
errors.push('Angular stories should not use "this.property" state management. ' +
|
|
476
|
+
'Use args-based patterns instead. This causes TS4111 errors with strict TypeScript.');
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
425
480
|
return {
|
|
426
481
|
valid: errors.length === 0,
|
|
427
482
|
errors,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storyValidator.d.ts","sourceRoot":"","sources":["../../story-generator/storyValidator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"storyValidator.d.ts","sourceRoot":"","sources":["../../story-generator/storyValidator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,eAAe,EAAE,CAmDrE"}
|
|
@@ -13,6 +13,10 @@ export function validateStory(storyContent) {
|
|
|
13
13
|
{ pattern: /slot:\s*['"][^'"]+['"]/i, message: 'The slot property in render functions does not work in Svelte Storybook. Use simple args-based stories instead.' },
|
|
14
14
|
// Catch abbreviated Material icon names that will render as text instead of icons
|
|
15
15
|
{ pattern: /<mat-icon>\s*(fav|ho|de|se|sta|che|add|rem|edi|sav|can|men|clo|sea)\s*<\/mat-icon>/i, message: 'Material icon name appears to be abbreviated. Use full icon names: "favorite" (not "fav"), "home" (not "ho"), "delete" (not "de"), "settings" (not "se"), etc.' },
|
|
16
|
+
// Catch Angular TS4111 patterns - "this.property" state management in render functions
|
|
17
|
+
{ pattern: /this\.\w+\s*=\s*\$?event\./i, message: 'Do not use "this.property = event.value" in Angular stories. This causes TS4111 errors. Use argTypes with action property for events and create separate stories for different states.' },
|
|
18
|
+
{ pattern: /this\.\w+\+\+/i, message: 'Do not use "this.property++" in Angular stories. This causes TS4111 errors. Use argTypes with action property for events instead of managing state.' },
|
|
19
|
+
{ pattern: /this\.\w+--/i, message: 'Do not use "this.property--" in Angular stories. This causes TS4111 errors. Use argTypes with action property for events instead of managing state.' },
|
|
16
20
|
];
|
|
17
21
|
lines.forEach((line, index) => {
|
|
18
22
|
for (const { pattern, message } of forbiddenPatterns) {
|