ywana-core8 0.0.244 → 0.0.248
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 +36 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +35 -14
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +36 -14
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentEditor.js +1 -1
- package/src/html/index.js +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 +28 -9
- package/src/html/text.test.js +11 -0
- package/src/html/textfield.js +5 -3
- package/src/html/textfield.test.js +12 -4
- package/src/widgets/login/LoginBox.test.js +11 -0
package/package.json
CHANGED
@@ -254,7 +254,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
|
|
254
254
|
case FORMATS.DATE: return <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} />
|
255
255
|
default:
|
256
256
|
return options ? (
|
257
|
-
<DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable}
|
257
|
+
<DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} predictive={predictive} />
|
258
258
|
) : (
|
259
259
|
<TextField outlined={outlined} id={id} label={label} value={value} onChange={change} readOnly={!editable} />
|
260
260
|
)
|
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
|
package/src/html/text.js
CHANGED
@@ -1,20 +1,39 @@
|
|
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 }) => {
|
18
|
+
|
19
|
+
const site = useContext(SiteContext)
|
20
|
+
|
21
|
+
console.log('xxx',format, site)
|
8
22
|
|
9
|
-
|
23
|
+
let value = children
|
10
24
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
25
|
+
if (site) {
|
26
|
+
const { lang, dictionary = {} } = site
|
27
|
+
const term = dictionary[children]
|
28
|
+
const text = term ? term[lang] : children
|
29
|
+
if (text) value=text
|
30
|
+
}
|
31
|
+
|
32
|
+
const formatter = Intl.NumberFormat()
|
33
|
+
switch (format) {
|
34
|
+
case FORMATS.NUMERIC: value = formatter.format(children); break;
|
35
|
+
}
|
17
36
|
|
18
|
-
|
37
|
+
return children ? <span>{value}</span> : ''
|
19
38
|
|
20
39
|
}
|
package/src/html/textfield.js
CHANGED
@@ -116,7 +116,7 @@ export const TextField = (props) => {
|
|
116
116
|
export const DropDown = (props) => {
|
117
117
|
|
118
118
|
const site = useContext(SiteContext)
|
119
|
-
const { id, options = [], value, onChange,
|
119
|
+
const { id, options = [], value, onChange, predictive = false, readOnly = false } = props
|
120
120
|
const [open, setOpen] = useState(false)
|
121
121
|
const [label, setLabel] = useState()
|
122
122
|
|
@@ -129,7 +129,7 @@ export const DropDown = (props) => {
|
|
129
129
|
}, [value])
|
130
130
|
|
131
131
|
function change(id, value) {
|
132
|
-
if (
|
132
|
+
if (predictive) {
|
133
133
|
setLabel(value)
|
134
134
|
} else {
|
135
135
|
if (onChange) onChange(id, value)
|
@@ -158,7 +158,7 @@ export const DropDown = (props) => {
|
|
158
158
|
function renderOptions() {
|
159
159
|
const canShow = open == true && Array.isArray(options)
|
160
160
|
if (canShow) {
|
161
|
-
const filterActive =
|
161
|
+
const filterActive = predictive === true && label && label.length > 0
|
162
162
|
const items = filterActive ? options.filter(option => option.label.toUpperCase().indexOf(label.toUpperCase()) >= 0) : options
|
163
163
|
const lis = items.map(option => <li key={option.value} value={option.value}>{option.label}</li>)
|
164
164
|
return <menu><ul onClick={select}>{lis}</ul></menu>
|
@@ -167,6 +167,8 @@ export const DropDown = (props) => {
|
|
167
167
|
}
|
168
168
|
}
|
169
169
|
|
170
|
+
console.log('dropdown',id, 'predictive', predictive)
|
171
|
+
|
170
172
|
return (
|
171
173
|
<div className="dropdown">
|
172
174
|
<TextField {...props} onClick={toggle} value={label} onChange={change} />
|
@@ -7,15 +7,23 @@ const TextFieldTest = (prop) => {
|
|
7
7
|
const [form, setForm] = useState({})
|
8
8
|
|
9
9
|
function change(id, value) {
|
10
|
-
const next = Object.assign({}, form, {
|
10
|
+
const next = Object.assign({}, form, { [id]: value })
|
11
11
|
setForm(next)
|
12
12
|
}
|
13
13
|
|
14
|
+
const options = [
|
15
|
+
{ label: "One", value: "1" },
|
16
|
+
{ label: "Two", value: "2" },
|
17
|
+
{ label: "Three", value: "3" },
|
18
|
+
{ label: "Four", value: "4" },
|
19
|
+
{ label: "Five", value: "5" },
|
20
|
+
]
|
21
|
+
|
14
22
|
return (
|
15
23
|
<>
|
16
|
-
<
|
17
|
-
<
|
18
|
-
<
|
24
|
+
<DropDown id="gender1" label="Dropdown" value={form.gender1} onChange={change} options={options} predictive={true}/>
|
25
|
+
<TextArea id="text1" label="Text 1" value={form.text1} onChange={change} />
|
26
|
+
<TextField id="date1" type="DATE" label="Date" value={form.date1} onChange={change} />
|
19
27
|
</>
|
20
28
|
)
|
21
29
|
}
|