Skip to content

Commit

Permalink
version 0.0.1 init
Browse files Browse the repository at this point in the history
  • Loading branch information
TomaszPilch committed Sep 13, 2020
0 parents commit d145e90
Show file tree
Hide file tree
Showing 92 changed files with 14,737 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"presets": [
"@babel/preset-flow",
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-transform-flow-strip-types",
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-syntax-dynamic-import"
]
}
24 changes: 24 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[ignore]
.*/Tests/.*
.*/node_modules/.*/node_modules/fbjs/.*

[include]

[libs]
flow-typed

[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.scss
emoji=true

munge_underscores=false

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_type=$FlowExpectedError
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Created by .ignore support plugin (hsz.mobi)
node_modules
yarn-error.log
lib
.coverage

# IntelliJ project files
.idea
*.iml
out
gen

.DS_Store
DS_Store
.out
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package.json
public
flow-typed
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"singleQuote": true,
"semi": false,
"trailingComma": "all",
"printWidth": 120
}
98 changes: 98 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"name": "@bheui/components",
"version": "0.0.1",
"description": "Components fo BHE be UI",
"main": "index.js",
"scripts": {
"prebuild": "rimraf lib && mkdir lib",
"build": "babel -d lib src --ignore ./src/**/*.spec.js && copyfiles -u 1 \"./src/styles/**/*.*\" ./lib",
"postbuild": "flow-copy-source -v -i '**/*.spec.js' src lib",
"test": "jest",
"test:watch": "jest --watch",
"publish:package": "yarn publish"
},
"repository": {
"type": "git",
"url": "git+https://github.com/TomaszPilch/BHE-be-ui-components.git"
},
"files": [
"package.json",
"readme.md",
"lib/*",
"yarn.lock"
],
"author": "devX",
"bugs": {
"url": "https://github.com/TomaszPilch/BHE-be-ui-components/issues"
},
"homepage": "https://github.com/TomaszPilch/BHE-be-ui-components#readme",
"peerDependencies": {
"next": "^9.5.3"
},
"dependencies": {
"@fluentui/react": "^7.137.1",
"axios": "^0.20.0",
"brace": "^0.11.1",
"classnames": "^2.2.6",
"cookie": "^0.4.1",
"devx-js-utilities": "^0.1.4",
"isomorphic-unfetch": "^3.0.0",
"moment": "^2.28.0",
"office-ui-fabric-core": "^11.0.0",
"react-ace": "^9.1.1",
"react-dropzone": "^11.1.0",
"react-redux": "^7.2.1",
"react-select": "^3.1.0",
"redux-observable": "^1.2.0",
"reduxsauce": "^1.2.0",
"rxjs": "^6.6.3",
"seamless-immutable": "^7.1.4"
},
"devDependencies": {
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-export-default-from": "^7.10.4",
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-flow-strip-types": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5",
"@babel/preset-flow": "^7.10.4",
"@babel/preset-react": "^7.10.4",
"@types/jest": "^26.0.13",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.3.0",
"babel-loader": "^8.1.0",
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-react-docgen": "^4.1.0",
"copyfiles": "^2.3.0",
"eslint": "^7.9.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^24.0.1",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.20.6",
"flow-bin": "^0.133.0",
"flow-copy-source": "2.0.9",
"jest": "^26.4.2",
"prettier": "^2.1.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"rimraf": "^2.6.3"
},
"jest": {
"clearMocks": true,
"collectCoverage": true,
"coverageDirectory": ".coverage",
"collectCoverageFrom": [
"src/**/*.{js,jsx}"
]
}
}
10 changes: 10 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# BHE UI components & functionality

Components and functionality for [BHE be ui v2](https://github.com/TomaszPilch/BHE-be-ui-v2).

## TODOs

- [ ] Changelog
- [ ] File upload
- [ ] Json component (not work in nextJS?)
- [ ] Tests
28 changes: 28 additions & 0 deletions src/__core/DataObjectInit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @flow
const initValue = (formItem) => {
if (typeof formItem.defaultValue !== 'undefined') {
return formItem.defaultValue
}
if (formItem.type === 'bool') {
return false
}
return ''
}

const initEmptyData = (config) =>
Object.keys(config).reduce((acc, tab) => {
acc = config[tab].reduce((accS, formItem) => {
if (formItem.translated) {
if (!accS.texts) {
accS.texts = {}
}
accS.texts[formItem.name] = initValue(formItem)
} else {
accS[formItem.name] = initValue(formItem)
}
return accS
}, acc)
return acc
}, {})

export default initEmptyData
16 changes: 16 additions & 0 deletions src/__core/PreProcessLocale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const preProcessLocale = (translations) => {
const defaultForms = translations.forms
translations.modules = Object.keys(translations.modules).reduce((acc, key) => {
acc[key] = {
...translations.modules[key],
form: {
...defaultForms,
...translations.modules[key].form,
},
}
return acc
}, {})
return translations
}

export default preProcessLocale
93 changes: 93 additions & 0 deletions src/components/FilterComponent.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// @flow
import React from 'react'
import classNames from 'classnames'

// components
import { TextField as FabricTextField } from '@fluentui/react'
import SelectCore from './formItems/SelectCore'

const VALID_TYPES = ['textBox', 'selectBox']
type FilterComponentProps = {
filterValues: Object,
onChangeFilterValue: Function,
options: Object,
}

export default class FilterComponent extends React.Component<FilterComponentProps> {
getOptions = () => [
{
id: '_empty_',
value: null,
},
...this.props.options.options.map((item) => ({
id: item,
value: item,
label: this.props.options.translate
? this.props.t(`filter._selectBox.${this.props.options.key}.${item}`)
: `${item}`,
})),
]

handleOnTextChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
const { options } = this.props
this.props.onChangeFilterValue(options.key, event.target.value)
}

handleOnBlurChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
const { options } = this.props
this.props.onChangeFilterValue(options.key, event.target.value, true)
}

handleOnSelectChange = (value: string) => {
const { options } = this.props
this.props.onChangeFilterValue(options.key, value, true)
}

render() {
const { options, filterValues, t } = this.props

if (!options.type || VALID_TYPES.indexOf(options.type) === -1) {
return null
}

const classes = {
'filter-component': true,
}

switch (options.type) {
case 'textBox':
classes['filter-component__textBox'] = true
classes[`filter-in-${Array.isArray(options.in) ? options.in.length : 1}`] = true
return (
<div className={classNames(classes)}>
<FabricTextField
label={t(`filter.${options.key}`)}
name={options.key}
onBlur={this.handleOnBlurChange}
onChange={this.handleOnTextChange}
placeholder={t(`filter.${options.key}`)}
value={filterValues.getIn([options.key], '')}
/>
</div>
)
case 'selectBox':
classes['filter-component__selectBox'] = true
return (
<div className={classNames(classes)}>
<SelectCore
formFieldConfig={{
name: options.key,
}}
label={t(`filter.${options.key}`)}
onBlur={this.handleOnSelectChange}
options={this.getOptions()}
t={t}
value={filterValues.getIn([options.key], '')}
/>
</div>
)
default:
return null
}
}
}
Loading

0 comments on commit d145e90

Please sign in to comment.