Skip to content

Commit 97bf5d9

Browse files
Merge pull request #44 from zeixcom/feature/type-inference
Feature/type inference
2 parents 15c8bf8 + 7e43b26 commit 97bf5d9

File tree

122 files changed

+3715
-2548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+3715
-2548
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ bun run serve:docs
9797

9898
To maintain a high-quality codebase, please follow these guidelines:
9999

100-
* Follow the projects existing coding style.
100+
* Follow the project's existing coding style.
101101
* Avoid unnecessary dependencies.
102102
* Use functional programming principles where applicable.
103103
* Prefer composition over inheritance.

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UIElement
22

3-
Version 0.10.0
3+
Version 0.10.1
44

55
**UIElement** - transform reusable markup, styles and behavior into powerful, reactive, and maintainable Web Components.
66

@@ -158,15 +158,17 @@ class TabList extends UIElement {
158158
// Handle click events on menu buttons and update active tab index
159159
this.all('menu button')
160160
.on('click', (_el, index) => () => this.set('active', index))
161-
.sync((host, target, index) => setAttribute(
162-
'aria-pressed',
163-
() => host.get('active') === index ? 'true' : 'false')(host, target)
164-
)
161+
.sync((host, target, index) => {
162+
setAttribute(
163+
'aria-pressed',
164+
() => host.get('active') === index ? 'true' : 'false'
165+
)(host, target)
166+
})
165167

166168
// Pass open attribute to tab-panel elements based on active tab index
167-
this.all('tab-panel').pass({
168-
open: (_el, index) => () => index === this.get('active')
169-
})
169+
this.all('tab-panel').pass((_el, index) => ({
170+
open: () => index === this.get('active')
171+
}))
170172
}
171173
}
172174
TabList.define('tab-list')
@@ -218,7 +220,7 @@ import { UIElement, setText, setProperty, effect, enqueue } from '@zeix/ui-eleme
218220

