Skip to content

Commit

Permalink
Merge pull request #1 from TeamWertarbyte/migration/from-unicef
Browse files Browse the repository at this point in the history
Migration/from unicef
  • Loading branch information
saschb2b authored Aug 12, 2024
2 parents 84f7cd7 + 8de663e commit b48d849
Show file tree
Hide file tree
Showing 22 changed files with 3,217 additions and 4 deletions.
18 changes: 18 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
33 changes: 33 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Check PR'

on:
pull_request_target:
types:
- opened
- synchronize
- reopened

jobs:
check-code:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Lint code
run: npm run lint
- name: Build library code
run: npm run build
check-versioning:
runs-on: ubuntu-latest
steps:
- uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Create release'

on: [workflow_dispatch]

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org/'
scope: '@wertarbyte'
- name: Install dependencies
run: npm ci
- name: Lint code
run: npm run lint
- name: Build library code
run: npm run build
- name: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# UpdateHive specific files
.env
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules

src/*
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/dist
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"endOfLine": "auto"
}
9 changes: 9 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"branches": ["master"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
"@semantic-release/npm"
]
}
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Wertarbyte
Copyright (c) 2024 Wertarbyte and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ 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.
SOFTWARE.
85 changes: 83 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,83 @@
# material-ui-currency-textfield
Currency textfield for React Material UI
# CurrencyTextField - React Material UI Component

## Overview

`CurrencyTextField` is a [React][react] component built using [Material UI's][mui] `TextField` and `react-number-format`. It provides a text field for currency input, supporting custom formatting options.

[react]: https://react.dev/
[mui]: https://mui.com/material-ui/

## Usage

```jsx
import * as React from 'react';
import Dinero from 'dinero.js';
import CurrencyTextField from '../lib/components/CurrencyTextField';

export const MyComponent: React.FC = () => {

const [value, setValue] = React.useState<Dinero.Dinero>();

return (
<CurrencyTextField
label={'Amount'}
name={'amount'}
value={value}
variant={'outlined'}
currencySymbol=""
currency="EUR"
precision={2}
minimumValue={0}
decimalCharacter=","
digitGroupSeparator="."
onChange={(value) => {
setValue(value);
}}
/>
);
};
```

## Documentation

### Props

|Name|Type|Default|Description|
|---|---|---|---|
|decimalCharacter|`string`|`'.'`|The character used as the decimal separator.|
|digitGroupSeparator|`string`|`','`|The character used as the thousand separator.|
|currency|`Dinero.Currency`|`'USD'`|ISO 4217 CURRENCY CODES as specified in the [documentation][iso]. Sorted and parsed|
|currencySymbol|`string`|`'$'`|The symbol used as the currency prefix.|
|minimumValue|`string` `number`|`'-10000000000000'`|The minimum allowable value as a string.|
|maximumValue|`string` `number`|`'10000000000000'`|The maximum allowable value as a string.|
|precision|`number`|`2`|The number of decimal places to display.|
|value|`Dinero.Dinero`||The current value of the text field. Can be a number or a string.|
|defaultValue|`Dinero.Dinero`||The default value of the text field.|
|onChange|`func`||Callback function that is called when the value changes. Receives the new value and formatted value as arguments.|
|onBlur|`func`||Callback function that is called when the input loses focus. Receives the event and value as arguments.|

[iso]: https://www.iso.org/iso-4217-currency-codes.html

## Installation

```sh
# npm
npm install @wertarbyte/material-ui-currency-textfield

# yarn
yarn add @wertarbyte/material-ui-currency-textfield
```

## Development

### Testing

The library can be easily testet in dev mode via the provided 'dev' script and App.tsx.

```
# npm
npm run dev
# yarn
yarn dev
```
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Currency TextField - React Material UI component</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading

0 comments on commit b48d849

Please sign in to comment.