ywana-core8 0.0.389 → 0.0.392
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 +28 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +18 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +28 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +28 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -1
- package/src/domain/ContentEditor.js +2 -1
- package/src/domain/ContentEditor.test.js +6 -5
- package/src/html/color.css +18 -0
- package/src/html/color.js +19 -0
- package/src/html/color.test.js +20 -0
- package/src/html/textfield.test.js +1 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ywana-core8",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.392",
|
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,7 +246,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
|
|
245
246
|
|
246
247
|
function renderFormat(format, options) {
|
247
248
|
switch (format) {
|
248
|
-
case FORMATS.COLOR: return <
|
249
|
+
case FORMATS.COLOR: return <ColorField id={id} onChange={change} />
|
249
250
|
case FORMATS.HTML: return <Editor id={id} value={value} onChange={change} content={content} />
|
250
251
|
case FORMATS.DATE: return <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} />
|
251
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,18 @@
|
|
1
|
+
.color-field {
|
2
|
+
flex: 1;
|
3
|
+
display: flex;
|
4
|
+
align-items: flex-end;
|
5
|
+
padding: .5rem;
|
6
|
+
overflow: hidden;
|
7
|
+
display: flex;
|
8
|
+
max-height: 3.5rem;
|
9
|
+
min-height: 3.5;
|
10
|
+
}
|
11
|
+
|
12
|
+
.color-field>label {
|
13
|
+
flex:1;
|
14
|
+
color: var(--primary-color);
|
15
|
+
font-size: .9rem;
|
16
|
+
font-weight: normal;
|
17
|
+
pointer-events: none;
|
18
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React, {useState} from 'react'
|
2
|
+
import './color.css'
|
3
|
+
|
4
|
+
export const ColorField = (props) => {
|
5
|
+
|
6
|
+
const {id, label="Color", value, onChange} = props
|
7
|
+
|
8
|
+
function change(event) {
|
9
|
+
const color = event.target.value
|
10
|
+
if (onChange) onChange(id, color)
|
11
|
+
}
|
12
|
+
|
13
|
+
return (
|
14
|
+
<div className="color-field">
|
15
|
+
<label for={id}>{label}</label>
|
16
|
+
<input id={id} type="color" onChange={change} value={value}/>
|
17
|
+
</div>
|
18
|
+
)
|
19
|
+
}
|
@@ -0,0 +1,20 @@
|
|
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
|
+
console.log(id, value)
|
11
|
+
const next = Object.assign({}, form, { [id] : value })
|
12
|
+
setForm(next)
|
13
|
+
}
|
14
|
+
|
15
|
+
return (
|
16
|
+
<>
|
17
|
+
<ColorField id="color1" onChange={change} value={form.color1} />
|
18
|
+
</>
|
19
|
+
)
|
20
|
+
}
|
@@ -27,6 +27,7 @@ const TextFieldTest = (prop) => {
|
|
27
27
|
<DropDown id="gender2" label="Dropdown 2" value={form.gender2} onChange={change} options={options} predictive={true}/>
|
28
28
|
<TextArea id="text1" label="Text 1" value={form.text1} onChange={change} />
|
29
29
|
<TextField id="date1" type="DATE" label="Date" value={form.date1} onChange={change} />
|
30
|
+
<TextField id="color1" type="COLOR" label="Color" value={form.date1} onChange={change} />
|
30
31
|
</>
|
31
32
|
)
|
32
33
|
}
|