ywana-core8 0.0.388 → 0.0.391
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/dist/index.cjs +25 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +25 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +28 -5
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -1
- package/src/domain/ContentEditor.js +2 -0
- package/src/domain/ContentEditor.test.js +6 -5
- package/src/domain/ContentType.js +1 -0
- package/src/html/color.js +17 -0
- package/src/html/color.test.js +19 -0
- package/src/html/color1.css +3 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ywana-core8",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.391",
|
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 = {
|
@@ -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} width=""/>
|
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
|
+
}
|