react 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +10 -231
  2. package/addons.js +1 -0
  3. package/lib/AutoFocusMixin.js +30 -0
  4. package/lib/CSSCore.js +115 -0
  5. package/lib/CSSProperty.js +121 -0
  6. package/lib/CSSPropertyOperations.js +97 -0
  7. package/lib/ChangeEventPlugin.js +387 -0
  8. package/lib/ClientReactRootIndex.js +30 -0
  9. package/lib/CompositionEventPlugin.js +260 -0
  10. package/lib/DOMChildrenOperations.js +165 -0
  11. package/lib/DOMProperty.js +268 -0
  12. package/lib/DOMPropertyOperations.js +181 -0
  13. package/lib/Danger.js +187 -0
  14. package/lib/DefaultDOMPropertyConfig.js +203 -0
  15. package/lib/DefaultEventPluginOrder.js +44 -0
  16. package/lib/EnterLeaveEventPlugin.js +145 -0
  17. package/lib/EventConstants.js +76 -0
  18. package/lib/EventListener.js +69 -0
  19. package/lib/EventPluginHub.js +293 -0
  20. package/lib/EventPluginRegistry.js +281 -0
  21. package/lib/EventPluginUtils.js +214 -0
  22. package/lib/EventPropagators.js +143 -0
  23. package/lib/ExecutionEnvironment.js +44 -0
  24. package/lib/LinkedStateMixin.js +46 -0
  25. package/lib/LinkedValueUtils.js +161 -0
  26. package/lib/MobileSafariClickEventPlugin.js +63 -0
  27. package/lib/PooledClass.js +119 -0
  28. package/lib/React.js +95 -0
  29. package/lib/ReactCSSTransitionGroup.js +65 -0
  30. package/lib/ReactCSSTransitionGroupChild.js +138 -0
  31. package/lib/ReactChildren.js +132 -0
  32. package/lib/ReactComponent.js +550 -0
  33. package/lib/ReactComponentBrowserEnvironment.js +158 -0
  34. package/lib/ReactComponentEnvironment.js +26 -0
  35. package/lib/ReactCompositeComponent.js +1455 -0
  36. package/lib/ReactContext.js +67 -0
  37. package/lib/ReactCurrentOwner.js +39 -0
  38. package/lib/ReactDOM.js +207 -0
  39. package/lib/ReactDOMButton.js +68 -0
  40. package/lib/ReactDOMComponent.js +399 -0
  41. package/lib/ReactDOMForm.js +59 -0
  42. package/lib/ReactDOMIDOperations.js +218 -0
  43. package/lib/ReactDOMImg.js +58 -0
  44. package/lib/ReactDOMInput.js +181 -0
  45. package/lib/ReactDOMOption.js +51 -0
  46. package/lib/ReactDOMSelect.js +179 -0
  47. package/lib/ReactDOMSelection.js +189 -0
  48. package/lib/ReactDOMTextarea.js +140 -0
  49. package/lib/ReactDefaultBatchingStrategy.js +75 -0
  50. package/lib/ReactDefaultInjection.js +115 -0
  51. package/lib/ReactDefaultPerf.js +244 -0
  52. package/lib/ReactDefaultPerfAnalysis.js +199 -0
  53. package/lib/ReactErrorUtils.js +37 -0
  54. package/lib/ReactEventEmitter.js +339 -0
  55. package/lib/ReactEventEmitterMixin.js +57 -0
  56. package/lib/ReactEventTopLevelCallback.js +149 -0
  57. package/lib/ReactInjection.js +39 -0
  58. package/lib/ReactInputSelection.js +140 -0
  59. package/lib/ReactInstanceHandles.js +338 -0
  60. package/lib/ReactLink.js +54 -0
  61. package/lib/ReactMarkupChecksum.js +53 -0
  62. package/lib/ReactMount.js +641 -0
  63. package/lib/ReactMountReady.js +95 -0
  64. package/lib/ReactMultiChild.js +425 -0
  65. package/lib/ReactMultiChildUpdateTypes.js +38 -0
  66. package/lib/ReactOwner.js +154 -0
  67. package/lib/ReactPerf.js +85 -0
  68. package/lib/ReactPropTransferer.js +147 -0
  69. package/lib/ReactPropTypeLocationNames.js +31 -0
  70. package/lib/ReactPropTypeLocations.js +29 -0
  71. package/lib/ReactPropTypes.js +359 -0
  72. package/lib/ReactPutListenerQueue.js +61 -0
  73. package/lib/ReactReconcileTransaction.js +181 -0
  74. package/lib/ReactRootIndex.js +36 -0
  75. package/lib/ReactServerRendering.js +59 -0
  76. package/lib/ReactStateSetters.js +111 -0
  77. package/lib/ReactTestUtils.js +394 -0
  78. package/lib/ReactTextComponent.js +99 -0
  79. package/lib/ReactTransitionChildMapping.js +106 -0
  80. package/lib/ReactTransitionEvents.js +97 -0
  81. package/lib/ReactTransitionGroup.js +187 -0
  82. package/lib/ReactUpdates.js +148 -0
  83. package/lib/ReactWithAddons.js +51 -0
  84. package/lib/SelectEventPlugin.js +200 -0
  85. package/lib/ServerReactRootIndex.js +36 -0
  86. package/lib/SimpleEventPlugin.js +413 -0
  87. package/lib/SyntheticClipboardEvent.js +51 -0
  88. package/lib/SyntheticCompositionEvent.js +51 -0
  89. package/lib/SyntheticDragEvent.js +44 -0
  90. package/lib/SyntheticEvent.js +164 -0
  91. package/lib/SyntheticFocusEvent.js +44 -0
  92. package/lib/SyntheticKeyboardEvent.js +58 -0
  93. package/lib/SyntheticMouseEvent.js +85 -0
  94. package/lib/SyntheticTouchEvent.js +50 -0
  95. package/lib/SyntheticUIEvent.js +45 -0
  96. package/lib/SyntheticWheelEvent.js +66 -0
  97. package/lib/Transaction.js +276 -0
  98. package/lib/ViewportMetrics.js +37 -0
  99. package/lib/accumulate.js +54 -0
  100. package/lib/adler32.js +39 -0
  101. package/lib/cloneWithProps.js +59 -0
  102. package/lib/containsNode.js +49 -0
  103. package/lib/copyProperties.js +54 -0
  104. package/lib/createArrayFrom.js +91 -0
  105. package/lib/createFullPageComponent.js +63 -0
  106. package/lib/createNodesFromMarkup.js +93 -0
  107. package/lib/createObjectFrom.js +61 -0
  108. package/lib/cx.js +44 -0
  109. package/lib/dangerousStyleValue.js +57 -0
  110. package/lib/emptyFunction.js +43 -0
  111. package/lib/escapeTextForBrowser.js +47 -0
  112. package/lib/flattenChildren.js +57 -0
  113. package/lib/forEachAccumulated.js +36 -0
  114. package/lib/getActiveElement.js +34 -0
  115. package/lib/getEventKey.js +85 -0
  116. package/lib/getEventTarget.js +36 -0
  117. package/lib/getMarkupWrap.js +118 -0
  118. package/lib/getNodeForCharacterOffset.js +80 -0
  119. package/lib/getReactRootElementInContainer.js +40 -0
  120. package/lib/getTextContentAccessor.js +42 -0
  121. package/lib/getUnboundedScrollPosition.js +45 -0
  122. package/lib/hyphenate.js +35 -0
  123. package/lib/invariant.js +62 -0
  124. package/lib/isEventSupported.js +70 -0
  125. package/lib/isNode.js +33 -0
  126. package/lib/isTextInputElement.js +49 -0
  127. package/lib/isTextNode.js +30 -0
  128. package/lib/joinClasses.js +44 -0
  129. package/lib/keyMirror.js +58 -0
  130. package/lib/keyOf.js +41 -0
  131. package/lib/memoizeStringOnly.js +39 -0
  132. package/lib/merge.js +37 -0
  133. package/lib/mergeHelpers.js +136 -0
  134. package/lib/mergeInto.js +45 -0
  135. package/lib/mixInto.js +34 -0
  136. package/lib/objMap.js +47 -0
  137. package/lib/objMapKeyVal.js +47 -0
  138. package/lib/onlyChild.js +43 -0
  139. package/lib/performanceNow.js +42 -0
  140. package/lib/shallowEqual.js +49 -0
  141. package/lib/shouldUpdateReactComponent.js +58 -0
  142. package/lib/toArray.js +75 -0
  143. package/lib/traverseAllChildren.js +189 -0
  144. package/lib/warning.js +48 -0
  145. package/package.json +33 -21
  146. package/react.js +1 -0
  147. package/.npmignore +0 -7
  148. package/.travis.yml +0 -7
  149. package/Jakefile.js +0 -39
  150. package/LICENSE +0 -19
  151. package/browser-test/dist.html +0 -90
  152. package/browser-test/index.html +0 -86
  153. package/browser-test/min.html +0 -90
  154. package/dist/react.js +0 -3141
  155. package/dist/react.min.js +0 -22
  156. package/doc/advanced.md +0 -174
  157. package/doc/color-def.graffle +0 -938
  158. package/doc/color-def.png +0 -0
  159. package/doc/simple.dot +0 -25
  160. package/doc/simple.png +0 -0
  161. package/examples/longer-example.js +0 -41
  162. package/examples/simple.js +0 -45
  163. package/examples/using-ast-directly.js +0 -30
  164. package/examples/using-events1.js +0 -79
  165. package/examples/using-log-events.js +0 -43
  166. package/lib/base-task.js +0 -120
  167. package/lib/cb-task.js +0 -84
  168. package/lib/core.js +0 -138
  169. package/lib/dsl.js +0 -138
  170. package/lib/error.js +0 -55
  171. package/lib/event-collector.js +0 -81
  172. package/lib/event-manager.js +0 -89
  173. package/lib/eventemitter.js +0 -20
  174. package/lib/finalcb-first-task.js +0 -68
  175. package/lib/finalcb-task.js +0 -65
  176. package/lib/id.js +0 -22
  177. package/lib/input-parser.js +0 -56
  178. package/lib/log-events.js +0 -101
  179. package/lib/parse.js +0 -41
  180. package/lib/promise-resolve.js +0 -50
  181. package/lib/promise-task.js +0 -93
  182. package/lib/react.js +0 -59
  183. package/lib/ret-task.js +0 -71
  184. package/lib/sprintf.js +0 -18
  185. package/lib/status.js +0 -14
  186. package/lib/task.js +0 -251
  187. package/lib/track-tasks.js +0 -74
  188. package/lib/validate.js +0 -159
  189. package/lib/vcon.js +0 -113
  190. package/lib/when-task.js +0 -84
  191. package/src/dist.build.requirejs +0 -20
  192. package/test/ast.mocha.js +0 -136
  193. package/test/cb-task.mocha.js +0 -220
  194. package/test/core-deferred.mocha.js +0 -143
  195. package/test/core-when.mocha.js +0 -96
  196. package/test/core.mocha.js +0 -589
  197. package/test/dsl.mocha.js +0 -352
  198. package/test/event-manager.mocha.js +0 -119
  199. package/test/exec-options.mocha.js +0 -48
  200. package/test/finalcb-task.mocha.js +0 -58
  201. package/test/input-parser.mocha.js +0 -86
  202. package/test/log-events.mocha.js +0 -88
  203. package/test/mocha.opts +0 -2
  204. package/test/module-use.mocha.js +0 -164
  205. package/test/promise-auto-resolve.mocha.js +0 -68
  206. package/test/ret-task.mocha.js +0 -220
  207. package/test/task.mocha.js +0 -42
  208. package/test/validate-cb-task.mocha.js +0 -100
  209. package/test/validate-ret-task.mocha.js +0 -110
  210. package/test/validate.mocha.js +0 -324
  211. package/test/vcon.mocha.js +0 -193
  212. package/vendor/chai/chai.js +0 -4251
  213. package/vendor/jquery/jquery-1.7.1.js +0 -9266
  214. package/vendor/jquery/jquery-1.7.1.min.js +0 -4
  215. package/vendor/node/util.js +0 -531
  216. package/vendor/requirejs/require.js +0 -2045
  217. package/vendor/requirejs/require.min.js +0 -36
