This repository has been archived by the owner on Jul 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* All dependecies are up to date + jest.mocked instead of ts-jest mocked due to jestjs/jest#12089 * Example removed * React Styleguidist first try * Better documentation * Styled documentation, changed min & max validators, removed special validators, workflows are tuned up * Reusable docs workflow * Reusable docs workflow fix * Additional item in changelog * Reusable docs workflow fix * Validators refactored * Invert validators result * Readme * min & length validators + integration test suites * fix * fix * one more fix * Exclude/ignore file(s) from Jest coverage by not running relevant tests * fix * code dublication avoided * Seems work * Bumped dependencies * Docs
- Loading branch information
Showing
116 changed files
with
29,225 additions
and
37,579 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
node_modules | ||
dist | ||
coverage | ||
example | ||
docs | ||
styleguide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Publish documentation | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
targetFolder: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
docs: | ||
name: Build & publish documentation | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm run build:docs | ||
- uses: JamesIves/github-pages-deploy-action@4.1.5 | ||
with: | ||
branch: docs | ||
folder: styleguide | ||
target-folder: ${{ inputs.targetFolder }} | ||
git-config-name: github-pages-deploy-action |
21 changes: 16 additions & 5 deletions
21
.github/workflows/release.yml → .github/workflows/publish.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,50 @@ | ||
name: Lint, test, build and publish | ||
name: Publish | ||
|
||
on: | ||
release: | ||
types: [ published ] | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm run lint | ||
|
||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm run test:ci | ||
|
||
publish: | ||
needs: [ lint, test ] | ||
name: Build & publish | ||
name: Build & publish package | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm run build | ||
- uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
|
||
docs: | ||
needs: [ publish ] | ||
steps: | ||
- uses: ./.github/workflows/docs.yml | ||
with: | ||
targetFolder: docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Verify | ||
|
||
on: | ||
push: | ||
tags-ignore: | ||
- '*' | ||
paths-ignore: | ||
- '**.md' | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm run lint | ||
|
||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm run test:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,5 @@ node_modules/ | |
.npm | ||
|
||
dist/ | ||
|
||
styleguide/ | ||
*.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
* | ||
.* | ||
!CHANGELOG | ||
!dist/*/* | ||
!src/**/* | ||
**/*.test.ts | ||
**/*.spec.ts | ||
**/.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16.12 | ||
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, {forwardRef, useMemo} from 'react'; | ||
|
||
const Button = forwardRef(({type, ...props}, ref) => { | ||
const className = useMemo(() => { | ||
const classes = ['btn me-3']; | ||
|
||
if (type === 'reset') { | ||
classes.push('btn-secondary') | ||
} | ||
else { | ||
classes.push('btn-primary') | ||
} | ||
|
||
return classes.join(' '); | ||
}, [type]); | ||
|
||
|
||
return ( | ||
<button | ||
ref={ref} | ||
type={type || 'button'} | ||
className={className} | ||
{...props} | ||
/> | ||
); | ||
}); | ||
|
||
Button.displayName = 'Button'; | ||
|
||
export default Button; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React, {forwardRef, useMemo} from 'react'; | ||
|
||
const Checks = forwardRef(({ | ||
items, | ||
description, | ||
label, | ||
required, | ||
id, | ||
name, | ||
['aria-invalid']: invalid, | ||
}, ref) => { | ||
const inputClassName = useMemo(() => { | ||
const classes = ['form-check-input']; | ||
|
||
if (invalid === true) { | ||
classes.push('is-invalid'); | ||
} | ||
|
||
if (invalid === false) { | ||
classes.push('is-valid'); | ||
} | ||
|
||
return classes.join(' '); | ||
}, [invalid]); | ||
|
||
const fieldsetClassName = useMemo(() => { | ||
const classes = []; | ||
|
||
if (invalid === true) { | ||
classes.push('is-invalid'); | ||
} | ||
|
||
if (invalid === false) { | ||
classes.push('is-valid'); | ||
} | ||
|
||
return classes.join(' '); | ||
}, [invalid]); | ||
|
||
const children = items.map(([itemLabel, value]) => { | ||
const itemId = `${id}-${itemLabel.toLowerCase().replace(/\s:#/ui, '-')}`; | ||
return ( | ||
<div className="form-check" key={itemId}> | ||
<input | ||
className={inputClassName} | ||
type="checkbox" | ||
value={value} | ||
id={itemId} | ||
name={name} | ||
/> | ||
<label | ||
className="form-check-label" | ||
htmlFor={itemId} | ||
> | ||
{itemLabel} | ||
</label> | ||
</div> | ||
); | ||
}); | ||
|
||
return ( | ||
<div className="mb-3"> | ||
<legend> | ||
{label} | ||
{required && <span aria-hidden="true"> *</span>} | ||
</legend> | ||
<fieldset | ||
ref={ref} | ||
id={id} | ||
aria-invalid={invalid} | ||
aria-describedby={id && description && `${id}-description`} | ||
className={fieldsetClassName} | ||
> | ||
{children} | ||
</fieldset> | ||
{description && ( | ||
<p | ||
id={id && `${id}-description`} | ||
className={invalid ? 'invalid-feedback' : 'valid-feedback'} | ||
> | ||
{description} | ||
</p> | ||
)} | ||
</div> | ||
) | ||
}); | ||
|
||
Checks.displayName = 'Checks'; | ||
|
||
export default Checks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React, {forwardRef, useState, useCallback} from 'react'; | ||
|
||
const Form = forwardRef((props, ref) => { | ||
|
||
return ( | ||
<form | ||
ref={ref} | ||
noValidate | ||
{...props} | ||
/> | ||
); | ||
}); | ||
|
||
Form.displayName = 'Form'; | ||
|
||
export default Form; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, {forwardRef, useMemo} from 'react'; | ||
|
||
const Input = forwardRef(({ | ||
id, | ||
label, | ||
description, | ||
required, | ||
['aria-invalid']: invalid, | ||
...props | ||
}, ref) => { | ||
|
||
const inputClassName = useMemo(() => { | ||
const classes = ['form-control']; | ||
|
||
if (invalid === true) { | ||
classes.push('is-invalid'); | ||
} | ||
|
||
if (invalid === false) { | ||
classes.push('is-valid'); | ||
} | ||
|
||
return classes.join(' '); | ||
}, [invalid]); | ||
|
||
return ( | ||
<div className="mb-3"> | ||
<label htmlFor={id} className="form-label"> | ||
{label} | ||
{required && <span aria-hidden="true"> *</span>} | ||
</label> | ||
<input | ||
ref={ref} | ||
id={id} | ||
className={inputClassName} | ||
aria-describedby={id && description && `${id}-description`} | ||
autoComplete="off" | ||
aria-invalid={invalid} | ||
{...props} | ||
/> | ||
{description && ( | ||
<p | ||
id={id && `${id}-description`} | ||
className={invalid ? 'invalid-feedback' : 'valid-feedback'} | ||
> | ||
{description} | ||
</p> | ||
)} | ||
</div> | ||
); | ||
}); | ||
|
||
Input.displayName = 'Input'; | ||
|
||
export default Input; |
Oops, something went wrong.