({
// element definition
tag = 'div',
name = null,
attributes = {},
// view interaction
read = () => {},
write = () => {},
create = () => {},
destroy = () => {},
// hooks
filterFrameActionsForChild = (child, actions) => actions,
didCreateView = () => {},
didWriteView = () => {},
// rect related
ignoreRect = false,
ignoreRectUpdate = false,
// mixins
mixins = []
} = {})
| 11 | export const createView = |
| 12 | // default view definition |
| 13 | ({ |
| 14 | // element definition |
| 15 | tag = 'div', |
| 16 | name = null, |
| 17 | attributes = {}, |
| 18 | |
| 19 | // view interaction |
| 20 | read = () => {}, |
| 21 | write = () => {}, |
| 22 | create = () => {}, |
| 23 | destroy = () => {}, |
| 24 | |
| 25 | // hooks |
| 26 | filterFrameActionsForChild = (child, actions) => actions, |
| 27 | didCreateView = () => {}, |
| 28 | didWriteView = () => {}, |
| 29 | |
| 30 | // rect related |
| 31 | ignoreRect = false, |
| 32 | ignoreRectUpdate = false, |
| 33 | |
| 34 | // mixins |
| 35 | mixins = [] |
| 36 | } = {}) => ( |
| 37 | // each view requires reference to store |
| 38 | store, |
| 39 | // specific properties for this view |
| 40 | props = {} |
| 41 | ) => { |
| 42 | // root element should not be changed |
| 43 | const element = createElement(tag, `filepond--${name}`, attributes); |
| 44 | |
| 45 | // style reference should also not be changed |
| 46 | const style = window.getComputedStyle(element, null); |
| 47 | |
| 48 | // element rectangle |
| 49 | const rect = updateRect(); |
| 50 | let frameRect = null; |
| 51 | |
| 52 | // rest state |
| 53 | let isResting = false; |
| 54 | |
| 55 | // pretty self explanatory |
| 56 | const childViews = []; |
| 57 | |
| 58 | // loaded mixins |
| 59 | const activeMixins = []; |
| 60 | |
| 61 | // references to created children |
| 62 | const ref = {}; |
| 63 | |
| 64 | // state used for each instance |
| 65 | const state = {}; |
| 66 | |
| 67 | // list of writers that will be called to update this view |
| 68 | const writers = [ |
| 69 | write // default writer |
| 70 | ]; |
no test coverage detected