ywana-core8 0.0.417 → 0.0.420
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 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +12 -28
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +11 -27
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentEditor.js +1 -2
- package/src/domain/ContentEditor.test.js +0 -2
- package/src/html/tokenfield.js +11 -20
package/package.json
CHANGED
@@ -250,8 +250,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
|
|
250
250
|
case FORMATS.HTML: return <Editor id={id} value={value} onChange={change} content={content} />
|
251
251
|
case FORMATS.DATE: return <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} />
|
252
252
|
case FORMATS.TOKENS:
|
253
|
-
|
254
|
-
return <TokenField id={id} label={label} onChange={change} readOnly={!editable} options={buildOptions()} init={init}/>
|
253
|
+
return <TokenField id={id} label={label} onChange={change} options={buildOptions()} tokens={value} />
|
255
254
|
default:
|
256
255
|
return options ? (
|
257
256
|
<DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} predictive={predictive} />
|
@@ -21,7 +21,6 @@ const schema = {
|
|
21
21
|
|
22
22
|
const value = {
|
23
23
|
name: "John Smith",
|
24
|
-
field3 : ["1","2"]
|
25
24
|
}
|
26
25
|
|
27
26
|
const ContentEditorTest = (prop) => {
|
@@ -33,7 +32,6 @@ const ContentEditorTest = (prop) => {
|
|
33
32
|
}
|
34
33
|
|
35
34
|
const content = new Content(schema, form)
|
36
|
-
console.log(form)
|
37
35
|
return (
|
38
36
|
<>
|
39
37
|
<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(
|
38
|
-
const next = tokens.concat(value)
|
39
|
-
|
40
|
-
setValue('
|
26
|
+
function changeDropDown(fid, value) {
|
27
|
+
const next = Array.isArray(tokens) ? tokens.concat(value) : [value]
|
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
|
) : (
|