ywana-core8 0.0.246 → 0.0.250

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.246",
3
+ "version": "0.0.250",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
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,36 @@
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 }) => {
8
18
 
9
- const site = useContext(SiteContext)
19
+ const site = useContext(SiteContext)
20
+ let value = children
10
21
 
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
- }
22
+ if (site) {
23
+ const { lang, dictionary = {} } = site
24
+ const term = dictionary[children]
25
+ const text = term ? term[lang] : children
26
+ if (text) value=text
27
+ }
28
+
29
+ const formatter = Intl.NumberFormat()
30
+ switch (format) {
31
+ case TEXTFORMATS.NUMERIC: value = formatter.format(children); break;
32
+ }
17
33
 
18
- return children ? <span>{children}</span> : ''
34
+ return children ? <span>{value}</span> : ''
19
35
 
20
36
  }
@@ -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
+ }