ywana-core8 0.0.901 → 0.0.903

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.901",
3
+ "version": "0.0.903",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -6,9 +6,6 @@ import './ContentViewer.css'
6
6
 
7
7
  /**
8
8
  * Content Viewer
9
- *
10
- * @param {*} props
11
- * @returns
12
9
  */
13
10
  export const ContentViewer = (props) => {
14
11
 
@@ -39,9 +36,6 @@ export const ContentViewer = (props) => {
39
36
 
40
37
  /**
41
38
  * Field Viewer
42
- *
43
- * @param {} props
44
- * @returns
45
39
  */
46
40
  const FieldViewer = (props) => {
47
41
 
@@ -26,46 +26,74 @@ export const Button = ({ label, icon, action, disabled = false, outlined, raised
26
26
  )
27
27
  }
28
28
 
29
+ /**
30
+ * Action Button
31
+ */
29
32
  export const ActionButton = (props) => {
30
33
 
31
- const { icon, state = "normal", action, className } = props
32
- const [_state, setState] = useState("normal")
34
+ const { states, state, className } = props
35
+
36
+ const [_state, setState] = useState()
33
37
 
34
38
  useEffect(() => {
35
39
  setState(state)
36
40
  }, [state])
37
41
 
38
- function activate() {
39
- setState("running")
40
- if (action) action()
41
- }
42
+ useEffect(() => {
43
+ if (states[_state] && states[_state].autoexec) execute()
44
+ }, [_state])
42
45
 
43
- let actionIcon = icon
44
-
45
- switch(_state) {
46
- case "normal":
47
- actionIcon = icon
48
- break
49
- case "running":
50
- actionIcon = "rotate_right"
51
- break
52
- case "success":
53
- actionIcon = "task_alt"
54
- break
55
- case "error":
56
- actionIcon = "error"
57
- break
46
+ async function execute() {
47
+ if (states[_state]) {
48
+ const newState = await states[_state].action()
49
+ if (newState) setState(newState)
50
+ }
58
51
  }
59
52
 
53
+ if (!_state) return null
54
+ const { icon, label } = states[_state]
55
+
60
56
  return (
61
- <Button {...props} icon={actionIcon} action={activate} className={`${className} action-btn ${_state}`} />
57
+ <Button {...props} icon={icon} label={label} action={execute} className={`${className} action-btn ${_state}`} />
62
58
  )
63
59
 
64
60
  }
65
61
 
66
- const ProgressButtonTest = (props) => {
62
+ const ActionButtonTest = (props) => {
63
+
64
+ const states = {
65
+ normal: {
66
+ icon: "add",
67
+ label: "Create Job",
68
+ action: () => {
69
+ return "running"
70
+ },
71
+ },
72
+ running: {
73
+ icon: "rotate_right",
74
+ label: "Creating Job",
75
+ autoexec: true,
76
+ action: () => {
77
+ console.log("Creating Job")
78
+ return new Promise((resolve, reject) => {
79
+ setTimeout(() => {
80
+ resolve("success")
81
+ }, 5000)
82
+ })
83
+ },
84
+ },
85
+ success: {
86
+ icon: "task_alt",
87
+ label: "Job Created"
88
+
89
+ },
90
+ error: {
91
+ icon: "error",
92
+ label: "Error"
93
+ }
94
+ }
67
95
 
68
96
  return (
69
- <ActionButton label="Test1" icon="add" action={() => console.log("test")} state="success" raised/>
97
+ <ActionButton states={states} state="normal" raised/>
70
98
  )
71
99
  }
@@ -7,7 +7,7 @@ import './Explorer.css'
7
7
  */
8
8
  export const FileExplorer = (props) => {
9
9
 
10
- const { columns, files = [], onSelectFile, folders = [], onSelectFolder, defaultView = "grid", defaultFolder, filterableColumns = false } = props
10
+ const { columns, files = [], onSelectFile, folders = [], onSelectFolder, defaultView = "grid", defaultFolder, filterableColumns = false, searchBy=[] } = props
11
11
  const [selectedFolder, setSelectedFolder] = useState()
12
12
  const [selectedFile, setSelectedFile] = useState()
13
13
  const [search, setSearch] = useState()
@@ -36,7 +36,12 @@ export const FileExplorer = (props) => {
36
36
  setSearch(value)
37
37
  }
38
38
 
39
- const filteredFiles = search ? files.filter(file => file.title.toLowerCase().includes(search.toLowerCase())) : files
39
+ const filteredFiles = search ? files.filter(file => {
40
+ const serchByValues = searchBy.map(key => file[key])
41
+ const searchByString = serchByValues.join(' ')
42
+ return searchByString.toLowerCase().includes(search.toLowerCase())
43
+ }) : files
44
+
40
45
  const selectedFiles = filteredFiles.filter(file => file.folder === selectedFolder)
41
46
 
42
47
  return (
@@ -110,6 +110,7 @@ const FileExplorerTest = (props) => {
110
110
  { id: 'icon', label: 'Icon', minWidth: 100 },
111
111
  { id: 'title', label: 'Titlcccce', minWidth: 100 },
112
112
  ]}
113
+ searchBy={['title', 'subtitle']}
113
114
  />
114
115
  )
115
- }
116
+ }