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/dist/index.cjs +23 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +23 -3
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +23 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/label.css +0 -0
- package/src/html/label.js +29 -0
- package/src/html/label.test.js +0 -0
- package/src/html/property.test.js +0 -1
- package/src/html/text.js +27 -9
- package/src/html/text.test.js +11 -0
package/package.json
CHANGED
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
|
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
|
-
|
18
|
+
const site = useContext(SiteContext)
|
10
19
|
|
11
|
-
|
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
|
-
|
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
|
}
|