Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dhis2/prop-types

Package Overview
Dependencies
Maintainers
15
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dhis2/prop-types - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

build/cjs/lib.js

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [2.0.1](https://github.com/dhis2/prop-types/compare/v2.0.0...v2.0.1) (2020-10-27)
### Bug Fixes
* build with platform d2-app-scripts ([#144](https://github.com/dhis2/prop-types/issues/144)) ([018c0ed](https://github.com/dhis2/prop-types/commit/018c0ed1d6d89b9bfb24a86f74e2f7f3d212f301))
# [2.0.0](https://github.com/dhis2/prop-types/compare/v1.6.4...v2.0.0) (2020-04-28)

@@ -2,0 +9,0 @@

78

package.json
{
"name": "@dhis2/prop-types",
"version": "2.0.0",
"main": "./build/cjs/index.js",
"module": "./build/es/index.js",
"sideEffects": false,
"repository": "https://github.com/dhis2/prop-types.git",
"author": "Jan-Gerke Salomon <jgs.salomon@gmail.com>",
"license": "BSD-3-Clause",
"private": false,
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "jest",
"docs": "jsdoc2md -t jsdoc2md/README.hbs src/*.js > README.md; echo",
"prebuild": "rm -rf ./build/** && yarn test",
"build:commonjs": "BABEL_ENV=commonjs babel src --out-dir ./build/cjs --copy-files --verbose",
"build:modules": "BABEL_ENV=modules babel src --out-dir ./build/es --copy-files --verbose",
"build": "NODE_ENV=production yarn build:commonjs && NODE_ENV=production yarn build:modules",
"lint:style": "d2-style js check --all"
},
"dependencies": {
"prop-types": "^15"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.8.3",
"@dhis2/cli-style": "6.0.0",
"babel-eslint": "^10.0.3",
"jest": "^25.1.0",
"jsdoc-to-markdown": "^5.0.3",
"react": "^16.12.0",
"react-dom": "^16.12.0"
},
"peerDependencies": {
"react": ">=15"
},
"files": [
"build"
]
"name": "@dhis2/prop-types",
"version": "2.0.1",
"main": "./build/cjs/lib.js",
"module": "./build/es/lib.js",
"sideEffects": false,
"repository": "https://github.com/dhis2/prop-types.git",
"author": "Jan-Gerke Salomon <jgs.salomon@gmail.com>",
"license": "BSD-3-Clause",
"private": false,
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "d2-app-scripts test",
"docs": "jsdoc2md -t jsdoc2md/README.hbs src/*.js > README.md; echo",
"build": "d2-app-scripts build",
"lint": "yarn lint:js && yarn lint:text",
"lint:js": "d2-style js check",
"lint:text": "d2-style text check"
},
"dependencies": {
"prop-types": "^15"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^5.4.0",
"@dhis2/cli-style": "7.2.0",
"jsdoc-to-markdown": "^6.0.1",
"react": "^16.14.0",
"react-dom": "^16.13.0"
},
"peerDependencies": {
"react": ">=15"
},
"files": [
"build"
]
}

@@ -6,2 +6,3 @@ # DHIS2 propTypes

## Installation
```bash

@@ -39,2 +40,3 @@ yarn add @dhis2/prop-types

## arrayWithLength([min], [max], [propType]) ⇒ <code>Error</code> \| <code>null</code>
Ensure the prop value is an array with a length between a minimum and maximum.

@@ -44,11 +46,12 @@ If a third `propType` argument is passed each item in the array needs to be of that prop-type

**Kind**: global function
**Returns**: <code>Error</code> \| <code>null</code> - Returns null if all conditions are met, or an error
**Returns**: <code>Error</code> \| <code>null</code> - Returns null if all conditions are met, or an error
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [min] | <code>number</code> | <code>0</code> | The minimal array length |
| [max] | <code>number</code> | <code>Infinity</code> | The maximal array length |
| [propType] | <code>function</code> | | The prop-type that each array item needs to conform to |
| Param | Type | Default | Description |
| ---------- | --------------------- | --------------------- | ------------------------------------------------------ |
| [min] | <code>number</code> | <code>0</code> | The minimal array length |
| [max] | <code>number</code> | <code>Infinity</code> | The maximal array length |
| [propType] | <code>function</code> | | The prop-type that each array item needs to conform to |
**Example**
**Example**
```js

@@ -64,3 +67,3 @@ import React from 'react'

arrayWithAtLeastTenItems: arrayWithLength(10),
mandatoryArrayBetweenOneAndTen: arrayWithLength(1,10).isRequired,
mandatoryArrayBetweenOneAndTen: arrayWithLength(1, 10).isRequired,
}

