ywana-core8 0.0.387 → 0.0.390

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.387",
3
+ "version": "0.0.390",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -34,6 +34,7 @@
34
34
  "material-design-icons-iconfont": "^6.1.1",
35
35
  "moment": "^2.29.1",
36
36
  "moment-range": "^4.0.2",
37
+ "react-color": "^2.19.3",
37
38
  "react-datepicker": "^4.6.0",
38
39
  "react-error-overlay": "^6.0.10",
39
40
  "react-notifications-component": "^3.4.1",
@@ -3,6 +3,7 @@ import { Button, CheckBox, DataTable, DropDown, Icon, Stack, Tab, Tabs, Text, Te
3
3
  import { CHECK, Content, TYPES } from './ContentType';
4
4
  import './ContentEditor.css';
5
5
  import { FORMATS } from './ContentType';
6
+ import { ColorField } from '../html/color';
6
7
 
7
8
  /**
8
9
  * Content Editor
@@ -245,6 +246,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
245
246
 
246
247
  function renderFormat(format, options) {
247
248
  switch (format) {
249
+ case FORMATS.COLOR: return <ColorField id={id} onChange={change} />
248
250
  case FORMATS.HTML: return <Editor id={id} value={value} onChange={change} content={content} />
249
251
  case FORMATS.DATE: return <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} />
250
252
  default:
@@ -1,13 +1,14 @@
1
1
  import React, { useState } from 'react'
2
2
  import { ContentEditor } from './ContentEditor'
3
- import { Content, TYPES } from './ContentType'
3
+ import { Content, FORMATS, TYPES } from './ContentType'
4
4
  import './ContentEditor.test.css'
5
5
 
6
6
  const schema = {
7
- name: { id: "name", type: TYPES.STRING, required: true, label: "Name" },
8
- field1: { id: "field1", type: TYPES.STRING, required: true, label: "field1", multivalue: true },
9
- field2: { id: "field2", type: TYPES.STRING, required: true, label: "field2" },
10
- field3: { id: "field3", type: TYPES.STRING, required: true, label: "field3" },
7
+ name : { id: "name" , type: TYPES.STRING, format: FORMATS.NONE, required: true, label: "Name" },
8
+ field1: { id: "field1", type: TYPES.STRING, format: FORMATS.NONE, required: true, label: "field1", multivalue: true },
9
+ field2: { id: "field2", type: TYPES.STRING, format: FORMATS.NONE, required: true, label: "field2" },
10
+ field3: { id: "field3", type: TYPES.STRING, format: FORMATS.NONE, required: true, label: "field3" },
11
+ field3: { id: "field4", type: TYPES.STRING, format: FORMATS.COLOR, required: true, label: "field3" },
11
12
  }
12
13
 
13
14
  const value = {
@@ -21,6 +21,7 @@ export const FORMATS = {
21
21
  HTML: 'HTML',
22
22
  URL: 'URL',
23
23
  IMG: 'IMG',
24
+ COLOR: 'COLOR'
24
25
  }
25
26
 
26
27
  /**
@@ -0,0 +1,17 @@
1
+ import React from 'react'
2
+ import { CirclePicker } from 'react-color'
3
+
4
+ export const ColorField = (props) => {
5
+
6
+ const {id, onChange} = props
7
+
8
+ function change(color) {
9
+ if (onChange) onChange(id, color.hex)
10
+ }
11
+
12
+ return (
13
+ <div className="color-field">
14
+ <CirclePicker onChangeComplete={change}/>
15
+ </div>
16
+ )
17
+ }
@@ -0,0 +1,19 @@
1
+ import React, { useState } from 'react'
2
+ import { ColorField } from './color'
3
+
4
+ const ColorFieldTest = (prop) => {
5
+
6
+ const [form, setForm] = useState({
7
+ })
8
+
9
+ function change(id, value) {
10
+ const next = Object.assign({}, form, { [id] : value })
11
+ setForm(next)
12
+ }
13
+
14
+ return (
15
+ <>
16
+ <ColorField onChange={change}/>
17
+ </>
18
+ )
19
+ }
@@ -0,0 +1,3 @@
1
+ .color-field {
2
+ border: solid 1px red;
3
+ }
@@ -8,6 +8,7 @@ import './LoginBox.css'
8
8
  export const LoginBox = ({
9
9
  logo, title,
10
10
  userLabel = "User",
11
+ userValue = "",
11
12
  passwordLabel = "Password",
12
13
  passwordValue = '',
13
14
  loginLabel = "Log In", onOK,
@@ -16,7 +17,7 @@ export const LoginBox = ({
16
17
  loading
17
18
  }) => {
18
19
 
19
- const [user, setUser] = useState('')
20
+ const [user, setUser] = useState(userValue)
20
21
  const [password, setPassword] = useState(passwordValue)
21
22
 
22
23
  function canOK() {