@jay-framework/compiler-jay-html 0.9.0 → 0.10.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/dist/index.d.cts +58 -45
- package/dist/index.js +1636 -463
- package/docs/jay-html-docs.md +32 -2
- package/package.json +9 -9
- package/readme.md +9 -12
package/docs/jay-html-docs.md
CHANGED
|
@@ -124,10 +124,40 @@ The `{}` syntax enables dynamic data binding to the current view state context.
|
|
|
124
124
|
|
|
125
125
|
Class bindings support dynamic and conditional class inclusion:
|
|
126
126
|
|
|
127
|
+
#### Dynamic Class from Property
|
|
128
|
+
|
|
127
129
|
```html
|
|
128
130
|
<div class="{status}">Status indicator</div>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### Conditional Class (Short Form)
|
|
134
|
+
|
|
135
|
+
Use the `{condition ? class-name}` syntax to conditionally add a class. The class name is **not quoted**:
|
|
136
|
+
|
|
137
|
+
```html
|
|
138
|
+
<div class="indicator {isActive ? active} {isLoading ? loading}">Status</div>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
When the condition is true, the class is added. When false, it's omitted.
|
|
142
|
+
|
|
143
|
+
#### Conditional Class (Full Ternary)
|
|
144
|
+
|
|
145
|
+
Use the full ternary syntax `{condition ? class-a : class-b}` to switch between two classes:
|
|
146
|
+
|
|
147
|
+
```html
|
|
148
|
+
<div class="{isPrimary ? primary : secondary} button">Button</div>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Combining Static and Conditional Classes
|
|
152
|
+
|
|
153
|
+
```html
|
|
154
|
+
<a
|
|
155
|
+
href="/cart"
|
|
156
|
+
class="cart-indicator {hasItems ? has-items} {isLoading ? is-loading} {justAdded ? just-added}"
|
|
157
|
+
>
|
|
158
|
+
<span class="icon">🛒</span>
|
|
159
|
+
<span class="count" if="hasItems">{itemCount}</span>
|
|
160
|
+
</a>
|
|
131
161
|
```
|
|
132
162
|
|
|
133
163
|
## Conditional Rendering
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/compiler-jay-html",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "npm run build:pegjs && npm run build:js && npm run build:types",
|
|
25
25
|
"build:watch": "npm run build:js -- --watch & npm run build:types -- --watch",
|
|
26
|
-
"build:pegjs": "pegjs --allowed-start-rules dynamicAttribute,booleanAttribute,dynamicText,dynamicProperty,conditionFunc,accessor,Identifier,classExpression,dynamicComponentProp,importNames,enum,is_enum,reactDynamicText,reactDynamicProperty,reactClassExpression,condition -o lib/expressions/expression-parser.cjs lib/expressions/expression-parser.pegjs",
|
|
26
|
+
"build:pegjs": "pegjs --allowed-start-rules dynamicAttribute,booleanAttribute,dynamicText,dynamicProperty,conditionFunc,accessor,Identifier,classExpression,dynamicComponentProp,importNames,enum,is_enum,reactDynamicText,reactDynamicProperty,reactClassExpression,condition,styleDeclarations -o lib/expressions/expression-parser.cjs lib/expressions/expression-parser.pegjs",
|
|
27
27
|
"build:js": "vite build",
|
|
28
28
|
"build:types": "tsup lib/index.ts --dts-only --format cjs",
|
|
29
29
|
"build:check-types": "tsc",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"author": "",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@jay-framework/compiler-analyze-exported-types": "^0.
|
|
38
|
-
"@jay-framework/compiler-shared": "^0.
|
|
39
|
-
"@jay-framework/component": "^0.
|
|
40
|
-
"@jay-framework/runtime": "^0.
|
|
41
|
-
"@jay-framework/secure": "^0.
|
|
37
|
+
"@jay-framework/compiler-analyze-exported-types": "^0.10.0",
|
|
38
|
+
"@jay-framework/compiler-shared": "^0.10.0",
|
|
39
|
+
"@jay-framework/component": "^0.10.0",
|
|
40
|
+
"@jay-framework/runtime": "^0.10.0",
|
|
41
|
+
"@jay-framework/secure": "^0.10.0",
|
|
42
42
|
"@types/js-yaml": "^4.0.9",
|
|
43
43
|
"change-case": "^4.1.2",
|
|
44
44
|
"js-yaml": "^4.1.0",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@caiogondim/strip-margin": "^1.0.0",
|
|
53
|
-
"@jay-framework/4-react": "^0.
|
|
54
|
-
"@jay-framework/dev-environment": "^0.
|
|
53
|
+
"@jay-framework/4-react": "^0.10.0",
|
|
54
|
+
"@jay-framework/dev-environment": "^0.10.0",
|
|
55
55
|
"@testing-library/jest-dom": "^6.2.0",
|
|
56
56
|
"@types/js-beautify": "^1",
|
|
57
57
|
"@types/node": "^20.11.5",
|
package/readme.md
CHANGED
|
@@ -62,23 +62,21 @@ Headfull components include both the contract and UI design:
|
|
|
62
62
|
|
|
63
63
|
### Importing Headless Components
|
|
64
64
|
|
|
65
|
-
Headless components provide only the contract and logic:
|
|
65
|
+
Headless components provide only the contract and logic, and are referenced through the plugin system:
|
|
66
66
|
|
|
67
67
|
```html
|
|
68
68
|
<script
|
|
69
69
|
type="application/jay-headless"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
name="{component-name}"
|
|
70
|
+
plugin="{plugin-name}"
|
|
71
|
+
contract="{contract-name}"
|
|
73
72
|
key="{nested-key}"
|
|
74
73
|
></script>
|
|
75
74
|
```
|
|
76
75
|
|
|
77
76
|
**Parameters:**
|
|
78
77
|
|
|
79
|
-
- `
|
|
80
|
-
- `
|
|
81
|
-
- `name` - Name of the exported component definition
|
|
78
|
+
- `plugin` - Plugin name (from plugin.yaml in src/plugins/ or node_modules/)
|
|
79
|
+
- `contract` - Contract name within the plugin
|
|
82
80
|
- `key` - Attribute name for nesting the component's ViewState and Refs
|
|
83
81
|
|
|
84
82
|
### Import Examples
|
|
@@ -95,13 +93,12 @@ Headless components provide only the contract and logic:
|
|
|
95
93
|
sandbox="true"
|
|
96
94
|
></script>
|
|
97
95
|
|
|
98
|
-
<!-- Import a headless component -->
|
|
96
|
+
<!-- Import a headless component from a plugin -->
|
|
99
97
|
<script
|
|
100
98
|
type="application/jay-headless"
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
key="store"
|
|
99
|
+
plugin="wix-stores"
|
|
100
|
+
contract="product-list"
|
|
101
|
+
key="products"
|
|
105
102
|
></script>
|
|
106
103
|
```
|
|
107
104
|
|