(config: {
attr?: PropertyMap
data?: PropertyMap
text?: StoreOrData<DOMProperty> | Array<StoreOrData<DOMProperty>>
style?: StylePropertyMap
styleVar?: PropertyMap
classList?: ClassListArray | ClassListMap
visible?: Store<boolean>
handler?:
| {
config?: {
passive?: boolean
capture?: boolean
prevent?: boolean
stop?: boolean
}
on: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
}
| Partial<{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}>
ɔ?: any
})
| 17 | import {forIn} from '../forIn' |
| 18 | |
| 19 | export function spec(config: { |
| 20 | attr?: PropertyMap |
| 21 | data?: PropertyMap |
| 22 | text?: StoreOrData<DOMProperty> | Array<StoreOrData<DOMProperty>> |
| 23 | style?: StylePropertyMap |
| 24 | styleVar?: PropertyMap |
| 25 | classList?: ClassListArray | ClassListMap |
| 26 | visible?: Store<boolean> |
| 27 | handler?: |
| 28 | | { |
| 29 | config?: { |
| 30 | passive?: boolean |
| 31 | capture?: boolean |
| 32 | prevent?: boolean |
| 33 | stop?: boolean |
| 34 | } |
| 35 | on: Partial< |
| 36 | {[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>} |
| 37 | > |
| 38 | } |
| 39 | | Partial<{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}> |
| 40 | ɔ?: any |
| 41 | }) { |
| 42 | assertClosure(currentTemplate, 'spec') |
| 43 | const draft = currentTemplate.draft |
| 44 | switch (draft.type) { |
| 45 | case 'list': |
| 46 | if (config.visible) draft.itemVisible = config.visible |
| 47 | return |
| 48 | case 'listItem': |
| 49 | case 'using': |
| 50 | case 'route': |
| 51 | case 'rec': |
| 52 | case 'recItem': |
| 53 | case 'block': |
| 54 | case 'blockItem': |
| 55 | return |
| 56 | } |
| 57 | if (config.attr) draft.attr.push(config.attr) |
| 58 | if (config.data) draft.data.push(config.data) |
| 59 | if ('text' in config) { |
| 60 | const text = config.text |
| 61 | const firstIndex = draft.childCount |
| 62 | if (Array.isArray(text)) { |
| 63 | draft.text.push( |
| 64 | ...text.map((value, i) => ({ |
| 65 | index: i + firstIndex, |
| 66 | value, |
| 67 | })), |
| 68 | ) |
| 69 | draft.childCount += text.length |
| 70 | } else { |
| 71 | draft.text.push({ |
| 72 | index: firstIndex, |
| 73 | value: text!, |
| 74 | }) |
| 75 | draft.childCount += 1 |
| 76 | } |
searching dependent graphs…