ywana-core8 0.0.246 → 0.0.247

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.247",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
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,38 @@
1
1
  import React, { useContext } from "react"
2
2
  import { SiteContext } from "../site/siteContext"
3
+ export const FORMATS = {
4
+ NONE: '',
5
+ NUMERIC: 'numeric',
6
+ DATE: 'date',
7
+ TIME: 'time',
8
+ EMAIL: 'email',
9
+ HTML: 'HTML',
10
+ URL: 'URL'
11
+ }
3
12
 
4
13
  /**
5
14
  * Text
6
15
  */
7
- export const Text = ({ children }) => {
16
+ export const Text = ({ format, children }) => {
8
17
 
9
- const site = useContext(SiteContext)
18
+ const site = useContext(SiteContext)
10
19
 
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
- }
20
+ console.log('xxx',format, site)
17
21
 
18
- return children ? <span>{children}</span> : ''
22
+ let value = children
23
+
24
+ if (site) {
25
+ const { lang, dictionary = {} } = site
26
+ const term = dictionary[children]
27
+ const text = term ? term[lang] : children
28
+ if (text) value=text
29
+ }
30
+
31
+ const formatter = Intl.NumberFormat()
32
+ switch (format) {
33
+ case FORMATS.NUMERIC: value = formatter.format(children); break;
34
+ }
35
+
36
+ return children ? <span>{value}</span> : ''
19
37
 
20
38
  }
@@ -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
+ }