ywana-core8 0.0.417 → 0.0.418

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.417",
3
+ "version": "0.0.418",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -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
 
@@ -250,8 +251,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
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
253
  case FORMATS.TOKENS:
253
- const init = Array.isArray(value) ? value : []
254
- return <TokenField id={id} label={label} onChange={change} readOnly={!editable} options={buildOptions()} init={init}/>
254
+ return <TokenField id={id} label={label} onChange={change} options={buildOptions()} tokens={value} />
255
255
  default:
256
256
  return options ? (
257
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"/>
@@ -7,26 +7,15 @@ import './tokenfield.css'
7
7
  /**
8
8
  * Token Field
9
9
  */
10
- export const TokenField = ({ id, label, init = [], readOnly, options, onChange }) => {
11
- const mounted = useRef(false)
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
- setTokens(next)
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(id, value) {
26
+ function changeDropDown(fid, value) {
38
27
  const next = tokens.concat(value)
39
- setTokens(next)
40
- setValue('xxx')
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
- setTokens(next)
38
+ if (onChange) onChange(id, next)
50
39
  setValue('')
51
40
  }
52
41