@nestio/pam 2.0.9-beta.0 → 2.0.10-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  version: '3'
2
2
  services:
3
3
  pam:
4
- image: node:12
4
+ image: node:24
5
5
  volumes:
6
6
  - ./../:/pam
7
7
  working_dir: /pam
@@ -0,0 +1,12 @@
1
+ steps:
2
+ - label: Run Tests
3
+ command: './.buildkite/steps/test.sh'
4
+ key: tests
5
+ agents:
6
+ queue: small
7
+
8
+ - label: ":mag: Checking Security"
9
+ key: security-checks
10
+ command: './.buildkite/steps/scan-repo.sh'
11
+ agents:
12
+ queue: small
@@ -0,0 +1,25 @@
1
+ timeout: 10m
2
+ format: json
3
+ dependency-tree: true
4
+ list-all-pkgs: true
5
+ exit-code: 0
6
+ output: /trivyscans/results.formatted
7
+ severity:
8
+ - HIGH
9
+ - CRITICAL
10
+ - MEDIUM
11
+ - LOW
12
+ scan:
13
+ skip-dirs:
14
+ - /lib64
15
+ - /lib
16
+ - /usr/lib
17
+ - /usr/include
18
+
19
+ scanners:
20
+ - secret
21
+ vulnerability:
22
+ type:
23
+ - os
24
+ - library
25
+ ignore-unfixed: true
@@ -0,0 +1,25 @@
1
+ # ----- TRIVY -----
2
+ FILESYSTEM_SCAN_ONLY=true
3
+ # Vulnerability scan (image)
4
+ VULN_SCAN_CRIT_THRESHOLD=0
5
+ VULN_SCAN_HIGH_THRESHOLD=10
6
+ VULN_SCAN_MEDIUM_THRESHOLD=1000
7
+ VULN_SCAN_LOW_THRESHOLD=1000
8
+
9
+ # Secret scan (fs)
10
+ SECRET_SCAN_CRIT_THRESHOLD=0
11
+ SECRET_SCAN_HIGH_THRESHOLD=0
12
+ SECRET_SCAN_MEDIUM_THRESHOLD=0
13
+ SECRET_SCAN_LOW_THRESHOLD=0
14
+
15
+ # Misconfig scan (optional)
16
+ MISCONFIG_SCAN_CRIT_THRESHOLD=0
17
+ MISCONFIG_SCAN_HIGH_THRESHOLD=50
18
+ MISCONFIG_SCAN_MEDIUM_THRESHOLD=1000
19
+ MISCONFIG_SCAN_LOW_THRESHOLD=1000
20
+
21
+ # License scan (optional)
22
+ LICENSE_SCAN_CRIT_THRESHOLD=0
23
+ LICENSE_SCAN_HIGH_THRESHOLD=50
24
+ LICENSE_SCAN_MEDIUM_THRESHOLD=1000
25
+ LICENSE_SCAN_LOW_THRESHOLD=1000
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+ REPO_SECURITY_SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3
+ SECURITY_REPO_PATH="$REPO_SECURITY_SCRIPT_PATH/owaspchecks"
4
+
5
+ get_repo(){
6
+ echo -e "--- Pulling owaspchecks Repo"
7
+ git clone --branch main --single-branch git@github.com:Nestio/owaspchecks.git $REPO_SECURITY_SCRIPT_PATH/owaspchecks
8
+ }
9
+
10
+ run_security_scans(){
11
+ $SECURITY_REPO_PATH/handler.sh "$IMG_HASH_NAME" envfile=$REPO_SECURITY_SCRIPT_PATH/envs/env.conf
12
+ }
13
+
14
+
15
+ security_checker(){
16
+ get_repo
17
+ run_security_scans
18
+ }
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ export IMG_HASH_NAME="placeholder"
3
+ source ./.buildkite/security/securitychecks.sh
4
+ security_checker
@@ -7,7 +7,7 @@ set -eo pipefail
7
7
  DOCKER_RUN_APP_CMD="docker-compose -f ./.buildkite/docker-compose-ci.yml run --rm pam"
8
8
 
9
9
  echo -e "--- Setting Up Environment"
10
- $DOCKER_RUN_APP_CMD /bin/bash -c "rm -rf node_modules && rm -rf lib && npm ci"
10
+ $DOCKER_RUN_APP_CMD /bin/bash -c "rm -rf node_modules && rm -rf lib && npm ci --legacy-peer-deps"
11
11
 
12
12
  echo -e "--- Running JS Tests"
13
13
  $DOCKER_RUN_APP_CMD npm run test
@@ -0,0 +1,69 @@
1
+ name: Publish npm package
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ permissions:
9
+ contents: write
10
+ id-token: write
11
+
12
+ concurrency:
13
+ group: publish-${{ github.ref }}
14
+ cancel-in-progress: false
15
+
16
+ jobs:
17
+ publish:
18
+ runs-on: ubuntu-latest
19
+
20
+ steps:
21
+ - name: Checkout
22
+ uses: actions/checkout@v4
23
+ with:
24
+ fetch-depth: 0
25
+
26
+ - name: Setup Node.js 24
27
+ uses: actions/setup-node@v4
28
+ with:
29
+ node-version: 24
30
+ registry-url: https://registry.npmjs.org
31
+
32
+ - name: Install dependencies
33
+ run: npm ci --legacy-peer-deps
34
+
35
+ - name: Run tests
36
+ run: npm test
37
+
38
+ - name: Read package metadata
39
+ id: pkg
40
+ run: |
41
+ node -e "const fs=require('fs'); const p=require('./package.json'); fs.appendFileSync(process.env.GITHUB_OUTPUT, 'name=' + p.name + '\nversion=' + p.version + '\n');"
42
+
43
+ - name: Check whether npm version already exists
44
+ id: npm_check
45
+ run: |
46
+ if npm view "${{ steps.pkg.outputs.name }}@${{ steps.pkg.outputs.version }}" version >/dev/null 2>&1; then
47
+ echo "already_published=true" >> "$GITHUB_OUTPUT"
48
+ echo "Version ${{ steps.pkg.outputs.version }} is already on npm; skipping publish."
49
+ else
50
+ echo "already_published=false" >> "$GITHUB_OUTPUT"
51
+ echo "Version ${{ steps.pkg.outputs.version }} is not on npm; publishing."
52
+ fi
53
+
54
+ - name: Publish package to npm
55
+ if: steps.npm_check.outputs.already_published == 'false'
56
+ run: npm publish --access public
57
+
58
+ - name: Create GitHub release
59
+ if: steps.npm_check.outputs.already_published == 'false'
60
+ env:
61
+ GH_TOKEN: ${{ github.token }}
62
+ run: |
63
+ if gh release view "${{ steps.pkg.outputs.version }}" >/dev/null 2>&1; then
64
+ echo "Release ${{ steps.pkg.outputs.version }} already exists; skipping."
65
+ else
66
+ gh release create "${{ steps.pkg.outputs.version }}" \
67
+ --title "${{ steps.pkg.outputs.version }}" \
68
+ --generate-notes
69
+ fi
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- 12
1
+ 24
@@ -0,0 +1,10 @@
1
+ {
2
+ "prettier": {
3
+ "allowed": false,
4
+ },
5
+ "languages": {
6
+ "JavaScript": {
7
+ "language_servers": ["...", "!biome", "!prettier"],
8
+ },
9
+ },
10
+ }
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Nestio React Component Kit
6
6
 
7
7
  ### How To Develop
8
- - `nvm use 12`
8
+ - `nvm use 24`
9
9
  - `npm install`
10
10
  - `npm start`
11
11
  - `http://localhost:8888`
@@ -13,19 +13,42 @@ Nestio React Component Kit
13
13
 
14
14
  ### How to Release a new version
15
15
 
16
+ 1. Update `version` in `package.json`, commit, and merge to `master`.
17
+ 2. GitHub Actions workflow `.github/workflows/publish.yml` runs on `master` and:
18
+ - installs dependencies and runs tests (`npm ci && npm test`)
19
+ - checks whether `@nestio/pam@<package.json version>` already exists on npm
20
+ - if that version does not exist, publishes to npm (`npm publish --access public`)
21
+ - creates a GitHub release with generated notes (`tag = version`, `title = version`)
22
+
23
+ Merges that do **not** bump `package.json` version are skipped (that version is already on npm).
24
+
25
+ Publish only runs from `master`.
26
+
27
+ Manual fallback (same as before):
16
28
  - Update version in package.json, commit, and push
17
- - Create a new release in github
29
+ - Create a new GitHub release:
18
30
  - Tag: new version number
19
31
  - Name: new version number
20
32
  - Description: Reference all PRs that are in the release
21
33
 
22
34
  ![Release form](http://nestio-wiki.s3.amazonaws.com/pam/release.png)
23
-
24
35
  - Release a new version to npm
25
-
26
36
  `npm publish`
27
37
 
28
- - Bump the version in corresponding package.json where pam is a dependency
38
+ ### Using Pam with Chuck (local / staging / prod)
39
+
40
+ Chuck does not build Pam from this repo. It installs a **pinned published version** of `@nestio/pam` from npm (see `package.json` / lockfile in Chuck).
41
+
42
+ That means Pam changes are not visible in Chuck until you:
43
+
44
+ 1. Publish a new `@nestio/pam` version (see above).
45
+ 2. Point the Chuck environment you care about at that version by updating its `@nestio/pam` dependency and reinstalling (`npm install` locally, or whatever deploy path staging uses).
46
+
47
+ **Local or staging:** bump `@nestio/pam` to your new release and verify Chuck there first.
48
+
49
+ **Production:** leave Chuck on the current Pam version until you are ready to promote; then bump `@nestio/pam` in Chuck’s prod config the same way.
50
+
51
+ Publishing Pam to npm alone does not change what Chuck runs in any environment—you have to update the version Chuck is pinned to for the changes to go into effect.
29
52
 
30
53
  ### Required Webpack Loaders
31
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestio/pam",
3
- "version": "2.0.9-beta.0",
3
+ "version": "2.0.10-beta.0",
4
4
  "description": "Nestio UI modules",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -60,13 +60,13 @@
60
60
  "file-loader": "^0.11.2",
61
61
  "identity-obj-proxy": "^3.0.0",
62
62
  "jest": "^20.0.4",
63
- "node-sass": "^4.14.1",
64
63
  "null-loader": "^0.1.1",
65
64
  "raf": "^3.4.0",
66
65
  "react": "^16.2.0",
67
66
  "react-dom": "^16.2.0",
68
67
  "react-router-dom": "^4.1.2",
69
- "sass-loader": "^7.0.1",
68
+ "sass": "^1.99.0",
69
+ "sass-loader": "^7.3.1",
70
70
  "sinon": "^1.17.4",
71
71
  "style-loader": "^0.13.2",
72
72
  "tap-webpack-plugin": "^1.1.0",
@@ -92,5 +92,8 @@
92
92
  "<rootDir>/test/setupShims.js",
93
93
  "<rootDir>/test/setupEnzyme.js"
94
94
  ]
95
+ },
96
+ "engines": {
97
+ "node": ">=24 <25"
95
98
  }
96
99
  }
@@ -17,9 +17,9 @@ import SingleSelectValueAdapter from '../adapters/SingleSelectValueAdapter';
17
17
  import MultiSelectValueAdapter from '../adapters/MultiSelectValueAdapter';
18
18
 
19
19
  /*
20
- Wrapper around SelectCore which bunldes various Async components. Can be used to render both single and multiple selects, along with normal and "search form"-styled selects.
20
+ Wrapper around SelectCore which bundles various Async components. Can be used to render both single and multiple selects, along with normal and "search form"-styled selects.
21
21
  */