@@ -70,2 +73,3 @@ ```

<a name="conditional"></a>
## conditional(propsToPropTypes) ⇒ <code>Error</code> \| <code>null</code>

@@ -77,9 +81,10 @@

**Kind**: global function
**Returns**: <code>Error</code> \| <code>null</code> - Returns null if all conditions are met, or an error
**Returns**: <code>Error</code> \| <code>null</code> - Returns null if all conditions are met, or an error
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| propsToPropType | <code>Function</code> | | The function that will determine the actual prop type |
| Param | Type | Default | Description |
| --------------- | --------------------- | ------- | ----------------------------------------------------- |
| propsToPropType | <code>Function</code> | | The function that will determine the actual prop type |
**Example**
**Example**
```js

@@ -115,12 +120,14 @@ import React from 'react'

## instanceOfComponent(Component) ⇒ <code>Error</code> \| <code>null</code>
Ensure the prop value is an instance of a certain component
**Kind**: global function
**Returns**: <code>Error</code> \| <code>null</code> - Returns null if all conditions are met, or an error
**Returns**: <code>Error</code> \| <code>null</code> - Returns null if all conditions are met, or an error
| Param | Type | Description |
| --- | --- | --- |
| Param | Type | Description |
| --------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Component | <code>function</code> \| <code>string</code> | The component that is expected. Can either be a React component, or a string for built-in components, such as 'span', 'div', etc. |
**Example**
**Example**
```js

@@ -134,3 +141,3 @@ import React from 'react'

ButtonWrap.propTypes = {
children: instanceOfComponent(Button)
children: instanceOfComponent(Button),
}

@@ -140,3 +147,3 @@

ButtonWrap.propTypes = {
children: instanceOfComponent(Button).isRequired
children: instanceOfComponent(Button).isRequired,
}

@@ -146,8 +153,10 @@

ButtonWrap.propTypes = {
children: proptypes.arrayOf(instanceOfComponent(Button)).isRequired
children: proptypes.arrayOf(instanceOfComponent(Button)).isRequired,
}
```
<a name="mutuallyExclusive"></a>
## mutuallyExclusive(exlusivePropNames, propType) ⇒ <code>Error</code> \| <code>null</code>
Ensure that only one property within a specified list is thruthy

@@ -157,10 +166,11 @@ This function will also check if the current property value is of the specified type

**Kind**: global function
**Returns**: <code>Error</code> \| <code>null</code> - Returns null if all conditions are met, or an error
**Returns**: <code>Error</code> \| <code>null</code> - Returns null if all conditions are met, or an error
| Param | Type | Description |
| --- | --- | --- |
| exlusivePropNames | <code>array.&lt;string&gt;</code> | The prop names to be checked |
| propType | <code>function</code> | The prop-type that the current prop-value needs to conform to |
| Param | Type | Description |
| ----------------- | --------------------------------- | ------------------------------------------------------------- |
| exlusivePropNames | <code>array.&lt;string&gt;</code> | The prop names to be checked |
| propType | <code>function</code> | The prop-type that the current prop-value needs to conform to |
**Example**
**Example**
```js

@@ -173,8 +183,9 @@ import React from 'react'

const Alert = ({ danger, warning, success, children }) => (
<div className={cx({danger, warning, success})}>
{children}
</div>
<div className={cx({ danger, warning, success })}>{children}</div>
)
const statusPropType = mutuallyExclusive(['danger', 'warning', 'success'], propTypes.bool)
const statusPropType = mutuallyExclusive(
['danger', 'warning', 'success'],
propTypes.bool
)

@@ -188,5 +199,7 @@ Alert.propTypes = {

```
<a name="requiredIf"></a>
## requiredIf(siblingPropName) ⇒ <code>Error</code> \| <code>null</code>
Ensure the prop has a value (i.e. treat it as required) when a given sibling prop

@@ -196,9 +209,10 @@ also has a value, and ensure the prop is of the correct prop-type

**Kind**: global function
**Returns**: <code>Error</code> \| <code>null</code> - Returns null if all conditions are met, or an error
**Returns**: <code>Error</code> \| <code>null</code> - Returns null if all conditions are met, or an error
| Param | Type | Description |
| --- | --- | --- |
| Param | Type | Description |
| --------------- | --------------------- | ---------------------------- |
| siblingPropName | <code>function</code> | The name of the sibling prop |
**Example**
**Example**
```js

@@ -219,1 +233,12 @@ import React from 'react'

```
# Report an issue
The issue tracker can be found in [DHIS2 JIRA](https://jira.dhis2.org)
under the [LIBS](https://jira.dhis2.org/projects/LIBS) project.
Deeplinks:
- [Bug](https://jira.dhis2.org/secure/CreateIssueDetails!init.jspa?pid=10700&issuetype=10006&components=11008)
- [Improvement](https://jira.dhis2.org/secure/CreateIssueDetails!init.jspa?pid=10700&issuetype=10002&components=11008)
- [Task](https://jira.dhis2.org/secure/CreateIssueDetails!init.jspa?pid=10700&issuetype=10003&components=11008)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc