ywana-core8 0.0.879 → 0.0.881
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 +29 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +29 -6
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +29 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/text.js +16 -5
- package/src/html/textfield.js +3 -3
package/package.json
CHANGED
package/src/html/text.js
CHANGED
@@ -8,13 +8,14 @@ export const TEXTFORMATS = {
|
|
8
8
|
TIME: 'time',
|
9
9
|
EMAIL: 'email',
|
10
10
|
HTML: 'HTML',
|
11
|
-
URL: 'URL'
|
11
|
+
URL: 'URL',
|
12
|
+
STRING: 'string',
|
12
13
|
}
|
13
14
|
|
14
15
|
/**
|
15
16
|
* Text
|
16
17
|
*/
|
17
|
-
export const Text = ({ format, children }) => {
|
18
|
+
export const Text = ({ format = TEXTFORMATS.HTML, children, className }) => {
|
18
19
|
|
19
20
|
const site = useContext(SiteContext)
|
20
21
|
let value = children
|
@@ -23,14 +24,24 @@ export const Text = ({ format, children }) => {
|
|
23
24
|
const { lang, dictionary = {} } = site
|
24
25
|
const term = dictionary[children]
|
25
26
|
const text = term ? term[lang] : children
|
26
|
-
if (text) value = text
|
27
|
+
if (text) value = text
|
27
28
|
}
|
28
|
-
|
29
|
+
|
29
30
|
const formatter = Intl.NumberFormat()
|
30
31
|
switch (format) {
|
31
32
|
case TEXTFORMATS.NUMERIC: value = formatter.format(children); break;
|
32
33
|
}
|
33
34
|
|
34
|
-
|
35
|
+
switch (format) {
|
36
|
+
case TEXTFORMATS.DATE: value = new Date(children).toLocaleDateString(); break;
|
37
|
+
case TEXTFORMATS.TIME: value = new Date(children).toLocaleTimeString(); break;
|
38
|
+
}
|
39
|
+
|
40
|
+
if (!children) return ''
|
41
|
+
|
42
|
+
switch (format) {
|
43
|
+
case TEXTFORMATS.STRING: return value
|
44
|
+
default: return <span className={className}>{value}</span>
|
45
|
+
}
|
35
46
|
|
36
47
|
}
|
package/src/html/textfield.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { useContext, useEffect, useState } from 'react'
|
2
2
|
import { SiteContext } from '../site/siteContext'
|
3
3
|
import { Icon } from './icon'
|
4
|
-
import { Text } from './text'
|
4
|
+
import { TEXTFORMATS, Text } from './text'
|
5
5
|
import './textfield-outlined.css'
|
6
6
|
import './textfield.css'
|
7
7
|
import './textarea.css'
|
@@ -45,7 +45,7 @@ export const TextField = (props) => {
|
|
45
45
|
const labelPositionStyle = labelPosition == 'left' ? "label-left" : "label-top"
|
46
46
|
const style = `${labelStyle} ${labelPositionStyle} ${borderStyle} textfield-${type}`
|
47
47
|
const labelTxt = <Text>{label}</Text>
|
48
|
-
const placeholderTxt = placeholder ? <Text>{placeholder}</Text> : null
|
48
|
+
const placeholderTxt = placeholder ? <Text format={TEXTFORMATS.STRING}>{placeholder}</Text> : null
|
49
49
|
|
50
50
|
return (
|
51
51
|
<div className={`${style} ${id}`} onClick={onClick}>
|
@@ -98,7 +98,7 @@ export const TextArea = (props) => {
|
|
98
98
|
const labelStyle = label ? "" : "no-label"
|
99
99
|
const style = `textarea ${labelStyle} textarea-${type}`
|
100
100
|
const labelTxt = <Text>{label}</Text>
|
101
|
-
const placeholderTxt = <Text>{placeholder}</Text>
|
101
|
+
const placeholderTxt = <Text format={TEXTFORMATS.STRING} >{placeholder}</Text>
|
102
102
|
|
103
103
|
return (
|
104
104
|
<div className={`${style}`} onClick={onClick}>
|