ywana-core8 0.0.254 → 0.0.255

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.254",
3
+ "version": "0.0.255",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -17,7 +17,6 @@ export const ContentViewer = (props) => {
17
17
 
18
18
  const sections = content.sections()
19
19
  const value = content.value()
20
- console.log(value)
21
20
  return (
22
21
  <div className="content-viewer">
23
22
  {sections.map(section => {
@@ -47,9 +46,7 @@ const FieldViewer = (props) => {
47
46
 
48
47
  const { field, value } = props
49
48
  const { id, type, item, label } = field
50
-
51
- console.log('FieldViewer', field, value)
52
-
49
+
53
50
  switch(type) {
54
51
  case TYPES.STRING:
55
52
  return <Property label={label} value={value} />
package/src/html/tab.js CHANGED
@@ -11,12 +11,12 @@ export const Tabs = (props) => {
11
11
 
12
12
  const tabs = React.Children.map(children, (child, index) => {
13
13
 
14
- function select() {
15
- if (onChange) onChange(index)
14
+ function select(id) {
15
+ if (onChange) onChange(id || index)
16
16
  }
17
17
 
18
18
  return React.cloneElement(child, {
19
- selected: index === selected,
19
+ selected: index === selected || selected === child.props.id,
20
20
  onSelect: select
21
21
  })
22
22
  })
@@ -34,10 +34,10 @@ export const Tabs = (props) => {
34
34
  */
35
35
  export const Tab = (props) => {
36
36
 
37
- const { label, selected, actions, onSelect } = props
37
+ const { id, label, selected, actions, onSelect } = props
38
38
 
39
39
  function select() {
40
- if (onSelect) onSelect()
40
+ if (onSelect) onSelect(id)
41
41
  }
42
42
 
43
43
  const style = selected ? "selected" : ""
@@ -0,0 +1,16 @@
1
+ import React, { useState } from 'react'
2
+ import { Icon } from '.'
3
+ import { Tabs, Tab } from './tab'
4
+
5
+ const TabTest = (prop) => {
6
+
7
+ return (
8
+ <>
9
+ <Tabs>
10
+ <Tab label="tab1" action={<Icon icon="close" size="small" />} />
11
+ <Tab label="tab2" action={<Icon icon="close" size="small" />} />
12
+ <Tab label="tab3" action={<Icon icon="close" size="small" />} />
13
+ </Tabs>
14
+ </>
15
+ )
16
+ }
package/src/html/table.js CHANGED
@@ -201,7 +201,14 @@ const BooleanCellViewer = ({ id, value = false }) => {
201
201
  * String Cell Viewer
202
202
  */
203
203
  const StringCellViewer = ({ id, value, format, options }) => {
204
- const option = options ? options.find(o => o.value === value) : null
204
+
205
+ function buildOptions() {
206
+ const opts = typeof options === 'function' ? options() : options
207
+ return opts
208
+ }
209
+
210
+ const option = options ? buildOptions().find(o => o.value === value) : null
211
+
205
212
  let text = option ? option.label : value
206
213
  const locale = window.navigator.userLanguage || window.navigator.language;
207
214
  switch (format) {
@@ -0,0 +1,31 @@
1
+ .ide-editor-box {
2
+ flex: 1;
3
+ width: 100%;
4
+ height: 100%;
5
+ display: flex;
6
+ overflow: hidden;
7
+ border: solid 1px red;
8
+ }
9
+
10
+ .ide-editor {
11
+ flex: 1;
12
+ width: 100%;
13
+ height: 100%;
14
+ display: flex;
15
+ flex-direction: column;
16
+ overflow: hidden;
17
+ }
18
+
19
+ .ide-editor>nav {
20
+ height: 2.2rem;
21
+ overflow: hidden;
22
+ display: flex;
23
+ }
24
+
25
+ .ide-editor>main {
26
+ border: solid 1px var(--divider-color);
27
+ border-top: 0px;
28
+ flex: 1;
29
+ padding: .5rem;
30
+ border: solid 1px blue;
31
+ }
@@ -0,0 +1,74 @@
1
+ import React, { useState } from 'react'
2
+ import { Icon, Tab, Tabs } from '../../html'
3
+ import './editor.css'
4
+
5
+ export const EditorBox = (props) => {
6
+
7
+ const { files = [], onClose, Renderer } = props
8
+ const [selected, setSelected] = useState()
9
+
10
+ function select(id) {
11
+ setSelected(id)
12
+ }
13
+
14
+ function close(id) {
15
+ if (id === selected) setSelected(null)
16
+ if (onClose) onClose(id)
17
+ }
18
+
19
+ function closer(id) {
20
+ return [<Icon icon="close" size="small" clickable action={() => close(id)} />]
21
+ }
22
+
23
+ function split() {
24
+ console.log('TODO: Split Vertical')
25
+ }
26
+
27
+ const style = " "
28
+ return (
29
+ <div className={`ide-editor-box ${style}`}>
30
+ <Editor files={files} onSplit={split} Renderer={Renderer}/>
31
+ <Editor files={files} onSplit={split} />
32
+ </div>
33
+ )
34
+ }
35
+
36
+ export const Editor = (props) => {
37
+
38
+ const { files = [], onClose, Renderer } = props
39
+ const [selected, setSelected] = useState()
40
+
41
+ function select(id) {
42
+ setSelected(id)
43
+ }
44
+
45
+ function close(id) {
46
+ if (id === selected) setSelected(null)
47
+ if (onClose) onClose(id)
48
+ }
49
+
50
+ function closer(id) {
51
+ return [<Icon icon="close" size="small" clickable action={() => close(id)} />]
52
+ }
53
+
54
+ function split() {
55
+ console.log('TODO: Split Vertical')
56
+ }
57
+
58
+ const style = " "
59
+ return (
60
+ <div className={`ide-editor ${style}`}>
61
+ <nav>
62
+ <Tabs onChange={select} selected={selected}>
63
+ {files.map(item => <Tab id={item.id} className='editor' label={item.label} actions={closer(item.id)}/>)}
64
+ </Tabs>
65
+ { selected ? <Icon icon="vertical_split" size="small" clickable action={split} /> : null }
66
+ </nav>
67
+ <main>
68
+ { selected ? <div className='editor'>
69
+ { Renderer ? <Renderer id={selected} /> : selected }
70
+ </div> : null }
71
+ </main>
72
+ </div>
73
+ )
74
+ }
@@ -0,0 +1,33 @@
1
+ import React, { useState } from 'react'
2
+ import { EditorBox } from './editor'
3
+
4
+ const FileRenderer = (props) => {
5
+
6
+ const { id } = props
7
+
8
+ return (
9
+ <div className='file-renderer'>
10
+ File Renderer {id}
11
+ </div>
12
+ )
13
+
14
+ }
15
+
16
+
17
+ const EditorTest = (prop) => {
18
+
19
+ const [files, setFiles] = useState([
20
+ { id: "1", label: "One" },
21
+ { id: "2", label: "Two" },
22
+ { id: "3", label: "Three" },
23
+ ])
24
+
25
+ function close(id) {
26
+ const next = files.filter(file => file.id !== id)
27
+ setFiles(next)
28
+ }
29
+
30
+ return (
31
+ <EditorBox files={files} onClose={close} Renderer={FileRenderer}/>
32
+ )
33
+ }