ywana-core8 0.0.244 → 0.0.248

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.244",
3
+ "version": "0.0.248",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -254,7 +254,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
254
254
  case FORMATS.DATE: return <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} />
255
255
  default:
256
256
  return options ? (
257
- <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} canFilter={predictive} />
257
+ <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} predictive={predictive} />
258
258
  ) : (
259
259
  <TextField outlined={outlined} id={id} label={label} value={value} onChange={change} readOnly={!editable} />
260
260
  )
package/src/html/index.js CHANGED
@@ -12,7 +12,7 @@ export { RadioButton } from './radio'
12
12
  export { Section } from './section'
13
13
  export { Tabs, Tab, Stack } from './tab'
14
14
  export { DataTable } from './table'
15
- export { Text } from './text'
15
+ export { Text, TEXTFORMATS } from './text'
16
16
  export { TextField, DropDown, TextArea } from './textfield'
17
17
  export { TokenField } from './tokenfield'
18
18
  export { Tree, TreeNode, TreeItem } from './tree'
File without changes
@@ -0,0 +1,29 @@
1
+ import React from 'react'
2
+ import './label.css'
3
+
4
+ export const Label = (props) => {
5
+
6
+ export const FORMATS = {
7
+ NONE: '',
8
+ NUMERIC: 'numeric',
9
+ DATE: 'date',
10
+ TIME: 'time',
11
+ EMAIL: 'email',
12
+ HTML: 'HTML',
13
+ URL: 'URL'
14
+ }
15
+
16
+ const { text, format = FORMATS.NONE } = props
17
+
18
+ let value = text
19
+ const formatter = Intl.NumberFormat()
20
+ switch (format) {
21
+ case FORMATS.NUMERIC: value = formatter.format(text); break;
22
+ }
23
+
24
+ return (
25
+ <label className={`label ${style}`}>
26
+ {value}
27
+ </label>
28
+ )
29
+ }
File without changes
@@ -1,5 +1,4 @@
1
1
  import React, { useState } from 'react'
2
- import { FORMATS } from '../domain/ContentType'
3
2
  import { Property } from './property'
4
3
 
5
4
  const PropertyTest = (prop) => {
package/src/html/text.js CHANGED
@@ -1,20 +1,39 @@
1
1
  import React, { useContext } from "react"
2
2
  import { SiteContext } from "../site/siteContext"
3
3
 
4
+ export const TEXTFORMATS = {
5
+ NONE: '',
6
+ NUMERIC: 'numeric',
7
+ DATE: 'date',
8
+ TIME: 'time',
9
+ EMAIL: 'email',
10
+ HTML: 'HTML',
11
+ URL: 'URL'
12
+ }
13
+
4
14
  /**
5
15
  * Text
6
16
  */
7
- export const Text = ({ children }) => {
17
+ export const Text = ({ format, children }) => {
18
+
19
+ const site = useContext(SiteContext)
20
+
21
+ console.log('xxx',format, site)
8
22
 
9
- const site = useContext(SiteContext)
23
+ let value = children
10
24
 
11
- if (site) {
12
- const { lang, dictionary = {}} = site
13
- const term = dictionary[children]
14
- const text = term ? term[lang] : children
15
- return text ? <span>{text}</span> : ''
16
- }
25
+ if (site) {
26
+ const { lang, dictionary = {} } = site
27
+ const term = dictionary[children]
28
+ const text = term ? term[lang] : children
29
+ if (text) value=text
30
+ }
31
+
32
+ const formatter = Intl.NumberFormat()
33
+ switch (format) {
34
+ case FORMATS.NUMERIC: value = formatter.format(children); break;
35
+ }
17
36
 
18
- return children ? <span>{children}</span> : ''
37
+ return children ? <span>{value}</span> : ''
19
38
 
20
39
  }
@@ -0,0 +1,11 @@
1
+ import React, { useState } from 'react'
2
+ import { Text, FORMATS } from './text'
3
+
4
+ const TextTest = (prop) => {
5
+
6
+ return (
7
+ <>
8
+ <Text format={FORMATS.NUMERIC}>345356345.345</Text>
9
+ </>
10
+ )
11
+ }
@@ -116,7 +116,7 @@ export const TextField = (props) => {
116
116
  export const DropDown = (props) => {
117
117
 
118
118
  const site = useContext(SiteContext)
119
- const { id, options = [], value, onChange, canFilter = false, readOnly = false } = props
119
+ const { id, options = [], value, onChange, predictive = false, readOnly = false } = props
120
120
  const [open, setOpen] = useState(false)
121
121
  const [label, setLabel] = useState()
122
122
 
@@ -129,7 +129,7 @@ export const DropDown = (props) => {
129
129
  }, [value])
130
130
 
131
131
  function change(id, value) {
132
- if (canFilter) {
132
+ if (predictive) {
133
133
  setLabel(value)
134
134
  } else {
135
135
  if (onChange) onChange(id, value)
@@ -158,7 +158,7 @@ export const DropDown = (props) => {
158
158
  function renderOptions() {
159
159
  const canShow = open == true && Array.isArray(options)
160
160
  if (canShow) {
161
- const filterActive = canFilter === true && label && label.length > 0
161
+ const filterActive = predictive === true && label && label.length > 0
162
162
  const items = filterActive ? options.filter(option => option.label.toUpperCase().indexOf(label.toUpperCase()) >= 0) : options
163
163
  const lis = items.map(option => <li key={option.value} value={option.value}>{option.label}</li>)
164
164
  return <menu><ul onClick={select}>{lis}</ul></menu>
@@ -167,6 +167,8 @@ export const DropDown = (props) => {
167
167
  }
168
168
  }
169
169
 
170
+ console.log('dropdown',id, 'predictive', predictive)
171
+
170
172
  return (
171
173
  <div className="dropdown">
172
174
  <TextField {...props} onClick={toggle} value={label} onChange={change} />
@@ -7,15 +7,23 @@ const TextFieldTest = (prop) => {
7
7
  const [form, setForm] = useState({})
8
8
 
9
9
  function change(id, value) {
10
- const next = Object.assign({}, form, { [id]: value })
10
+ const next = Object.assign({}, form, { [id]: value })
11
11
  setForm(next)
12
12
  }
13
13
 
14
+ const options = [
15
+ { label: "One", value: "1" },
16
+ { label: "Two", value: "2" },
17
+ { label: "Three", value: "3" },
18
+ { label: "Four", value: "4" },
19
+ { label: "Five", value: "5" },
20
+ ]
21
+
14
22
  return (
15
23
  <>
16
- <TextArea id="text1" label="Text 1" value={form.text1} onChange={change}/>
17
- <TextField id="date1" type="DATE" label="Date" value={form.date1} onChange={change}/>
18
- <DropDown id="gender1" label="Gender" value={form.gender1} onChange={change} options={[ {label: "Male", value: "M"}, { label: "Female", value: "F" }]} />
24
+ <DropDown id="gender1" label="Dropdown" value={form.gender1} onChange={change} options={options} predictive={true}/>
25
+ <TextArea id="text1" label="Text 1" value={form.text1} onChange={change} />
26
+ <TextField id="date1" type="DATE" label="Date" value={form.date1} onChange={change} />
19
27
  </>
20
28
  )
21
29
  }
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import { LoginBox } from './LoginBox'
3
+
4
+ const LoginBoxTest = (prop) => {
5
+
6
+ return (
7
+
8
+ <LoginBox />
9
+
10
+ )
11
+ }