diff --git a/.eslintignore b/.eslintignore index 0fe833c..3346406 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,5 @@ -coverage/ -docs/ +!.eslintrc.js +!.prettierrc.js +!.storybook/ dist/ +docs/ diff --git a/.eslintrc.js b/.eslintrc.js index 584d91b..c37c9bb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,34 +6,41 @@ module.exports = { node: true }, extends: [ - 'eslint:recommended', - 'plugin:jsx-a11y/recommended', + 'plugin:react/recommended', + 'plugin:@typescript-eslint/recommended', + 'prettier/@typescript-eslint', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:jsx-a11y/recommended' ], parserOptions: { - ecmaVersion: 2019, + ecmaVersion: 2020, sourceType: 'module' }, - plugins: [ - 'jsx-a11y', - 'react', - 'react-hooks' - ], + parser: '@typescript-eslint/parser', + plugins: ['jsx-a11y', 'react', 'react-hooks', '@typescript-eslint'], rules: { - 'indent': ['error', 2, { 'SwitchCase': 1 }], 'jsx-quotes': ['error', 'prefer-double'], 'jsx-a11y/no-onchange': 0, 'no-trailing-spaces': 'error', 'object-curly-spacing': ['error', 'always'], - 'quotes': ['error', 'single', { 'allowTemplateLiterals': true }], - 'react-hooks/exhaustive-deps': 'warn', + quotes: ['error', 'single', { allowTemplateLiterals: true }], + 'react-hooks/exhaustive-deps': 'error', 'react-hooks/rules-of-hooks': 'error', - 'semi': ['error', 'never'] + 'react/prop-types': 0, + semi: ['error', 'never'] }, settings: { react: { - version: '16' + version: 'detect' + } + }, + overrides: [ + { + files: ['*.js', '*.jsx'], + rules: { + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-var-requires': 'off' + } } - } + ] } diff --git a/.gitignore b/.gitignore index 9232a41..2a1479d 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,4 @@ typings/ dist/ *.tmp +.DS_Store diff --git a/.storybook/addons.js b/.storybook/addons.js new file mode 100644 index 0000000..c0a9be5 --- /dev/null +++ b/.storybook/addons.js @@ -0,0 +1 @@ +import '@storybook/addon-a11y/register' diff --git a/.storybook/base.css b/.storybook/base.css new file mode 100644 index 0000000..5089e7e --- /dev/null +++ b/.storybook/base.css @@ -0,0 +1,37 @@ +html { + font-size: 16px; + box-sizing: border-box; + -ms-text-size-adjust: 100%; + -webkit-text-size-adjust: 100%; +} +html, +body { + min-height: 100%; +} +*, +*:before, +*:after { + box-sizing: inherit; +} +body { + margin: 2em; + font-size: 1rem; + font-family: monospace; + color: #333; +} +body, +input, +button { + -webkit-font-smoothing: antialiased; +} +.textarea { + width: 100%; + outline: 0; + margin: 1rem 0; + padding: 0.5rem 1rem; + border: none; + background-color: #FFF; + border-left: 4px solid #005C9A; + resize: none; + font: inherit; +} diff --git a/.storybook/config.js b/.storybook/config.js new file mode 100644 index 0000000..2edefd2 --- /dev/null +++ b/.storybook/config.js @@ -0,0 +1,7 @@ +import { configure } from '@storybook/react' + +function loadStories() { + require('../stories.js') +} + +configure(loadStories, module) diff --git a/.travis.yml b/.travis.yml index 2458726..b28b465 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,11 @@ language: node_js node_js: - - "12" + - "13" +before_install: + - curl -o- -L https://yarnpkg.com/install.sh | bash + - export PATH="$HOME/.yarn/bin:$PATH" cache: yarn +script: + - yarn ci after_success: - - npm run coverage + - yarn run coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index c65df77..70d1ab0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [2.2.0] - 2020-03-14 + +### Added +* typescript support + +### Changed +* license from ISC to BSD-3 + +### Fixed +* issue where `line-height` is `normal` and calculation breaks by falling back + to `fontSize * 1.2` +* upgrades to fix vulnerabilities + ## [2.1.2] - 2020-02-04 ### Added diff --git a/LICENSE b/LICENSE index 7e027d1..d646aa4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,30 @@ -ISC License (ISC) +Copyright (c) 2020, Robert Pearce -Copyright 2019 Robert Pearce +All rights reserved. -Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * 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. + + * Neither the name of Robert Pearce nor the names of other + contributors may 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 +OWNER OR 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. diff --git a/README.md b/README.md index fc54b07..c6be404 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # react-expanding-textarea [![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-) -[![npm version](https://img.shields.io/npm/v/react-expanding-textarea.svg)](https://www.npmjs.com/package/react-expanding-textarea) [![npm downloads](https://img.shields.io/npm/dm/react-expanding-textarea.svg)](https://www.npmjs.com/package/react-expanding-textarea) [![Build Status](https://travis-ci.org/rpearce/react-expanding-textarea.svg?branch=master)](https://travis-ci.org/rpearce/react-expanding-textarea) [![Coverage Status](https://coveralls.io/repos/github/rpearce/react-expanding-textarea/badge.svg?branch=master)](https://coveralls.io/github/rpearce/react-expanding-textarea?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/f1395be9796a63b3d9a2/maintainability)](https://codeclimate.com/github/rpearce/react-expanding-textarea/maintainability) +[![npm version](https://img.shields.io/npm/v/react-expanding-textarea.svg)](https://www.npmjs.com/package/react-expanding-textarea) [![npm downloads](https://img.shields.io/npm/dm/react-expanding-textarea.svg)](https://www.npmjs.com/package/react-expanding-textarea) [![bundlephobia size](https://badgen.net/bundlephobia/minzip/react-expanding-textarea)](bundlephobia.com/result?p=react-expanding-textarea) [![Build Status](https://travis-ci.org/rpearce/react-expanding-textarea.svg?branch=master)](https://travis-ci.org/rpearce/react-expanding-textarea) [![Coverage Status](https://coveralls.io/repos/github/rpearce/react-expanding-textarea/badge.svg?branch=master)](https://coveralls.io/github/rpearce/react-expanding-textarea?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/f1395be9796a63b3d9a2/maintainability)](https://codeclimate.com/github/rpearce/react-expanding-textarea/maintainability) React textarea component to automatically expand and contract your textareas. diff --git a/__tests__/__snapshots__/index.tsx.snap b/__tests__/__snapshots__/index.tsx.snap new file mode 100644 index 0000000..2b60a0f --- /dev/null +++ b/__tests__/__snapshots__/index.tsx.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`continues to work if no onChange and no onInput 1`] = ` + + + +`; diff --git a/__tests__/index.js b/__tests__/index.tsx similarity index 61% rename from __tests__/index.js rename to __tests__/index.tsx index a416a86..4c936c8 100644 --- a/__tests__/index.js +++ b/__tests__/index.tsx @@ -1,11 +1,10 @@ -import React, { createRef } from 'react' +import React, { CSSProperties, createRef } from 'react' import { fireEvent, render } from '@testing-library/react' import '@testing-library/jest-dom/extend-expect' - import ExpandingTextarea, { getHeight, resize } from '../source' test('renders with a minimum number of rows', () => { - const wrapStyles = { + const wrapStyles: React.CSSProperties = { boxSizing: 'border-box', maxWidth: '500px' } @@ -48,47 +47,64 @@ test('calls onChange & onInput when text changes', () => { expect(onInput).toBeCalled() }) +test('continues to work if no onChange and no onInput', () => { + const onChange = jest.fn() + const onInput = jest.fn() + const { asFragment, getByText } = render( + + ) + + fireEvent.input(getByText('Some text'), { + target: { value: 'Some text is here' } + }) + + expect(asFragment()).toMatchSnapshot() +}) + test('getHeight: returns scroll height when no rows', () => { - global.window.getComputedStyle = jest.fn().mockImplementation(() => ({ + window.getComputedStyle = jest.fn().mockImplementation(() => ({ borderBottomWidth: '4px', borderTopWidth: '4px', lineHeight: '27.2px', paddingBottom: '10px', paddingTop: '10px' })) - const el = { scrollHeight: 129 } + const el = document.createElement('textarea') + jest.spyOn(el, 'scrollHeight', 'get').mockImplementation(() => 129) - expect(getHeight(undefined, el)).toEqual(137) + expect(getHeight(0, el)).toEqual(137) }) test('getHeight: returns scroll height when larger than row height', () => { - global.window.getComputedStyle = jest.fn().mockImplementation(() => ({ + window.getComputedStyle = jest.fn().mockImplementation(() => ({ borderBottomWidth: '4px', borderTopWidth: '4px', lineHeight: '27.2px', paddingBottom: '10px', paddingTop: '10px' })) - const el = { scrollHeight: 129 } + const el = document.createElement('textarea') + jest.spyOn(el, 'scrollHeight', 'get').mockImplementation(() => 129) expect(getHeight(3, el)).toEqual(137) }) test('getHeight: returns row height when larger than scroll height', () => { - global.window.getComputedStyle = jest.fn().mockImplementation(() => ({ + window.getComputedStyle = jest.fn().mockImplementation(() => ({ borderBottomWidth: '4px', borderTopWidth: '4px', lineHeight: '27.2px', paddingBottom: '10px', paddingTop: '10px' })) - const el = { scrollHeight: 129 } + const el = document.createElement('textarea') + jest.spyOn(el, 'scrollHeight', 'get').mockImplementation(() => 129) expect(getHeight(5, el)).toEqual(164) }) test('resize: sets style height when present', () => { - global.window.getComputedStyle = jest.fn().mockImplementation(() => ({ + window.getComputedStyle = jest.fn().mockImplementation(() => ({ borderBottomWidth: '4px', borderTopWidth: '4px', lineHeight: '27.2px', @@ -96,19 +112,21 @@ test('resize: sets style height when present', () => { paddingTop: '10px' })) - const el = { scrollHeight: 129, style: { height: '100px' } } + const el = document.createElement('textarea') + jest.spyOn(el, 'scrollHeight', 'get').mockImplementation(() => 129) + el.style.height = '100px' - resize(undefined, null) + resize(0, null) expect(el.style.height).toEqual('100px') - resize(undefined, el) + resize(0, el) expect(el.style.height).toEqual('137px') }) test('accepts ref', () => { - const ref = createRef(null) + const ref = createRef() render() - expect(ref.current.tagName).toEqual('TEXTAREA') + expect(ref.current?.tagName).toEqual('TEXTAREA') }) diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index 02d082f..0000000 --- a/babel.config.js +++ /dev/null @@ -1,5 +0,0 @@ -const presets = ['@babel/preset-env', '@babel/preset-react'] - -const plugins = [['transform-react-remove-prop-types', { mode: 'wrap' }]] - -module.exports = { presets, plugins } diff --git a/docs/app.js b/docs/app.js deleted file mode 100644 index 66b2218..0000000 --- a/docs/app.js +++ /dev/null @@ -1,33123 +0,0 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i= 0 || (o[t] = e[t]); - } - - return o; - }(e, r); - - if (Object.getOwnPropertySymbols) { - var a = Object.getOwnPropertySymbols(e); - - for (n = 0; n < a.length; n++) { - t = a[n], r.indexOf(t) >= 0 || Object.prototype.propertyIsEnumerable.call(e, t) && (o[t] = e[t]); - } - } - - return o; - } - - function a(e) { - return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e["default"] : e; - } - - function i(e, r) { - return e(r = { - exports: {} - }, r.exports), r.exports; - } - - var c = i(function (e, r) { - Object.defineProperty(r, "__esModule", { - value: !0 - }); - var t = "function" == typeof Symbol && Symbol["for"], - n = t ? Symbol["for"]("react.element") : 60103, - o = t ? Symbol["for"]("react.portal") : 60106, - a = t ? Symbol["for"]("react.fragment") : 60107, - i = t ? Symbol["for"]("react.strict_mode") : 60108, - c = t ? Symbol["for"]("react.profiler") : 60114, - u = t ? Symbol["for"]("react.provider") : 60109, - f = t ? Symbol["for"]("react.context") : 60110, - s = t ? Symbol["for"]("react.async_mode") : 60111, - l = t ? Symbol["for"]("react.concurrent_mode") : 60111, - p = t ? Symbol["for"]("react.forward_ref") : 60112, - y = t ? Symbol["for"]("react.suspense") : 60113, - d = t ? Symbol["for"]("react.suspense_list") : 60120, - m = t ? Symbol["for"]("react.memo") : 60115, - v = t ? Symbol["for"]("react.lazy") : 60116, - b = t ? Symbol["for"]("react.fundamental") : 60117, - h = t ? Symbol["for"]("react.responder") : 60118, - g = t ? Symbol["for"]("react.scope") : 60119; - - function O(e) { - if ("object" == _typeof(e) && null !== e) { - var r = e.$$typeof; - - switch (r) { - case n: - switch (e = e.type) { - case s: - case l: - case a: - case c: - case i: - case y: - return e; - - default: - switch (e = e && e.$$typeof) { - case f: - case p: - case v: - case m: - case u: - return e; - - default: - return r; - } - - } - - case o: - return r; - } - } - } - - function w(e) { - return O(e) === l; - } - - r.typeOf = O, r.AsyncMode = s, r.ConcurrentMode = l, r.ContextConsumer = f, r.ContextProvider = u, r.Element = n, r.ForwardRef = p, r.Fragment = a, r.Lazy = v, r.Memo = m, r.Portal = o, r.Profiler = c, r.StrictMode = i, r.Suspense = y, r.isValidElementType = function (e) { - return "string" == typeof e || "function" == typeof e || e === a || e === l || e === c || e === i || e === y || e === d || "object" == _typeof(e) && null !== e && (e.$$typeof === v || e.$$typeof === m || e.$$typeof === u || e.$$typeof === f || e.$$typeof === p || e.$$typeof === b || e.$$typeof === h || e.$$typeof === g); - }, r.isAsyncMode = function (e) { - return w(e) || O(e) === s; - }, r.isConcurrentMode = w, r.isContextConsumer = function (e) { - return O(e) === f; - }, r.isContextProvider = function (e) { - return O(e) === u; - }, r.isElement = function (e) { - return "object" == _typeof(e) && null !== e && e.$$typeof === n; - }, r.isForwardRef = function (e) { - return O(e) === p; - }, r.isFragment = function (e) { - return O(e) === a; - }, r.isLazy = function (e) { - return O(e) === v; - }, r.isMemo = function (e) { - return O(e) === m; - }, r.isPortal = function (e) { - return O(e) === o; - }, r.isProfiler = function (e) { - return O(e) === c; - }, r.isStrictMode = function (e) { - return O(e) === i; - }, r.isSuspense = function (e) { - return O(e) === y; - }; - }); - a(c); - c.typeOf, c.AsyncMode, c.ConcurrentMode, c.ContextConsumer, c.ContextProvider, c.Element, c.ForwardRef, c.Fragment, c.Lazy, c.Memo, c.Portal, c.Profiler, c.StrictMode, c.Suspense, c.isValidElementType, c.isAsyncMode, c.isConcurrentMode, c.isContextConsumer, c.isContextProvider, c.isElement, c.isForwardRef, c.isFragment, c.isLazy, c.isMemo, c.isPortal, c.isProfiler, c.isStrictMode, c.isSuspense; - var u = i(function (e, r) { - "production" !== process.env.NODE_ENV && function () { - Object.defineProperty(r, "__esModule", { - value: !0 - }); - var e = "function" == typeof Symbol && Symbol["for"], - t = e ? Symbol["for"]("react.element") : 60103, - n = e ? Symbol["for"]("react.portal") : 60106, - o = e ? Symbol["for"]("react.fragment") : 60107, - a = e ? Symbol["for"]("react.strict_mode") : 60108, - i = e ? Symbol["for"]("react.profiler") : 60114, - c = e ? Symbol["for"]("react.provider") : 60109, - u = e ? Symbol["for"]("react.context") : 60110, - f = e ? Symbol["for"]("react.async_mode") : 60111, - s = e ? Symbol["for"]("react.concurrent_mode") : 60111, - l = e ? Symbol["for"]("react.forward_ref") : 60112, - p = e ? Symbol["for"]("react.suspense") : 60113, - y = e ? Symbol["for"]("react.suspense_list") : 60120, - d = e ? Symbol["for"]("react.memo") : 60115, - m = e ? Symbol["for"]("react.lazy") : 60116, - v = e ? Symbol["for"]("react.fundamental") : 60117, - b = e ? Symbol["for"]("react.responder") : 60118, - h = e ? Symbol["for"]("react.scope") : 60119; - - var g = function g(e) { - for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++) { - t[n - 1] = arguments[n]; - } - - var o = 0, - a = "Warning: " + e.replace(/%s/g, function () { - return t[o++]; - }); - "undefined" != typeof console && console.warn(a); - - try { - throw new Error(a); - } catch (e) {} - }, - O = function O(e, r) { - if (void 0 === r) throw new Error("`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning message argument"); - - if (!e) { - for (var t = arguments.length, n = new Array(t > 2 ? t - 2 : 0), o = 2; o < t; o++) { - n[o - 2] = arguments[o]; - } - - g.apply(void 0, [r].concat(n)); - } - }; - - function w(e) { - if ("object" == _typeof(e) && null !== e) { - var r = e.$$typeof; - - switch (r) { - case t: - var y = e.type; - - switch (y) { - case f: - case s: - case o: - case i: - case a: - case p: - return y; - - default: - var v = y && y.$$typeof; - - switch (v) { - case u: - case l: - case m: - case d: - case c: - return v; - - default: - return r; - } - - } - - case n: - return r; - } - } - } - - var S = f, - E = s, - x = u, - P = c, - j = t, - C = l, - $ = o, - _ = m, - M = d, - T = n, - R = i, - I = a, - N = p, - F = !1; - - function k(e) { - return w(e) === s; - } - - r.typeOf = w, r.AsyncMode = S, r.ConcurrentMode = E, r.ContextConsumer = x, r.ContextProvider = P, r.Element = j, r.ForwardRef = C, r.Fragment = $, r.Lazy = _, r.Memo = M, r.Portal = T, r.Profiler = R, r.StrictMode = I, r.Suspense = N, r.isValidElementType = function (e) { - return "string" == typeof e || "function" == typeof e || e === o || e === s || e === i || e === a || e === p || e === y || "object" == _typeof(e) && null !== e && (e.$$typeof === m || e.$$typeof === d || e.$$typeof === c || e.$$typeof === u || e.$$typeof === l || e.$$typeof === v || e.$$typeof === b || e.$$typeof === h); - }, r.isAsyncMode = function (e) { - return F || (F = !0, O(!1, "The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")), k(e) || w(e) === f; - }, r.isConcurrentMode = k, r.isContextConsumer = function (e) { - return w(e) === u; - }, r.isContextProvider = function (e) { - return w(e) === c; - }, r.isElement = function (e) { - return "object" == _typeof(e) && null !== e && e.$$typeof === t; - }, r.isForwardRef = function (e) { - return w(e) === l; - }, r.isFragment = function (e) { - return w(e) === o; - }, r.isLazy = function (e) { - return w(e) === m; - }, r.isMemo = function (e) { - return w(e) === d; - }, r.isPortal = function (e) { - return w(e) === n; - }, r.isProfiler = function (e) { - return w(e) === i; - }, r.isStrictMode = function (e) { - return w(e) === a; - }, r.isSuspense = function (e) { - return w(e) === p; - }; - }(); - }); - a(u); - u.typeOf, u.AsyncMode, u.ConcurrentMode, u.ContextConsumer, u.ContextProvider, u.Element, u.ForwardRef, u.Fragment, u.Lazy, u.Memo, u.Portal, u.Profiler, u.StrictMode, u.Suspense, u.isValidElementType, u.isAsyncMode, u.isConcurrentMode, u.isContextConsumer, u.isContextProvider, u.isElement, u.isForwardRef, u.isFragment, u.isLazy, u.isMemo, u.isPortal, u.isProfiler, u.isStrictMode, u.isSuspense; - var f = i(function (e) { - "production" === process.env.NODE_ENV ? e.exports = c : e.exports = u; - }), - s = Object.getOwnPropertySymbols, - l = Object.prototype.hasOwnProperty, - p = Object.prototype.propertyIsEnumerable; - - function y(e) { - if (null == e) throw new TypeError("Object.assign cannot be called with null or undefined"); - return Object(e); - } - - var d = function () { - try { - if (!Object.assign) return !1; - var e = new String("abc"); - if (e[5] = "de", "5" === Object.getOwnPropertyNames(e)[0]) return !1; - - for (var r = {}, t = 0; t < 10; t++) { - r["_" + String.fromCharCode(t)] = t; - } - - if ("0123456789" !== Object.getOwnPropertyNames(r).map(function (e) { - return r[e]; - }).join("")) return !1; - var n = {}; - return "abcdefghijklmnopqrst".split("").forEach(function (e) { - n[e] = e; - }), "abcdefghijklmnopqrst" === Object.keys(Object.assign({}, n)).join(""); - } catch (e) { - return !1; - } - }() ? Object.assign : function (e, r) { - for (var t, n, o = y(e), a = 1; a < arguments.length; a++) { - for (var i in t = Object(arguments[a])) { - l.call(t, i) && (o[i] = t[i]); - } - - if (s) { - n = s(t); - - for (var c = 0; c < n.length; c++) { - p.call(t, n[c]) && (o[n[c]] = t[n[c]]); - } - } - } - - return o; - }, - m = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED", - v = function v() {}; - - if ("production" !== process.env.NODE_ENV) { - var b = m, - h = {}, - g = Function.call.bind(Object.prototype.hasOwnProperty); - - v = function v(e) { - var r = "Warning: " + e; - "undefined" != typeof console && console.error(r); - - try { - throw new Error(r); - } catch (e) {} - }; - } - - function O(e, r, t, n, o) { - if ("production" !== process.env.NODE_ENV) for (var a in e) { - if (g(e, a)) { - var i; - - try { - if ("function" != typeof e[a]) { - var c = Error((n || "React class") + ": " + t + " type `" + a + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + _typeof(e[a]) + "`."); - throw c.name = "Invariant Violation", c; - } - - i = e[a](r, a, n, t, null, b); - } catch (e) { - i = e; - } - - if (!i || i instanceof Error || v((n || "React class") + ": type specification of " + t + " `" + a + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + _typeof(i) + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."), i instanceof Error && !(i.message in h)) { - h[i.message] = !0; - var u = o ? o() : ""; - v("Failed " + t + " type: " + i.message + (null != u ? u : "")); - } - } - } - } - - O.resetWarningCache = function () { - "production" !== process.env.NODE_ENV && (h = {}); - }; - - var w = O, - S = Function.call.bind(Object.prototype.hasOwnProperty), - E = function E() {}; - - function x() { - return null; - } - - "production" !== process.env.NODE_ENV && (E = function E(e) { - var r = "Warning: " + e; - "undefined" != typeof console && console.error(r); - - try { - throw new Error(r); - } catch (e) {} - }); - - var P = function P(e, r) { - var t = "function" == typeof Symbol && Symbol.iterator; - var n = { - array: c("array"), - bool: c("boolean"), - func: c("function"), - number: c("number"), - object: c("object"), - string: c("string"), - symbol: c("symbol"), - any: i(x), - arrayOf: function arrayOf(e) { - return i(function (r, t, n, o, i) { - if ("function" != typeof e) return new a("Property `" + i + "` of component `" + n + "` has invalid PropType notation inside arrayOf."); - var c = r[t]; - if (!Array.isArray(c)) return new a("Invalid " + o + " `" + i + "` of type `" + s(c) + "` supplied to `" + n + "`, expected an array."); - - for (var u = 0; u < c.length; u++) { - var f = e(c, u, n, o, i + "[" + u + "]", m); - if (f instanceof Error) return f; - } - - return null; - }); - }, - element: i(function (r, t, n, o, i) { - var c = r[t]; - return e(c) ? null : new a("Invalid " + o + " `" + i + "` of type `" + s(c) + "` supplied to `" + n + "`, expected a single ReactElement."); - }), - elementType: i(function (e, r, t, n, o) { - var i = e[r]; - return f.isValidElementType(i) ? null : new a("Invalid " + n + " `" + o + "` of type `" + s(i) + "` supplied to `" + t + "`, expected a single ReactElement type."); - }), - instanceOf: function instanceOf(e) { - return i(function (r, t, n, o, i) { - if (!(r[t] instanceof e)) { - var c = e.name || "<>"; - return new a("Invalid " + o + " `" + i + "` of type `" + function (e) { - if (!e.constructor || !e.constructor.name) return "<>"; - return e.constructor.name; - }(r[t]) + "` supplied to `" + n + "`, expected instance of `" + c + "`."); - } - - return null; - }); - }, - node: i(function (e, r, t, n, o) { - return u(e[r]) ? null : new a("Invalid " + n + " `" + o + "` supplied to `" + t + "`, expected a ReactNode."); - }), - objectOf: function objectOf(e) { - return i(function (r, t, n, o, i) { - if ("function" != typeof e) return new a("Property `" + i + "` of component `" + n + "` has invalid PropType notation inside objectOf."); - var c = r[t], - u = s(c); - if ("object" !== u) return new a("Invalid " + o + " `" + i + "` of type `" + u + "` supplied to `" + n + "`, expected an object."); - - for (var f in c) { - if (S(c, f)) { - var l = e(c, f, n, o, i + "." + f, m); - if (l instanceof Error) return l; - } - } - - return null; - }); - }, - oneOf: function oneOf(e) { - if (!Array.isArray(e)) return "production" !== process.env.NODE_ENV && (arguments.length > 1 ? E("Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).") : E("Invalid argument supplied to oneOf, expected an array.")), x; - - function r(r, t, n, i, c) { - for (var u = r[t], f = 0; f < e.length; f++) { - if (o(u, e[f])) return null; - } - - var s = JSON.stringify(e, function (e, r) { - return "symbol" === l(r) ? String(r) : r; - }); - return new a("Invalid " + i + " `" + c + "` of value `" + String(u) + "` supplied to `" + n + "`, expected one of " + s + "."); - } - - return i(r); - }, - oneOfType: function oneOfType(e) { - if (!Array.isArray(e)) return "production" !== process.env.NODE_ENV && E("Invalid argument supplied to oneOfType, expected an instance of array."), x; - - for (var r = 0; r < e.length; r++) { - var t = e[r]; - if ("function" != typeof t) return E("Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + p(t) + " at index " + r + "."), x; - } - - return i(function (r, t, n, o, i) { - for (var c = 0; c < e.length; c++) { - if (null == (0, e[c])(r, t, n, o, i, m)) return null; - } - - return new a("Invalid " + o + " `" + i + "` supplied to `" + n + "`."); - }); - }, - shape: function shape(e) { - return i(function (r, t, n, o, i) { - var c = r[t], - u = s(c); - if ("object" !== u) return new a("Invalid " + o + " `" + i + "` of type `" + u + "` supplied to `" + n + "`, expected `object`."); - - for (var f in e) { - var l = e[f]; - - if (l) { - var p = l(c, f, n, o, i + "." + f, m); - if (p) return p; - } - } - - return null; - }); - }, - exact: function exact(e) { - return i(function (r, t, n, o, i) { - var c = r[t], - u = s(c); - if ("object" !== u) return new a("Invalid " + o + " `" + i + "` of type `" + u + "` supplied to `" + n + "`, expected `object`."); - var f = d({}, r[t], e); - - for (var l in f) { - var p = e[l]; - if (!p) return new a("Invalid " + o + " `" + i + "` key `" + l + "` supplied to `" + n + "`.\nBad object: " + JSON.stringify(r[t], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(e), null, " ")); - var y = p(c, l, n, o, i + "." + l, m); - if (y) return y; - } - - return null; - }); - } - }; - - function o(e, r) { - return e === r ? 0 !== e || 1 / e == 1 / r : e != e && r != r; - } - - function a(e) { - this.message = e, this.stack = ""; - } - - function i(e) { - if ("production" !== process.env.NODE_ENV) var t = {}, - n = 0; - - function o(o, i, c, u, f, s, l) { - if (u = u || "<>", s = s || c, l !== m) { - if (r) { - var p = new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types"); - throw p.name = "Invariant Violation", p; - } - - if ("production" !== process.env.NODE_ENV && "undefined" != typeof console) { - var y = u + ":" + c; - !t[y] && n < 3 && (E("You are manually calling a React.PropTypes validation function for the `" + s + "` prop on `" + u + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."), t[y] = !0, n++); - } - } - - return null == i[c] ? o ? null === i[c] ? new a("The " + f + " `" + s + "` is marked as required in `" + u + "`, but its value is `null`.") : new a("The " + f + " `" + s + "` is marked as required in `" + u + "`, but its value is `undefined`.") : null : e(i, c, u, f, s); - } - - var i = o.bind(null, !1); - return i.isRequired = o.bind(null, !0), i; - } - - function c(e) { - return i(function (r, t, n, o, i, c) { - var u = r[t]; - return s(u) !== e ? new a("Invalid " + o + " `" + i + "` of type `" + l(u) + "` supplied to `" + n + "`, expected `" + e + "`.") : null; - }); - } - - function u(r) { - switch (_typeof(r)) { - case "number": - case "string": - case "undefined": - return !0; - - case "boolean": - return !r; - - case "object": - if (Array.isArray(r)) return r.every(u); - if (null === r || e(r)) return !0; - - var n = function (e) { - var r = e && (t && e[t] || e["@@iterator"]); - if ("function" == typeof r) return r; - }(r); - - if (!n) return !1; - var o, - a = n.call(r); - - if (n !== r.entries) { - for (; !(o = a.next()).done;) { - if (!u(o.value)) return !1; - } - } else for (; !(o = a.next()).done;) { - var i = o.value; - if (i && !u(i[1])) return !1; - } - - return !0; - - default: - return !1; - } - } - - function s(e) { - var r = _typeof(e); - - return Array.isArray(e) ? "array" : e instanceof RegExp ? "object" : function (e, r) { - return "symbol" === e || !!r && ("Symbol" === r["@@toStringTag"] || "function" == typeof Symbol && r instanceof Symbol); - }(r, e) ? "symbol" : r; - } - - function l(e) { - if (null == e) return "" + e; - var r = s(e); - - if ("object" === r) { - if (e instanceof Date) return "date"; - if (e instanceof RegExp) return "regexp"; - } - - return r; - } - - function p(e) { - var r = l(e); - - switch (r) { - case "array": - case "object": - return "an " + r; - - case "boolean": - case "date": - case "regexp": - return "a " + r; - - default: - return r; - } - } - - return a.prototype = Error.prototype, n.checkPropTypes = w, n.resetWarningCache = w.resetWarningCache, n.PropTypes = n, n; - }; - - function j() {} - - function C() {} - - C.resetWarningCache = j; - var $ = i(function (e) { - if ("production" !== process.env.NODE_ENV) { - var r = f; - e.exports = P(r.isElement, !0); - } else e.exports = function () { - function e(e, r, t, n, o, a) { - if (a !== m) { - var i = new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"); - throw i.name = "Invariant Violation", i; - } - } - - function r() { - return e; - } - - e.isRequired = e; - var t = { - array: e, - bool: e, - func: e, - number: e, - object: e, - string: e, - symbol: e, - any: e, - arrayOf: r, - element: e, - elementType: e, - instanceOf: r, - node: e, - objectOf: r, - oneOf: r, - oneOfType: r, - shape: r, - exact: r, - checkPropTypes: C, - resetWarningCache: j - }; - return t.PropTypes = t, t; - }(); - }), - _ = $.func, - M = $.number, - T = $.object, - R = $.oneOfType, - I = $.string; - - function N() { - return (N = Object.assign || function (e) { - for (var r = 1; r < arguments.length; r++) { - var t = arguments[r]; - - for (var n in t) { - Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]); - } - } - - return e; - }).apply(this, arguments); - } - - var F = function F(e, r) { - var t = window.getComputedStyle(r), - n = t.borderBottomWidth, - o = t.borderTopWidth, - a = t.lineHeight, - i = t.paddingBottom, - c = t.paddingTop, - u = null == e ? 0 : parseFloat(a) * parseInt(e, 10) + parseFloat(n) + parseFloat(o) + parseFloat(i) + parseFloat(c), - f = r.scrollHeight + parseFloat(n) + parseFloat(o); - return Math.max(u, f); - }, - k = function k(e, r) { - r && (r.style.height = "0", r.style.overflowY = "hidden", r.style.height = "".concat(F(e, r), "px")); - }, - A = function A(e) { - var a = e.forwardedRef, - i = o(e, ["forwardedRef"]), - c = a || r.createRef(null), - u = i.onChange, - f = i.onInput, - s = i.rows, - l = i.value; - r.useEffect(function () { - k(s, c.current); - }, [s, l, c]); - var p = r.useCallback(function (e) { - u(e), f(e), k(s, c.current); - }, [c, u, f, s]); - return t.createElement("textarea", n({}, i, { - onInput: p, - ref: c - })); - }; - - A.propTypes = "production" !== process.env.NODE_ENV ? { - onChange: _, - onInput: _, - forwardedRef: T, - rows: R([M, I]), - value: I - } : {}, A.defaultProps = { - onChange: Function.prototype, - onInput: Function.prototype - }; - var V, - D, - z, - W = (D = function D(e, r) { - return t.createElement(V, N({}, e, { - forwardedRef: r - })); - }, z = (V = A).displayName || V.name, D.displayName = "withForwardedRef(".concat(z, ")"), r.forwardRef(D)); - e["default"] = W, e.getHeight = F, e.resize = k, Object.defineProperty(e, "__esModule", { - value: !0 - }); -}); - -}).call(this,require('_process')) -},{"_process":4,"react":12}],2:[function(require,module,exports){ -"use strict"; - -function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - -var _react = _interopRequireWildcard(require("react")); - -var _reactDom = _interopRequireDefault(require("react-dom")); - -var _cjs = _interopRequireDefault(require("../dist/cjs")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } - -var App = function App() { - var textareaRef = (0, _react.useRef)(null); - var handleChange = (0, _react.useCallback)(function (e) { - console.log(e.target.value); - }, []); - (0, _react.useEffect)(function () { - textareaRef.current.focus(); - }, []); - return _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement("label", { - htmlFor: "my-textarea" - }, "Please Enter Some Details:"), _react["default"].createElement(_cjs["default"], { - className: "textarea", - defaultValue: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", - id: "my-textarea", - maxLength: "3000", - name: "pet[notes]", - onChange: handleChange, - placeholder: "Enter details here...", - ref: textareaRef - })); -}; - -var container = document.querySelector('[data-app]'); - -_reactDom["default"].render(_react["default"].createElement(App, null), container); - -},{"../dist/cjs":1,"react":12,"react-dom":9}],3:[function(require,module,exports){ -/* -object-assign -(c) Sindre Sorhus -@license MIT -*/ - -'use strict'; -/* eslint-disable no-unused-vars */ -var getOwnPropertySymbols = Object.getOwnPropertySymbols; -var hasOwnProperty = Object.prototype.hasOwnProperty; -var propIsEnumerable = Object.prototype.propertyIsEnumerable; - -function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); -} - -function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line no-new-wrappers - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (err) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } -} - -module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - - return to; -}; - -},{}],4:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],5:[function(require,module,exports){ -(function (process){ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -var printWarning = function() {}; - -if (process.env.NODE_ENV !== 'production') { - var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); - var loggedTypeFailures = {}; - var has = Function.call.bind(Object.prototype.hasOwnProperty); - - printWarning = function(text) { - var message = 'Warning: ' + text; - if (typeof console !== 'undefined') { - console.error(message); - } - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch (x) {} - }; -} - -/** - * Assert that the values match with the type specs. - * Error messages are memorized and will only be shown once. - * - * @param {object} typeSpecs Map of name to a ReactPropType - * @param {object} values Runtime values that need to be type-checked - * @param {string} location e.g. "prop", "context", "child context" - * @param {string} componentName Name of the component for error messages. - * @param {?Function} getStack Returns the component stack. - * @private - */ -function checkPropTypes(typeSpecs, values, location, componentName, getStack) { - if (process.env.NODE_ENV !== 'production') { - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error; - // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== 'function') { - var err = Error( - (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + - 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' - ); - err.name = 'Invariant Violation'; - throw err; - } - error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); - } catch (ex) { - error = ex; - } - if (error && !(error instanceof Error)) { - printWarning( - (componentName || 'React class') + ': type specification of ' + - location + ' `' + typeSpecName + '` is invalid; the type checker ' + - 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + - 'You may have forgotten to pass an argument to the type checker ' + - 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + - 'shape all require an argument).' - ); - } - if (error instanceof Error && !(error.message in loggedTypeFailures)) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error.message] = true; - - var stack = getStack ? getStack() : ''; - - printWarning( - 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') - ); - } - } - } - } -} - -/** - * Resets warning cache when testing. - * - * @private - */ -checkPropTypes.resetWarningCache = function() { - if (process.env.NODE_ENV !== 'production') { - loggedTypeFailures = {}; - } -} - -module.exports = checkPropTypes; - -}).call(this,require('_process')) -},{"./lib/ReactPropTypesSecret":6,"_process":4}],6:[function(require,module,exports){ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; - -module.exports = ReactPropTypesSecret; - -},{}],7:[function(require,module,exports){ -(function (process){ -/** @license React v16.12.0 - * react-dom.development.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - - - -if (process.env.NODE_ENV !== "production") { - (function() { -'use strict'; - -var React = require('react'); -var _assign = require('object-assign'); -var Scheduler = require('scheduler'); -var checkPropTypes = require('prop-types/checkPropTypes'); -var tracing = require('scheduler/tracing'); - -// Do not require this module directly! Use normal `invariant` calls with -// template literal strings. The messages will be replaced with error codes -// during build. - -/** - * Use invariant() to assert state which your program assumes to be true. - * - * Provide sprintf-style format (only %s is supported) and arguments - * to provide information about what broke and what you were - * expecting. - * - * The invariant message will be stripped in production, but the invariant - * will remain to ensure logic does not differ in production. - */ - -if (!React) { - { - throw Error("ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM."); - } -} - -/** - * Injectable ordering of event plugins. - */ -var eventPluginOrder = null; -/** - * Injectable mapping from names to event plugin modules. - */ - -var namesToPlugins = {}; -/** - * Recomputes the plugin list using the injected plugins and plugin ordering. - * - * @private - */ - -function recomputePluginOrdering() { - if (!eventPluginOrder) { - // Wait until an `eventPluginOrder` is injected. - return; - } - - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName]; - var pluginIndex = eventPluginOrder.indexOf(pluginName); - - if (!(pluginIndex > -1)) { - { - throw Error("EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`."); - } - } - - if (plugins[pluginIndex]) { - continue; - } - - if (!pluginModule.extractEvents) { - { - throw Error("EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not."); - } - } - - plugins[pluginIndex] = pluginModule; - var publishedEvents = pluginModule.eventTypes; - - for (var eventName in publishedEvents) { - if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) { - { - throw Error("EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`."); - } - } - } - } -} -/** - * Publishes an event so that it can be dispatched by the supplied plugin. - * - * @param {object} dispatchConfig Dispatch configuration for the event. - * @param {object} PluginModule Plugin publishing the event. - * @return {boolean} True if the event was successfully published. - * @private - */ - - -function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { - if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { - { - throw Error("EventPluginHub: More than one plugin attempted to publish the same event name, `" + eventName + "`."); - } - } - - eventNameDispatchConfigs[eventName] = dispatchConfig; - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - - if (phasedRegistrationNames) { - for (var phaseName in phasedRegistrationNames) { - if (phasedRegistrationNames.hasOwnProperty(phaseName)) { - var phasedRegistrationName = phasedRegistrationNames[phaseName]; - publishRegistrationName(phasedRegistrationName, pluginModule, eventName); - } - } - - return true; - } else if (dispatchConfig.registrationName) { - publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); - return true; - } - - return false; -} -/** - * Publishes a registration name that is used to identify dispatched events. - * - * @param {string} registrationName Registration name to add. - * @param {object} PluginModule Plugin publishing the event. - * @private - */ - - -function publishRegistrationName(registrationName, pluginModule, eventName) { - if (!!registrationNameModules[registrationName]) { - { - throw Error("EventPluginHub: More than one plugin attempted to publish the same registration name, `" + registrationName + "`."); - } - } - - registrationNameModules[registrationName] = pluginModule; - registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; - - { - var lowerCasedName = registrationName.toLowerCase(); - possibleRegistrationNames[lowerCasedName] = registrationName; - - if (registrationName === 'onDoubleClick') { - possibleRegistrationNames.ondblclick = registrationName; - } - } -} -/** - * Registers plugins so that they can extract and dispatch events. - * - * @see {EventPluginHub} - */ - -/** - * Ordered list of injected plugins. - */ - - -var plugins = []; -/** - * Mapping from event name to dispatch config - */ - -var eventNameDispatchConfigs = {}; -/** - * Mapping from registration name to plugin module - */ - -var registrationNameModules = {}; -/** - * Mapping from registration name to event name - */ - -var registrationNameDependencies = {}; -/** - * Mapping from lowercase registration names to the properly cased version, - * used to warn in the case of missing event handlers. Available - * only in true. - * @type {Object} - */ - -var possibleRegistrationNames = {}; // Trust the developer to only use possibleRegistrationNames in true - -/** - * Injects an ordering of plugins (by plugin name). This allows the ordering - * to be decoupled from injection of the actual plugins so that ordering is - * always deterministic regardless of packaging, on-the-fly injection, etc. - * - * @param {array} InjectedEventPluginOrder - * @internal - * @see {EventPluginHub.injection.injectEventPluginOrder} - */ - -function injectEventPluginOrder(injectedEventPluginOrder) { - if (!!eventPluginOrder) { - { - throw Error("EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."); - } - } // Clone the ordering so it cannot be dynamically mutated. - - - eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); - recomputePluginOrdering(); -} -/** - * Injects plugins to be used by `EventPluginHub`. The plugin names must be - * in the ordering injected by `injectEventPluginOrder`. - * - * Plugins can be injected as part of page initialization or on-the-fly. - * - * @param {object} injectedNamesToPlugins Map from names to plugin modules. - * @internal - * @see {EventPluginHub.injection.injectEventPluginsByName} - */ - -function injectEventPluginsByName(injectedNamesToPlugins) { - var isOrderingDirty = false; - - for (var pluginName in injectedNamesToPlugins) { - if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { - continue; - } - - var pluginModule = injectedNamesToPlugins[pluginName]; - - if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) { - if (!!namesToPlugins[pluginName]) { - { - throw Error("EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + pluginName + "`."); - } - } - - namesToPlugins[pluginName] = pluginModule; - isOrderingDirty = true; - } - } - - if (isOrderingDirty) { - recomputePluginOrdering(); - } -} - -var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) { - var funcArgs = Array.prototype.slice.call(arguments, 3); - - try { - func.apply(context, funcArgs); - } catch (error) { - this.onError(error); - } -}; - -{ - // In DEV mode, we swap out invokeGuardedCallback for a special version - // that plays more nicely with the browser's DevTools. The idea is to preserve - // "Pause on exceptions" behavior. Because React wraps all user-provided - // functions in invokeGuardedCallback, and the production version of - // invokeGuardedCallback uses a try-catch, all user exceptions are treated - // like caught exceptions, and the DevTools won't pause unless the developer - // takes the extra step of enabling pause on caught exceptions. This is - // unintuitive, though, because even though React has caught the error, from - // the developer's perspective, the error is uncaught. - // - // To preserve the expected "Pause on exceptions" behavior, we don't use a - // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake - // DOM node, and call the user-provided callback from inside an event handler - // for that fake event. If the callback throws, the error is "captured" using - // a global event handler. But because the error happens in a different - // event loop context, it does not interrupt the normal program flow. - // Effectively, this gives us try-catch behavior without actually using - // try-catch. Neat! - // Check that the browser supports the APIs we need to implement our special - // DEV version of invokeGuardedCallback - if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { - var fakeNode = document.createElement('react'); - - var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) { - // If document doesn't exist we know for sure we will crash in this method - // when we call document.createEvent(). However this can cause confusing - // errors: https://github.com/facebookincubator/create-react-app/issues/3482 - // So we preemptively throw with a better message instead. - if (!(typeof document !== 'undefined')) { - { - throw Error("The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous."); - } - } - - var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We - // set this to true at the beginning, then set it to false right after - // calling the function. If the function errors, `didError` will never be - // set to false. This strategy works even if the browser is flaky and - // fails to call our global error handler, because it doesn't rely on - // the error event at all. - - var didError = true; // Keeps track of the value of window.event so that we can reset it - // during the callback to let user code access window.event in the - // browsers that support it. - - var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event - // dispatching: https://github.com/facebook/react/issues/13688 - - var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously - // dispatch our fake event using `dispatchEvent`. Inside the handler, we - // call the user-provided callback. - - var funcArgs = Array.prototype.slice.call(arguments, 3); - - function callCallback() { - // We immediately remove the callback from event listeners so that - // nested `invokeGuardedCallback` calls do not clash. Otherwise, a - // nested call would trigger the fake event handlers of any call higher - // in the stack. - fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the - // window.event assignment in both IE <= 10 as they throw an error - // "Member not found" in strict mode, and in Firefox which does not - // support window.event. - - if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) { - window.event = windowEvent; - } - - func.apply(context, funcArgs); - didError = false; - } // Create a global error event handler. We use this to capture the value - // that was thrown. It's possible that this error handler will fire more - // than once; for example, if non-React code also calls `dispatchEvent` - // and a handler for that event throws. We should be resilient to most of - // those cases. Even if our error event handler fires more than once, the - // last error event is always used. If the callback actually does error, - // we know that the last error event is the correct one, because it's not - // possible for anything else to have happened in between our callback - // erroring and the code that follows the `dispatchEvent` call below. If - // the callback doesn't error, but the error event was fired, we know to - // ignore it because `didError` will be false, as described above. - - - var error; // Use this to track whether the error event is ever called. - - var didSetError = false; - var isCrossOriginError = false; - - function handleWindowError(event) { - error = event.error; - didSetError = true; - - if (error === null && event.colno === 0 && event.lineno === 0) { - isCrossOriginError = true; - } - - if (event.defaultPrevented) { - // Some other error handler has prevented default. - // Browsers silence the error report if this happens. - // We'll remember this to later decide whether to log it or not. - if (error != null && typeof error === 'object') { - try { - error._suppressLogging = true; - } catch (inner) {// Ignore. - } - } - } - } // Create a fake event type. - - - var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers - - window.addEventListener('error', handleWindowError); - fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function - // errors, it will trigger our global error handler. - - evt.initEvent(evtType, false, false); - fakeNode.dispatchEvent(evt); - - if (windowEventDescriptor) { - Object.defineProperty(window, 'event', windowEventDescriptor); - } - - if (didError) { - if (!didSetError) { - // The callback errored, but the error event never fired. - error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.'); - } else if (isCrossOriginError) { - error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.'); - } - - this.onError(error); - } // Remove our event listeners - - - window.removeEventListener('error', handleWindowError); - }; - - invokeGuardedCallbackImpl = invokeGuardedCallbackDev; - } -} - -var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; - -var hasError = false; -var caughtError = null; // Used by event system to capture/rethrow the first error. - -var hasRethrowError = false; -var rethrowError = null; -var reporter = { - onError: function (error) { - hasError = true; - caughtError = error; - } -}; -/** - * Call a function while guarding against errors that happens within it. - * Returns an error if it throws, otherwise null. - * - * In production, this is implemented using a try-catch. The reason we don't - * use a try-catch directly is so that we can swap out a different - * implementation in DEV mode. - * - * @param {String} name of the guard to use for logging or debugging - * @param {Function} func The function to invoke - * @param {*} context The context to use when calling the function - * @param {...*} args Arguments for function - */ - -function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { - hasError = false; - caughtError = null; - invokeGuardedCallbackImpl$1.apply(reporter, arguments); -} -/** - * Same as invokeGuardedCallback, but instead of returning an error, it stores - * it in a global so it can be rethrown by `rethrowCaughtError` later. - * TODO: See if caughtError and rethrowError can be unified. - * - * @param {String} name of the guard to use for logging or debugging - * @param {Function} func The function to invoke - * @param {*} context The context to use when calling the function - * @param {...*} args Arguments for function - */ - -function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) { - invokeGuardedCallback.apply(this, arguments); - - if (hasError) { - var error = clearCaughtError(); - - if (!hasRethrowError) { - hasRethrowError = true; - rethrowError = error; - } - } -} -/** - * During execution of guarded functions we will capture the first error which - * we will rethrow to be handled by the top level error handler. - */ - -function rethrowCaughtError() { - if (hasRethrowError) { - var error = rethrowError; - hasRethrowError = false; - rethrowError = null; - throw error; - } -} -function hasCaughtError() { - return hasError; -} -function clearCaughtError() { - if (hasError) { - var error = caughtError; - hasError = false; - caughtError = null; - return error; - } else { - { - { - throw Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue."); - } - } - } -} - -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ -var warningWithoutStack = function () {}; - -{ - warningWithoutStack = function (condition, format) { - for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - args[_key - 2] = arguments[_key]; - } - - if (format === undefined) { - throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument'); - } - - if (args.length > 8) { - // Check before the condition to catch violations early. - throw new Error('warningWithoutStack() currently supports at most 8 arguments.'); - } - - if (condition) { - return; - } - - if (typeof console !== 'undefined') { - var argsWithFormat = args.map(function (item) { - return '' + item; - }); - argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it - // breaks IE9: https://github.com/facebook/react/issues/13610 - - Function.prototype.apply.call(console.error, console, argsWithFormat); - } - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - var argIndex = 0; - var message = 'Warning: ' + format.replace(/%s/g, function () { - return args[argIndex++]; - }); - throw new Error(message); - } catch (x) {} - }; -} - -var warningWithoutStack$1 = warningWithoutStack; - -var getFiberCurrentPropsFromNode = null; -var getInstanceFromNode = null; -var getNodeFromInstance = null; -function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) { - getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl; - getInstanceFromNode = getInstanceFromNodeImpl; - getNodeFromInstance = getNodeFromInstanceImpl; - - { - !(getNodeFromInstance && getInstanceFromNode) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0; - } -} -var validateEventDispatches; - -{ - validateEventDispatches = function (event) { - var dispatchListeners = event._dispatchListeners; - var dispatchInstances = event._dispatchInstances; - var listenersIsArr = Array.isArray(dispatchListeners); - var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; - var instancesIsArr = Array.isArray(dispatchInstances); - var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; - !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0; - }; -} -/** - * Dispatch the event to the listener. - * @param {SyntheticEvent} event SyntheticEvent to handle - * @param {function} listener Application-level callback - * @param {*} inst Internal component instance - */ - - -function executeDispatch(event, listener, inst) { - var type = event.type || 'unknown-event'; - event.currentTarget = getNodeFromInstance(inst); - invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); - event.currentTarget = null; -} -/** - * Standard/simple iteration through an event's collected dispatches. - */ - -function executeDispatchesInOrder(event) { - var dispatchListeners = event._dispatchListeners; - var dispatchInstances = event._dispatchInstances; - - { - validateEventDispatches(event); - } - - if (Array.isArray(dispatchListeners)) { - for (var i = 0; i < dispatchListeners.length; i++) { - if (event.isPropagationStopped()) { - break; - } // Listeners and Instances are two parallel arrays that are always in sync. - - - executeDispatch(event, dispatchListeners[i], dispatchInstances[i]); - } - } else if (dispatchListeners) { - executeDispatch(event, dispatchListeners, dispatchInstances); - } - - event._dispatchListeners = null; - event._dispatchInstances = null; -} -/** - * @see executeDispatchesInOrderStopAtTrueImpl - */ - - - -/** - * Execution of a "direct" dispatch - there must be at most one dispatch - * accumulated on the event or it is considered an error. It doesn't really make - * sense for an event with multiple dispatches (bubbled) to keep track of the - * return values at each dispatch execution, but it does tend to make sense when - * dealing with "direct" dispatches. - * - * @return {*} The return value of executing the single dispatch. - */ - - -/** - * @param {SyntheticEvent} event - * @return {boolean} True iff number of dispatches accumulated is greater than 0. - */ - -/** - * Accumulates items that must not be null or undefined into the first one. This - * is used to conserve memory by avoiding array allocations, and thus sacrifices - * API cleanness. Since `current` can be null before being passed in and not - * null after this function, make sure to assign it back to `current`: - * - * `a = accumulateInto(a, b);` - * - * This API should be sparingly used. Try `accumulate` for something cleaner. - * - * @return {*|array<*>} An accumulation of items. - */ - -function accumulateInto(current, next) { - if (!(next != null)) { - { - throw Error("accumulateInto(...): Accumulated items must not be null or undefined."); - } - } - - if (current == null) { - return next; - } // Both are not empty. Warning: Never call x.concat(y) when you are not - // certain that x is an Array (x could be a string with concat method). - - - if (Array.isArray(current)) { - if (Array.isArray(next)) { - current.push.apply(current, next); - return current; - } - - current.push(next); - return current; - } - - if (Array.isArray(next)) { - // A bit too dangerous to mutate `next`. - return [current].concat(next); - } - - return [current, next]; -} - -/** - * @param {array} arr an "accumulation" of items which is either an Array or - * a single item. Useful when paired with the `accumulate` module. This is a - * simple utility that allows us to reason about a collection of items, but - * handling the case when there is exactly one item (and we do not need to - * allocate an array). - * @param {function} cb Callback invoked with each element or a collection. - * @param {?} [scope] Scope used as `this` in a callback. - */ -function forEachAccumulated(arr, cb, scope) { - if (Array.isArray(arr)) { - arr.forEach(cb, scope); - } else if (arr) { - cb.call(scope, arr); - } -} - -/** - * 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) { - executeDispatchesInOrder(event); - - if (!event.isPersistent()) { - event.constructor.release(event); - } - } -}; - -var executeDispatchesAndReleaseTopLevel = function (e) { - return executeDispatchesAndRelease(e); -}; - -function runEventsInBatch(events) { - if (events !== null) { - eventQueue = accumulateInto(eventQueue, events); - } // Set `eventQueue` to null before processing it so that we can tell if more - // events get enqueued while processing. - - - var processingEventQueue = eventQueue; - eventQueue = null; - - if (!processingEventQueue) { - return; - } - - forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); - - if (!!eventQueue) { - { - throw Error("processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."); - } - } // This would be a good time to rethrow if any of the event handlers threw. - - - rethrowCaughtError(); -} - -function isInteractive(tag) { - return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; -} - -function shouldPreventMouseEvent(name, type, props) { - switch (name) { - case 'onClick': - case 'onClickCapture': - case 'onDoubleClick': - case 'onDoubleClickCapture': - case 'onMouseDown': - case 'onMouseDownCapture': - case 'onMouseMove': - case 'onMouseMoveCapture': - case 'onMouseUp': - case 'onMouseUpCapture': - return !!(props.disabled && isInteractive(type)); - - default: - return false; - } -} -/** - * 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 - */ - -/** - * Methods for injecting dependencies. - */ - - -var injection = { - /** - * @param {array} InjectedEventPluginOrder - * @public - */ - injectEventPluginOrder: injectEventPluginOrder, - - /** - * @param {object} injectedNamesToPlugins Map from names to plugin modules. - */ - injectEventPluginsByName: injectEventPluginsByName -}; -/** - * @param {object} inst The instance, which is the source of events. - * @param {string} registrationName Name of listener (e.g. `onClick`). - * @return {?function} The stored callback. - */ - -function getListener(inst, registrationName) { - var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not - // live here; needs to be moved to a better place soon - - var stateNode = inst.stateNode; - - if (!stateNode) { - // Work in progress (ex: onload events in incremental mode). - return null; - } - - var props = getFiberCurrentPropsFromNode(stateNode); - - if (!props) { - // Work in progress. - return null; - } - - listener = props[registrationName]; - - if (shouldPreventMouseEvent(registrationName, inst.type, props)) { - return null; - } - - if (!(!listener || typeof listener === 'function')) { - { - throw Error("Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type."); - } - } - - return listener; -} -/** - * Allows registered plugins an opportunity to extract events from top-level - * native browser events. - * - * @return {*} An accumulation of synthetic events. - * @internal - */ - -function extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { - var events = null; - - for (var i = 0; i < plugins.length; i++) { - // Not every plugin in the ordering may be loaded at runtime. - var possiblePlugin = plugins[i]; - - if (possiblePlugin) { - var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); - - if (extractedEvents) { - events = accumulateInto(events, extractedEvents); - } - } - } - - return events; -} - -function runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { - var events = extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); - runEventsInBatch(events); -} - -var FunctionComponent = 0; -var ClassComponent = 1; -var IndeterminateComponent = 2; // Before we know whether it is function or class - -var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - -var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - -var HostComponent = 5; -var HostText = 6; -var Fragment = 7; -var Mode = 8; -var ContextConsumer = 9; -var ContextProvider = 10; -var ForwardRef = 11; -var Profiler = 12; -var SuspenseComponent = 13; -var MemoComponent = 14; -var SimpleMemoComponent = 15; -var LazyComponent = 16; -var IncompleteClassComponent = 17; -var DehydratedFragment = 18; -var SuspenseListComponent = 19; -var FundamentalComponent = 20; -var ScopeComponent = 21; - -var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. -// Current owner and dispatcher used to share the same ref, -// but PR #14548 split them out to better support the react-debug-tools package. - -if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) { - ReactSharedInternals.ReactCurrentDispatcher = { - current: null - }; -} - -if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) { - ReactSharedInternals.ReactCurrentBatchConfig = { - suspense: null - }; -} - -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; -var describeComponentFrame = function (name, source, ownerName) { - var sourceInfo = ''; - - if (source) { - var path = source.fileName; - var fileName = path.replace(BEFORE_SLASH_RE, ''); - - { - // In DEV, include code for a common special case: - // prefer "folder/index.js" instead of just "index.js". - if (/^index\./.test(fileName)) { - var match = path.match(BEFORE_SLASH_RE); - - if (match) { - var pathBeforeSlash = match[1]; - - if (pathBeforeSlash) { - var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); - fileName = folderName + '/' + fileName; - } - } - } - } - - sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; - } else if (ownerName) { - sourceInfo = ' (created by ' + ownerName + ')'; - } - - return '\n in ' + (name || 'Unknown') + sourceInfo; -}; - -// The Symbol used to tag the ReactElement-like types. If there is no native Symbol -// nor polyfill, then a plain number is used for performance. -var hasSymbol = typeof Symbol === 'function' && Symbol.for; -var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; -var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; -var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; -var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; -var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; -var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; -var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary -// (unstable) APIs that have been removed. Can we remove the symbols? - - -var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; -var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; -var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; -var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; -var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; -var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; -var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; -var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; -var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; -var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; -var FAUX_ITERATOR_SYMBOL = '@@iterator'; -function getIteratorFn(maybeIterable) { - if (maybeIterable === null || typeof maybeIterable !== 'object') { - return null; - } - - var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; - - if (typeof maybeIterator === 'function') { - return maybeIterator; - } - - return null; -} - -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function (condition, format) { - if (condition) { - return; - } - - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args - - for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack])); - }; -} - -var warning$1 = warning; - -var Uninitialized = -1; -var Pending = 0; -var Resolved = 1; -var Rejected = 2; -function refineResolvedLazyComponent(lazyComponent) { - return lazyComponent._status === Resolved ? lazyComponent._result : null; -} -function initializeLazyComponentType(lazyComponent) { - if (lazyComponent._status === Uninitialized) { - lazyComponent._status = Pending; - var ctor = lazyComponent._ctor; - var thenable = ctor(); - lazyComponent._result = thenable; - thenable.then(function (moduleObject) { - if (lazyComponent._status === Pending) { - var defaultExport = moduleObject.default; - - { - if (defaultExport === undefined) { - warning$1(false, 'lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject); - } - } - - lazyComponent._status = Resolved; - lazyComponent._result = defaultExport; - } - }, function (error) { - if (lazyComponent._status === Pending) { - lazyComponent._status = Rejected; - lazyComponent._result = error; - } - }); - } -} - -function getWrappedName(outerType, innerType, wrapperName) { - var functionName = innerType.displayName || innerType.name || ''; - return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); -} - -function getComponentName(type) { - if (type == null) { - // Host root, text node or just invalid type. - return null; - } - - { - if (typeof type.tag === 'number') { - warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); - } - } - - if (typeof type === 'function') { - return type.displayName || type.name || null; - } - - if (typeof type === 'string') { - return type; - } - - switch (type) { - case REACT_FRAGMENT_TYPE: - return 'Fragment'; - - case REACT_PORTAL_TYPE: - return 'Portal'; - - case REACT_PROFILER_TYPE: - return "Profiler"; - - case REACT_STRICT_MODE_TYPE: - return 'StrictMode'; - - case REACT_SUSPENSE_TYPE: - return 'Suspense'; - - case REACT_SUSPENSE_LIST_TYPE: - return 'SuspenseList'; - } - - if (typeof type === 'object') { - switch (type.$$typeof) { - case REACT_CONTEXT_TYPE: - return 'Context.Consumer'; - - case REACT_PROVIDER_TYPE: - return 'Context.Provider'; - - case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, 'ForwardRef'); - - case REACT_MEMO_TYPE: - return getComponentName(type.type); - - case REACT_LAZY_TYPE: - { - var thenable = type; - var resolvedThenable = refineResolvedLazyComponent(thenable); - - if (resolvedThenable) { - return getComponentName(resolvedThenable); - } - - break; - } - } - } - - return null; -} - -var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - -function describeFiber(fiber) { - switch (fiber.tag) { - case HostRoot: - case HostPortal: - case HostText: - case Fragment: - case ContextProvider: - case ContextConsumer: - return ''; - - default: - var owner = fiber._debugOwner; - var source = fiber._debugSource; - var name = getComponentName(fiber.type); - var ownerName = null; - - if (owner) { - ownerName = getComponentName(owner.type); - } - - return describeComponentFrame(name, source, ownerName); - } -} - -function getStackByFiberInDevAndProd(workInProgress) { - var info = ''; - var node = workInProgress; - - do { - info += describeFiber(node); - node = node.return; - } while (node); - - return info; -} -var current = null; -var phase = null; -function getCurrentFiberOwnerNameInDevOrNull() { - { - if (current === null) { - return null; - } - - var owner = current._debugOwner; - - if (owner !== null && typeof owner !== 'undefined') { - return getComponentName(owner.type); - } - } - - return null; -} -function getCurrentFiberStackInDev() { - { - if (current === null) { - return ''; - } // Safe because if current fiber exists, we are reconciling, - // and it is guaranteed to be the work-in-progress version. - - - return getStackByFiberInDevAndProd(current); - } - - return ''; -} -function resetCurrentFiber() { - { - ReactDebugCurrentFrame.getCurrentStack = null; - current = null; - phase = null; - } -} -function setCurrentFiber(fiber) { - { - ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev; - current = fiber; - phase = null; - } -} -function setCurrentPhase(lifeCyclePhase) { - { - phase = lifeCyclePhase; - } -} - -var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); - -function endsWith(subject, search) { - var length = subject.length; - return subject.substring(length - search.length, length) === search; -} - -var PLUGIN_EVENT_SYSTEM = 1; -var RESPONDER_EVENT_SYSTEM = 1 << 1; -var IS_PASSIVE = 1 << 2; -var IS_ACTIVE = 1 << 3; -var PASSIVE_NOT_SUPPORTED = 1 << 4; -var IS_REPLAYED = 1 << 5; - -var restoreImpl = null; -var restoreTarget = null; -var restoreQueue = null; - -function restoreStateOfTarget(target) { - // We perform this translation at the end of the event loop so that we - // always receive the correct fiber here - var internalInstance = getInstanceFromNode(target); - - if (!internalInstance) { - // Unmounted - return; - } - - if (!(typeof restoreImpl === 'function')) { - { - throw Error("setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue."); - } - } - - var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); - restoreImpl(internalInstance.stateNode, internalInstance.type, props); -} - -function setRestoreImplementation(impl) { - restoreImpl = impl; -} -function enqueueStateRestore(target) { - if (restoreTarget) { - if (restoreQueue) { - restoreQueue.push(target); - } else { - restoreQueue = [target]; - } - } else { - restoreTarget = target; - } -} -function needsStateRestore() { - return restoreTarget !== null || restoreQueue !== null; -} -function restoreStateIfNeeded() { - if (!restoreTarget) { - return; - } - - var target = restoreTarget; - var queuedTargets = restoreQueue; - restoreTarget = null; - restoreQueue = null; - restoreStateOfTarget(target); - - if (queuedTargets) { - for (var i = 0; i < queuedTargets.length; i++) { - restoreStateOfTarget(queuedTargets[i]); - } - } -} - -var enableUserTimingAPI = true; // Helps identify side effects in render-phase lifecycle hooks and setState -// reducers by double invoking them in Strict Mode. - -var debugRenderPhaseSideEffectsForStrictMode = true; // To preserve the "Pause on caught exceptions" behavior of the debugger, we -// replay the begin phase of a failed component inside invokeGuardedCallback. - -var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: - -var warnAboutDeprecatedLifecycles = true; // Gather advanced timing metrics for Profiler subtrees. - -var enableProfilerTimer = true; // Trace which interactions trigger each commit. - -var enableSchedulerTracing = true; // SSR experiments - -var enableSuspenseServerRenderer = false; -var enableSelectiveHydration = false; // Only used in www builds. - - // Only used in www builds. - - // Disable javascript: URL strings in href for XSS protection. - -var disableJavaScriptURLs = false; // React Fire: prevent the value and checked attributes from syncing -// with their related DOM properties - -var disableInputAttributeSyncing = false; // These APIs will no longer be "unstable" in the upcoming 16.7 release, -// Control this behavior with a flag to support 16.6 minor releases in the meanwhile. - -var exposeConcurrentModeAPIs = false; -var warnAboutShorthandPropertyCollision = false; // Experimental React Flare event system and event components support. - -var enableFlareAPI = false; // Experimental Host Component support. - -var enableFundamentalAPI = false; // Experimental Scope support. - -var enableScopeAPI = false; // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107 - - // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?) -// Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version - -var warnAboutUnmockedScheduler = false; // For tests, we flush suspense fallbacks in an act scope; -// *except* in some of our own tests, where we test incremental loading states. - -var flushSuspenseFallbacksInTests = true; // Add a callback property to suspense to notify which promises are currently -// in the update queue. This allows reporting and tracing of what is causing -// the user to see a loading state. -// Also allows hydration callbacks to fire when a dehydrated boundary gets -// hydrated or deleted. - -var enableSuspenseCallback = false; // Part of the simplification of React.createElement so we can eventually move -// from React.createElement to React.jsx -// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md - -var warnAboutDefaultPropsOnFunctionComponents = false; -var warnAboutStringRefs = false; -var disableLegacyContext = false; -var disableSchedulerTimeoutBasedOnReactExpirationTime = false; -var enableTrustedTypesIntegration = false; // Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance - -// the renderer. Such as when we're dispatching events or if third party -// libraries need to call batchedUpdates. Eventually, this API will go away when -// everything is batched by default. We'll then have a similar API to opt-out of -// scheduled work and instead do synchronous work. -// Defaults - -var batchedUpdatesImpl = function (fn, bookkeeping) { - return fn(bookkeeping); -}; - -var discreteUpdatesImpl = function (fn, a, b, c) { - return fn(a, b, c); -}; - -var flushDiscreteUpdatesImpl = function () {}; - -var batchedEventUpdatesImpl = batchedUpdatesImpl; -var isInsideEventHandler = false; -var isBatchingEventUpdates = false; - -function finishEventHandler() { - // Here we wait until all updates have propagated, which is important - // when using controlled components within layers: - // https://github.com/facebook/react/issues/1698 - // Then we restore state of any controlled component. - var controlledComponentsHavePendingUpdates = needsStateRestore(); - - if (controlledComponentsHavePendingUpdates) { - // If a controlled event was fired, we may need to restore the state of - // the DOM node back to the controlled value. This is necessary when React - // bails out of the update without touching the DOM. - flushDiscreteUpdatesImpl(); - restoreStateIfNeeded(); - } -} - -function batchedUpdates(fn, bookkeeping) { - if (isInsideEventHandler) { - // If we are currently inside another batch, we need to wait until it - // fully completes before restoring state. - return fn(bookkeeping); - } - - isInsideEventHandler = true; - - try { - return batchedUpdatesImpl(fn, bookkeeping); - } finally { - isInsideEventHandler = false; - finishEventHandler(); - } -} -function batchedEventUpdates(fn, a, b) { - if (isBatchingEventUpdates) { - // If we are currently inside another batch, we need to wait until it - // fully completes before restoring state. - return fn(a, b); - } - - isBatchingEventUpdates = true; - - try { - return batchedEventUpdatesImpl(fn, a, b); - } finally { - isBatchingEventUpdates = false; - finishEventHandler(); - } -} // This is for the React Flare event system - -function executeUserEventHandler(fn, value) { - var previouslyInEventHandler = isInsideEventHandler; - - try { - isInsideEventHandler = true; - var type = typeof value === 'object' && value !== null ? value.type : ''; - invokeGuardedCallbackAndCatchFirstError(type, fn, undefined, value); - } finally { - isInsideEventHandler = previouslyInEventHandler; - } -} -function discreteUpdates(fn, a, b, c) { - var prevIsInsideEventHandler = isInsideEventHandler; - isInsideEventHandler = true; - - try { - return discreteUpdatesImpl(fn, a, b, c); - } finally { - isInsideEventHandler = prevIsInsideEventHandler; - - if (!isInsideEventHandler) { - finishEventHandler(); - } - } -} -var lastFlushedEventTimeStamp = 0; -function flushDiscreteUpdatesIfNeeded(timeStamp) { - // event.timeStamp isn't overly reliable due to inconsistencies in - // how different browsers have historically provided the time stamp. - // Some browsers provide high-resolution time stamps for all events, - // some provide low-resolution time stamps for all events. FF < 52 - // even mixes both time stamps together. Some browsers even report - // negative time stamps or time stamps that are 0 (iOS9) in some cases. - // Given we are only comparing two time stamps with equality (!==), - // we are safe from the resolution differences. If the time stamp is 0 - // we bail-out of preventing the flush, which can affect semantics, - // such as if an earlier flush removes or adds event listeners that - // are fired in the subsequent flush. However, this is the same - // behaviour as we had before this change, so the risks are low. - if (!isInsideEventHandler && (!enableFlareAPI || timeStamp === 0 || lastFlushedEventTimeStamp !== timeStamp)) { - lastFlushedEventTimeStamp = timeStamp; - flushDiscreteUpdatesImpl(); - } -} -function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) { - batchedUpdatesImpl = _batchedUpdatesImpl; - discreteUpdatesImpl = _discreteUpdatesImpl; - flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; - batchedEventUpdatesImpl = _batchedEventUpdatesImpl; -} - -var DiscreteEvent = 0; -var UserBlockingEvent = 1; -var ContinuousEvent = 2; - -// CommonJS interop named imports. - -var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; -var runWithPriority = Scheduler.unstable_runWithPriority; -var listenToResponderEventTypesImpl; -function setListenToResponderEventTypes(_listenToResponderEventTypesImpl) { - listenToResponderEventTypesImpl = _listenToResponderEventTypesImpl; -} -var rootEventTypesToEventResponderInstances = new Map(); -var DoNotPropagateToNextResponder = 0; -var PropagateToNextResponder = 1; -var currentTimeStamp = 0; -var currentInstance = null; -var currentDocument = null; -var currentPropagationBehavior = DoNotPropagateToNextResponder; -var eventResponderContext = { - dispatchEvent: function (eventValue, eventListener, eventPriority) { - validateResponderContext(); - validateEventValue(eventValue); - - switch (eventPriority) { - case DiscreteEvent: - { - flushDiscreteUpdatesIfNeeded(currentTimeStamp); - discreteUpdates(function () { - return executeUserEventHandler(eventListener, eventValue); - }); - break; - } - - case UserBlockingEvent: - { - runWithPriority(UserBlockingPriority, function () { - return executeUserEventHandler(eventListener, eventValue); - }); - break; - } - - case ContinuousEvent: - { - executeUserEventHandler(eventListener, eventValue); - break; - } - } - }, - isTargetWithinResponder: function (target) { - validateResponderContext(); - - if (target != null) { - var fiber = getClosestInstanceFromNode(target); - var responderFiber = currentInstance.fiber; - - while (fiber !== null) { - if (fiber === responderFiber || fiber.alternate === responderFiber) { - return true; - } - - fiber = fiber.return; - } - } - - return false; - }, - isTargetWithinResponderScope: function (target) { - validateResponderContext(); - var componentInstance = currentInstance; - var responder = componentInstance.responder; - - if (target != null) { - var fiber = getClosestInstanceFromNode(target); - var responderFiber = currentInstance.fiber; - - while (fiber !== null) { - if (fiber === responderFiber || fiber.alternate === responderFiber) { - return true; - } - - if (doesFiberHaveResponder(fiber, responder)) { - return false; - } - - fiber = fiber.return; - } - } - - return false; - }, - isTargetWithinNode: function (childTarget, parentTarget) { - validateResponderContext(); - var childFiber = getClosestInstanceFromNode(childTarget); - var parentFiber = getClosestInstanceFromNode(parentTarget); - - if (childFiber != null && parentFiber != null) { - var parentAlternateFiber = parentFiber.alternate; - var node = childFiber; - - while (node !== null) { - if (node === parentFiber || node === parentAlternateFiber) { - return true; - } - - node = node.return; - } - - return false; - } // Fallback to DOM APIs - - - return parentTarget.contains(childTarget); - }, - addRootEventTypes: function (rootEventTypes) { - validateResponderContext(); - listenToResponderEventTypesImpl(rootEventTypes, currentDocument); - - for (var i = 0; i < rootEventTypes.length; i++) { - var rootEventType = rootEventTypes[i]; - var eventResponderInstance = currentInstance; - registerRootEventType(rootEventType, eventResponderInstance); - } - }, - removeRootEventTypes: function (rootEventTypes) { - validateResponderContext(); - - for (var i = 0; i < rootEventTypes.length; i++) { - var rootEventType = rootEventTypes[i]; - var rootEventResponders = rootEventTypesToEventResponderInstances.get(rootEventType); - var rootEventTypesSet = currentInstance.rootEventTypes; - - if (rootEventTypesSet !== null) { - rootEventTypesSet.delete(rootEventType); - } - - if (rootEventResponders !== undefined) { - rootEventResponders.delete(currentInstance); - } - } - }, - getActiveDocument: getActiveDocument, - objectAssign: _assign, - getTimeStamp: function () { - validateResponderContext(); - return currentTimeStamp; - }, - isTargetWithinHostComponent: function (target, elementType) { - validateResponderContext(); - var fiber = getClosestInstanceFromNode(target); - - while (fiber !== null) { - if (fiber.tag === HostComponent && fiber.type === elementType) { - return true; - } - - fiber = fiber.return; - } - - return false; - }, - continuePropagation: function () { - currentPropagationBehavior = PropagateToNextResponder; - }, - enqueueStateRestore: enqueueStateRestore, - getResponderNode: function () { - validateResponderContext(); - var responderFiber = currentInstance.fiber; - - if (responderFiber.tag === ScopeComponent) { - return null; - } - - return responderFiber.stateNode; - } -}; - -function validateEventValue(eventValue) { - if (typeof eventValue === 'object' && eventValue !== null) { - var target = eventValue.target, - type = eventValue.type, - timeStamp = eventValue.timeStamp; - - if (target == null || type == null || timeStamp == null) { - throw new Error('context.dispatchEvent: "target", "timeStamp", and "type" fields on event object are required.'); - } - - var showWarning = function (name) { - { - warning$1(false, '%s is not available on event objects created from event responder modules (React Flare). ' + 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.%s }`', name, name); - } - }; - - eventValue.isDefaultPrevented = function () { - { - showWarning('isDefaultPrevented()'); - } - }; - - eventValue.isPropagationStopped = function () { - { - showWarning('isPropagationStopped()'); - } - }; // $FlowFixMe: we don't need value, Flow thinks we do - - - Object.defineProperty(eventValue, 'nativeEvent', { - get: function () { - { - showWarning('nativeEvent'); - } - } - }); - } -} - -function doesFiberHaveResponder(fiber, responder) { - var tag = fiber.tag; - - if (tag === HostComponent || tag === ScopeComponent) { - var dependencies = fiber.dependencies; - - if (dependencies !== null) { - var respondersMap = dependencies.responders; - - if (respondersMap !== null && respondersMap.has(responder)) { - return true; - } - } - } - - return false; -} - -function getActiveDocument() { - return currentDocument; -} - -function createDOMResponderEvent(topLevelType, nativeEvent, nativeEventTarget, passive, passiveSupported) { - var _ref = nativeEvent, - buttons = _ref.buttons, - pointerType = _ref.pointerType; - var eventPointerType = ''; - - if (pointerType !== undefined) { - eventPointerType = pointerType; - } else if (nativeEvent.key !== undefined) { - eventPointerType = 'keyboard'; - } else if (buttons !== undefined) { - eventPointerType = 'mouse'; - } else if (nativeEvent.changedTouches !== undefined) { - eventPointerType = 'touch'; - } - - return { - nativeEvent: nativeEvent, - passive: passive, - passiveSupported: passiveSupported, - pointerType: eventPointerType, - target: nativeEventTarget, - type: topLevelType - }; -} - -function responderEventTypesContainType(eventTypes, type) { - for (var i = 0, len = eventTypes.length; i < len; i++) { - if (eventTypes[i] === type) { - return true; - } - } - - return false; -} - -function validateResponderTargetEventTypes(eventType, responder) { - var targetEventTypes = responder.targetEventTypes; // Validate the target event type exists on the responder - - if (targetEventTypes !== null) { - return responderEventTypesContainType(targetEventTypes, eventType); - } - - return false; -} - -function traverseAndHandleEventResponderInstances(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags) { - var isPassiveEvent = (eventSystemFlags & IS_PASSIVE) !== 0; - var isPassiveSupported = (eventSystemFlags & PASSIVE_NOT_SUPPORTED) === 0; - var isPassive = isPassiveEvent || !isPassiveSupported; - var eventType = isPassive ? topLevelType : topLevelType + '_active'; // Trigger event responders in this order: - // - Bubble target responder phase - // - Root responder phase - - var visitedResponders = new Set(); - var responderEvent = createDOMResponderEvent(topLevelType, nativeEvent, nativeEventTarget, isPassiveEvent, isPassiveSupported); - var node = targetFiber; - var insidePortal = false; - - while (node !== null) { - var _node = node, - dependencies = _node.dependencies, - tag = _node.tag; - - if (tag === HostPortal) { - insidePortal = true; - } else if ((tag === HostComponent || tag === ScopeComponent) && dependencies !== null) { - var respondersMap = dependencies.responders; - - if (respondersMap !== null) { - var responderInstances = Array.from(respondersMap.values()); - - for (var i = 0, length = responderInstances.length; i < length; i++) { - var responderInstance = responderInstances[i]; - var props = responderInstance.props, - responder = responderInstance.responder, - state = responderInstance.state; - - if (!visitedResponders.has(responder) && validateResponderTargetEventTypes(eventType, responder) && (!insidePortal || responder.targetPortalPropagation)) { - visitedResponders.add(responder); - var onEvent = responder.onEvent; - - if (onEvent !== null) { - currentInstance = responderInstance; - onEvent(responderEvent, eventResponderContext, props, state); - - if (currentPropagationBehavior === PropagateToNextResponder) { - visitedResponders.delete(responder); - currentPropagationBehavior = DoNotPropagateToNextResponder; - } - } - } - } - } - } - - node = node.return; - } // Root phase - - - var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(eventType); - - if (rootEventResponderInstances !== undefined) { - var _responderInstances = Array.from(rootEventResponderInstances); - - for (var _i = 0; _i < _responderInstances.length; _i++) { - var _responderInstance = _responderInstances[_i]; - var props = _responderInstance.props, - responder = _responderInstance.responder, - state = _responderInstance.state; - var onRootEvent = responder.onRootEvent; - - if (onRootEvent !== null) { - currentInstance = _responderInstance; - onRootEvent(responderEvent, eventResponderContext, props, state); - } - } - } -} - -function mountEventResponder(responder, responderInstance, props, state) { - var onMount = responder.onMount; - - if (onMount !== null) { - var previousInstance = currentInstance; - currentInstance = responderInstance; - - try { - batchedEventUpdates(function () { - onMount(eventResponderContext, props, state); - }); - } finally { - currentInstance = previousInstance; - } - } -} -function unmountEventResponder(responderInstance) { - var responder = responderInstance.responder; - var onUnmount = responder.onUnmount; - - if (onUnmount !== null) { - var props = responderInstance.props, - state = responderInstance.state; - var previousInstance = currentInstance; - currentInstance = responderInstance; - - try { - batchedEventUpdates(function () { - onUnmount(eventResponderContext, props, state); - }); - } finally { - currentInstance = previousInstance; - } - } - - var rootEventTypesSet = responderInstance.rootEventTypes; - - if (rootEventTypesSet !== null) { - var rootEventTypes = Array.from(rootEventTypesSet); - - for (var i = 0; i < rootEventTypes.length; i++) { - var topLevelEventType = rootEventTypes[i]; - var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(topLevelEventType); - - if (rootEventResponderInstances !== undefined) { - rootEventResponderInstances.delete(responderInstance); - } - } - } -} - -function validateResponderContext() { - if (!(currentInstance !== null)) { - { - throw Error("An event responder context was used outside of an event cycle."); - } - } -} - -function dispatchEventForResponderEventSystem(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags) { - if (enableFlareAPI) { - var previousInstance = currentInstance; - var previousTimeStamp = currentTimeStamp; - var previousDocument = currentDocument; - var previousPropagationBehavior = currentPropagationBehavior; - currentPropagationBehavior = DoNotPropagateToNextResponder; // nodeType 9 is DOCUMENT_NODE - - currentDocument = nativeEventTarget.nodeType === 9 ? nativeEventTarget : nativeEventTarget.ownerDocument; // We might want to control timeStamp another way here - - currentTimeStamp = nativeEvent.timeStamp; - - try { - batchedEventUpdates(function () { - traverseAndHandleEventResponderInstances(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags); - }); - } finally { - currentInstance = previousInstance; - currentTimeStamp = previousTimeStamp; - currentDocument = previousDocument; - currentPropagationBehavior = previousPropagationBehavior; - } - } -} -function addRootEventTypesForResponderInstance(responderInstance, rootEventTypes) { - for (var i = 0; i < rootEventTypes.length; i++) { - var rootEventType = rootEventTypes[i]; - registerRootEventType(rootEventType, responderInstance); - } -} - -function registerRootEventType(rootEventType, eventResponderInstance) { - var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(rootEventType); - - if (rootEventResponderInstances === undefined) { - rootEventResponderInstances = new Set(); - rootEventTypesToEventResponderInstances.set(rootEventType, rootEventResponderInstances); - } - - var rootEventTypesSet = eventResponderInstance.rootEventTypes; - - if (rootEventTypesSet === null) { - rootEventTypesSet = eventResponderInstance.rootEventTypes = new Set(); - } - - if (!!rootEventTypesSet.has(rootEventType)) { - { - throw Error("addRootEventTypes() found a duplicate root event type of \"" + rootEventType + "\". This might be because the event type exists in the event responder \"rootEventTypes\" array or because of a previous addRootEventTypes() using this root event type."); - } - } - - rootEventTypesSet.add(rootEventType); - rootEventResponderInstances.add(eventResponderInstance); -} - -// A reserved attribute. -// It is handled by React separately and shouldn't be written to the DOM. -var RESERVED = 0; // A simple string attribute. -// Attributes that aren't in the whitelist are presumed to have this type. - -var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called -// "enumerated" attributes with "true" and "false" as possible values. -// When true, it should be set to a "true" string. -// When false, it should be set to a "false" string. - -var BOOLEANISH_STRING = 2; // A real boolean attribute. -// When true, it should be present (set either to an empty string or its name). -// When false, it should be omitted. - -var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value. -// When true, it should be present (set either to an empty string or its name). -// When false, it should be omitted. -// For any other value, should be present with that value. - -var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric. -// When falsy, it should be removed. - -var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric. -// When falsy, it should be removed. - -var POSITIVE_NUMERIC = 6; - -/* eslint-disable max-len */ -var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; -/* eslint-enable max-len */ - -var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; - -var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; -var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); -var hasOwnProperty = Object.prototype.hasOwnProperty; -var illegalAttributeNameCache = {}; -var validatedAttributeNameCache = {}; -function isAttributeNameSafe(attributeName) { - if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) { - return true; - } - - if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) { - return false; - } - - if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { - validatedAttributeNameCache[attributeName] = true; - return true; - } - - illegalAttributeNameCache[attributeName] = true; - - { - warning$1(false, 'Invalid attribute name: `%s`', attributeName); - } - - return false; -} -function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) { - if (propertyInfo !== null) { - return propertyInfo.type === RESERVED; - } - - if (isCustomComponentTag) { - return false; - } - - if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { - return true; - } - - return false; -} -function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { - if (propertyInfo !== null && propertyInfo.type === RESERVED) { - return false; - } - - switch (typeof value) { - case 'function': // $FlowIssue symbol is perfectly valid here - - case 'symbol': - // eslint-disable-line - return true; - - case 'boolean': - { - if (isCustomComponentTag) { - return false; - } - - if (propertyInfo !== null) { - return !propertyInfo.acceptsBooleans; - } else { - var prefix = name.toLowerCase().slice(0, 5); - return prefix !== 'data-' && prefix !== 'aria-'; - } - } - - default: - return false; - } -} -function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { - if (value === null || typeof value === 'undefined') { - return true; - } - - if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) { - return true; - } - - if (isCustomComponentTag) { - return false; - } - - if (propertyInfo !== null) { - switch (propertyInfo.type) { - case BOOLEAN: - return !value; - - case OVERLOADED_BOOLEAN: - return value === false; - - case NUMERIC: - return isNaN(value); - - case POSITIVE_NUMERIC: - return isNaN(value) || value < 1; - } - } - - return false; -} -function getPropertyInfo(name) { - return properties.hasOwnProperty(name) ? properties[name] : null; -} - -function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) { - this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; - this.attributeName = attributeName; - this.attributeNamespace = attributeNamespace; - this.mustUseProperty = mustUseProperty; - this.propertyName = name; - this.type = type; - this.sanitizeURL = sanitizeURL; -} // When adding attributes to this list, be sure to also add them to -// the `possibleStandardNames` module to ensure casing and incorrect -// name warnings. - - -var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM. - -['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular -// elements (not just inputs). Now that ReactDOMInput assigns to the -// defaultValue property -- do we need this? -'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty - name, // attributeName - null, // attributeNamespace - false); -}); // A few React string attributes have a different name. -// This is a mapping from React prop names to the attribute names. - -[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { - var name = _ref[0], - attributeName = _ref[1]; - properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty - attributeName, // attributeName - null, // attributeNamespace - false); -}); // These are "enumerated" HTML attributes that accept "true" and "false". -// In React, we let users pass `true` and `false` even though technically -// these aren't boolean attributes (they are coerced to strings). - -['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty - name.toLowerCase(), // attributeName - null, // attributeNamespace - false); -}); // These are "enumerated" SVG attributes that accept "true" and "false". -// In React, we let users pass `true` and `false` even though technically -// these aren't boolean attributes (they are coerced to strings). -// Since these are SVG attributes, their attribute names are case-sensitive. - -['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty - name, // attributeName - null, // attributeNamespace - false); -}); // These are HTML boolean attributes. - -['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM -// on the client side because the browsers are inconsistent. Instead we call focus(). -'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata -'itemScope'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty - name.toLowerCase(), // attributeName - null, // attributeNamespace - false); -}); // These are the few React props that we set as DOM properties -// rather than attributes. These are all booleans. - -['checked', // Note: `option.selected` is not updated if `select.multiple` is -// disabled with `removeAttribute`. We have special logic for handling this. -'multiple', 'muted', 'selected'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty - name, // attributeName - null, // attributeNamespace - false); -}); // These are HTML attributes that are "overloaded booleans": they behave like -// booleans, but can also accept a string value. - -['capture', 'download'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty - name, // attributeName - null, // attributeNamespace - false); -}); // These are HTML attributes that must be positive numbers. - -['cols', 'rows', 'size', 'span'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty - name, // attributeName - null, // attributeNamespace - false); -}); // These are HTML attributes that must be numbers. - -['rowSpan', 'start'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty - name.toLowerCase(), // attributeName - null, // attributeNamespace - false); -}); -var CAMELIZE = /[\-\:]([a-z])/g; - -var capitalize = function (token) { - return token[1].toUpperCase(); -}; // This is a list of all SVG attributes that need special casing, namespacing, -// or boolean value assignment. Regular attributes that just accept strings -// and have the same names are omitted, just like in the HTML whitelist. -// Some of these attributes can be hard to find. This list was created by -// scrapping the MDN documentation. - - -['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height'].forEach(function (attributeName) { - var name = attributeName.replace(CAMELIZE, capitalize); - properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty - attributeName, null, // attributeNamespace - false); -}); // String SVG attributes with the xlink namespace. - -['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) { - var name = attributeName.replace(CAMELIZE, capitalize); - properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty - attributeName, 'http://www.w3.org/1999/xlink', false); -}); // String SVG attributes with the xml namespace. - -['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) { - var name = attributeName.replace(CAMELIZE, capitalize); - properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty - attributeName, 'http://www.w3.org/XML/1998/namespace', false); -}); // These attribute exists both in HTML and SVG. -// The attribute name is case-sensitive in SVG so we can't just use -// the React name like we do for attributes that exist only in HTML. - -['tabIndex', 'crossOrigin'].forEach(function (attributeName) { - properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty - attributeName.toLowerCase(), // attributeName - null, // attributeNamespace - false); -}); // These attributes accept URLs. These must not allow javascript: URLS. -// These will also need to accept Trusted Types object in the future. - -var xlinkHref = 'xlinkHref'; -properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty -'xlink:href', 'http://www.w3.org/1999/xlink', true); -['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { - properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty - attributeName.toLowerCase(), // attributeName - null, // attributeNamespace - true); -}); - -var ReactDebugCurrentFrame$1 = null; - -{ - ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; -} // A javascript: URL can contain leading C0 control or \u0020 SPACE, -// and any newline or tab are filtered out as if they're not part of the URL. -// https://url.spec.whatwg.org/#url-parsing -// Tab or newline are defined as \r\n\t: -// https://infra.spec.whatwg.org/#ascii-tab-or-newline -// A C0 control is a code point in the range \u0000 NULL to \u001F -// INFORMATION SEPARATOR ONE, inclusive: -// https://infra.spec.whatwg.org/#c0-control-or-space - -/* eslint-disable max-len */ - - -var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i; -var didWarn = false; - -function sanitizeURL(url) { - if (disableJavaScriptURLs) { - if (!!isJavaScriptProtocol.test(url)) { - { - throw Error("React has blocked a javascript: URL as a security precaution." + (ReactDebugCurrentFrame$1.getStackAddendum())); - } - } - } else if (true && !didWarn && isJavaScriptProtocol.test(url)) { - didWarn = true; - warning$1(false, 'A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url)); - } -} - -// Flow does not allow string concatenation of most non-string types. To work -// around this limitation, we use an opaque type that can only be obtained by -// passing the value through getToStringValue first. -function toString(value) { - return '' + value; -} -function getToStringValue(value) { - switch (typeof value) { - case 'boolean': - case 'number': - case 'object': - case 'string': - case 'undefined': - return value; - - default: - // function, symbol are assigned as empty strings - return ''; - } -} -/** Trusted value is a wrapper for "safe" values which can be assigned to DOM execution sinks. */ - -/** - * We allow passing objects with toString method as element attributes or in dangerouslySetInnerHTML - * and we do validations that the value is safe. Once we do validation we want to use the validated - * value instead of the object (because object.toString may return something else on next call). - * - * If application uses Trusted Types we don't stringify trusted values, but preserve them as objects. - */ -var toStringOrTrustedType = toString; - -if (enableTrustedTypesIntegration && typeof trustedTypes !== 'undefined') { - toStringOrTrustedType = function (value) { - if (typeof value === 'object' && (trustedTypes.isHTML(value) || trustedTypes.isScript(value) || trustedTypes.isScriptURL(value) || - /* TrustedURLs are deprecated and will be removed soon: https://github.com/WICG/trusted-types/pull/204 */ - trustedTypes.isURL && trustedTypes.isURL(value))) { - // Pass Trusted Types through. - return value; - } - - return toString(value); - }; -} - -/** - * Set attribute for a node. The attribute value can be either string or - * Trusted value (if application uses Trusted Types). - */ -function setAttribute(node, attributeName, attributeValue) { - node.setAttribute(attributeName, attributeValue); -} -/** - * Set attribute with namespace for a node. The attribute value can be either string or - * Trusted value (if application uses Trusted Types). - */ - -function setAttributeNS(node, attributeNamespace, attributeName, attributeValue) { - node.setAttributeNS(attributeNamespace, attributeName, attributeValue); -} - -/** - * Get the value for a property on a node. Only used in DEV for SSR validation. - * The "expected" argument is used as a hint of what the expected value is. - * Some properties have multiple equivalent values. - */ -function getValueForProperty(node, name, expected, propertyInfo) { - { - if (propertyInfo.mustUseProperty) { - var propertyName = propertyInfo.propertyName; - return node[propertyName]; - } else { - if (!disableJavaScriptURLs && propertyInfo.sanitizeURL) { - // If we haven't fully disabled javascript: URLs, and if - // the hydration is successful of a javascript: URL, we - // still want to warn on the client. - sanitizeURL('' + expected); - } - - var attributeName = propertyInfo.attributeName; - var stringValue = null; - - if (propertyInfo.type === OVERLOADED_BOOLEAN) { - if (node.hasAttribute(attributeName)) { - var value = node.getAttribute(attributeName); - - if (value === '') { - return true; - } - - if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { - return value; - } - - if (value === '' + expected) { - return expected; - } - - return value; - } - } else if (node.hasAttribute(attributeName)) { - if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { - // We had an attribute but shouldn't have had one, so read it - // for the error message. - return node.getAttribute(attributeName); - } - - if (propertyInfo.type === BOOLEAN) { - // If this was a boolean, it doesn't matter what the value is - // the fact that we have it is the same as the expected. - return expected; - } // Even if this property uses a namespace we use getAttribute - // because we assume its namespaced name is the same as our config. - // To use getAttributeNS we need the local name which we don't have - // in our config atm. - - - stringValue = node.getAttribute(attributeName); - } - - if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { - return stringValue === null ? expected : stringValue; - } else if (stringValue === '' + expected) { - return expected; - } else { - return stringValue; - } - } - } -} -/** - * Get the value for a attribute on a node. Only used in DEV for SSR validation. - * The third argument is used as a hint of what the expected value is. Some - * attributes have multiple equivalent values. - */ - -function getValueForAttribute(node, name, expected) { - { - if (!isAttributeNameSafe(name)) { - return; - } - - if (!node.hasAttribute(name)) { - return expected === undefined ? undefined : null; - } - - var value = node.getAttribute(name); - - if (value === '' + expected) { - return expected; - } - - return value; - } -} -/** - * Sets the value for a property on a node. - * - * @param {DOMElement} node - * @param {string} name - * @param {*} value - */ - -function setValueForProperty(node, name, value, isCustomComponentTag) { - var propertyInfo = getPropertyInfo(name); - - if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) { - return; - } - - if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { - value = null; - } // If the prop isn't in the special list, treat it as a simple attribute. - - - if (isCustomComponentTag || propertyInfo === null) { - if (isAttributeNameSafe(name)) { - var _attributeName = name; - - if (value === null) { - node.removeAttribute(_attributeName); - } else { - setAttribute(node, _attributeName, toStringOrTrustedType(value)); - } - } - - return; - } - - var mustUseProperty = propertyInfo.mustUseProperty; - - if (mustUseProperty) { - var propertyName = propertyInfo.propertyName; - - if (value === null) { - var type = propertyInfo.type; - node[propertyName] = type === BOOLEAN ? false : ''; - } else { - // Contrary to `setAttribute`, object properties are properly - // `toString`ed by IE8/9. - node[propertyName] = value; - } - - return; - } // The rest are treated as attributes with special cases. - - - var attributeName = propertyInfo.attributeName, - attributeNamespace = propertyInfo.attributeNamespace; - - if (value === null) { - node.removeAttribute(attributeName); - } else { - var _type = propertyInfo.type; - var attributeValue; - - if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) { - // If attribute type is boolean, we know for sure it won't be an execution sink - // and we won't require Trusted Type here. - attributeValue = ''; - } else { - // `setAttribute` with objects becomes only `[object]` in IE8/9, - // ('' + value) makes it output the correct toString()-value. - attributeValue = toStringOrTrustedType(value); - - if (propertyInfo.sanitizeURL) { - sanitizeURL(attributeValue.toString()); - } - } - - if (attributeNamespace) { - setAttributeNS(node, attributeNamespace, attributeName, attributeValue); - } else { - setAttribute(node, attributeName, attributeValue); - } - } -} - -var ReactDebugCurrentFrame$2 = null; -var ReactControlledValuePropTypes = { - checkPropTypes: null -}; - -{ - ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame; - var hasReadOnlyValue = { - button: true, - checkbox: true, - image: true, - hidden: true, - radio: true, - reset: true, - submit: true - }; - var propTypes = { - value: function (props, propName, componentName) { - if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) { - return null; - } - - return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); - }, - checked: function (props, propName, componentName) { - if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) { - return null; - } - - return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); - } - }; - /** - * Provide a linked `value` attribute for controlled forms. You should not use - * this outside of the ReactDOM controlled form components. - */ - - ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) { - checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum); - }; -} - -function isCheckable(elem) { - var type = elem.type; - var nodeName = elem.nodeName; - return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); -} - -function getTracker(node) { - return node._valueTracker; -} - -function detachTracker(node) { - node._valueTracker = null; -} - -function getValueFromNode(node) { - var value = ''; - - if (!node) { - return value; - } - - if (isCheckable(node)) { - value = node.checked ? 'true' : 'false'; - } else { - value = node.value; - } - - return value; -} - -function trackValueOnNode(node) { - var valueField = isCheckable(node) ? 'checked' : 'value'; - var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); - var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail - // and don't track value will cause over reporting of changes, - // but it's better then a hard failure - // (needed for certain tests that spyOn input values and Safari) - - if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { - return; - } - - var get = descriptor.get, - set = descriptor.set; - Object.defineProperty(node, valueField, { - configurable: true, - get: function () { - return get.call(this); - }, - set: function (value) { - currentValue = '' + value; - set.call(this, value); - } - }); // We could've passed this the first time - // but it triggers a bug in IE11 and Edge 14/15. - // Calling defineProperty() again should be equivalent. - // https://github.com/facebook/react/issues/11768 - - Object.defineProperty(node, valueField, { - enumerable: descriptor.enumerable - }); - var tracker = { - getValue: function () { - return currentValue; - }, - setValue: function (value) { - currentValue = '' + value; - }, - stopTracking: function () { - detachTracker(node); - delete node[valueField]; - } - }; - return tracker; -} - -function track(node) { - if (getTracker(node)) { - return; - } // TODO: Once it's just Fiber we can move this to node._wrapperState - - - node._valueTracker = trackValueOnNode(node); -} -function updateValueIfChanged(node) { - if (!node) { - return false; - } - - var tracker = getTracker(node); // if there is no tracker at this point it's unlikely - // that trying again will succeed - - if (!tracker) { - return true; - } - - var lastValue = tracker.getValue(); - var nextValue = getValueFromNode(node); - - if (nextValue !== lastValue) { - tracker.setValue(nextValue); - return true; - } - - return false; -} - -// TODO: direct imports like some-package/src/* are bad. Fix me. -var didWarnValueDefaultValue = false; -var didWarnCheckedDefaultChecked = false; -var didWarnControlledToUncontrolled = false; -var didWarnUncontrolledToControlled = false; - -function isControlled(props) { - var usesChecked = props.type === 'checkbox' || props.type === 'radio'; - return usesChecked ? props.checked != null : props.value != null; -} -/** - * Implements an host component that allows setting these optional - * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. - * - * If `checked` or `value` are not supplied (or null/undefined), user actions - * that affect the checked state or value will trigger updates to the element. - * - * If they are supplied (and not null/undefined), the rendered element will not - * trigger updates to the element. Instead, the props must change in order for - * the rendered element to be updated. - * - * The rendered element will be initialized as unchecked (or `defaultChecked`) - * with an empty value (or `defaultValue`). - * - * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html - */ - - -function getHostProps(element, props) { - var node = element; - var checked = props.checked; - - var hostProps = _assign({}, props, { - defaultChecked: undefined, - defaultValue: undefined, - value: undefined, - checked: checked != null ? checked : node._wrapperState.initialChecked - }); - - return hostProps; -} -function initWrapperState(element, props) { - { - ReactControlledValuePropTypes.checkPropTypes('input', props); - - if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { - warning$1(false, '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); - didWarnCheckedDefaultChecked = true; - } - - if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { - warning$1(false, '%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); - didWarnValueDefaultValue = true; - } - } - - var node = element; - var defaultValue = props.defaultValue == null ? '' : props.defaultValue; - node._wrapperState = { - initialChecked: props.checked != null ? props.checked : props.defaultChecked, - initialValue: getToStringValue(props.value != null ? props.value : defaultValue), - controlled: isControlled(props) - }; -} -function updateChecked(element, props) { - var node = element; - var checked = props.checked; - - if (checked != null) { - setValueForProperty(node, 'checked', checked, false); - } -} -function updateWrapper(element, props) { - var node = element; - - { - var controlled = isControlled(props); - - if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { - warning$1(false, 'A component is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type); - didWarnUncontrolledToControlled = true; - } - - if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { - warning$1(false, 'A component is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type); - didWarnControlledToUncontrolled = true; - } - } - - updateChecked(element, props); - var value = getToStringValue(props.value); - var type = props.type; - - if (value != null) { - if (type === 'number') { - if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible. - // eslint-disable-next-line - node.value != value) { - node.value = toString(value); - } - } else if (node.value !== toString(value)) { - node.value = toString(value); - } - } else if (type === 'submit' || type === 'reset') { - // Submit/reset inputs need the attribute removed completely to avoid - // blank-text buttons. - node.removeAttribute('value'); - return; - } - - if (disableInputAttributeSyncing) { - // When not syncing the value attribute, React only assigns a new value - // whenever the defaultValue React prop has changed. When not present, - // React does nothing - if (props.hasOwnProperty('defaultValue')) { - setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); - } - } else { - // When syncing the value attribute, the value comes from a cascade of - // properties: - // 1. The value React property - // 2. The defaultValue React property - // 3. Otherwise there should be no change - if (props.hasOwnProperty('value')) { - setDefaultValue(node, props.type, value); - } else if (props.hasOwnProperty('defaultValue')) { - setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); - } - } - - if (disableInputAttributeSyncing) { - // When not syncing the checked attribute, the attribute is directly - // controllable from the defaultValue React property. It needs to be - // updated as new props come in. - if (props.defaultChecked == null) { - node.removeAttribute('checked'); - } else { - node.defaultChecked = !!props.defaultChecked; - } - } else { - // When syncing the checked attribute, it only changes when it needs - // to be removed, such as transitioning from a checkbox into a text input - if (props.checked == null && props.defaultChecked != null) { - node.defaultChecked = !!props.defaultChecked; - } - } -} -function postMountWrapper(element, props, isHydrating) { - var node = element; // Do not assign value if it is already set. This prevents user text input - // from being lost during SSR hydration. - - if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { - var type = props.type; - var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the - // default value provided by the browser. See: #12872 - - if (isButton && (props.value === undefined || props.value === null)) { - return; - } - - var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input - // from being lost during SSR hydration. - - if (!isHydrating) { - if (disableInputAttributeSyncing) { - var value = getToStringValue(props.value); // When not syncing the value attribute, the value property points - // directly to the React prop. Only assign it if it exists. - - if (value != null) { - // Always assign on buttons so that it is possible to assign an - // empty string to clear button text. - // - // Otherwise, do not re-assign the value property if is empty. This - // potentially avoids a DOM write and prevents Firefox (~60.0.1) from - // prematurely marking required inputs as invalid. Equality is compared - // to the current value in case the browser provided value is not an - // empty string. - if (isButton || value !== node.value) { - node.value = toString(value); - } - } - } else { - // When syncing the value attribute, the value property should use - // the wrapperState._initialValue property. This uses: - // - // 1. The value React property when present - // 2. The defaultValue React property when present - // 3. An empty string - if (initialValue !== node.value) { - node.value = initialValue; - } - } - } - - if (disableInputAttributeSyncing) { - // When not syncing the value attribute, assign the value attribute - // directly from the defaultValue React property (when present) - var defaultValue = getToStringValue(props.defaultValue); - - if (defaultValue != null) { - node.defaultValue = toString(defaultValue); - } - } else { - // Otherwise, the value attribute is synchronized to the property, - // so we assign defaultValue to the same thing as the value property - // assignment step above. - node.defaultValue = initialValue; - } - } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug - // this is needed to work around a chrome bug where setting defaultChecked - // will sometimes influence the value of checked (even after detachment). - // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 - // We need to temporarily unset name to avoid disrupting radio button groups. - - - var name = node.name; - - if (name !== '') { - node.name = ''; - } - - if (disableInputAttributeSyncing) { - // When not syncing the checked attribute, the checked property - // never gets assigned. It must be manually set. We don't want - // to do this when hydrating so that existing user input isn't - // modified - if (!isHydrating) { - updateChecked(element, props); - } // Only assign the checked attribute if it is defined. This saves - // a DOM write when controlling the checked attribute isn't needed - // (text inputs, submit/reset) - - - if (props.hasOwnProperty('defaultChecked')) { - node.defaultChecked = !node.defaultChecked; - node.defaultChecked = !!props.defaultChecked; - } - } else { - // When syncing the checked attribute, both the checked property and - // attribute are assigned at the same time using defaultChecked. This uses: - // - // 1. The checked React property when present - // 2. The defaultChecked React property when present - // 3. Otherwise, false - node.defaultChecked = !node.defaultChecked; - node.defaultChecked = !!node._wrapperState.initialChecked; - } - - if (name !== '') { - node.name = name; - } -} -function restoreControlledState$1(element, props) { - var node = element; - updateWrapper(node, props); - updateNamedCousins(node, props); -} - -function updateNamedCousins(rootNode, props) { - var name = props.name; - - if (props.type === 'radio' && name != null) { - var queryRoot = rootNode; - - while (queryRoot.parentNode) { - queryRoot = queryRoot.parentNode; - } // If `rootNode.form` was non-null, then we could try `form.elements`, - // but that sometimes behaves strangely in IE8. We could also try using - // `form.getElementsByName`, but that will only return direct children - // and won't include inputs that use the HTML5 `form=` attribute. Since - // the input might not even be in a form. It might not even be in the - // document. Let's just use the local `querySelectorAll` to ensure we don't - // miss anything. - - - var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); - - for (var i = 0; i < group.length; i++) { - var otherNode = group[i]; - - if (otherNode === rootNode || otherNode.form !== rootNode.form) { - continue; - } // This will throw if radio buttons rendered by different copies of React - // and the same name are rendered into the same form (same as #1939). - // That's probably okay; we don't support it just as we don't support - // mixing React radio buttons with non-React ones. - - - var otherProps = getFiberCurrentPropsFromNode$1(otherNode); - - if (!otherProps) { - { - throw Error("ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported."); - } - } // We need update the tracked value on the named cousin since the value - // was changed but the input saw no event or value set - - - updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that - // was previously checked to update will cause it to be come re-checked - // as appropriate. - - updateWrapper(otherNode, otherProps); - } - } -} // In Chrome, assigning defaultValue to certain input types triggers input validation. -// For number inputs, the display value loses trailing decimal points. For email inputs, -// Chrome raises "The specified value is not a valid email address". -// -// Here we check to see if the defaultValue has actually changed, avoiding these problems -// when the user is inputting text -// -// https://github.com/facebook/react/issues/7253 - - -function setDefaultValue(node, type, value) { - if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js - type !== 'number' || node.ownerDocument.activeElement !== node) { - if (value == null) { - node.defaultValue = toString(node._wrapperState.initialValue); - } else if (node.defaultValue !== toString(value)) { - node.defaultValue = toString(value); - } - } -} - -var didWarnSelectedSetOnOption = false; -var didWarnInvalidChild = false; - -function flattenChildren(children) { - var content = ''; // Flatten children. We'll warn if they are invalid - // during validateProps() which runs for hydration too. - // Note that this would throw on non-element objects. - // Elements are stringified (which is normally irrelevant - // but matters for ). - - React.Children.forEach(children, function (child) { - if (child == null) { - return; - } - - content += child; // Note: we don't warn about invalid children here. - // Instead, this is done separately below so that - // it happens during the hydration codepath too. - }); - return content; -} -/** - * Implements an