ywana-core8 0.0.474 → 0.0.477
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 +71 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +71 -33
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +71 -33
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.js +20 -6
- package/src/domain/TabbedTablePage.js +1 -1
- package/src/html/tab.js +3 -2
- package/src/html/textfield.test.js +2 -1
- package/src/html/tokenfield.js +1 -1
package/package.json
CHANGED
@@ -15,9 +15,9 @@ import "./CollectionPage.css"
|
|
15
15
|
export const CollectionPage = (props) => {
|
16
16
|
|
17
17
|
const site = useContext(SiteContext)
|
18
|
-
const { id = "collection", icon, title, name = "Collection 1", schema, url,
|
18
|
+
const { id = "collection", icon, title, name = "Collection 1", schema, url, field, host, page, fetching= false, groupBy, editor, autosave = false, delay = 1000, actions, levels, onSelect, children } = props
|
19
19
|
const [pageContext, setPageContext] = useContext(PageContext)
|
20
|
-
const context = CollectionContext(url, field, host, page)
|
20
|
+
const context = CollectionContext(url, field, host, page, fetching)
|
21
21
|
|
22
22
|
useEffect(async () => {
|
23
23
|
await context.load()
|
@@ -237,7 +237,7 @@ const CollectionEditor = (props) => {
|
|
237
237
|
/**
|
238
238
|
* Collection Context
|
239
239
|
*/
|
240
|
-
export const CollectionContext = (url, field, host, page) => {
|
240
|
+
export const CollectionContext = (url, field, host, page, fetching) => {
|
241
241
|
|
242
242
|
const API = CollectionAPI(url, host)
|
243
243
|
|
@@ -256,9 +256,23 @@ export const CollectionContext = (url, field, host, page) => {
|
|
256
256
|
return
|
257
257
|
},
|
258
258
|
|
259
|
-
select(id) {
|
260
|
-
|
261
|
-
|
259
|
+
async select(id) {
|
260
|
+
if (fetching) {
|
261
|
+
const result = await this.fetch(id)
|
262
|
+
this.selected = result
|
263
|
+
} else {
|
264
|
+
const result = this.all.find(item => item.id === id);
|
265
|
+
this.selected = result;
|
266
|
+
}
|
267
|
+
},
|
268
|
+
|
269
|
+
async fetch(id) {
|
270
|
+
try {
|
271
|
+
const result = await API.find(id)
|
272
|
+
return result
|
273
|
+
} catch (error) {
|
274
|
+
console.log(error)
|
275
|
+
}
|
262
276
|
},
|
263
277
|
|
264
278
|
clear() {
|
@@ -152,7 +152,7 @@ export const TabbedTablePage = (props) => {
|
|
152
152
|
function renderTabs() {
|
153
153
|
const selected = tab ? tab.value : null
|
154
154
|
return (
|
155
|
-
<Tabs selected={selected} onChange={changeTab}>
|
155
|
+
<Tabs selected={selected} onChange={changeTab} fillRight={true} fillLeft={false}>
|
156
156
|
{tabs.map(tab => <Tab id={tab.value} label={tab.label} />)}
|
157
157
|
</Tabs>
|
158
158
|
)
|
package/src/html/tab.js
CHANGED
@@ -7,7 +7,7 @@ import './tab.css'
|
|
7
7
|
*/
|
8
8
|
export const Tabs = (props) => {
|
9
9
|
|
10
|
-
const { children, selected, onChange } = props
|
10
|
+
const { children, selected, onChange, fillLeft=false, fillRight=true } = props
|
11
11
|
|
12
12
|
const tabs = React.Children.map(children, (child, index) => {
|
13
13
|
|
@@ -23,8 +23,9 @@ export const Tabs = (props) => {
|
|
23
23
|
|
24
24
|
return (
|
25
25
|
<div className="tabs">
|
26
|
+
{ fillLeft ? <div className="tab-filler" /> : null }
|
26
27
|
{tabs}
|
27
|
-
<div className="tab-filler" />
|
28
|
+
{ fillRight ? <div className="tab-filler" /> : null }
|
28
29
|
</div>
|
29
30
|
)
|
30
31
|
}
|
@@ -25,10 +25,11 @@ const TextFieldTest = (prop) => {
|
|
25
25
|
{ label: "NO", value: "false" },
|
26
26
|
]
|
27
27
|
|
28
|
+
console.log(form)
|
28
29
|
return (
|
29
30
|
<>
|
30
31
|
<DropDown id="b1" label="Boolean1" onChange={change} options={options2} value={form.b1} />
|
31
|
-
<TokenField id="token1" label="Tokens" onChange={change}
|
32
|
+
<TokenField id="token1" label="Tokens" onChange={change} />
|
32
33
|
<TextField id="name" label="Name" value={form.name} onChange={change} />
|
33
34
|
<DropDown id="gender1" label="Dropdown 1" value={form.gender1} onChange={change} options={options} predictive={false}/>
|
34
35
|
<DropDown id="gender2" label="Dropdown 2" value={form.gender2} onChange={change} options={options} predictive={true}/>
|
package/src/html/tokenfield.js
CHANGED
@@ -33,7 +33,7 @@ export const TokenField = ({ id, label, tokens = [], readOnly, options, onChange
|
|
33
33
|
event.preventDefault()
|
34
34
|
event.stopPropagation()
|
35
35
|
const token = event.target.value
|
36
|
-
const next = tokens.concat(token)
|
36
|
+
const next = tokens.concat(token.trim())
|
37
37
|
if (onChange) onChange(id, next)
|
38
38
|
setValue('')
|
39
39
|
}
|