@base-framework/atoms 1.0.63 → 1.0.65
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/copilot.md +103 -0
- package/package.json +5 -3
package/copilot.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Base Atoms - AI Coding Instructions
|
|
2
|
+
|
|
3
|
+
## Architecture Overview
|
|
4
|
+
This is an npm package that provides atomic HTML components for the Base Framework. It exports reusable, composable atoms that serve as building blocks for component-based architecture.
|
|
5
|
+
|
|
6
|
+
**Key Dependencies:**
|
|
7
|
+
- `@base-framework/base`: Core framework providing `Atom`, `Builder`, and `dataBinder`
|
|
8
|
+
- Built as ESM module with TypeScript declarations generated from JSDoc
|
|
9
|
+
|
|
10
|
+
## Core Patterns
|
|
11
|
+
|
|
12
|
+
### Atom Creation Patterns
|
|
13
|
+
Two primary patterns for creating atoms:
|
|
14
|
+
|
|
15
|
+
1. **Simple Function Atoms** (for basic HTML elements):
|
|
16
|
+
```javascript
|
|
17
|
+
const Meta = (props) => ({ ...props, tag: 'meta' });
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
2. **Atom Wrapper Functions** (for composable atoms):
|
|
21
|
+
```javascript
|
|
22
|
+
const Div = Atom((props, children) => Tag(props, children));
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Component Composition
|
|
26
|
+
Atoms use composition over inheritance. Children are passed as arrays:
|
|
27
|
+
```javascript
|
|
28
|
+
const SecondaryButton = Atom((props, children) => Button({
|
|
29
|
+
...props,
|
|
30
|
+
class: 'secondary-btn',
|
|
31
|
+
children
|
|
32
|
+
}));
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Special Atoms Architecture
|
|
36
|
+
Located in `/src/on/` and `/src/use/` directories:
|
|
37
|
+
|
|
38
|
+
- **On Atoms**: Conditional rendering based on data binding (`On`, `OnState`, `OnRoute`)
|
|
39
|
+
- **UseParent**: Provides access to parent component context
|
|
40
|
+
- Use **comment placeholders** to maintain DOM position during dynamic updates
|
|
41
|
+
|
|
42
|
+
## Development Workflows
|
|
43
|
+
|
|
44
|
+
### Build Process
|
|
45
|
+
```bash
|
|
46
|
+
npm run build # Builds dist/ with esbuild + generates TypeScript declarations
|
|
47
|
+
npm run prepublishOnly # Pre-publish build step
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### File Structure
|
|
51
|
+
- `src/atoms.js`: Main export file with all HTML element atoms
|
|
52
|
+
- `src/on/on.js`: Dynamic conditional rendering atoms
|
|
53
|
+
- `src/use/use.js`: Parent component access utilities
|
|
54
|
+
- `src/comment.js`: Comment placeholder utility
|
|
55
|
+
|
|
56
|
+
## Code Conventions
|
|
57
|
+
|
|
58
|
+
### JSDoc Documentation
|
|
59
|
+
All atoms require comprehensive JSDoc with proper type annotations:
|
|
60
|
+
```javascript
|
|
61
|
+
/**
|
|
62
|
+
* Creates a button element.
|
|
63
|
+
*
|
|
64
|
+
* @param {object} props - Properties for the element.
|
|
65
|
+
* @param {array} children - Children elements.
|
|
66
|
+
* @returns {object} - Returns an object representing the element.
|
|
67
|
+
*/
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Event Handling Pattern
|
|
71
|
+
Event callbacks receive `(event, parent)` parameters for parent component access:
|
|
72
|
+
```javascript
|
|
73
|
+
Button({
|
|
74
|
+
click(event, parent) {
|
|
75
|
+
// Access parent component here
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Flexible Argument Handling
|
|
81
|
+
Atoms support multiple call patterns:
|
|
82
|
+
- Props only: `Div({class: 'text'})`
|
|
83
|
+
- Children only: `Div('text')` or `Div([childrenArray])`
|
|
84
|
+
- Both: `Div({class: 'text'}, children)`
|
|
85
|
+
|
|
86
|
+
## Critical Implementation Details
|
|
87
|
+
|
|
88
|
+
### Dynamic Rendering (On Atoms)
|
|
89
|
+
- Use comment placeholders to maintain DOM insertion points
|
|
90
|
+
- Handle previous element cleanup in `updateLayout` functions
|
|
91
|
+
- Support data binding to component data, context, or state
|
|
92
|
+
|
|
93
|
+
### Base Framework Integration
|
|
94
|
+
- Always import `Atom` from `@base-framework/base`
|
|
95
|
+
- Use `Builder.build()` and `Builder.removeNode()` for DOM manipulation
|
|
96
|
+
- Leverage `dataBinder` for reactive data connections
|
|
97
|
+
|
|
98
|
+
### TypeScript Support
|
|
99
|
+
- Enable `allowJs: true` and `checkJs: true` in tsconfig.json
|
|
100
|
+
- Generate declarations with `emitDeclarationOnly: true`
|
|
101
|
+
- Map Base Framework types in `paths` configuration
|
|
102
|
+
|
|
103
|
+
When working with this codebase, focus on maintaining the established patterns for atom creation, JSDoc documentation, and the flexible argument handling that allows atoms to work seamlessly within the Base Framework ecosystem.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base-framework/atoms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.65",
|
|
4
4
|
"description": "This will add default atoms to the base framework.",
|
|
5
5
|
"main": "./dist/atoms.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,14 +35,16 @@
|
|
|
35
35
|
"files": [
|
|
36
36
|
"package.json",
|
|
37
37
|
"readme.md",
|
|
38
|
-
"dist"
|
|
38
|
+
"dist",
|
|
39
|
+
"copilot.md"
|
|
39
40
|
],
|
|
40
41
|
"exports": {
|
|
41
42
|
"./package.json": "./package.json",
|
|
42
43
|
".": {
|
|
43
44
|
"import": "./dist/atoms.js",
|
|
44
45
|
"require": "./dist/atoms.js"
|
|
45
|
-
}
|
|
46
|
+
},
|
|
47
|
+
"./copilot.md": "./copilot.md"
|
|
46
48
|
},
|
|
47
49
|
"homepage": "https://github.com/chrisdurfee/atoms#readme"
|
|
48
50
|
}
|