@pyreon/attrs 0.11.5 → 0.11.7
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 +18 -13
- package/package.json +22 -22
- package/src/__tests__/attrs.test.ts +177 -177
- package/src/__tests__/attrsHoc.test.ts +39 -39
- package/src/__tests__/utils.test.ts +69 -69
- package/src/attrs.ts +13 -13
- package/src/hoc/attrsHoc.ts +4 -4
- package/src/hoc/index.ts +1 -1
- package/src/index.ts +9 -9
- package/src/init.ts +7 -7
- package/src/isAttrsComponent.ts +2 -2
- package/src/types/AttrsComponent.ts +6 -6
- package/src/types/InitAttrsComponent.ts +3 -3
- package/src/types/config.ts +1 -1
- package/src/types/configuration.ts +1 -1
- package/src/types/hoc.ts +1 -1
- package/src/types/utils.ts +1 -1
- package/src/utils/attrs.ts +1 -1
- package/src/utils/chaining.ts +2 -2
- package/src/utils/compose.ts +1 -1
- package/src/utils/statics.ts +1 -1
package/README.md
CHANGED
|
@@ -25,8 +25,11 @@ bun add @pyreon/attrs
|
|
|
25
25
|
import attrs from '@pyreon/attrs'
|
|
26
26
|
import { Element } from '@pyreon/elements'
|
|
27
27
|
|
|
28
|
-
const Button = attrs({ name: 'Button', component: Element })
|
|
29
|
-
|
|
28
|
+
const Button = attrs({ name: 'Button', component: Element }).attrs({
|
|
29
|
+
tag: 'button',
|
|
30
|
+
alignX: 'center',
|
|
31
|
+
alignY: 'center',
|
|
32
|
+
})
|
|
30
33
|
|
|
31
34
|
// Renders Element with tag="button", alignX="center", alignY="center"
|
|
32
35
|
Button({ label: 'Click me' })
|
|
@@ -43,7 +46,7 @@ Creates an attrs-enhanced component.
|
|
|
43
46
|
|
|
44
47
|
```ts
|
|
45
48
|
const Component = attrs({
|
|
46
|
-
name: 'ComponentName',
|
|
49
|
+
name: 'ComponentName', // required — sets displayName
|
|
47
50
|
component: BaseComponent, // required — the Pyreon component to wrap
|
|
48
51
|
})
|
|
49
52
|
```
|
|
@@ -110,11 +113,13 @@ const WithoutTracking = Enhanced.compose({ withTracking: null })
|
|
|
110
113
|
Attach metadata accessible via the `.meta` property.
|
|
111
114
|
|
|
112
115
|
```ts
|
|
113
|
-
const Button = attrs({ name: 'Button', component: Element })
|
|
114
|
-
|
|
116
|
+
const Button = attrs({ name: 'Button', component: Element }).statics({
|
|
117
|
+
category: 'action',
|
|
118
|
+
sizes: ['sm', 'md', 'lg'],
|
|
119
|
+
})
|
|
115
120
|
|
|
116
121
|
Button.meta.category // => 'action'
|
|
117
|
-
Button.meta.sizes
|
|
122
|
+
Button.meta.sizes // => ['sm', 'md', 'lg']
|
|
118
123
|
```
|
|
119
124
|
|
|
120
125
|
### isAttrsComponent(value)
|
|
@@ -125,7 +130,7 @@ Runtime type guard.
|
|
|
125
130
|
import { isAttrsComponent } from '@pyreon/attrs'
|
|
126
131
|
|
|
127
132
|
isAttrsComponent(Button) // => true
|
|
128
|
-
isAttrsComponent('div')
|
|
133
|
+
isAttrsComponent('div') // => false
|
|
129
134
|
```
|
|
130
135
|
|
|
131
136
|
### getDefaultAttrs()
|
|
@@ -143,9 +148,9 @@ Each `.attrs<P>()` call adds `P` to the component's prop types through `MergeTyp
|
|
|
143
148
|
```ts
|
|
144
149
|
const Base = attrs({ name: 'Base', component: Element })
|
|
145
150
|
|
|
146
|
-
const Typed = Base
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
const Typed = Base.attrs<{ variant: 'primary' | 'secondary' }>({ variant: 'primary' }).attrs<{
|
|
152
|
+
size?: 'sm' | 'md' | 'lg'
|
|
153
|
+
}>({})
|
|
149
154
|
|
|
150
155
|
// Typed accepts: Element props + { variant, size? }
|
|
151
156
|
Typed({ variant: 'secondary', size: 'lg', label: 'Hello' })
|
|
@@ -161,9 +166,9 @@ type ExtendedProps = typeof Typed.$$extendedTypes
|
|
|
161
166
|
|
|
162
167
|
## Peer Dependencies
|
|
163
168
|
|
|
164
|
-
| Package
|
|
165
|
-
|
|
|
166
|
-
| @pyreon/core
|
|
169
|
+
| Package | Version |
|
|
170
|
+
| --------------- | -------- |
|
|
171
|
+
| @pyreon/core | >= 0.0.1 |
|
|
167
172
|
| @pyreon/ui-core | >= 0.0.1 |
|
|
168
173
|
|
|
169
174
|
## License
|
package/package.json
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/attrs",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.7",
|
|
4
|
+
"description": "Attrs HOC chaining for Pyreon components",
|
|
5
|
+
"license": "MIT",
|
|
4
6
|
"repository": {
|
|
5
7
|
"type": "git",
|
|
6
8
|
"url": "https://github.com/pyreon/pyreon",
|
|
7
9
|
"directory": "packages/ui-system/attrs"
|
|
8
10
|
},
|
|
9
|
-
"description": "Attrs HOC chaining for Pyreon components",
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"type": "module",
|
|
12
|
-
"sideEffects": false,
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"bun": "./src/index.ts",
|
|
16
|
-
"import": "./lib/index.js",
|
|
17
|
-
"types": "./lib/index.d.ts"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"types": "./lib/index.d.ts",
|
|
21
|
-
"main": "./lib/index.js",
|
|
22
11
|
"files": [
|
|
23
12
|
"lib",
|
|
24
13
|
"!lib/**/*.map",
|
|
@@ -27,8 +16,16 @@
|
|
|
27
16
|
"LICENSE",
|
|
28
17
|
"src"
|
|
29
18
|
],
|
|
30
|
-
"
|
|
31
|
-
|
|
19
|
+
"type": "module",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"main": "./lib/index.js",
|
|
22
|
+
"types": "./lib/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"bun": "./src/index.ts",
|
|
26
|
+
"import": "./lib/index.js",
|
|
27
|
+
"types": "./lib/index.d.ts"
|
|
28
|
+
}
|
|
32
29
|
},
|
|
33
30
|
"publishConfig": {
|
|
34
31
|
"access": "public"
|
|
@@ -37,18 +34,21 @@
|
|
|
37
34
|
"prepublish": "bun run build",
|
|
38
35
|
"build": "bun run vl_rolldown_build",
|
|
39
36
|
"build:watch": "bun run vl_rolldown_build-watch",
|
|
40
|
-
"lint": "
|
|
37
|
+
"lint": "oxlint .",
|
|
41
38
|
"test": "vitest run",
|
|
42
39
|
"test:coverage": "vitest run --coverage",
|
|
43
40
|
"test:watch": "vitest",
|
|
44
41
|
"typecheck": "tsc --noEmit"
|
|
45
42
|
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@pyreon/typescript": "^0.11.7",
|
|
45
|
+
"@vitus-labs/tools-rolldown": "^1.15.3"
|
|
46
|
+
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@pyreon/core": "^0.11.
|
|
48
|
-
"@pyreon/ui-core": "^0.11.
|
|
48
|
+
"@pyreon/core": "^0.11.7",
|
|
49
|
+
"@pyreon/ui-core": "^0.11.7"
|
|
49
50
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"@pyreon/typescript": "^0.11.5"
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">= 22"
|
|
53
53
|
}
|
|
54
54
|
}
|