'use strict' ; import { registerRule } from './RulesRegistry' ; import isPlainObject from './utils/isPlainObject' ; import isNonEmptyString from './utils/isNonEmptyString' ; import { StyleObject } from './Rule' ; import { Indexable , Nullable } from './utils/types' ; param id param style returns export const createRule = function createRule ( ... args ) { let [ id , style ] = args as any ; if ( ! style && isPlainObject ( id ) ) { style = id as any ; id = null ; } if ( id && ! isNonEmptyString ( id ) ) { throw new Error ( `StyleSheet.createRule(...): expect string but given : ${ id }` ) ; } if ( ! isPlainObject ( style ) ) { throw new Error ( `StyleSheet.createRule(...): expect plain object but given : ${ style }` ) ; } return registerRule ( id , style ) ; } ; param id param styles returns export const create = function create ( ... args ) { let [ id , styles ] = args as any ; if ( id && ! styles && typeof id === 'object' ) { styles = id as any ; id = null ; } if ( id && ! isNonEmptyString ( id ) ) { throw new Error ( `StyleSheet.create(...): expect string but given : ${ id }` ) ; } if ( ! isPlainObject ( styles ) ) { throw new Error ( `StyleSheet.create(...): expect plain object but given : ${ styles }` ) ; } const styleSheet = { } ; for ( const styleName in styles ) { if ( styles . hasOwnProperty ( styleName ) ) { styleSheet [ styleName ] = createRule ( id && `${ id }_${ styleName }` , styles [ styleName ] ) ; } } return styleSheet ; } ;