ywana-core8 0.0.375 → 0.0.378

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.375",
3
+ "version": "0.0.378",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -19,7 +19,8 @@ export const FORMATS = {
19
19
  TIME: 'time',
20
20
  EMAIL: 'email',
21
21
  HTML: 'HTML',
22
- URL: 'URL'
22
+ URL: 'URL',
23
+ IMG: 'IMG',
23
24
  }
24
25
 
25
26
  /**
@@ -52,4 +52,8 @@
52
52
  white-space: nowrap;
53
53
  max-width: 10rem;
54
54
  color: var(--text-color-light);
55
- }
55
+ }
56
+
57
+ .datatable8 .string-viewer img {
58
+ height: 5rem;
59
+ }
package/src/html/table.js CHANGED
@@ -144,8 +144,10 @@ const DataTableRow = (props) => {
144
144
  */
145
145
  const DataTableCell = ({ row, column, cell, editable }) => {
146
146
 
147
+
147
148
  const render = (type) => {
148
149
  const { id, disabled = false, min, max, onChange, format, options, item } = column
150
+
149
151
  if (id === "checked") {
150
152
  return <CheckBox id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
151
153
  } else if (editable && onChange) {
@@ -208,18 +210,25 @@ const StringCellViewer = ({ id, value, format, options }) => {
208
210
  }
209
211
 
210
212
  const option = options ? buildOptions().find(o => o.value === value) : null
211
-
212
213
  let text = option ? option.label : value
213
214
  const locale = window.navigator.userLanguage || window.navigator.language;
214
215
  switch (format) {
216
+ case FORMATS.URL:
217
+ text = <a href={text} target="download" download >{text}</a>
218
+ break;
219
+ case FORMATS.IMG:
220
+ text = <img src={text} />
221
+ break;
215
222
  case FORMATS.DATE:
216
223
  let fecha = new Date(text)
217
224
  fecha.setMinutes(fecha.getMinutes() + fecha.getTimezoneOffset() + 1)
218
225
  text = fecha.toLocaleString( locale, { year: 'numeric', month: 'numeric', day: 'numeric'});
219
226
  break;
220
227
  case FORMATS.TIME:
221
- text = new Date(text).toLocaleString( locale, { year: 'hour', month: 'minute', day: 'second' }); break;
228
+ text = new Date(text).toLocaleString( locale, { year: 'hour', month: 'minute', day: 'second' });
229
+ break;
222
230
  }
231
+ console.log(value, format)
223
232
  return (<div className="field-editor string-viewer">{text}</div>)
224
233
  }
225
234
 
@@ -15,11 +15,12 @@ const TableTest = (prop) => {
15
15
  columns : [
16
16
  { id: "checked", onChange: check },
17
17
  { id: "name", label: "Name" },
18
+ { id: "thumb", label: "Thumb", type: "String", format: "IMG" },
18
19
 
19
20
  ],
20
21
  rows: [
21
- { checked: true, name: "John Smith"},
22
- { checked: false, name: "Ann Martin"},
22
+ { checked: true, name: "John Smith", thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png"},
23
+ { checked: false, name: "Ann Martin" },
23
24
  ]
24
25
  }
25
26
 
@@ -2,7 +2,6 @@ async function fetchAsync(method, URL, body = null, token, headers) {
2
2
 
3
3
  console.log('FETCH', method, URL)
4
4
 
5
-
6
5
  const requestHeaders = Object.assign({}, {
7
6
  "Accept": "application/json",
8
7
  "Content-Type": "application/json",
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useContext, useState } from 'react';
1
+ import React, { Fragment, useContext } from 'react';
2
2
  import { Uploader } from './Uploader'
3
3
  import { Button, Text } from '../../html';
4
4
  import { SiteContext, Dialog } from '../../site';
@@ -6,7 +6,7 @@ import { SiteContext, Dialog } from '../../site';
6
6
  /**
7
7
  * Upload Dialog
8
8
  */
9
- export const UploadDialog = ({ label, target, accept, onSuccess, onComplete, onClose }) => {
9
+ export const UploadDialog = ({ className, label, target, accept, onSuccess, onComplete, onClose, children }) => {
10
10
 
11
11
  const site = useContext(SiteContext);
12
12
 
@@ -33,8 +33,9 @@ export const UploadDialog = ({ label, target, accept, onSuccess, onComplete, onC
33
33
 
34
34
  const title = <Text use="headline6">{label}</Text>
35
35
  return (
36
- <Dialog title={title} open={true} onAction={onAction} actions={actions} eventPropagation={true}>
36
+ <Dialog className={className} title={title} open={true} onAction={onAction} actions={actions} eventPropagation={false}>
37
37
  <Uploader label={label} accept={accept} target={target} onSuccess={success} onComplete={complete} />
38
+ {children}
38
39
  </Dialog>
39
40
  )
40
41
  }