Commit ac3fc47e authored by 박상호's avatar 박상호 🎼
Browse files

from jw

parent fdf4d71d
## 15.7.2
* [Fix] ensure nullish values in `oneOf` do not crash ([#256](https://github.com/facebook/prop-types/issues/256))
* [Fix] move `loose-envify` back to production deps, for browerify usage ([#203](https://github.com/facebook/prop-types/issues/203))
## 15.7.1
* [Fix] avoid template literal syntax ([#255](https://github.com/facebook/prop-types/issues/255), [#254](https://github.com/facebook/prop-types/issues/254))
## 15.7.0
* [New] Add `.elementType` ([#211](https://github.com/facebook/prop-types/pull/211))
* [New] add `PropTypes.resetWarningCache` ([#178](https://github.com/facebook/prop-types/pull/178))
* `oneOf`: improve warning when multiple arguments are supplied ([#244](https://github.com/facebook/prop-types/pull/244))
* Fix `oneOf` when used with Symbols ([#224](https://github.com/facebook/prop-types/pull/224))
* Avoid relying on `hasOwnProperty` being present on values' prototypes ([#112](https://github.com/facebook/prop-types/pull/112), [#187](https://github.com/facebook/prop-types/pull/187))
* Improve readme ([#248](https://github.com/facebook/prop-types/pull/248), [#233](https://github.com/facebook/prop-types/pull/233))
* Clean up mistaken runtime dep, swap envify for loose-envify ([#204](https://github.com/facebook/prop-types/pull/204))
## 15.6.2
* Remove the `fbjs` dependency by inlining some helpers from it ([#194](https://github.com/facebook/prop-types/pull/194)))
## 15.6.1
* Fix an issue where outdated BSD license headers were still present in the published bundle [#162](https://github.com/facebook/prop-types/issues/162)
## 15.6.0
* Switch from BSD + Patents to MIT license
* Add PropTypes.exact, like PropTypes.shape but warns on extra object keys. ([@thejameskyle](https://github.com/thejameskyle) and [@aweary](https://github.com/aweary) in [#41](https://github.com/facebook/prop-types/pull/41) and [#87](https://github.com/facebook/prop-types/pull/87))
## 15.5.10
* Fix a false positive warning when using a production UMD build of a third-party library with a DEV version of React. ([@gaearon](https://github.com/gaearon) in [#50](https://github.com/facebook/prop-types/pull/50))
## 15.5.9
* Add `loose-envify` Browserify transform for users who don't envify globally. ([@mridgway](https://github.com/mridgway) in [#45](https://github.com/facebook/prop-types/pull/45))
## 15.5.8
* Limit the manual PropTypes call warning count because it has false positives with React versions earlier than 15.2.0 in the 15.x branch and 0.14.9 in the 0.14.x branch. ([@gaearon](https://github.com/gaearon) in [#26](https://github.com/facebook/prop-types/pull/26))
## 15.5.7
* **Critical Bugfix:** Fix an accidental breaking change that caused errors in production when used through `React.PropTypes`. ([@gaearon](https://github.com/gaearon) in [#20](https://github.com/facebook/prop-types/pull/20))
* Improve the size of production UMD build. ([@aweary](https://github.com/aweary) in [38ba18](https://github.com/facebook/prop-types/commit/38ba18a4a8f705f4b2b33c88204573ddd604f2d6) and [7882a7](https://github.com/facebook/prop-types/commit/7882a7285293db5f284bcf559b869fd2cd4c44d4))
## 15.5.6
**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**
* Fix a markdown issue in README. ([@bvaughn](https://github.com/bvaughn) in [174f77](https://github.com/facebook/prop-types/commit/174f77a50484fa628593e84b871fb40eed78b69a))
## 15.5.5
**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**
* Add missing documentation and license files. ([@bvaughn](https://github.com/bvaughn) in [0a53d3](https://github.com/facebook/prop-types/commit/0a53d3a34283ae1e2d3aa396632b6dc2a2061e6a))
## 15.5.4
**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**
* Reduce the size of the UMD Build. ([@acdlite](https://github.com/acdlite) in [31e9344](https://github.com/facebook/prop-types/commit/31e9344ca3233159928da66295da17dad82db1a8))
* Remove bad package url. ([@ljharb](https://github.com/ljharb) in [158198f](https://github.com/facebook/prop-types/commit/158198fd6c468a3f6f742e0e355e622b3914048a))
* Remove the accidentally included typechecking code from the production build.
## 15.5.3
**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**
* Remove the accidentally included React package code from the UMD bundle. ([@acdlite](https://github.com/acdlite) in [df318bb](https://github.com/facebook/prop-types/commit/df318bba8a89bc5aadbb0292822cf4ed71d27ace))
## 15.5.2
**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**
* Remove dependency on React for CommonJS entry point. ([@acdlite](https://github.com/acdlite) in [cae72bb](https://github.com/facebook/prop-types/commit/cae72bb281a3766c765e3624f6088c3713567e6d))
## 15.5.1
**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**
* Remove accidental uncompiled ES6 syntax in the published package. ([@acdlite](https://github.com/acdlite) in [e191963](https://github.com/facebook/react/commit/e1919638b39dd65eedd250a8bb649773ca61b6f1))
## 15.5.0
**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**
* Initial release.
## Before 15.5.0
PropTypes was previously included in React, but is now a separate package. For earlier history of PropTypes [see the React change log.](https://github.com/facebook/react/blob/master/CHANGELOG.md)
MIT License
Copyright (c) 2013-present, Facebook, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# prop-types [![Build Status](https://travis-ci.com/facebook/prop-types.svg?branch=master)](https://travis-ci.org/facebook/prop-types)
Runtime type checking for React props and similar objects.
You can use prop-types to document the intended types of properties passed to
components. React (and potentially other libraries—see the checkPropTypes()
reference below) will check props passed to your components against those
definitions, and warn in development if they don’t match.
## Installation
```shell
npm install --save prop-types
```
## Importing
```js
import PropTypes from 'prop-types'; // ES6
var PropTypes = require('prop-types'); // ES5 with npm
```
### CDN
If you prefer to exclude `prop-types` from your application and use it
globally via `window.PropTypes`, the `prop-types` package provides
single-file distributions, which are hosted on the following CDNs:
* [**unpkg**](https://unpkg.com/prop-types/)
```html
<!-- development version -->
<script src="https://unpkg.com/prop-types@15.6/prop-types.js"></script>
<!-- production version -->
<script src="https://unpkg.com/prop-types@15.6/prop-types.min.js"></script>
```
* [**cdnjs**](https://cdnjs.com/libraries/prop-types)
```html
<!-- development version -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.6.0/prop-types.js"></script>
<!-- production version -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.6.0/prop-types.min.js"></script>
```
To load a specific version of `prop-types` replace `15.6.0` with the version number.
## Usage
PropTypes was originally exposed as part of the React core module, and is
commonly used with React components.
Here is an example of using PropTypes with a React component, which also
documents the different validators provided:
```js
import React from 'react';
import PropTypes from 'prop-types';
class MyComponent extends React.Component {
render() {
// ... do things with the props
}
}
MyComponent.propTypes = {
// You can declare that a prop is a specific JS primitive. By default, these
// are all optional.
optionalArray: PropTypes.array,
optionalBool: PropTypes.bool,
optionalFunc: PropTypes.func,
optionalNumber: PropTypes.number,
optionalObject: PropTypes.object,
optionalString: PropTypes.string,
optionalSymbol: PropTypes.symbol,
// Anything that can be rendered: numbers, strings, elements or an array
// (or fragment) containing these types.
optionalNode: PropTypes.node,
// A React element (ie. <MyComponent />).
optionalElement: PropTypes.element,
// A React element type (ie. MyComponent).
optionalElementType: PropTypes.elementType,
// You can also declare that a prop is an instance of a class. This uses
// JS's instanceof operator.
optionalMessage: PropTypes.instanceOf(Message),
// You can ensure that your prop is limited to specific values by treating
// it as an enum.
optionalEnum: PropTypes.oneOf(['News', 'Photos']),
// An object that could be one of many types
optionalUnion: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.instanceOf(Message)
]),
// An array of a certain type
optionalArrayOf: PropTypes.arrayOf(PropTypes.number),
// An object with property values of a certain type
optionalObjectOf: PropTypes.objectOf(PropTypes.number),
// You can chain any of the above with `isRequired` to make sure a warning
// is shown if the prop isn't provided.
// An object taking on a particular shape
optionalObjectWithShape: PropTypes.shape({
optionalProperty: PropTypes.string,
requiredProperty: PropTypes.number.isRequired
}),
// An object with warnings on extra properties
optionalObjectWithStrictShape: PropTypes.exact({
optionalProperty: PropTypes.string,
requiredProperty: PropTypes.number.isRequired
}),
requiredFunc: PropTypes.func.isRequired,
// A value of any data type
requiredAny: PropTypes.any.isRequired,
// You can also specify a custom validator. It should return an Error
// object if the validation fails. Don't `console.warn` or throw, as this
// won't work inside `oneOfType`.
customProp: function(props, propName, componentName) {
if (!/matchme/.test(props[propName])) {
return new Error(
'Invalid prop `' + propName + '` supplied to' +
' `' + componentName + '`. Validation failed.'
);
}
},
// You can also supply a custom validator to `arrayOf` and `objectOf`.
// It should return an Error object if the validation fails. The validator
// will be called for each key in the array or object. The first two
// arguments of the validator are the array or object itself, and the
// current item's key.
customArrayProp: PropTypes.arrayOf(function(propValue, key, componentName, location, propFullName) {
if (!/matchme/.test(propValue[key])) {
return new Error(
'Invalid prop `' + propFullName + '` supplied to' +
' `' + componentName + '`. Validation failed.'
);
}
})
};
```
Refer to the [React documentation](https://facebook.github.io/react/docs/typechecking-with-proptypes.html) for more information.
## Migrating from React.PropTypes
Check out [Migrating from React.PropTypes](https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.proptypes) for details on how to migrate to `prop-types` from `React.PropTypes`.
Note that this blog posts **mentions a codemod script that performs the conversion automatically**.
There are also important notes below.
## How to Depend on This Package?
For apps, we recommend putting it in `dependencies` with a caret range.
For example:
```js
"dependencies": {
"prop-types": "^15.5.7"
}
```
For libraries, we *also* recommend leaving it in `dependencies`:
```js
"dependencies": {
"prop-types": "^15.5.7"
},
"peerDependencies": {
"react": "^15.5.0"
}
```
**Note:** there are known issues in versions before 15.5.7 so we recommend using it as the minimal version.
Make sure that the version range uses a caret (`^`) and thus is broad enough for npm to efficiently deduplicate packages.
For UMD bundles of your components, make sure you **don’t** include `PropTypes` in the build. Usually this is done by marking it as an external (the specifics depend on your bundler), just like you do with React.
## Compatibility
### React 0.14
This package is compatible with **React 0.14.9**. Compared to 0.14.8 (which was released in March of 2016), there are no other changes in 0.14.9, so it should be a painless upgrade.
```shell
# ATTENTION: Only run this if you still use React 0.14!
npm install --save react@^0.14.9 react-dom@^0.14.9
```
### React 15+
This package is compatible with **React 15.3.0** and higher.
```
npm install --save react@^15.3.0 react-dom@^15.3.0
```
### What happens on other React versions?
It outputs warnings with the message below even though the developer doesn’t do anything wrong. Unfortunately there is no solution for this other than updating React to either 15.3.0 or higher, or 0.14.9 if you’re using React 0.14.
## Difference from `React.PropTypes`: Don’t Call Validator Functions
First of all, **which version of React are you using**? You might be seeing this message because a component library has updated to use `prop-types` package, but your version of React is incompatible with it. See the [above section](#compatibility) for more details.
Are you using either React 0.14.9 or a version higher than React 15.3.0? Read on.
When you migrate components to use the standalone `prop-types`, **all validator functions will start throwing an error if you call them directly**. This makes sure that nobody relies on them in production code, and it is safe to strip their implementations to optimize the bundle size.
Code like this is still fine:
```js
MyComponent.propTypes = {
myProp: PropTypes.bool
};
```
However, code like this will not work with the `prop-types` package:
```js
// Will not work with `prop-types` package!
var errorOrNull = PropTypes.bool(42, 'myProp', 'MyComponent', 'prop');
```
It will throw an error:
```
Calling PropTypes validators directly is not supported by the `prop-types` package.
Use PropTypes.checkPropTypes() to call them.
```
(If you see **a warning** rather than an error with this message, please check the [above section about compatibility](#compatibility).)
This is new behavior, and you will only encounter it when you migrate from `React.PropTypes` to the `prop-types` package. For the vast majority of components, this doesn’t matter, and if you didn’t see [this warning](https://facebook.github.io/react/warnings/dont-call-proptypes.html) in your components, your code is safe to migrate. This is not a breaking change in React because you are only opting into this change for a component by explicitly changing your imports to use `prop-types`. If you temporarily need the old behavior, you can keep using `React.PropTypes` until React 16.
**If you absolutely need to trigger the validation manually**, call `PropTypes.checkPropTypes()`. Unlike the validators themselves, this function is safe to call in production, as it will be replaced by an empty function:
```js
// Works with standalone PropTypes
PropTypes.checkPropTypes(MyComponent.propTypes, props, 'prop', 'MyComponent');
```
See below for more info.
**You might also see this error** if you’re calling a `PropTypes` validator from your own custom `PropTypes` validator. In this case, the fix is to make sure that you are passing *all* of the arguments to the inner function. There is a more in-depth explanation of how to fix it [on this page](https://facebook.github.io/react/warnings/dont-call-proptypes.html#fixing-the-false-positive-in-third-party-proptypes). Alternatively, you can temporarily keep using `React.PropTypes` until React 16, as it would still only warn in this case.
If you use a bundler like Browserify or Webpack, don’t forget to [follow these instructions](https://reactjs.org/docs/optimizing-performance.html#use-the-production-build) to correctly bundle your application in development or production mode. Otherwise you’ll ship unnecessary code to your users.
## PropTypes.checkPropTypes
React will automatically check the propTypes you set on the component, but if
you are using PropTypes without React then you may want to manually call
`PropTypes.checkPropTypes`, like so:
```js
const myPropTypes = {
name: PropTypes.string,
age: PropTypes.number,
// ... define your prop validations
};
const props = {
name: 'hello', // is valid
age: 'world', // not valid
};
// Let's say your component is called 'MyComponent'
// Works with standalone PropTypes
PropTypes.checkPropTypes(myPropTypes, props, 'age', 'MyComponent');
// This will warn as follows:
// Warning: Failed prop type: Invalid prop `age` of type `string` supplied to
// `MyComponent`, expected `number`.
```
## PropTypes.resetWarningCache()
`PropTypes.checkPropTypes(...)` only `console.error.log(...)`s a given message once. To reset the cache while testing call `PropTypes.resetWarningCache()`
### License
prop-types is [MIT licensed](./LICENSE).
/**
* 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;
/**
* 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';
// React 15.5 references this module, and assumes PropTypes are still callable in production.
// Therefore we re-export development-only version with all the PropTypes checks here.
// However if one is migrating to the `prop-types` npm library, they will go through the
// `index.js` entry point, and it will branch depending on the environment.
var factory = require('./factoryWithTypeCheckers');
module.exports = function(isValidElement) {
// It is still allowed in 15.5.
var throwOnDirectAccess = false;
return factory(isValidElement, throwOnDirectAccess);
};
/**
* 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 = require('./lib/ReactPropTypesSecret');
function emptyFunction() {}
function emptyFunctionWithReset() {}
emptyFunctionWithReset.resetWarningCache = emptyFunction;
module.exports = function() {
function shim(props, propName, componentName, location, propFullName, secret) {
if (secret === ReactPropTypesSecret) {
// It is still safe when called from React.
return;
}
var err = 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'
);
err.name = 'Invariant Violation';
throw err;
};
shim.isRequired = shim;
function getShim() {
return shim;
};
// Important!
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
var ReactPropTypes = {
array: shim,
bool: shim,
func: shim,
number: shim,
object: shim,
string: shim,
symbol: shim,
any: shim,
arrayOf: getShim,
element: shim,
elementType: shim,
instanceOf: getShim,
node: shim,
objectOf: getShim,
oneOf: getShim,
oneOfType: getShim,
shape: getShim,
exact: getShim,
checkPropTypes: emptyFunctionWithReset,
resetWarningCache: emptyFunction
};
ReactPropTypes.PropTypes = ReactPropTypes;
return ReactPropTypes;
};
This diff is collapsed.
/**
* 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.
*/
if (process.env.NODE_ENV !== 'production') {
var ReactIs = require('react-is');
// By explicitly using `prop-types` you are opting into new development behavior.
// http://fb.me/prop-types-in-prod
var throwOnDirectAccess = true;
module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess);
} else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = require('./factoryWithThrowingShims')();
}
/**
* 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;
{
"_from": "prop-types@^15.6.2",
"_id": "prop-types@15.7.2",
"_inBundle": false,
"_integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==",
"_location": "/prop-types",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "prop-types@^15.6.2",
"name": "prop-types",
"escapedName": "prop-types",
"rawSpec": "^15.6.2",
"saveSpec": null,
"fetchSpec": "^15.6.2"
},
"_requiredBy": [
"/react",
"/react-daum-postcode"
],
"_resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
"_shasum": "52c41e75b8c87e72b9d9360e0206b99dcbffa6c5",
"_spec": "prop-types@^15.6.2",
"_where": "C:\\Users\\Administrator\\Desktop\\YOUN LAB\\shopping-mall\\node_modules\\react-daum-postcode",
"browserify": {
"transform": [
"loose-envify"
]
},
"bugs": {
"url": "https://github.com/facebook/prop-types/issues"
},
"bundleDependencies": false,
"dependencies": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.8.1"
},
"deprecated": false,
"description": "Runtime type checking for React props and similar objects.",
"devDependencies": {
"babel-jest": "^19.0.0",
"babel-preset-react": "^6.24.1",
"browserify": "^16.2.3",
"bundle-collapser": "^1.2.1",
"eslint": "^5.13.0",
"jest": "^19.0.2",
"react": "^15.5.1",
"uglifyify": "^3.0.4",
"uglifyjs": "^2.4.10"
},
"files": [
"LICENSE",
"README.md",
"checkPropTypes.js",
"factory.js",
"factoryWithThrowingShims.js",
"factoryWithTypeCheckers.js",
"index.js",
"prop-types.js",
"prop-types.min.js",
"lib"
],
"homepage": "https://facebook.github.io/react/",
"keywords": [
"react"
],
"license": "MIT",
"main": "index.js",
"name": "prop-types",
"repository": {
"type": "git",
"url": "git+https://github.com/facebook/prop-types.git"
},
"scripts": {
"build": "yarn umd && yarn umd-min",
"lint": "eslint .",
"prepublish": "yarn build",
"pretest": "npm run lint",
"test": "npm run tests-only",
"tests-only": "jest",
"umd": "NODE_ENV=development browserify index.js -t loose-envify --standalone PropTypes -o prop-types.js",
"umd-min": "NODE_ENV=production browserify index.js -t loose-envify -t uglifyify --standalone PropTypes -p bundle-collapser/plugin -o | uglifyjs --compress unused,dead_code -o prop-types.min.js"
},
"version": "15.7.2"
}
This diff is collapsed.
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.PropTypes=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";function emptyFunction(){}function emptyFunctionWithReset(){}var ReactPropTypesSecret=require(3);emptyFunctionWithReset.resetWarningCache=emptyFunction,module.exports=function(){function e(e,t,n,r,o,p){if(p!==ReactPropTypesSecret){var c=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 c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:emptyFunctionWithReset,resetWarningCache:emptyFunction};return n.PropTypes=n,n}},{3:3}],2:[function(require,module,exports){module.exports=require(1)()},{1:1}],3:[function(require,module,exports){"use strict";module.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},{}]},{},[2])(2)});
\ No newline at end of file
### > 1.8.3
[Github 레포지터리의 릴리즈 기록을 참고해주세요](https://github.com/bernard-kms/react-daum-postcode/releases)
### 1.8.2
- 검색결과 TypeScript 타입에 `noSelected` 인자 추가
### 1.8.1
- TypeScript 타입선언 업데이트
### 1.8.0
- 구 우편번호를 검색 결과에서 제외하는 `zonecodeOnly` props 추가
### 1.7.1
- Daum Postcode 커스텀 props가 DOM으로 주입되는 문제 해결
### 1.7.0
- React 버전을 16.4로 올림
- TypeScript 타입선언 파일을 추가
- `DaumPostcode`컴포넌트 타입
- 컴포넌트의 props인 `DaumPostcodeProps` 타입
- _onComplete_ props의 인자로 쓰이는 `AddressData` 타입
### 1.6.0
- React 버전을 16.3 으로 올림
- `alwaysShowEngAddr`, `submitMode`, `useSuggest` 생성자 속성을 추가
### 1.5.0
- Daum 우편번호 스크립트가 로드되지 않을때, 오류 메시지를 표시
- 패키지 라이브러리를 빌드할 때 minify 적용
### 1.4.2
- 다음 우편주소 검색창이 여러번 반복해서 열릴수 있도록 함
### 1.4.1
- 다음 우편주소 스크립트를 중복으로 생성하지 않도록 함 ([@ignocide](https://github.com/ignocide) in [#3](https://github.com/kimminsik-bernard/react-daum-postcode/pull/3))
- React 버전을 16.2.0으로 올림
### 1.4.0
- 다음 우편번호 생성자가 받을수 있는 모든 속성을 props를 통해 전달
- React 버전을 16.0.0으로 올림
### 1.3.0
- 다음 우편번호 스크립트를 자체적으로 로드
- README 수정
### 1.2.1
- 에러 핸들링 개선
- README 수정
### 1.2.0
- React 버전을 15.5.0으로 올림
- prop-types 패키지 사용
### 1.1.0
- 다음 우편번호 스크립트를 동적으로 로딩
### 1.0.1
- 문서 수정
- eslint 설정
### 1.0.0
- 최초 배포
# react-daum-postcode
리액트 컴포넌트로 만든 Daum 우편번호 검색 서비스입니다. Daum 우편번호 검색 서비스를 React환경에서 간편하게 이용할 수 있습니다.
## 설치
```shell
npm install --save react-daum-postcode
```
## 사용
```javascript
import React from 'react';
import DaumPostcode from 'react-daum-postcode';
const Postcode = () => {
const handleComplete = (data) => {
let fullAddress = data.address;
let extraAddress = '';
if (data.addressType === 'R') {
if (data.bname !== '') {
extraAddress += data.bname;
}
if (data.buildingName !== '') {
extraAddress += (extraAddress !== '' ? `, ${data.buildingName}` : data.buildingName);
}
fullAddress += (extraAddress !== '' ? ` (${extraAddress})` : '');
}
console.log(fullAddress); // e.g. '서울 성동구 왕십리로2길 20 (성수동1가)'
}
return (
<DaumPostcode
onComplete={handleComplete}
{ ...props }
/>
);
}
```
## props
- `onComplete` (필수) _[function]_ - 우편번호 검색이 끝났을 때 사용자가 선택한 정보를 받아올 콜백함수입니다.
- `function(data: object) => void` : 주소 데이터의 구성은 [Daum 우편번호 서비스 가이드](http://postcode.map.daum.net/guide)를 참고해주세요.
- `onSearch` _[function]_ - 주소를 검색할 경우에 실행되는 콜백함수입니다.
- `function(data: object) => void` : 검색결과 정보의 구성은 [Daum 우편번호 서비스 가이드](http://postcode.map.daum.net/guide)를 참고해주세요.
- `width` _[number or string]_ - 컴포넌트의 가로 길이입니다. 300이하는 무시됩니다. 기본값: `'100%'`
- `height` _[number or string]_ - 컴포넌트의 세로 길이입니다. 400이하는 무시됩니다. 기본값: `400`
- `autoClose` _[bool]_ - 우편번호 검색이 끝났을 때 컴포넌트를 자동으로 닫습니다. 기본값: `false`
- `autoResize` _[bool]_ - 우편번호를 검색할 때 검색 결과에 따라 컴포넌트의 세로 길이를 자동으로 조절합니다. 기본값: `false`
- `animation` _[bool]_ - 우편번호를 검색할 때 애니메이션 효과를 줍니다. 기본값: `false`
- `defaultQuery` _[string]_ - 우편번호 검색창에 미리 표시할 검색어입니다. 기본값: `null`
- `theme` _[object]_ - Daum 우편번호 검색 모듈에 적용할 테마입니다. 테마의 설정은 [Daum 우편번호 서비스 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. 기본값: `null`
- `style` _[object]_ - 우편번호 검색창을 감싸는 최상위 컴포넌트에 적용할 스타일입니다. 기본값: `null`
- `scriptUrl` _[string]_ - 컴포넌트에서 사용할 Daum 우편번호 스크립트 주소입니다. 기본값: `'https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js'`
- `errorMessage` _[React element]_ - Daum 우편번호 스크립트가 로드되지 않을 때 나타낼 에러 메시지입니다. 기본값: `<p>현재 Daum 우편번호 서비스를 이용할 수 없습니다. 잠시 후 다시 시도해주세요.</p>`
- Daum 우편번호 생성자 속성들을 동일한 이름의 props로 전달할 수 있습니다. 속성값에 대해서는 [Daum 우편번호 서비스 가이드](http://postcode.map.daum.net/guide#attributes)를 참고해주세요.
## 안내
`react-daum-postcode`는 Daum 우편번호 서비스와 독립적으로 제작된 패키지입니다. React환경에서 발생하는 `react-daum-postcode`의 버그는 패키지 레포지터리의 [이슈트래커](https://github.com/kimminsik-bernard/react-daum-postcode/issues)에 말씀해주세요. 만약 Daum 우편번호 서비스 자체의 문제라고 생각하신다면, 다음 우편번호 서비스의 [FAQ](https://github.com/daumPostcode/QnA/blob/master/README.md)[이슈트래커](https://github.com/daumPostcode/QnA/issues)를 참조해주세요.
\ No newline at end of file
declare module "react-daum-postcode" {
import * as React from "react";
type AddressData = {
zonecode: string;
address: string;
addressEnglish: string;
addressType: "R" | "J";
userSelectedType: "R" | "J";
userLanguageType: "K" | "E";
roadAddress: string;
roadAddressEnglish: string;
jibunAddress: string;
jibunAddressEnglish: string;
autoRoadAddress: string;
autoRoadAddressEnglish: string;
autoJibunAddress: string;
autoJibunAddressEnglish: string;
buildingCode: string;
buildingName: string;
apartment: "Y" | "N"
sido: string;
sigungu: string;
sigunguCode: string;
roadnameCode: string;
bcode: string;
roadname: string;
bname: string;
bname1: string;
bname2: string;
hname: string;
query: string;
noSelected: "Y" | "N";
}
type SearchData = {
q: string;
count: number;
}
type DaumPostcodeProps = {
onComplete(data: AddressData): void;
onSearch?(data: SearchData): void;
alwaysShowEngAddr?: boolean;
animation?: boolean;
autoClose?: boolean;
autoMapping?: boolean;
autoResize?: boolean;
defaultQuery?: string;
errorMessage?: React.ReactElement<any>
height?: number | string;
hideEngBtn?: boolean;
hideMapBtn?: boolean;
maxSuggestItems?: number;
pleaseReadGuide?: number;
pleaseReadGuideTimer?: number;
scriptUrl?: string;
shorthand?: boolean;
showMoreHName?: boolean;
style?: object;
theme?: object;
useSuggest?: boolean;
width?: number | string;
submitMode?: boolean;
focusInput?: boolean,
focusContent?: boolean,
}
class DaumPostcode extends React.Component<DaumPostcodeProps, any> {}
export { AddressData, DaumPostcodeProps, DaumPostcode };
export default DaumPostcode;
}
\ No newline at end of file
'use strict';var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_react=require('react'),_react2=_interopRequireDefault(_react),_propTypes=require('prop-types'),_propTypes2=_interopRequireDefault(_propTypes);Object.defineProperty(exports,'__esModule',{value:!0});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _objectWithoutProperties(a,b){var c={};for(var d in a)!(0<=b.indexOf(d))&&Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function _inherits(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var defaultErrorMessage=_react2.default.createElement('p',null,'\uD604\uC7AC Daum \uC6B0\uD3B8\uBC88\uD638 \uC11C\uBE44\uC2A4\uB97C \uC774\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uC7A0\uC2DC \uD6C4 \uB2E4\uC2DC \uC2DC\uB3C4\uD574\uC8FC\uC138\uC694.'),DaumPostcode=function(a){function b(a){_classCallCheck(this,b);var c=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a));return c.state={display:'block',width:c.props.width,height:c.props.height,error:!1},c.initiate=function(a){window.daum.postcode.load(function(){var b=new window.daum.Postcode({oncomplete:function(b){a.props.onComplete(b),a.props.autoClose&&a.setState({display:'none'})},onsearch:a.props.onSearch,onresize:function(b){a.props.autoResize&&a.setState({height:b.height})},alwaysShowEngAddr:a.props.alwaysShowEngAddr,animation:a.props.animation,autoMapping:a.props.autoMapping,autoResize:a.props.autoResize,height:a.props.height,hideEngBtn:a.props.hideEngBtn,hideMapBtn:a.props.hideMapBtn,maxSuggestItems:a.props.maxSuggestItems,pleaseReadGuide:a.props.pleaseReadGuide,pleaseReadGuideTimer:a.props.pleaseReadGuideTimer,shorthand:a.props.shorthand,showMoreHName:a.props.showMoreHName,submitMode:a.props.submitMode,theme:a.props.theme,useSuggest:a.props.useSuggest,width:a.props.width,focusInput:a.props.focusInput,focusContent:a.props.focusContent});b.embed(c.wrap,{q:c.props.defaultQuery,autoClose:c.props.autoClose})})},c.handleError=function(a){a.target.remove(),c.setState({error:!0})},c.state={display:'block',width:c.props.width,height:c.props.height,error:!1},c}return _inherits(b,a),_createClass(b,[{key:'componentDidMount',value:function componentDidMount(){var a=this,b='daum_postcode_script',c=!!document.getElementById(b);if(!c){var d=document.createElement('script');d.src=this.props.scriptUrl,d.onload=function(){return a.initiate(a)},d.onerror=function(b){return a.handleError(b)},d.id=b,document.body.appendChild(d)}else this.initiate(this)}},{key:'render',value:function render(){var a=this,b=this.props,c=b.style,d=b.onComplete,e=b.onSearch,f=b.alwaysShowEngAddr,g=b.animation,h=b.autoClose,i=b.autoMapping,j=b.autoResize,k=b.defaultQuery,l=b.errorMessage,m=b.height,n=b.hideEngBtn,o=b.hideMapBtn,p=b.maxSuggestItems,q=b.pleaseReadGuide,r=b.pleaseReadGuideTimer,s=b.scriptUrl,t=b.shorthand,u=b.showMoreHName,v=b.submitMode,w=b.theme,x=b.useSuggest,y=b.width,z=b.zonecodeOnly,A=b.focusInput,B=b.focusContent,C=_objectWithoutProperties(b,['style','onComplete','onSearch','alwaysShowEngAddr','animation','autoClose','autoMapping','autoResize','defaultQuery','errorMessage','height','hideEngBtn','hideMapBtn','maxSuggestItems','pleaseReadGuide','pleaseReadGuideTimer','scriptUrl','shorthand','showMoreHName','submitMode','theme','useSuggest','width','zonecodeOnly','focusInput','focusContent']);return _react2.default.createElement('div',_extends({ref:function ref(b){a.wrap=b},style:_extends({width:this.state.width,height:this.state.height,display:this.state.display},c)},C),this.state.error&&this.props.errorMessage)}}]),b}(_react2.default.Component);DaumPostcode.propTypes={onComplete:_propTypes2.default.func.isRequired,onSearch:_propTypes2.default.func,alwaysShowEngAddr:_propTypes2.default.bool,animation:_propTypes2.default.bool,autoClose:_propTypes2.default.bool,autoMapping:_propTypes2.default.bool,autoResize:_propTypes2.default.bool,defaultQuery:_propTypes2.default.string,errorMessage:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.element]),height:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]),hideEngBtn:_propTypes2.default.bool,hideMapBtn:_propTypes2.default.bool,maxSuggestItems:_propTypes2.default.number,pleaseReadGuide:_propTypes2.default.number,pleaseReadGuideTimer:_propTypes2.default.number,scriptUrl:_propTypes2.default.string,shorthand:_propTypes2.default.bool,showMoreHName:_propTypes2.default.bool,style:_propTypes2.default.object,submitMode:_propTypes2.default.bool,theme:_propTypes2.default.object,useSuggest:_propTypes2.default.bool,width:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]),focusInput:_propTypes2.default.bool,focusContent:_propTypes2.default.bool},DaumPostcode.defaultProps={onSearch:void 0,alwaysShowEngAddr:!1,animation:!1,autoClose:!1,autoMapping:!0,autoResize:!1,defaultQuery:null,errorMessage:defaultErrorMessage,height:400,hideEngBtn:!1,hideMapBtn:!1,maxSuggestItems:10,pleaseReadGuide:0,pleaseReadGuideTimer:1.5,scriptUrl:'https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js',shorthand:!0,showMoreHName:!1,style:null,submitMode:!0,theme:null,useSuggest:!0,width:'100%',focusInput:!0,focusContent:!0},exports.default=DaumPostcode;
\ No newline at end of file
'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.DaumPostcode=void 0;var _DaumPostcode=require('./DaumPostcode'),_DaumPostcode2=_interopRequireDefault(_DaumPostcode);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}exports.DaumPostcode=_DaumPostcode2.default,exports.default=_DaumPostcode2.default;
\ No newline at end of file
{
"_from": "react-daum-postcode",
"_id": "react-daum-postcode@2.0.2",
"_inBundle": false,
"_integrity": "sha512-K1ScGNJeIk8lUqGf3mSn3flD1zJ+PmH1G54FplHxywlyKp8uG/+xrP1VEgDHKYBFJtpuiHvIUaJDFAh8m8zX9g==",
"_location": "/react-daum-postcode",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "react-daum-postcode",
"name": "react-daum-postcode",
"escapedName": "react-daum-postcode",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/react-daum-postcode/-/react-daum-postcode-2.0.2.tgz",
"_shasum": "7adc21173f9567f86d1ea0aafd3b5b1c63e9ec66",
"_spec": "react-daum-postcode",
"_where": "C:\\Users\\Administrator\\Desktop\\YOUN LAB\\shopping-mall",
"author": {
"name": "kimminsik-bernard"
},
"bugs": {
"url": "https://github.com/kimminsik-bernard/react-daum-postcode/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Minsik Kim",
"url": "https://github.com/kimminsik-bernard"
},
{
"name": "Sungmin Kim",
"url": "https://github.com/ignocide"
},
{
"name": "jong-hui",
"url": "https://github.com/jong-hui"
},
{
"name": "KimSeonghyeon",
"url": "https://github.com/seonghyeonkimm"
}
],
"dependencies": {
"prop-types": "^15.6.2",
"react": "^16.4.2"
},
"deprecated": false,
"description": "React daum-postcode component",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.1.2",
"babel-plugin-minify-simplify": "^0.3.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-minify": "^0.3.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"eslint": "^3.15.0",
"eslint-config-airbnb-base": "^11.1.0",
"eslint-config-react-app": "^0.5.1",
"eslint-plugin-flowtype": "^2.21.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.4.1",
"express": "^4.15.2",
"react-dom": "^16.13.1",
"webpack": "^3.10.0",
"webpack-dev-middleware": "^1.12.0",
"webpack-hot-middleware": "^2.19.1"
},
"homepage": "https://github.com/kimminsik-bernard/react-daum-postcode#readme",
"keywords": [
"react",
"postcode",
"zipcode"
],
"license": "MIT",
"main": "./lib/index.js",
"name": "react-daum-postcode",
"repository": {
"type": "git",
"url": "git+https://github.com/kimminsik-bernard/react-daum-postcode.git"
},
"scripts": {
"build": "babel src -d lib",
"test": "echo \"Error: no test specified\" && exit 1"
},
"types": "./index.d.ts",
"version": "2.0.2"
}
import React from 'react';
import PropTypes from 'prop-types';
const defaultErrorMessage = (<p>현재 Daum 우편번호 서비스를 이용할 수 없습니다. 잠시 후 다시 시도해주세요.</p>);
class DaumPostcode extends React.Component {
constructor(props) {
super(props);
this.state = {
display: 'block',
width: this.props.width,
height: this.props.height,
error: false,
};
}
componentDidMount() {
const scriptId = 'daum_postcode_script';
const isExist = !!document.getElementById(scriptId);
if (!isExist) {
const script = document.createElement('script');
script.src = this.props.scriptUrl;
script.onload = () => this.initiate(this);
script.onerror = error => this.handleError(error);
script.id = scriptId;
document.body.appendChild(script);
} else this.initiate(this);
}
initiate = (comp) => {
window.daum.postcode.load(() => {
const Postcode = new window.daum.Postcode({
oncomplete: function oncomplete(data) {
comp.props.onComplete(data);
if (comp.props.autoClose) comp.setState({ display: 'none' });
},
onsearch: comp.props.onSearch,
onresize: function onresize(size) {
if (comp.props.autoResize) comp.setState({ height: size.height });
},
alwaysShowEngAddr: comp.props.alwaysShowEngAddr,
animation: comp.props.animation,
autoMapping: comp.props.autoMapping,
autoResize: comp.props.autoResize,
height: comp.props.height,
hideEngBtn: comp.props.hideEngBtn,
hideMapBtn: comp.props.hideMapBtn,
maxSuggestItems: comp.props.maxSuggestItems,
pleaseReadGuide: comp.props.pleaseReadGuide,
pleaseReadGuideTimer: comp.props.pleaseReadGuideTimer,
shorthand: comp.props.shorthand,
showMoreHName: comp.props.showMoreHName,
submitMode: comp.props.submitMode,
theme: comp.props.theme,
useSuggest: comp.props.useSuggest,
width: comp.props.width,
focusInput: comp.props.focusInput,
focusContent: comp.props.focusContent,
});
Postcode.embed(this.wrap, { q: this.props.defaultQuery, autoClose: this.props.autoClose });
});
};
handleError = (error) => {
error.target.remove();
this.setState({ error: true });
};
render() {
const {
style,
onComplete,
onSearch,
alwaysShowEngAddr,
animation,
autoClose,
autoMapping,
autoResize,
defaultQuery,
errorMessage,
height,
hideEngBtn,
hideMapBtn,
maxSuggestItems,
pleaseReadGuide,
pleaseReadGuideTimer,
scriptUrl,
shorthand,
showMoreHName,
submitMode,
theme,
useSuggest,
width,
zonecodeOnly,
focusInput,
focusContent,
...rest
} = this.props;
return (
<div
ref={(div) => { this.wrap = div; }}
style={{
width: this.state.width,
height: this.state.height,
display: this.state.display,
...style,
}}
{...rest}
>
{this.state.error && this.props.errorMessage}
</div>
);
}
}
DaumPostcode.propTypes = {
onComplete: PropTypes.func.isRequired,
onSearch: PropTypes.func,
alwaysShowEngAddr: PropTypes.bool,
animation: PropTypes.bool,
autoClose: PropTypes.bool,
autoMapping: PropTypes.bool,
autoResize: PropTypes.bool,
defaultQuery: PropTypes.string,
errorMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
hideEngBtn: PropTypes.bool,
hideMapBtn: PropTypes.bool,
maxSuggestItems: PropTypes.number,
pleaseReadGuide: PropTypes.number,
pleaseReadGuideTimer: PropTypes.number,
scriptUrl: PropTypes.string,
shorthand: PropTypes.bool,
showMoreHName: PropTypes.bool,
style: PropTypes.object,
submitMode: PropTypes.bool,
theme: PropTypes.object,
useSuggest: PropTypes.bool,
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
focusInput: PropTypes.bool,
focusContent: PropTypes.bool,
};
DaumPostcode.defaultProps = {
onSearch: undefined,
alwaysShowEngAddr: false,
animation: false,
autoClose: false,
autoMapping: true,
autoResize: false,
defaultQuery: null,
errorMessage: defaultErrorMessage,
height: 400,
hideEngBtn: false,
hideMapBtn: false,
maxSuggestItems: 10,
pleaseReadGuide: 0,
pleaseReadGuideTimer: 1.5,
scriptUrl: 'https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js',
shorthand: true,
showMoreHName: false,
style: null,
submitMode: true,
theme: null,
useSuggest: true,
width: '100%',
focusInput: true,
focusContent: true,
};
export default DaumPostcode;
import DaumPostcode from './DaumPostcode';
export { DaumPostcode };
export default DaumPostcode;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment