ywana-core8 0.1.44 → 0.1.46
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 +48 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +28 -9
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +48 -61
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +48 -61
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/checkbox.css +18 -9
- package/src/html/checkbox.js +30 -38
- package/src/html/textfield.css +4 -0
- package/src/widgets/upload/Upload.test.js +1 -1
- package/src/widgets/upload/UploadArea.css +6 -0
- package/src/widgets/upload/UploadArea.js +9 -6
- package/src/widgets/upload/UploadDialog.js +2 -2
- package/src/widgets/upload/Uploader.js +4 -4
package/package.json
CHANGED
package/src/html/checkbox.css
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
.checkbox .checkmark {
|
10
10
|
width: 1.5rem;
|
11
|
-
height: 1.
|
11
|
+
height: 1.5rem;
|
12
12
|
display: flex;
|
13
13
|
align-items: center;
|
14
14
|
justify-content: center;
|
@@ -18,6 +18,10 @@
|
|
18
18
|
padding-bottom: .1rem;
|
19
19
|
}
|
20
20
|
|
21
|
+
.checkbox.readonly>.checkmark {
|
22
|
+
border: solid 1px var(--text-color-light);
|
23
|
+
}
|
24
|
+
|
21
25
|
.checkbox .checkmark:after {
|
22
26
|
content: "";
|
23
27
|
width: 0.3rem;
|
@@ -31,7 +35,12 @@
|
|
31
35
|
z-index: 0;
|
32
36
|
}
|
33
37
|
|
34
|
-
.checkbox
|
38
|
+
.checkbox.readonly .checkmark:after {
|
39
|
+
border-color: var(--text-color-lighter);
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
.checkbox>input {
|
35
44
|
position: absolute;
|
36
45
|
flex: 1;
|
37
46
|
width: 2rem;
|
@@ -40,16 +49,16 @@
|
|
40
49
|
z-index: 1;
|
41
50
|
}
|
42
51
|
|
43
|
-
input:checked
|
44
|
-
|
45
|
-
|
52
|
+
input:checked~.checkmark:after {
|
53
|
+
display: block;
|
54
|
+
}
|
46
55
|
|
47
|
-
.checkbox
|
48
|
-
color: var(--text-color
|
56
|
+
.checkbox>label {
|
57
|
+
color: var(--text-color);
|
49
58
|
font-size: 1rem;
|
50
59
|
font-weight: normal;
|
51
60
|
}
|
52
61
|
|
53
|
-
.checkbox
|
54
|
-
|
62
|
+
.checkbox.readonly>label {
|
63
|
+
color: var(--text-color-light);
|
55
64
|
}
|
package/src/html/checkbox.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
import React from 'react'
|
1
|
+
import React, { useEffect } from 'react'
|
2
2
|
import { Text } from './text'
|
3
|
-
import { Icon } from './icon'
|
4
3
|
import './checkbox.css'
|
5
4
|
|
6
5
|
/**
|
@@ -8,58 +7,51 @@ import './checkbox.css'
|
|
8
7
|
*/
|
9
8
|
export const CheckBox = (props) => {
|
10
9
|
|
11
|
-
const { id, label,
|
10
|
+
const { id, label, value = false, readOnly = false, onChange } = props
|
11
|
+
|
12
|
+
const [checked, setChecked] = React.useState(value)
|
13
|
+
|
14
|
+
useEffect(() => {
|
15
|
+
setChecked(value)
|
16
|
+
}, [value])
|
12
17
|
|
13
18
|
function change(event) {
|
14
19
|
event.stopPropagation()
|
15
|
-
event.
|
16
|
-
|
17
|
-
if (onChange) onChange(id,
|
20
|
+
const nextValue = event.target.checked
|
21
|
+
setChecked(nextValue)
|
22
|
+
if (onChange) onChange(id, nextValue)
|
18
23
|
}
|
19
24
|
|
20
|
-
const labelTxt = <Text>{label}</Text>
|
21
|
-
const placeholderTxt = <Text>{placeholder}</Text>
|
25
|
+
const labelTxt = label && <Text>{label}</Text>
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<div className="checkbox" key={`${id}1`}>
|
27
|
-
<Icon id={id} icon="check" size="small" />
|
28
|
-
<span className="checkmark" />
|
29
|
-
<label htmlFor={id}>{labelTxt}</label>
|
30
|
-
</div>
|
31
|
-
) : (
|
32
|
-
<div className="checkbox" key={`${id}0`}>
|
33
|
-
<span className="checkmark" />
|
34
|
-
<label htmlFor={id}>{labelTxt}</label>
|
35
|
-
</div>
|
36
|
-
)
|
37
|
-
}
|
38
|
-
|
39
|
-
return value === true ? (
|
40
|
-
<div className="checkbox" key={`${id}1`}>
|
41
|
-
<input id={id} type="checkbox" placeholder={placeholderTxt} checked value={value} onChange={change} readOnly />
|
42
|
-
<span className="checkmark" />
|
43
|
-
<label htmlFor={id}>{labelTxt}</label>
|
44
|
-
</div>
|
45
|
-
) : (
|
46
|
-
<div className="checkbox" key={`${id}0`}>
|
47
|
-
<input id={id} type="checkbox" placeholder={placeholderTxt} value={value} onChange={change} readOnly />
|
27
|
+
return (
|
28
|
+
<div className={`checkbox ${readOnly ? "readonly" : ""}`} key={`${id}1`}>
|
29
|
+
<input id={id} key={`${id}_${checked}`} type="checkbox" checked={checked} onChange={change} disabled={readOnly} />
|
48
30
|
<span className="checkmark" />
|
49
31
|
<label htmlFor={id}>{labelTxt}</label>
|
50
32
|
</div>
|
51
33
|
)
|
52
34
|
}
|
53
35
|
|
54
|
-
|
55
36
|
const CheckBoxTest = (props) => {
|
56
37
|
|
38
|
+
const [checked, setChecked] = React.useState({
|
39
|
+
check1: true,
|
40
|
+
check2: false,
|
41
|
+
check3: true,
|
42
|
+
check4: false
|
43
|
+
})
|
44
|
+
|
45
|
+
function change(id, value) {
|
46
|
+
setChecked({ ...checked, [id]: value })
|
47
|
+
}
|
48
|
+
|
57
49
|
return (
|
58
50
|
<div>
|
59
|
-
<CheckBox id="check1" label="Check 1"
|
60
|
-
<CheckBox id="check2" label="Check 2"
|
61
|
-
<CheckBox id="check3" label="Check 3"
|
62
|
-
<CheckBox id="check4" label="Check 4"
|
51
|
+
<CheckBox id="check1" label="Check 1" value={checked.check1} onChange={change} />
|
52
|
+
<CheckBox id="check2" label="Check 2" value={checked.check2} onChange={change} />
|
53
|
+
<CheckBox id="check3" label="Check 3" value={checked.check3} onChange={change} readOnly/>
|
54
|
+
<CheckBox id="check4" label="Check 4" value={checked.check4} onChange={change} readOnly/>
|
63
55
|
</div>
|
64
56
|
)
|
65
57
|
}
|
package/src/html/textfield.css
CHANGED
@@ -7,7 +7,7 @@ import { UPLOAD_STATES } from './UploadStates'
|
|
7
7
|
const UploadAreaTest = (props) => {
|
8
8
|
return (
|
9
9
|
<div style={{ padding: "1rem" }}>
|
10
|
-
<UploadArea icon="cloud_upload" label="UploadArea Test" />
|
10
|
+
<UploadArea icon="cloud_upload" label="UploadArea Test" disabled={true} />
|
11
11
|
</div>
|
12
12
|
)
|
13
13
|
}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import React, { useState, useEffect, useRef } from 'react'
|
2
2
|
import { Icon } from '../../html'
|
3
|
-
|
3
|
+
import './UploadArea.css'
|
4
4
|
/**
|
5
5
|
* Upload Area
|
6
6
|
*/
|
7
7
|
export const UploadArea = (props) => {
|
8
8
|
|
9
|
-
const { icon, label = 'Add file or drop file here...' } = props
|
9
|
+
const { icon, label = 'Add file or drop file here...', disabled= false } = props
|
10
10
|
const areaElement = useRef()
|
11
11
|
const [drag, setDrag] = useState(false)
|
12
12
|
const { resumable } = props
|
@@ -18,22 +18,25 @@ export const UploadArea = (props) => {
|
|
18
18
|
}, [])
|
19
19
|
|
20
20
|
const onDragOver = () => {
|
21
|
+
if (disabled) return
|
21
22
|
setDrag(true)
|
22
23
|
}
|
23
24
|
|
24
25
|
const onDragLeave = () => {
|
26
|
+
if (disabled) return
|
25
27
|
setDrag(false)
|
26
28
|
}
|
27
29
|
|
28
30
|
const dragging = drag === true ? 'drag-over' : ''
|
31
|
+
const disabledStyle = disabled === true ? 'disabled' : ''
|
29
32
|
|
30
33
|
return (
|
31
|
-
<div className={`upload-area6 ${dragging}`}
|
34
|
+
<div className={`upload-area6 ${dragging} ${disabledStyle}`}
|
32
35
|
onDragOver={onDragOver}
|
33
36
|
onDragLeave={onDragLeave}
|
34
37
|
ref={areaElement}
|
35
38
|
>
|
36
|
-
<UploadIcon resumable={resumable}/>
|
39
|
+
<UploadIcon icon={icon} resumable={resumable} disabled={disabled}/>
|
37
40
|
<label>{label}</label>
|
38
41
|
</div>
|
39
42
|
)
|
@@ -42,7 +45,7 @@ export const UploadArea = (props) => {
|
|
42
45
|
/**
|
43
46
|
* Upload Icon
|
44
47
|
*/
|
45
|
-
export const UploadIcon = ({ icon = "folder_open", resumable }) => {
|
48
|
+
export const UploadIcon = ({ icon = "folder_open", resumable, disabled=false }) => {
|
46
49
|
|
47
50
|
const iconElement = useRef()
|
48
51
|
|
@@ -54,7 +57,7 @@ export const UploadIcon = ({ icon = "folder_open", resumable }) => {
|
|
54
57
|
|
55
58
|
return (
|
56
59
|
<div className="upload-icon" ref={iconElement}>
|
57
|
-
<Icon icon={icon} clickable/>
|
60
|
+
<Icon icon={icon} clickable disabled={disabled}/>
|
58
61
|
</div>
|
59
62
|
)
|
60
63
|
}
|
@@ -6,7 +6,7 @@ import { SiteContext, Dialog } from '../../site';
|
|
6
6
|
/**
|
7
7
|
* Upload Dialog
|
8
8
|
*/
|
9
|
-
export const UploadDialog = ({ label, target, accept, onSuccess, onComplete, onClose, children, className, disabled, onCanClose, overlayCanClose = true }) => {
|
9
|
+
export const UploadDialog = ({ label, target, accept, onSuccess, onComplete, onClose, children, className, disabled=false, onCanClose, overlayCanClose = true }) => {
|
10
10
|
|
11
11
|
const site = useContext(SiteContext);
|
12
12
|
|
@@ -38,7 +38,7 @@ export const UploadDialog = ({ label, target, accept, onSuccess, onComplete, onC
|
|
38
38
|
const title = <Text use="headline6">{label}</Text>
|
39
39
|
return (
|
40
40
|
<Dialog title={title} open={true} onAction={onAction} actions={actions} className={className} overlayCanClose={overlayCanClose}>
|
41
|
-
|
41
|
+
<Uploader label={label} accept={accept} target={target} onSuccess={success} onComplete={complete} disabled={disabled} />
|
42
42
|
{children}
|
43
43
|
</Dialog>
|
44
44
|
)
|
@@ -9,7 +9,7 @@ import './Uploader.css'
|
|
9
9
|
/**
|
10
10
|
* Uploader
|
11
11
|
*/
|
12
|
-
export const Uploader = ({ icon, label, view="area", target, accept, simultaneousUploads = 1, className, onProgress, onSuccess, onError, onComplete }) => {
|
12
|
+
export const Uploader = ({ icon, label, view="area", target, accept, simultaneousUploads = 1, className, onProgress, onSuccess, onError, onComplete, disabled = false }) => {
|
13
13
|
|
14
14
|
const resumable = useMemo(() => {
|
15
15
|
const config = {
|
@@ -65,9 +65,9 @@ export const Uploader = ({ icon, label, view="area", target, accept, simultaneou
|
|
65
65
|
|
66
66
|
function renderView() {
|
67
67
|
switch (view) {
|
68
|
-
case "area": return <UploadArea resumable={resumable} icon={icon} label={label} />
|
69
|
-
case "icon": return <UploadIcon resumable={resumable} icon={icon} />
|
70
|
-
default: return <UploadArea resumable={resumable} icon={icon} label={label} />
|
68
|
+
case "area": return <UploadArea resumable={resumable} icon={icon} label={label} disabled={disabled} />
|
69
|
+
case "icon": return <UploadIcon resumable={resumable} icon={icon} disabled={disabled} />
|
70
|
+
default: return <UploadArea resumable={resumable} icon={icon} label={label} disabled={disabled} />
|
71
71
|
}
|
72
72
|
}
|
73
73
|
|