ywana-core8 0.0.880 → 0.0.882
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 +33 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +33 -8
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +33 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/button.js +2 -4
- package/src/html/text.js +18 -6
- package/src/html/text.test.js +1 -0
- package/src/html/textfield.js +4 -3
- package/src/html/textfield.test.js +1 -1
- package/src/site/site.js +6 -0
package/package.json
CHANGED
package/src/html/button.js
CHANGED
@@ -20,10 +20,8 @@ export const Button = ({ label, icon, action, disabled = false, outlined, raised
|
|
20
20
|
if (disabled) style = `${style} disabled`
|
21
21
|
return (
|
22
22
|
<button className={`btn ${style} ${className}`} onClick={click}>
|
23
|
-
{icon ? <Icon icon={icon} size="small" clickable action={click} /> : null}
|
24
|
-
<
|
25
|
-
<Text>{label}</Text>
|
26
|
-
</span>
|
23
|
+
{ icon ? <Icon icon={icon} size="small" clickable action={click} /> : null }
|
24
|
+
<Text>{ label }</Text>
|
27
25
|
</button>
|
28
26
|
)
|
29
27
|
}
|
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,25 @@ 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
|
+
}
|
46
|
+
|
47
|
+
}
|
35
48
|
|
36
|
-
}
|
package/src/html/text.test.js
CHANGED
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 =
|
48
|
+
const placeholderTxt = site.translate ? site.translate(placeholder) : placeholder
|
49
49
|
|
50
50
|
return (
|
51
51
|
<div className={`${style} ${id}`} onClick={onClick}>
|
@@ -98,7 +98,8 @@ 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
|
-
|
101
|
+
|
102
|
+
const placeholderTxt = site.translate ? site.translate(placeholder) : placeholder
|
102
103
|
|
103
104
|
return (
|
104
105
|
<div className={`${style}`} onClick={onClick}>
|
@@ -43,7 +43,7 @@ const TextFieldTest = (prop) => {
|
|
43
43
|
<TokenField id="token2" label="Tokens DropDown" onChange={change} options={options} tokens={form.token2}/>
|
44
44
|
<br/>
|
45
45
|
<br/>
|
46
|
-
<TextArea id="text1" label="Text 1" value={form.text1} onChange={change} />
|
46
|
+
<TextArea id="text1" label="Text 1" value={form.text1} onChange={change} placeholder="loremitsum"/>
|
47
47
|
<TextField id="date1" type="DATE" label="Date" value={form.date1} onChange={change} />
|
48
48
|
<DateRange id="range1" value={form.range1} onChange={change}/>
|
49
49
|
</>
|
package/src/site/site.js
CHANGED
@@ -34,6 +34,12 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => {
|
|
34
34
|
|
35
35
|
dictionary,
|
36
36
|
setDictionary,
|
37
|
+
translate: (key) => {
|
38
|
+
if (!key) return key
|
39
|
+
if (dictionary === undefined) return key
|
40
|
+
const term = dictionary[key]
|
41
|
+
return term ? term[lang] : key
|
42
|
+
},
|
37
43
|
|
38
44
|
sideNav,
|
39
45
|
setSideNav,
|