219221
class LazyLoad extends UIElement {
220222
static observedAttributes = ['src']
221-
static states = {
223+
states = {
222224
src: v => {
223225
let url = ''
224226
try {
@@ -238,12 +240,12 @@ class LazyLoad extends UIElement {
238240

239241
// Show / hide loading message
240242
this.first('.loading')
241-
.sync(setProperty('ariaHidden', () => !!this.get('error')))
243+
.sync(setProperty('hidden', () => !!this.get('error')))
242244

243245
// Set and show / hide error message
244246
this.first('.error')
245247
.sync(setText('error'))
246-
.sync(setProperty('ariaHidden', () => !this.get('error')))
248+
.sync(setProperty('hidden', () => !this.get('error')))
247249

248250
// Load content from provided URL
249251
effect(async () => {

bun.lockb

1009 Bytes
Binary file not shown.
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1-
import { asBoolean, setProperty, toggleAttribute, UIElement } from "@zeix/ui-element"
1+
import { asBoolean, setProperty, toggleAttribute, UIElement } from "../../../"
22

3-
export class AccordionPanel extends UIElement {
4-
static states = {
5-
open: asBoolean,
6-
collapsible: asBoolean
7-
}
3+
export class AccordionPanel extends UIElement<{
4+
open: boolean,
5+
collapsible: boolean,
6+
}> {
7+
static readonly localName = 'accordion-panel'
8+
static observedAttributes = ['open', 'collapsible']
9+
10+
states = {
11+
open: asBoolean,
12+
collapsible: asBoolean
13+
}
814

915
connectedCallback() {
1016
super.connectedCallback()
11-
17+
1218
// Handle open and collapsible state changes
1319
this.self.sync(
1420
toggleAttribute('open'),
1521
toggleAttribute('collapsible'),
16-
setProperty('ariaHidden', () => !this.get('open') && !this.get('collapsible'))
22+
setProperty('hidden', () => !this.get('open') && !this.get('collapsible'))
1723
)
1824

1925
// Control inner details panel
20-
this.first('details').sync(
26+
this.first<HTMLDetailsElement>('details').sync(
2127
setProperty('open'),
22-
setProperty('ariaDisabled', () => !this.get('collapsible'))
28+
setProperty('ariaDisabled', () => String(!this.get('collapsible')))
2329
)
2430
}
2531
}
26-
AccordionPanel.define('accordion-panel')
32+
AccordionPanel.define()

docs-src/components/badge-button/badge-button.css

Lines changed: 0 additions & 44 deletions
This file was deleted.

docs-src/components/badge-button/badge-button.html

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs-src/components/badge-button/badge-button.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs-src/components/code-block/code-block.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
</p>
1111
<pre><code class="language-html"></code></pre>
1212
<input-button class="copy">
13-
<button type="button" class="secondary small">Copy</button>
13+
<button type="button" class="secondary small">
14+
<span class="label">Copy</span>
15+
</button>
1416
</input-button>
1517
<button type="button" class="overlay">Expand</button>
1618
</code-block></code></pre>
1719
<input-button class="copy">
18-
<button type="button" class="secondary small">Copy</button>
20+
<button type="button" class="secondary small">
21+
<span class="label">Copy</span>
22+
</button>
1923
</input-button>
2024
<button type="button" class="overlay">Expand</button>
2125
</code-block>

docs-src/components/code-block/code-block.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import { asBoolean, toggleAttribute, UIElement } from "@zeix/ui-element"
1+
import { asBoolean, toggleAttribute, UIElement } from '../../../'
22
// import Prism from 'prismjs'
33
// import 'prismjs/components/prism-bash';
44
// import 'prismjs/components/prism-json';
55
// import 'prismjs/components/prism-typescript';
66

77
import type { InputButton } from '../input-button/input-button'
88

9-
export class CodeBlock extends UIElement {
9+
export class CodeBlock extends UIElement<{ collapsed: boolean }> {
10+
static readonly localName = 'code-block'
1011
static observedAttributes = ['collapsed']
11-
static states = {
12+
13+
states = {
1214
collapsed: asBoolean
1315
}
1416

@@ -39,7 +41,7 @@ export class CodeBlock extends UIElement {
3941
// Copy to clipboard
4042
this.first('.copy').on('click', async (e: Event) => {
4143
const copyButton = e.currentTarget as InputButton
42-
const label = copyButton.textContent
44+
const label = copyButton.textContent ?? ''
4345
let status = 'success'
4446
try {
4547
await navigator.clipboard.writeText(content.textContent ?? '')
@@ -48,7 +50,7 @@ export class CodeBlock extends UIElement {
4850
status = 'error'
4951
}
5052
copyButton.set('disabled', true)
51-
copyButton.set('label', this.getAttribute(`copy-${status}`))
53+
copyButton.set('label', this.getAttribute(`copy-${status}`) ?? label)
5254
setTimeout(() => {
5355
copyButton.set('disabled', false)
5456
copyButton.set('label', label)
@@ -61,4 +63,4 @@ export class CodeBlock extends UIElement {
6163
}
6264
}
6365
}
64-
CodeBlock.define('code-block')
66+
CodeBlock.define()
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { setText, UIElement } from "@zeix/ui-element"
1+
import { setText, UIElement, RESET } from "../../../"
2+
3+
export class HelloWorld extends UIElement<{ name?: string }> {
4+
static localName = 'hello-world'
25

3-
export class HelloWorld extends UIElement {
46
connectedCallback() {
5-
this.first('span').sync(setText('name'))
7+
this.first('span').sync(setText('name'))
68
this.first('input').on('input', (e: Event) => {
7-
this.set('name', (e.target as HTMLInputElement)?.value || undefined)
9+
this.set('name', (e.target as HTMLInputElement)?.value || RESET)
810
})
911
}
1012
}
11-
HelloWorld.define('hello-world')
13+
HelloWorld.define()

0 commit comments

Comments
 (0)