Fixing
This commit is contained in:
@@ -103,23 +103,42 @@ post '/cart/confirmation' do
|
||||
end
|
||||
|
||||
post '/payment/confirmation' do
|
||||
data = param[:custom]
|
||||
anonymus = data[:anonymous_id_string]
|
||||
user = data[:user_id]
|
||||
data = JSON.parse params[:custom]
|
||||
|
||||
cart = Cart.just_find(anonymus, user)
|
||||
allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note"]
|
||||
params = data.reject { |key,_| !allowed_keys.include?(key) }
|
||||
cart.delivery_destination.update_attributes(params)
|
||||
cart.delivery_destination.save!
|
||||
puts "Data #{data.inspect}"
|
||||
|
||||
anonymous = data["anonymous_id_string"]
|
||||
user = data["user_id"]
|
||||
user ||= -1
|
||||
user = user.to_i
|
||||
|
||||
cart = Cart.just_find(anonymous, user)
|
||||
if cart.item_in_carts.length > 0
|
||||
cart.ordered = true
|
||||
cart.save!
|
||||
end
|
||||
|
||||
Cart.find_or_create(anonymous, logged_in_user_id)
|
||||
Cart.find_or_create(anonymous, user)
|
||||
report_to_trello(cart)
|
||||
send_order_email(cart)
|
||||
"OK".to_json
|
||||
end
|
||||
|
||||
get '/pikpay/confirmation' do
|
||||
anonymous = params["anonymous_id_string"]
|
||||
user = params["user_id"]
|
||||
user ||= -1
|
||||
user = user.to_i
|
||||
|
||||
cart = Cart.just_find(anonymous, user)
|
||||
if cart.item_in_carts.length > 0
|
||||
cart.ordered = true
|
||||
cart.save!
|
||||
end
|
||||
|
||||
Cart.find_or_create(anonymous, user)
|
||||
report_to_trello(cart)
|
||||
send_order_email(cart)
|
||||
|
||||
redirect "http://localhost:3001/hvala"
|
||||
end
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddPaymentMethodToDeliveryDestination < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :delivery_destinations, :payment_method, :string
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160108081208) do
|
||||
ActiveRecord::Schema.define(version: 20160111024541) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -67,7 +67,7 @@ ActiveRecord::Schema.define(version: 20160108081208) do
|
||||
t.integer "user_id"
|
||||
t.string "anonymous_id_string"
|
||||
t.boolean "instant_delivery", default: false
|
||||
t.string "payment_method", default: "cash_on_delivery"
|
||||
t.string "payment_method"
|
||||
end
|
||||
|
||||
create_table "delivery_time_estimations", force: :cascade do |t|
|
||||
|
||||
@@ -19,7 +19,12 @@ var CheckoutPage = React.createClass({
|
||||
render: function() {
|
||||
var choosePayment = (
|
||||
<div className="payment-btn">
|
||||
<PaymentSelect onSubmitPaypal={this._handleOnSubmitPaypal} deliveryDestination={this.state.deliveryDestination} amount={CartStore.getAmount()} deliveryCost={CartStore.getDeliveryCost(false)} />
|
||||
<PaymentSelect deliveryDestination={this.state.deliveryDestination}
|
||||
amount={CartStore.getAmount()}
|
||||
deliveryCost={CartStore.getDeliveryCost(false)}
|
||||
disabled={!this.state.isDeliveryDestinationValid}
|
||||
onCashClick={this._onOrderClick}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -97,25 +102,21 @@ var CheckoutPage = React.createClass({
|
||||
<textarea className="form-control" id="note" name="note" value={this.state.deliveryDestination.get('note')} onChange={this._onFieldChange} ></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-group ">
|
||||
<label className="col-md-4 control-label" htmlFor="order"></label>
|
||||
<div className="col-md-8">
|
||||
<div> Roba: <CartTotal items={this.state.items} itemCounts={this.state.itemCounts} /><br />
|
||||
<span className={this.state.deliveryDestinationErrors['place'] ? 'hidden' : 'shown'}>
|
||||
Dostava: <CartTotal deliveryCosts={this.state.deliveryCosts} /><br />
|
||||
Ukupno: <CartTotal items={this.state.items} itemCounts={this.state.itemCounts} deliveryCosts={this.state.deliveryCosts} />
|
||||
<div className="form-group">
|
||||
<label className="col-md-4 control-label" htmlFor="order"></label>
|
||||
<div className="col-md-8">
|
||||
<div> Roba: <CartTotal items={this.state.items} itemCounts={this.state.itemCounts} /><br />
|
||||
<span className={this.state.deliveryDestinationErrors['place'] ? 'hidden' : 'shown'}>
|
||||
Dostava: <CartTotal deliveryCosts={this.state.deliveryCosts} /><br />
|
||||
Ukupno: <CartTotal items={this.state.items} itemCounts={this.state.itemCounts} deliveryCosts={this.state.deliveryCosts} />
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<br />
|
||||
Plaćanje: <br /><br />
|
||||
<div className="payment-btn"><button id="order" name="order" className="mybutton" disabled={!this.state.isDeliveryDestinationValid} onClick={this._onOrderClick}>Završi narudžbu</button></div>
|
||||
{choosePayment}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="payment-select-container">
|
||||
{choosePayment}
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
||||
17
front-ui/app/components/payment/cashOnDeliveryButton.js
Normal file
17
front-ui/app/components/payment/cashOnDeliveryButton.js
Normal file
@@ -0,0 +1,17 @@
|
||||
var React = require('react');
|
||||
var ItemActions = require('../../actions/itemActions');
|
||||
var NavigationActions = require('../../actions/navigationActions');
|
||||
var NavigationStore = require('../../stores/navigationStore');
|
||||
|
||||
var Globals = require('../../globals');
|
||||
var Router = require('react-router');
|
||||
|
||||
var CashOnDeliveryButton = React.createClass({
|
||||
render: function() {
|
||||
return (
|
||||
<button type="button" className="btn mybutton payment-btn" disabled={this.props.disabled} onClick={this.props.onCashClick}>Plati prilikom preuzimanja</button>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = CashOnDeliveryButton;
|
||||
@@ -6,13 +6,29 @@ var NavigationStore = require('../../stores/navigationStore');
|
||||
var Globals = require('../../globals');
|
||||
var Router = require('react-router');
|
||||
var PaypalButton = require('./paypalButton');
|
||||
var PikpaylButton = require('./pikpayButton');
|
||||
var CashOnDeliveryButton = require('./cashOnDeliveryButton');
|
||||
|
||||
var PaymentSelect = React.createClass({
|
||||
render: function() {
|
||||
var cashOnDeliveryBtn = ( <CashOnDeliveryButton onCashClick={this.props.onCashClick} disabled={this.props.disabled}/> );
|
||||
var pikpayBtn = ( <PikpaylButton amount={this.props.amount} deliveryCost={this.props.deliveryCost} disabled={this.props.disabled} deliveryDestination={this.props.deliveryDestination}/> );
|
||||
var paypalBtn = ( <PaypalButton disabled={this.props.disabled} deliveryDestination={this.props.deliveryDestination} amount={this.props.amount} deliveryCost={this.props.deliveryCost} /> );
|
||||
|
||||
return (
|
||||
<div className="payment_select">
|
||||
<PaypalButton deliveryDestination={this.props.deliveryDestination} amount={this.props.amount} deliveryCost={this.props.deliveryCost} />
|
||||
</div>);
|
||||
<div>
|
||||
<div className="payment_select btn-group payment-select-desktop hidden-xs">
|
||||
{cashOnDeliveryBtn}
|
||||
{pikpayBtn}
|
||||
{paypalBtn}
|
||||
</div>
|
||||
|
||||
<div className="payment_select btn-group-vertical payment-select-mobile visible-xs">
|
||||
{cashOnDeliveryBtn}
|
||||
{pikpayBtn}
|
||||
{paypalBtn}
|
||||
</div>
|
||||
</div>);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -2,27 +2,38 @@ var React = require('react');
|
||||
var ItemActions = require('../../actions/itemActions');
|
||||
var NavigationActions = require('../../actions/navigationActions');
|
||||
var NavigationStore = require('../../stores/navigationStore');
|
||||
var CartStore = require('../../stores/cartStore');
|
||||
var CartActions = require('../../actions/cartActions');
|
||||
|
||||
var Globals = require('../../globals');
|
||||
var Router = require('react-router');
|
||||
|
||||
var PaypalButton = React.createClass({
|
||||
render: function() {
|
||||
var deliveryDestination = JSON.stringify(this.props.deliveryDestination);
|
||||
var deliveryDestination = JSON.stringify(
|
||||
{
|
||||
'anonymous_id_string': this.props.deliveryDestination.get('anonymous_id_string'),
|
||||
'user_id': this.props.deliveryDestination.get('user_id')
|
||||
});
|
||||
var amount = Globals.ConvertToEuro(this.props.amount);
|
||||
var deliveryCost = Globals.ConvertToEuro(this.props.deliveryCost);
|
||||
var notifyUrl = Globals.ApiUrl + "/payment/confirmation";
|
||||
var root = location.protocol + '//' + location.host;
|
||||
var return_url = root + "/hvala_paypal";
|
||||
var cancel_return_url = root + "/odgodjeno";
|
||||
var return_url = root + "/hvala";
|
||||
var cancel_return_url = root + "/dostava";
|
||||
|
||||
return (
|
||||
<<<<<<< HEAD
|
||||
<div>
|
||||
<form onSubmit={this.props.onSubmitPaypal} action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
||||
=======
|
||||
<button onClick={this._onPaypalClick} disabled={this.props.disabled} type="button" className="btn mybutton payment-btn">Pay with paypal
|
||||
<form id="paypal_form" className="hidden" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
||||
>>>>>>> 7b2552c31c6f356bd24e3df0def6d3a021f6c138
|
||||
<input type="hidden" name="cmd" value="_xclick" />
|
||||
<input type="hidden" name="business" value={Globals.PaypalId} />
|
||||
<input type="hidden" name="lc" value="BA" />
|
||||
<input type="hidden" name="item_name" value="Item name" />
|
||||
<input type="hidden" name="item_name" value="Item" />
|
||||
<input type="hidden" name="item_number" value="555" />
|
||||
<input type="hidden" name="amount" value={amount} />
|
||||
<input type="hidden" name="currency_code" value="EUR" />
|
||||
@@ -40,8 +51,14 @@ var PaypalButton = React.createClass({
|
||||
<input name="notify_url" value={notifyUrl} type="hidden" />
|
||||
<input name="custom" value={deliveryDestination} type="hidden" />
|
||||
</form>
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
},
|
||||
_onPaypalClick: function(e) {
|
||||
CartActions.changeDeliveryDestinationProperty('payment_method', 'paypal');
|
||||
CartStore.saveDeliveryDestinationAnd(function() {
|
||||
$("#paypal_form").submit();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
64
front-ui/app/components/payment/pikpayButton.js
Normal file
64
front-ui/app/components/payment/pikpayButton.js
Normal file
@@ -0,0 +1,64 @@
|
||||
var React = require('react');
|
||||
var ItemActions = require('../../actions/itemActions');
|
||||
var NavigationActions = require('../../actions/navigationActions');
|
||||
var NavigationStore = require('../../stores/navigationStore');
|
||||
var CartStore = require('../../stores/cartStore');
|
||||
var CartActions = require('../../actions/cartActions');
|
||||
|
||||
var Globals = require('../../globals');
|
||||
var Router = require('react-router');
|
||||
var sha1 = require('sha1');
|
||||
|
||||
var PikpayButton = React.createClass({
|
||||
render: function() {
|
||||
var total = this.props.amount + this.props.deliveryCost;
|
||||
total = total * 100;
|
||||
var order_info = "Info";
|
||||
var order_number = "4678678678229";
|
||||
var key = "Ribica"
|
||||
var authenticity_token = Globals.PikpayAuthenticityToken;
|
||||
var digest = sha1(key + order_number + total + "BAM");
|
||||
var rebate_digest = sha1(key + order_number + total + total + "BAM");
|
||||
var deliveryDestination = this.props.deliveryDestination;
|
||||
var city = CartStore.getNameOfThePlace(deliveryDestination.get('place'));
|
||||
var custom = JSON.stringify(
|
||||
{
|
||||
'anonymous_id_string': deliveryDestination.get('anonymous_id_string'),
|
||||
'user_id': deliveryDestination.get('user_id')
|
||||
});
|
||||
|
||||
return (
|
||||
<button type="button" onClick={this._onPikpayClick} disabled={this.props.disabled} className="btn mybutton payment-btn">Plati karticom
|
||||
<form id="pikpay_form" action={Globals.PikpayFormUrl} method="post" target="_top">
|
||||
<input type="hidden" name="ch_full_name" value={deliveryDestination.get('name')} />
|
||||
<input type="hidden" name="ch_address" value={deliveryDestination.get('address')} />
|
||||
<input type="hidden" name="ch_city" value={city} />
|
||||
<input type="hidden" name="ch_zip" value={deliveryDestination.get('place')} />
|
||||
<input type="hidden" name="ch_country" value="Bosna i Hercegovina" />
|
||||
<input type="hidden" name="ch_phone" value={deliveryDestination.get('phone')} />
|
||||
<input type="hidden" name="ch_email" value={deliveryDestination.get('email')} />
|
||||
|
||||
<input type="hidden" name="order_info" value={order_info} />
|
||||
<input type="hidden" name="order_number" value={order_number} />
|
||||
<input type="hidden" name="amount" value={total} />
|
||||
<input type="hidden" name="currency" value="BAM" />
|
||||
<input type="hidden" name="original_amount" value={total} />
|
||||
<input type="hidden" name="language" value="hr" />
|
||||
<input type="hidden" name="transaction_type" value="authorize" />
|
||||
<input type="hidden" name="authenticity_token" value={authenticity_token} />
|
||||
<input type="hidden" name="digest" value={digest} />
|
||||
<input type="hidden" name="rebate_digest" value={rebate_digest} />
|
||||
<input type="hidden" name="custom_params" value={custom} />
|
||||
</form>
|
||||
</button>
|
||||
);
|
||||
},
|
||||
_onPikpayClick: function(e) {
|
||||
CartActions.changeDeliveryDestinationProperty('payment_method', 'pikpay');
|
||||
CartStore.saveDeliveryDestinationAnd(function() {
|
||||
$("#pikpay_form").submit();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = PikpayButton;
|
||||
@@ -1,10 +1,16 @@
|
||||
.checkout_form_margin {
|
||||
margin-right: 10px !important;
|
||||
margin-left: 10px !important;
|
||||
|
||||
}
|
||||
|
||||
.payment-btn {
|
||||
float: left;
|
||||
margin-left: 12px;
|
||||
.payment-select-container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.payment-select-desktop .payment-btn {
|
||||
margin-right: 10px !important;;
|
||||
}
|
||||
|
||||
.payment-select-mobile .payment-btn {
|
||||
margin-bottom: 6px !important;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ module.exports = {
|
||||
},
|
||||
MaxNumberOfItemsToBeAdded: 1000,
|
||||
PaypalId: "W7GKS2Q9ZGLGY",
|
||||
PikpayFormUrl: "https://ipgtest.pikpay.ba/form",
|
||||
PikpayAuthenticityToken: "1bb1eea16bd6492c01262636897c0c2e3291a1ab",
|
||||
|
||||
Slugify: function(text) {
|
||||
return text.toString().toLowerCase()
|
||||
|
||||
@@ -48,8 +48,8 @@ var router = Router.create({
|
||||
location: Router.HistoryLocation
|
||||
});
|
||||
|
||||
router.run(function (Handler, state) {
|
||||
|
||||
router.run(function (Handler, state) {
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -2694,10 +2694,14 @@ var addNItems = function(item, count) {
|
||||
var changeDeliveryDestinationProperty = function(property, value) {
|
||||
_deliveryDestination.set(property, value);
|
||||
|
||||
console.log(_deliveryDestination);
|
||||
|
||||
if (property === 'place') {
|
||||
fetchPlace();
|
||||
}
|
||||
validateDeliveryDestinationForm();
|
||||
|
||||
console.log(_deliveryDestination);
|
||||
};
|
||||
|
||||
|
||||
@@ -2717,6 +2721,13 @@ var confirmOrder = function() {
|
||||
});
|
||||
};
|
||||
|
||||
var saveDeliveryDestinationAnd = function(successCallback) {
|
||||
_deliveryDestination.save(null, {
|
||||
success: function() {
|
||||
successCallback();
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
var saveDeliveryDestination = function() {
|
||||
_deliveryDestination.save(null, {
|
||||
@@ -2809,8 +2820,8 @@ var CartStore = _.extend({}, EventEmitter.prototype, {
|
||||
},
|
||||
|
||||
getDeliveryCost: function(instantDelivery) {
|
||||
return instantDelivery ? _deliveryCosts.get('instant_delivery_price')
|
||||
: _deliveryCosts.get('delivery_price');
|
||||
return instantDelivery ? Number(_deliveryCosts.get('instant_delivery_price'))
|
||||
: Number(_deliveryCosts.get('delivery_price'));
|
||||
},
|
||||
|
||||
getWholeCartState: function() {
|
||||
@@ -2871,6 +2882,14 @@ var CartStore = _.extend({}, EventEmitter.prototype, {
|
||||
address.push(_deliveryDestination.get('email'))
|
||||
|
||||
return address;
|
||||
},
|
||||
|
||||
getNameOfThePlace: function(code) {
|
||||
return nameOfThePlace(code);
|
||||
},
|
||||
|
||||
saveDeliveryDestinationAnd: function(successCallback) {
|
||||
saveDeliveryDestinationAnd(successCallback);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
23
node_modules/ga-react-router/README.md
generated
vendored
23
node_modules/ga-react-router/README.md
generated
vendored
@@ -1,23 +0,0 @@
|
||||
# Google analytics for react-router
|
||||
|
||||
## How to use
|
||||
|
||||
1. `npm install ga-react-router`
|
||||
2. In your `webpack.config.js` add `new webpack.DefinePlugin({GA_TRACKING_CODE: JSON.stringify('XXXXXXXX')})`
|
||||
3. Use analytics in your `Router.run` code.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
'use strict';
|
||||
var React = require('react');
|
||||
var Router = require('react-router');
|
||||
var analytics = require('ga-react-router');
|
||||
|
||||
var routes = require('./routes');
|
||||
|
||||
Router.run(routes, Router.HistoryLocation, function(Handler, state) {
|
||||
React.render(<Handler />, document.getElementById('content'));
|
||||
analytics(state);
|
||||
});
|
||||
```
|
||||
50
node_modules/ga-react-router/package.json
generated
vendored
50
node_modules/ga-react-router/package.json
generated
vendored
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"name": "ga-react-router",
|
||||
"version": "1.3.0",
|
||||
"description": "Google analytics component for react-router",
|
||||
"main": "src/index.js",
|
||||
"peerDependencies": {
|
||||
"react-router": "0.11.x - 0.13.x"
|
||||
},
|
||||
"author": {
|
||||
"name": "Thomas Coopman @tcoopman"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/tcoopman/ga-react-router.git"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://www.opensource.org/licenses/mit-license.php"
|
||||
}
|
||||
],
|
||||
"gitHead": "bd1a0c6d97aef76c38690de4278dec63da13fe9c",
|
||||
"bugs": {
|
||||
"url": "https://github.com/tcoopman/ga-react-router/issues"
|
||||
},
|
||||
"homepage": "https://github.com/tcoopman/ga-react-router#readme",
|
||||
"_id": "ga-react-router@1.3.0",
|
||||
"scripts": {},
|
||||
"_shasum": "28f51f27d5b0339db55499adf82265033cedc939",
|
||||
"_from": "ga-react-router@*",
|
||||
"_npmVersion": "2.8.3",
|
||||
"_nodeVersion": "1.8.1",
|
||||
"_npmUser": {
|
||||
"name": "tcoopman",
|
||||
"email": "thomas.coopman@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tcoopman",
|
||||
"email": "thomas.coopman@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "28f51f27d5b0339db55499adf82265033cedc939",
|
||||
"tarball": "http://registry.npmjs.org/ga-react-router/-/ga-react-router-1.3.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/ga-react-router/-/ga-react-router-1.3.0.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
||||
31
node_modules/ga-react-router/src/ga.js
generated
vendored
31
node_modules/ga-react-router/src/ga.js
generated
vendored
@@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
if(typeof window !== 'undefined' && typeof GA_TRACKING_CODE !== 'undefined') {
|
||||
(function(window, document, script, url, r, tag, firstScriptTag) {
|
||||
window['GoogleAnalyticsObject']=r;
|
||||
window[r] = window[r] || function() {
|
||||
(window[r].q = window[r].q || []).push(arguments)
|
||||
};
|
||||
window[r].l = 1*new Date();
|
||||
tag = document.createElement(script),
|
||||
firstScriptTag = document.getElementsByTagName(script)[0];
|
||||
tag.async = 1;
|
||||
tag.src = url;
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
})(
|
||||
window,
|
||||
document,
|
||||
'script',
|
||||
'//www.google-analytics.com/analytics.js',
|
||||
'ga'
|
||||
);
|
||||
|
||||
var ga = window.ga;
|
||||
|
||||
ga('create', GA_TRACKING_CODE, 'auto');
|
||||
|
||||
module.exports = function() {
|
||||
return window.ga.apply(window.ga, arguments);
|
||||
};
|
||||
} else {
|
||||
module.exports = function() {console.log(arguments)};
|
||||
}
|
||||
12
node_modules/ga-react-router/src/index.js
generated
vendored
12
node_modules/ga-react-router/src/index.js
generated
vendored
@@ -1,12 +0,0 @@
|
||||
'use strict';
|
||||
var ga = require('./ga');
|
||||
|
||||
|
||||
function analytics(state) {
|
||||
ga('send', 'pageview', {
|
||||
'page': state.path
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
module.exports = analytics;
|
||||
140
node_modules/react-router/README.md
generated
vendored
140
node_modules/react-router/README.md
generated
vendored
@@ -1,140 +0,0 @@
|
||||
[](https://www.npmjs.org/package/react-router)
|
||||
[](https://travis-ci.org/rackt/react-router)
|
||||
[](https://david-dm.org/rackt/react-router)
|
||||
[](https://gitter.im/rackt/react-router?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
|
||||
React Router
|
||||
============
|
||||
|
||||
A complete routing library for React.
|
||||
|
||||
Docs
|
||||
----
|
||||
|
||||
- [Guide: Overview](/docs/guides/overview.md)
|
||||
- [API](/docs/api/)
|
||||
|
||||
Important Notes
|
||||
---------------
|
||||
|
||||
### SemVer
|
||||
|
||||
Before our `1.0` release, breaking API changes will cause a bump to
|
||||
`0.x`. For example, `0.4.1` and `0.4.8` will have the same API, but
|
||||
`0.5.0` will have breaking changes.
|
||||
|
||||
Please refer to the [upgrade guide](/UPGRADE_GUIDE.md) and
|
||||
[changelog](/CHANGELOG.md) when upgrading.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
```sh
|
||||
npm install react-router
|
||||
# or
|
||||
bower install react-router
|
||||
```
|
||||
|
||||
This library is written with CommonJS modules. If you are using
|
||||
browserify, webpack, or similar, you can consume it like anything else
|
||||
installed from npm.
|
||||
|
||||
There is also a global build available on bower, find the library on
|
||||
`window.ReactRouter`.
|
||||
|
||||
The library is also available on the popular CDN [cdnjs](https://cdnjs.com/libraries/react-router).
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- Nested views mapped to nested routes
|
||||
- Modular construction of route hierarchy
|
||||
- Sync and async transition hooks
|
||||
- Transition abort / redirect / retry
|
||||
- Dynamic segments
|
||||
- Query parameters
|
||||
- Links with automatic `.active` class when their route is active
|
||||
- Multiple root routes
|
||||
- Hash or HTML5 history (with fallback) URLs
|
||||
- Declarative Redirect routes
|
||||
- Declarative NotFound routes
|
||||
- Browser scroll behavior with transitions
|
||||
|
||||
Check out the `examples` directory to see how simple previously complex UI
|
||||
and workflows are to create.
|
||||
|
||||
What's it look like?
|
||||
--------------------
|
||||
|
||||
```js
|
||||
var routes = (
|
||||
<Route handler={App} path="/">
|
||||
<DefaultRoute handler={Home} />
|
||||
<Route name="about" handler={About} />
|
||||
<Route name="users" handler={Users}>
|
||||
<Route name="recent-users" path="recent" handler={RecentUsers} />
|
||||
<Route name="user" path="/user/:userId" handler={User} />
|
||||
<NotFoundRoute handler={UserRouteNotFound}/>
|
||||
</Route>
|
||||
<NotFoundRoute handler={NotFound}/>
|
||||
<Redirect from="company" to="about" />
|
||||
</Route>
|
||||
);
|
||||
|
||||
Router.run(routes, function (Handler) {
|
||||
React.render(<Handler/>, document.body);
|
||||
});
|
||||
|
||||
// Or, if you'd like to use the HTML5 history API for cleaner URLs:
|
||||
|
||||
Router.run(routes, Router.HistoryLocation, function (Handler) {
|
||||
React.render(<Handler/>, document.body);
|
||||
});
|
||||
```
|
||||
|
||||
See more in the [overview guide](/docs/guides/overview.md).
|
||||
|
||||
Benefits of this Approach
|
||||
-------------------------
|
||||
|
||||
1. **Incredible screen-creation productivity** - There is only one
|
||||
use-case when a user visits a route: render something. Every user
|
||||
interface has layers (or nesting) whether it's a simple navbar or
|
||||
multiple levels of master-detail. Coupling nested routes to these
|
||||
nested views gets rid of a ton of work for the developer to wire all
|
||||
of it together when the user switches routes. Adding new screens
|
||||
could not get faster.
|
||||
|
||||
2. **Immediate understanding of application structure** - When routes
|
||||
are declared in one place, developers can easily construct a mental
|
||||
image of the application. It's essentially a sitemap. There's not a
|
||||
better way to get so much information about your app this quickly.
|
||||
|
||||
3. **Code tractability** - When a developer gets a ticket to fix a bug
|
||||
at as specific url they simply 1) look at the route config, then 2)
|
||||
go find the handler for that route. Every entry point into your
|
||||
application is represented by these routes.
|
||||
|
||||
4. **URLs are your first thought, not an after-thought** - With React
|
||||
Router, you don't get UI on the page without configuring a url first.
|
||||
Fortunately, it's wildly productive this way, too.
|
||||
|
||||
Related Modules
|
||||
---------------
|
||||
|
||||
- [rnr-constrained-route](https://github.com/bjyoungblood/rnr-constrained-route) - validate paths
|
||||
and parameters on route handlers.
|
||||
- [react-router-bootstrap](https://github.com/mtscout6/react-router-bootstrap) - Integration with [react-bootstrap](https://github.com/react-bootstrap/react-bootstrap) components.
|
||||
- [react-router-proxy-loader](https://github.com/odysseyscience/react-router-proxy-loader) - A Webpack loader to dynamically load react-router components on-demand
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Please see [CONTRIBUTING](CONTRIBUTING.md)
|
||||
|
||||
Thanks, Ember
|
||||
-------------
|
||||
|
||||
This library is highly inspired by the Ember.js routing API. In general,
|
||||
it's a translation of the Ember router api to React. Huge thanks to the
|
||||
Ember team for solving the hardest part already.
|
||||
9
node_modules/react-router/lib/Cancellation.js
generated
vendored
9
node_modules/react-router/lib/Cancellation.js
generated
vendored
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* Represents a cancellation caused by navigating away
|
||||
* before the previous transition has fully resolved.
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
function Cancellation() {}
|
||||
|
||||
module.exports = Cancellation;
|
||||
30
node_modules/react-router/lib/History.js
generated
vendored
30
node_modules/react-router/lib/History.js
generated
vendored
@@ -1,30 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var invariant = require('react/lib/invariant');
|
||||
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
|
||||
|
||||
var History = {
|
||||
|
||||
/**
|
||||
* The current number of entries in the history.
|
||||
*
|
||||
* Note: This property is read-only.
|
||||
*/
|
||||
length: 1,
|
||||
|
||||
/**
|
||||
* Sends the browser back one entry in the history.
|
||||
*/
|
||||
back: function back() {
|
||||
invariant(canUseDOM, 'Cannot use History.back without a DOM');
|
||||
|
||||
// Do this first so that History.length will
|
||||
// be accurate in location change listeners.
|
||||
History.length -= 1;
|
||||
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = History;
|
||||
75
node_modules/react-router/lib/Match.js
generated
vendored
75
node_modules/react-router/lib/Match.js
generated
vendored
@@ -1,75 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
/* jshint -W084 */
|
||||
var PathUtils = require('./PathUtils');
|
||||
|
||||
function deepSearch(route, pathname, query) {
|
||||
// Check the subtree first to find the most deeply-nested match.
|
||||
var childRoutes = route.childRoutes;
|
||||
if (childRoutes) {
|
||||
var match, childRoute;
|
||||
for (var i = 0, len = childRoutes.length; i < len; ++i) {
|
||||
childRoute = childRoutes[i];
|
||||
|
||||
if (childRoute.isDefault || childRoute.isNotFound) continue; // Check these in order later.
|
||||
|
||||
if (match = deepSearch(childRoute, pathname, query)) {
|
||||
// A route in the subtree matched! Add this route and we're done.
|
||||
match.routes.unshift(route);
|
||||
return match;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No child routes matched; try the default route.
|
||||
var defaultRoute = route.defaultRoute;
|
||||
if (defaultRoute && (params = PathUtils.extractParams(defaultRoute.path, pathname))) {
|
||||
return new Match(pathname, params, query, [route, defaultRoute]);
|
||||
} // Does the "not found" route match?
|
||||
var notFoundRoute = route.notFoundRoute;
|
||||
if (notFoundRoute && (params = PathUtils.extractParams(notFoundRoute.path, pathname))) {
|
||||
return new Match(pathname, params, query, [route, notFoundRoute]);
|
||||
} // Last attempt: check this route.
|
||||
var params = PathUtils.extractParams(route.path, pathname);
|
||||
if (params) {
|
||||
return new Match(pathname, params, query, [route]);
|
||||
}return null;
|
||||
}
|
||||
|
||||
var Match = (function () {
|
||||
function Match(pathname, params, query, routes) {
|
||||
_classCallCheck(this, Match);
|
||||
|
||||
this.pathname = pathname;
|
||||
this.params = params;
|
||||
this.query = query;
|
||||
this.routes = routes;
|
||||
}
|
||||
|
||||
_createClass(Match, null, [{
|
||||
key: 'findMatch',
|
||||
|
||||
/**
|
||||
* Attempts to match depth-first a route in the given route's
|
||||
* subtree against the given path and returns the match if it
|
||||
* succeeds, null if no match can be made.
|
||||
*/
|
||||
value: function findMatch(routes, path) {
|
||||
var pathname = PathUtils.withoutQuery(path);
|
||||
var query = PathUtils.extractQuery(path);
|
||||
var match = null;
|
||||
|
||||
for (var i = 0, len = routes.length; match == null && i < len; ++i) match = deepSearch(routes[i], pathname, query);
|
||||
|
||||
return match;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Match;
|
||||
})();
|
||||
|
||||
module.exports = Match;
|
||||
70
node_modules/react-router/lib/Navigation.js
generated
vendored
70
node_modules/react-router/lib/Navigation.js
generated
vendored
@@ -1,70 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var PropTypes = require('./PropTypes');
|
||||
|
||||
/**
|
||||
* A mixin for components that modify the URL.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* var MyLink = React.createClass({
|
||||
* mixins: [ Router.Navigation ],
|
||||
* handleClick(event) {
|
||||
* event.preventDefault();
|
||||
* this.transitionTo('aRoute', { the: 'params' }, { the: 'query' });
|
||||
* },
|
||||
* render() {
|
||||
* return (
|
||||
* <a onClick={this.handleClick}>Click me!</a>
|
||||
* );
|
||||
* }
|
||||
* });
|
||||
*/
|
||||
var Navigation = {
|
||||
|
||||
contextTypes: {
|
||||
router: PropTypes.router.isRequired
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an absolute URL path created from the given route
|
||||
* name, URL parameters, and query values.
|
||||
*/
|
||||
makePath: function makePath(to, params, query) {
|
||||
return this.context.router.makePath(to, params, query);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a string that may safely be used as the href of a
|
||||
* link to the route with the given name.
|
||||
*/
|
||||
makeHref: function makeHref(to, params, query) {
|
||||
return this.context.router.makeHref(to, params, query);
|
||||
},
|
||||
|
||||
/**
|
||||
* Transitions to the URL specified in the arguments by pushing
|
||||
* a new URL onto the history stack.
|
||||
*/
|
||||
transitionTo: function transitionTo(to, params, query) {
|
||||
this.context.router.transitionTo(to, params, query);
|
||||
},
|
||||
|
||||
/**
|
||||
* Transitions to the URL specified in the arguments by replacing
|
||||
* the current URL in the history stack.
|
||||
*/
|
||||
replaceWith: function replaceWith(to, params, query) {
|
||||
this.context.router.replaceWith(to, params, query);
|
||||
},
|
||||
|
||||
/**
|
||||
* Transitions to the previous URL.
|
||||
*/
|
||||
goBack: function goBack() {
|
||||
return this.context.router.goBack();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = Navigation;
|
||||
153
node_modules/react-router/lib/PathUtils.js
generated
vendored
153
node_modules/react-router/lib/PathUtils.js
generated
vendored
@@ -1,153 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var invariant = require('react/lib/invariant');
|
||||
var assign = require('object-assign');
|
||||
var qs = require('qs');
|
||||
|
||||
var paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g;
|
||||
var paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?]?)|[*]/g;
|
||||
var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?\/|\/\?/g;
|
||||
var queryMatcher = /\?(.*)$/;
|
||||
|
||||
var _compiledPatterns = {};
|
||||
|
||||
function compilePattern(pattern) {
|
||||
if (!(pattern in _compiledPatterns)) {
|
||||
var paramNames = [];
|
||||
var source = pattern.replace(paramCompileMatcher, function (match, paramName) {
|
||||
if (paramName) {
|
||||
paramNames.push(paramName);
|
||||
return '([^/?#]+)';
|
||||
} else if (match === '*') {
|
||||
paramNames.push('splat');
|
||||
return '(.*?)';
|
||||
} else {
|
||||
return '\\' + match;
|
||||
}
|
||||
});
|
||||
|
||||
_compiledPatterns[pattern] = {
|
||||
matcher: new RegExp('^' + source + '$', 'i'),
|
||||
paramNames: paramNames
|
||||
};
|
||||
}
|
||||
|
||||
return _compiledPatterns[pattern];
|
||||
}
|
||||
|
||||
var PathUtils = {
|
||||
|
||||
/**
|
||||
* Returns true if the given path is absolute.
|
||||
*/
|
||||
isAbsolute: function isAbsolute(path) {
|
||||
return path.charAt(0) === '/';
|
||||
},
|
||||
|
||||
/**
|
||||
* Joins two URL paths together.
|
||||
*/
|
||||
join: function join(a, b) {
|
||||
return a.replace(/\/*$/, '/') + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array of the names of all parameters in the given pattern.
|
||||
*/
|
||||
extractParamNames: function extractParamNames(pattern) {
|
||||
return compilePattern(pattern).paramNames;
|
||||
},
|
||||
|
||||
/**
|
||||
* Extracts the portions of the given URL path that match the given pattern
|
||||
* and returns an object of param name => value pairs. Returns null if the
|
||||
* pattern does not match the given path.
|
||||
*/
|
||||
extractParams: function extractParams(pattern, path) {
|
||||
var _compilePattern = compilePattern(pattern);
|
||||
|
||||
var matcher = _compilePattern.matcher;
|
||||
var paramNames = _compilePattern.paramNames;
|
||||
|
||||
var match = path.match(matcher);
|
||||
|
||||
if (!match) {
|
||||
return null;
|
||||
}var params = {};
|
||||
|
||||
paramNames.forEach(function (paramName, index) {
|
||||
params[paramName] = match[index + 1];
|
||||
});
|
||||
|
||||
return params;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a version of the given route path with params interpolated. Throws
|
||||
* if there is a dynamic segment of the route path for which there is no param.
|
||||
*/
|
||||
injectParams: function injectParams(pattern, params) {
|
||||
params = params || {};
|
||||
|
||||
var splatIndex = 0;
|
||||
|
||||
return pattern.replace(paramInjectMatcher, function (match, paramName) {
|
||||
paramName = paramName || 'splat';
|
||||
|
||||
// If param is optional don't check for existence
|
||||
if (paramName.slice(-1) === '?') {
|
||||
paramName = paramName.slice(0, -1);
|
||||
|
||||
if (params[paramName] == null) return '';
|
||||
} else {
|
||||
invariant(params[paramName] != null, 'Missing "%s" parameter for path "%s"', paramName, pattern);
|
||||
}
|
||||
|
||||
var segment;
|
||||
if (paramName === 'splat' && Array.isArray(params[paramName])) {
|
||||
segment = params[paramName][splatIndex++];
|
||||
|
||||
invariant(segment != null, 'Missing splat # %s for path "%s"', splatIndex, pattern);
|
||||
} else {
|
||||
segment = params[paramName];
|
||||
}
|
||||
|
||||
return segment;
|
||||
}).replace(paramInjectTrailingSlashMatcher, '/');
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an object that is the result of parsing any query string contained
|
||||
* in the given path, null if the path contains no query string.
|
||||
*/
|
||||
extractQuery: function extractQuery(path) {
|
||||
var match = path.match(queryMatcher);
|
||||
return match && qs.parse(match[1]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a version of the given path without the query string.
|
||||
*/
|
||||
withoutQuery: function withoutQuery(path) {
|
||||
return path.replace(queryMatcher, '');
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a version of the given path with the parameters in the given
|
||||
* query merged into the query string.
|
||||
*/
|
||||
withQuery: function withQuery(path, query) {
|
||||
var existingQuery = PathUtils.extractQuery(path);
|
||||
|
||||
if (existingQuery) query = query ? assign(existingQuery, query) : existingQuery;
|
||||
|
||||
var queryString = qs.stringify(query, { arrayFormat: 'brackets' });
|
||||
|
||||
if (queryString) {
|
||||
return PathUtils.withoutQuery(path) + '?' + queryString;
|
||||
}return PathUtils.withoutQuery(path);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = PathUtils;
|
||||
31
node_modules/react-router/lib/PropTypes.js
generated
vendored
31
node_modules/react-router/lib/PropTypes.js
generated
vendored
@@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var assign = require('react/lib/Object.assign');
|
||||
var ReactPropTypes = require('react').PropTypes;
|
||||
var Route = require('./Route');
|
||||
|
||||
var PropTypes = assign({}, ReactPropTypes, {
|
||||
|
||||
/**
|
||||
* Indicates that a prop should be falsy.
|
||||
*/
|
||||
falsy: function falsy(props, propName, componentName) {
|
||||
if (props[propName]) {
|
||||
return new Error('<' + componentName + '> should not have a "' + propName + '" prop');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Indicates that a prop should be a Route object.
|
||||
*/
|
||||
route: ReactPropTypes.instanceOf(Route),
|
||||
|
||||
/**
|
||||
* Indicates that a prop should be a Router object.
|
||||
*/
|
||||
//router: ReactPropTypes.instanceOf(Router) // TODO
|
||||
router: ReactPropTypes.func
|
||||
|
||||
});
|
||||
|
||||
module.exports = PropTypes;
|
||||
12
node_modules/react-router/lib/Redirect.js
generated
vendored
12
node_modules/react-router/lib/Redirect.js
generated
vendored
@@ -1,12 +0,0 @@
|
||||
/**
|
||||
* Encapsulates a redirect to the given route.
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
function Redirect(to, params, query) {
|
||||
this.to = to;
|
||||
this.params = params;
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
module.exports = Redirect;
|
||||
200
node_modules/react-router/lib/Route.js
generated
vendored
200
node_modules/react-router/lib/Route.js
generated
vendored
@@ -1,200 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
var assign = require('react/lib/Object.assign');
|
||||
var invariant = require('react/lib/invariant');
|
||||
var warning = require('react/lib/warning');
|
||||
var PathUtils = require('./PathUtils');
|
||||
|
||||
var _currentRoute;
|
||||
|
||||
var Route = (function () {
|
||||
function Route(name, path, ignoreScrollBehavior, isDefault, isNotFound, onEnter, onLeave, handler) {
|
||||
_classCallCheck(this, Route);
|
||||
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.paramNames = PathUtils.extractParamNames(this.path);
|
||||
this.ignoreScrollBehavior = !!ignoreScrollBehavior;
|
||||
this.isDefault = !!isDefault;
|
||||
this.isNotFound = !!isNotFound;
|
||||
this.onEnter = onEnter;
|
||||
this.onLeave = onLeave;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
_createClass(Route, [{
|
||||
key: 'appendChild',
|
||||
|
||||
/**
|
||||
* Appends the given route to this route's child routes.
|
||||
*/
|
||||
value: function appendChild(route) {
|
||||
invariant(route instanceof Route, 'route.appendChild must use a valid Route');
|
||||
|
||||
if (!this.childRoutes) this.childRoutes = [];
|
||||
|
||||
this.childRoutes.push(route);
|
||||
}
|
||||
}, {
|
||||
key: 'toString',
|
||||
value: function toString() {
|
||||
var string = '<Route';
|
||||
|
||||
if (this.name) string += ' name="' + this.name + '"';
|
||||
|
||||
string += ' path="' + this.path + '">';
|
||||
|
||||
return string;
|
||||
}
|
||||
}], [{
|
||||
key: 'createRoute',
|
||||
|
||||
/**
|
||||
* Creates and returns a new route. Options may be a URL pathname string
|
||||
* with placeholders for named params or an object with any of the following
|
||||
* properties:
|
||||
*
|
||||
* - name The name of the route. This is used to lookup a
|
||||
* route relative to its parent route and should be
|
||||
* unique among all child routes of the same parent
|
||||
* - path A URL pathname string with optional placeholders
|
||||
* that specify the names of params to extract from
|
||||
* the URL when the path matches. Defaults to `/${name}`
|
||||
* when there is a name given, or the path of the parent
|
||||
* route, or /
|
||||
* - ignoreScrollBehavior True to make this route (and all descendants) ignore
|
||||
* the scroll behavior of the router
|
||||
* - isDefault True to make this route the default route among all
|
||||
* its siblings
|
||||
* - isNotFound True to make this route the "not found" route among
|
||||
* all its siblings
|
||||
* - onEnter A transition hook that will be called when the
|
||||
* router is going to enter this route
|
||||
* - onLeave A transition hook that will be called when the
|
||||
* router is going to leave this route
|
||||
* - handler A React component that will be rendered when
|
||||
* this route is active
|
||||
* - parentRoute The parent route to use for this route. This option
|
||||
* is automatically supplied when creating routes inside
|
||||
* the callback to another invocation of createRoute. You
|
||||
* only ever need to use this when declaring routes
|
||||
* independently of one another to manually piece together
|
||||
* the route hierarchy
|
||||
*
|
||||
* The callback may be used to structure your route hierarchy. Any call to
|
||||
* createRoute, createDefaultRoute, createNotFoundRoute, or createRedirect
|
||||
* inside the callback automatically uses this route as its parent.
|
||||
*/
|
||||
value: function createRoute(options, callback) {
|
||||
options = options || {};
|
||||
|
||||
if (typeof options === 'string') options = { path: options };
|
||||
|
||||
var parentRoute = _currentRoute;
|
||||
|
||||
if (parentRoute) {
|
||||
warning(options.parentRoute == null || options.parentRoute === parentRoute, 'You should not use parentRoute with createRoute inside another route\'s child callback; it is ignored');
|
||||
} else {
|
||||
parentRoute = options.parentRoute;
|
||||
}
|
||||
|
||||
var name = options.name;
|
||||
var path = options.path || name;
|
||||
|
||||
if (path && !(options.isDefault || options.isNotFound)) {
|
||||
if (PathUtils.isAbsolute(path)) {
|
||||
if (parentRoute) {
|
||||
invariant(path === parentRoute.path || parentRoute.paramNames.length === 0, 'You cannot nest path "%s" inside "%s"; the parent requires URL parameters', path, parentRoute.path);
|
||||
}
|
||||
} else if (parentRoute) {
|
||||
// Relative paths extend their parent.
|
||||
path = PathUtils.join(parentRoute.path, path);
|
||||
} else {
|
||||
path = '/' + path;
|
||||
}
|
||||
} else {
|
||||
path = parentRoute ? parentRoute.path : '/';
|
||||
}
|
||||
|
||||
if (options.isNotFound && !/\*$/.test(path)) path += '*'; // Auto-append * to the path of not found routes.
|
||||
|
||||
var route = new Route(name, path, options.ignoreScrollBehavior, options.isDefault, options.isNotFound, options.onEnter, options.onLeave, options.handler);
|
||||
|
||||
if (parentRoute) {
|
||||
if (route.isDefault) {
|
||||
invariant(parentRoute.defaultRoute == null, '%s may not have more than one default route', parentRoute);
|
||||
|
||||
parentRoute.defaultRoute = route;
|
||||
} else if (route.isNotFound) {
|
||||
invariant(parentRoute.notFoundRoute == null, '%s may not have more than one not found route', parentRoute);
|
||||
|
||||
parentRoute.notFoundRoute = route;
|
||||
}
|
||||
|
||||
parentRoute.appendChild(route);
|
||||
}
|
||||
|
||||
// Any routes created in the callback
|
||||
// use this route as their parent.
|
||||
if (typeof callback === 'function') {
|
||||
var currentRoute = _currentRoute;
|
||||
_currentRoute = route;
|
||||
callback.call(route, route);
|
||||
_currentRoute = currentRoute;
|
||||
}
|
||||
|
||||
return route;
|
||||
}
|
||||
}, {
|
||||
key: 'createDefaultRoute',
|
||||
|
||||
/**
|
||||
* Creates and returns a route that is rendered when its parent matches
|
||||
* the current URL.
|
||||
*/
|
||||
value: function createDefaultRoute(options) {
|
||||
return Route.createRoute(assign({}, options, { isDefault: true }));
|
||||
}
|
||||
}, {
|
||||
key: 'createNotFoundRoute',
|
||||
|
||||
/**
|
||||
* Creates and returns a route that is rendered when its parent matches
|
||||
* the current URL but none of its siblings do.
|
||||
*/
|
||||
value: function createNotFoundRoute(options) {
|
||||
return Route.createRoute(assign({}, options, { isNotFound: true }));
|
||||
}
|
||||
}, {
|
||||
key: 'createRedirect',
|
||||
|
||||
/**
|
||||
* Creates and returns a route that automatically redirects the transition
|
||||
* to another route. In addition to the normal options to createRoute, this
|
||||
* function accepts the following options:
|
||||
*
|
||||
* - from An alias for the `path` option. Defaults to *
|
||||
* - to The path/route/route name to redirect to
|
||||
* - params The params to use in the redirect URL. Defaults
|
||||
* to using the current params
|
||||
* - query The query to use in the redirect URL. Defaults
|
||||
* to using the current query
|
||||
*/
|
||||
value: function createRedirect(options) {
|
||||
return Route.createRoute(assign({}, options, {
|
||||
path: options.path || options.from || '*',
|
||||
onEnter: function onEnter(transition, params, query) {
|
||||
transition.redirect(options.to, options.params || params, options.query || query);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}]);
|
||||
|
||||
return Route;
|
||||
})();
|
||||
|
||||
module.exports = Route;
|
||||
75
node_modules/react-router/lib/ScrollHistory.js
generated
vendored
75
node_modules/react-router/lib/ScrollHistory.js
generated
vendored
@@ -1,75 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var invariant = require('react/lib/invariant');
|
||||
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
|
||||
var getWindowScrollPosition = require('./getWindowScrollPosition');
|
||||
|
||||
function shouldUpdateScroll(state, prevState) {
|
||||
if (!prevState) {
|
||||
return true;
|
||||
} // Don't update scroll position when only the query has changed.
|
||||
if (state.pathname === prevState.pathname) {
|
||||
return false;
|
||||
}var routes = state.routes;
|
||||
var prevRoutes = prevState.routes;
|
||||
|
||||
var sharedAncestorRoutes = routes.filter(function (route) {
|
||||
return prevRoutes.indexOf(route) !== -1;
|
||||
});
|
||||
|
||||
return !sharedAncestorRoutes.some(function (route) {
|
||||
return route.ignoreScrollBehavior;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the router with the ability to manage window scroll position
|
||||
* according to its scroll behavior.
|
||||
*/
|
||||
var ScrollHistory = {
|
||||
|
||||
statics: {
|
||||
|
||||
/**
|
||||
* Records curent scroll position as the last known position for the given URL path.
|
||||
*/
|
||||
recordScrollPosition: function recordScrollPosition(path) {
|
||||
if (!this.scrollHistory) this.scrollHistory = {};
|
||||
|
||||
this.scrollHistory[path] = getWindowScrollPosition();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the last known scroll position for the given URL path.
|
||||
*/
|
||||
getScrollPosition: function getScrollPosition(path) {
|
||||
if (!this.scrollHistory) this.scrollHistory = {};
|
||||
|
||||
return this.scrollHistory[path] || null;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
componentWillMount: function componentWillMount() {
|
||||
invariant(this.constructor.getScrollBehavior() == null || canUseDOM, 'Cannot use scroll behavior without a DOM');
|
||||
},
|
||||
|
||||
componentDidMount: function componentDidMount() {
|
||||
this._updateScroll();
|
||||
},
|
||||
|
||||
componentDidUpdate: function componentDidUpdate(prevProps, prevState) {
|
||||
this._updateScroll(prevState);
|
||||
},
|
||||
|
||||
_updateScroll: function _updateScroll(prevState) {
|
||||
if (!shouldUpdateScroll(this.state, prevState)) {
|
||||
return;
|
||||
}var scrollBehavior = this.constructor.getScrollBehavior();
|
||||
|
||||
if (scrollBehavior) scrollBehavior.updateScrollPosition(this.constructor.getScrollPosition(this.state.path), this.state.action);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = ScrollHistory;
|
||||
74
node_modules/react-router/lib/State.js
generated
vendored
74
node_modules/react-router/lib/State.js
generated
vendored
@@ -1,74 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var PropTypes = require('./PropTypes');
|
||||
|
||||
/**
|
||||
* A mixin for components that need to know the path, routes, URL
|
||||
* params and query that are currently active.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* var AboutLink = React.createClass({
|
||||
* mixins: [ Router.State ],
|
||||
* render() {
|
||||
* var className = this.props.className;
|
||||
*
|
||||
* if (this.isActive('about'))
|
||||
* className += ' is-active';
|
||||
*
|
||||
* return React.DOM.a({ className: className }, this.props.children);
|
||||
* }
|
||||
* });
|
||||
*/
|
||||
var State = {
|
||||
|
||||
contextTypes: {
|
||||
router: PropTypes.router.isRequired
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the current URL path.
|
||||
*/
|
||||
getPath: function getPath() {
|
||||
return this.context.router.getCurrentPath();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the current URL path without the query string.
|
||||
*/
|
||||
getPathname: function getPathname() {
|
||||
return this.context.router.getCurrentPathname();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an object of the URL params that are currently active.
|
||||
*/
|
||||
getParams: function getParams() {
|
||||
return this.context.router.getCurrentParams();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an object of the query params that are currently active.
|
||||
*/
|
||||
getQuery: function getQuery() {
|
||||
return this.context.router.getCurrentQuery();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array of the routes that are currently active.
|
||||
*/
|
||||
getRoutes: function getRoutes() {
|
||||
return this.context.router.getCurrentRoutes();
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method to determine if a given route, params, and query
|
||||
* are active.
|
||||
*/
|
||||
isActive: function isActive(to, params, query) {
|
||||
return this.context.router.isActive(to, params, query);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = State;
|
||||
171
node_modules/react-router/lib/TestUtils.js
generated
vendored
171
node_modules/react-router/lib/TestUtils.js
generated
vendored
@@ -1,171 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var RouteHandler = require('./components/RouteHandler');
|
||||
var PropTypes = require('./PropTypes');
|
||||
|
||||
exports.Nested = React.createClass({
|
||||
displayName: 'Nested',
|
||||
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
'div',
|
||||
null,
|
||||
React.createElement(
|
||||
'h1',
|
||||
{ className: 'Nested' },
|
||||
'Nested'
|
||||
),
|
||||
React.createElement(RouteHandler, null)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
exports.Foo = React.createClass({
|
||||
displayName: 'Foo',
|
||||
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
'div',
|
||||
{ className: 'Foo' },
|
||||
'Foo'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
exports.Bar = React.createClass({
|
||||
displayName: 'Bar',
|
||||
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
'div',
|
||||
{ className: 'Bar' },
|
||||
'Bar'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
exports.Baz = React.createClass({
|
||||
displayName: 'Baz',
|
||||
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
'div',
|
||||
{ className: 'Baz' },
|
||||
'Baz'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
exports.Async = React.createClass({
|
||||
displayName: 'Async',
|
||||
|
||||
statics: {
|
||||
delay: 10,
|
||||
|
||||
willTransitionTo: function willTransitionTo(transition, params, query, callback) {
|
||||
setTimeout(callback, exports.Async.delay);
|
||||
}
|
||||
},
|
||||
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
'div',
|
||||
{ className: 'Async' },
|
||||
'Async'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
exports.RedirectToFoo = React.createClass({
|
||||
displayName: 'RedirectToFoo',
|
||||
|
||||
statics: {
|
||||
willTransitionTo: function willTransitionTo(transition) {
|
||||
transition.redirect('/foo');
|
||||
}
|
||||
},
|
||||
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
exports.RedirectToFooAsync = React.createClass({
|
||||
displayName: 'RedirectToFooAsync',
|
||||
|
||||
statics: {
|
||||
delay: 10,
|
||||
|
||||
willTransitionTo: function willTransitionTo(transition, params, query, callback) {
|
||||
setTimeout(function () {
|
||||
transition.redirect('/foo');
|
||||
callback();
|
||||
}, exports.RedirectToFooAsync.delay);
|
||||
}
|
||||
},
|
||||
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
exports.Abort = React.createClass({
|
||||
displayName: 'Abort',
|
||||
|
||||
statics: {
|
||||
willTransitionTo: function willTransitionTo(transition) {
|
||||
transition.abort();
|
||||
}
|
||||
},
|
||||
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
exports.AbortAsync = React.createClass({
|
||||
displayName: 'AbortAsync',
|
||||
|
||||
statics: {
|
||||
delay: 10,
|
||||
|
||||
willTransitionTo: function willTransitionTo(transition, params, query, callback) {
|
||||
setTimeout(function () {
|
||||
transition.abort();
|
||||
callback();
|
||||
}, exports.AbortAsync.delay);
|
||||
}
|
||||
},
|
||||
|
||||
render: function render() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
exports.EchoFooProp = React.createClass({
|
||||
displayName: 'EchoFooProp',
|
||||
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
'div',
|
||||
null,
|
||||
this.props.foo
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
exports.EchoBarParam = React.createClass({
|
||||
displayName: 'EchoBarParam',
|
||||
|
||||
contextTypes: {
|
||||
router: PropTypes.router.isRequired
|
||||
},
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
'div',
|
||||
{ className: 'EchoBarParam' },
|
||||
this.context.router.getCurrentParams().bar
|
||||
);
|
||||
}
|
||||
});
|
||||
75
node_modules/react-router/lib/Transition.js
generated
vendored
75
node_modules/react-router/lib/Transition.js
generated
vendored
@@ -1,75 +0,0 @@
|
||||
/* jshint -W058 */
|
||||
|
||||
'use strict';
|
||||
|
||||
var Cancellation = require('./Cancellation');
|
||||
var Redirect = require('./Redirect');
|
||||
|
||||
/**
|
||||
* Encapsulates a transition to a given path.
|
||||
*
|
||||
* The willTransitionTo and willTransitionFrom handlers receive
|
||||
* an instance of this class as their first argument.
|
||||
*/
|
||||
function Transition(path, retry) {
|
||||
this.path = path;
|
||||
this.abortReason = null;
|
||||
// TODO: Change this to router.retryTransition(transition)
|
||||
this.retry = retry.bind(this);
|
||||
}
|
||||
|
||||
Transition.prototype.abort = function (reason) {
|
||||
if (this.abortReason == null) this.abortReason = reason || 'ABORT';
|
||||
};
|
||||
|
||||
Transition.prototype.redirect = function (to, params, query) {
|
||||
this.abort(new Redirect(to, params, query));
|
||||
};
|
||||
|
||||
Transition.prototype.cancel = function () {
|
||||
this.abort(new Cancellation());
|
||||
};
|
||||
|
||||
Transition.from = function (transition, routes, components, callback) {
|
||||
routes.reduce(function (callback, route, index) {
|
||||
return function (error) {
|
||||
if (error || transition.abortReason) {
|
||||
callback(error);
|
||||
} else if (route.onLeave) {
|
||||
try {
|
||||
route.onLeave(transition, components[index], callback);
|
||||
|
||||
// If there is no callback in the argument list, call it automatically.
|
||||
if (route.onLeave.length < 3) callback();
|
||||
} catch (e) {
|
||||
callback(e);
|
||||
}
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
}, callback)();
|
||||
};
|
||||
|
||||
Transition.to = function (transition, routes, params, query, callback) {
|
||||
routes.reduceRight(function (callback, route) {
|
||||
return function (error) {
|
||||
if (error || transition.abortReason) {
|
||||
callback(error);
|
||||
} else if (route.onEnter) {
|
||||
try {
|
||||
route.onEnter(transition, params, query, callback);
|
||||
|
||||
// If there is no callback in the argument list, call it automatically.
|
||||
if (route.onEnter.length < 4) callback();
|
||||
} catch (e) {
|
||||
callback(e);
|
||||
}
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
}, callback)();
|
||||
};
|
||||
|
||||
module.exports = Transition;
|
||||
25
node_modules/react-router/lib/actions/LocationActions.js
generated
vendored
25
node_modules/react-router/lib/actions/LocationActions.js
generated
vendored
@@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Actions that modify the URL.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var LocationActions = {
|
||||
|
||||
/**
|
||||
* Indicates a new location is being pushed to the history stack.
|
||||
*/
|
||||
PUSH: 'push',
|
||||
|
||||
/**
|
||||
* Indicates the current location should be replaced.
|
||||
*/
|
||||
REPLACE: 'replace',
|
||||
|
||||
/**
|
||||
* Indicates the most recent entry should be removed from the history stack.
|
||||
*/
|
||||
POP: 'pop'
|
||||
|
||||
};
|
||||
|
||||
module.exports = LocationActions;
|
||||
29
node_modules/react-router/lib/behaviors/ImitateBrowserBehavior.js
generated
vendored
29
node_modules/react-router/lib/behaviors/ImitateBrowserBehavior.js
generated
vendored
@@ -1,29 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var LocationActions = require('../actions/LocationActions');
|
||||
|
||||
/**
|
||||
* A scroll behavior that attempts to imitate the default behavior
|
||||
* of modern browsers.
|
||||
*/
|
||||
var ImitateBrowserBehavior = {
|
||||
|
||||
updateScrollPosition: function updateScrollPosition(position, actionType) {
|
||||
switch (actionType) {
|
||||
case LocationActions.PUSH:
|
||||
case LocationActions.REPLACE:
|
||||
window.scrollTo(0, 0);
|
||||
break;
|
||||
case LocationActions.POP:
|
||||
if (position) {
|
||||
window.scrollTo(position.x, position.y);
|
||||
} else {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = ImitateBrowserBehavior;
|
||||
15
node_modules/react-router/lib/behaviors/ScrollToTopBehavior.js
generated
vendored
15
node_modules/react-router/lib/behaviors/ScrollToTopBehavior.js
generated
vendored
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* A scroll behavior that always scrolls to the top of the page
|
||||
* after a transition.
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
var ScrollToTopBehavior = {
|
||||
|
||||
updateScrollPosition: function updateScrollPosition() {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = ScrollToTopBehavior;
|
||||
108
node_modules/react-router/lib/components/ActiveHandler.js
generated
vendored
108
node_modules/react-router/lib/components/ActiveHandler.js
generated
vendored
@@ -1,108 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var React = require('react');
|
||||
var ContextWrapper = require('./ContextWrapper');
|
||||
var assign = require('react/lib/Object.assign');
|
||||
var PropTypes = require('../PropTypes');
|
||||
|
||||
var REF_NAME = '__routeHandler__';
|
||||
|
||||
/**
|
||||
* A <RouteHandler> component renders the active child route handler
|
||||
* when routes are nested.
|
||||
*/
|
||||
|
||||
var RouteHandler = (function (_React$Component) {
|
||||
function RouteHandler() {
|
||||
_classCallCheck(this, RouteHandler);
|
||||
|
||||
if (_React$Component != null) {
|
||||
_React$Component.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(RouteHandler, _React$Component);
|
||||
|
||||
_createClass(RouteHandler, [{
|
||||
key: 'getChildContext',
|
||||
value: function getChildContext() {
|
||||
return {
|
||||
routeDepth: this.context.routeDepth + 1
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: 'componentDidMount',
|
||||
value: function componentDidMount() {
|
||||
this._updateRouteComponent(this.refs[REF_NAME]);
|
||||
}
|
||||
}, {
|
||||
key: 'componentDidUpdate',
|
||||
value: function componentDidUpdate() {
|
||||
this._updateRouteComponent(this.refs[REF_NAME]);
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillUnmount',
|
||||
value: function componentWillUnmount() {
|
||||
this._updateRouteComponent(null);
|
||||
}
|
||||
}, {
|
||||
key: '_updateRouteComponent',
|
||||
value: function _updateRouteComponent(component) {
|
||||
this.context.router.setRouteComponentAtDepth(this.getRouteDepth(), component);
|
||||
}
|
||||
}, {
|
||||
key: 'getRouteDepth',
|
||||
value: function getRouteDepth() {
|
||||
return this.context.routeDepth;
|
||||
}
|
||||
}, {
|
||||
key: 'createChildRouteHandler',
|
||||
value: function createChildRouteHandler(props) {
|
||||
var route = this.context.router.getRouteAtDepth(this.getRouteDepth());
|
||||
|
||||
if (route == null) {
|
||||
return null;
|
||||
}var childProps = assign({}, props || this.props, {
|
||||
ref: REF_NAME,
|
||||
params: this.context.router.getCurrentParams(),
|
||||
query: this.context.router.getCurrentQuery()
|
||||
});
|
||||
|
||||
return React.createElement(route.handler, childProps);
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var handler = this.createChildRouteHandler();
|
||||
// <script/> for things like <CSSTransitionGroup/> that don't like null
|
||||
return handler ? React.createElement(
|
||||
ContextWrapper,
|
||||
null,
|
||||
handler
|
||||
) : React.createElement('script', null);
|
||||
}
|
||||
}]);
|
||||
|
||||
return RouteHandler;
|
||||
})(React.Component);
|
||||
|
||||
// TODO: Include these in the above class definition
|
||||
// once we can use ES7 property initializers.
|
||||
// https://github.com/babel/babel/issues/619
|
||||
|
||||
RouteHandler.contextTypes = {
|
||||
routeDepth: PropTypes.number.isRequired,
|
||||
router: PropTypes.router.isRequired
|
||||
};
|
||||
|
||||
RouteHandler.childContextTypes = {
|
||||
routeDepth: PropTypes.number.isRequired
|
||||
};
|
||||
|
||||
module.exports = RouteHandler;
|
||||
38
node_modules/react-router/lib/components/ContextWrapper.js
generated
vendored
38
node_modules/react-router/lib/components/ContextWrapper.js
generated
vendored
@@ -1,38 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
/**
|
||||
* This component is necessary to get around a context warning
|
||||
* present in React 0.13.0. It sovles this by providing a separation
|
||||
* between the "owner" and "parent" contexts.
|
||||
*/
|
||||
|
||||
var React = require('react');
|
||||
|
||||
var ContextWrapper = (function (_React$Component) {
|
||||
function ContextWrapper() {
|
||||
_classCallCheck(this, ContextWrapper);
|
||||
|
||||
if (_React$Component != null) {
|
||||
_React$Component.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(ContextWrapper, _React$Component);
|
||||
|
||||
_createClass(ContextWrapper, [{
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
return this.props.children;
|
||||
}
|
||||
}]);
|
||||
|
||||
return ContextWrapper;
|
||||
})(React.Component);
|
||||
|
||||
module.exports = ContextWrapper;
|
||||
47
node_modules/react-router/lib/components/DefaultRoute.js
generated
vendored
47
node_modules/react-router/lib/components/DefaultRoute.js
generated
vendored
@@ -1,47 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var PropTypes = require('../PropTypes');
|
||||
var RouteHandler = require('./RouteHandler');
|
||||
var Route = require('./Route');
|
||||
|
||||
/**
|
||||
* A <DefaultRoute> component is a special kind of <Route> that
|
||||
* renders when its parent matches but none of its siblings do.
|
||||
* Only one such route may be used at any given level in the
|
||||
* route hierarchy.
|
||||
*/
|
||||
|
||||
var DefaultRoute = (function (_Route) {
|
||||
function DefaultRoute() {
|
||||
_classCallCheck(this, DefaultRoute);
|
||||
|
||||
if (_Route != null) {
|
||||
_Route.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(DefaultRoute, _Route);
|
||||
|
||||
return DefaultRoute;
|
||||
})(Route);
|
||||
|
||||
// TODO: Include these in the above class definition
|
||||
// once we can use ES7 property initializers.
|
||||
// https://github.com/babel/babel/issues/619
|
||||
|
||||
DefaultRoute.propTypes = {
|
||||
name: PropTypes.string,
|
||||
path: PropTypes.falsy,
|
||||
children: PropTypes.falsy,
|
||||
handler: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
DefaultRoute.defaultProps = {
|
||||
handler: RouteHandler
|
||||
};
|
||||
|
||||
module.exports = DefaultRoute;
|
||||
135
node_modules/react-router/lib/components/Link.js
generated
vendored
135
node_modules/react-router/lib/components/Link.js
generated
vendored
@@ -1,135 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var React = require('react');
|
||||
var assign = require('react/lib/Object.assign');
|
||||
var PropTypes = require('../PropTypes');
|
||||
|
||||
function isLeftClickEvent(event) {
|
||||
return event.button === 0;
|
||||
}
|
||||
|
||||
function isModifiedEvent(event) {
|
||||
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* <Link> components are used to create an <a> element that links to a route.
|
||||
* When that route is active, the link gets an "active" class name (or the
|
||||
* value of its `activeClassName` prop).
|
||||
*
|
||||
* For example, assuming you have the following route:
|
||||
*
|
||||
* <Route name="showPost" path="/posts/:postID" handler={Post}/>
|
||||
*
|
||||
* You could use the following component to link to that route:
|
||||
*
|
||||
* <Link to="showPost" params={{ postID: "123" }} />
|
||||
*
|
||||
* In addition to params, links may pass along query string parameters
|
||||
* using the `query` prop.
|
||||
*
|
||||
* <Link to="showPost" params={{ postID: "123" }} query={{ show:true }}/>
|
||||
*/
|
||||
|
||||
var Link = (function (_React$Component) {
|
||||
function Link() {
|
||||
_classCallCheck(this, Link);
|
||||
|
||||
if (_React$Component != null) {
|
||||
_React$Component.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(Link, _React$Component);
|
||||
|
||||
_createClass(Link, [{
|
||||
key: 'handleClick',
|
||||
value: function handleClick(event) {
|
||||
var allowTransition = true;
|
||||
var clickResult;
|
||||
|
||||
if (this.props.onClick) clickResult = this.props.onClick(event);
|
||||
|
||||
if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
|
||||
return;
|
||||
}if (clickResult === false || event.defaultPrevented === true) allowTransition = false;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if (allowTransition) this.context.router.transitionTo(this.props.to, this.props.params, this.props.query);
|
||||
}
|
||||
}, {
|
||||
key: 'getHref',
|
||||
|
||||
/**
|
||||
* Returns the value of the "href" attribute to use on the DOM element.
|
||||
*/
|
||||
value: function getHref() {
|
||||
return this.context.router.makeHref(this.props.to, this.props.params, this.props.query);
|
||||
}
|
||||
}, {
|
||||
key: 'getClassName',
|
||||
|
||||
/**
|
||||
* Returns the value of the "class" attribute to use on the DOM element, which contains
|
||||
* the value of the activeClassName property when this <Link> is active.
|
||||
*/
|
||||
value: function getClassName() {
|
||||
var className = this.props.className;
|
||||
|
||||
if (this.getActiveState()) className += ' ' + this.props.activeClassName;
|
||||
|
||||
return className;
|
||||
}
|
||||
}, {
|
||||
key: 'getActiveState',
|
||||
value: function getActiveState() {
|
||||
return this.context.router.isActive(this.props.to, this.props.params, this.props.query);
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var props = assign({}, this.props, {
|
||||
href: this.getHref(),
|
||||
className: this.getClassName(),
|
||||
onClick: this.handleClick.bind(this)
|
||||
});
|
||||
|
||||
if (props.activeStyle && this.getActiveState()) props.style = props.activeStyle;
|
||||
|
||||
return React.DOM.a(props, this.props.children);
|
||||
}
|
||||
}]);
|
||||
|
||||
return Link;
|
||||
})(React.Component);
|
||||
|
||||
// TODO: Include these in the above class definition
|
||||
// once we can use ES7 property initializers.
|
||||
// https://github.com/babel/babel/issues/619
|
||||
|
||||
Link.contextTypes = {
|
||||
router: PropTypes.router.isRequired
|
||||
};
|
||||
|
||||
Link.propTypes = {
|
||||
activeClassName: PropTypes.string.isRequired,
|
||||
to: PropTypes.oneOfType([PropTypes.string, PropTypes.route]).isRequired,
|
||||
params: PropTypes.object,
|
||||
query: PropTypes.object,
|
||||
activeStyle: PropTypes.object,
|
||||
onClick: PropTypes.func
|
||||
};
|
||||
|
||||
Link.defaultProps = {
|
||||
activeClassName: 'active',
|
||||
className: ''
|
||||
};
|
||||
|
||||
module.exports = Link;
|
||||
48
node_modules/react-router/lib/components/NotFoundRoute.js
generated
vendored
48
node_modules/react-router/lib/components/NotFoundRoute.js
generated
vendored
@@ -1,48 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var PropTypes = require('../PropTypes');
|
||||
var RouteHandler = require('./RouteHandler');
|
||||
var Route = require('./Route');
|
||||
|
||||
/**
|
||||
* A <NotFoundRoute> is a special kind of <Route> that
|
||||
* renders when the beginning of its parent's path matches
|
||||
* but none of its siblings do, including any <DefaultRoute>.
|
||||
* Only one such route may be used at any given level in the
|
||||
* route hierarchy.
|
||||
*/
|
||||
|
||||
var NotFoundRoute = (function (_Route) {
|
||||
function NotFoundRoute() {
|
||||
_classCallCheck(this, NotFoundRoute);
|
||||
|
||||
if (_Route != null) {
|
||||
_Route.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(NotFoundRoute, _Route);
|
||||
|
||||
return NotFoundRoute;
|
||||
})(Route);
|
||||
|
||||
// TODO: Include these in the above class definition
|
||||
// once we can use ES7 property initializers.
|
||||
// https://github.com/babel/babel/issues/619
|
||||
|
||||
NotFoundRoute.propTypes = {
|
||||
name: PropTypes.string,
|
||||
path: PropTypes.falsy,
|
||||
children: PropTypes.falsy,
|
||||
handler: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
NotFoundRoute.defaultProps = {
|
||||
handler: RouteHandler
|
||||
};
|
||||
|
||||
module.exports = NotFoundRoute;
|
||||
43
node_modules/react-router/lib/components/Redirect.js
generated
vendored
43
node_modules/react-router/lib/components/Redirect.js
generated
vendored
@@ -1,43 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var PropTypes = require('../PropTypes');
|
||||
var Route = require('./Route');
|
||||
|
||||
/**
|
||||
* A <Redirect> component is a special kind of <Route> that always
|
||||
* redirects to another route when it matches.
|
||||
*/
|
||||
|
||||
var Redirect = (function (_Route) {
|
||||
function Redirect() {
|
||||
_classCallCheck(this, Redirect);
|
||||
|
||||
if (_Route != null) {
|
||||
_Route.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(Redirect, _Route);
|
||||
|
||||
return Redirect;
|
||||
})(Route);
|
||||
|
||||
// TODO: Include these in the above class definition
|
||||
// once we can use ES7 property initializers.
|
||||
// https://github.com/babel/babel/issues/619
|
||||
|
||||
Redirect.propTypes = {
|
||||
path: PropTypes.string,
|
||||
from: PropTypes.string, // Alias for path.
|
||||
to: PropTypes.string,
|
||||
handler: PropTypes.falsy
|
||||
};
|
||||
|
||||
// Redirects should not have a default handler
|
||||
Redirect.defaultProps = {};
|
||||
|
||||
module.exports = Redirect;
|
||||
91
node_modules/react-router/lib/components/Route.js
generated
vendored
91
node_modules/react-router/lib/components/Route.js
generated
vendored
@@ -1,91 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var React = require('react');
|
||||
var invariant = require('react/lib/invariant');
|
||||
var PropTypes = require('../PropTypes');
|
||||
var RouteHandler = require('./RouteHandler');
|
||||
|
||||
/**
|
||||
* <Route> components specify components that are rendered to the page when the
|
||||
* URL matches a given pattern.
|
||||
*
|
||||
* Routes are arranged in a nested tree structure. When a new URL is requested,
|
||||
* the tree is searched depth-first to find a route whose path matches the URL.
|
||||
* When one is found, all routes in the tree that lead to it are considered
|
||||
* "active" and their components are rendered into the DOM, nested in the same
|
||||
* order as they are in the tree.
|
||||
*
|
||||
* The preferred way to configure a router is using JSX. The XML-like syntax is
|
||||
* a great way to visualize how routes are laid out in an application.
|
||||
*
|
||||
* var routes = [
|
||||
* <Route handler={App}>
|
||||
* <Route name="login" handler={Login}/>
|
||||
* <Route name="logout" handler={Logout}/>
|
||||
* <Route name="about" handler={About}/>
|
||||
* </Route>
|
||||
* ];
|
||||
*
|
||||
* Router.run(routes, function (Handler) {
|
||||
* React.render(<Handler/>, document.body);
|
||||
* });
|
||||
*
|
||||
* Handlers for Route components that contain children can render their active
|
||||
* child route using a <RouteHandler> element.
|
||||
*
|
||||
* var App = React.createClass({
|
||||
* render: function () {
|
||||
* return (
|
||||
* <div class="application">
|
||||
* <RouteHandler/>
|
||||
* </div>
|
||||
* );
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* If no handler is provided for the route, it will render a matched child route.
|
||||
*/
|
||||
|
||||
var Route = (function (_React$Component) {
|
||||
function Route() {
|
||||
_classCallCheck(this, Route);
|
||||
|
||||
if (_React$Component != null) {
|
||||
_React$Component.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(Route, _React$Component);
|
||||
|
||||
_createClass(Route, [{
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
invariant(false, '%s elements are for router configuration only and should not be rendered', this.constructor.name);
|
||||
}
|
||||
}]);
|
||||
|
||||
return Route;
|
||||
})(React.Component);
|
||||
|
||||
// TODO: Include these in the above class definition
|
||||
// once we can use ES7 property initializers.
|
||||
// https://github.com/babel/babel/issues/619
|
||||
|
||||
Route.propTypes = {
|
||||
name: PropTypes.string,
|
||||
path: PropTypes.string,
|
||||
handler: PropTypes.func,
|
||||
ignoreScrollBehavior: PropTypes.bool
|
||||
};
|
||||
|
||||
Route.defaultProps = {
|
||||
handler: RouteHandler
|
||||
};
|
||||
|
||||
module.exports = Route;
|
||||
108
node_modules/react-router/lib/components/RouteHandler.js
generated
vendored
108
node_modules/react-router/lib/components/RouteHandler.js
generated
vendored
@@ -1,108 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var React = require('react');
|
||||
var ContextWrapper = require('./ContextWrapper');
|
||||
var assign = require('react/lib/Object.assign');
|
||||
var PropTypes = require('../PropTypes');
|
||||
|
||||
var REF_NAME = '__routeHandler__';
|
||||
|
||||
/**
|
||||
* A <RouteHandler> component renders the active child route handler
|
||||
* when routes are nested.
|
||||
*/
|
||||
|
||||
var RouteHandler = (function (_React$Component) {
|
||||
function RouteHandler() {
|
||||
_classCallCheck(this, RouteHandler);
|
||||
|
||||
if (_React$Component != null) {
|
||||
_React$Component.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(RouteHandler, _React$Component);
|
||||
|
||||
_createClass(RouteHandler, [{
|
||||
key: 'getChildContext',
|
||||
value: function getChildContext() {
|
||||
return {
|
||||
routeDepth: this.context.routeDepth + 1
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: 'componentDidMount',
|
||||
value: function componentDidMount() {
|
||||
this._updateRouteComponent(this.refs[REF_NAME]);
|
||||
}
|
||||
}, {
|
||||
key: 'componentDidUpdate',
|
||||
value: function componentDidUpdate() {
|
||||
this._updateRouteComponent(this.refs[REF_NAME]);
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillUnmount',
|
||||
value: function componentWillUnmount() {
|
||||
this._updateRouteComponent(null);
|
||||
}
|
||||
}, {
|
||||
key: '_updateRouteComponent',
|
||||
value: function _updateRouteComponent(component) {
|
||||
this.context.router.setRouteComponentAtDepth(this.getRouteDepth(), component);
|
||||
}
|
||||
}, {
|
||||
key: 'getRouteDepth',
|
||||
value: function getRouteDepth() {
|
||||
return this.context.routeDepth;
|
||||
}
|
||||
}, {
|
||||
key: 'createChildRouteHandler',
|
||||
value: function createChildRouteHandler(props) {
|
||||
var route = this.context.router.getRouteAtDepth(this.getRouteDepth());
|
||||
|
||||
if (route == null) {
|
||||
return null;
|
||||
}var childProps = assign({}, props || this.props, {
|
||||
ref: REF_NAME,
|
||||
params: this.context.router.getCurrentParams(),
|
||||
query: this.context.router.getCurrentQuery()
|
||||
});
|
||||
|
||||
return React.createElement(route.handler, childProps);
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var handler = this.createChildRouteHandler();
|
||||
// <script/> for things like <CSSTransitionGroup/> that don't like null
|
||||
return handler ? React.createElement(
|
||||
ContextWrapper,
|
||||
null,
|
||||
handler
|
||||
) : React.createElement('script', null);
|
||||
}
|
||||
}]);
|
||||
|
||||
return RouteHandler;
|
||||
})(React.Component);
|
||||
|
||||
// TODO: Include these in the above class definition
|
||||
// once we can use ES7 property initializers.
|
||||
// https://github.com/babel/babel/issues/619
|
||||
|
||||
RouteHandler.contextTypes = {
|
||||
routeDepth: PropTypes.number.isRequired,
|
||||
router: PropTypes.router.isRequired
|
||||
};
|
||||
|
||||
RouteHandler.childContextTypes = {
|
||||
routeDepth: PropTypes.number.isRequired
|
||||
};
|
||||
|
||||
module.exports = RouteHandler;
|
||||
514
node_modules/react-router/lib/createRouter.js
generated
vendored
514
node_modules/react-router/lib/createRouter.js
generated
vendored
@@ -1,514 +0,0 @@
|
||||
/* jshint -W058 */
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var warning = require('react/lib/warning');
|
||||
var invariant = require('react/lib/invariant');
|
||||
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
|
||||
var LocationActions = require('./actions/LocationActions');
|
||||
var ImitateBrowserBehavior = require('./behaviors/ImitateBrowserBehavior');
|
||||
var HashLocation = require('./locations/HashLocation');
|
||||
var HistoryLocation = require('./locations/HistoryLocation');
|
||||
var RefreshLocation = require('./locations/RefreshLocation');
|
||||
var StaticLocation = require('./locations/StaticLocation');
|
||||
var ScrollHistory = require('./ScrollHistory');
|
||||
var createRoutesFromReactChildren = require('./createRoutesFromReactChildren');
|
||||
var isReactChildren = require('./isReactChildren');
|
||||
var Transition = require('./Transition');
|
||||
var PropTypes = require('./PropTypes');
|
||||
var Redirect = require('./Redirect');
|
||||
var History = require('./History');
|
||||
var Cancellation = require('./Cancellation');
|
||||
var Match = require('./Match');
|
||||
var Route = require('./Route');
|
||||
var supportsHistory = require('./supportsHistory');
|
||||
var PathUtils = require('./PathUtils');
|
||||
|
||||
/**
|
||||
* The default location for new routers.
|
||||
*/
|
||||
var DEFAULT_LOCATION = canUseDOM ? HashLocation : '/';
|
||||
|
||||
/**
|
||||
* The default scroll behavior for new routers.
|
||||
*/
|
||||
var DEFAULT_SCROLL_BEHAVIOR = canUseDOM ? ImitateBrowserBehavior : null;
|
||||
|
||||
function hasProperties(object, properties) {
|
||||
for (var propertyName in properties) if (properties.hasOwnProperty(propertyName) && object[propertyName] !== properties[propertyName]) {
|
||||
return false;
|
||||
}return true;
|
||||
}
|
||||
|
||||
function hasMatch(routes, route, prevParams, nextParams, prevQuery, nextQuery) {
|
||||
return routes.some(function (r) {
|
||||
if (r !== route) return false;
|
||||
|
||||
var paramNames = route.paramNames;
|
||||
var paramName;
|
||||
|
||||
// Ensure that all params the route cares about did not change.
|
||||
for (var i = 0, len = paramNames.length; i < len; ++i) {
|
||||
paramName = paramNames[i];
|
||||
|
||||
if (nextParams[paramName] !== prevParams[paramName]) return false;
|
||||
}
|
||||
|
||||
// Ensure the query hasn't changed.
|
||||
return hasProperties(prevQuery, nextQuery) && hasProperties(nextQuery, prevQuery);
|
||||
});
|
||||
}
|
||||
|
||||
function addRoutesToNamedRoutes(routes, namedRoutes) {
|
||||
var route;
|
||||
for (var i = 0, len = routes.length; i < len; ++i) {
|
||||
route = routes[i];
|
||||
|
||||
if (route.name) {
|
||||
invariant(namedRoutes[route.name] == null, 'You may not have more than one route named "%s"', route.name);
|
||||
|
||||
namedRoutes[route.name] = route;
|
||||
}
|
||||
|
||||
if (route.childRoutes) addRoutesToNamedRoutes(route.childRoutes, namedRoutes);
|
||||
}
|
||||
}
|
||||
|
||||
function routeIsActive(activeRoutes, routeName) {
|
||||
return activeRoutes.some(function (route) {
|
||||
return route.name === routeName;
|
||||
});
|
||||
}
|
||||
|
||||
function paramsAreActive(activeParams, params) {
|
||||
for (var property in params) if (String(activeParams[property]) !== String(params[property])) {
|
||||
return false;
|
||||
}return true;
|
||||
}
|
||||
|
||||
function queryIsActive(activeQuery, query) {
|
||||
for (var property in query) if (String(activeQuery[property]) !== String(query[property])) {
|
||||
return false;
|
||||
}return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new router using the given options. A router
|
||||
* is a ReactComponent class that knows how to react to changes in the
|
||||
* URL and keep the contents of the page in sync.
|
||||
*
|
||||
* Options may be any of the following:
|
||||
*
|
||||
* - routes (required) The route config
|
||||
* - location The location to use. Defaults to HashLocation when
|
||||
* the DOM is available, "/" otherwise
|
||||
* - scrollBehavior The scroll behavior to use. Defaults to ImitateBrowserBehavior
|
||||
* when the DOM is available, null otherwise
|
||||
* - onError A function that is used to handle errors
|
||||
* - onAbort A function that is used to handle aborted transitions
|
||||
*
|
||||
* When rendering in a server-side environment, the location should simply
|
||||
* be the URL path that was used in the request, including the query string.
|
||||
*/
|
||||
function createRouter(options) {
|
||||
options = options || {};
|
||||
|
||||
if (isReactChildren(options)) options = { routes: options };
|
||||
|
||||
var mountedComponents = [];
|
||||
var location = options.location || DEFAULT_LOCATION;
|
||||
var scrollBehavior = options.scrollBehavior || DEFAULT_SCROLL_BEHAVIOR;
|
||||
var state = {};
|
||||
var nextState = {};
|
||||
var pendingTransition = null;
|
||||
var dispatchHandler = null;
|
||||
|
||||
if (typeof location === 'string') location = new StaticLocation(location);
|
||||
|
||||
if (location instanceof StaticLocation) {
|
||||
warning(!canUseDOM || process.env.NODE_ENV === 'test', 'You should not use a static location in a DOM environment because ' + 'the router will not be kept in sync with the current URL');
|
||||
} else {
|
||||
invariant(canUseDOM || location.needsDOM === false, 'You cannot use %s without a DOM', location);
|
||||
}
|
||||
|
||||
// Automatically fall back to full page refreshes in
|
||||
// browsers that don't support the HTML history API.
|
||||
if (location === HistoryLocation && !supportsHistory()) location = RefreshLocation;
|
||||
|
||||
var Router = React.createClass({
|
||||
|
||||
displayName: 'Router',
|
||||
|
||||
statics: {
|
||||
|
||||
isRunning: false,
|
||||
|
||||
cancelPendingTransition: function cancelPendingTransition() {
|
||||
if (pendingTransition) {
|
||||
pendingTransition.cancel();
|
||||
pendingTransition = null;
|
||||
}
|
||||
},
|
||||
|
||||
clearAllRoutes: function clearAllRoutes() {
|
||||
Router.cancelPendingTransition();
|
||||
Router.namedRoutes = {};
|
||||
Router.routes = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds routes to this router from the given children object (see ReactChildren).
|
||||
*/
|
||||
addRoutes: function addRoutes(routes) {
|
||||
if (isReactChildren(routes)) routes = createRoutesFromReactChildren(routes);
|
||||
|
||||
addRoutesToNamedRoutes(routes, Router.namedRoutes);
|
||||
|
||||
Router.routes.push.apply(Router.routes, routes);
|
||||
},
|
||||
|
||||
/**
|
||||
* Replaces routes of this router from the given children object (see ReactChildren).
|
||||
*/
|
||||
replaceRoutes: function replaceRoutes(routes) {
|
||||
Router.clearAllRoutes();
|
||||
Router.addRoutes(routes);
|
||||
Router.refresh();
|
||||
},
|
||||
|
||||
/**
|
||||
* Performs a match of the given path against this router and returns an object
|
||||
* with the { routes, params, pathname, query } that match. Returns null if no
|
||||
* match can be made.
|
||||
*/
|
||||
match: function match(path) {
|
||||
return Match.findMatch(Router.routes, path);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an absolute URL path created from the given route
|
||||
* name, URL parameters, and query.
|
||||
*/
|
||||
makePath: function makePath(to, params, query) {
|
||||
var path;
|
||||
if (PathUtils.isAbsolute(to)) {
|
||||
path = to;
|
||||
} else {
|
||||
var route = to instanceof Route ? to : Router.namedRoutes[to];
|
||||
|
||||
invariant(route instanceof Route, 'Cannot find a route named "%s"', to);
|
||||
|
||||
path = route.path;
|
||||
}
|
||||
|
||||
return PathUtils.withQuery(PathUtils.injectParams(path, params), query);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a string that may safely be used as the href of a link
|
||||
* to the route with the given name, URL parameters, and query.
|
||||
*/
|
||||
makeHref: function makeHref(to, params, query) {
|
||||
var path = Router.makePath(to, params, query);
|
||||
return location === HashLocation ? '#' + path : path;
|
||||
},
|
||||
|
||||
/**
|
||||
* Transitions to the URL specified in the arguments by pushing
|
||||
* a new URL onto the history stack.
|
||||
*/
|
||||
transitionTo: function transitionTo(to, params, query) {
|
||||
var path = Router.makePath(to, params, query);
|
||||
|
||||
if (pendingTransition) {
|
||||
// Replace so pending location does not stay in history.
|
||||
location.replace(path);
|
||||
} else {
|
||||
location.push(path);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Transitions to the URL specified in the arguments by replacing
|
||||
* the current URL in the history stack.
|
||||
*/
|
||||
replaceWith: function replaceWith(to, params, query) {
|
||||
location.replace(Router.makePath(to, params, query));
|
||||
},
|
||||
|
||||
/**
|
||||
* Transitions to the previous URL if one is available. Returns true if the
|
||||
* router was able to go back, false otherwise.
|
||||
*
|
||||
* Note: The router only tracks history entries in your application, not the
|
||||
* current browser session, so you can safely call this function without guarding
|
||||
* against sending the user back to some other site. However, when using
|
||||
* RefreshLocation (which is the fallback for HistoryLocation in browsers that
|
||||
* don't support HTML5 history) this method will *always* send the client back
|
||||
* because we cannot reliably track history length.
|
||||
*/
|
||||
goBack: function goBack() {
|
||||
if (History.length > 1 || location === RefreshLocation) {
|
||||
location.pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
warning(false, 'goBack() was ignored because there is no router history');
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
handleAbort: options.onAbort || function (abortReason) {
|
||||
if (location instanceof StaticLocation) throw new Error('Unhandled aborted transition! Reason: ' + abortReason);
|
||||
|
||||
if (abortReason instanceof Cancellation) {
|
||||
return;
|
||||
} else if (abortReason instanceof Redirect) {
|
||||
location.replace(Router.makePath(abortReason.to, abortReason.params, abortReason.query));
|
||||
} else {
|
||||
location.pop();
|
||||
}
|
||||
},
|
||||
|
||||
handleError: options.onError || function (error) {
|
||||
// Throw so we don't silently swallow async errors.
|
||||
throw error; // This error probably originated in a transition hook.
|
||||
},
|
||||
|
||||
handleLocationChange: function handleLocationChange(change) {
|
||||
Router.dispatch(change.path, change.type);
|
||||
},
|
||||
|
||||
/**
|
||||
* Performs a transition to the given path and calls callback(error, abortReason)
|
||||
* when the transition is finished. If both arguments are null the router's state
|
||||
* was updated. Otherwise the transition did not complete.
|
||||
*
|
||||
* In a transition, a router first determines which routes are involved by beginning
|
||||
* with the current route, up the route tree to the first parent route that is shared
|
||||
* with the destination route, and back down the tree to the destination route. The
|
||||
* willTransitionFrom hook is invoked on all route handlers we're transitioning away
|
||||
* from, in reverse nesting order. Likewise, the willTransitionTo hook is invoked on
|
||||
* all route handlers we're transitioning to.
|
||||
*
|
||||
* Both willTransitionFrom and willTransitionTo hooks may either abort or redirect the
|
||||
* transition. To resolve asynchronously, they may use the callback argument. If no
|
||||
* hooks wait, the transition is fully synchronous.
|
||||
*/
|
||||
dispatch: function dispatch(path, action) {
|
||||
Router.cancelPendingTransition();
|
||||
|
||||
var prevPath = state.path;
|
||||
var isRefreshing = action == null;
|
||||
|
||||
if (prevPath === path && !isRefreshing) {
|
||||
return;
|
||||
} // Nothing to do!
|
||||
|
||||
// Record the scroll position as early as possible to
|
||||
// get it before browsers try update it automatically.
|
||||
if (prevPath && action === LocationActions.PUSH) Router.recordScrollPosition(prevPath);
|
||||
|
||||
var match = Router.match(path);
|
||||
|
||||
warning(match != null, 'No route matches path "%s". Make sure you have <Route path="%s"> somewhere in your routes', path, path);
|
||||
|
||||
if (match == null) match = {};
|
||||
|
||||
var prevRoutes = state.routes || [];
|
||||
var prevParams = state.params || {};
|
||||
var prevQuery = state.query || {};
|
||||
|
||||
var nextRoutes = match.routes || [];
|
||||
var nextParams = match.params || {};
|
||||
var nextQuery = match.query || {};
|
||||
|
||||
var fromRoutes, toRoutes;
|
||||
if (prevRoutes.length) {
|
||||
fromRoutes = prevRoutes.filter(function (route) {
|
||||
return !hasMatch(nextRoutes, route, prevParams, nextParams, prevQuery, nextQuery);
|
||||
});
|
||||
|
||||
toRoutes = nextRoutes.filter(function (route) {
|
||||
return !hasMatch(prevRoutes, route, prevParams, nextParams, prevQuery, nextQuery);
|
||||
});
|
||||
} else {
|
||||
fromRoutes = [];
|
||||
toRoutes = nextRoutes;
|
||||
}
|
||||
|
||||
var transition = new Transition(path, Router.replaceWith.bind(Router, path));
|
||||
pendingTransition = transition;
|
||||
|
||||
var fromComponents = mountedComponents.slice(prevRoutes.length - fromRoutes.length);
|
||||
|
||||
Transition.from(transition, fromRoutes, fromComponents, function (error) {
|
||||
if (error || transition.abortReason) return dispatchHandler.call(Router, error, transition); // No need to continue.
|
||||
|
||||
Transition.to(transition, toRoutes, nextParams, nextQuery, function (error) {
|
||||
dispatchHandler.call(Router, error, transition, {
|
||||
path: path,
|
||||
action: action,
|
||||
pathname: match.pathname,
|
||||
routes: nextRoutes,
|
||||
params: nextParams,
|
||||
query: nextQuery
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Starts this router and calls callback(router, state) when the route changes.
|
||||
*
|
||||
* If the router's location is static (i.e. a URL path in a server environment)
|
||||
* the callback is called only once. Otherwise, the location should be one of the
|
||||
* Router.*Location objects (e.g. Router.HashLocation or Router.HistoryLocation).
|
||||
*/
|
||||
run: function run(callback) {
|
||||
invariant(!Router.isRunning, 'Router is already running');
|
||||
|
||||
dispatchHandler = function (error, transition, newState) {
|
||||
if (error) Router.handleError(error);
|
||||
|
||||
if (pendingTransition !== transition) return;
|
||||
|
||||
pendingTransition = null;
|
||||
|
||||
if (transition.abortReason) {
|
||||
Router.handleAbort(transition.abortReason);
|
||||
} else {
|
||||
callback.call(Router, Router, nextState = newState);
|
||||
}
|
||||
};
|
||||
|
||||
if (!(location instanceof StaticLocation)) {
|
||||
if (location.addChangeListener) location.addChangeListener(Router.handleLocationChange);
|
||||
|
||||
Router.isRunning = true;
|
||||
}
|
||||
|
||||
// Bootstrap using the current path.
|
||||
Router.refresh();
|
||||
},
|
||||
|
||||
refresh: function refresh() {
|
||||
Router.dispatch(location.getCurrentPath(), null);
|
||||
},
|
||||
|
||||
stop: function stop() {
|
||||
Router.cancelPendingTransition();
|
||||
|
||||
if (location.removeChangeListener) location.removeChangeListener(Router.handleLocationChange);
|
||||
|
||||
Router.isRunning = false;
|
||||
},
|
||||
|
||||
getLocation: function getLocation() {
|
||||
return location;
|
||||
},
|
||||
|
||||
getScrollBehavior: function getScrollBehavior() {
|
||||
return scrollBehavior;
|
||||
},
|
||||
|
||||
getRouteAtDepth: function getRouteAtDepth(routeDepth) {
|
||||
var routes = state.routes;
|
||||
return routes && routes[routeDepth];
|
||||
},
|
||||
|
||||
setRouteComponentAtDepth: function setRouteComponentAtDepth(routeDepth, component) {
|
||||
mountedComponents[routeDepth] = component;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the current URL path + query string.
|
||||
*/
|
||||
getCurrentPath: function getCurrentPath() {
|
||||
return state.path;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the current URL path without the query string.
|
||||
*/
|
||||
getCurrentPathname: function getCurrentPathname() {
|
||||
return state.pathname;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an object of the currently active URL parameters.
|
||||
*/
|
||||
getCurrentParams: function getCurrentParams() {
|
||||
return state.params;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an object of the currently active query parameters.
|
||||
*/
|
||||
getCurrentQuery: function getCurrentQuery() {
|
||||
return state.query;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array of the currently active routes.
|
||||
*/
|
||||
getCurrentRoutes: function getCurrentRoutes() {
|
||||
return state.routes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if the given route, params, and query are active.
|
||||
*/
|
||||
isActive: function isActive(to, params, query) {
|
||||
if (PathUtils.isAbsolute(to)) {
|
||||
return to === state.path;
|
||||
}return routeIsActive(state.routes, to) && paramsAreActive(state.params, params) && (query == null || queryIsActive(state.query, query));
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
mixins: [ScrollHistory],
|
||||
|
||||
propTypes: {
|
||||
children: PropTypes.falsy
|
||||
},
|
||||
|
||||
childContextTypes: {
|
||||
routeDepth: PropTypes.number.isRequired,
|
||||
router: PropTypes.router.isRequired
|
||||
},
|
||||
|
||||
getChildContext: function getChildContext() {
|
||||
return {
|
||||
routeDepth: 1,
|
||||
router: Router
|
||||
};
|
||||
},
|
||||
|
||||
getInitialState: function getInitialState() {
|
||||
return state = nextState;
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function componentWillReceiveProps() {
|
||||
this.setState(state = nextState);
|
||||
},
|
||||
|
||||
componentWillUnmount: function componentWillUnmount() {
|
||||
Router.stop();
|
||||
},
|
||||
|
||||
render: function render() {
|
||||
var route = Router.getRouteAtDepth(0);
|
||||
return route ? React.createElement(route.handler, this.props) : null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Router.clearAllRoutes();
|
||||
|
||||
if (options.routes) Router.addRoutes(options.routes);
|
||||
|
||||
return Router;
|
||||
}
|
||||
|
||||
module.exports = createRouter;
|
||||
81
node_modules/react-router/lib/createRoutesFromReactChildren.js
generated
vendored
81
node_modules/react-router/lib/createRoutesFromReactChildren.js
generated
vendored
@@ -1,81 +0,0 @@
|
||||
/* jshint -W084 */
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var assign = require('react/lib/Object.assign');
|
||||
var warning = require('react/lib/warning');
|
||||
var DefaultRoute = require('./components/DefaultRoute');
|
||||
var NotFoundRoute = require('./components/NotFoundRoute');
|
||||
var Redirect = require('./components/Redirect');
|
||||
var Route = require('./Route');
|
||||
|
||||
function checkPropTypes(componentName, propTypes, props) {
|
||||
componentName = componentName || 'UnknownComponent';
|
||||
|
||||
for (var propName in propTypes) {
|
||||
if (propTypes.hasOwnProperty(propName)) {
|
||||
var error = propTypes[propName](props, propName, componentName);
|
||||
|
||||
if (error instanceof Error) warning(false, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createRouteOptions(props) {
|
||||
var options = assign({}, props);
|
||||
var handler = options.handler;
|
||||
|
||||
if (handler) {
|
||||
options.onEnter = handler.willTransitionTo;
|
||||
options.onLeave = handler.willTransitionFrom;
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
function createRouteFromReactElement(element) {
|
||||
if (!React.isValidElement(element)) {
|
||||
return;
|
||||
}var type = element.type;
|
||||
var props = assign({}, type.defaultProps, element.props);
|
||||
|
||||
if (type.propTypes) checkPropTypes(type.displayName, type.propTypes, props);
|
||||
|
||||
if (type === DefaultRoute) {
|
||||
return Route.createDefaultRoute(createRouteOptions(props));
|
||||
}if (type === NotFoundRoute) {
|
||||
return Route.createNotFoundRoute(createRouteOptions(props));
|
||||
}if (type === Redirect) {
|
||||
return Route.createRedirect(createRouteOptions(props));
|
||||
}return Route.createRoute(createRouteOptions(props), function () {
|
||||
if (props.children) createRoutesFromReactChildren(props.children);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns an array of routes created from the given
|
||||
* ReactChildren, all of which should be one of <Route>, <DefaultRoute>,
|
||||
* <NotFoundRoute>, or <Redirect>, e.g.:
|
||||
*
|
||||
* var { createRoutesFromReactChildren, Route, Redirect } = require('react-router');
|
||||
*
|
||||
* var routes = createRoutesFromReactChildren(
|
||||
* <Route path="/" handler={App}>
|
||||
* <Route name="user" path="/user/:userId" handler={User}>
|
||||
* <Route name="task" path="tasks/:taskId" handler={Task}/>
|
||||
* <Redirect from="todos/:taskId" to="task"/>
|
||||
* </Route>
|
||||
* </Route>
|
||||
* );
|
||||
*/
|
||||
function createRoutesFromReactChildren(children) {
|
||||
var routes = [];
|
||||
|
||||
React.Children.forEach(children, function (child) {
|
||||
if (child = createRouteFromReactElement(child)) routes.push(child);
|
||||
});
|
||||
|
||||
return routes;
|
||||
}
|
||||
|
||||
module.exports = createRoutesFromReactChildren;
|
||||
18
node_modules/react-router/lib/getWindowScrollPosition.js
generated
vendored
18
node_modules/react-router/lib/getWindowScrollPosition.js
generated
vendored
@@ -1,18 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var invariant = require('react/lib/invariant');
|
||||
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
|
||||
|
||||
/**
|
||||
* Returns the current scroll position of the window as { x, y }.
|
||||
*/
|
||||
function getWindowScrollPosition() {
|
||||
invariant(canUseDOM, 'Cannot get current scroll position without a DOM');
|
||||
|
||||
return {
|
||||
x: window.pageXOffset || document.documentElement.scrollLeft,
|
||||
y: window.pageYOffset || document.documentElement.scrollTop
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = getWindowScrollPosition;
|
||||
31
node_modules/react-router/lib/index.js
generated
vendored
31
node_modules/react-router/lib/index.js
generated
vendored
@@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
exports.DefaultRoute = require('./components/DefaultRoute');
|
||||
exports.Link = require('./components/Link');
|
||||
exports.NotFoundRoute = require('./components/NotFoundRoute');
|
||||
exports.Redirect = require('./components/Redirect');
|
||||
exports.Route = require('./components/Route');
|
||||
exports.ActiveHandler = require('./components/RouteHandler');
|
||||
exports.RouteHandler = exports.ActiveHandler;
|
||||
|
||||
exports.HashLocation = require('./locations/HashLocation');
|
||||
exports.HistoryLocation = require('./locations/HistoryLocation');
|
||||
exports.RefreshLocation = require('./locations/RefreshLocation');
|
||||
exports.StaticLocation = require('./locations/StaticLocation');
|
||||
exports.TestLocation = require('./locations/TestLocation');
|
||||
|
||||
exports.ImitateBrowserBehavior = require('./behaviors/ImitateBrowserBehavior');
|
||||
exports.ScrollToTopBehavior = require('./behaviors/ScrollToTopBehavior');
|
||||
|
||||
exports.History = require('./History');
|
||||
exports.Navigation = require('./Navigation');
|
||||
exports.State = require('./State');
|
||||
|
||||
exports.createRoute = require('./Route').createRoute;
|
||||
exports.createDefaultRoute = require('./Route').createDefaultRoute;
|
||||
exports.createNotFoundRoute = require('./Route').createNotFoundRoute;
|
||||
exports.createRedirect = require('./Route').createRedirect;
|
||||
exports.createRoutesFromReactChildren = require('./createRoutesFromReactChildren');
|
||||
|
||||
exports.create = require('./createRouter');
|
||||
exports.run = require('./runRouter');
|
||||
13
node_modules/react-router/lib/isReactChildren.js
generated
vendored
13
node_modules/react-router/lib/isReactChildren.js
generated
vendored
@@ -1,13 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
|
||||
function isValidChild(object) {
|
||||
return object == null || React.isValidElement(object);
|
||||
}
|
||||
|
||||
function isReactChildren(object) {
|
||||
return isValidChild(object) || Array.isArray(object) && object.every(isValidChild);
|
||||
}
|
||||
|
||||
module.exports = isReactChildren;
|
||||
111
node_modules/react-router/lib/locations/HashLocation.js
generated
vendored
111
node_modules/react-router/lib/locations/HashLocation.js
generated
vendored
@@ -1,111 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var LocationActions = require('../actions/LocationActions');
|
||||
var History = require('../History');
|
||||
|
||||
var _listeners = [];
|
||||
var _isListening = false;
|
||||
var _actionType;
|
||||
|
||||
function notifyChange(type) {
|
||||
if (type === LocationActions.PUSH) History.length += 1;
|
||||
|
||||
var change = {
|
||||
path: HashLocation.getCurrentPath(),
|
||||
type: type
|
||||
};
|
||||
|
||||
_listeners.forEach(function (listener) {
|
||||
listener.call(HashLocation, change);
|
||||
});
|
||||
}
|
||||
|
||||
function ensureSlash() {
|
||||
var path = HashLocation.getCurrentPath();
|
||||
|
||||
if (path.charAt(0) === '/') {
|
||||
return true;
|
||||
}HashLocation.replace('/' + path);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function onHashChange() {
|
||||
if (ensureSlash()) {
|
||||
// If we don't have an _actionType then all we know is the hash
|
||||
// changed. It was probably caused by the user clicking the Back
|
||||
// button, but may have also been the Forward button or manual
|
||||
// manipulation. So just guess 'pop'.
|
||||
var curActionType = _actionType;
|
||||
_actionType = null;
|
||||
notifyChange(curActionType || LocationActions.POP);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A Location that uses `window.location.hash`.
|
||||
*/
|
||||
var HashLocation = {
|
||||
|
||||
addChangeListener: function addChangeListener(listener) {
|
||||
_listeners.push(listener);
|
||||
|
||||
// Do this BEFORE listening for hashchange.
|
||||
ensureSlash();
|
||||
|
||||
if (!_isListening) {
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener('hashchange', onHashChange, false);
|
||||
} else {
|
||||
window.attachEvent('onhashchange', onHashChange);
|
||||
}
|
||||
|
||||
_isListening = true;
|
||||
}
|
||||
},
|
||||
|
||||
removeChangeListener: function removeChangeListener(listener) {
|
||||
_listeners = _listeners.filter(function (l) {
|
||||
return l !== listener;
|
||||
});
|
||||
|
||||
if (_listeners.length === 0) {
|
||||
if (window.removeEventListener) {
|
||||
window.removeEventListener('hashchange', onHashChange, false);
|
||||
} else {
|
||||
window.removeEvent('onhashchange', onHashChange);
|
||||
}
|
||||
|
||||
_isListening = false;
|
||||
}
|
||||
},
|
||||
|
||||
push: function push(path) {
|
||||
_actionType = LocationActions.PUSH;
|
||||
window.location.hash = path;
|
||||
},
|
||||
|
||||
replace: function replace(path) {
|
||||
_actionType = LocationActions.REPLACE;
|
||||
window.location.replace(window.location.pathname + window.location.search + '#' + path);
|
||||
},
|
||||
|
||||
pop: function pop() {
|
||||
_actionType = LocationActions.POP;
|
||||
History.back();
|
||||
},
|
||||
|
||||
getCurrentPath: function getCurrentPath() {
|
||||
return decodeURI(
|
||||
// We can't use window.location.hash here because it's not
|
||||
// consistent across browsers - Firefox will pre-decode it!
|
||||
window.location.href.split('#')[1] || '');
|
||||
},
|
||||
|
||||
toString: function toString() {
|
||||
return '<HashLocation>';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = HashLocation;
|
||||
86
node_modules/react-router/lib/locations/HistoryLocation.js
generated
vendored
86
node_modules/react-router/lib/locations/HistoryLocation.js
generated
vendored
@@ -1,86 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var LocationActions = require('../actions/LocationActions');
|
||||
var History = require('../History');
|
||||
|
||||
var _listeners = [];
|
||||
var _isListening = false;
|
||||
|
||||
function notifyChange(type) {
|
||||
var change = {
|
||||
path: HistoryLocation.getCurrentPath(),
|
||||
type: type
|
||||
};
|
||||
|
||||
_listeners.forEach(function (listener) {
|
||||
listener.call(HistoryLocation, change);
|
||||
});
|
||||
}
|
||||
|
||||
function onPopState(event) {
|
||||
if (event.state === undefined) {
|
||||
return;
|
||||
} // Ignore extraneous popstate events in WebKit.
|
||||
|
||||
notifyChange(LocationActions.POP);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Location that uses HTML5 history.
|
||||
*/
|
||||
var HistoryLocation = {
|
||||
|
||||
addChangeListener: function addChangeListener(listener) {
|
||||
_listeners.push(listener);
|
||||
|
||||
if (!_isListening) {
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener('popstate', onPopState, false);
|
||||
} else {
|
||||
window.attachEvent('onpopstate', onPopState);
|
||||
}
|
||||
|
||||
_isListening = true;
|
||||
}
|
||||
},
|
||||
|
||||
removeChangeListener: function removeChangeListener(listener) {
|
||||
_listeners = _listeners.filter(function (l) {
|
||||
return l !== listener;
|
||||
});
|
||||
|
||||
if (_listeners.length === 0) {
|
||||
if (window.addEventListener) {
|
||||
window.removeEventListener('popstate', onPopState, false);
|
||||
} else {
|
||||
window.removeEvent('onpopstate', onPopState);
|
||||
}
|
||||
|
||||
_isListening = false;
|
||||
}
|
||||
},
|
||||
|
||||
push: function push(path) {
|
||||
window.history.pushState({ path: path }, '', path);
|
||||
History.length += 1;
|
||||
notifyChange(LocationActions.PUSH);
|
||||
},
|
||||
|
||||
replace: function replace(path) {
|
||||
window.history.replaceState({ path: path }, '', path);
|
||||
notifyChange(LocationActions.REPLACE);
|
||||
},
|
||||
|
||||
pop: History.back,
|
||||
|
||||
getCurrentPath: function getCurrentPath() {
|
||||
return decodeURI(window.location.pathname + window.location.search);
|
||||
},
|
||||
|
||||
toString: function toString() {
|
||||
return '<HistoryLocation>';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = HistoryLocation;
|
||||
31
node_modules/react-router/lib/locations/RefreshLocation.js
generated
vendored
31
node_modules/react-router/lib/locations/RefreshLocation.js
generated
vendored
@@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var HistoryLocation = require('./HistoryLocation');
|
||||
var History = require('../History');
|
||||
|
||||
/**
|
||||
* A Location that uses full page refreshes. This is used as
|
||||
* the fallback for HistoryLocation in browsers that do not
|
||||
* support the HTML5 history API.
|
||||
*/
|
||||
var RefreshLocation = {
|
||||
|
||||
push: function push(path) {
|
||||
window.location = path;
|
||||
},
|
||||
|
||||
replace: function replace(path) {
|
||||
window.location.replace(path);
|
||||
},
|
||||
|
||||
pop: History.back,
|
||||
|
||||
getCurrentPath: HistoryLocation.getCurrentPath,
|
||||
|
||||
toString: function toString() {
|
||||
return '<RefreshLocation>';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = RefreshLocation;
|
||||
49
node_modules/react-router/lib/locations/StaticLocation.js
generated
vendored
49
node_modules/react-router/lib/locations/StaticLocation.js
generated
vendored
@@ -1,49 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
var invariant = require('react/lib/invariant');
|
||||
|
||||
function throwCannotModify() {
|
||||
invariant(false, 'You cannot modify a static location');
|
||||
}
|
||||
|
||||
/**
|
||||
* A location that only ever contains a single path. Useful in
|
||||
* stateless environments like servers where there is no path history,
|
||||
* only the path that was used in the request.
|
||||
*/
|
||||
|
||||
var StaticLocation = (function () {
|
||||
function StaticLocation(path) {
|
||||
_classCallCheck(this, StaticLocation);
|
||||
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
_createClass(StaticLocation, [{
|
||||
key: 'getCurrentPath',
|
||||
value: function getCurrentPath() {
|
||||
return this.path;
|
||||
}
|
||||
}, {
|
||||
key: 'toString',
|
||||
value: function toString() {
|
||||
return '<StaticLocation path="' + this.path + '">';
|
||||
}
|
||||
}]);
|
||||
|
||||
return StaticLocation;
|
||||
})();
|
||||
|
||||
// TODO: Include these in the above class definition
|
||||
// once we can use ES7 property initializers.
|
||||
// https://github.com/babel/babel/issues/619
|
||||
|
||||
StaticLocation.prototype.push = throwCannotModify;
|
||||
StaticLocation.prototype.replace = throwCannotModify;
|
||||
StaticLocation.prototype.pop = throwCannotModify;
|
||||
|
||||
module.exports = StaticLocation;
|
||||
94
node_modules/react-router/lib/locations/TestLocation.js
generated
vendored
94
node_modules/react-router/lib/locations/TestLocation.js
generated
vendored
@@ -1,94 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
var invariant = require('react/lib/invariant');
|
||||
var LocationActions = require('../actions/LocationActions');
|
||||
var History = require('../History');
|
||||
|
||||
/**
|
||||
* A location that is convenient for testing and does not require a DOM.
|
||||
*/
|
||||
|
||||
var TestLocation = (function () {
|
||||
function TestLocation(history) {
|
||||
_classCallCheck(this, TestLocation);
|
||||
|
||||
this.history = history || [];
|
||||
this.listeners = [];
|
||||
this._updateHistoryLength();
|
||||
}
|
||||
|
||||
_createClass(TestLocation, [{
|
||||
key: 'needsDOM',
|
||||
get: function () {
|
||||
return false;
|
||||
}
|
||||
}, {
|
||||
key: '_updateHistoryLength',
|
||||
value: function _updateHistoryLength() {
|
||||
History.length = this.history.length;
|
||||
}
|
||||
}, {
|
||||
key: '_notifyChange',
|
||||
value: function _notifyChange(type) {
|
||||
var change = {
|
||||
path: this.getCurrentPath(),
|
||||
type: type
|
||||
};
|
||||
|
||||
for (var i = 0, len = this.listeners.length; i < len; ++i) this.listeners[i].call(this, change);
|
||||
}
|
||||
}, {
|
||||
key: 'addChangeListener',
|
||||
value: function addChangeListener(listener) {
|
||||
this.listeners.push(listener);
|
||||
}
|
||||
}, {
|
||||
key: 'removeChangeListener',
|
||||
value: function removeChangeListener(listener) {
|
||||
this.listeners = this.listeners.filter(function (l) {
|
||||
return l !== listener;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'push',
|
||||
value: function push(path) {
|
||||
this.history.push(path);
|
||||
this._updateHistoryLength();
|
||||
this._notifyChange(LocationActions.PUSH);
|
||||
}
|
||||
}, {
|
||||
key: 'replace',
|
||||
value: function replace(path) {
|
||||
invariant(this.history.length, 'You cannot replace the current path with no history');
|
||||
|
||||
this.history[this.history.length - 1] = path;
|
||||
|
||||
this._notifyChange(LocationActions.REPLACE);
|
||||
}
|
||||
}, {
|
||||
key: 'pop',
|
||||
value: function pop() {
|
||||
this.history.pop();
|
||||
this._updateHistoryLength();
|
||||
this._notifyChange(LocationActions.POP);
|
||||
}
|
||||
}, {
|
||||
key: 'getCurrentPath',
|
||||
value: function getCurrentPath() {
|
||||
return this.history[this.history.length - 1];
|
||||
}
|
||||
}, {
|
||||
key: 'toString',
|
||||
value: function toString() {
|
||||
return '<TestLocation>';
|
||||
}
|
||||
}]);
|
||||
|
||||
return TestLocation;
|
||||
})();
|
||||
|
||||
module.exports = TestLocation;
|
||||
50
node_modules/react-router/lib/runRouter.js
generated
vendored
50
node_modules/react-router/lib/runRouter.js
generated
vendored
@@ -1,50 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var createRouter = require('./createRouter');
|
||||
|
||||
/**
|
||||
* A high-level convenience method that creates, configures, and
|
||||
* runs a router in one shot. The method signature is:
|
||||
*
|
||||
* Router.run(routes[, location ], callback);
|
||||
*
|
||||
* Using `window.location.hash` to manage the URL, you could do:
|
||||
*
|
||||
* Router.run(routes, function (Handler) {
|
||||
* React.render(<Handler/>, document.body);
|
||||
* });
|
||||
*
|
||||
* Using HTML5 history and a custom "cursor" prop:
|
||||
*
|
||||
* Router.run(routes, Router.HistoryLocation, function (Handler) {
|
||||
* React.render(<Handler cursor={cursor}/>, document.body);
|
||||
* });
|
||||
*
|
||||
* Returns the newly created router.
|
||||
*
|
||||
* Note: If you need to specify further options for your router such
|
||||
* as error/abort handling or custom scroll behavior, use Router.create
|
||||
* instead.
|
||||
*
|
||||
* var router = Router.create(options);
|
||||
* router.run(function (Handler) {
|
||||
* // ...
|
||||
* });
|
||||
*/
|
||||
function runRouter(routes, location, callback) {
|
||||
if (typeof location === 'function') {
|
||||
callback = location;
|
||||
location = null;
|
||||
}
|
||||
|
||||
var router = createRouter({
|
||||
routes: routes,
|
||||
location: location
|
||||
});
|
||||
|
||||
router.run(callback);
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
module.exports = runRouter;
|
||||
16
node_modules/react-router/lib/supportsHistory.js
generated
vendored
16
node_modules/react-router/lib/supportsHistory.js
generated
vendored
@@ -1,16 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
function supportsHistory() {
|
||||
/*! taken from modernizr
|
||||
* https://github.com/Modernizr/Modernizr/blob/master/LICENSE
|
||||
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
|
||||
* changed to avoid false negatives for Windows Phones: https://github.com/rackt/react-router/issues/586
|
||||
*/
|
||||
var ua = navigator.userAgent;
|
||||
if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) {
|
||||
return false;
|
||||
}
|
||||
return window.history && 'pushState' in window.history;
|
||||
}
|
||||
|
||||
module.exports = supportsHistory;
|
||||
26
node_modules/react-router/node_modules/object-assign/index.js
generated
vendored
26
node_modules/react-router/node_modules/object-assign/index.js
generated
vendored
@@ -1,26 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
function ToObject(val) {
|
||||
if (val == null) {
|
||||
throw new TypeError('Object.assign cannot be called with null or undefined');
|
||||
}
|
||||
|
||||
return Object(val);
|
||||
}
|
||||
|
||||
module.exports = Object.assign || function (target, source) {
|
||||
var from;
|
||||
var keys;
|
||||
var to = ToObject(target);
|
||||
|
||||
for (var s = 1; s < arguments.length; s++) {
|
||||
from = arguments[s];
|
||||
keys = Object.keys(Object(from));
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
to[keys[i]] = from[keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
return to;
|
||||
};
|
||||
21
node_modules/react-router/node_modules/object-assign/license
generated
vendored
21
node_modules/react-router/node_modules/object-assign/license
generated
vendored
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
68
node_modules/react-router/node_modules/object-assign/package.json
generated
vendored
68
node_modules/react-router/node_modules/object-assign/package.json
generated
vendored
@@ -1,68 +0,0 @@
|
||||
{
|
||||
"name": "object-assign",
|
||||
"version": "2.1.1",
|
||||
"description": "ES6 Object.assign() ponyfill",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/object-assign.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "http://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"object",
|
||||
"assign",
|
||||
"extend",
|
||||
"properties",
|
||||
"es6",
|
||||
"ecmascript",
|
||||
"harmony",
|
||||
"ponyfill",
|
||||
"prollyfill",
|
||||
"polyfill",
|
||||
"shim",
|
||||
"browser"
|
||||
],
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
},
|
||||
"gitHead": "4cd0365f5a78dd369473ca0bbd31f7b234148c42",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/object-assign/issues"
|
||||
},
|
||||
"homepage": "https://github.com/sindresorhus/object-assign",
|
||||
"_id": "object-assign@2.1.1",
|
||||
"_shasum": "43c36e5d569ff8e4816c4efa8be02d26967c18aa",
|
||||
"_from": "object-assign@>=2.0.0 <3.0.0",
|
||||
"_npmVersion": "2.10.1",
|
||||
"_nodeVersion": "0.12.4",
|
||||
"_npmUser": {
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "43c36e5d569ff8e4816c4efa8be02d26967c18aa",
|
||||
"tarball": "http://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
||||
51
node_modules/react-router/node_modules/object-assign/readme.md
generated
vendored
51
node_modules/react-router/node_modules/object-assign/readme.md
generated
vendored
@@ -1,51 +0,0 @@
|
||||
# object-assign [](https://travis-ci.org/sindresorhus/object-assign)
|
||||
|
||||
> ES6 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill
|
||||
|
||||
> Ponyfill: A polyfill that doesn't overwrite the native method
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save object-assign
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var objectAssign = require('object-assign');
|
||||
|
||||
objectAssign({foo: 0}, {bar: 1});
|
||||
//=> {foo: 0, bar: 1}
|
||||
|
||||
// multiple sources
|
||||
objectAssign({foo: 0}, {bar: 1}, {baz: 2});
|
||||
//=> {foo: 0, bar: 1, baz: 2}
|
||||
|
||||
// overwrites equal keys
|
||||
objectAssign({foo: 0}, {foo: 1}, {foo: 2});
|
||||
//=> {foo: 2}
|
||||
|
||||
// ignores null and undefined sources
|
||||
objectAssign({foo: 0}, null, {bar: 1}, undefined);
|
||||
//=> {foo: 0, bar: 1}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### objectAssign(target, source, [source, ...])
|
||||
|
||||
Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones.
|
||||
|
||||
|
||||
## Resources
|
||||
|
||||
- [ES6 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
1
node_modules/react-router/node_modules/qs/.jshintignore
generated
vendored
1
node_modules/react-router/node_modules/qs/.jshintignore
generated
vendored
@@ -1 +0,0 @@
|
||||
node_modules
|
||||
10
node_modules/react-router/node_modules/qs/.jshintrc
generated
vendored
10
node_modules/react-router/node_modules/qs/.jshintrc
generated
vendored
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"node": true,
|
||||
|
||||
"curly": true,
|
||||
"latedef": true,
|
||||
"quotmark": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"trailing": true
|
||||
}
|
||||
18
node_modules/react-router/node_modules/qs/.npmignore
generated
vendored
18
node_modules/react-router/node_modules/qs/.npmignore
generated
vendored
@@ -1,18 +0,0 @@
|
||||
.idea
|
||||
*.iml
|
||||
npm-debug.log
|
||||
dump.rdb
|
||||
node_modules
|
||||
results.tap
|
||||
results.xml
|
||||
npm-shrinkwrap.json
|
||||
config.json
|
||||
.DS_Store
|
||||
*/.DS_Store
|
||||
*/*/.DS_Store
|
||||
._*
|
||||
*/._*
|
||||
*/*/._*
|
||||
coverage.*
|
||||
lib-cov
|
||||
complexity.md
|
||||
6
node_modules/react-router/node_modules/qs/.travis.yml
generated
vendored
6
node_modules/react-router/node_modules/qs/.travis.yml
generated
vendored
@@ -1,6 +0,0 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 0.10
|
||||
- 0.12
|
||||
- iojs
|
||||
68
node_modules/react-router/node_modules/qs/CHANGELOG.md
generated
vendored
68
node_modules/react-router/node_modules/qs/CHANGELOG.md
generated
vendored
@@ -1,68 +0,0 @@
|
||||
|
||||
## [**2.3.3**](https://github.com/hapijs/qs/issues?milestone=18&state=open)
|
||||
- [**#59**](https://github.com/hapijs/qs/issues/59) make sure array indexes are >= 0, closes #57
|
||||
- [**#58**](https://github.com/hapijs/qs/issues/58) make qs usable for browser loader
|
||||
|
||||
## [**2.3.2**](https://github.com/hapijs/qs/issues?milestone=17&state=closed)
|
||||
- [**#55**](https://github.com/hapijs/qs/issues/55) allow merging a string into an object
|
||||
|
||||
## [**2.3.1**](https://github.com/hapijs/qs/issues?milestone=16&state=closed)
|
||||
- [**#52**](https://github.com/hapijs/qs/issues/52) Return "undefined" and "false" instead of throwing "TypeError".
|
||||
|
||||
## [**2.3.0**](https://github.com/hapijs/qs/issues?milestone=15&state=closed)
|
||||
- [**#50**](https://github.com/hapijs/qs/issues/50) add option to omit array indices, closes #46
|
||||
|
||||
## [**2.2.5**](https://github.com/hapijs/qs/issues?milestone=14&state=closed)
|
||||
- [**#39**](https://github.com/hapijs/qs/issues/39) Is there an alternative to Buffer.isBuffer?
|
||||
- [**#49**](https://github.com/hapijs/qs/issues/49) refactor utils.merge, fixes #45
|
||||
- [**#41**](https://github.com/hapijs/qs/issues/41) avoid browserifying Buffer, for #39
|
||||
|
||||
## [**2.2.4**](https://github.com/hapijs/qs/issues?milestone=13&state=closed)
|
||||
- [**#38**](https://github.com/hapijs/qs/issues/38) how to handle object keys beginning with a number
|
||||
|
||||
## [**2.2.3**](https://github.com/hapijs/qs/issues?milestone=12&state=closed)
|
||||
- [**#37**](https://github.com/hapijs/qs/issues/37) parser discards first empty value in array
|
||||
- [**#36**](https://github.com/hapijs/qs/issues/36) Update to lab 4.x
|
||||
|
||||
## [**2.2.2**](https://github.com/hapijs/qs/issues?milestone=11&state=closed)
|
||||
- [**#33**](https://github.com/hapijs/qs/issues/33) Error when plain object in a value
|
||||
- [**#34**](https://github.com/hapijs/qs/issues/34) use Object.prototype.hasOwnProperty.call instead of obj.hasOwnProperty
|
||||
- [**#24**](https://github.com/hapijs/qs/issues/24) Changelog? Semver?
|
||||
|
||||
## [**2.2.1**](https://github.com/hapijs/qs/issues?milestone=10&state=closed)
|
||||
- [**#32**](https://github.com/hapijs/qs/issues/32) account for circular references properly, closes #31
|
||||
- [**#31**](https://github.com/hapijs/qs/issues/31) qs.parse stackoverflow on circular objects
|
||||
|
||||
## [**2.2.0**](https://github.com/hapijs/qs/issues?milestone=9&state=closed)
|
||||
- [**#26**](https://github.com/hapijs/qs/issues/26) Don't use Buffer global if it's not present
|
||||
- [**#30**](https://github.com/hapijs/qs/issues/30) Bug when merging non-object values into arrays
|
||||
- [**#29**](https://github.com/hapijs/qs/issues/29) Don't call Utils.clone at the top of Utils.merge
|
||||
- [**#23**](https://github.com/hapijs/qs/issues/23) Ability to not limit parameters?
|
||||
|
||||
## [**2.1.0**](https://github.com/hapijs/qs/issues?milestone=8&state=closed)
|
||||
- [**#22**](https://github.com/hapijs/qs/issues/22) Enable using a RegExp as delimiter
|
||||
|
||||
## [**2.0.0**](https://github.com/hapijs/qs/issues?milestone=7&state=closed)
|
||||
- [**#18**](https://github.com/hapijs/qs/issues/18) Why is there arrayLimit?
|
||||
- [**#20**](https://github.com/hapijs/qs/issues/20) Configurable parametersLimit
|
||||
- [**#21**](https://github.com/hapijs/qs/issues/21) make all limits optional, for #18, for #20
|
||||
|
||||
## [**1.2.2**](https://github.com/hapijs/qs/issues?milestone=6&state=closed)
|
||||
- [**#19**](https://github.com/hapijs/qs/issues/19) Don't overwrite null values
|
||||
|
||||
## [**1.2.1**](https://github.com/hapijs/qs/issues?milestone=5&state=closed)
|
||||
- [**#16**](https://github.com/hapijs/qs/issues/16) ignore non-string delimiters
|
||||
- [**#15**](https://github.com/hapijs/qs/issues/15) Close code block
|
||||
|
||||
## [**1.2.0**](https://github.com/hapijs/qs/issues?milestone=4&state=closed)
|
||||
- [**#12**](https://github.com/hapijs/qs/issues/12) Add optional delim argument
|
||||
- [**#13**](https://github.com/hapijs/qs/issues/13) fix #11: flattened keys in array are now correctly parsed
|
||||
|
||||
## [**1.1.0**](https://github.com/hapijs/qs/issues?milestone=3&state=closed)
|
||||
- [**#7**](https://github.com/hapijs/qs/issues/7) Empty values of a POST array disappear after being submitted
|
||||
- [**#9**](https://github.com/hapijs/qs/issues/9) Should not omit equals signs (=) when value is null
|
||||
- [**#6**](https://github.com/hapijs/qs/issues/6) Minor grammar fix in README
|
||||
|
||||
## [**1.0.2**](https://github.com/hapijs/qs/issues?milestone=2&state=closed)
|
||||
- [**#5**](https://github.com/hapijs/qs/issues/5) array holes incorrectly copied into object on large index
|
||||
|
||||
1
node_modules/react-router/node_modules/qs/CONTRIBUTING.md
generated
vendored
1
node_modules/react-router/node_modules/qs/CONTRIBUTING.md
generated
vendored
@@ -1 +0,0 @@
|
||||
Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/CONTRIBUTING.md).
|
||||
28
node_modules/react-router/node_modules/qs/LICENSE
generated
vendored
28
node_modules/react-router/node_modules/qs/LICENSE
generated
vendored
@@ -1,28 +0,0 @@
|
||||
Copyright (c) 2014 Nathan LaFreniere and other contributors.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
* * *
|
||||
|
||||
The complete list of contributors can be found at: https://github.com/hapijs/qs/graphs/contributors
|
||||
8
node_modules/react-router/node_modules/qs/Makefile
generated
vendored
8
node_modules/react-router/node_modules/qs/Makefile
generated
vendored
@@ -1,8 +0,0 @@
|
||||
test:
|
||||
@node node_modules/lab/bin/lab -a code -L
|
||||
test-cov:
|
||||
@node node_modules/lab/bin/lab -a code -t 100 -L
|
||||
test-cov-html:
|
||||
@node node_modules/lab/bin/lab -a code -L -r html -o coverage.html
|
||||
|
||||
.PHONY: test test-cov test-cov-html
|
||||
233
node_modules/react-router/node_modules/qs/README.md
generated
vendored
233
node_modules/react-router/node_modules/qs/README.md
generated
vendored
@@ -1,233 +0,0 @@
|
||||
# qs
|
||||
|
||||
A querystring parsing and stringifying library with some added security.
|
||||
|
||||
[](http://travis-ci.org/hapijs/qs)
|
||||
|
||||
Lead Maintainer: [Nathan LaFreniere](https://github.com/nlf)
|
||||
|
||||
The **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring).
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var Qs = require('qs');
|
||||
|
||||
var obj = Qs.parse('a=c'); // { a: 'c' }
|
||||
var str = Qs.stringify(obj); // 'a=c'
|
||||
```
|
||||
|
||||
### Parsing Objects
|
||||
|
||||
```javascript
|
||||
Qs.parse(string, [options]);
|
||||
```
|
||||
|
||||
**qs** allows you to create nested objects within your query strings, by surrounding the name of sub-keys with square brackets `[]`.
|
||||
For example, the string `'foo[bar]=baz'` converts to:
|
||||
|
||||
```javascript
|
||||
{
|
||||
foo: {
|
||||
bar: 'baz'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
URI encoded strings work too:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a%5Bb%5D=c');
|
||||
// { a: { b: 'c' } }
|
||||
```
|
||||
|
||||
You can also nest your objects, like `'foo[bar][baz]=foobarbaz'`:
|
||||
|
||||
```javascript
|
||||
{
|
||||
foo: {
|
||||
bar: {
|
||||
baz: 'foobarbaz'
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
By default, when nesting objects **qs** will only parse up to 5 children deep. This means if you attempt to parse a string like
|
||||
`'a[b][c][d][e][f][g][h][i]=j'` your resulting object will be:
|
||||
|
||||
```javascript
|
||||
{
|
||||
a: {
|
||||
b: {
|
||||
c: {
|
||||
d: {
|
||||
e: {
|
||||
f: {
|
||||
'[g][h][i]': 'j'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This depth can be overridden by passing a `depth` option to `Qs.parse(string, [options])`:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 });
|
||||
// { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } }
|
||||
```
|
||||
|
||||
The depth limit helps mitigate abuse when **qs** is used to parse user input, and it is recommended to keep it a reasonably small number.
|
||||
|
||||
For similar reasons, by default **qs** will only parse up to 1000 parameters. This can be overridden by passing a `parameterLimit` option:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a=b&c=d', { parameterLimit: 1 });
|
||||
// { a: 'b' }
|
||||
```
|
||||
|
||||
An optional delimiter can also be passed:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a=b;c=d', { delimiter: ';' });
|
||||
// { a: 'b', c: 'd' }
|
||||
```
|
||||
|
||||
Delimiters can be a regular expression too:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ });
|
||||
// { a: 'b', c: 'd', e: 'f' }
|
||||
```
|
||||
|
||||
### Parsing Arrays
|
||||
|
||||
**qs** can also parse arrays using a similar `[]` notation:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a[]=b&a[]=c');
|
||||
// { a: ['b', 'c'] }
|
||||
```
|
||||
|
||||
You may specify an index as well:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a[1]=c&a[0]=b');
|
||||
// { a: ['b', 'c'] }
|
||||
```
|
||||
|
||||
Note that the only difference between an index in an array and a key in an object is that the value between the brackets must be a number
|
||||
to create an array. When creating arrays with specific indices, **qs** will compact a sparse array to only the existing values preserving
|
||||
their order:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a[1]=b&a[15]=c');
|
||||
// { a: ['b', 'c'] }
|
||||
```
|
||||
|
||||
Note that an empty string is also a value, and will be preserved:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a[]=&a[]=b');
|
||||
// { a: ['', 'b'] }
|
||||
Qs.parse('a[0]=b&a[1]=&a[2]=c');
|
||||
// { a: ['b', '', 'c'] }
|
||||
```
|
||||
|
||||
**qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will
|
||||
instead be converted to an object with the index as the key:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a[100]=b');
|
||||
// { a: { '100': 'b' } }
|
||||
```
|
||||
|
||||
This limit can be overridden by passing an `arrayLimit` option:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a[1]=b', { arrayLimit: 0 });
|
||||
// { a: { '1': 'b' } }
|
||||
```
|
||||
|
||||
To disable array parsing entirely, set `arrayLimit` to `-1`.
|
||||
|
||||
If you mix notations, **qs** will merge the two items into an object:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a[0]=b&a[b]=c');
|
||||
// { a: { '0': 'b', b: 'c' } }
|
||||
```
|
||||
|
||||
You can also create arrays of objects:
|
||||
|
||||
```javascript
|
||||
Qs.parse('a[][b]=c');
|
||||
// { a: [{ b: 'c' }] }
|
||||
```
|
||||
|
||||
### Stringifying
|
||||
|
||||
```javascript
|
||||
Qs.stringify(object, [options]);
|
||||
```
|
||||
|
||||
When stringifying, **qs** always URI encodes output. Objects are stringified as you would expect:
|
||||
|
||||
```javascript
|
||||
Qs.stringify({ a: 'b' });
|
||||
// 'a=b'
|
||||
Qs.stringify({ a: { b: 'c' } });
|
||||
// 'a%5Bb%5D=c'
|
||||
```
|
||||
|
||||
Examples beyond this point will be shown as though the output is not URI encoded for clarity. Please note that the return values in these cases *will* be URI encoded during real usage.
|
||||
|
||||
When arrays are stringified, by default they are given explicit indices:
|
||||
|
||||
```javascript
|
||||
Qs.stringify({ a: ['b', 'c', 'd'] });
|
||||
// 'a[0]=b&a[1]=c&a[2]=d'
|
||||
```
|
||||
|
||||
You may override this by setting the `indices` option to `false`:
|
||||
|
||||
```javascript
|
||||
Qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false });
|
||||
// 'a=b&a=c&a=d'
|
||||
```
|
||||
|
||||
You may use the `arrayFormat` option to specify the format of the output array
|
||||
|
||||
```javascript
|
||||
Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })
|
||||
// 'a[0]=b&a[1]=c'
|
||||
Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
|
||||
// 'a[]=b&a[]=c'
|
||||
Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
|
||||
// 'a=b&a=c'
|
||||
```
|
||||
|
||||
Empty strings and null values will omit the value, but the equals sign (=) remains in place:
|
||||
|
||||
```javascript
|
||||
Qs.stringify({ a: '' });
|
||||
// 'a='
|
||||
```
|
||||
|
||||
Properties that are set to `undefined` will be omitted entirely:
|
||||
|
||||
```javascript
|
||||
Qs.stringify({ a: null, b: undefined });
|
||||
// 'a='
|
||||
```
|
||||
|
||||
The delimiter may be overridden with stringify as well:
|
||||
|
||||
```javascript
|
||||
Qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' });
|
||||
// 'a=b;c=d'
|
||||
```
|
||||
1
node_modules/react-router/node_modules/qs/index.js
generated
vendored
1
node_modules/react-router/node_modules/qs/index.js
generated
vendored
@@ -1 +0,0 @@
|
||||
module.exports = require('./lib/');
|
||||
15
node_modules/react-router/node_modules/qs/lib/index.js
generated
vendored
15
node_modules/react-router/node_modules/qs/lib/index.js
generated
vendored
@@ -1,15 +0,0 @@
|
||||
// Load modules
|
||||
|
||||
var Stringify = require('./stringify');
|
||||
var Parse = require('./parse');
|
||||
|
||||
|
||||
// Declare internals
|
||||
|
||||
var internals = {};
|
||||
|
||||
|
||||
module.exports = {
|
||||
stringify: Stringify,
|
||||
parse: Parse
|
||||
};
|
||||
161
node_modules/react-router/node_modules/qs/lib/parse.js
generated
vendored
161
node_modules/react-router/node_modules/qs/lib/parse.js
generated
vendored
@@ -1,161 +0,0 @@
|
||||
// Load modules
|
||||
|
||||
var Utils = require('./utils');
|
||||
|
||||
|
||||
// Declare internals
|
||||
|
||||
var internals = {
|
||||
delimiter: '&',
|
||||
depth: 5,
|
||||
arrayLimit: 20,
|
||||
parameterLimit: 1000
|
||||
};
|
||||
|
||||
|
||||
internals.parseValues = function (str, options) {
|
||||
|
||||
var obj = {};
|
||||
var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
|
||||
|
||||
for (var i = 0, il = parts.length; i < il; ++i) {
|
||||
var part = parts[i];
|
||||
var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
|
||||
|
||||
if (pos === -1) {
|
||||
obj[Utils.decode(part)] = '';
|
||||
}
|
||||
else {
|
||||
var key = Utils.decode(part.slice(0, pos));
|
||||
var val = Utils.decode(part.slice(pos + 1));
|
||||
|
||||
if (Object.prototype.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!obj.hasOwnProperty(key)) {
|
||||
obj[key] = val;
|
||||
}
|
||||
else {
|
||||
obj[key] = [].concat(obj[key]).concat(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
internals.parseObject = function (chain, val, options) {
|
||||
|
||||
if (!chain.length) {
|
||||
return val;
|
||||
}
|
||||
|
||||
var root = chain.shift();
|
||||
|
||||
var obj = {};
|
||||
if (root === '[]') {
|
||||
obj = [];
|
||||
obj = obj.concat(internals.parseObject(chain, val, options));
|
||||
}
|
||||
else {
|
||||
var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
|
||||
var index = parseInt(cleanRoot, 10);
|
||||
var indexString = '' + index;
|
||||
if (!isNaN(index) &&
|
||||
root !== cleanRoot &&
|
||||
indexString === cleanRoot &&
|
||||
index >= 0 &&
|
||||
index <= options.arrayLimit) {
|
||||
|
||||
obj = [];
|
||||
obj[index] = internals.parseObject(chain, val, options);
|
||||
}
|
||||
else {
|
||||
obj[cleanRoot] = internals.parseObject(chain, val, options);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
internals.parseKeys = function (key, val, options) {
|
||||
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The regex chunks
|
||||
|
||||
var parent = /^([^\[\]]*)/;
|
||||
var child = /(\[[^\[\]]*\])/g;
|
||||
|
||||
// Get the parent
|
||||
|
||||
var segment = parent.exec(key);
|
||||
|
||||
// Don't allow them to overwrite object prototype properties
|
||||
|
||||
if (Object.prototype.hasOwnProperty(segment[1])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Stash the parent if it exists
|
||||
|
||||
var keys = [];
|
||||
if (segment[1]) {
|
||||
keys.push(segment[1]);
|
||||
}
|
||||
|
||||
// Loop through children appending to the array until we hit depth
|
||||
|
||||
var i = 0;
|
||||
while ((segment = child.exec(key)) !== null && i < options.depth) {
|
||||
|
||||
++i;
|
||||
if (!Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
|
||||
keys.push(segment[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// If there's a remainder, just add whatever is left
|
||||
|
||||
if (segment) {
|
||||
keys.push('[' + key.slice(segment.index) + ']');
|
||||
}
|
||||
|
||||
return internals.parseObject(keys, val, options);
|
||||
};
|
||||
|
||||
|
||||
module.exports = function (str, options) {
|
||||
|
||||
if (str === '' ||
|
||||
str === null ||
|
||||
typeof str === 'undefined') {
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter;
|
||||
options.depth = typeof options.depth === 'number' ? options.depth : internals.depth;
|
||||
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;
|
||||
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;
|
||||
|
||||
var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;
|
||||
var obj = {};
|
||||
|
||||
// Iterate over the keys and setup the new object
|
||||
|
||||
var keys = Object.keys(tempObj);
|
||||
for (var i = 0, il = keys.length; i < il; ++i) {
|
||||
var key = keys[i];
|
||||
var newObj = internals.parseKeys(key, tempObj[key], options);
|
||||
obj = Utils.merge(obj, newObj);
|
||||
}
|
||||
|
||||
return Utils.compact(obj);
|
||||
};
|
||||
97
node_modules/react-router/node_modules/qs/lib/stringify.js
generated
vendored
97
node_modules/react-router/node_modules/qs/lib/stringify.js
generated
vendored
@@ -1,97 +0,0 @@
|
||||
// Load modules
|
||||
|
||||
var Utils = require('./utils');
|
||||
|
||||
|
||||
// Declare internals
|
||||
|
||||
var internals = {
|
||||
delimiter: '&',
|
||||
arrayPrefixGenerators: {
|
||||
brackets: function (prefix, key) {
|
||||
return prefix + '[]';
|
||||
},
|
||||
indices: function (prefix, key) {
|
||||
return prefix + '[' + key + ']';
|
||||
},
|
||||
repeat: function (prefix, key) {
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.stringify = function (obj, prefix, generateArrayPrefix) {
|
||||
|
||||
if (Utils.isBuffer(obj)) {
|
||||
obj = obj.toString();
|
||||
}
|
||||
else if (obj instanceof Date) {
|
||||
obj = obj.toISOString();
|
||||
}
|
||||
else if (obj === null) {
|
||||
obj = '';
|
||||
}
|
||||
|
||||
if (typeof obj === 'string' ||
|
||||
typeof obj === 'number' ||
|
||||
typeof obj === 'boolean') {
|
||||
|
||||
return [encodeURIComponent(prefix) + '=' + encodeURIComponent(obj)];
|
||||
}
|
||||
|
||||
var values = [];
|
||||
|
||||
if (typeof obj === 'undefined') {
|
||||
return values;
|
||||
}
|
||||
|
||||
var objKeys = Object.keys(obj);
|
||||
for (var i = 0, il = objKeys.length; i < il; ++i) {
|
||||
var key = objKeys[i];
|
||||
if (Array.isArray(obj)) {
|
||||
values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix));
|
||||
}
|
||||
else {
|
||||
values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix));
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
};
|
||||
|
||||
|
||||
module.exports = function (obj, options) {
|
||||
|
||||
options = options || {};
|
||||
var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;
|
||||
|
||||
var keys = [];
|
||||
|
||||
if (typeof obj !== 'object' ||
|
||||
obj === null) {
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
var arrayFormat;
|
||||
if (options.arrayFormat in internals.arrayPrefixGenerators) {
|
||||
arrayFormat = options.arrayFormat;
|
||||
}
|
||||
else if ('indices' in options) {
|
||||
arrayFormat = options.indices ? 'indices' : 'repeat';
|
||||
}
|
||||
else {
|
||||
arrayFormat = 'indices';
|
||||
}
|
||||
|
||||
var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat];
|
||||
|
||||
var objKeys = Object.keys(obj);
|
||||
for (var i = 0, il = objKeys.length; i < il; ++i) {
|
||||
var key = objKeys[i];
|
||||
keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix));
|
||||
}
|
||||
|
||||
return keys.join(delimiter);
|
||||
};
|
||||
132
node_modules/react-router/node_modules/qs/lib/utils.js
generated
vendored
132
node_modules/react-router/node_modules/qs/lib/utils.js
generated
vendored
@@ -1,132 +0,0 @@
|
||||
// Load modules
|
||||
|
||||
|
||||
// Declare internals
|
||||
|
||||
var internals = {};
|
||||
|
||||
|
||||
exports.arrayToObject = function (source) {
|
||||
|
||||
var obj = {};
|
||||
for (var i = 0, il = source.length; i < il; ++i) {
|
||||
if (typeof source[i] !== 'undefined') {
|
||||
|
||||
obj[i] = source[i];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
exports.merge = function (target, source) {
|
||||
|
||||
if (!source) {
|
||||
return target;
|
||||
}
|
||||
|
||||
if (typeof source !== 'object') {
|
||||
if (Array.isArray(target)) {
|
||||
target.push(source);
|
||||
}
|
||||
else {
|
||||
target[source] = true;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
if (typeof target !== 'object') {
|
||||
target = [target].concat(source);
|
||||
return target;
|
||||
}
|
||||
|
||||
if (Array.isArray(target) &&
|
||||
!Array.isArray(source)) {
|
||||
|
||||
target = exports.arrayToObject(target);
|
||||
}
|
||||
|
||||
var keys = Object.keys(source);
|
||||
for (var k = 0, kl = keys.length; k < kl; ++k) {
|
||||
var key = keys[k];
|
||||
var value = source[key];
|
||||
|
||||
if (!target[key]) {
|
||||
target[key] = value;
|
||||
}
|
||||
else {
|
||||
target[key] = exports.merge(target[key], value);
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
|
||||
exports.decode = function (str) {
|
||||
|
||||
try {
|
||||
return decodeURIComponent(str.replace(/\+/g, ' '));
|
||||
} catch (e) {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.compact = function (obj, refs) {
|
||||
|
||||
if (typeof obj !== 'object' ||
|
||||
obj === null) {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
refs = refs || [];
|
||||
var lookup = refs.indexOf(obj);
|
||||
if (lookup !== -1) {
|
||||
return refs[lookup];
|
||||
}
|
||||
|
||||
refs.push(obj);
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
var compacted = [];
|
||||
|
||||
for (var i = 0, il = obj.length; i < il; ++i) {
|
||||
if (typeof obj[i] !== 'undefined') {
|
||||
compacted.push(obj[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return compacted;
|
||||
}
|
||||
|
||||
var keys = Object.keys(obj);
|
||||
for (i = 0, il = keys.length; i < il; ++i) {
|
||||
var key = keys[i];
|
||||
obj[key] = exports.compact(obj[key], refs);
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
exports.isRegExp = function (obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
||||
};
|
||||
|
||||
|
||||
exports.isBuffer = function (obj) {
|
||||
|
||||
if (obj === null ||
|
||||
typeof obj === 'undefined') {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!(obj.constructor &&
|
||||
obj.constructor.isBuffer &&
|
||||
obj.constructor.isBuffer(obj));
|
||||
};
|
||||
58
node_modules/react-router/node_modules/qs/package.json
generated
vendored
58
node_modules/react-router/node_modules/qs/package.json
generated
vendored
@@ -1,58 +0,0 @@
|
||||
{
|
||||
"name": "qs",
|
||||
"version": "2.4.1",
|
||||
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
|
||||
"homepage": "https://github.com/hapijs/qs",
|
||||
"main": "index.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"code": "1.x.x",
|
||||
"lab": "5.x.x"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test-cov"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/hapijs/qs.git"
|
||||
},
|
||||
"keywords": [
|
||||
"querystring",
|
||||
"qs"
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "BSD",
|
||||
"url": "http://github.com/hapijs/qs/raw/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"gitHead": "58c6540418954867822c1af3e45fb4c26708b07e",
|
||||
"bugs": {
|
||||
"url": "https://github.com/hapijs/qs/issues"
|
||||
},
|
||||
"_id": "qs@2.4.1",
|
||||
"_shasum": "68cbaea971013426a80c1404fad6b1a6b1175245",
|
||||
"_from": "qs@2.4.1",
|
||||
"_npmVersion": "2.6.1",
|
||||
"_nodeVersion": "0.10.36",
|
||||
"_npmUser": {
|
||||
"name": "nlf",
|
||||
"email": "quitlahok@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "nlf",
|
||||
"email": "quitlahok@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "hueniverse",
|
||||
"email": "eran@hueniverse.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "68cbaea971013426a80c1404fad6b1a6b1175245",
|
||||
"tarball": "http://registry.npmjs.org/qs/-/qs-2.4.1.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/qs/-/qs-2.4.1.tgz"
|
||||
}
|
||||
413
node_modules/react-router/node_modules/qs/test/parse.js
generated
vendored
413
node_modules/react-router/node_modules/qs/test/parse.js
generated
vendored
@@ -1,413 +0,0 @@
|
||||
/* eslint no-extend-native:0 */
|
||||
// Load modules
|
||||
|
||||
var Code = require('code');
|
||||
var Lab = require('lab');
|
||||
var Qs = require('../');
|
||||
|
||||
|
||||
// Declare internals
|
||||
|
||||
var internals = {};
|
||||
|
||||
|
||||
// Test shortcuts
|
||||
|
||||
var lab = exports.lab = Lab.script();
|
||||
var expect = Code.expect;
|
||||
var describe = lab.experiment;
|
||||
var it = lab.test;
|
||||
|
||||
|
||||
describe('parse()', function () {
|
||||
|
||||
it('parses a simple string', function (done) {
|
||||
|
||||
expect(Qs.parse('0=foo')).to.deep.equal({ '0': 'foo' });
|
||||
expect(Qs.parse('foo=c++')).to.deep.equal({ foo: 'c ' });
|
||||
expect(Qs.parse('a[>=]=23')).to.deep.equal({ a: { '>=': '23' } });
|
||||
expect(Qs.parse('a[<=>]==23')).to.deep.equal({ a: { '<=>': '=23' } });
|
||||
expect(Qs.parse('a[==]=23')).to.deep.equal({ a: { '==': '23' } });
|
||||
expect(Qs.parse('foo')).to.deep.equal({ foo: '' });
|
||||
expect(Qs.parse('foo=bar')).to.deep.equal({ foo: 'bar' });
|
||||
expect(Qs.parse(' foo = bar = baz ')).to.deep.equal({ ' foo ': ' bar = baz ' });
|
||||
expect(Qs.parse('foo=bar=baz')).to.deep.equal({ foo: 'bar=baz' });
|
||||
expect(Qs.parse('foo=bar&bar=baz')).to.deep.equal({ foo: 'bar', bar: 'baz' });
|
||||
expect(Qs.parse('foo=bar&baz')).to.deep.equal({ foo: 'bar', baz: '' });
|
||||
expect(Qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World')).to.deep.equal({
|
||||
cht: 'p3',
|
||||
chd: 't:60,40',
|
||||
chs: '250x100',
|
||||
chl: 'Hello|World'
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses a single nested string', function (done) {
|
||||
|
||||
expect(Qs.parse('a[b]=c')).to.deep.equal({ a: { b: 'c' } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses a double nested string', function (done) {
|
||||
|
||||
expect(Qs.parse('a[b][c]=d')).to.deep.equal({ a: { b: { c: 'd' } } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('defaults to a depth of 5', function (done) {
|
||||
|
||||
expect(Qs.parse('a[b][c][d][e][f][g][h]=i')).to.deep.equal({ a: { b: { c: { d: { e: { f: { '[g][h]': 'i' } } } } } } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('only parses one level when depth = 1', function (done) {
|
||||
|
||||
expect(Qs.parse('a[b][c]=d', { depth: 1 })).to.deep.equal({ a: { b: { '[c]': 'd' } } });
|
||||
expect(Qs.parse('a[b][c][d]=e', { depth: 1 })).to.deep.equal({ a: { b: { '[c][d]': 'e' } } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses a simple array', function (done) {
|
||||
|
||||
expect(Qs.parse('a=b&a=c')).to.deep.equal({ a: ['b', 'c'] });
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses an explicit array', function (done) {
|
||||
|
||||
expect(Qs.parse('a[]=b')).to.deep.equal({ a: ['b'] });
|
||||
expect(Qs.parse('a[]=b&a[]=c')).to.deep.equal({ a: ['b', 'c'] });
|
||||
expect(Qs.parse('a[]=b&a[]=c&a[]=d')).to.deep.equal({ a: ['b', 'c', 'd'] });
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses a mix of simple and explicit arrays', function (done) {
|
||||
|
||||
expect(Qs.parse('a=b&a[]=c')).to.deep.equal({ a: ['b', 'c'] });
|
||||
expect(Qs.parse('a[]=b&a=c')).to.deep.equal({ a: ['b', 'c'] });
|
||||
expect(Qs.parse('a[0]=b&a=c')).to.deep.equal({ a: ['b', 'c'] });
|
||||
expect(Qs.parse('a=b&a[0]=c')).to.deep.equal({ a: ['b', 'c'] });
|
||||
expect(Qs.parse('a[1]=b&a=c')).to.deep.equal({ a: ['b', 'c'] });
|
||||
expect(Qs.parse('a=b&a[1]=c')).to.deep.equal({ a: ['b', 'c'] });
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses a nested array', function (done) {
|
||||
|
||||
expect(Qs.parse('a[b][]=c&a[b][]=d')).to.deep.equal({ a: { b: ['c', 'd'] } });
|
||||
expect(Qs.parse('a[>=]=25')).to.deep.equal({ a: { '>=': '25' } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('allows to specify array indices', function (done) {
|
||||
|
||||
expect(Qs.parse('a[1]=c&a[0]=b&a[2]=d')).to.deep.equal({ a: ['b', 'c', 'd'] });
|
||||
expect(Qs.parse('a[1]=c&a[0]=b')).to.deep.equal({ a: ['b', 'c'] });
|
||||
expect(Qs.parse('a[1]=c')).to.deep.equal({ a: ['c'] });
|
||||
done();
|
||||
});
|
||||
|
||||
it('limits specific array indices to 20', function (done) {
|
||||
|
||||
expect(Qs.parse('a[20]=a')).to.deep.equal({ a: ['a'] });
|
||||
expect(Qs.parse('a[21]=a')).to.deep.equal({ a: { '21': 'a' } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('supports keys that begin with a number', function (done) {
|
||||
|
||||
expect(Qs.parse('a[12b]=c')).to.deep.equal({ a: { '12b': 'c' } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('supports encoded = signs', function (done) {
|
||||
|
||||
expect(Qs.parse('he%3Dllo=th%3Dere')).to.deep.equal({ 'he=llo': 'th=ere' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('is ok with url encoded strings', function (done) {
|
||||
|
||||
expect(Qs.parse('a[b%20c]=d')).to.deep.equal({ a: { 'b c': 'd' } });
|
||||
expect(Qs.parse('a[b]=c%20d')).to.deep.equal({ a: { b: 'c d' } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('allows brackets in the value', function (done) {
|
||||
|
||||
expect(Qs.parse('pets=["tobi"]')).to.deep.equal({ pets: '["tobi"]' });
|
||||
expect(Qs.parse('operators=[">=", "<="]')).to.deep.equal({ operators: '[">=", "<="]' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('allows empty values', function (done) {
|
||||
|
||||
expect(Qs.parse('')).to.deep.equal({});
|
||||
expect(Qs.parse(null)).to.deep.equal({});
|
||||
expect(Qs.parse(undefined)).to.deep.equal({});
|
||||
done();
|
||||
});
|
||||
|
||||
it('transforms arrays to objects', function (done) {
|
||||
|
||||
expect(Qs.parse('foo[0]=bar&foo[bad]=baz')).to.deep.equal({ foo: { '0': 'bar', bad: 'baz' } });
|
||||
expect(Qs.parse('foo[bad]=baz&foo[0]=bar')).to.deep.equal({ foo: { bad: 'baz', '0': 'bar' } });
|
||||
expect(Qs.parse('foo[bad]=baz&foo[]=bar')).to.deep.equal({ foo: { bad: 'baz', '0': 'bar' } });
|
||||
expect(Qs.parse('foo[]=bar&foo[bad]=baz')).to.deep.equal({ foo: { '0': 'bar', bad: 'baz' } });
|
||||
expect(Qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo')).to.deep.equal({ foo: { bad: 'baz', '0': 'bar', '1': 'foo' } });
|
||||
expect(Qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb')).to.deep.equal({foo: [ {a: 'a', b: 'b'}, {a: 'aa', b: 'bb'} ]});
|
||||
done();
|
||||
});
|
||||
|
||||
it('can add keys to objects', function (done) {
|
||||
|
||||
expect(Qs.parse('a[b]=c&a=d')).to.deep.equal({ a: { b: 'c', d: true } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('correctly prunes undefined values when converting an array to an object', function (done) {
|
||||
|
||||
expect(Qs.parse('a[2]=b&a[99999999]=c')).to.deep.equal({ a: { '2': 'b', '99999999': 'c' } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('supports malformed uri characters', function (done) {
|
||||
|
||||
expect(Qs.parse('{%:%}')).to.deep.equal({ '{%:%}': '' });
|
||||
expect(Qs.parse('foo=%:%}')).to.deep.equal({ foo: '%:%}' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('doesn\'t produce empty keys', function (done) {
|
||||
|
||||
expect(Qs.parse('_r=1&')).to.deep.equal({ '_r': '1' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('cannot override prototypes', function (done) {
|
||||
|
||||
var obj = Qs.parse('hasOwnProperty=bad&toString=bad&bad[toString]=bad&constructor=bad');
|
||||
expect(typeof obj.toString).to.equal('function');
|
||||
expect(typeof obj.bad.toString).to.equal('function');
|
||||
expect(typeof obj.constructor).to.equal('function');
|
||||
done();
|
||||
});
|
||||
|
||||
it('cannot access Object prototype', function (done) {
|
||||
|
||||
Qs.parse('constructor[prototype][bad]=bad');
|
||||
Qs.parse('bad[constructor][prototype][bad]=bad');
|
||||
expect(typeof Object.prototype.bad).to.equal('undefined');
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses arrays of objects', function (done) {
|
||||
|
||||
expect(Qs.parse('a[][b]=c')).to.deep.equal({ a: [{ b: 'c' }] });
|
||||
expect(Qs.parse('a[0][b]=c')).to.deep.equal({ a: [{ b: 'c' }] });
|
||||
done();
|
||||
});
|
||||
|
||||
it('allows for empty strings in arrays', function (done) {
|
||||
|
||||
expect(Qs.parse('a[]=b&a[]=&a[]=c')).to.deep.equal({ a: ['b', '', 'c'] });
|
||||
expect(Qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]=')).to.deep.equal({ a: ['b', '', 'c', ''] });
|
||||
expect(Qs.parse('a[]=&a[]=b&a[]=c')).to.deep.equal({ a: ['', 'b', 'c'] });
|
||||
done();
|
||||
});
|
||||
|
||||
it('compacts sparse arrays', function (done) {
|
||||
|
||||
expect(Qs.parse('a[10]=1&a[2]=2')).to.deep.equal({ a: ['2', '1'] });
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses semi-parsed strings', function (done) {
|
||||
|
||||
expect(Qs.parse({ 'a[b]': 'c' })).to.deep.equal({ a: { b: 'c' } });
|
||||
expect(Qs.parse({ 'a[b]': 'c', 'a[d]': 'e' })).to.deep.equal({ a: { b: 'c', d: 'e' } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses buffers correctly', function (done) {
|
||||
|
||||
var b = new Buffer('test');
|
||||
expect(Qs.parse({ a: b })).to.deep.equal({ a: b });
|
||||
done();
|
||||
});
|
||||
|
||||
it('continues parsing when no parent is found', function (done) {
|
||||
|
||||
expect(Qs.parse('[]&a=b')).to.deep.equal({ '0': '', a: 'b' });
|
||||
expect(Qs.parse('[foo]=bar')).to.deep.equal({ foo: 'bar' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('does not error when parsing a very long array', function (done) {
|
||||
|
||||
var str = 'a[]=a';
|
||||
while (Buffer.byteLength(str) < 128 * 1024) {
|
||||
str += '&' + str;
|
||||
}
|
||||
|
||||
expect(function () {
|
||||
|
||||
Qs.parse(str);
|
||||
}).to.not.throw();
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not throw when a native prototype has an enumerable property', { parallel: false }, function (done) {
|
||||
|
||||
Object.prototype.crash = '';
|
||||
Array.prototype.crash = '';
|
||||
expect(Qs.parse.bind(null, 'a=b')).to.not.throw();
|
||||
expect(Qs.parse('a=b')).to.deep.equal({ a: 'b' });
|
||||
expect(Qs.parse.bind(null, 'a[][b]=c')).to.not.throw();
|
||||
expect(Qs.parse('a[][b]=c')).to.deep.equal({ a: [{ b: 'c' }] });
|
||||
delete Object.prototype.crash;
|
||||
delete Array.prototype.crash;
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses a string with an alternative string delimiter', function (done) {
|
||||
|
||||
expect(Qs.parse('a=b;c=d', { delimiter: ';' })).to.deep.equal({ a: 'b', c: 'd' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses a string with an alternative RegExp delimiter', function (done) {
|
||||
|
||||
expect(Qs.parse('a=b; c=d', { delimiter: /[;,] */ })).to.deep.equal({ a: 'b', c: 'd' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('does not use non-splittable objects as delimiters', function (done) {
|
||||
|
||||
expect(Qs.parse('a=b&c=d', { delimiter: true })).to.deep.equal({ a: 'b', c: 'd' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('allows overriding parameter limit', function (done) {
|
||||
|
||||
expect(Qs.parse('a=b&c=d', { parameterLimit: 1 })).to.deep.equal({ a: 'b' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('allows setting the parameter limit to Infinity', function (done) {
|
||||
|
||||
expect(Qs.parse('a=b&c=d', { parameterLimit: Infinity })).to.deep.equal({ a: 'b', c: 'd' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('allows overriding array limit', function (done) {
|
||||
|
||||
expect(Qs.parse('a[0]=b', { arrayLimit: -1 })).to.deep.equal({ a: { '0': 'b' } });
|
||||
expect(Qs.parse('a[-1]=b', { arrayLimit: -1 })).to.deep.equal({ a: { '-1': 'b' } });
|
||||
expect(Qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 })).to.deep.equal({ a: { '0': 'b', '1': 'c' } });
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses an object', function (done) {
|
||||
|
||||
var input = {
|
||||
'user[name]': {'pop[bob]': 3},
|
||||
'user[email]': null
|
||||
};
|
||||
|
||||
var expected = {
|
||||
'user': {
|
||||
'name': {'pop[bob]': 3},
|
||||
'email': null
|
||||
}
|
||||
};
|
||||
|
||||
var result = Qs.parse(input);
|
||||
|
||||
expect(result).to.deep.equal(expected);
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses an object and not child values', function (done) {
|
||||
|
||||
var input = {
|
||||
'user[name]': {'pop[bob]': { 'test': 3 }},
|
||||
'user[email]': null
|
||||
};
|
||||
|
||||
var expected = {
|
||||
'user': {
|
||||
'name': {'pop[bob]': { 'test': 3 }},
|
||||
'email': null
|
||||
}
|
||||
};
|
||||
|
||||
var result = Qs.parse(input);
|
||||
|
||||
expect(result).to.deep.equal(expected);
|
||||
done();
|
||||
});
|
||||
|
||||
it('does not blow up when Buffer global is missing', function (done) {
|
||||
|
||||
var tempBuffer = global.Buffer;
|
||||
delete global.Buffer;
|
||||
var result = Qs.parse('a=b&c=d');
|
||||
global.Buffer = tempBuffer;
|
||||
expect(result).to.deep.equal({ a: 'b', c: 'd' });
|
||||
done();
|
||||
});
|
||||
|
||||
it('does not crash when using invalid dot notation', function (done) {
|
||||
|
||||
expect(Qs.parse('roomInfoList[0].childrenAges[0]=15&roomInfoList[0].numberOfAdults=2')).to.deep.equal({ roomInfoList: [['15', '2']] });
|
||||
done();
|
||||
});
|
||||
|
||||
it('does not crash when parsing circular references', function (done) {
|
||||
|
||||
var a = {};
|
||||
a.b = a;
|
||||
|
||||
var parsed;
|
||||
|
||||
expect(function () {
|
||||
|
||||
parsed = Qs.parse({ 'foo[bar]': 'baz', 'foo[baz]': a });
|
||||
}).to.not.throw();
|
||||
|
||||
expect(parsed).to.contain('foo');
|
||||
expect(parsed.foo).to.contain('bar', 'baz');
|
||||
expect(parsed.foo.bar).to.equal('baz');
|
||||
expect(parsed.foo.baz).to.deep.equal(a);
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses plain objects correctly', function (done) {
|
||||
|
||||
var a = Object.create(null);
|
||||
a.b = 'c';
|
||||
|
||||
expect(Qs.parse(a)).to.deep.equal({ b: 'c' });
|
||||
var result = Qs.parse({ a: a });
|
||||
expect(result).to.contain('a');
|
||||
expect(result.a).to.deep.equal(a);
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses dates correctly', function (done) {
|
||||
|
||||
var now = new Date();
|
||||
expect(Qs.parse({ a: now })).to.deep.equal({ a: now });
|
||||
done();
|
||||
});
|
||||
|
||||
it('parses regular expressions correctly', function (done) {
|
||||
|
||||
var re = /^test$/;
|
||||
expect(Qs.parse({ a: re })).to.deep.equal({ a: re });
|
||||
done();
|
||||
});
|
||||
});
|
||||
209
node_modules/react-router/node_modules/qs/test/stringify.js
generated
vendored
209
node_modules/react-router/node_modules/qs/test/stringify.js
generated
vendored
@@ -1,209 +0,0 @@
|
||||
/* eslint no-extend-native:0 */
|
||||
// Load modules
|
||||
|
||||
var Code = require('code');
|
||||
var Lab = require('lab');
|
||||
var Qs = require('../');
|
||||
|
||||
|
||||
// Declare internals
|
||||
|
||||
var internals = {};
|
||||
|
||||
|
||||
// Test shortcuts
|
||||
|
||||
var lab = exports.lab = Lab.script();
|
||||
var expect = Code.expect;
|
||||
var describe = lab.experiment;
|
||||
var it = lab.test;
|
||||
|
||||
|
||||
describe('stringify()', function () {
|
||||
|
||||
it('stringifies a querystring object', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: 'b' })).to.equal('a=b');
|
||||
expect(Qs.stringify({ a: 1 })).to.equal('a=1');
|
||||
expect(Qs.stringify({ a: 1, b: 2 })).to.equal('a=1&b=2');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies a nested object', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: { b: 'c' } })).to.equal('a%5Bb%5D=c');
|
||||
expect(Qs.stringify({ a: { b: { c: { d: 'e' } } } })).to.equal('a%5Bb%5D%5Bc%5D%5Bd%5D=e');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies an array value', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: ['b', 'c', 'd'] })).to.equal('a%5B0%5D=b&a%5B1%5D=c&a%5B2%5D=d');
|
||||
done();
|
||||
});
|
||||
|
||||
it('omits array indices when asked', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false })).to.equal('a=b&a=c&a=d');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies a nested array value', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: { b: ['c', 'd'] } })).to.equal('a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies an object inside an array', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: [{ b: 'c' }] })).to.equal('a%5B0%5D%5Bb%5D=c');
|
||||
expect(Qs.stringify({ a: [{ b: { c: [1] } }] })).to.equal('a%5B0%5D%5Bb%5D%5Bc%5D%5B0%5D=1');
|
||||
done();
|
||||
});
|
||||
|
||||
it('does not omit object keys when indices = false', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: [{ b: 'c' }] }, { indices: false })).to.equal('a%5Bb%5D=c');
|
||||
done();
|
||||
});
|
||||
|
||||
it('uses indices notation for arrays when indices=true', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: ['b', 'c'] }, { indices: true })).to.equal('a%5B0%5D=b&a%5B1%5D=c');
|
||||
done();
|
||||
});
|
||||
|
||||
it('uses indices notation for arrays when no arrayFormat is specified', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: ['b', 'c'] })).to.equal('a%5B0%5D=b&a%5B1%5D=c');
|
||||
done();
|
||||
});
|
||||
|
||||
it('uses indices notation for arrays when no arrayFormat=indices', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })).to.equal('a%5B0%5D=b&a%5B1%5D=c');
|
||||
done();
|
||||
});
|
||||
|
||||
it('uses repeat notation for arrays when no arrayFormat=repeat', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })).to.equal('a=b&a=c');
|
||||
done();
|
||||
});
|
||||
|
||||
it('uses brackets notation for arrays when no arrayFormat=brackets', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })).to.equal('a%5B%5D=b&a%5B%5D=c');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies a complicated object', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: { b: 'c', d: 'e' } })).to.equal('a%5Bb%5D=c&a%5Bd%5D=e');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies an empty value', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: '' })).to.equal('a=');
|
||||
expect(Qs.stringify({ a: '', b: '' })).to.equal('a=&b=');
|
||||
expect(Qs.stringify({ a: null })).to.equal('a=');
|
||||
expect(Qs.stringify({ a: { b: null } })).to.equal('a%5Bb%5D=');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies an empty object', function (done) {
|
||||
|
||||
var obj = Object.create(null);
|
||||
obj.a = 'b';
|
||||
expect(Qs.stringify(obj)).to.equal('a=b');
|
||||
done();
|
||||
});
|
||||
|
||||
it('returns an empty string for invalid input', function (done) {
|
||||
|
||||
expect(Qs.stringify(undefined)).to.equal('');
|
||||
expect(Qs.stringify(false)).to.equal('');
|
||||
expect(Qs.stringify(null)).to.equal('');
|
||||
expect(Qs.stringify('')).to.equal('');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies an object with an empty object as a child', function (done) {
|
||||
|
||||
var obj = {
|
||||
a: Object.create(null)
|
||||
};
|
||||
|
||||
obj.a.b = 'c';
|
||||
expect(Qs.stringify(obj)).to.equal('a%5Bb%5D=c');
|
||||
done();
|
||||
});
|
||||
|
||||
it('drops keys with a value of undefined', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: undefined })).to.equal('');
|
||||
expect(Qs.stringify({ a: { b: undefined, c: null } })).to.equal('a%5Bc%5D=');
|
||||
done();
|
||||
});
|
||||
|
||||
it('url encodes values', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: 'b c' })).to.equal('a=b%20c');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies a date', function (done) {
|
||||
|
||||
var now = new Date();
|
||||
var str = 'a=' + encodeURIComponent(now.toISOString());
|
||||
expect(Qs.stringify({ a: now })).to.equal(str);
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies the weird object from qs', function (done) {
|
||||
|
||||
expect(Qs.stringify({ 'my weird field': 'q1!2"\'w$5&7/z8)?' })).to.equal('my%20weird%20field=q1!2%22\'w%245%267%2Fz8)%3F');
|
||||
done();
|
||||
});
|
||||
|
||||
it('skips properties that are part of the object prototype', function (done) {
|
||||
|
||||
Object.prototype.crash = 'test';
|
||||
expect(Qs.stringify({ a: 'b'})).to.equal('a=b');
|
||||
expect(Qs.stringify({ a: { b: 'c' } })).to.equal('a%5Bb%5D=c');
|
||||
delete Object.prototype.crash;
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies boolean values', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: true })).to.equal('a=true');
|
||||
expect(Qs.stringify({ a: { b: true } })).to.equal('a%5Bb%5D=true');
|
||||
expect(Qs.stringify({ b: false })).to.equal('b=false');
|
||||
expect(Qs.stringify({ b: { c: false } })).to.equal('b%5Bc%5D=false');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies buffer values', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: new Buffer('test') })).to.equal('a=test');
|
||||
expect(Qs.stringify({ a: { b: new Buffer('test') } })).to.equal('a%5Bb%5D=test');
|
||||
done();
|
||||
});
|
||||
|
||||
it('stringifies an object using an alternative delimiter', function (done) {
|
||||
|
||||
expect(Qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' })).to.equal('a=b;c=d');
|
||||
done();
|
||||
});
|
||||
|
||||
it('doesn\'t blow up when Buffer global is missing', function (done) {
|
||||
|
||||
var tempBuffer = global.Buffer;
|
||||
delete global.Buffer;
|
||||
expect(Qs.stringify({ a: 'b', c: 'd' })).to.equal('a=b&c=d');
|
||||
global.Buffer = tempBuffer;
|
||||
done();
|
||||
});
|
||||
});
|
||||
65
node_modules/react-router/package.json
generated
vendored
65
node_modules/react-router/package.json
generated
vendored
@@ -1,65 +0,0 @@
|
||||
{
|
||||
"name": "react-router",
|
||||
"version": "0.13.3",
|
||||
"description": "A complete routing library for React.js",
|
||||
"main": "lib",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rackt/react-router.git"
|
||||
},
|
||||
"homepage": "https://github.com/rackt/react-router/blob/latest/README.md",
|
||||
"bugs": {
|
||||
"url": "https://github.com/rackt/react-router/issues"
|
||||
},
|
||||
"authors": [
|
||||
"Ryan Florence",
|
||||
"Michael Jackson"
|
||||
],
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "0.13.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"object-assign": "^2.0.0",
|
||||
"qs": "2.4.1"
|
||||
},
|
||||
"tags": [
|
||||
"react",
|
||||
"router"
|
||||
],
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-component",
|
||||
"routing",
|
||||
"route",
|
||||
"routes",
|
||||
"router"
|
||||
],
|
||||
"_id": "react-router@0.13.3",
|
||||
"scripts": {},
|
||||
"_shasum": "95455dd19d2c04c7b2957ff7fccda76031ac29b1",
|
||||
"_from": "react-router@>=0.11.0 <0.14.0",
|
||||
"_resolved": "https://registry.npmjs.org/react-router/-/react-router-0.13.3.tgz",
|
||||
"_npmVersion": "2.5.1",
|
||||
"_nodeVersion": "0.12.0",
|
||||
"_npmUser": {
|
||||
"name": "ryanflorence",
|
||||
"email": "rpflorence@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "ryanflorence",
|
||||
"email": "rpflorence@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "mjackson",
|
||||
"email": "mjijackson@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "95455dd19d2c04c7b2957ff7fccda76031ac29b1",
|
||||
"tarball": "http://registry.npmjs.org/react-router/-/react-router-0.13.3.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
||||
3386
node_modules/react-router/umd/ReactRouter.js
generated
vendored
3386
node_modules/react-router/umd/ReactRouter.js
generated
vendored
File diff suppressed because it is too large
Load Diff
6
node_modules/react-router/umd/ReactRouter.min.js
generated
vendored
6
node_modules/react-router/umd/ReactRouter.min.js
generated
vendored
File diff suppressed because one or more lines are too long
20
node_modules/react/README.md
generated
vendored
20
node_modules/react/README.md
generated
vendored
@@ -1,20 +0,0 @@
|
||||
# react
|
||||
|
||||
An npm package to get you immediate access to [React](https://facebook.github.io/react/),
|
||||
without also requiring the JSX transformer. This is especially useful for cases where you
|
||||
want to [`browserify`](https://github.com/substack/node-browserify) your module using
|
||||
`React`.
|
||||
|
||||
**Note:** by default, React will be in development mode. The development version includes extra warnings about common mistakes, whereas the production version includes extra performance optimizations and strips all error messages.
|
||||
|
||||
To use React in production mode, set the environment variable `NODE_ENV` to `production`. A minifier that performs dead-code elimination such as [UglifyJS](https://github.com/mishoo/UglifyJS2) is recommended to completely remove the extra code present in development mode.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```js
|
||||
var React = require('react');
|
||||
|
||||
// You can also access ReactWithAddons.
|
||||
var React = require('react/addons');
|
||||
```
|
||||
|
||||
1
node_modules/react/addons.js
generated
vendored
1
node_modules/react/addons.js
generated
vendored
@@ -1 +0,0 @@
|
||||
module.exports = require('./lib/ReactWithAddons');
|
||||
15919
node_modules/react/dist/JSXTransformer.js
generated
vendored
15919
node_modules/react/dist/JSXTransformer.js
generated
vendored
File diff suppressed because one or more lines are too long
21642
node_modules/react/dist/react-with-addons.js
generated
vendored
21642
node_modules/react/dist/react-with-addons.js
generated
vendored
File diff suppressed because it is too large
Load Diff
18
node_modules/react/dist/react-with-addons.min.js
generated
vendored
18
node_modules/react/dist/react-with-addons.min.js
generated
vendored
File diff suppressed because one or more lines are too long
19602
node_modules/react/dist/react.js
generated
vendored
19602
node_modules/react/dist/react.js
generated
vendored
File diff suppressed because it is too large
Load Diff
16
node_modules/react/dist/react.min.js
generated
vendored
16
node_modules/react/dist/react.min.js
generated
vendored
File diff suppressed because one or more lines are too long
25
node_modules/react/lib/AutoFocusMixin.js
generated
vendored
25
node_modules/react/lib/AutoFocusMixin.js
generated
vendored
@@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule AutoFocusMixin
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var focusNode = require("./focusNode");
|
||||
|
||||
var AutoFocusMixin = {
|
||||
componentDidMount: function() {
|
||||
if (this.props.autoFocus) {
|
||||
focusNode(this.getDOMNode());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = AutoFocusMixin;
|
||||
493
node_modules/react/lib/BeforeInputEventPlugin.js
generated
vendored
493
node_modules/react/lib/BeforeInputEventPlugin.js
generated
vendored
@@ -1,493 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015 Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule BeforeInputEventPlugin
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var EventConstants = require("./EventConstants");
|
||||
var EventPropagators = require("./EventPropagators");
|
||||
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
||||
var FallbackCompositionState = require("./FallbackCompositionState");
|
||||
var SyntheticCompositionEvent = require("./SyntheticCompositionEvent");
|
||||
var SyntheticInputEvent = require("./SyntheticInputEvent");
|
||||
|
||||
var keyOf = require("./keyOf");
|
||||
|
||||
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
|
||||
var START_KEYCODE = 229;
|
||||
|
||||
var canUseCompositionEvent = (
|
||||
ExecutionEnvironment.canUseDOM &&
|
||||
'CompositionEvent' in window
|
||||
);
|
||||
|
||||
var documentMode = null;
|
||||
if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) {
|
||||
documentMode = document.documentMode;
|
||||
}
|
||||
|
||||
// Webkit offers a very useful `textInput` event that can be used to
|
||||
// directly represent `beforeInput`. The IE `textinput` event is not as
|
||||
// useful, so we don't use it.
|
||||
var canUseTextInputEvent = (
|
||||
ExecutionEnvironment.canUseDOM &&
|
||||
'TextEvent' in window &&
|
||||
!documentMode &&
|
||||
!isPresto()
|
||||
);
|
||||
|
||||
// In IE9+, we have access to composition events, but the data supplied
|
||||
// by the native compositionend event may be incorrect. Japanese ideographic
|
||||
// spaces, for instance (\u3000) are not recorded correctly.
|
||||
var useFallbackCompositionData = (
|
||||
ExecutionEnvironment.canUseDOM &&
|
||||
(
|
||||
(!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11)
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Opera <= 12 includes TextEvent in window, but does not fire
|
||||
* text input events. Rely on keypress instead.
|
||||
*/
|
||||
function isPresto() {
|
||||
var opera = window.opera;
|
||||
return (
|
||||
typeof opera === 'object' &&
|
||||
typeof opera.version === 'function' &&
|
||||
parseInt(opera.version(), 10) <= 12
|
||||
);
|
||||
}
|
||||
|
||||
var SPACEBAR_CODE = 32;
|
||||
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
|
||||
|
||||
var topLevelTypes = EventConstants.topLevelTypes;
|
||||
|
||||
// Events and their corresponding property names.
|
||||
var eventTypes = {
|
||||
beforeInput: {
|
||||
phasedRegistrationNames: {
|
||||
bubbled: keyOf({onBeforeInput: null}),
|
||||
captured: keyOf({onBeforeInputCapture: null})
|
||||
},
|
||||
dependencies: [
|
||||
topLevelTypes.topCompositionEnd,
|
||||
topLevelTypes.topKeyPress,
|
||||
topLevelTypes.topTextInput,
|
||||
topLevelTypes.topPaste
|
||||
]
|
||||
},
|
||||
compositionEnd: {
|
||||
phasedRegistrationNames: {
|
||||
bubbled: keyOf({onCompositionEnd: null}),
|
||||
captured: keyOf({onCompositionEndCapture: null})
|
||||
},
|
||||
dependencies: [
|
||||
topLevelTypes.topBlur,
|
||||
topLevelTypes.topCompositionEnd,
|
||||
topLevelTypes.topKeyDown,
|
||||
topLevelTypes.topKeyPress,
|
||||
topLevelTypes.topKeyUp,
|
||||
topLevelTypes.topMouseDown
|
||||
]
|
||||
},
|
||||
compositionStart: {
|
||||
phasedRegistrationNames: {
|
||||
bubbled: keyOf({onCompositionStart: null}),
|
||||
captured: keyOf({onCompositionStartCapture: null})
|
||||
},
|
||||
dependencies: [
|
||||
topLevelTypes.topBlur,
|
||||
topLevelTypes.topCompositionStart,
|
||||
topLevelTypes.topKeyDown,
|
||||
topLevelTypes.topKeyPress,
|
||||
topLevelTypes.topKeyUp,
|
||||
topLevelTypes.topMouseDown
|
||||
]
|
||||
},
|
||||
compositionUpdate: {
|
||||
phasedRegistrationNames: {
|
||||
bubbled: keyOf({onCompositionUpdate: null}),
|
||||
captured: keyOf({onCompositionUpdateCapture: null})
|
||||
},
|
||||
dependencies: [
|
||||
topLevelTypes.topBlur,
|
||||
topLevelTypes.topCompositionUpdate,
|
||||
topLevelTypes.topKeyDown,
|
||||
topLevelTypes.topKeyPress,
|
||||
topLevelTypes.topKeyUp,
|
||||
topLevelTypes.topMouseDown
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
// Track whether we've ever handled a keypress on the space key.
|
||||
var hasSpaceKeypress = false;
|
||||
|
||||
/**
|
||||
* Return whether a native keypress event is assumed to be a command.
|
||||
* This is required because Firefox fires `keypress` events for key commands
|
||||
* (cut, copy, select-all, etc.) even though no character is inserted.
|
||||
*/
|
||||
function isKeypressCommand(nativeEvent) {
|
||||
return (
|
||||
(nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
|
||||
// ctrlKey && altKey is equivalent to AltGr, and is not a command.
|
||||
!(nativeEvent.ctrlKey && nativeEvent.altKey)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translate native top level events into event types.
|
||||
*
|
||||
* @param {string} topLevelType
|
||||
* @return {object}
|
||||
*/
|
||||
function getCompositionEventType(topLevelType) {
|
||||
switch (topLevelType) {
|
||||
case topLevelTypes.topCompositionStart:
|
||||
return eventTypes.compositionStart;
|
||||
case topLevelTypes.topCompositionEnd:
|
||||
return eventTypes.compositionEnd;
|
||||
case topLevelTypes.topCompositionUpdate:
|
||||
return eventTypes.compositionUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does our fallback best-guess model think this event signifies that
|
||||
* composition has begun?
|
||||
*
|
||||
* @param {string} topLevelType
|
||||
* @param {object} nativeEvent
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isFallbackCompositionStart(topLevelType, nativeEvent) {
|
||||
return (
|
||||
topLevelType === topLevelTypes.topKeyDown &&
|
||||
nativeEvent.keyCode === START_KEYCODE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does our fallback mode think that this event is the end of composition?
|
||||
*
|
||||
* @param {string} topLevelType
|
||||
* @param {object} nativeEvent
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isFallbackCompositionEnd(topLevelType, nativeEvent) {
|
||||
switch (topLevelType) {
|
||||
case topLevelTypes.topKeyUp:
|
||||
// Command keys insert or clear IME input.
|
||||
return (END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1);
|
||||
case topLevelTypes.topKeyDown:
|
||||
// Expect IME keyCode on each keydown. If we get any other
|
||||
// code we must have exited earlier.
|
||||
return (nativeEvent.keyCode !== START_KEYCODE);
|
||||
case topLevelTypes.topKeyPress:
|
||||
case topLevelTypes.topMouseDown:
|
||||
case topLevelTypes.topBlur:
|
||||
// Events are not possible without cancelling IME.
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Google Input Tools provides composition data via a CustomEvent,
|
||||
* with the `data` property populated in the `detail` object. If this
|
||||
* is available on the event object, use it. If not, this is a plain
|
||||
* composition event and we have nothing special to extract.
|
||||
*
|
||||
* @param {object} nativeEvent
|
||||
* @return {?string}
|
||||
*/
|
||||
function getDataFromCustomEvent(nativeEvent) {
|
||||
var detail = nativeEvent.detail;
|
||||
if (typeof detail === 'object' && 'data' in detail) {
|
||||
return detail.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Track the current IME composition fallback object, if any.
|
||||
var currentComposition = null;
|
||||
|
||||
/**
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {?object} A SyntheticCompositionEvent.
|
||||
*/
|
||||
function extractCompositionEvent(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID,
|
||||
nativeEvent
|
||||
) {
|
||||
var eventType;
|
||||
var fallbackData;
|
||||
|
||||
if (canUseCompositionEvent) {
|
||||
eventType = getCompositionEventType(topLevelType);
|
||||
} else if (!currentComposition) {
|
||||
if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
|
||||
eventType = eventTypes.compositionStart;
|
||||
}
|
||||
} else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
|
||||
eventType = eventTypes.compositionEnd;
|
||||
}
|
||||
|
||||
if (!eventType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (useFallbackCompositionData) {
|
||||
// The current composition is stored statically and must not be
|
||||
// overwritten while composition continues.
|
||||
if (!currentComposition && eventType === eventTypes.compositionStart) {
|
||||
currentComposition = FallbackCompositionState.getPooled(topLevelTarget);
|
||||
} else if (eventType === eventTypes.compositionEnd) {
|
||||
if (currentComposition) {
|
||||
fallbackData = currentComposition.getData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var event = SyntheticCompositionEvent.getPooled(
|
||||
eventType,
|
||||
topLevelTargetID,
|
||||
nativeEvent
|
||||
);
|
||||
|
||||
if (fallbackData) {
|
||||
// Inject data generated from fallback path into the synthetic event.
|
||||
// This matches the property of native CompositionEventInterface.
|
||||
event.data = fallbackData;
|
||||
} else {
|
||||
var customData = getDataFromCustomEvent(nativeEvent);
|
||||
if (customData !== null) {
|
||||
event.data = customData;
|
||||
}
|
||||
}
|
||||
|
||||
EventPropagators.accumulateTwoPhaseDispatches(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {?string} The string corresponding to this `beforeInput` event.
|
||||
*/
|
||||
function getNativeBeforeInputChars(topLevelType, nativeEvent) {
|
||||
switch (topLevelType) {
|
||||
case topLevelTypes.topCompositionEnd:
|
||||
return getDataFromCustomEvent(nativeEvent);
|
||||
case topLevelTypes.topKeyPress:
|
||||
/**
|
||||
* If native `textInput` events are available, our goal is to make
|
||||
* use of them. However, there is a special case: the spacebar key.
|
||||
* In Webkit, preventing default on a spacebar `textInput` event
|
||||
* cancels character insertion, but it *also* causes the browser
|
||||
* to fall back to its default spacebar behavior of scrolling the
|
||||
* page.
|
||||
*
|
||||
* Tracking at:
|
||||
* https://code.google.com/p/chromium/issues/detail?id=355103
|
||||
*
|
||||
* To avoid this issue, use the keypress event as if no `textInput`
|
||||
* event is available.
|
||||
*/
|
||||
var which = nativeEvent.which;
|
||||
if (which !== SPACEBAR_CODE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
hasSpaceKeypress = true;
|
||||
return SPACEBAR_CHAR;
|
||||
|
||||
case topLevelTypes.topTextInput:
|
||||
// Record the characters to be added to the DOM.
|
||||
var chars = nativeEvent.data;
|
||||
|
||||
// If it's a spacebar character, assume that we have already handled
|
||||
// it at the keypress level and bail immediately. Android Chrome
|
||||
// doesn't give us keycodes, so we need to blacklist it.
|
||||
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return chars;
|
||||
|
||||
default:
|
||||
// For other native event types, do nothing.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For browsers that do not provide the `textInput` event, extract the
|
||||
* appropriate string to use for SyntheticInputEvent.
|
||||
*
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {?string} The fallback string for this `beforeInput` event.
|
||||
*/
|
||||
function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
|
||||
// If we are currently composing (IME) and using a fallback to do so,
|
||||
// try to extract the composed characters from the fallback object.
|
||||
if (currentComposition) {
|
||||
if (
|
||||
topLevelType === topLevelTypes.topCompositionEnd ||
|
||||
isFallbackCompositionEnd(topLevelType, nativeEvent)
|
||||
) {
|
||||
var chars = currentComposition.getData();
|
||||
FallbackCompositionState.release(currentComposition);
|
||||
currentComposition = null;
|
||||
return chars;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (topLevelType) {
|
||||
case topLevelTypes.topPaste:
|
||||
// If a paste event occurs after a keypress, throw out the input
|
||||
// chars. Paste events should not lead to BeforeInput events.
|
||||
return null;
|
||||
case topLevelTypes.topKeyPress:
|
||||
/**
|
||||
* As of v27, Firefox may fire keypress events even when no character
|
||||
* will be inserted. A few possibilities:
|
||||
*
|
||||
* - `which` is `0`. Arrow keys, Esc key, etc.
|
||||
*
|
||||
* - `which` is the pressed key code, but no char is available.
|
||||
* Ex: 'AltGr + d` in Polish. There is no modified character for
|
||||
* this key combination and no character is inserted into the
|
||||
* document, but FF fires the keypress for char code `100` anyway.
|
||||
* No `input` event will occur.
|
||||
*
|
||||
* - `which` is the pressed key code, but a command combination is
|
||||
* being used. Ex: `Cmd+C`. No character is inserted, and no
|
||||
* `input` event will occur.
|
||||
*/
|
||||
if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
|
||||
return String.fromCharCode(nativeEvent.which);
|
||||
}
|
||||
return null;
|
||||
case topLevelTypes.topCompositionEnd:
|
||||
return useFallbackCompositionData ? null : nativeEvent.data;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a SyntheticInputEvent for `beforeInput`, based on either native
|
||||
* `textInput` or fallback behavior.
|
||||
*
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {?object} A SyntheticInputEvent.
|
||||
*/
|
||||
function extractBeforeInputEvent(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID,
|
||||
nativeEvent
|
||||
) {
|
||||
var chars;
|
||||
|
||||
if (canUseTextInputEvent) {
|
||||
chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
|
||||
} else {
|
||||
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
|
||||
}
|
||||
|
||||
// If no characters are being inserted, no BeforeInput event should
|
||||
// be fired.
|
||||
if (!chars) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var event = SyntheticInputEvent.getPooled(
|
||||
eventTypes.beforeInput,
|
||||
topLevelTargetID,
|
||||
nativeEvent
|
||||
);
|
||||
|
||||
event.data = chars;
|
||||
EventPropagators.accumulateTwoPhaseDispatches(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an `onBeforeInput` event to match
|
||||
* http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
|
||||
*
|
||||
* This event plugin is based on the native `textInput` event
|
||||
* available in Chrome, Safari, Opera, and IE. This event fires after
|
||||
* `onKeyPress` and `onCompositionEnd`, but before `onInput`.
|
||||
*
|
||||
* `beforeInput` is spec'd but not implemented in any browsers, and
|
||||
* the `input` event does not provide any useful information about what has
|
||||
* actually been added, contrary to the spec. Thus, `textInput` is the best
|
||||
* available event to identify the characters that have actually been inserted
|
||||
* into the target node.
|
||||
*
|
||||
* This plugin is also responsible for emitting `composition` events, thus
|
||||
* allowing us to share composition fallback code for both `beforeInput` and
|
||||
* `composition` event types.
|
||||
*/
|
||||
var BeforeInputEventPlugin = {
|
||||
|
||||
eventTypes: eventTypes,
|
||||
|
||||
/**
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {*} An accumulation of synthetic events.
|
||||
* @see {EventPluginHub.extractEvents}
|
||||
*/
|
||||
extractEvents: function(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID,
|
||||
nativeEvent
|
||||
) {
|
||||
return [
|
||||
extractCompositionEvent(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID,
|
||||
nativeEvent
|
||||
),
|
||||
extractBeforeInputEvent(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID,
|
||||
nativeEvent
|
||||
)
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = BeforeInputEventPlugin;
|
||||
108
node_modules/react/lib/CSSCore.js
generated
vendored
108
node_modules/react/lib/CSSCore.js
generated
vendored
@@ -1,108 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule CSSCore
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
var invariant = require("./invariant");
|
||||
|
||||
/**
|
||||
* The CSSCore module specifies the API (and implements most of the methods)
|
||||
* that should be used when dealing with the display of elements (via their
|
||||
* CSS classes and visibility on screen. It is an API focused on mutating the
|
||||
* display and not reading it as no logical state should be encoded in the
|
||||
* display of elements.
|
||||
*/
|
||||
|
||||
var CSSCore = {
|
||||
|
||||
/**
|
||||
* Adds the class passed in to the element if it doesn't already have it.
|
||||
*
|
||||
* @param {DOMElement} element the element to set the class on
|
||||
* @param {string} className the CSS className
|
||||
* @return {DOMElement} the element passed in
|
||||
*/
|
||||
addClass: function(element, className) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
!/\s/.test(className),
|
||||
'CSSCore.addClass takes only a single class name. "%s" contains ' +
|
||||
'multiple classes.', className
|
||||
) : invariant(!/\s/.test(className)));
|
||||
|
||||
if (className) {
|
||||
if (element.classList) {
|
||||
element.classList.add(className);
|
||||
} else if (!CSSCore.hasClass(element, className)) {
|
||||
element.className = element.className + ' ' + className;
|
||||
}
|
||||
}
|
||||
return element;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the class passed in from the element
|
||||
*
|
||||
* @param {DOMElement} element the element to set the class on
|
||||
* @param {string} className the CSS className
|
||||
* @return {DOMElement} the element passed in
|
||||
*/
|
||||
removeClass: function(element, className) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
!/\s/.test(className),
|
||||
'CSSCore.removeClass takes only a single class name. "%s" contains ' +
|
||||
'multiple classes.', className
|
||||
) : invariant(!/\s/.test(className)));
|
||||
|
||||
if (className) {
|
||||
if (element.classList) {
|
||||
element.classList.remove(className);
|
||||
} else if (CSSCore.hasClass(element, className)) {
|
||||
element.className = element.className
|
||||
.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1')
|
||||
.replace(/\s+/g, ' ') // multiple spaces to one
|
||||
.replace(/^\s*|\s*$/g, ''); // trim the ends
|
||||
}
|
||||
}
|
||||
return element;
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper to add or remove a class from an element based on a condition.
|
||||
*
|
||||
* @param {DOMElement} element the element to set the class on
|
||||
* @param {string} className the CSS className
|
||||
* @param {*} bool condition to whether to add or remove the class
|
||||
* @return {DOMElement} the element passed in
|
||||
*/
|
||||
conditionClass: function(element, className, bool) {
|
||||
return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className);
|
||||
},
|
||||
|
||||
/**
|
||||
* Tests whether the element has the class specified.
|
||||
*
|
||||
* @param {DOMNode|DOMWindow} element the element to set the class on
|
||||
* @param {string} className the CSS className
|
||||
* @return {boolean} true if the element has the class, false if not
|
||||
*/
|
||||
hasClass: function(element, className) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
!/\s/.test(className),
|
||||
'CSS.hasClass takes only a single class name.'
|
||||
) : invariant(!/\s/.test(className)));
|
||||
if (element.classList) {
|
||||
return !!className && element.classList.contains(className);
|
||||
}
|
||||
return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = CSSCore;
|
||||
123
node_modules/react/lib/CSSProperty.js
generated
vendored
123
node_modules/react/lib/CSSProperty.js
generated
vendored
@@ -1,123 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule CSSProperty
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* CSS properties which accept numbers but are not in units of "px".
|
||||
*/
|
||||
var isUnitlessNumber = {
|
||||
boxFlex: true,
|
||||
boxFlexGroup: true,
|
||||
columnCount: true,
|
||||
flex: true,
|
||||
flexGrow: true,
|
||||
flexPositive: true,
|
||||
flexShrink: true,
|
||||
flexNegative: true,
|
||||
fontWeight: true,
|
||||
lineClamp: true,
|
||||
lineHeight: true,
|
||||
opacity: true,
|
||||
order: true,
|
||||
orphans: true,
|
||||
widows: true,
|
||||
zIndex: true,
|
||||
zoom: true,
|
||||
|
||||
// SVG-related properties
|
||||
fillOpacity: true,
|
||||
strokeDashoffset: true,
|
||||
strokeOpacity: true,
|
||||
strokeWidth: true
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
||||
* @param {string} key style name, eg: transitionDuration
|
||||
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
||||
* WebkitTransitionDuration
|
||||
*/
|
||||
function prefixKey(prefix, key) {
|
||||
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Support style names that may come passed in prefixed by adding permutations
|
||||
* of vendor prefixes.
|
||||
*/
|
||||
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
|
||||
|
||||
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
|
||||
// infinite loop, because it iterates over the newly added props too.
|
||||
Object.keys(isUnitlessNumber).forEach(function(prop) {
|
||||
prefixes.forEach(function(prefix) {
|
||||
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Most style properties can be unset by doing .style[prop] = '' but IE8
|
||||
* doesn't like doing that with shorthand properties so for the properties that
|
||||
* IE8 breaks on, which are listed here, we instead unset each of the
|
||||
* individual properties. See http://bugs.jquery.com/ticket/12385.
|
||||
* The 4-value 'clock' properties like margin, padding, border-width seem to
|
||||
* behave without any problems. Curiously, list-style works too without any
|
||||
* special prodding.
|
||||
*/
|
||||
var shorthandPropertyExpansions = {
|
||||
background: {
|
||||
backgroundImage: true,
|
||||
backgroundPosition: true,
|
||||
backgroundRepeat: true,
|
||||
backgroundColor: true
|
||||
},
|
||||
border: {
|
||||
borderWidth: true,
|
||||
borderStyle: true,
|
||||
borderColor: true
|
||||
},
|
||||
borderBottom: {
|
||||
borderBottomWidth: true,
|
||||
borderBottomStyle: true,
|
||||
borderBottomColor: true
|
||||
},
|
||||
borderLeft: {
|
||||
borderLeftWidth: true,
|
||||
borderLeftStyle: true,
|
||||
borderLeftColor: true
|
||||
},
|
||||
borderRight: {
|
||||
borderRightWidth: true,
|
||||
borderRightStyle: true,
|
||||
borderRightColor: true
|
||||
},
|
||||
borderTop: {
|
||||
borderTopWidth: true,
|
||||
borderTopStyle: true,
|
||||
borderTopColor: true
|
||||
},
|
||||
font: {
|
||||
fontStyle: true,
|
||||
fontVariant: true,
|
||||
fontWeight: true,
|
||||
fontSize: true,
|
||||
lineHeight: true,
|
||||
fontFamily: true
|
||||
}
|
||||
};
|
||||
|
||||
var CSSProperty = {
|
||||
isUnitlessNumber: isUnitlessNumber,
|
||||
shorthandPropertyExpansions: shorthandPropertyExpansions
|
||||
};
|
||||
|
||||
module.exports = CSSProperty;
|
||||
178
node_modules/react/lib/CSSPropertyOperations.js
generated
vendored
178
node_modules/react/lib/CSSPropertyOperations.js
generated
vendored
@@ -1,178 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule CSSPropertyOperations
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var CSSProperty = require("./CSSProperty");
|
||||
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
||||
|
||||
var camelizeStyleName = require("./camelizeStyleName");
|
||||
var dangerousStyleValue = require("./dangerousStyleValue");
|
||||
var hyphenateStyleName = require("./hyphenateStyleName");
|
||||
var memoizeStringOnly = require("./memoizeStringOnly");
|
||||
var warning = require("./warning");
|
||||
|
||||
var processStyleName = memoizeStringOnly(function(styleName) {
|
||||
return hyphenateStyleName(styleName);
|
||||
});
|
||||
|
||||
var styleFloatAccessor = 'cssFloat';
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
// IE8 only supports accessing cssFloat (standard) as styleFloat
|
||||
if (document.documentElement.style.cssFloat === undefined) {
|
||||
styleFloatAccessor = 'styleFloat';
|
||||
}
|
||||
}
|
||||
|
||||
if ("production" !== process.env.NODE_ENV) {
|
||||
// 'msTransform' is correct, but the other prefixes should be capitalized
|
||||
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
|
||||
|
||||
// style values shouldn't contain a semicolon
|
||||
var badStyleValueWithSemicolonPattern = /;\s*$/;
|
||||
|
||||
var warnedStyleNames = {};
|
||||
var warnedStyleValues = {};
|
||||
|
||||
var warnHyphenatedStyleName = function(name) {
|
||||
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
||||
return;
|
||||
}
|
||||
|
||||
warnedStyleNames[name] = true;
|
||||
("production" !== process.env.NODE_ENV ? warning(
|
||||
false,
|
||||
'Unsupported style property %s. Did you mean %s?',
|
||||
name,
|
||||
camelizeStyleName(name)
|
||||
) : null);
|
||||
};
|
||||
|
||||
var warnBadVendoredStyleName = function(name) {
|
||||
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
||||
return;
|
||||
}
|
||||
|
||||
warnedStyleNames[name] = true;
|
||||
("production" !== process.env.NODE_ENV ? warning(
|
||||
false,
|
||||
'Unsupported vendor-prefixed style property %s. Did you mean %s?',
|
||||
name,
|
||||
name.charAt(0).toUpperCase() + name.slice(1)
|
||||
) : null);
|
||||
};
|
||||
|
||||
var warnStyleValueWithSemicolon = function(name, value) {
|
||||
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
|
||||
return;
|
||||
}
|
||||
|
||||
warnedStyleValues[value] = true;
|
||||
("production" !== process.env.NODE_ENV ? warning(
|
||||
false,
|
||||
'Style property values shouldn\'t contain a semicolon. ' +
|
||||
'Try "%s: %s" instead.',
|
||||
name,
|
||||
value.replace(badStyleValueWithSemicolonPattern, '')
|
||||
) : null);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {*} value
|
||||
*/
|
||||
var warnValidStyle = function(name, value) {
|
||||
if (name.indexOf('-') > -1) {
|
||||
warnHyphenatedStyleName(name);
|
||||
} else if (badVendoredStyleNamePattern.test(name)) {
|
||||
warnBadVendoredStyleName(name);
|
||||
} else if (badStyleValueWithSemicolonPattern.test(value)) {
|
||||
warnStyleValueWithSemicolon(name, value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations for dealing with CSS properties.
|
||||
*/
|
||||
var CSSPropertyOperations = {
|
||||
|
||||
/**
|
||||
* Serializes a mapping of style properties for use as inline styles:
|
||||
*
|
||||
* > createMarkupForStyles({width: '200px', height: 0})
|
||||
* "width:200px;height:0;"
|
||||
*
|
||||
* Undefined values are ignored so that declarative programming is easier.
|
||||
* The result should be HTML-escaped before insertion into the DOM.
|
||||
*
|
||||
* @param {object} styles
|
||||
* @return {?string}
|
||||
*/
|
||||
createMarkupForStyles: function(styles) {
|
||||
var serialized = '';
|
||||
for (var styleName in styles) {
|
||||
if (!styles.hasOwnProperty(styleName)) {
|
||||
continue;
|
||||
}
|
||||
var styleValue = styles[styleName];
|
||||
if ("production" !== process.env.NODE_ENV) {
|
||||
warnValidStyle(styleName, styleValue);
|
||||
}
|
||||
if (styleValue != null) {
|
||||
serialized += processStyleName(styleName) + ':';
|
||||
serialized += dangerousStyleValue(styleName, styleValue) + ';';
|
||||
}
|
||||
}
|
||||
return serialized || null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the value for multiple styles on a node. If a value is specified as
|
||||
* '' (empty string), the corresponding style property will be unset.
|
||||
*
|
||||
* @param {DOMElement} node
|
||||
* @param {object} styles
|
||||
*/
|
||||
setValueForStyles: function(node, styles) {
|
||||
var style = node.style;
|
||||
for (var styleName in styles) {
|
||||
if (!styles.hasOwnProperty(styleName)) {
|
||||
continue;
|
||||
}
|
||||
if ("production" !== process.env.NODE_ENV) {
|
||||
warnValidStyle(styleName, styles[styleName]);
|
||||
}
|
||||
var styleValue = dangerousStyleValue(styleName, styles[styleName]);
|
||||
if (styleName === 'float') {
|
||||
styleName = styleFloatAccessor;
|
||||
}
|
||||
if (styleValue) {
|
||||
style[styleName] = styleValue;
|
||||
} else {
|
||||
var expansion = CSSProperty.shorthandPropertyExpansions[styleName];
|
||||
if (expansion) {
|
||||
// Shorthand property that IE8 won't like unsetting, so unset each
|
||||
// component to placate it
|
||||
for (var individualStyleName in expansion) {
|
||||
style[individualStyleName] = '';
|
||||
}
|
||||
} else {
|
||||
style[styleName] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = CSSPropertyOperations;
|
||||
96
node_modules/react/lib/CallbackQueue.js
generated
vendored
96
node_modules/react/lib/CallbackQueue.js
generated
vendored
@@ -1,96 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule CallbackQueue
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var PooledClass = require("./PooledClass");
|
||||
|
||||
var assign = require("./Object.assign");
|
||||
var invariant = require("./invariant");
|
||||
|
||||
/**
|
||||
* A specialized pseudo-event module to help keep track of components waiting to
|
||||
* be notified when their DOM representations are available for use.
|
||||
*
|
||||
* This implements `PooledClass`, so you should never need to instantiate this.
|
||||
* Instead, use `CallbackQueue.getPooled()`.
|
||||
*
|
||||
* @class ReactMountReady
|
||||
* @implements PooledClass
|
||||
* @internal
|
||||
*/
|
||||
function CallbackQueue() {
|
||||
this._callbacks = null;
|
||||
this._contexts = null;
|
||||
}
|
||||
|
||||
assign(CallbackQueue.prototype, {
|
||||
|
||||
/**
|
||||
* Enqueues a callback to be invoked when `notifyAll` is invoked.
|
||||
*
|
||||
* @param {function} callback Invoked when `notifyAll` is invoked.
|
||||
* @param {?object} context Context to call `callback` with.
|
||||
* @internal
|
||||
*/
|
||||
enqueue: function(callback, context) {
|
||||
this._callbacks = this._callbacks || [];
|
||||
this._contexts = this._contexts || [];
|
||||
this._callbacks.push(callback);
|
||||
this._contexts.push(context);
|
||||
},
|
||||
|
||||
/**
|
||||
* Invokes all enqueued callbacks and clears the queue. This is invoked after
|
||||
* the DOM representation of a component has been created or updated.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
notifyAll: function() {
|
||||
var callbacks = this._callbacks;
|
||||
var contexts = this._contexts;
|
||||
if (callbacks) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
callbacks.length === contexts.length,
|
||||
'Mismatched list of contexts in callback queue'
|
||||
) : invariant(callbacks.length === contexts.length));
|
||||
this._callbacks = null;
|
||||
this._contexts = null;
|
||||
for (var i = 0, l = callbacks.length; i < l; i++) {
|
||||
callbacks[i].call(contexts[i]);
|
||||
}
|
||||
callbacks.length = 0;
|
||||
contexts.length = 0;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the internal queue.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
reset: function() {
|
||||
this._callbacks = null;
|
||||
this._contexts = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* `PooledClass` looks for this.
|
||||
*/
|
||||
destructor: function() {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
PooledClass.addPoolingTo(CallbackQueue);
|
||||
|
||||
module.exports = CallbackQueue;
|
||||
380
node_modules/react/lib/ChangeEventPlugin.js
generated
vendored
380
node_modules/react/lib/ChangeEventPlugin.js
generated
vendored
@@ -1,380 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule ChangeEventPlugin
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var EventConstants = require("./EventConstants");
|
||||
var EventPluginHub = require("./EventPluginHub");
|
||||
var EventPropagators = require("./EventPropagators");
|
||||
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
||||
var ReactUpdates = require("./ReactUpdates");
|
||||
var SyntheticEvent = require("./SyntheticEvent");
|
||||
|
||||
var isEventSupported = require("./isEventSupported");
|
||||
var isTextInputElement = require("./isTextInputElement");
|
||||
var keyOf = require("./keyOf");
|
||||
|
||||
var topLevelTypes = EventConstants.topLevelTypes;
|
||||
|
||||
var eventTypes = {
|
||||
change: {
|
||||
phasedRegistrationNames: {
|
||||
bubbled: keyOf({onChange: null}),
|
||||
captured: keyOf({onChangeCapture: null})
|
||||
},
|
||||
dependencies: [
|
||||
topLevelTypes.topBlur,
|
||||
topLevelTypes.topChange,
|
||||
topLevelTypes.topClick,
|
||||
topLevelTypes.topFocus,
|
||||
topLevelTypes.topInput,
|
||||
topLevelTypes.topKeyDown,
|
||||
topLevelTypes.topKeyUp,
|
||||
topLevelTypes.topSelectionChange
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* For IE shims
|
||||
*/
|
||||
var activeElement = null;
|
||||
var activeElementID = null;
|
||||
var activeElementValue = null;
|
||||
var activeElementValueProp = null;
|
||||
|
||||
/**
|
||||
* SECTION: handle `change` event
|
||||
*/
|
||||
function shouldUseChangeEvent(elem) {
|
||||
return (
|
||||
elem.nodeName === 'SELECT' ||
|
||||
(elem.nodeName === 'INPUT' && elem.type === 'file')
|
||||
);
|
||||
}
|
||||
|
||||
var doesChangeEventBubble = false;
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
// See `handleChange` comment below
|
||||
doesChangeEventBubble = isEventSupported('change') && (
|
||||
(!('documentMode' in document) || document.documentMode > 8)
|
||||
);
|
||||
}
|
||||
|
||||
function manualDispatchChangeEvent(nativeEvent) {
|
||||
var event = SyntheticEvent.getPooled(
|
||||
eventTypes.change,
|
||||
activeElementID,
|
||||
nativeEvent
|
||||
);
|
||||
EventPropagators.accumulateTwoPhaseDispatches(event);
|
||||
|
||||
// If change and propertychange bubbled, we'd just bind to it like all the
|
||||
// other events and have it go through ReactBrowserEventEmitter. Since it
|
||||
// doesn't, we manually listen for the events and so we have to enqueue and
|
||||
// process the abstract event manually.
|
||||
//
|
||||
// Batching is necessary here in order to ensure that all event handlers run
|
||||
// before the next rerender (including event handlers attached to ancestor
|
||||
// elements instead of directly on the input). Without this, controlled
|
||||
// components don't work properly in conjunction with event bubbling because
|
||||
// the component is rerendered and the value reverted before all the event
|
||||
// handlers can run. See https://github.com/facebook/react/issues/708.
|
||||
ReactUpdates.batchedUpdates(runEventInBatch, event);
|
||||
}
|
||||
|
||||
function runEventInBatch(event) {
|
||||
EventPluginHub.enqueueEvents(event);
|
||||
EventPluginHub.processEventQueue();
|
||||
}
|
||||
|
||||
function startWatchingForChangeEventIE8(target, targetID) {
|
||||
activeElement = target;
|
||||
activeElementID = targetID;
|
||||
activeElement.attachEvent('onchange', manualDispatchChangeEvent);
|
||||
}
|
||||
|
||||
function stopWatchingForChangeEventIE8() {
|
||||
if (!activeElement) {
|
||||
return;
|
||||
}
|
||||
activeElement.detachEvent('onchange', manualDispatchChangeEvent);
|
||||
activeElement = null;
|
||||
activeElementID = null;
|
||||
}
|
||||
|
||||
function getTargetIDForChangeEvent(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topChange) {
|
||||
return topLevelTargetID;
|
||||
}
|
||||
}
|
||||
function handleEventsForChangeEventIE8(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topFocus) {
|
||||
// stopWatching() should be a noop here but we call it just in case we
|
||||
// missed a blur event somehow.
|
||||
stopWatchingForChangeEventIE8();
|
||||
startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID);
|
||||
} else if (topLevelType === topLevelTypes.topBlur) {
|
||||
stopWatchingForChangeEventIE8();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SECTION: handle `input` event
|
||||
*/
|
||||
var isInputEventSupported = false;
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
// IE9 claims to support the input event but fails to trigger it when
|
||||
// deleting text, so we ignore its input events
|
||||
isInputEventSupported = isEventSupported('input') && (
|
||||
(!('documentMode' in document) || document.documentMode > 9)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* (For old IE.) Replacement getter/setter for the `value` property that gets
|
||||
* set on the active element.
|
||||
*/
|
||||
var newValueProp = {
|
||||
get: function() {
|
||||
return activeElementValueProp.get.call(this);
|
||||
},
|
||||
set: function(val) {
|
||||
// Cast to a string so we can do equality checks.
|
||||
activeElementValue = '' + val;
|
||||
activeElementValueProp.set.call(this, val);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* (For old IE.) Starts tracking propertychange events on the passed-in element
|
||||
* and override the value property so that we can distinguish user events from
|
||||
* value changes in JS.
|
||||
*/
|
||||
function startWatchingForValueChange(target, targetID) {
|
||||
activeElement = target;
|
||||
activeElementID = targetID;
|
||||
activeElementValue = target.value;
|
||||
activeElementValueProp = Object.getOwnPropertyDescriptor(
|
||||
target.constructor.prototype,
|
||||
'value'
|
||||
);
|
||||
|
||||
Object.defineProperty(activeElement, 'value', newValueProp);
|
||||
activeElement.attachEvent('onpropertychange', handlePropertyChange);
|
||||
}
|
||||
|
||||
/**
|
||||
* (For old IE.) Removes the event listeners from the currently-tracked element,
|
||||
* if any exists.
|
||||
*/
|
||||
function stopWatchingForValueChange() {
|
||||
if (!activeElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// delete restores the original property definition
|
||||
delete activeElement.value;
|
||||
activeElement.detachEvent('onpropertychange', handlePropertyChange);
|
||||
|
||||
activeElement = null;
|
||||
activeElementID = null;
|
||||
activeElementValue = null;
|
||||
activeElementValueProp = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* (For old IE.) Handles a propertychange event, sending a `change` event if
|
||||
* the value of the active element has changed.
|
||||
*/
|
||||
function handlePropertyChange(nativeEvent) {
|
||||
if (nativeEvent.propertyName !== 'value') {
|
||||
return;
|
||||
}
|
||||
var value = nativeEvent.srcElement.value;
|
||||
if (value === activeElementValue) {
|
||||
return;
|
||||
}
|
||||
activeElementValue = value;
|
||||
|
||||
manualDispatchChangeEvent(nativeEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* If a `change` event should be fired, returns the target's ID.
|
||||
*/
|
||||
function getTargetIDForInputEvent(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topInput) {
|
||||
// In modern browsers (i.e., not IE8 or IE9), the input event is exactly
|
||||
// what we want so fall through here and trigger an abstract event
|
||||
return topLevelTargetID;
|
||||
}
|
||||
}
|
||||
|
||||
// For IE8 and IE9.
|
||||
function handleEventsForInputEventIE(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topFocus) {
|
||||
// In IE8, we can capture almost all .value changes by adding a
|
||||
// propertychange handler and looking for events with propertyName
|
||||
// equal to 'value'
|
||||
// In IE9, propertychange fires for most input events but is buggy and
|
||||
// doesn't fire when text is deleted, but conveniently, selectionchange
|
||||
// appears to fire in all of the remaining cases so we catch those and
|
||||
// forward the event if the value has changed
|
||||
// In either case, we don't want to call the event handler if the value
|
||||
// is changed from JS so we redefine a setter for `.value` that updates
|
||||
// our activeElementValue variable, allowing us to ignore those changes
|
||||
//
|
||||
// stopWatching() should be a noop here but we call it just in case we
|
||||
// missed a blur event somehow.
|
||||
stopWatchingForValueChange();
|
||||
startWatchingForValueChange(topLevelTarget, topLevelTargetID);
|
||||
} else if (topLevelType === topLevelTypes.topBlur) {
|
||||
stopWatchingForValueChange();
|
||||
}
|
||||
}
|
||||
|
||||
// For IE8 and IE9.
|
||||
function getTargetIDForInputEventIE(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topSelectionChange ||
|
||||
topLevelType === topLevelTypes.topKeyUp ||
|
||||
topLevelType === topLevelTypes.topKeyDown) {
|
||||
// On the selectionchange event, the target is just document which isn't
|
||||
// helpful for us so just check activeElement instead.
|
||||
//
|
||||
// 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
|
||||
// propertychange on the first input event after setting `value` from a
|
||||
// script and fires only keydown, keypress, keyup. Catching keyup usually
|
||||
// gets it and catching keydown lets us fire an event for the first
|
||||
// keystroke if user does a key repeat (it'll be a little delayed: right
|
||||
// before the second keystroke). Other input methods (e.g., paste) seem to
|
||||
// fire selectionchange normally.
|
||||
if (activeElement && activeElement.value !== activeElementValue) {
|
||||
activeElementValue = activeElement.value;
|
||||
return activeElementID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SECTION: handle `click` event
|
||||
*/
|
||||
function shouldUseClickEvent(elem) {
|
||||
// Use the `click` event to detect changes to checkbox and radio inputs.
|
||||
// This approach works across all browsers, whereas `change` does not fire
|
||||
// until `blur` in IE8.
|
||||
return (
|
||||
elem.nodeName === 'INPUT' &&
|
||||
(elem.type === 'checkbox' || elem.type === 'radio')
|
||||
);
|
||||
}
|
||||
|
||||
function getTargetIDForClickEvent(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topClick) {
|
||||
return topLevelTargetID;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This plugin creates an `onChange` event that normalizes change events
|
||||
* across form elements. This event fires at a time when it's possible to
|
||||
* change the element's value without seeing a flicker.
|
||||
*
|
||||
* Supported elements are:
|
||||
* - input (see `isTextInputElement`)
|
||||
* - textarea
|
||||
* - select
|
||||
*/
|
||||
var ChangeEventPlugin = {
|
||||
|
||||
eventTypes: eventTypes,
|
||||
|
||||
/**
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {*} An accumulation of synthetic events.
|
||||
* @see {EventPluginHub.extractEvents}
|
||||
*/
|
||||
extractEvents: function(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID,
|
||||
nativeEvent) {
|
||||
|
||||
var getTargetIDFunc, handleEventFunc;
|
||||
if (shouldUseChangeEvent(topLevelTarget)) {
|
||||
if (doesChangeEventBubble) {
|
||||
getTargetIDFunc = getTargetIDForChangeEvent;
|
||||
} else {
|
||||
handleEventFunc = handleEventsForChangeEventIE8;
|
||||
}
|
||||
} else if (isTextInputElement(topLevelTarget)) {
|
||||
if (isInputEventSupported) {
|
||||
getTargetIDFunc = getTargetIDForInputEvent;
|
||||
} else {
|
||||
getTargetIDFunc = getTargetIDForInputEventIE;
|
||||
handleEventFunc = handleEventsForInputEventIE;
|
||||
}
|
||||
} else if (shouldUseClickEvent(topLevelTarget)) {
|
||||
getTargetIDFunc = getTargetIDForClickEvent;
|
||||
}
|
||||
|
||||
if (getTargetIDFunc) {
|
||||
var targetID = getTargetIDFunc(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID
|
||||
);
|
||||
if (targetID) {
|
||||
var event = SyntheticEvent.getPooled(
|
||||
eventTypes.change,
|
||||
targetID,
|
||||
nativeEvent
|
||||
);
|
||||
EventPropagators.accumulateTwoPhaseDispatches(event);
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
||||
if (handleEventFunc) {
|
||||
handleEventFunc(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = ChangeEventPlugin;
|
||||
23
node_modules/react/lib/ClientReactRootIndex.js
generated
vendored
23
node_modules/react/lib/ClientReactRootIndex.js
generated
vendored
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule ClientReactRootIndex
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var nextReactRootIndex = 0;
|
||||
|
||||
var ClientReactRootIndex = {
|
||||
createReactRootIndex: function() {
|
||||
return nextReactRootIndex++;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = ClientReactRootIndex;
|
||||
134
node_modules/react/lib/DOMChildrenOperations.js
generated
vendored
134
node_modules/react/lib/DOMChildrenOperations.js
generated
vendored
@@ -1,134 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule DOMChildrenOperations
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var Danger = require("./Danger");
|
||||
var ReactMultiChildUpdateTypes = require("./ReactMultiChildUpdateTypes");
|
||||
|
||||
var setTextContent = require("./setTextContent");
|
||||
var invariant = require("./invariant");
|
||||
|
||||
/**
|
||||
* Inserts `childNode` as a child of `parentNode` at the `index`.
|
||||
*
|
||||
* @param {DOMElement} parentNode Parent node in which to insert.
|
||||
* @param {DOMElement} childNode Child node to insert.
|
||||
* @param {number} index Index at which to insert the child.
|
||||
* @internal
|
||||
*/
|
||||
function insertChildAt(parentNode, childNode, index) {
|
||||
// By exploiting arrays returning `undefined` for an undefined index, we can
|
||||
// rely exclusively on `insertBefore(node, null)` instead of also using
|
||||
// `appendChild(node)`. However, using `undefined` is not allowed by all
|
||||
// browsers so we must replace it with `null`.
|
||||
parentNode.insertBefore(
|
||||
childNode,
|
||||
parentNode.childNodes[index] || null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations for updating with DOM children.
|
||||
*/
|
||||
var DOMChildrenOperations = {
|
||||
|
||||
dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
|
||||
|
||||
updateTextContent: setTextContent,
|
||||
|
||||
/**
|
||||
* Updates a component's children by processing a series of updates. The
|
||||
* update configurations are each expected to have a `parentNode` property.
|
||||
*
|
||||
* @param {array<object>} updates List of update configurations.
|
||||
* @param {array<string>} markupList List of markup strings.
|
||||
* @internal
|
||||
*/
|
||||
processUpdates: function(updates, markupList) {
|
||||
var update;
|
||||
// Mapping from parent IDs to initial child orderings.
|
||||
var initialChildren = null;
|
||||
// List of children that will be moved or removed.
|
||||
var updatedChildren = null;
|
||||
|
||||
for (var i = 0; i < updates.length; i++) {
|
||||
update = updates[i];
|
||||
if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING ||
|
||||
update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
|
||||
var updatedIndex = update.fromIndex;
|
||||
var updatedChild = update.parentNode.childNodes[updatedIndex];
|
||||
var parentID = update.parentID;
|
||||
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
updatedChild,
|
||||
'processUpdates(): Unable to find child %s of element. This ' +
|
||||
'probably means the DOM was unexpectedly mutated (e.g., by the ' +
|
||||
'browser), usually due to forgetting a <tbody> when using tables, ' +
|
||||
'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' +
|
||||
'in an <svg> parent. Try inspecting the child nodes of the element ' +
|
||||
'with React ID `%s`.',
|
||||
updatedIndex,
|
||||
parentID
|
||||
) : invariant(updatedChild));
|
||||
|
||||
initialChildren = initialChildren || {};
|
||||
initialChildren[parentID] = initialChildren[parentID] || [];
|
||||
initialChildren[parentID][updatedIndex] = updatedChild;
|
||||
|
||||
updatedChildren = updatedChildren || [];
|
||||
updatedChildren.push(updatedChild);
|
||||
}
|
||||
}
|
||||
|
||||
var renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
|
||||
|
||||
// Remove updated children first so that `toIndex` is consistent.
|
||||
if (updatedChildren) {
|
||||
for (var j = 0; j < updatedChildren.length; j++) {
|
||||
updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
|
||||
}
|
||||
}
|
||||
|
||||
for (var k = 0; k < updates.length; k++) {
|
||||
update = updates[k];
|
||||
switch (update.type) {
|
||||
case ReactMultiChildUpdateTypes.INSERT_MARKUP:
|
||||
insertChildAt(
|
||||
update.parentNode,
|
||||
renderedMarkup[update.markupIndex],
|
||||
update.toIndex
|
||||
);
|
||||
break;
|
||||
case ReactMultiChildUpdateTypes.MOVE_EXISTING:
|
||||
insertChildAt(
|
||||
update.parentNode,
|
||||
initialChildren[update.parentID][update.fromIndex],
|
||||
update.toIndex
|
||||
);
|
||||
break;
|
||||
case ReactMultiChildUpdateTypes.TEXT_CONTENT:
|
||||
setTextContent(
|
||||
update.parentNode,
|
||||
update.textContent
|
||||
);
|
||||
break;
|
||||
case ReactMultiChildUpdateTypes.REMOVE_NODE:
|
||||
// Already removed by the for-loop above.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = DOMChildrenOperations;
|
||||
295
node_modules/react/lib/DOMProperty.js
generated
vendored
295
node_modules/react/lib/DOMProperty.js
generated
vendored
@@ -1,295 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule DOMProperty
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
/*jslint bitwise: true */
|
||||
|
||||
'use strict';
|
||||
|
||||
var invariant = require("./invariant");
|
||||
|
||||
function checkMask(value, bitmask) {
|
||||
return (value & bitmask) === bitmask;
|
||||
}
|
||||
|
||||
var DOMPropertyInjection = {
|
||||
/**
|
||||
* Mapping from normalized, camelcased property names to a configuration that
|
||||
* specifies how the associated DOM property should be accessed or rendered.
|
||||
*/
|
||||
MUST_USE_ATTRIBUTE: 0x1,
|
||||
MUST_USE_PROPERTY: 0x2,
|
||||
HAS_SIDE_EFFECTS: 0x4,
|
||||
HAS_BOOLEAN_VALUE: 0x8,
|
||||
HAS_NUMERIC_VALUE: 0x10,
|
||||
HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10,
|
||||
HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
|
||||
|
||||
/**
|
||||
* Inject some specialized knowledge about the DOM. This takes a config object
|
||||
* with the following properties:
|
||||
*
|
||||
* isCustomAttribute: function that given an attribute name will return true
|
||||
* if it can be inserted into the DOM verbatim. Useful for data-* or aria-*
|
||||
* attributes where it's impossible to enumerate all of the possible
|
||||
* attribute names,
|
||||
*
|
||||
* Properties: object mapping DOM property name to one of the
|
||||
* DOMPropertyInjection constants or null. If your attribute isn't in here,
|
||||
* it won't get written to the DOM.
|
||||
*
|
||||
* DOMAttributeNames: object mapping React attribute name to the DOM
|
||||
* attribute name. Attribute names not specified use the **lowercase**
|
||||
* normalized name.
|
||||
*
|
||||
* DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
|
||||
* Property names not specified use the normalized name.
|
||||
*
|
||||
* DOMMutationMethods: Properties that require special mutation methods. If
|
||||
* `value` is undefined, the mutation method should unset the property.
|
||||
*
|
||||
* @param {object} domPropertyConfig the config as described above.
|
||||
*/
|
||||
injectDOMPropertyConfig: function(domPropertyConfig) {
|
||||
var Properties = domPropertyConfig.Properties || {};
|
||||
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
|
||||
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
|
||||
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
|
||||
|
||||
if (domPropertyConfig.isCustomAttribute) {
|
||||
DOMProperty._isCustomAttributeFunctions.push(
|
||||
domPropertyConfig.isCustomAttribute
|
||||
);
|
||||
}
|
||||
|
||||
for (var propName in Properties) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
!DOMProperty.isStandardName.hasOwnProperty(propName),
|
||||
'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
|
||||
'\'%s\' which has already been injected. You may be accidentally ' +
|
||||
'injecting the same DOM property config twice, or you may be ' +
|
||||
'injecting two configs that have conflicting property names.',
|
||||
propName
|
||||
) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName)));
|
||||
|
||||
DOMProperty.isStandardName[propName] = true;
|
||||
|
||||
var lowerCased = propName.toLowerCase();
|
||||
DOMProperty.getPossibleStandardName[lowerCased] = propName;
|
||||
|
||||
if (DOMAttributeNames.hasOwnProperty(propName)) {
|
||||
var attributeName = DOMAttributeNames[propName];
|
||||
DOMProperty.getPossibleStandardName[attributeName] = propName;
|
||||
DOMProperty.getAttributeName[propName] = attributeName;
|
||||
} else {
|
||||
DOMProperty.getAttributeName[propName] = lowerCased;
|
||||
}
|
||||
|
||||
DOMProperty.getPropertyName[propName] =
|
||||
DOMPropertyNames.hasOwnProperty(propName) ?
|
||||
DOMPropertyNames[propName] :
|
||||
propName;
|
||||
|
||||
if (DOMMutationMethods.hasOwnProperty(propName)) {
|
||||
DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName];
|
||||
} else {
|
||||
DOMProperty.getMutationMethod[propName] = null;
|
||||
}
|
||||
|
||||
var propConfig = Properties[propName];
|
||||
DOMProperty.mustUseAttribute[propName] =
|
||||
checkMask(propConfig, DOMPropertyInjection.MUST_USE_ATTRIBUTE);
|
||||
DOMProperty.mustUseProperty[propName] =
|
||||
checkMask(propConfig, DOMPropertyInjection.MUST_USE_PROPERTY);
|
||||
DOMProperty.hasSideEffects[propName] =
|
||||
checkMask(propConfig, DOMPropertyInjection.HAS_SIDE_EFFECTS);
|
||||
DOMProperty.hasBooleanValue[propName] =
|
||||
checkMask(propConfig, DOMPropertyInjection.HAS_BOOLEAN_VALUE);
|
||||
DOMProperty.hasNumericValue[propName] =
|
||||
checkMask(propConfig, DOMPropertyInjection.HAS_NUMERIC_VALUE);
|
||||
DOMProperty.hasPositiveNumericValue[propName] =
|
||||
checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
|
||||
DOMProperty.hasOverloadedBooleanValue[propName] =
|
||||
checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
|
||||
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
!DOMProperty.mustUseAttribute[propName] ||
|
||||
!DOMProperty.mustUseProperty[propName],
|
||||
'DOMProperty: Cannot require using both attribute and property: %s',
|
||||
propName
|
||||
) : invariant(!DOMProperty.mustUseAttribute[propName] ||
|
||||
!DOMProperty.mustUseProperty[propName]));
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
DOMProperty.mustUseProperty[propName] ||
|
||||
!DOMProperty.hasSideEffects[propName],
|
||||
'DOMProperty: Properties that have side effects must use property: %s',
|
||||
propName
|
||||
) : invariant(DOMProperty.mustUseProperty[propName] ||
|
||||
!DOMProperty.hasSideEffects[propName]));
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
!!DOMProperty.hasBooleanValue[propName] +
|
||||
!!DOMProperty.hasNumericValue[propName] +
|
||||
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1,
|
||||
'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
|
||||
'numeric value, but not a combination: %s',
|
||||
propName
|
||||
) : invariant(!!DOMProperty.hasBooleanValue[propName] +
|
||||
!!DOMProperty.hasNumericValue[propName] +
|
||||
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1));
|
||||
}
|
||||
}
|
||||
};
|
||||
var defaultValueCache = {};
|
||||
|
||||
/**
|
||||
* DOMProperty exports lookup objects that can be used like functions:
|
||||
*
|
||||
* > DOMProperty.isValid['id']
|
||||
* true
|
||||
* > DOMProperty.isValid['foobar']
|
||||
* undefined
|
||||
*
|
||||
* Although this may be confusing, it performs better in general.
|
||||
*
|
||||
* @see http://jsperf.com/key-exists
|
||||
* @see http://jsperf.com/key-missing
|
||||
*/
|
||||
var DOMProperty = {
|
||||
|
||||
ID_ATTRIBUTE_NAME: 'data-reactid',
|
||||
|
||||
/**
|
||||
* Checks whether a property name is a standard property.
|
||||
* @type {Object}
|
||||
*/
|
||||
isStandardName: {},
|
||||
|
||||
/**
|
||||
* Mapping from lowercase property names to the properly cased version, used
|
||||
* to warn in the case of missing properties.
|
||||
* @type {Object}
|
||||
*/
|
||||
getPossibleStandardName: {},
|
||||
|
||||
/**
|
||||
* Mapping from normalized names to attribute names that differ. Attribute
|
||||
* names are used when rendering markup or with `*Attribute()`.
|
||||
* @type {Object}
|
||||
*/
|
||||
getAttributeName: {},
|
||||
|
||||
/**
|
||||
* Mapping from normalized names to properties on DOM node instances.
|
||||
* (This includes properties that mutate due to external factors.)
|
||||
* @type {Object}
|
||||
*/
|
||||
getPropertyName: {},
|
||||
|
||||
/**
|
||||
* Mapping from normalized names to mutation methods. This will only exist if
|
||||
* mutation cannot be set simply by the property or `setAttribute()`.
|
||||
* @type {Object}
|
||||
*/
|
||||
getMutationMethod: {},
|
||||
|
||||
/**
|
||||
* Whether the property must be accessed and mutated as an object property.
|
||||
* @type {Object}
|
||||
*/
|
||||
mustUseAttribute: {},
|
||||
|
||||
/**
|
||||
* Whether the property must be accessed and mutated using `*Attribute()`.
|
||||
* (This includes anything that fails `<propName> in <element>`.)
|
||||
* @type {Object}
|
||||
*/
|
||||
mustUseProperty: {},
|
||||
|
||||
/**
|
||||
* Whether or not setting a value causes side effects such as triggering
|
||||
* resources to be loaded or text selection changes. We must ensure that
|
||||
* the value is only set if it has changed.
|
||||
* @type {Object}
|
||||
*/
|
||||
hasSideEffects: {},
|
||||
|
||||
/**
|
||||
* Whether the property should be removed when set to a falsey value.
|
||||
* @type {Object}
|
||||
*/
|
||||
hasBooleanValue: {},
|
||||
|
||||
/**
|
||||
* Whether the property must be numeric or parse as a
|
||||
* numeric and should be removed when set to a falsey value.
|
||||
* @type {Object}
|
||||
*/
|
||||
hasNumericValue: {},
|
||||
|
||||
/**
|
||||
* Whether the property must be positive numeric or parse as a positive
|
||||
* numeric and should be removed when set to a falsey value.
|
||||
* @type {Object}
|
||||
*/
|
||||
hasPositiveNumericValue: {},
|
||||
|
||||
/**
|
||||
* Whether the property can be used as a flag as well as with a value. Removed
|
||||
* when strictly equal to false; present without a value when strictly equal
|
||||
* to true; present with a value otherwise.
|
||||
* @type {Object}
|
||||
*/
|
||||
hasOverloadedBooleanValue: {},
|
||||
|
||||
/**
|
||||
* All of the isCustomAttribute() functions that have been injected.
|
||||
*/
|
||||
_isCustomAttributeFunctions: [],
|
||||
|
||||
/**
|
||||
* Checks whether a property name is a custom attribute.
|
||||
* @method
|
||||
*/
|
||||
isCustomAttribute: function(attributeName) {
|
||||
for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
|
||||
var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
|
||||
if (isCustomAttributeFn(attributeName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the default property value for a DOM property (i.e., not an
|
||||
* attribute). Most default values are '' or false, but not all. Worse yet,
|
||||
* some (in particular, `type`) vary depending on the type of element.
|
||||
*
|
||||
* TODO: Is it better to grab all the possible properties when creating an
|
||||
* element to avoid having to create the same element twice?
|
||||
*/
|
||||
getDefaultValueForProperty: function(nodeName, prop) {
|
||||
var nodeDefaults = defaultValueCache[nodeName];
|
||||
var testElement;
|
||||
if (!nodeDefaults) {
|
||||
defaultValueCache[nodeName] = nodeDefaults = {};
|
||||
}
|
||||
if (!(prop in nodeDefaults)) {
|
||||
testElement = document.createElement(nodeName);
|
||||
nodeDefaults[prop] = testElement[prop];
|
||||
}
|
||||
return nodeDefaults[prop];
|
||||
},
|
||||
|
||||
injection: DOMPropertyInjection
|
||||
};
|
||||
|
||||
module.exports = DOMProperty;
|
||||
188
node_modules/react/lib/DOMPropertyOperations.js
generated
vendored
188
node_modules/react/lib/DOMPropertyOperations.js
generated
vendored
@@ -1,188 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule DOMPropertyOperations
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var DOMProperty = require("./DOMProperty");
|
||||
|
||||
var quoteAttributeValueForBrowser = require("./quoteAttributeValueForBrowser");
|
||||
var warning = require("./warning");
|
||||
|
||||
function shouldIgnoreValue(name, value) {
|
||||
return value == null ||
|
||||
(DOMProperty.hasBooleanValue[name] && !value) ||
|
||||
(DOMProperty.hasNumericValue[name] && isNaN(value)) ||
|
||||
(DOMProperty.hasPositiveNumericValue[name] && (value < 1)) ||
|
||||
(DOMProperty.hasOverloadedBooleanValue[name] && value === false);
|
||||
}
|
||||
|
||||
if ("production" !== process.env.NODE_ENV) {
|
||||
var reactProps = {
|
||||
children: true,
|
||||
dangerouslySetInnerHTML: true,
|
||||
key: true,
|
||||
ref: true
|
||||
};
|
||||
var warnedProperties = {};
|
||||
|
||||
var warnUnknownProperty = function(name) {
|
||||
if (reactProps.hasOwnProperty(name) && reactProps[name] ||
|
||||
warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
||||
return;
|
||||
}
|
||||
|
||||
warnedProperties[name] = true;
|
||||
var lowerCasedName = name.toLowerCase();
|
||||
|
||||
// data-* attributes should be lowercase; suggest the lowercase version
|
||||
var standardName = (
|
||||
DOMProperty.isCustomAttribute(lowerCasedName) ?
|
||||
lowerCasedName :
|
||||
DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ?
|
||||
DOMProperty.getPossibleStandardName[lowerCasedName] :
|
||||
null
|
||||
);
|
||||
|
||||
// For now, only warn when we have a suggested correction. This prevents
|
||||
// logging too much when using transferPropsTo.
|
||||
("production" !== process.env.NODE_ENV ? warning(
|
||||
standardName == null,
|
||||
'Unknown DOM property %s. Did you mean %s?',
|
||||
name,
|
||||
standardName
|
||||
) : null);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations for dealing with DOM properties.
|
||||
*/
|
||||
var DOMPropertyOperations = {
|
||||
|
||||
/**
|
||||
* Creates markup for the ID property.
|
||||
*
|
||||
* @param {string} id Unescaped ID.
|
||||
* @return {string} Markup string.
|
||||
*/
|
||||
createMarkupForID: function(id) {
|
||||
return DOMProperty.ID_ATTRIBUTE_NAME + '=' +
|
||||
quoteAttributeValueForBrowser(id);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates markup for a property.
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {*} value
|
||||
* @return {?string} Markup string, or null if the property was invalid.
|
||||
*/
|
||||
createMarkupForProperty: function(name, value) {
|
||||
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
||||
DOMProperty.isStandardName[name]) {
|
||||
if (shouldIgnoreValue(name, value)) {
|
||||
return '';
|
||||
}
|
||||
var attributeName = DOMProperty.getAttributeName[name];
|
||||
if (DOMProperty.hasBooleanValue[name] ||
|
||||
(DOMProperty.hasOverloadedBooleanValue[name] && value === true)) {
|
||||
return attributeName;
|
||||
}
|
||||
return attributeName + '=' + quoteAttributeValueForBrowser(value);
|
||||
} else if (DOMProperty.isCustomAttribute(name)) {
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
return name + '=' + quoteAttributeValueForBrowser(value);
|
||||
} else if ("production" !== process.env.NODE_ENV) {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the value for a property on a node.
|
||||
*
|
||||
* @param {DOMElement} node
|
||||
* @param {string} name
|
||||
* @param {*} value
|
||||
*/
|
||||
setValueForProperty: function(node, name, value) {
|
||||
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
||||
DOMProperty.isStandardName[name]) {
|
||||
var mutationMethod = DOMProperty.getMutationMethod[name];
|
||||
if (mutationMethod) {
|
||||
mutationMethod(node, value);
|
||||
} else if (shouldIgnoreValue(name, value)) {
|
||||
this.deleteValueForProperty(node, name);
|
||||
} else if (DOMProperty.mustUseAttribute[name]) {
|
||||
// `setAttribute` with objects becomes only `[object]` in IE8/9,
|
||||
// ('' + value) makes it output the correct toString()-value.
|
||||
node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
|
||||
} else {
|
||||
var propName = DOMProperty.getPropertyName[name];
|
||||
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
|
||||
// property type before comparing; only `value` does and is string.
|
||||
if (!DOMProperty.hasSideEffects[name] ||
|
||||
('' + node[propName]) !== ('' + value)) {
|
||||
// Contrary to `setAttribute`, object properties are properly
|
||||
// `toString`ed by IE8/9.
|
||||
node[propName] = value;
|
||||
}
|
||||
}
|
||||
} else if (DOMProperty.isCustomAttribute(name)) {
|
||||
if (value == null) {
|
||||
node.removeAttribute(name);
|
||||
} else {
|
||||
node.setAttribute(name, '' + value);
|
||||
}
|
||||
} else if ("production" !== process.env.NODE_ENV) {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes the value for a property on a node.
|
||||
*
|
||||
* @param {DOMElement} node
|
||||
* @param {string} name
|
||||
*/
|
||||
deleteValueForProperty: function(node, name) {
|
||||
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
||||
DOMProperty.isStandardName[name]) {
|
||||
var mutationMethod = DOMProperty.getMutationMethod[name];
|
||||
if (mutationMethod) {
|
||||
mutationMethod(node, undefined);
|
||||
} else if (DOMProperty.mustUseAttribute[name]) {
|
||||
node.removeAttribute(DOMProperty.getAttributeName[name]);
|
||||
} else {
|
||||
var propName = DOMProperty.getPropertyName[name];
|
||||
var defaultValue = DOMProperty.getDefaultValueForProperty(
|
||||
node.nodeName,
|
||||
propName
|
||||
);
|
||||
if (!DOMProperty.hasSideEffects[name] ||
|
||||
('' + node[propName]) !== defaultValue) {
|
||||
node[propName] = defaultValue;
|
||||
}
|
||||
}
|
||||
} else if (DOMProperty.isCustomAttribute(name)) {
|
||||
node.removeAttribute(name);
|
||||
} else if ("production" !== process.env.NODE_ENV) {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = DOMPropertyOperations;
|
||||
183
node_modules/react/lib/Danger.js
generated
vendored
183
node_modules/react/lib/Danger.js
generated
vendored
@@ -1,183 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule Danger
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
/*jslint evil: true, sub: true */
|
||||
|
||||
'use strict';
|
||||
|
||||
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
||||
|
||||
var createNodesFromMarkup = require("./createNodesFromMarkup");
|
||||
var emptyFunction = require("./emptyFunction");
|
||||
var getMarkupWrap = require("./getMarkupWrap");
|
||||
var invariant = require("./invariant");
|
||||
|
||||
var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
|
||||
var RESULT_INDEX_ATTR = 'data-danger-index';
|
||||
|
||||
/**
|
||||
* Extracts the `nodeName` from a string of markup.
|
||||
*
|
||||
* NOTE: Extracting the `nodeName` does not require a regular expression match
|
||||
* because we make assumptions about React-generated markup (i.e. there are no
|
||||
* spaces surrounding the opening tag and there is at least one attribute).
|
||||
*
|
||||
* @param {string} markup String of markup.
|
||||
* @return {string} Node name of the supplied markup.
|
||||
* @see http://jsperf.com/extract-nodename
|
||||
*/
|
||||
function getNodeName(markup) {
|
||||
return markup.substring(1, markup.indexOf(' '));
|
||||
}
|
||||
|
||||
var Danger = {
|
||||
|
||||
/**
|
||||
* Renders markup into an array of nodes. The markup is expected to render
|
||||
* into a list of root nodes. Also, the length of `resultList` and
|
||||
* `markupList` should be the same.
|
||||
*
|
||||
* @param {array<string>} markupList List of markup strings to render.
|
||||
* @return {array<DOMElement>} List of rendered nodes.
|
||||
* @internal
|
||||
*/
|
||||
dangerouslyRenderMarkup: function(markupList) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
ExecutionEnvironment.canUseDOM,
|
||||
'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
|
||||
'thread. Make sure `window` and `document` are available globally ' +
|
||||
'before requiring React when unit testing or use ' +
|
||||
'React.renderToString for server rendering.'
|
||||
) : invariant(ExecutionEnvironment.canUseDOM));
|
||||
var nodeName;
|
||||
var markupByNodeName = {};
|
||||
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
|
||||
for (var i = 0; i < markupList.length; i++) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
markupList[i],
|
||||
'dangerouslyRenderMarkup(...): Missing markup.'
|
||||
) : invariant(markupList[i]));
|
||||
nodeName = getNodeName(markupList[i]);
|
||||
nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
|
||||
markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
|
||||
markupByNodeName[nodeName][i] = markupList[i];
|
||||
}
|
||||
var resultList = [];
|
||||
var resultListAssignmentCount = 0;
|
||||
for (nodeName in markupByNodeName) {
|
||||
if (!markupByNodeName.hasOwnProperty(nodeName)) {
|
||||
continue;
|
||||
}
|
||||
var markupListByNodeName = markupByNodeName[nodeName];
|
||||
|
||||
// This for-in loop skips the holes of the sparse array. The order of
|
||||
// iteration should follow the order of assignment, which happens to match
|
||||
// numerical index order, but we don't rely on that.
|
||||
var resultIndex;
|
||||
for (resultIndex in markupListByNodeName) {
|
||||
if (markupListByNodeName.hasOwnProperty(resultIndex)) {
|
||||
var markup = markupListByNodeName[resultIndex];
|
||||
|
||||
// Push the requested markup with an additional RESULT_INDEX_ATTR
|
||||
// attribute. If the markup does not start with a < character, it
|
||||
// will be discarded below (with an appropriate console.error).
|
||||
markupListByNodeName[resultIndex] = markup.replace(
|
||||
OPEN_TAG_NAME_EXP,
|
||||
// This index will be parsed back out below.
|
||||
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Render each group of markup with similar wrapping `nodeName`.
|
||||
var renderNodes = createNodesFromMarkup(
|
||||
markupListByNodeName.join(''),
|
||||
emptyFunction // Do nothing special with <script> tags.
|
||||
);
|
||||
|
||||
for (var j = 0; j < renderNodes.length; ++j) {
|
||||
var renderNode = renderNodes[j];
|
||||
if (renderNode.hasAttribute &&
|
||||
renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
|
||||
|
||||
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
|
||||
renderNode.removeAttribute(RESULT_INDEX_ATTR);
|
||||
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
!resultList.hasOwnProperty(resultIndex),
|
||||
'Danger: Assigning to an already-occupied result index.'
|
||||
) : invariant(!resultList.hasOwnProperty(resultIndex)));
|
||||
|
||||
resultList[resultIndex] = renderNode;
|
||||
|
||||
// This should match resultList.length and markupList.length when
|
||||
// we're done.
|
||||
resultListAssignmentCount += 1;
|
||||
|
||||
} else if ("production" !== process.env.NODE_ENV) {
|
||||
console.error(
|
||||
'Danger: Discarding unexpected node:',
|
||||
renderNode
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Although resultList was populated out of order, it should now be a dense
|
||||
// array.
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
resultListAssignmentCount === resultList.length,
|
||||
'Danger: Did not assign to every index of resultList.'
|
||||
) : invariant(resultListAssignmentCount === resultList.length));
|
||||
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
resultList.length === markupList.length,
|
||||
'Danger: Expected markup to render %s nodes, but rendered %s.',
|
||||
markupList.length,
|
||||
resultList.length
|
||||
) : invariant(resultList.length === markupList.length));
|
||||
|
||||
return resultList;
|
||||
},
|
||||
|
||||
/**
|
||||
* Replaces a node with a string of markup at its current position within its
|
||||
* parent. The markup must render into a single root node.
|
||||
*
|
||||
* @param {DOMElement} oldChild Child node to replace.
|
||||
* @param {string} markup Markup to render in place of the child node.
|
||||
* @internal
|
||||
*/
|
||||
dangerouslyReplaceNodeWithMarkup: function(oldChild, markup) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
ExecutionEnvironment.canUseDOM,
|
||||
'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' +
|
||||
'worker thread. Make sure `window` and `document` are available ' +
|
||||
'globally before requiring React when unit testing or use ' +
|
||||
'React.renderToString for server rendering.'
|
||||
) : invariant(ExecutionEnvironment.canUseDOM));
|
||||
("production" !== process.env.NODE_ENV ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
oldChild.tagName.toLowerCase() !== 'html',
|
||||
'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' +
|
||||
'<html> node. This is because browser quirks make this unreliable ' +
|
||||
'and/or slow. If you want to render to the root you must use ' +
|
||||
'server rendering. See React.renderToString().'
|
||||
) : invariant(oldChild.tagName.toLowerCase() !== 'html'));
|
||||
|
||||
var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
||||
oldChild.parentNode.replaceChild(newChild, oldChild);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = Danger;
|
||||
37
node_modules/react/lib/DefaultEventPluginOrder.js
generated
vendored
37
node_modules/react/lib/DefaultEventPluginOrder.js
generated
vendored
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule DefaultEventPluginOrder
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var keyOf = require("./keyOf");
|
||||
|
||||
/**
|
||||
* Module that is injectable into `EventPluginHub`, that specifies a
|
||||
* deterministic ordering of `EventPlugin`s. A convenient way to reason about
|
||||
* plugins, without having to package every one of them. This is better than
|
||||
* having plugins be ordered in the same order that they are injected because
|
||||
* that ordering would be influenced by the packaging order.
|
||||
* `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
|
||||
* preventing default on events is convenient in `SimpleEventPlugin` handlers.
|
||||
*/
|
||||
var DefaultEventPluginOrder = [
|
||||
keyOf({ResponderEventPlugin: null}),
|
||||
keyOf({SimpleEventPlugin: null}),
|
||||
keyOf({TapEventPlugin: null}),
|
||||
keyOf({EnterLeaveEventPlugin: null}),
|
||||
keyOf({ChangeEventPlugin: null}),
|
||||
keyOf({SelectEventPlugin: null}),
|
||||
keyOf({BeforeInputEventPlugin: null}),
|
||||
keyOf({AnalyticsEventPlugin: null}),
|
||||
keyOf({MobileSafariClickEventPlugin: null})
|
||||
];
|
||||
|
||||
module.exports = DefaultEventPluginOrder;
|
||||
138
node_modules/react/lib/EnterLeaveEventPlugin.js
generated
vendored
138
node_modules/react/lib/EnterLeaveEventPlugin.js
generated
vendored
@@ -1,138 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule EnterLeaveEventPlugin
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var EventConstants = require("./EventConstants");
|
||||
var EventPropagators = require("./EventPropagators");
|
||||
var SyntheticMouseEvent = require("./SyntheticMouseEvent");
|
||||
|
||||
var ReactMount = require("./ReactMount");
|
||||
var keyOf = require("./keyOf");
|
||||
|
||||
var topLevelTypes = EventConstants.topLevelTypes;
|
||||
var getFirstReactDOM = ReactMount.getFirstReactDOM;
|
||||
|
||||
var eventTypes = {
|
||||
mouseEnter: {
|
||||
registrationName: keyOf({onMouseEnter: null}),
|
||||
dependencies: [
|
||||
topLevelTypes.topMouseOut,
|
||||
topLevelTypes.topMouseOver
|
||||
]
|
||||
},
|
||||
mouseLeave: {
|
||||
registrationName: keyOf({onMouseLeave: null}),
|
||||
dependencies: [
|
||||
topLevelTypes.topMouseOut,
|
||||
topLevelTypes.topMouseOver
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
var extractedEvents = [null, null];
|
||||
|
||||
var EnterLeaveEventPlugin = {
|
||||
|
||||
eventTypes: eventTypes,
|
||||
|
||||
/**
|
||||
* For almost every interaction we care about, there will be both a top-level
|
||||
* `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
|
||||
* we do not extract duplicate events. However, moving the mouse into the
|
||||
* browser from outside will not fire a `mouseout` event. In this case, we use
|
||||
* the `mouseover` top-level event.
|
||||
*
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {*} An accumulation of synthetic events.
|
||||
* @see {EventPluginHub.extractEvents}
|
||||
*/
|
||||
extractEvents: function(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID,
|
||||
nativeEvent) {
|
||||
if (topLevelType === topLevelTypes.topMouseOver &&
|
||||
(nativeEvent.relatedTarget || nativeEvent.fromElement)) {
|
||||
return null;
|
||||
}
|
||||
if (topLevelType !== topLevelTypes.topMouseOut &&
|
||||
topLevelType !== topLevelTypes.topMouseOver) {
|
||||
// Must not be a mouse in or mouse out - ignoring.
|
||||
return null;
|
||||
}
|
||||
|
||||
var win;
|
||||
if (topLevelTarget.window === topLevelTarget) {
|
||||
// `topLevelTarget` is probably a window object.
|
||||
win = topLevelTarget;
|
||||
} else {
|
||||
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
|
||||
var doc = topLevelTarget.ownerDocument;
|
||||
if (doc) {
|
||||
win = doc.defaultView || doc.parentWindow;
|
||||
} else {
|
||||
win = window;
|
||||
}
|
||||
}
|
||||
|
||||
var from, to;
|
||||
if (topLevelType === topLevelTypes.topMouseOut) {
|
||||
from = topLevelTarget;
|
||||
to =
|
||||
getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
|
||||
win;
|
||||
} else {
|
||||
from = win;
|
||||
to = topLevelTarget;
|
||||
}
|
||||
|
||||
if (from === to) {
|
||||
// Nothing pertains to our managed components.
|
||||
return null;
|
||||
}
|
||||
|
||||
var fromID = from ? ReactMount.getID(from) : '';
|
||||
var toID = to ? ReactMount.getID(to) : '';
|
||||
|
||||
var leave = SyntheticMouseEvent.getPooled(
|
||||
eventTypes.mouseLeave,
|
||||
fromID,
|
||||
nativeEvent
|
||||
);
|
||||
leave.type = 'mouseleave';
|
||||
leave.target = from;
|
||||
leave.relatedTarget = to;
|
||||
|
||||
var enter = SyntheticMouseEvent.getPooled(
|
||||
eventTypes.mouseEnter,
|
||||
toID,
|
||||
nativeEvent
|
||||
);
|
||||
enter.type = 'mouseenter';
|
||||
enter.target = to;
|
||||
enter.relatedTarget = from;
|
||||
|
||||
EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
|
||||
|
||||
extractedEvents[0] = leave;
|
||||
extractedEvents[1] = enter;
|
||||
|
||||
return extractedEvents;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = EnterLeaveEventPlugin;
|
||||
70
node_modules/react/lib/EventConstants.js
generated
vendored
70
node_modules/react/lib/EventConstants.js
generated
vendored
@@ -1,70 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule EventConstants
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var keyMirror = require("./keyMirror");
|
||||
|
||||
var PropagationPhases = keyMirror({bubbled: null, captured: null});
|
||||
|
||||
/**
|
||||
* Types of raw signals from the browser caught at the top level.
|
||||
*/
|
||||
var topLevelTypes = keyMirror({
|
||||
topBlur: null,
|
||||
topChange: null,
|
||||
topClick: null,
|
||||
topCompositionEnd: null,
|
||||
topCompositionStart: null,
|
||||
topCompositionUpdate: null,
|
||||
topContextMenu: null,
|
||||
topCopy: null,
|
||||
topCut: null,
|
||||
topDoubleClick: null,
|
||||
topDrag: null,
|
||||
topDragEnd: null,
|
||||
topDragEnter: null,
|
||||
topDragExit: null,
|
||||
topDragLeave: null,
|
||||
topDragOver: null,
|
||||
topDragStart: null,
|
||||
topDrop: null,
|
||||
topError: null,
|
||||
topFocus: null,
|
||||
topInput: null,
|
||||
topKeyDown: null,
|
||||
topKeyPress: null,
|
||||
topKeyUp: null,
|
||||
topLoad: null,
|
||||
topMouseDown: null,
|
||||
topMouseMove: null,
|
||||
topMouseOut: null,
|
||||
topMouseOver: null,
|
||||
topMouseUp: null,
|
||||
topPaste: null,
|
||||
topReset: null,
|
||||
topScroll: null,
|
||||
topSelectionChange: null,
|
||||
topSubmit: null,
|
||||
topTextInput: null,
|
||||
topTouchCancel: null,
|
||||
topTouchEnd: null,
|
||||
topTouchMove: null,
|
||||
topTouchStart: null,
|
||||
topWheel: null
|
||||
});
|
||||
|
||||
var EventConstants = {
|
||||
topLevelTypes: topLevelTypes,
|
||||
PropagationPhases: PropagationPhases
|
||||
};
|
||||
|
||||
module.exports = EventConstants;
|
||||
86
node_modules/react/lib/EventListener.js
generated
vendored
86
node_modules/react/lib/EventListener.js
generated
vendored
@@ -1,86 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @providesModule EventListener
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
var emptyFunction = require("./emptyFunction");
|
||||
|
||||
/**
|
||||
* Upstream version of event listener. Does not take into account specific
|
||||
* nature of platform.
|
||||
*/
|
||||
var EventListener = {
|
||||
/**
|
||||
* Listen to DOM events during the bubble phase.
|
||||
*
|
||||
* @param {DOMEventTarget} target DOM element to register listener on.
|
||||
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
|
||||
* @param {function} callback Callback function.
|
||||
* @return {object} Object with a `remove` method.
|
||||
*/
|
||||
listen: function(target, eventType, callback) {
|
||||
if (target.addEventListener) {
|
||||
target.addEventListener(eventType, callback, false);
|
||||
return {
|
||||
remove: function() {
|
||||
target.removeEventListener(eventType, callback, false);
|
||||
}
|
||||
};
|
||||
} else if (target.attachEvent) {
|
||||
target.attachEvent('on' + eventType, callback);
|
||||
return {
|
||||
remove: function() {
|
||||
target.detachEvent('on' + eventType, callback);
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Listen to DOM events during the capture phase.
|
||||
*
|
||||
* @param {DOMEventTarget} target DOM element to register listener on.
|
||||
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
|
||||
* @param {function} callback Callback function.
|
||||
* @return {object} Object with a `remove` method.
|
||||
*/
|
||||
capture: function(target, eventType, callback) {
|
||||
if (!target.addEventListener) {
|
||||
if ("production" !== process.env.NODE_ENV) {
|
||||
console.error(
|
||||
'Attempted to listen to events during the capture phase on a ' +
|
||||
'browser that does not support the capture phase. Your application ' +
|
||||
'will not receive some events.'
|
||||
);
|
||||
}
|
||||
return {
|
||||
remove: emptyFunction
|
||||
};
|
||||
} else {
|
||||
target.addEventListener(eventType, callback, true);
|
||||
return {
|
||||
remove: function() {
|
||||
target.removeEventListener(eventType, callback, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
registerDefault: function() {}
|
||||
};
|
||||
|
||||
module.exports = EventListener;
|
||||
274
node_modules/react/lib/EventPluginHub.js
generated
vendored
274
node_modules/react/lib/EventPluginHub.js
generated
vendored
@@ -1,274 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule EventPluginHub
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var EventPluginRegistry = require("./EventPluginRegistry");
|
||||
var EventPluginUtils = require("./EventPluginUtils");
|
||||
|
||||
var accumulateInto = require("./accumulateInto");
|
||||
var forEachAccumulated = require("./forEachAccumulated");
|
||||
var invariant = require("./invariant");
|
||||
|
||||
/**
|
||||
* Internal store for event listeners
|
||||
*/
|
||||
var listenerBank = {};
|
||||
|
||||
/**
|
||||
* Internal queue of events that have accumulated their dispatches and are
|
||||
* waiting to have their dispatches executed.
|
||||
*/
|
||||
var eventQueue = null;
|
||||
|
||||
/**
|
||||
* Dispatches an event and releases it back into the pool, unless persistent.
|
||||
*
|
||||
* @param {?object} event Synthetic event to be dispatched.
|
||||
* @private
|
||||
*/
|
||||
var executeDispatchesAndRelease = function(event) {
|
||||
if (event) {
|
||||
var executeDispatch = EventPluginUtils.executeDispatch;
|
||||
// Plugins can provide custom behavior when dispatching events.
|
||||
var PluginModule = EventPluginRegistry.getPluginModuleForEvent(event);
|
||||
if (PluginModule && PluginModule.executeDispatch) {
|
||||
executeDispatch = PluginModule.executeDispatch;
|
||||
}
|
||||
EventPluginUtils.executeDispatchesInOrder(event, executeDispatch);
|
||||
|
||||
if (!event.isPersistent()) {
|
||||
event.constructor.release(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
|
||||
* hierarchy given ids of the logical DOM elements involved.
|
||||
*/
|
||||
var InstanceHandle = null;
|
||||
|
||||
function validateInstanceHandle() {
|
||||
var valid =
|
||||
InstanceHandle &&
|
||||
InstanceHandle.traverseTwoPhase &&
|
||||
InstanceHandle.traverseEnterLeave;
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
valid,
|
||||
'InstanceHandle not injected before use!'
|
||||
) : invariant(valid));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a unified interface for event plugins to be installed and configured.
|
||||
*
|
||||
* Event plugins can implement the following properties:
|
||||
*
|
||||
* `extractEvents` {function(string, DOMEventTarget, string, object): *}
|
||||
* Required. When a top-level event is fired, this method is expected to
|
||||
* extract synthetic events that will in turn be queued and dispatched.
|
||||
*
|
||||
* `eventTypes` {object}
|
||||
* Optional, plugins that fire events must publish a mapping of registration
|
||||
* names that are used to register listeners. Values of this mapping must
|
||||
* be objects that contain `registrationName` or `phasedRegistrationNames`.
|
||||
*
|
||||
* `executeDispatch` {function(object, function, string)}
|
||||
* Optional, allows plugins to override how an event gets dispatched. By
|
||||
* default, the listener is simply invoked.
|
||||
*
|
||||
* Each plugin that is injected into `EventsPluginHub` is immediately operable.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
var EventPluginHub = {
|
||||
|
||||
/**
|
||||
* Methods for injecting dependencies.
|
||||
*/
|
||||
injection: {
|
||||
|
||||
/**
|
||||
* @param {object} InjectedMount
|
||||
* @public
|
||||
*/
|
||||
injectMount: EventPluginUtils.injection.injectMount,
|
||||
|
||||
/**
|
||||
* @param {object} InjectedInstanceHandle
|
||||
* @public
|
||||
*/
|
||||
injectInstanceHandle: function(InjectedInstanceHandle) {
|
||||
InstanceHandle = InjectedInstanceHandle;
|
||||
if ("production" !== process.env.NODE_ENV) {
|
||||
validateInstanceHandle();
|
||||
}
|
||||
},
|
||||
|
||||
getInstanceHandle: function() {
|
||||
if ("production" !== process.env.NODE_ENV) {
|
||||
validateInstanceHandle();
|
||||
}
|
||||
return InstanceHandle;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {array} InjectedEventPluginOrder
|
||||
* @public
|
||||
*/
|
||||
injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
|
||||
|
||||
/**
|
||||
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
|
||||
*/
|
||||
injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName
|
||||
|
||||
},
|
||||
|
||||
eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
|
||||
|
||||
registrationNameModules: EventPluginRegistry.registrationNameModules,
|
||||
|
||||
/**
|
||||
* Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
|
||||
*
|
||||
* @param {string} id ID of the DOM element.
|
||||
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
||||
* @param {?function} listener The callback to store.
|
||||
*/
|
||||
putListener: function(id, registrationName, listener) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
!listener || typeof listener === 'function',
|
||||
'Expected %s listener to be a function, instead got type %s',
|
||||
registrationName, typeof listener
|
||||
) : invariant(!listener || typeof listener === 'function'));
|
||||
|
||||
var bankForRegistrationName =
|
||||
listenerBank[registrationName] || (listenerBank[registrationName] = {});
|
||||
bankForRegistrationName[id] = listener;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} id ID of the DOM element.
|
||||
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
||||
* @return {?function} The stored callback.
|
||||
*/
|
||||
getListener: function(id, registrationName) {
|
||||
var bankForRegistrationName = listenerBank[registrationName];
|
||||
return bankForRegistrationName && bankForRegistrationName[id];
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a listener from the registration bank.
|
||||
*
|
||||
* @param {string} id ID of the DOM element.
|
||||
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
||||
*/
|
||||
deleteListener: function(id, registrationName) {
|
||||
var bankForRegistrationName = listenerBank[registrationName];
|
||||
if (bankForRegistrationName) {
|
||||
delete bankForRegistrationName[id];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes all listeners for the DOM element with the supplied ID.
|
||||
*
|
||||
* @param {string} id ID of the DOM element.
|
||||
*/
|
||||
deleteAllListeners: function(id) {
|
||||
for (var registrationName in listenerBank) {
|
||||
delete listenerBank[registrationName][id];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Allows registered plugins an opportunity to extract events from top-level
|
||||
* native browser events.
|
||||
*
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {*} An accumulation of synthetic events.
|
||||
* @internal
|
||||
*/
|
||||
extractEvents: function(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID,
|
||||
nativeEvent) {
|
||||
var events;
|
||||
var plugins = EventPluginRegistry.plugins;
|
||||
for (var i = 0, l = plugins.length; i < l; i++) {
|
||||
// Not every plugin in the ordering may be loaded at runtime.
|
||||
var possiblePlugin = plugins[i];
|
||||
if (possiblePlugin) {
|
||||
var extractedEvents = possiblePlugin.extractEvents(
|
||||
topLevelType,
|
||||
topLevelTarget,
|
||||
topLevelTargetID,
|
||||
nativeEvent
|
||||
);
|
||||
if (extractedEvents) {
|
||||
events = accumulateInto(events, extractedEvents);
|
||||
}
|
||||
}
|
||||
}
|
||||
return events;
|
||||
},
|
||||
|
||||
/**
|
||||
* Enqueues a synthetic event that should be dispatched when
|
||||
* `processEventQueue` is invoked.
|
||||
*
|
||||
* @param {*} events An accumulation of synthetic events.
|
||||
* @internal
|
||||
*/
|
||||
enqueueEvents: function(events) {
|
||||
if (events) {
|
||||
eventQueue = accumulateInto(eventQueue, events);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Dispatches all synthetic events on the event queue.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
processEventQueue: function() {
|
||||
// Set `eventQueue` to null before processing it so that we can tell if more
|
||||
// events get enqueued while processing.
|
||||
var processingEventQueue = eventQueue;
|
||||
eventQueue = null;
|
||||
forEachAccumulated(processingEventQueue, executeDispatchesAndRelease);
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
!eventQueue,
|
||||
'processEventQueue(): Additional events were enqueued while processing ' +
|
||||
'an event queue. Support for this has not yet been implemented.'
|
||||
) : invariant(!eventQueue));
|
||||
},
|
||||
|
||||
/**
|
||||
* These are needed for tests only. Do not use!
|
||||
*/
|
||||
__purge: function() {
|
||||
listenerBank = {};
|
||||
},
|
||||
|
||||
__getListenerBank: function() {
|
||||
return listenerBank;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = EventPluginHub;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user