package/README.md CHANGED
@@ -1,238 +1,17 @@
1
- # React.js
1
+ # react
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/jeffbski/react.png?branch=master)](http://travis-ci.org/jeffbski/react)
3
+ An npm package to get you immediate access to [React](http://facebook.github.io/react/),
4
+ without also requiring the JSX transformer. This is especially useful for cases where you
5
+ want to [`browserify`](https://github.com/substack/node-browserify) your module using
6
+ `React`.
4
7
 
5
- React is a javascript module to make it easier to work with asynchronous code, by reducing boilerplate code and improving error and exception handling while allowing variable and task dependencies when defining flow. This project is applying the concepts of Reactive programming or Dataflow to controlling application flow.
6
8
 
7
- This async flow control module is initially designed to work with Node.js but is planned to be extended to browser and other environments.
9
+ ## Example Usage
8
10
 
9
- React gets its name from similarities with how "chain reactions" work in the physical world. You start the reaction and then it cascades and continues until complete.
11
+ ```js
12
+ var React = require('react');
10
13
 
11
- Also "Reactive Programming" or "Dataflow" describe defining flow which reacts to the data similar to how a spreadsheet updates cells. These are good examples of how React controls flow based on when data is available
12
-
13
- - Reactive programming - <http://en.wikipedia.org/wiki/Reactive_programming>
14
- - Dataflow programming - <http://en.wikipedia.org/wiki/Dataflow>
15
- - Dataflow Programming: Handling Huge Data Loads Without Adding Complexity (Dr. Dobb's Sept 19, 2011) - <http://drdobbs.com/database/231400148>
16
-
17
- It takes inspiration from several projects including:
18
-
19
- - Tim Caswell and Elijah Insua's [conductor](https://github.com/tmpvar/conductor) - [Article](http://howtonode.org/step-of-conductor)
20
- - Caolan McMahon's [async](https://github.com/caolan/async)
21
-
22
- ## Example Video and Comparison
23
-
24
- Ryan Atkinson did a nice job of demonstrating some of the power of react as compared to async and native callback code. http://www.youtube.com/embed/5EDucc56UnA?rel=0
25
-
26
- You can read more and see his example site here https://github.com/ryanatkn/react-writeup
27
-
28
-
29
- ## Goals
30
-
31
- - Minimize boilerplate code needed for working with asynchronous functions
32
- - Minimize the need to customize your code simply to use async flow control. The use of a flow control module ideally should not affect the way you write your code, it should only help take over some of the burden.
33
- - Improved error and exception handling
34
- - Provide useful stack traces and context information for easier debugging
35
- - Make code more readable and easier to understand which should translate to less defects
36
- - Provide the right level of abstraction to make it easier to refactor code, without being too magical
37
- - Allow the mixing of pure functions, method calls, and callback style functions in the flow
38
-
39
- ## Supports
40
-
41
- - async node-style callback(err, arg...) functions
42
- - sync functions which directly return value
43
- - object instance method calls
44
- - class method calls
45
- - selectFirst flow where the first task that returns defined, non-null value is used
46
- - promise style functions - also automatic resolution of promise inputs (optionally loaded with `react.resolvePromises();`)
47
- - use of resulting flow function as callback style or promise style (if no callback provided) (provided via plugin corresponding to the promise library used) See https://github.com/jeffbski/react-deferred
48
- - supports ES5 browsers (can work with others by using polyfills)
49
- - (planned) iteration on arrays, streams, sockets
50
- - (planned) event emitter integration
51
- - tested on node 0.8, 0.10, 0.11
52
-
53
- The tasks can be mixed, meaning you can use async, sync, object method calls, class method calls, etc in the same flow.
54
-
55
- ## Concept
56
-
57
- Borrowing heavily from Tim and Elijah's ideas for conductor, this async flow control module provides a way to construct a flow from a
58
- collection of rules based on functions or methods (referred to as _tasks_ in this module). It allows dependencies to be defined between the tasks so they can run in parallel as their dependencies are satisfied. React can us both variable dependencies and task dependencies.
59
-
60
- As tasks complete, React watches the dependencies and kicks off additional tasks that have all their dependencies met and are ready to execute. This allows the flow to run at maximum speed without needing to arbitrarily block tasks into groups of parallel and serial flow.
61
-
62
- To reduce the boilerplate code needed and improve error handling, React automatically provides callback functions for your asynchronous code. These React-provided callback functions perform these steps:
63
-
64
- 1. check for error and handle by calling outer callback function with this error after augmenting it with additional context information for easier debugging
65
- 2. save the callback variables into a context for future reference
66
- 3. call back into React (and it will kick off additional tasks that are now ready to go)
67
- 4. Using the dependencies specified for each
68
-
69
- ## Design
70
-
71
- - Parse and validate DSL rules at module load time creating AST
72
- - Validate the flow AST at module load time - determine if dependencies can all be met as defined
73
- - Execute the flow AST by calling the function with arguments
74
-
75
- ## Installing
76
-
77
- npm install react
78
-
79
- OR
80
-
81
- Pull from github - http://github.com/jeffbski/react
82
-
83
- ## Examples
84
-
85
- <a name="defaultDSL"/>
86
- ### Example using default DSL interface
87
-
88
- - Simple example showing flow definition of two async functions feeding a
89
- synchronous function.
90
-
91
- - First two async functions inputs are satisfied by the flow inputs, so
92
- they will both run immediately in parallel.
93
-
94
- - The last function waits for the outputs of the previous ones, then
95
- executes synchronously.
96
-
97
- - Finally the flow calls the callback with the output values once all
98
- the tasks have completed.
99
-
100
- ```javascript
101
- // in your foobar module
102
- var react = require('react');
103
-
104
- // some normal async and sync functions
105
- function loadFoo(fooPath, cb) {
106
- setTimeout(function () {
107
- cb(null, [fooPath, 'data'].join(':'));
108
- }, 10);
109
- }
110
-
111
- function loadBar(barPath, barP2, cb) {
112
- setTimeout(function () {
113
- cb(null, [barPath, barP2, 'data'].join(':'));
114
- }, 10);
115
- }
116
-
117
- function render(foo, bar) {
118
- return ['<html>', foo, '/', bar, '</html>'].join('');
119
- }
120
-
121
- // define fn, glue together with react, it will parallelize
122
- // starts with name and in/out params, then the tasks
123
- var loadRender = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
124
- loadFoo, 'fooPath, cb -> err, foo', // async cb function
125
- loadBar, 'barPath, barP2, cb -> err, bar', // async cb function
126
- render, 'foo, bar -> renderedOut' // sync function using outputs from first two
127
- );
128
-
129
- exports.loadRender = loadRender; // is a normal fn created by react
130
-
131
-
132
- // in a different module far far away, use this as any other node function
133
- var foobar = require('foobar');
134
- foobar.loadRender('foo.txt', 'bar.txt', 'BBB', function (err, renderedOut) {
135
- // tasks in loadRender were parallelized based on their input dependencies
136
- console.error('results:', renderedOut);
137
- });
138
- ```
139
-
140
- Below is a graph of how the dependencies are mapped by React which
141
- also indicates how the tasks will be executed. This was generated by the
142
- react plugin [react-graphviz](https://github.com/jeffbski/react-graphviz)
143
- which you can use to also graph your flows.
144
-
145
- ![simple.png](https://github.com/jeffbski/react/raw/master/doc/simple.png)
146
-
147
-
148
-
149
- ## User API
150
-
151
- The main function returned from require('react') can be used to define the AST used for the processing of the rules or flow.
152
-
153
- It takes the following arguments to define a flow function:
154
-
155
- ```javascript
156
- var fn = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
157
- loadFoo, 'fooPath, cb -> err, foo',
158
- loadBar, 'barPath, barP2, cb -> err, bar',
159
- render, 'foo, bar -> renderedOut'
160
- );
161
- ```
162
-
163
- ![color-def](https://github.com/jeffbski/react/raw/master/doc/color-def.png)
164
-
165
- 1. **flow/function name** - string - represents the name of the flow or function that will be created. React will use the name when generating events so you can monitor progress and performance and also when errors occur.
166
- 2. **in/out flow parameter definition** - string - the inputs and outputs for the flow function. The parameters are specified in one single string for easy typing, separated by commas. The output follows the input after being separated by a `->`. Use the parameter name `cb` or `callback` to specify the Node style callback and `err` to represent the error parameter as the first output parameter of the callback. Literal values can also be specified directly (true, false, numbers, this, null). Literal strings can simply be quoted using single or double quotes.
167
- 3. **optional flow options** - object - If an object is provided immediately after the in/out flow def, then these options will be provided to react to customize the flow. The `locals` property can contain an object map of any local variables you want to reference in the flow (other than what is passed in as parameters). For example: `{ locals: { foo: foo, bar: bar }}` would make local vars available in the flow. Note that global variables are already available in the flow.
168
- 4. **function reference or method string** - Specify the function to be called for this task, or if calling a method off of an object being passed in or returned by a task, use a string to specify like `'obj.method'`. These can be asynchronous Node-style callback `cb(err, ...)` functions or synchronous functions which simply return values directly.
169
- 5. **in/out task parameter definition** - string - similar to the in/out flow parameter definition above, these are the inputs and outputs that are passed to a task function and returned from a task function. The inputs will need to match either those from the flow inputs or outputs from other tasks that will run before this task. React will use the inputs as dependencies, so it will invoke and wait for response from the tasks that provide the dependent inputs. So simply by specifying inputs and outputs for the tasks, React will prioritize and parallelize tasks to run as fast as possible. Use `cb` or `callback` along with `err` to specify asynchronous Node style `cb(err, ...)` task, or omit both to specify a synchronous task.A synchronous task can only have a single return parameter.
170
- 6. **optional task options** - object - if an object is provided this can be used to specify additional options for this task. Currently the valid options for a task are:
171
- - **name** - string - specifies a name for a task, otherwise React will try to use the function name or method string if it is unique in the flow. If a name is not unique subsequent tasks will have `_index` (zero based index of the task) added to create unique name. If you specify a name, you will also want to indicate a unique name for within the flow otherwise it will get a suffix as well. Example: `{ name: 'myTaskName' }`
172
- - **after** - string, function reference, or array of string or function refs - specify additional preconditions that need to be complete before this task can run. In addition to the input dependencies being met, wait for these named tasks to complete before running. The preconditions are specified using the name of the task or if the task function was only used once and is a named function (not anonymous), you can just provide the function reference and it will determine name from it. Example: `{ after: 'foo' }` or `{ after: ['foo', 'bar'] }`
173
- 7. **repeat 4-6** - repeat steps 4-6 to specify additional tasks in this flow. As dependencies are met for tasks, React will invoke additional tasks that are ready to run in the order they are defined in this flow definition. So while the order does have some influence on the execution, it is primarily defined by the input dependencies and any other additonal preconditions specified with the `after` option. If you want to guarantee that something only runs after something else completes, then it will need to use an output from that task or specify the dependency with an `after`.
174
-
175
-
176
- The flow function created by react from the input definition is a normal Node-style function which can be used like any other. These flow functions can be defined in a module and exported, they can be passed into other functions, used as methods on objects (the `this` context is passed in and available).
177
-
178
- ### Debugging React
179
-
180
- React has a built-in plugin which can be loaded that will enable logging of tasks and flow as it executes very useful for debugging. For full details see [Advanced React - LogEvents](https://github.com/jeffbski/react/blob/master/doc/advanced.md#LogEvents) along with the other plugins and an explanation of the AST React uses.
181
-
182
- ```javascript
183
- var react = require('react');
184
- react.logEvents(); // turn on flow and task logging for all react functions
14
+ // You can also access ReactWithAddons.
15
+ var React = require('react/addons');
185
16
  ```
186
17
 
187
- ### Advanced React
188
-
189
- React has many additional plugins and features which enable logging, monitoring, promise resolution, etc.
190
-
191
- See the [Advanced React](https://github.com/jeffbski/react/blob/master/doc/advanced.md) for details on the AST React uses for processing and other plugins that are available.
192
-
193
-
194
-
195
- ## Status
196
-
197
- - 2013-05-23 - Allow use of globals without needing to specify in locals, move 'use strict' into define, upgrade amdefine@0.0.5, eventemitter@0.4.11, requirejs@2.1.6, mocha@1.10.0, chai@1.6.0, jake@0.5.15 (v0.7.0)
198
- - 2013-04-12 - Update to test on node 0.8, 0.10, 0.11
199
- - 2012-10-17 - Fix issue with logEvents and provide way to disable logEvents(false) (v0.6.3)
200
- - 2012-09-12 - Upgrade RequireJS@2.0.6, mocha@1.4.2, chai@1.2.0, jake@0.3.16. Update travis config to include Node 0.8 (v0.6.2)
201
- - 2012-04-25 - Browser compatibility issue with process check, (v0.6.1)
202
- - 2012-04-05 - Remove dependency on sprint, use util.format
203
- - 2012-03-28 - Make react AMD-enabled and compatible with ES5 browsers and node.js, provide single file dist and min, add browser tests (v0.6.0)
204
- - 2012-03-24 - Add Travis-CI, remove promised-io since failing to install in travis-ci for node 0.6/0.7, switch from tap to mocha/chai
205
- - 2012-03-12 - Pass ast.define events to process (v0.5.2)
206
- - 2012-01-18 - Remove old DSL interfaces, improve plugin loading, log flow name with task name, ast.defined event, test with node 0.7.0 (v0.5.1)
207
- - 2012-01-17 - Additional documentation (v0.3.5)
208
- - 2012-01-16 - Refine events and create logging plugin (v0.3.3)
209
- - 2012-01-13 - Add promise tasks, promise resolution, refactor alternate DSL interfaces as optional requires (v0.3.0)
210
- - 2012-01-11 - Provide warning/error when name is skipped in default DSL, literal check in validate (v0.2.5)
211
- - 2012-01-10 - Create default DSL for react(), create error for missing variables, list remaining tasks when flow won't complete
212
- - 2011-12-21 - Refactor from ground up with tests, changes to the interfaces
213
- - 2011-10-26 - React is in active development and interface may change frequently in these early stages. Current code is functional but does not perform validation yet. Additional interfaces are planned to make it easy to define flows in a variety of ways. Documentation and examples forthcoming.
214
-
215
- ## Test Results
216
-
217
- [![Build Status](https://secure.travis-ci.org/jeffbski/react.png?branch=master)](http://travis-ci.org/jeffbski/react)
218
-
219
- ```bash
220
- mocha
221
-
222
- 178 tests complete
223
- ```
224
-
225
- ## License
226
-
227
- - [MIT license](http://github.com/jeffbski/react/raw/master/LICENSE)
228
-
229
- ## Contributors
230
-
231
- - Author: Jeff Barczewski (@jeffbski)
232
-
233
- ## Contributing
234
-
235
- - Source code repository: http://github.com/jeffbski/react
236
- - Ideas and pull requests are encouraged - http://github.com/jeffbski/react/issues
237
-
238
- - You may contact me at @jeffbski or through github at http://github.com/jeffbski
package/addons.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./lib/ReactWithAddons');
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright 2013-2014 Facebook, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * @providesModule AutoFocusMixin
17
+ * @typechecks static-only
18
+ */
19
+
20
+ "use strict";
21
+
22
+ var AutoFocusMixin = {
23
+ componentDidMount: function() {
24
+ if (this.props.autoFocus) {
25
+ this.getDOMNode().focus();
26
+ }
27
+ }
28
+ };
29
+
30
+ module.exports = AutoFocusMixin;
package/lib/CSSCore.js ADDED
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Copyright 2013-2014 Facebook, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * @providesModule CSSCore
17
+ * @typechecks
18
+ */
19
+
20
+ var invariant = require("./invariant");
21
+
22
+ /**
23
+ * The CSSCore module specifies the API (and implements most of the methods)
24
+ * that should be used when dealing with the display of elements (via their
25
+ * CSS classes and visibility on screen. It is an API focused on mutating the
26
+ * display and not reading it as no logical state should be encoded in the
27
+ * display of elements.
28
+ */
29
+
30
+ var CSSCore = {
31
+
32
+ /**
33
+ * Adds the class passed in to the element if it doesn't already have it.
34
+ *
35
+ * @param {DOMElement} element the element to set the class on
36
+ * @param {string} className the CSS className
37
+ * @return {DOMElement} the element passed in
38
+ */
39
+ addClass: function(element, className) {
40
+ ("production" !== process.env.NODE_ENV ? invariant(
41
+ !/\s/.test(className),
42
+ 'CSSCore.addClass takes only a single class name. "%s" contains ' +
43
+ 'multiple classes.', className
44
+ ) : invariant(!/\s/.test(className)));
45
+
46
+ if (className) {
47
+ if (element.classList) {
48
+ element.classList.add(className);
49
+ } else if (!CSSCore.hasClass(element, className)) {
50
+ element.className = element.className + ' ' + className;
51
+ }
52
+ }
53
+ return element;
54
+ },
55
+
56
+ /**
57
+ * Removes the class passed in from the element
58
+ *
59
+ * @param {DOMElement} element the element to set the class on
60
+ * @param {string} className the CSS className
61
+ * @return {DOMElement} the element passed in
62
+ */
63
+ removeClass: function(element, className) {
64
+ ("production" !== process.env.NODE_ENV ? invariant(
65
+ !/\s/.test(className),
66
+ 'CSSCore.removeClass takes only a single class name. "%s" contains ' +
67
+ 'multiple classes.', className
68
+ ) : invariant(!/\s/.test(className)));
69
+
70
+ if (className) {
71
+ if (element.classList) {
72
+ element.classList.remove(className);
73
+ } else if (CSSCore.hasClass(element, className)) {
74
+ element.className = element.className
75
+ .replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1')
76
+ .replace(/\s+/g, ' ') // multiple spaces to one
77
+ .replace(/^\s*|\s*$/g, ''); // trim the ends
78
+ }
79
+ }
80
+ return element;
81
+ },
82
+
83
+ /**
84
+ * Helper to add or remove a class from an element based on a condition.
85
+ *
86
+ * @param {DOMElement} element the element to set the class on
87
+ * @param {string} className the CSS className
88
+ * @param {*} bool condition to whether to add or remove the class
89
+ * @return {DOMElement} the element passed in
90
+ */
91
+ conditionClass: function(element, className, bool) {
92
+ return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className);
93
+ },
94
+
95
+ /**
96
+ * Tests whether the element has the class specified.
97
+ *
98
+ * @param {DOMNode|DOMWindow} element the element to set the class on
99
+ * @param {string} className the CSS className
100
+ * @returns {boolean} true if the element has the class, false if not
101
+ */
102
+ hasClass: function(element, className) {
103
+ ("production" !== process.env.NODE_ENV ? invariant(
104
+ !/\s/.test(className),
105
+ 'CSS.hasClass takes only a single class name.'
106
+ ) : invariant(!/\s/.test(className)));
107
+ if (element.classList) {
108
+ return !!className && element.classList.contains(className);
109
+ }
110
+ return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
111
+ }
112
+
113
+ };
114
+
115
+ module.exports = CSSCore;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Copyright 2013-2014 Facebook, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * @providesModule CSSProperty
17
+ */
18
+
19
+ "use strict";
20
+
21
+ /**
22
+ * CSS properties which accept numbers but are not in units of "px".
23
+ */
24
+ var isUnitlessNumber = {
25
+ columnCount: true,
26
+ fillOpacity: true,
27
+ flex: true,
28
+ flexGrow: true,
29
+ flexShrink: true,
30
+ fontWeight: true,
31
+ lineClamp: true,
32
+ lineHeight: true,
33
+ opacity: true,
34
+ order: true,
35
+ orphans: true,
36
+ widows: true,
37
+ zIndex: true,
38
+ zoom: true
39
+ };
40
+
41
+ /**
42
+ * @param {string} prefix vendor-specific prefix, eg: Webkit
43
+ * @param {string} key style name, eg: transitionDuration
44
+ * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
45
+ * WebkitTransitionDuration
46
+ */
47
+ function prefixKey(prefix, key) {
48
+ return prefix + key.charAt(0).toUpperCase() + key.substring(1);
49
+ }
50
+
51
+ /**
52
+ * Support style names that may come passed in prefixed by adding permutations
53
+ * of vendor prefixes.
54
+ */
55
+ var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
56
+
57
+ // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
58
+ // infinite loop, because it iterates over the newly added props too.
59
+ Object.keys(isUnitlessNumber).forEach(function(prop) {
60
+ prefixes.forEach(function(prefix) {
61
+ isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
62
+ });
63
+ });
64
+
65
+ /**
66
+ * Most style properties can be unset by doing .style[prop] = '' but IE8
67
+ * doesn't like doing that with shorthand properties so for the properties that
68
+ * IE8 breaks on, which are listed here, we instead unset each of the
69
+ * individual properties. See http://bugs.jquery.com/ticket/12385.
70
+ * The 4-value 'clock' properties like margin, padding, border-width seem to
71
+ * behave without any problems. Curiously, list-style works too without any
72
+ * special prodding.
73
+ */
74
+ var shorthandPropertyExpansions = {
75
+ background: {
76
+ backgroundImage: true,
77
+ backgroundPosition: true,
78
+ backgroundRepeat: true,
79
+ backgroundColor: true
80
+ },
81
+ border: {
82
+ borderWidth: true,
83
+ borderStyle: true,
84
+ borderColor: true
85
+ },
86
+ borderBottom: {
87
+ borderBottomWidth: true,
88
+ borderBottomStyle: true,
89
+ borderBottomColor: true
90
+ },
91
+ borderLeft: {
92
+ borderLeftWidth: true,
93
+ borderLeftStyle: true,
94
+ borderLeftColor: true
95
+ },
96
+ borderRight: {
97
+ borderRightWidth: true,
98
+ borderRightStyle: true,
99
+ borderRightColor: true
100
+ },
101
+ borderTop: {
102
+ borderTopWidth: true,
103
+ borderTopStyle: true,
104
+ borderTopColor: true
105
+ },
106
+ font: {
107
+ fontStyle: true,
108
+ fontVariant: true,
109
+ fontWeight: true,
110
+ fontSize: true,
111
+ lineHeight: true,
112
+ fontFamily: true
113
+ }
114
+ };
115
+
116
+ var CSSProperty = {
117
+ isUnitlessNumber: isUnitlessNumber,
118
+ shorthandPropertyExpansions: shorthandPropertyExpansions
119
+ };
120
+
121
+ module.exports = CSSProperty;