-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproperty.ts
27 lines (23 loc) · 839 Bytes
/
property.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import type { PropertyDeclaration, ReactiveElement } from 'lit'
import { property as litProperty } from 'lit/decorators.js'
import { updated } from './updated/updated.js'
import { UpdatedCallback } from './updated/UpdatedController.js'
import { associatedEvent, bindingDefaultProperty } from './bind/index.js'
export const property = <T>(options?: PropertyDeclaration & {
updated?: UpdatedCallback<T>
bindingDefault?: boolean
event?: string
}) => {
return (prototype: ReactiveElement, propertyKey: PropertyKey) => {
if (options?.updated) {
updated(options.updated)(prototype, propertyKey)
}
if (options?.bindingDefault) {
bindingDefaultProperty()(prototype, propertyKey)
}
if (options?.event) {
associatedEvent(options.event)(prototype, propertyKey)
}
return litProperty(options)(prototype, propertyKey)
}
}