ywana-core8 0.0.416 → 0.0.419
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 +11 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +12 -26
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +11 -25
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentEditor.js +3 -1
- package/src/domain/ContentEditor.test.js +1 -2
- package/src/html/tokenfield.js +10 -19
package/package.json
CHANGED
@@ -236,6 +236,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
|
|
236
236
|
const { id, format, label, options, editable = true, predictive = false, multivalue = false, Editor } = field
|
237
237
|
|
238
238
|
function change(id, value) {
|
239
|
+
console.log(id,value)
|
239
240
|
if (onChange) onChange(id, value)
|
240
241
|
}
|
241
242
|
|
@@ -249,7 +250,8 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
|
|
249
250
|
case FORMATS.COLOR: return <ColorField id={id} onChange={change} value={value}/>
|
250
251
|
case FORMATS.HTML: return <Editor id={id} value={value} onChange={change} content={content} />
|
251
252
|
case FORMATS.DATE: return <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} />
|
252
|
-
case FORMATS.TOKENS:
|
253
|
+
case FORMATS.TOKENS:
|
254
|
+
return <TokenField id={id} label={label} onChange={change} options={buildOptions()} tokens={value} />
|
253
255
|
default:
|
254
256
|
return options ? (
|
255
257
|
<DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} predictive={predictive} />
|
@@ -21,7 +21,7 @@ const schema = {
|
|
21
21
|
|
22
22
|
const value = {
|
23
23
|
name: "John Smith",
|
24
|
-
field3 : ["1","2"]
|
24
|
+
field3 : ["1","2","4"]
|
25
25
|
}
|
26
26
|
|
27
27
|
const ContentEditorTest = (prop) => {
|
@@ -33,7 +33,6 @@ const ContentEditorTest = (prop) => {
|
|
33
33
|
}
|
34
34
|
|
35
35
|
const content = new Content(schema, form)
|
36
|
-
console.log(form)
|
37
36
|
return (
|
38
37
|
<>
|
39
38
|
<ContentEditor content={content} outlined={false} onChange={change} className="grid1"/>
|
package/src/html/tokenfield.js
CHANGED
@@ -7,26 +7,15 @@ import './tokenfield.css'
|
|
7
7
|
/**
|
8
8
|
* Token Field
|
9
9
|
*/
|
10
|
-
export const TokenField = ({ id, label,
|
11
|
-
|
10
|
+
export const TokenField = ({ id, label, tokens = [], readOnly, options, onChange }) => {
|
11
|
+
|
12
12
|
const [value, setValue] = useState()
|
13
|
-
const [tokens, setTokens] = useState(init)
|
14
13
|
const [open, setOpen] = useState(false)
|
15
14
|
|
16
|
-
useEffect(() => {
|
17
|
-
if (mounted.current) {
|
18
|
-
if (onChange) {
|
19
|
-
if (tokens) onChange(id, tokens)
|
20
|
-
}
|
21
|
-
} else {
|
22
|
-
mounted.current = true
|
23
|
-
}
|
24
|
-
}, [tokens])
|
25
|
-
|
26
15
|
function remove(index) {
|
27
16
|
const next = tokens.slice()
|
28
17
|
next.splice(index, 1)
|
29
|
-
|
18
|
+
if (onChange) onChange(id, next)
|
30
19
|
}
|
31
20
|
|
32
21
|
function change(event) {
|
@@ -34,10 +23,10 @@ export const TokenField = ({ id, label, init = [], readOnly, options, onChange }
|
|
34
23
|
setValue(value)
|
35
24
|
}
|
36
25
|
|
37
|
-
function changeDropDown(
|
26
|
+
function changeDropDown(fid, value) {
|
38
27
|
const next = tokens.concat(value)
|
39
|
-
|
40
|
-
setValue('
|
28
|
+
if (onChange) onChange(id, next)
|
29
|
+
setValue('')
|
41
30
|
}
|
42
31
|
|
43
32
|
function onEnter(event) {
|
@@ -46,7 +35,7 @@ export const TokenField = ({ id, label, init = [], readOnly, options, onChange }
|
|
46
35
|
event.stopPropagation()
|
47
36
|
const token = event.target.value
|
48
37
|
const next = tokens.concat(token)
|
49
|
-
|
38
|
+
if (onChange) onChange(id, next)
|
50
39
|
setValue('')
|
51
40
|
}
|
52
41
|
|
@@ -56,10 +45,12 @@ export const TokenField = ({ id, label, init = [], readOnly, options, onChange }
|
|
56
45
|
}
|
57
46
|
}
|
58
47
|
|
48
|
+
const tks = Array.isArray(tokens) ? tokens : []
|
49
|
+
|
59
50
|
return (
|
60
51
|
<div className='tokenField'>
|
61
52
|
<label>{label}</label>
|
62
|
-
{
|
53
|
+
{tks.map((text, index) => <Token text={text} onDelete={() => remove(index)} />)}
|
63
54
|
{options ? (
|
64
55
|
<DropDown onChange={changeDropDown} options={options} predictive={true} verbose={false} />
|
65
56
|
) : (
|