UNPKG

aui

Version:
1 lines 10.8 kB
{"version":3,"sources":["aui.coffee","aui.min.js"],"names":["Aui","AuiMixin","AuiOptions","React","cache","jQuery","ref1","ref2","ref3","ref4","ref5","hasProp","hasOwnProperty","indexOf","item","i","l","this","length","window","global","Error","console","warn","site","settings","modules","$","ref","findDOMNode","refs","componentWillMount","render","element","apply","arguments","classify","isValidElement","warning","createClass","mixins","props","children","componentDidMount","Mixin","options","className","classNames","key","len","value","split","call","disableModules","Array","isArray","Object","keys","join","cloneElement","ignoreChildren","Children","map","createElement","Module","message","DOM","span","data-warning","slice","only","callModules","componentWillReceiveProps","$element","module","name","ref6","stringifiedOptions","id","attr","JSON","stringify","componentWillUnmount","exports"],"mappings":"CAAA,WAAA,GAAAA,GAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,KAAAC,eCGIC,KAAaA,SAAW,SAASC,GAAQ,IAAK,GAAIC,GAAI,EAAGC,EAAIC,KAAKC,OAAYF,EAAJD,EAAOA,IAAO,GAAIA,IAAKE,OAAQA,KAAKF,KAAOD,EAAM,MAAOC,EAAK,OAAO,GDFlJ,IADAT,EAAkBa,QAAUC,OAA3BjB,EAAAG,EAAAH,MAAOE,EAAAC,EAAAD,OACD,MAAAF,EAAY,KAAU,IAAAkB,OAAM,+BAC5B,OAAAhB,GAAaiB,QAAQC,KAAK,2EAC1B,OAAA,MAAAlB,GAAA,OAAAE,EAAAF,EAAAmB,OAAA,OAAAhB,EAAAD,EAAAkB,UAAAjB,EAAAkB,QAAA,SAAsCJ,QAAQC,KAAK,6FAQ1DtB,GAOE0B,EAAG,SAACC,GCGA,MDHQvB,GAAOF,EAAM0B,YAAYZ,KAACa,KAAKF,IAAQA,KACnDG,mBAAoB,WAClB,GAAAC,ECME,ODNFA,GAASf,KAACe,OACVf,KAACe,OAAS,WACR,GAAAC,EACA,OADAA,GAAA,MAAAD,GAAA,kBAAAA,GAAAE,MAAUF,EAAQE,MA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AAC,EAAA9B,EAAA+B,EAAAC,CAAAJ,GAAWpE,EAAOF,EAAM0B,YAAYZ,OACpCA,KAAC6D,GAAKL,EAASM,KAAK,gBACpB3E,EAAAuE,EAAM1D,KAAC6D,MAAP1E,EAAAuE,OACAC,EAAA3D,KAAAwB,MAAAf,OAAA,KAAAgD,IAAAE,GC+BSjE,EAAQyC,KAAKwB,EAAMF,KACxB7B,EAAU+B,EAAKF,GD/BjBG,EAAqBG,KAAKC,UAAUpC,GACjCzC,EAAMa,KAAC6D,IAAIJ,KAAaG,IACzBzE,EAAMa,KAAC6D,IAAIJ,GAAUG,ECiCa,kBAArBJ,GAASC,IDhCtBD,EAASC,GAAAxC,MAAAuC,EAASxD,KAACwB,MAAMC,SAASD,MAAMiC,OAE9CQ,qBAAsB,WCqClB,aDpCK9E,GAAMa,KAAC6D,OCwCM,mBAAX3D,SAAqC,OAAXA,SDtCvCA,OAAQnB,IAAMA,GC0CU,mBAAX0E,SAAqC,OAAXA,SDzCvCA,OAAQS,QAAUnF,KC6CfoD,KAAKnC","file":"aui.min.js","sourcesContent":["{React, jQuery} = window or global\r\nunless React? then throw new Error \"Aui: window.React not found.\"\r\nunless jQuery? then console.warn \"Aui: window.jQuery not found, Modules and Semantic-UI will be disabled.\"\r\nunless jQuery?.site?.settings?.modules? then console.warn 'Aui: No Semantic-UI window.jQuery.site.settings.modules found, Semantic will be disabled.'\r\n\r\n## Aui.Mixin\r\n# [JSFiddle around with the examples here!](http://javascriptismagic.github.io/aui/)\r\n# Aui.Mixin is the main wrapper around React Components\r\n# it recursively goes through all it's children,\r\n# finding props that === true or are on the `Aui.modules` list,\r\n# and merges them into the className of each element.\r\nAuiMixin =\r\n ## this.$('react ref')\r\n # jQuery wraps a React ref `<div ref=\"react ref\" />` or jQuery selector `this.$('react ref')`.\r\n # This is the intended way to interact with jQuery to supply utility functionality.\r\n # **Warning!** Use this only in `componentDidMount` or event handlers!\r\n # Do NOT use jQuery to re-arange the dom or you will run into Invarient erros in React,\r\n # use React to arange your dom ahead of time as React is expecting.\r\n $: (ref) -> jQuery React.findDOMNode @refs[ref] or ref\r\n componentWillMount: ->\r\n render = @render\r\n @render = ->\r\n element = render?.apply? @, arguments\r\n if React.isValidElement element\r\n Aui.classify element\r\n else\r\n Aui.classify Aui.warning 'Aui.Mixin: Child is not a React.isValidElement', element\r\n\r\n# (depricated) `<Aui/>` tag, use Aui.Mixin instead.\r\nAui = React.createClass\r\n mixins: [AuiMixin]\r\n render: ->\r\n Aui.warning '<Aui/> tag is depricated, use Aui.Mixin instead', @props.children\r\n componentDidMount: ->\r\n console.warn React.findDOMNode @\r\nAui.Mixin = Aui.AuiMixin = AuiMixin\r\nAui.Aui = Aui\r\n## Aui.$\r\n# The instance of jQuery Aui is using, if needed.\r\nAui.$ = jQuery\r\n\r\n## Aui.classify(element)\r\n# finds all the props that === true or are on the `Aui.modules` list,\r\n# and merging them with the className prop.\r\n# Use this inside the render function like a React helper function.\r\n# Example: `Aui.classify(<div ui grid><div column>content</div></div>)`\r\n# returns `<div ui grid className=\"ui grid\"><div column className=\"column\">content</div></div>`\r\nAui.classify = (element, options) ->\r\n options = AuiOptions options\r\n unless React.isValidElement element\r\n element = Aui.warning 'Aui.classify: element is not a React.isValidElement', element\r\n classify = (element) ->\r\n return element unless React.isValidElement element\r\n classNames = {}\r\n modules = null\r\n props = {}\r\n if element.props.className?\r\n for className in \"#{element.props.className}\".split /\\s+/g\r\n classNames[className] = yes\r\n for own key, value of element.props\r\n classNames[key] = yes if value is yes\r\n if (not options.disableModules) and (Array.isArray value) and (key in Aui.modules)\r\n classNames[key] = yes\r\n modules or= {}\r\n modules[key] = value\r\n props[key] = value\r\n props.className = Object.keys(classNames).join ' '\r\n unless props.className.length\r\n delete props.className\r\n element = React.cloneElement element, props, if options.ignoreChildren then element.props.children else React.Children.map element.props.children, classify\r\n if modules\r\n React.createElement Aui.Module, { modules, options }, element\r\n else element\r\n classify element\r\n\r\n## Aui.warning('string', element)\r\n# console.warn a warning message inside a ReactElement durring a React Component's render function.\r\n# returns the element wrapped in a warning span.\r\n# Use inside the render function of a React Component\r\nAui.warning = (message, element) ->\r\n console.warn message, element\r\n React.DOM.span { 'data-warning': message }, element\r\n\r\nAui.settings =\r\n ## Aui.settings.disableModules\r\n # disables jQuery based Aui.modules from calling\r\n disableModules: not jQuery?\r\n ## Aui.settings.ignoreChildren\r\n # disables recursively calling `Aui.classify` to `props.children`.\r\n ignoreChildren: no\r\n\r\n# (internal) AuiOptions defaults options for `Aui.classify`\r\nclass AuiOptions\r\n constructor: (options) ->\r\n if options instanceof AuiOptions\r\n return options\r\n unless @ instanceof AuiOptions\r\n return new AuiOptions options\r\n options or= {}\r\n for own key, value of Aui.settings\r\n @[key] = if options[key]? then options[key] else value\r\n\r\n## Aui.modules\r\n# A whitelist of jQuery modules.\r\n# `Aui.modules.push('widget')` to configure Aui to support `$.fn.widget`.\r\n# By default this includes `window.jQuery.site.settings.modules` from Semantic-UI.\r\n# When a property is encountered on a ReactElement that matches this whitelist and is an Array,\r\n# the corisponding `window.jQuery.fn[modulename]` will be called with the property's array value.\r\n# This is mostly intended for use with Semantic-UI's javascript,\r\n# but in theory could be used to call any `$.fn` function.\r\nAui.modules = (jQuery?.site?.settings?.modules or []).slice()\r\n\r\n# internal global cache of options passed to module functions.\r\ncache = {}\r\n\r\n# (internal) `<Aui.Module/>`\r\n# This class provides support for `Aui.modules` internally and generally is not used directly.\r\n# `<Aui.Module/>` handles calling jQuery.fn[module] calls when used inside a React Component's render.\r\n# `<div ui checkbox={[]}/>` will automatically call `$.fn.checkbox()`, and\r\n# `<form ui form={[{...}]}></form>` will automatically call `$.fn.form({...})`\r\nAui.Module = React.createClass\r\n render: -> React.Children.only @props.children\r\n componentDidMount: ->\r\n @callModules @props.children.props\r\n componentWillReceiveProps: (props) ->\r\n @callModules props.children.props\r\n callModules: (props) ->\r\n $element = jQuery React.findDOMNode @\r\n @id = $element.attr 'data-reactid'\r\n cache[@id] or= {}\r\n for own module, options of @props.modules\r\n stringifiedOptions = JSON.stringify options\r\n if cache[@id][module] isnt stringifiedOptions\r\n cache[@id][module] = stringifiedOptions\r\n $element[module]? @props.children.props[module]...\r\n return\r\n componentWillUnmount: ->\r\n delete cache[@id]\r\n\r\nwindow?.Aui = Aui\r\nmodule?.exports = Aui\r\n",null],"sourceRoot":"/source/"}