create-stencil-components 1.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/LICENSE +21 -0
- package/LICENSE.md +21 -0
- package/README.md +55 -0
- package/dist/index.mjs +396 -0
- package/dist/index.mjs.map +1 -0
- package/dist/templates/base/.editorconfig +15 -0
- package/dist/templates/base/.eslintignore +4 -0
- package/dist/templates/base/.gemini/settings.json +13 -0
- package/dist/templates/base/.husky/commit-msg +1 -0
- package/dist/templates/base/.husky/install.mjs +6 -0
- package/dist/templates/base/.husky/pre-commit +2 -0
- package/dist/templates/base/.mcp.json +12 -0
- package/dist/templates/base/.nvmrc +1 -0
- package/dist/templates/base/.prettierignore +2 -0
- package/dist/templates/base/.stylelintignore +0 -0
- package/dist/templates/base/AGENTS.md +118 -0
- package/dist/templates/base/CLAUDE.md +16 -0
- package/dist/templates/base/README.md +83 -0
- package/dist/templates/base/commitlint.config.mjs +1 -0
- package/dist/templates/base/docs/CODE_OF_CONDUCT.md +122 -0
- package/dist/templates/base/docs/CONTRIBUTING.md +103 -0
- package/dist/templates/base/docs/LICENSE.md +21 -0
- package/dist/templates/base/docs/RELEASE.md +95 -0
- package/dist/templates/base/docs/STYLE_GUIDE.md +128 -0
- package/dist/templates/base/eslint.config.mjs +37 -0
- package/dist/templates/base/gitignore +32 -0
- package/dist/templates/base/nx.json +36 -0
- package/dist/templates/base/package.json +43 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/CHANGELOG.md +0 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/README.md +74 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/project.json +144 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/components/my-component/my-component.scss +3 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/components/my-component/my-component.tsx +32 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/components/my-component/readme.md +19 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/components/my-component/test/my-component.e2e.ts +32 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/components/my-component/test/my-component.spec.ts +36 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/components.d.ts +61 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/index.html +14 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/index.ts +12 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/main.scss +0 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/utils/utils.spec.ts +19 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/utils/utils.ts +3 -0
- package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/tsconfig.json +12 -0
- package/dist/templates/base/prettier.config.mjs +19 -0
- package/dist/templates/base/stylelint.config.mjs +25 -0
- package/dist/templates/base/tsconfig.base.json +23 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/CHANGELOG.md +0 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/README.md +108 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/ng-package.json +6 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/package.json +27 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/project.json +93 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/src/components-{{PROJECT_NAME_KEBAB}}.module.ts +20 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/src/directives/.gitkeep +0 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/src/index.ts +3 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/standalone/ng-package.json +6 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/standalone/src/directives/.gitkeep +0 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/standalone/src/index.ts +1 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-angular/tsconfig.json +41 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +85 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-core/stencil.config.ts +90 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/CHANGELOG.md +0 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/README.md +97 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/package.json +48 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/project.json +92 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/src/components/index.ts +1 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/src/index.ts +1 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/tsconfig.json +36 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-vue/CHANGELOG.md +0 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-vue/README.md +78 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-vue/package.json +43 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-vue/project.json +92 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-vue/src/components/index.ts +1 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-vue/src/index.ts +1 -0
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-vue/tsconfig.json +39 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/CHANGELOG.md +0 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/README.md +108 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/ng-package.json +6 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/package.json +27 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/project.json +93 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/src/components-{{PROJECT_NAME_KEBAB}}.module.ts +20 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/src/directives/.gitkeep +0 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/src/index.ts +3 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/standalone/ng-package.json +6 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/standalone/src/directives/.gitkeep +0 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/standalone/src/index.ts +1 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-angular/tsconfig.json +41 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +83 -0
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-core/stencil.config.ts +72 -0
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +83 -0
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-core/stencil.config.ts +67 -0
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/CHANGELOG.md +0 -0
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/README.md +97 -0
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/package.json +48 -0
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/project.json +92 -0
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/src/components/index.ts +1 -0
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/src/index.ts +1 -0
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/tsconfig.json +36 -0
- package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +83 -0
- package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-core/stencil.config.ts +67 -0
- package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-vue/CHANGELOG.md +0 -0
- package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-vue/README.md +78 -0
- package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-vue/package.json +43 -0
- package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-vue/project.json +92 -0
- package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-vue/src/components/index.ts +1 -0
- package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-vue/src/index.ts +1 -0
- package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-vue/tsconfig.json +39 -0
- package/dist/templates/variants/web-components/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +82 -0
- package/dist/templates/variants/web-components/packages/components-{{PROJECT_NAME_KEBAB}}-core/stencil.config.ts +58 -0
- package/package.json +60 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Style Guide
|
|
2
|
+
|
|
3
|
+
## 1. Component Architecture
|
|
4
|
+
|
|
5
|
+
### Naming Conventions
|
|
6
|
+
|
|
7
|
+
- **Tag Name:** The prefix has a major role when you are creating a collection of components intended to be used across different projects. Web Components are not scoped because they are globally declared within the webpage, which means an "unique" prefix is needed to prevent collisions. Must be lowercase and hyphenated (kebab-case). It must include at least one hyphen to comply with W3C Custom Element standards.
|
|
8
|
+
- *Good:* `my-data-table`, `ui-button`
|
|
9
|
+
- *Bad:* `myDataTable`, `uibutton`
|
|
10
|
+
- **Class Name:** Use PascalCase for the TypeScript class name, matching the component tag without hyphens.
|
|
11
|
+
- *Example:* `<my-data-table>` becomes `class MyDataTable`.
|
|
12
|
+
- **File Names:** Name files after the tag name.
|
|
13
|
+
- *Example:* `my-button.tsx`, `my-button.css`, `my-button.spec.ts`.
|
|
14
|
+
|
|
15
|
+
### Directory Structure
|
|
16
|
+
|
|
17
|
+
Each component should reside in its own folder within `src/components/`:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
src/components/my-component/
|
|
21
|
+
│── test/
|
|
22
|
+
│ ├── my-component.e2e.ts (End-to-end tests
|
|
23
|
+
│ └── my-component.spec.ts (Unit tests)
|
|
24
|
+
├── my-component.scss
|
|
25
|
+
├── my-component.tsx
|
|
26
|
+
└── readme.md (Auto-generated)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 2. TypeScript Standards
|
|
30
|
+
|
|
31
|
+
### Member Ordering
|
|
32
|
+
|
|
33
|
+
Maintain a consistent order for class members to improve readability:
|
|
34
|
+
|
|
35
|
+
1. **Properties:** `@Element()`, `@Prop()`, `@State()`
|
|
36
|
+
2. **Internal Variables:** Private/Protected properties
|
|
37
|
+
3. **Events:** `@Event()`
|
|
38
|
+
4. **Watchers:** `@Watch()`
|
|
39
|
+
5. **Lifecycle Hooks:** `connectedCallback`, `componentWillLoad`, etc.
|
|
40
|
+
6. **Methods:** `@Listen()`, `@Method()`, then private helper methods
|
|
41
|
+
7. **Render:** `render()`
|
|
42
|
+
|
|
43
|
+
### Typing
|
|
44
|
+
|
|
45
|
+
- **Strictness:** Always enable `strict: true` in `tsconfig.json`.
|
|
46
|
+
- **Explicit Returns:** Define return types for all functions and `@Method()` calls.
|
|
47
|
+
- **Interfaces:** Prefix interfaces with `I` (optional, based on preference) or place them in a shared `types.ts` file if used by multiple components.
|
|
48
|
+
|
|
49
|
+
## 3. Stencil Decorator Usage
|
|
50
|
+
|
|
51
|
+
### Props (@Prop)
|
|
52
|
+
|
|
53
|
+
- Use **camelCase** for property names in TypeScript. Stencil automatically maps these to **kebab-case** attributes in HTML.
|
|
54
|
+
- **Initialization:** Always provide a default value if a prop is not required.
|
|
55
|
+
- **Immutability:** Set `mutable: true` only when the component needs to modify its own prop.
|
|
56
|
+
|
|
57
|
+
### State (@State)
|
|
58
|
+
|
|
59
|
+
- Use `@State()` for any internal data that should trigger a re-render.
|
|
60
|
+
- For objects and arrays, use **immutable updates**:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// Good
|
|
64
|
+
this.items = [...this.items, 'new-item'];
|
|
65
|
+
// Bad
|
|
66
|
+
this.items.push('new-item');
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Events (@Event)
|
|
70
|
+
|
|
71
|
+
- Use **camelCase** for event names (e.g., `todoCompleted`).
|
|
72
|
+
- Provide specific types for the `EventEmitter` payload: `EventEmitter<ISearchResult>`.
|
|
73
|
+
|
|
74
|
+
## 4. JSX & Rendering
|
|
75
|
+
|
|
76
|
+
### The `<Host>` Element
|
|
77
|
+
|
|
78
|
+
Always use the `<Host>` component as the top-level element in your `render()` function to manage attributes and classes on the custom element itself.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
render() {
|
|
82
|
+
return (
|
|
83
|
+
<Host class={{ 'is-active': this.isActive }}>
|
|
84
|
+
<slot />
|
|
85
|
+
</Host>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Conditional Rendering
|
|
91
|
+
|
|
92
|
+
Use ternary operators or short-circuit evaluation for simple conditions. For complex logic, extract the JSX to a private method.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
render() {
|
|
96
|
+
return (
|
|
97
|
+
<div>
|
|
98
|
+
{this.isLoading ? <spinner-icon /> : <slot />}
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 5. CSS & Styling
|
|
105
|
+
|
|
106
|
+
### Shadow DOM
|
|
107
|
+
|
|
108
|
+
- Use `shadow: true` by default.
|
|
109
|
+
- Use **CSS Variables** for any values that need to be "themeable" from outside the component.
|
|
110
|
+
- **Naming:** Follow BEM (Block Element Modifier) if not using scoped CSS, or simple descriptive classes if using Shadow DOM.
|
|
111
|
+
|
|
112
|
+
### Selectors
|
|
113
|
+
|
|
114
|
+
- Use `:host` to style the component container.
|
|
115
|
+
- Use `:host-context(.dark-theme)` for theme-dependent styling.
|
|
116
|
+
- Use `::slotted(selector)` to style elements passed into a slot.
|
|
117
|
+
|
|
118
|
+
## 6. Performance
|
|
119
|
+
|
|
120
|
+
- **Minimize @Watch:** Only use `@Watch` when you need to perform side effects (like fetching data) in response to a prop change. Avoid using it to sync state.
|
|
121
|
+
- **Lazy Loading:** Keep component logic lean. If a library is large, consider dynamic imports inside `componentWillLoad`.
|
|
122
|
+
- **Ref usage:** Avoid direct DOM manipulation. Use `ref={(el) => this.myElement = el}` only when absolutely necessary.
|
|
123
|
+
|
|
124
|
+
## 7. Testing & Quality
|
|
125
|
+
|
|
126
|
+
- **Unit Tests:** Test logic, formatting, and state changes in `.spec.ts`.
|
|
127
|
+
- **E2E Tests:** Test DOM rendering and event firing in `.e2e.ts`.
|
|
128
|
+
- **Comments:** Use JSDoc for all public `@Prop` and `@Method` members to ensure the generated `readme.md` is helpful for consumers.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import { defineConfig } from 'eslint/config';
|
|
4
|
+
import tseslint from 'typescript-eslint';
|
|
5
|
+
import sonarlint from 'eslint-plugin-sonarjs';
|
|
6
|
+
import tsParser from '@typescript-eslint/parser';
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
extends: [
|
|
10
|
+
eslint.configs.recommended,
|
|
11
|
+
sonarlint.configs.recommended,
|
|
12
|
+
tseslint.configs.recommended,
|
|
13
|
+
tseslint.configs.strict,
|
|
14
|
+
tseslint.configs.stylistic
|
|
15
|
+
],
|
|
16
|
+
files: ['**/**.{ts,tsx}'],
|
|
17
|
+
languageOptions: {
|
|
18
|
+
ecmaVersion: 2022,
|
|
19
|
+
globals: {
|
|
20
|
+
...globals.browser,
|
|
21
|
+
...globals.jest
|
|
22
|
+
},
|
|
23
|
+
parser: tsParser
|
|
24
|
+
},
|
|
25
|
+
plugins: {
|
|
26
|
+
sonarlint: sonarlint
|
|
27
|
+
},
|
|
28
|
+
rules: {
|
|
29
|
+
"sonarjs/unused-import": "off",
|
|
30
|
+
"@typescript-eslint/no-unused-vars": [
|
|
31
|
+
"warn",
|
|
32
|
+
{
|
|
33
|
+
"varsIgnorePattern": "^(h|Fragment)$"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
}
|
|
37
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
dist/
|
|
2
|
+
www/
|
|
3
|
+
loader/
|
|
4
|
+
generated/
|
|
5
|
+
|
|
6
|
+
*~
|
|
7
|
+
*.sw[mnpcod]
|
|
8
|
+
*.log
|
|
9
|
+
*.lock
|
|
10
|
+
*.tmp
|
|
11
|
+
*.tmp.*
|
|
12
|
+
log.txt
|
|
13
|
+
*.sublime-project
|
|
14
|
+
*.sublime-workspace
|
|
15
|
+
|
|
16
|
+
.stencil/
|
|
17
|
+
.idea/
|
|
18
|
+
.vscode/
|
|
19
|
+
.sass-cache/
|
|
20
|
+
.versions/
|
|
21
|
+
node_modules/
|
|
22
|
+
$RECYCLE.BIN/
|
|
23
|
+
|
|
24
|
+
.DS_Store
|
|
25
|
+
Thumbs.db
|
|
26
|
+
UserInterfaceState.xcuserstate
|
|
27
|
+
.env
|
|
28
|
+
|
|
29
|
+
.nx/cache
|
|
30
|
+
.nx/workspace-data
|
|
31
|
+
.cursor/rules/nx-rules.mdc
|
|
32
|
+
.github/instructions/nx.instructions.md
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./node_modules/nx/presets/npm.json",
|
|
3
|
+
"$schema": "./node_modules/nx/schemas/nx-schema.json",
|
|
4
|
+
"defaultBase": "master",
|
|
5
|
+
"release": {
|
|
6
|
+
"changelog": {
|
|
7
|
+
"projectChangelogs": {
|
|
8
|
+
"renderOptions": {
|
|
9
|
+
"authors": false,
|
|
10
|
+
"applyUsernameToAuthors": false,
|
|
11
|
+
"commitReferences": false,
|
|
12
|
+
"versionTitleDate": false
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"workspaceChangelog": false
|
|
16
|
+
},
|
|
17
|
+
"git": {
|
|
18
|
+
"commit": false,
|
|
19
|
+
"tag": false
|
|
20
|
+
},
|
|
21
|
+
"groups": {
|
|
22
|
+
"components": {
|
|
23
|
+
"projects": ["packages/*"],
|
|
24
|
+
"projectsRelationship": "fixed"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"version": {
|
|
28
|
+
"conventionalCommits": false,
|
|
29
|
+
"preVersionCommand": "npx nx run-many -t clean,build",
|
|
30
|
+
"versionPrefix": ""
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"tui": {
|
|
34
|
+
"enabled": true
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@{{ORGANIZATION_NAME}}/{{PROJECT_NAME_KEBAB}}",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Build modern, lightning-fast web applications for any platform using a single codebase",
|
|
5
|
+
"license": "{{LICENSE}}",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"agnostic",
|
|
8
|
+
"stencil",
|
|
9
|
+
"stenciljs",
|
|
10
|
+
"web components"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"prepare": "node .husky/install.mjs"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@commitlint/cli": "20.2.0",
|
|
17
|
+
"@commitlint/config-conventional": "20.2.0",
|
|
18
|
+
"@eslint/js": "9.39.2",
|
|
19
|
+
"@nx/js": "22.3.3",
|
|
20
|
+
"eslint": "9.39.2",
|
|
21
|
+
"eslint-config-prettier": "10.1.8",
|
|
22
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
23
|
+
"eslint-plugin-sonarjs": "3.0.5",
|
|
24
|
+
"husky": "9.1.7",
|
|
25
|
+
"nx": "22.3.3",
|
|
26
|
+
"rimraf": "6.1.2",
|
|
27
|
+
"stylelint": "16.26.1",
|
|
28
|
+
"stylelint-config-standard": "39.0.1",
|
|
29
|
+
"stylelint-config-standard-scss": "16.0.0",
|
|
30
|
+
"stylelint-use-logical": "2.1.2",
|
|
31
|
+
"ts-node": "10.9.2",
|
|
32
|
+
"typescript": "5.9.3",
|
|
33
|
+
"typescript-eslint": "8.50.1"
|
|
34
|
+
},
|
|
35
|
+
"nx": {},
|
|
36
|
+
"volta": {
|
|
37
|
+
"node": "25.2.1"
|
|
38
|
+
},
|
|
39
|
+
"workspaces": [
|
|
40
|
+
"packages/*"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {}
|
|
43
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @{{ORGANIZATION_NAME}}/components-{{PROJECT_NAME_KEBAB}}-core
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
A framework-agnostic collection of [web components](https://www.webcomponents.org/introduction) built for maximum compatibility. These components integrate seamlessly with popular libraries like React, Angular, and Vue, or can function entirely on their own using standard browser JavaScript.
|
|
6
|
+
|
|
7
|
+
## Tasks
|
|
8
|
+
|
|
9
|
+
The following is a list of available command line tasks:
|
|
10
|
+
|
|
11
|
+
| Task | Description |
|
|
12
|
+
| ------------- | ----------------------------------------------- |
|
|
13
|
+
| clean | Deletes build outputs of the package. |
|
|
14
|
+
| build | Builds the package. |
|
|
15
|
+
| format | Validates the form of the package. |
|
|
16
|
+
| format:fix | Performs a format fix of the package. |
|
|
17
|
+
| generate | Creates a stencil component. |
|
|
18
|
+
| lint | Validates the code of the package. |
|
|
19
|
+
| lint:fix | Performs a validation fix of the package. |
|
|
20
|
+
| server:dev | Run a standalone stencil server of the code. |
|
|
21
|
+
| test | Performs a test run of the package. |
|
|
22
|
+
| test:e2e | Performs end-to-end test run of the package. |
|
|
23
|
+
| test:watch | Performs a watch of the test run of the package |
|
|
24
|
+
|
|
25
|
+
You can execute tasks within an [Nx](https://nx.dev) workspace using several methods. Here are the most common approaches:
|
|
26
|
+
|
|
27
|
+
**From the `workspace` root:**
|
|
28
|
+
|
|
29
|
+
Use the full project target path to run tasks:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npx nx run components-{{PROJECT_NAME_KEBAB}}-core:[task]
|
|
33
|
+
npx nx run components-{{PROJECT_NAME_KEBAB}}-core:build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**From within the package directory:**
|
|
37
|
+
|
|
38
|
+
Navigate to packages/components-{{PROJECT_NAME_KEBAB}}-core and run the task directly:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npx nx run [task]
|
|
42
|
+
npx nx run build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Output Targets
|
|
46
|
+
|
|
47
|
+
- **dist**: Generate the component(s) as a reusable library that can be self-lazy loading.
|
|
48
|
+
- **cjs and esm**: Bundler ready javascript file for commonjs and modules.
|
|
49
|
+
- **collection**: Stencil files transpiled to simple javascript. Those are the files used if
|
|
50
|
+
you import your library into another stencil distribution.
|
|
51
|
+
- **loader**: Bundler entry for lazy loaded builds (used for example to register all components
|
|
52
|
+
at once in the web component registry with defineCustomElements function).
|
|
53
|
+
- **output-target-stencils (app workspace name)**: Browser ready component.
|
|
54
|
+
- **types**: Typescript types with d.ts files.
|
|
55
|
+
- **dist-custom-elements**: Custom elements that directly extend HTMLElement and provides simple utility functions for easily defining these elements on the Custom Element Registry.
|
|
56
|
+
- **www**: Oriented for web apps and websites, hosted from an http server.
|
|
57
|
+
|
|
58
|
+
## Folder Hierarchy
|
|
59
|
+
|
|
60
|
+
The package structure is organized as follows:
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
├── src/ # Source code
|
|
64
|
+
│ ├── components/ # Stencil components
|
|
65
|
+
│ │ └── [name]/ # Component files (*.tsx, *.css, *.spec.ts, *.e2e.ts)
|
|
66
|
+
│ ├── index.html # Dev server entry
|
|
67
|
+
│ └── index.ts # Library export entry point
|
|
68
|
+
├── package.json # Root configuration: workspaces, dependencies, and scripts
|
|
69
|
+
├── project.json # Project Nx build system configuration
|
|
70
|
+
├── stencil.config.ts # Stencil build configuration
|
|
71
|
+
├── tsconfig.json # TypeScript configuration
|
|
72
|
+
├── CHANGELOG.md # Changelog documentation
|
|
73
|
+
└── README.md # Package documentation
|
|
74
|
+
```
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "components-{{PROJECT_NAME_KEBAB}}-core",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"namedInputs": {
|
|
5
|
+
"default": ["{projectRoot}/**/*"]
|
|
6
|
+
},
|
|
7
|
+
"targets": {
|
|
8
|
+
"clean": {
|
|
9
|
+
"cache": false,
|
|
10
|
+
"executor": "nx:run-script",
|
|
11
|
+
"inputs": [
|
|
12
|
+
{
|
|
13
|
+
"externalDependencies": ["rimraf"]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"options": {
|
|
17
|
+
"script": "clean",
|
|
18
|
+
"cwd": "{projectRoot}"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"build": {
|
|
22
|
+
"cache": false,
|
|
23
|
+
"dependsOn": [
|
|
24
|
+
"^lint"
|
|
25
|
+
],
|
|
26
|
+
"executor": "nx:run-script",
|
|
27
|
+
"inputs": [
|
|
28
|
+
"default",
|
|
29
|
+
{
|
|
30
|
+
"externalDependencies": ["@stencil/core"]
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"options": {
|
|
34
|
+
"script": "build",
|
|
35
|
+
"cwd": "{projectRoot}"
|
|
36
|
+
},
|
|
37
|
+
"outputs": ["{projectRoot}/dist"]
|
|
38
|
+
},
|
|
39
|
+
"format": {
|
|
40
|
+
"cache": false,
|
|
41
|
+
"executor": "nx:run-script",
|
|
42
|
+
"options": {
|
|
43
|
+
"script": "format",
|
|
44
|
+
"cwd": "{projectRoot}"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"format:fix": {
|
|
48
|
+
"cache": false,
|
|
49
|
+
"executor": "nx:run-script",
|
|
50
|
+
"options": {
|
|
51
|
+
"script": "format:fix",
|
|
52
|
+
"cwd": "{projectRoot}"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"generate": {
|
|
56
|
+
"cache": false,
|
|
57
|
+
"executor": "nx:run-script",
|
|
58
|
+
"inputs": [
|
|
59
|
+
"default",
|
|
60
|
+
{
|
|
61
|
+
"externalDependencies": ["@stencil/core"]
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"options": {
|
|
65
|
+
"script": "generate",
|
|
66
|
+
"cwd": "{projectRoot}"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"lint": {
|
|
70
|
+
"cache": false,
|
|
71
|
+
"executor": "nx:run-commands",
|
|
72
|
+
"options": {
|
|
73
|
+
"commands": ["npm run lint:eslint", "npm run lint:stylelint"],
|
|
74
|
+
"cwd": "{projectRoot}",
|
|
75
|
+
"parallel": true
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"lint:fix": {
|
|
79
|
+
"cache": false,
|
|
80
|
+
"executor": "nx:run-commands",
|
|
81
|
+
"options": {
|
|
82
|
+
"commands": ["npm run lint:eslint:fix", "npm run lint:stylelint:fix"],
|
|
83
|
+
"cwd": "{projectRoot}",
|
|
84
|
+
"parallel": true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"server:dev": {
|
|
88
|
+
"cache": false,
|
|
89
|
+
"executor": "nx:run-script",
|
|
90
|
+
"inputs": [
|
|
91
|
+
"default",
|
|
92
|
+
{
|
|
93
|
+
"externalDependencies": ["@stencil/core"]
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"options": {
|
|
97
|
+
"script": "server:dev",
|
|
98
|
+
"cwd": "{projectRoot}"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"test": {
|
|
102
|
+
"cache": false,
|
|
103
|
+
"executor": "nx:run-script",
|
|
104
|
+
"inputs": [
|
|
105
|
+
"default",
|
|
106
|
+
{
|
|
107
|
+
"externalDependencies": ["@stencil/core"]
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"options": {
|
|
111
|
+
"script": "test",
|
|
112
|
+
"cwd": "{projectRoot}"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"test:e2e": {
|
|
116
|
+
"cache": false,
|
|
117
|
+
"executor": "nx:run-script",
|
|
118
|
+
"inputs": [
|
|
119
|
+
"default",
|
|
120
|
+
{
|
|
121
|
+
"externalDependencies": ["@stencil/core"]
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"options": {
|
|
125
|
+
"script": "test:e2e",
|
|
126
|
+
"cwd": "{projectRoot}"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"test:watch": {
|
|
130
|
+
"cache": false,
|
|
131
|
+
"executor": "nx:run-script",
|
|
132
|
+
"inputs": [
|
|
133
|
+
"default",
|
|
134
|
+
{
|
|
135
|
+
"externalDependencies": ["@stencil/core"]
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"options": {
|
|
139
|
+
"script": "test:watch",
|
|
140
|
+
"cwd": "{projectRoot}"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Component, ComponentInterface, Prop, h } from '@stencil/core';
|
|
2
|
+
import { format } from '../../utils/utils';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
tag: 'my-component',
|
|
6
|
+
styleUrl: 'my-component.scss',
|
|
7
|
+
shadow: true,
|
|
8
|
+
})
|
|
9
|
+
export class MyComponent implements ComponentInterface {
|
|
10
|
+
/**
|
|
11
|
+
* The first name
|
|
12
|
+
*/
|
|
13
|
+
@Prop() first: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The middle name
|
|
17
|
+
*/
|
|
18
|
+
@Prop() middle: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The last name
|
|
22
|
+
*/
|
|
23
|
+
@Prop() last: string;
|
|
24
|
+
|
|
25
|
+
private getText(): string {
|
|
26
|
+
return format(this.first, this.middle, this.last);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
return <div>Hello, World! I'm {this.getText()}</div>;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# my-component
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
<!-- Auto Generated Below -->
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
|
|
10
|
+
| Property | Attribute | Description | Type | Default |
|
|
11
|
+
| -------- | --------- | --------------- | -------- | ----------- |
|
|
12
|
+
| `first` | `first` | The first name | `string` | `undefined` |
|
|
13
|
+
| `last` | `last` | The last name | `string` | `undefined` |
|
|
14
|
+
| `middle` | `middle` | The middle name | `string` | `undefined` |
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
----------------------------------------------
|
|
18
|
+
|
|
19
|
+
*Built with [StencilJS](https://stenciljs.com/)*
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { newE2EPage } from '@stencil/core/testing';
|
|
2
|
+
|
|
3
|
+
describe('my-component', () => {
|
|
4
|
+
it('renders', async () => {
|
|
5
|
+
const page = await newE2EPage();
|
|
6
|
+
|
|
7
|
+
await page.setContent('<my-component></my-component>');
|
|
8
|
+
const element = await page.find('my-component');
|
|
9
|
+
expect(element).toHaveClass('hydrated');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('renders changes to the name data', async () => {
|
|
13
|
+
const page = await newE2EPage();
|
|
14
|
+
|
|
15
|
+
await page.setContent('<my-component></my-component>');
|
|
16
|
+
const component = await page.find('my-component');
|
|
17
|
+
const element = await page.find('my-component >>> div');
|
|
18
|
+
expect(element.textContent).toEqual(`Hello, World! I'm `);
|
|
19
|
+
|
|
20
|
+
component.setProperty('first', 'James');
|
|
21
|
+
await page.waitForChanges();
|
|
22
|
+
expect(element.textContent).toEqual(`Hello, World! I'm James`);
|
|
23
|
+
|
|
24
|
+
component.setProperty('last', 'Quincy');
|
|
25
|
+
await page.waitForChanges();
|
|
26
|
+
expect(element.textContent).toEqual(`Hello, World! I'm James Quincy`);
|
|
27
|
+
|
|
28
|
+
component.setProperty('middle', 'Earl');
|
|
29
|
+
await page.waitForChanges();
|
|
30
|
+
expect(element.textContent).toEqual(`Hello, World! I'm James Earl Quincy`);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
+
import { MyComponent } from '../my-component';
|
|
3
|
+
|
|
4
|
+
describe('my-component', () => {
|
|
5
|
+
it('renders', async () => {
|
|
6
|
+
const { root } = await newSpecPage({
|
|
7
|
+
components: [MyComponent],
|
|
8
|
+
html: '<my-component></my-component>',
|
|
9
|
+
});
|
|
10
|
+
expect(root).toEqualHtml(`
|
|
11
|
+
<my-component>
|
|
12
|
+
<mock:shadow-root>
|
|
13
|
+
<div>
|
|
14
|
+
Hello, World! I'm
|
|
15
|
+
</div>
|
|
16
|
+
</mock:shadow-root>
|
|
17
|
+
</my-component>
|
|
18
|
+
`);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('renders with values', async () => {
|
|
22
|
+
const { root } = await newSpecPage({
|
|
23
|
+
components: [MyComponent],
|
|
24
|
+
html: `<my-component first="Stencil" middle="'Don't call me a framework'" last="JS"></my-component>`,
|
|
25
|
+
});
|
|
26
|
+
expect(root).toEqualHtml(`
|
|
27
|
+
<my-component first="Stencil" middle="'Don't call me a framework'" last="JS">
|
|
28
|
+
<mock:shadow-root>
|
|
29
|
+
<div>
|
|
30
|
+
Hello, World! I'm Stencil 'Don't call me a framework' JS
|
|
31
|
+
</div>
|
|
32
|
+
</mock:shadow-root>
|
|
33
|
+
</my-component>
|
|
34
|
+
`);
|
|
35
|
+
});
|
|
36
|
+
});
|
package/dist/templates/base/packages/components-{{PROJECT_NAME_KEBAB}}-core/src/components.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/**
|
|
4
|
+
* This is an autogenerated file created by the Stencil compiler.
|
|
5
|
+
* It contains typing information for all components that exist in this project.
|
|
6
|
+
*/
|
|
7
|
+
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
|
|
8
|
+
export namespace Components {
|
|
9
|
+
interface MyComponent {
|
|
10
|
+
/**
|
|
11
|
+
* The first name
|
|
12
|
+
*/
|
|
13
|
+
"first": string;
|
|
14
|
+
/**
|
|
15
|
+
* The last name
|
|
16
|
+
*/
|
|
17
|
+
"last": string;
|
|
18
|
+
/**
|
|
19
|
+
* The middle name
|
|
20
|
+
*/
|
|
21
|
+
"middle": string;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
declare global {
|
|
25
|
+
interface HTMLMyComponentElement extends Components.MyComponent, HTMLStencilElement {
|
|
26
|
+
}
|
|
27
|
+
var HTMLMyComponentElement: {
|
|
28
|
+
prototype: HTMLMyComponentElement;
|
|
29
|
+
new (): HTMLMyComponentElement;
|
|
30
|
+
};
|
|
31
|
+
interface HTMLElementTagNameMap {
|
|
32
|
+
"my-component": HTMLMyComponentElement;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
declare namespace LocalJSX {
|
|
36
|
+
interface MyComponent {
|
|
37
|
+
/**
|
|
38
|
+
* The first name
|
|
39
|
+
*/
|
|
40
|
+
"first"?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The last name
|
|
43
|
+
*/
|
|
44
|
+
"last"?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The middle name
|
|
47
|
+
*/
|
|
48
|
+
"middle"?: string;
|
|
49
|
+
}
|
|
50
|
+
interface IntrinsicElements {
|
|
51
|
+
"my-component": MyComponent;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export { LocalJSX as JSX };
|
|
55
|
+
declare module "@stencil/core" {
|
|
56
|
+
export namespace JSX {
|
|
57
|
+
interface IntrinsicElements {
|
|
58
|
+
"my-component": LocalJSX.MyComponent & JSXBase.HTMLAttributes<HTMLMyComponentElement>;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|