UNPKG

intentful

Version:

Create Custom Skills with less headache

109 lines (108 loc) 4.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.APLComponent = void 0; const helpers_1 = require("../interfaces/helpers"); class APLComponent { constructor(type, props) { this.convertBaseComponentPropsToModel = () => { return { id: this.props.id, accessibilityLabel: this.props.accessibilityLabel, description: this.props.description, checked: this.props.checked, disabled: this.props.disabled, display: this.props.display, height: this.props.height, width: this.props.width, inheritParentState: this.props.inheritParentState, layoutDirection: this.props.layoutDirection, maxHeight: this.props.maxHeight, maxWidth: this.props.maxWidth, minHeight: this.props.minHeight, minWidth: this.props.minWidth, opacity: this.props.opacity, padding: this.props.padding, paddingBottom: this.props.paddingBottom, paddingEnd: this.props.paddingEnd, paddingLeft: this.props.paddingLeft, paddingRight: this.props.paddingRight, paddingStart: this.props.paddingStart, paddingTop: this.props.paddingTop, preserve: this.props.preserve, role: this.props.role, shadowColor: this.props.shadowColor, shadowHorizontalOffset: this.props.shadowHorizontalOffset, shadowRadius: this.props.shadowRadius, shadowVerticalOffset: this.props.shadowVerticalOffset, style: this.props.style, when: this.props.when, onMount: this.props.onMount, onCursorEnter: this.props.onCursorEnter, onCursorExit: this.props.onCursorExit, actions: this.props.actions, bind: this.props.bind, entities: this.props.entities, handleTick: this.props.handleTick, transform: this.props.transform, ...this.convertContainerChildComponentPropsToModel(this.props) }; }; this.type = type; this.props = props; } model() { return { ...this.convertBaseComponentPropsToModel(), type: this.type, ...this.componentSpecificModel() }; } toJSON() { return this.model(); } getRequestHandlers() { return [...this.convertBaseComponentPropsToRequestHandlers(), ...this.componentSpecificRequestHandlers()]; } convertBaseComponentPropsToRequestHandlers() { return [ ...(0, helpers_1.convertCommandListToRequestHandlers)(this.props.onMount), ...(0, helpers_1.convertCommandListToRequestHandlers)(this.props.onCursorEnter), ...(0, helpers_1.convertCommandListToRequestHandlers)(this.props.onCursorExit), ...(0, helpers_1.convertActionListToRequestHandlers)(this.props.actions), ...(0, helpers_1.convertTickHandlerToRequestHandlers)(this.props.handleTick) ]; } convertContainerChildComponentPropsToModel(props) { return { alignSelf: props.alignSelf, bottom: props.bottom, end: props.end, grow: props.grow, left: props.left, numbering: props.numbering, position: props.position, right: props.right, shrink: props.shrink, spacing: props.spacing, start: props.start, top: props.top }; } convertActionableComponentPropsToModel(props) { return { handleKeyDown: props.handleKeyDown, handleKeyUp: props.handleKeyUp, onFocus: props.onFocus, onBlur: props.onBlur }; } convertMultiChildComponentPropsToModel(props) { return { data: props.data, firstItem: props.firstItem, lastItem: props.lastItem, items: props.items }; } } exports.APLComponent = APLComponent;