subay 0.0.12 → 0.1.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/README.md +14 -18
- package/README.zh.md +677 -682
- package/examples/todo-app.html +5 -20
- package/lib/arr.d.ts +2 -0
- package/lib/arr.d.ts.map +1 -0
- package/lib/arr.js +122 -0
- package/lib/arr.js.map +1 -0
- package/lib/h.d.ts.map +1 -1
- package/lib/h.js +131 -318
- package/lib/h.js.map +1 -1
- package/lib/index.js +3 -1
- package/lib/s.d.ts +1 -1
- package/lib/s.d.ts.map +1 -1
- package/lib/s.js +1 -1
- package/lib/s.js.map +1 -1
- package/package.json +2 -6
- package/skills/subay-application/SKILL.md +122 -0
- package/skills/subay-component/SKILL.md +53 -0
- package/skills/subay-expert/SKILL.md +37 -0
- package/skills/subay-state/SKILL.md +162 -0
- package/skills/subay-template/SKILL.md +39 -0
- package/src/arr.ts +428 -0
- package/src/h.ts +138 -365
- package/src/s.ts +1 -1
- package/lib/index.dev.js +0 -96
- package/lib/name.d.ts +0 -2
- package/lib/name.d.ts.map +0 -1
- package/lib/name.js +0 -58
- package/lib/name.js.map +0 -1
package/README.md
CHANGED
|
@@ -603,10 +603,8 @@ const Greeting = (name: string, children: () => Node[]) => {
|
|
|
603
603
|
|
|
604
604
|
**Component Usage**
|
|
605
605
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
The parameters passed to the component must be in the same order as the component's declared parameters.
|
|
609
|
-
The parameters received by the component are always consistent with those passed in.
|
|
606
|
+
Subay components do not support interpolation at the tag position in templates. Instead, they are used through direct calls or deferred calls.
|
|
607
|
+
A deferred call means creating a function that returns the result of the component call.
|
|
610
608
|
|
|
611
609
|
**Example**
|
|
612
610
|
|
|
@@ -618,9 +616,14 @@ const Greeting = (greet: string, name: () => string) => {
|
|
|
618
616
|
};
|
|
619
617
|
|
|
620
618
|
const name = o('World');
|
|
621
|
-
const app = html` <div><${Greeting} greet=${'Hello'} name=${name}></${Greeting}></div> `;
|
|
622
619
|
|
|
623
|
-
|
|
620
|
+
// Direct call
|
|
621
|
+
const app1 = html` <div>${Greeting('Hello', name)}</div> `;
|
|
622
|
+
|
|
623
|
+
// Deferred call
|
|
624
|
+
const app2 = html` <div>${() => Greeting('Hello', name)}</div> `;
|
|
625
|
+
|
|
626
|
+
document.body.append(...app1);
|
|
624
627
|
```
|
|
625
628
|
|
|
626
629
|
**Don't Do This**
|
|
@@ -633,25 +636,19 @@ const Greeting = (greet: string, name: () => string) => {
|
|
|
633
636
|
};
|
|
634
637
|
|
|
635
638
|
const name = o('World');
|
|
636
|
-
// Error
|
|
639
|
+
// Error - Interpolation at tag position
|
|
637
640
|
const app = html`
|
|
638
641
|
<div>
|
|
639
|
-
<${Greeting}
|
|
640
|
-
greet=${'Hello'}
|
|
641
|
-
name=${name}
|
|
642
|
-
/>
|
|
643
|
-
<span></span>
|
|
642
|
+
<${Greeting} greet=${'Hello'} name=${name}></${Greeting}>
|
|
644
643
|
</div>
|
|
645
644
|
`;
|
|
646
|
-
// Error, parameter order is inconsistent with Greeting's parameters
|
|
647
|
-
const app = html` <div><${Greeting} name=${name} greet=${'Hi'} ></${Greeting}></div> `;
|
|
648
645
|
|
|
649
646
|
document.body.append(...app);
|
|
650
647
|
```
|
|
651
648
|
|
|
652
649
|
**Dynamic Components**
|
|
653
650
|
|
|
654
|
-
|
|
651
|
+
You can dynamically select which component to render based on conditions by returning different components from a function.
|
|
655
652
|
|
|
656
653
|
**Example**
|
|
657
654
|
|
|
@@ -668,14 +665,13 @@ const Farewell = (name: () => string) => {
|
|
|
668
665
|
|
|
669
666
|
const showGreeting = o(true);
|
|
670
667
|
const name = o('World');
|
|
671
|
-
const Component = S(() => (showGreeting() ? Greeting : Farewell));
|
|
672
668
|
|
|
673
669
|
const app = html`
|
|
674
670
|
<div>
|
|
675
|
-
|
|
671
|
+
${() => (showGreeting() ? Greeting(name) : Farewell(name))}
|
|
676
672
|
<button onclick=${() => showGreeting(!showGreeting())}>Toggle</button>
|
|
677
673
|
</div>
|
|
678
674
|
`;
|
|
679
675
|
|
|
680
676
|
document.body.append(...app);
|
|
681
|
-
```
|
|
677
|
+
```
|