22
- export default function AsyncSelect (props) {
22
+ export default function AsyncSelect(props) {
23
23
  const components = {};
24
24
  let valueAdapter;
25
25
 
@@ -66,6 +66,11 @@ export default function AsyncSelect (props) {
66
66
  closeOnSelect = props.multiple ? false : true;
67
67
  }
68
68
 
69
+ const {
70
+ label = 'Search...',
71
+ filterOption = () => true
72
+ } = props;
73
+
69
74
  return (
70
75
  <SelectCore
71
76
  {...components}
@@ -74,10 +79,10 @@ export default function AsyncSelect (props) {
74
79
  valueAdapter={valueAdapter}
75
80
 
76
81
  ariaLabel={props.ariaLabel}
77
- valueLabel={props.label}
82
+ valueLabel={label}
78
83
  disabled={props.disabled}
79
- filterOption={props.filterOption}
80
- label={props.label}
84
+ filterOption={filterOption}
85
+ label={label}
81
86
  loadOptions={props.loadOptions}
82
87
  loadFromValue={props.loadFromValue}
83
88
  minLength={props.minLength}
@@ -87,7 +92,7 @@ export default function AsyncSelect (props) {
87
92
  onOpen={props.onOpen}
88
93
  options={props.options}
89
94
  optionSets={props.optionSets}
90
- placeholder={props.label}
95
+ placeholder={label}
91
96
  processLoadFromValue={props.processLoadFromValue}
92
97
  processLoadOptions={props.processLoadOptions}
93
98
  renderValueLabel={props.renderValueLabel}
@@ -98,11 +103,6 @@ export default function AsyncSelect (props) {
98
103
  );
99
104
  }
100
105
 
101
- AsyncSelect.defaultProps = {
102
- label: 'Search',
103
- filterOption: () => true
104
- };
105
-
106
106
  AsyncSelect.propTypes = {
107
107
  /* Unique Props */
108
108
  /**
@@ -16,13 +16,19 @@ const valueAdapter = new BaseValueAdapter();
16
16
  Select designed for choosing a single date
17
17
  */
18
18
  export const CalendarInput = (props) => {
19
- const restProps = omit(props, 'valueLabel');
19
+ const {
20
+ format = DEFAULT_DISPLAY_FORMAT,
21
+ defaultValue = moment(new Date()).format(DEFAULT_DISPLAY_FORMAT),
22
+ } = props;
23
+ const restProps = omit(props, ['valueLabel', 'format', 'defaultValue']);
20
24
 
21
25
  return (
22
26
  <SelectCore
23
27
  MenuComponent={CalendarSelectMenuWrap}
24
28
  ValueComponent={InputWrap}
25
29
  valueAdapter={valueAdapter}
30
+ format={format}
31
+ defaultValue={defaultValue}
26
32
  {...restProps}
27
33
  id={props.id}
28
34
  />
@@ -31,10 +37,10 @@ export const CalendarInput = (props) => {
31
37
 
32
38
  export class CalendarSelectMenuWrap extends PureComponent {
33
39
  constructor(props) {
34
- super(props);
40
+ super(props);
35
41
 
36
- this.changeValue = this.changeValue.bind(this);
37
- this.parseDate = this.parseDate.bind(this);
42
+ this.changeValue = this.changeValue.bind(this);
43
+ this.parseDate = this.parseDate.bind(this);
38
44
  }
39
45
 
40
46
  parseDate() {
@@ -52,7 +58,7 @@ export class CalendarSelectMenuWrap extends PureComponent {
52
58
 
53
59
  return (
54
60
  <CalendarSelectMenu
55
- { ...this.props }
61
+ {...this.props}
56
62
  currentValue={this.parseDate()}
57
63
  defaultValue={defaultValue}
58
64
  changeValue={this.changeValue}
@@ -104,7 +110,7 @@ export class InputWrap extends PureComponent {
104
110
  render() {
105
111
  return (
106
112
  <InputValue
107
- { ...this.props }
113
+ {...this.props}
108
114
  currentText={!this.props.currentValue ? this.props.defaultValue : this.props.currentValue}
109
115
  changeText={this.changeText}
110
116
  />
@@ -141,6 +147,7 @@ CalendarInput.propTypes = {
141
147
  Initial value
142
148
  */
143
149
  value: PropTypes.string,
150
+ defaultValue: PropTypes.string,
144
151
  /**
145
152
  Label displayed if no value is selected
146
153
  */
@@ -152,9 +159,4 @@ CalendarInput.propTypes = {
152
159
  id: PropTypes.string,
153
160
  };
154
161
 
155
- CalendarInput.defaultProps = {
156
- format: DEFAULT_DISPLAY_FORMAT,
157
- defaultValue: moment(new Date()).format(DEFAULT_DISPLAY_FORMAT)
158
- };
159
-
160
162
  export default CalendarInput;
@@ -25,7 +25,7 @@ const defaultProps = {
25
25
  };
26
26
 
27
27
  /**
28
- Menu used for CalendarRangeSelec
28
+ Menu used for CalendarRangeSelect
29
29
  */
30
30
  export default class CalendarRangeSelectMenu extends Component {
31
31
  constructor (props) {
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import omit from 'lodash/omit';
4
3
 
5
4
  import CalendarSelectMenu from './CalendarSelectMenu';
6
5
  import MomentValueAdapter from '../adapters/MomentValueAdapter';
@@ -10,7 +9,7 @@ import { validMomentObject } from '../utils/PropTypes';
10
9
 
11
10
  const DEFAULT_DISPLAY_FORMAT = 'M/D/YYYY';
12
11
 
13
- const renderValueLabel = (format=DEFAULT_DISPLAY_FORMAT, valueLabel='Select Date') => momentValue => {
12
+ const renderValueLabel = (format = DEFAULT_DISPLAY_FORMAT, valueLabel = 'Select Date') => momentValue => {
14
13
  return momentValue ? momentValue.format(format) : valueLabel;
15
14
  };
16
15
 
@@ -19,8 +18,8 @@ const valueAdapter = new MomentValueAdapter();
19
18
  /**
20
19
  Select designed for choosing a single date
21
20
  */
22
- export default function CalendarSelect (props) {
23
- const { format, valueLabel, value } = props;
21
+ export default function CalendarSelect(props) {
22
+ const { format, valueLabel, value, ValueComponent = SingleSelectValue } = props;
24
23
  const restProps = omit(props, 'format', 'value');
25
24
 
26
25
  return (
@@ -29,6 +28,7 @@ export default function CalendarSelect (props) {
29
28
  renderValueLabel={renderValueLabel(format, valueLabel)}
30
29
  value={value || null}
31
30
  valueAdapter={valueAdapter}
31
+ ValueComponent={ValueComponent}
32
32
  {...restProps}
33
33
  id={props.id}
34
34
  />
@@ -51,7 +51,3 @@ CalendarSelect.propTypes = {
51
51
  ValueComponent: PropTypes.func.isRequired,
52
52
  id: PropTypes.string
53
53
  };
54
-
55
- CalendarSelect.defaultProps = {
56
- ValueComponent: SingleSelectValue
57
- };
@@ -12,13 +12,18 @@ const valueAdapter = new MultiSelectValueAdapter();
12
12
  /**
13
13
  Wrapper around SelectCore to render a MultiSelect
14
14
  */
15
- export default function MultiSelect (props){
15
+ export default function MultiSelect(props) {
16
+ const {
17
+ ValueComponent = MultiSelectValue,
18
+ filterable = false
19
+ } = props;
20
+
16
21
  return (
17
22
  <SelectCore
18
23
  ariaLabel={props.ariaLabel}
19
24
  closeOnSelect={false}
20
25
  emptyValue={[]}
21
- filterable={props.filterable}
26
+ filterable={filterable}
22
27
  MenuComponent={BasicMenu}
23
28
  OptionComponent={MultiSelectOption}
24
29
  menuContainerClassName={props.menuContainerClassName}
@@ -35,7 +40,7 @@ export default function MultiSelect (props){
35
40
  renderValueLabel={props.renderValueLabel}
36
41
  value={props.value}
37
42
  valueAdapter={valueAdapter}
38
- ValueComponent={props.ValueComponent}
43
+ ValueComponent={ValueComponent}
39
44
  collapsibleOptions={props.collapsibleOptions}
40
45
  id={props.id}
41
46
  />
@@ -61,8 +66,3 @@ MultiSelect.propTypes = {
61
66
  ValueComponent: PropTypes.func.isRequired,
62
67
  id: PropTypes.string,
63
68
  };
64
-
65
- MultiSelect.defaultProps = {
66
- ValueComponent: MultiSelectValue,
67
- filterable: false
68
- };
@@ -9,10 +9,17 @@ import styles from './styles/MultiSelectOption.scss';
9
9
  /**
10
10
  OptionComponent designed for use in MultiSelects
11
11
  */
12
- export default function MultiSelectOption (props) {
13
- const { isSelected, isHighlighted, option, currentText, collapsibleOptions } = props;
12
+ export default function MultiSelectOption(props) {
13
+ const {
14
+ isSelected,
15
+ isHighlighted,
16
+ option,
17
+ currentText,
18
+ collapsibleOptions,
19
+ renderOptionLabel = (o) => o.label
20
+ } = props;
14
21
 
15
- function _getCollapsibleClassName(){
22
+ function _getCollapsibleClassName() {
16
23
  if (currentText) {
17
24
  return null;
18
25
  }
@@ -33,11 +40,11 @@ export default function MultiSelectOption (props) {
33
40
  _getCollapsibleClassName()
34
41
  );
35
42
 
36
- const checkboxClass = classnames({[styles.checked]: isSelected}, {[styles.unchecked]: !isSelected});
37
- const label = props.renderOptionLabel(props.option);
43
+ const checkboxClass = classnames({ [styles.checked]: isSelected }, { [styles.unchecked]: !isSelected });
44
+ const label = renderOptionLabel(props.option);
38
45
 
39
46
  return (
40
- <SelectOption className={optionClass} {...props} >
47
+ <SelectOption className={optionClass} {...props} renderOptionLabel={renderOptionLabel}>
41
48
  <span className={styles.checkbox}>
42
49
  <i className={checkboxClass} />
43
50
  </span>
@@ -55,9 +62,3 @@ MultiSelectOption.propTypes = {
55
62
  collapsibleOptions: PropTypes.array,
56
63
  currentText: PropTypes.string
57
64
  };
58
-
59
- MultiSelectOption.defaultProps = {
60
- renderOptionLabel: function(option) {
61
- return option.label;
62
- }
63
- };
@@ -1,16 +1,18 @@
1
1
  import React from 'react';
2
2
 
3
3
  import SelectValue from './SelectValue';
4
-
5
- export default function MultiSelectValue(props){
6
- return <SelectValue {...props} />;
7
- }
4
+ import PropTypes from 'prop-types';
8
5
 
9
6
  /**
10
7
  ValueComponent designed for use in MultiSelects
11
8
  */
12
- MultiSelectValue.defaultProps = {
13
- renderValueLabel: function(currentValue) {
14
- return currentValue.length ? `${currentValue.length} selected` : 'Select options';
15
- }
9
+ export default function MultiSelectValue(props) {
10
+ const {
11
+ renderValueLabel = (v) => v.length ? `${v.length} selected` : 'Select options'
12
+ } = props;
13
+ return <SelectValue {...props} renderValueLabel={renderValueLabel} />;
14
+ }
15
+
16
+ MultiSelectValue.propTypes = {
17
+ renderValueLabel: PropTypes.func,
16
18
  };
@@ -11,7 +11,7 @@ export const DEFAULT_PRICE_MAX_GRADATIONS = [1000, 1500, 1750, 2000, 2250, 2500,
11
11
 
12
12
  export const createRenderValueLabelFunction = (valueLabel, minKey, maxKey) => {
13
13
  return (currentValue) => {
14
- if (currentValue.hasOwnProperty(minKey) && currentValue.hasOwnProperty(maxKey)){
14
+ if (currentValue.hasOwnProperty(minKey) && currentValue.hasOwnProperty(maxKey)) {
15
15
  return `$${currentValue[minKey].toLocaleString()} - $${currentValue[maxKey].toLocaleString()}`;
16
16
  } else if (currentValue.hasOwnProperty(minKey)) {
17
17
  return `$${currentValue[minKey].toLocaleString()} or more`;
@@ -23,7 +23,7 @@ export const createRenderValueLabelFunction = (valueLabel, minKey, maxKey) => {
23
23
  };
24
24
  };
25
25
 
26
- function sanitizeInitialValue(valObj, key){
26
+ function sanitizeInitialValue(valObj, key) {
27
27
  if (valObj.hasOwnProperty(key)) {
28
28
  const stripped = String(valObj[key]).replace(/\D/g, '');
29
29
  if (stripped) {
@@ -36,33 +36,44 @@ function sanitizeInitialValue(valObj, key){
36
36
  return valObj;
37
37
  }
38
38
 
39
- const valueAdapter = new BaseValueAdapter({emptyValue: {}});
39
+ const valueAdapter = new BaseValueAdapter({ emptyValue: {} });
40
40
 
41
41
  /**
42
42
  Select for selecting either a minimum, maximum or range of prices
43
43
  */
44
- export default function PriceSelect (props){
44
+ export default function PriceSelect(props) {
45
+ const {
46
+ minKey = 'min',
47
+ maxKey = 'max',
48
+ priceMinGradations = DEFAULT_PRICE_MIN_GRADATIONS,
49
+ priceMaxGradations = DEFAULT_PRICE_MAX_GRADATIONS,
50
+ priceStep = 250,
51
+ valueLabel = 'Price',
52
+ ValueComponent = SingleSelectValue
53
+ } = props;
54
+
55
+
45
56
  const value = props.value || {};
46
- sanitizeInitialValue(value, props.minKey);
47
- sanitizeInitialValue(value, props.maxKey);
57
+ sanitizeInitialValue(value, minKey);
58
+ sanitizeInitialValue(value, maxKey);
48
59
 
49
60
  return (
50
61
  <SelectCore
51
62
  MenuComponent={PriceMenu}
52
- renderValueLabel={createRenderValueLabelFunction(props.valueLabel, props.minKey, props.maxKey)}
63
+ renderValueLabel={createRenderValueLabelFunction(valueLabel, minKey, maxKey)}
53
64
  valueAdapter={valueAdapter}
54
65
 
55
66
  value={value}
56
- valueLabel={props.valueLabel}
67
+ valueLabel={valueLabel}
57
68
  onChange={props.onChange}
58
69
  onOpen={props.onOpen}
59
70
  onClose={props.onClose}
60
- minKey={props.minKey}
61
- maxKey={props.maxKey}
62
- priceMinGradations={props.priceMinGradations}
63
- priceMaxGradations={props.priceMaxGradations}
64
- priceStep={props.priceStep}
65
- ValueComponent={props.ValueComponent}
71
+ minKey={minKey}
72
+ maxKey={maxKey}
73
+ priceMinGradations={priceMinGradations}
74
+ priceMaxGradations={priceMaxGradations}
75
+ priceStep={priceStep}
76
+ ValueComponent={ValueComponent}
66
77
  />
67
78
  );
68
79
  }
@@ -98,13 +109,3 @@ PriceSelect.propTypes = {
98
109
  ValueComponent: PropTypes.func.isRequired,
99
110
  valueLabel: PropTypes.string
100
111
  };
101
-
102
- PriceSelect.defaultProps = {
103
- minKey: 'min',
104
- maxKey: 'max',
105
- priceMinGradations: DEFAULT_PRICE_MIN_GRADATIONS,
106
- priceMaxGradations: DEFAULT_PRICE_MAX_GRADATIONS,
107
- priceStep: 250,
108
- valueLabel: 'Price',
109
- ValueComponent: SingleSelectValue
110
- };
@@ -13,8 +13,15 @@ const valueAdapter = new SingleSelectValueAdapter();
13
13
  /**
14
14
  Wrapper around SelectCore to render a SingleSelect
15
15
  */
16
- export default function SingleSelect (props){
17
- let ValueComponent = props.filterable ? SingleSelectInputValue : SingleSelectValue;
16
+ export default function SingleSelect(props) {
17
+ const {
18
+ filterable = false,
19
+ placeholder = 'Choose one',
20
+ unselectOnClick = true,
21
+ OptionComponent = SingleSelectOption
22
+ } = props;
23
+
24
+ let ValueComponent = filterable ? SingleSelectInputValue : SingleSelectValue;
18
25
 
19
26
  if (props.hasOwnProperty('ValueComponent')) {
20
27
  ValueComponent = props.ValueComponent;
@@ -23,14 +30,14 @@ export default function SingleSelect (props){
23
30
  return (
24
31
  <SelectCore
25
32
  MenuComponent={BasicMenu}
26
- OptionComponent={props.OptionComponent}
33
+ OptionComponent={OptionComponent}
27
34
  valueAdapter={valueAdapter}
28
35
  ValueComponent={ValueComponent}
29
36
 
30
37
  alwaysOpen={props.alwaysOpen}
31
38
  ariaLabel={props.ariaLabel}
32
39
  disabled={props.disabled}
33
- filterable={props.filterable}
40
+ filterable={filterable}
34
41
  menuContainerClassName={props.menuContainerClassName}
35
42
  menuContainerText={props.menuContainerText}
36
43
  menuContainerTextClassName={props.menuContainerTextClassName}
@@ -41,10 +48,10 @@ export default function SingleSelect (props){
41
48
  options={props.options}
42
49
  optionSets={props.optionSets}
43
50
  onChangeText={props.onChangeText}
44
- placeholder={props.placeholder}
51
+ placeholder={placeholder}
45
52
  renderValueLabel={props.renderValueLabel}
46
53
  renderOptionLabel={props.renderOptionLabel}
47
- unselectOnClick={props.unselectOnClick}
54
+ unselectOnClick={unselectOnClick}
48
55
  value={props.value}
49
56
  id={props.id}
50
57
  />
@@ -75,10 +82,3 @@ SingleSelect.propTypes = {
75
82
  ValueComponent: PropTypes.func,
76
83
  id: PropTypes.string,
77
84
  };
78
-
79
- SingleSelect.defaultProps = {
80
- filterable: false,
81
- placeholder: 'Choose one',
82
- unselectOnClick: true,
83
- OptionComponent: SingleSelectOption
84
- };
@@ -8,18 +8,18 @@ import styles from './styles/SingleSelectOption.scss';
8
8
  /**
9
9
  OptionComponent for Single Selects
10
10
  */
11
- export default function SingleSelectOption (props) {
12
- const { isSelected, isHighlighted, option } = props;
13
- const label = props.renderOptionLabel(props.option);
11
+ export default function SingleSelectOption(props) {
12
+ const { isSelected, isHighlighted, option, renderOptionLabel = (o) => o.label } = props;
13
+ const label = renderOptionLabel(props.option);
14
14
  const optionClass = classnames(
15
15
  styles.option,
16
- {[styles.selected]: isSelected},
17
- {[styles.disabled]: option.disabled},
18
- {[styles.highlighted]: isHighlighted}
16
+ { [styles.selected]: isSelected },
17
+ { [styles.disabled]: option.disabled },
18
+ { [styles.highlighted]: isHighlighted }
19
19
  );
20
20
 
21
21
  return (
22
- <SelectOption className={optionClass} {...props} >
22
+ <SelectOption className={optionClass} {...props} renderOptionLabel={renderOptionLabel} >
23
23
  <span className={styles.label}>{label}</span>
24
24
  </SelectOption>
25
25
  );
@@ -31,9 +31,3 @@ SingleSelectOption.propTypes = {
31
31
  isSelected: PropTypes.bool.isRequired,
32
32
  renderOptionLabel: PropTypes.func,
33
33
  };
34
-
35
- SingleSelectOption.defaultProps = {
36
- renderOptionLabel: function(option) {
37
- return option.label;
38
- }
39
- };
@@ -1,15 +1,16 @@
1
1
  import React from 'react';
2
2
  import SelectValue from './SelectValue';
3
+ import PropTypes from 'prop-types';
3
4
 
4
5
  /**
5
6
  ValueComponent for Single Selects
6
7
  */
7
- export default function SingleSelectValue(props){
8
- return <SelectValue {...props} />;
8
+ export default function SingleSelectValue(props) {
9
+ const { renderValueLabel = (currentValue) => currentValue ? currentValue.label : 'Select one' } = props;
10
+
11
+ return <SelectValue {...props} renderValueLabel={renderValueLabel} />;
9
12
  }
10
13
 
11
- SingleSelectValue.defaultProps = {
12
- renderValueLabel: function(currentValue) {
13
- return currentValue ? currentValue.label : 'Select one';
14
- }
14
+ SingleSelectValue.propTypes = {
15
+ renderValueLabel: PropTypes.func
15
16
  };
@@ -11,14 +11,20 @@ const valueAdapter = new MultiSelectValueAdapter();
11
11
  /**
12
12
  * Select with options divided into multiple tabs
13
13
  */
14
- export default function TabbedSelect (props){
15
- const options = props.getOptions(props.options);
16
- const tabbedOptions = props.getTabbedOptions(props.options);
14
+ export default function TabbedSelect(props) {
15
+ const {
16
+ getTabbedOptions = (options) => options,
17
+ ValueComponent = BadgeValue,
18
+ getOptions = (options) => options.reduce((acc, cur) => acc.concat(cur.choices), [])
19
+ } = props;
20
+
21
+ const options = getOptions(props.options);
22
+ const tabbedOptions = getTabbedOptions(props.options);
17
23
 
18
24
  return (
19
25
  <SelectCore
20
26
  MenuComponent={TabbedMenu}
21
- ValueComponent={props.ValueComponent}
27
+ ValueComponent={ValueComponent}
22
28
  ariaLabel={props.ariaLabel}
23
29
  multiple={true}
24
30
  closeOnSelect={false}
@@ -51,9 +57,3 @@ TabbedSelect.propTypes = {
51
57
  };
52
58
 
53
59
  // Tabs -> {name: '', choices: [{label, value}]}
54
-
55
- TabbedSelect.defaultProps = {
56
- getTabbedOptions: (options) => options,
57
- ValueComponent: BadgeValue,
58
- getOptions: (options) => options.reduce((acc, cur) => acc.concat(cur.choices), [])
59
- };
@@ -9,7 +9,7 @@ import styles from './styles/TagBox.scss';
9
9
 
10
10
  /**
11
11
  * Base uncontrolled component for rendering tags, representing selected values, along with conditionally showing
12
- * an input that can be used to maniplate the currentText of a higher component.
12
+ * an input that can be used to manipulate the currentText of a higher component.
13
13
  */
14
14
  export default class TagBox extends Component {
15
15
  constructor (props) {
@@ -12,7 +12,12 @@ const valueAdapter = new MultiSelectValueAdapter();
12
12
  /**
13
13
  * Renders a select with a BadgeValue and a TagBoxMenu for use in Nestio-style search forms
14
14
  */
15
- export default function TagBoxMenuSelect (props) {
15
+ export default function TagBoxMenuSelect(props) {
16
+ const {
17
+ filterable = true,
18
+ ValueComponent = BadgeValue
19
+ } = props;
20
+
16
21
  return (
17
22
  <SelectCore
18
23
  MenuComponent={TagBoxMenu}
@@ -23,7 +28,7 @@ export default function TagBoxMenuSelect (props) {
23
28
 
24
29
  ariaLabel={props.ariaLabel}
25
30
  collapsibleOptions={props.collapsibleOptions}
26
- filterable={props.filterable}
31
+ filterable={filterable}
27
32
  disabled={props.disabled}
28
33
  onChange={props.onChange}
29
34
  onOpen={props.onOpen}
@@ -32,7 +37,7 @@ export default function TagBoxMenuSelect (props) {
32
37
  renderValueLabel={props.renderValueLabel}
33
38
  renderOptionLabel={props.renderOptionLabel}
34
39
  value={props.value}
35
- ValueComponent={props.ValueComponent}
40
+ ValueComponent={ValueComponent}
36
41
  valueLabel={props.valueLabel || 'Choices'}
37
42
  id={props.id}
38
43
  />
@@ -55,8 +60,3 @@ TagBoxMenuSelect.propTypes = {
55
60
  ValueComponent: PropTypes.func.isRequired,
56
61
  id: PropTypes.string,
57
62
  };
58
-
59
- TagBoxMenuSelect.defaultProps = {
60
- filterable: true,
61
- ValueComponent: BadgeValue
62
- };
@@ -12,7 +12,13 @@ const valueAdapter = new MultiSelectValueAdapter();
12
12
  /**
13
13
  * Renders a multiselect with a TagBoxValue
14
14
  */
15
- export default function TagBoxValueSelect (props) {
15
+ export default function TagBoxValueSelect(props) {
16
+ const {
17
+ filterable = true,
18
+ placeholder = 'Choices'
19
+ } = props;
20
+
21
+
16
22
  return (
17
23
  <SelectCore
18
24
  ariaLabel={props.ariaLabel}
@@ -24,8 +30,8 @@ export default function TagBoxValueSelect (props) {
24
30
  valueAdapter={valueAdapter}
25
31
 
26
32
  alwaysOpen={props.alwaysOpen}
27
- placeholder={props.placeholder}
28
- filterable={props.filterable}
33
+ placeholder={placeholder}
34
+ filterable={filterable}
29
35
  value={props.value}
30
36
  menuContainerClassName={props.menuContainerClassName}
31
37
  menuContainerText={props.menuContainerText}
@@ -61,8 +67,3 @@ TagBoxValueSelect.propTypes = {
61
67
  value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]),
62
68
  id: PropTypes.string,
63
69
  };
64
-
65
- TagBoxValueSelect.defaultProps = {
66
- filterable: true,
67
- placeholder: 'Choices'
68
- };
@@ -1,5 +0,0 @@
1
- steps:
2
- - label: Run Tests
3
- command: './.buildkite/test.sh'
4
- agents:
5
- queue: docker