@zuzjs/ui 0.3.3 → 0.3.5
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/README.md +0 -0
- package/dist/hooks.js +89 -0
- package/dist/styles.css +37 -62
- package/dist/ui.js +679 -0
- package/jest.config.js +0 -0
- package/package.json +17 -18
- package/rollup.config.js +30 -47
- package/tsconfig.json +0 -0
- package/tsconfig.lib.json +0 -0
- package/tsconfig.spec.json +0 -0
- package/dist/index.js +0 -1879
- package/src/actions/addForm.tsx +0 -0
- package/src/actions/index.tsx +0 -29
- package/src/actions/redo.tsx +0 -1
- package/src/actions/reset.tsx +0 -1
- package/src/actions/undo.tsx +0 -1
- package/src/comps/app.tsx +0 -34
- package/src/comps/box.tsx +0 -28
- package/src/comps/button.tsx +0 -47
- package/src/comps/checkbox.tsx +0 -74
- package/src/comps/component.tsx +0 -32
- package/src/comps/contextmenu.tsx +0 -60
- package/src/comps/cover.tsx +0 -34
- package/src/comps/form.tsx +0 -89
- package/src/comps/heading.tsx +0 -31
- package/src/comps/icon.tsx +0 -36
- package/src/comps/image.tsx +0 -34
- package/src/comps/input.tsx +0 -224
- package/src/comps/masonry.tsx +0 -192
- package/src/comps/mediaplayer.tsx +0 -12
- package/src/comps/placeholder.tsx +0 -58
- package/src/comps/root.tsx +0 -32
- package/src/comps/select.tsx +0 -63
- package/src/comps/spacer.tsx +0 -20
- package/src/comps/spinner.tsx +0 -36
- package/src/comps/text.tsx +0 -27
- package/src/comps/toaster.tsx +0 -123
- package/src/comps/tweet.tsx +0 -48
- package/src/context/AppContext.tsx +0 -3
- package/src/context/AppProvider.tsx +0 -106
- package/src/context/_AppProvider.tsx +0 -116
- package/src/context/combineReducers.tsx +0 -47
- package/src/context/combineState.tsx +0 -14
- package/src/context/createSlice.tsx +0 -40
- package/src/context/index.tsx +0 -6
- package/src/context/reduceReducers.tsx +0 -6
- package/src/context/store/appbase.tsx +0 -19
- package/src/context/store/lang.tsx +0 -26
- package/src/context/store/theme.tsx +0 -54
- package/src/core/extractCurrentDesignState.tsx +0 -0
- package/src/core/index.ts +0 -431
- package/src/core/router.ts +0 -86
- package/src/core/styles.ts +0 -372
- package/src/hooks/index.tsx +0 -10
- package/src/hooks/useAppReducer.tsx +0 -40
- package/src/hooks/useChooseEffect.tsx +0 -6
- package/src/hooks/useContextMenu.tsx +0 -123
- package/src/hooks/useDevice.tsx +0 -168
- package/src/hooks/useDispatch.tsx +0 -37
- package/src/hooks/useImage.tsx +0 -84
- package/src/hooks/useLang.tsx +0 -9
- package/src/hooks/useMediaPlayer.tsx +0 -27
- package/src/hooks/useNavigator.tsx +0 -6
- package/src/hooks/useRender.tsx +0 -29
- package/src/hooks/useResizeObserver.tsx +0 -84
- package/src/hooks/useRouter.tsx +0 -45
- package/src/hooks/useSelector.tsx +0 -9
- package/src/hooks/useStore.tsx +0 -27
- package/src/hooks/useTheme.tsx +0 -9
- package/src/hooks/useToast.tsx +0 -11
- package/src/index.tsx +0 -33
- package/src/kit/Builder.tsx +0 -18
- package/src/kit/Component.tsx +0 -32
- package/src/kit/Header.tsx +0 -21
- package/src/scss/constants.scss +0 -4
- package/src/scss/mixins.scss +0 -3
- package/src/scss/props.scss +0 -70
- package/src/scss/style.scss +0 -133
package/src/actions/addForm.tsx
DELETED
|
File without changes
|
package/src/actions/index.tsx
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { UNDO } from './undo'
|
|
2
|
-
import { REDO } from './redo'
|
|
3
|
-
import { RESET } from './reset'
|
|
4
|
-
|
|
5
|
-
export const ADD_FORM = (name, fields, forms) => ({
|
|
6
|
-
forms: {
|
|
7
|
-
...forms,
|
|
8
|
-
[name] : { touched: false, loading: false, ...fields }
|
|
9
|
-
}
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
export const UPDATE_FORM_FIELD = (formName, field, value, forms) => {
|
|
13
|
-
if(forms[formName]){
|
|
14
|
-
let _forms = {
|
|
15
|
-
...forms
|
|
16
|
-
}
|
|
17
|
-
_forms[formName][field] = value;
|
|
18
|
-
return {
|
|
19
|
-
forms: _forms
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return {}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
UNDO,
|
|
27
|
-
REDO,
|
|
28
|
-
RESET
|
|
29
|
-
}
|
package/src/actions/redo.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const REDO = 'REDO';
|
package/src/actions/reset.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const RESET = 'RESET';
|
package/src/actions/undo.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const UNDO = 'UNDO';
|
package/src/comps/app.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
forwardRef,
|
|
3
|
-
useEffect
|
|
4
|
-
} from 'react';
|
|
5
|
-
import { setCSSVar, buildCSS } from '../core'
|
|
6
|
-
import { Provider } from '../context'
|
|
7
|
-
import { ClassNames } from '@emotion/react'
|
|
8
|
-
import { useStore } from '../hooks'
|
|
9
|
-
|
|
10
|
-
const AppMain = forwardRef((props : { [ key: string ] : any }, ref) => {
|
|
11
|
-
|
|
12
|
-
// const { dispatch } = useStore()
|
|
13
|
-
|
|
14
|
-
// if("theme" in props && !theme){
|
|
15
|
-
// dispatch(setTheme(props.theme));
|
|
16
|
-
// }
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<ClassNames>
|
|
20
|
-
{({ css, cx }) => <main className={`${props.as ? props.as : `zuz-app`} ${cx(css`${buildCSS(props)} &:hover {${buildCSS(props.hover || {})}} &:active {${buildCSS(props.active || {})}}`)}`}>{props.children}</main>}
|
|
21
|
-
</ClassNames>
|
|
22
|
-
)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const App = forwardRef((props : { [ key: string ] : any }, ref) => {
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<Provider>
|
|
29
|
-
<AppMain />
|
|
30
|
-
</Provider>
|
|
31
|
-
)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
export default App
|
package/src/comps/box.tsx
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
forwardRef,
|
|
3
|
-
useEffect
|
|
4
|
-
} from 'react';
|
|
5
|
-
import { ClassNames } from '@emotion/react'
|
|
6
|
-
import { cleanProps, buildCSS } from '../core'
|
|
7
|
-
|
|
8
|
-
const Box = forwardRef((props : { [ key: string ] : any }, ref) => {
|
|
9
|
-
|
|
10
|
-
const _noClick = () => {}
|
|
11
|
-
|
|
12
|
-
// console.log(props)
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<ClassNames>
|
|
16
|
-
{({ css, cx }) => <div
|
|
17
|
-
{...cleanProps(props)}
|
|
18
|
-
title={props.title || undefined}
|
|
19
|
-
id={props.id || undefined}
|
|
20
|
-
onDoubleClick={props.onDoubleClick || undefined}
|
|
21
|
-
onClick={props.onClick || _noClick}
|
|
22
|
-
className={`${props.as ? `${props.as} ` : ``}${cx(css`${buildCSS(props)} &:hover {${buildCSS(props.hover || {})}} &:active {${buildCSS(props.active || {})}}`)}`}
|
|
23
|
-
ref={props.bref || ref}>{props.html ? <span dangerouslySetInnerHTML={{ __html: props.html }} /> : props.children}</div>}
|
|
24
|
-
</ClassNames>
|
|
25
|
-
)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
export default Box;
|
package/src/comps/button.tsx
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
forwardRef,
|
|
3
|
-
LegacyRef
|
|
4
|
-
} from 'react';
|
|
5
|
-
import { ClassNames } from '@emotion/react'
|
|
6
|
-
import {
|
|
7
|
-
buildCSS,
|
|
8
|
-
cleanProps
|
|
9
|
-
} from '../core'
|
|
10
|
-
import { useStore } from '../hooks'
|
|
11
|
-
import { STORE_FORM_KEY } from '../context/AppProvider'
|
|
12
|
-
const Button = forwardRef((props: { [ key: string ] : any }, ref : LegacyRef<HTMLButtonElement>) => {
|
|
13
|
-
|
|
14
|
-
const { forms } = useStore(state => state[STORE_FORM_KEY], false);
|
|
15
|
-
const _otherProps = {}
|
|
16
|
-
if(props.html){
|
|
17
|
-
_otherProps['dangerouslySetInnerHTML'] = { __html: props.html }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<ClassNames>
|
|
22
|
-
{({ css, cx }) => {
|
|
23
|
-
return (
|
|
24
|
-
<button
|
|
25
|
-
{...cleanProps(props)}
|
|
26
|
-
title={"title" in props ? props.title : undefined}
|
|
27
|
-
type={props.type}
|
|
28
|
-
className={`button${props.as ? ` ${props.as}` : ``} ${cx(css`
|
|
29
|
-
padding: 5px 10px;
|
|
30
|
-
border-radius: 2px;
|
|
31
|
-
${buildCSS(props)} &:hover {${buildCSS(props.hover || {})}} &:active {${buildCSS(props.active || {})}}`)}`}
|
|
32
|
-
ref={ref}
|
|
33
|
-
onDoubleClick={props.onDoubleClick || undefined}
|
|
34
|
-
onClick={e => {
|
|
35
|
-
if(props.form && props.type && props.type == 'submit'){
|
|
36
|
-
props.onSubmit(forms[props.form]);
|
|
37
|
-
}else{
|
|
38
|
-
props.onClick ? props.onClick(e) : () => console.warn('onClick Missing')
|
|
39
|
-
}
|
|
40
|
-
}} disabled={props.disabled || false} >{props.html ? <span dangerouslySetInnerHTML={{ __html: props.html }} /> : props.children}</button>
|
|
41
|
-
)
|
|
42
|
-
}}
|
|
43
|
-
</ClassNames>
|
|
44
|
-
)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
export default Button;
|
package/src/comps/checkbox.tsx
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import { nanoid } from 'nanoid'
|
|
4
|
-
import Box from './box'
|
|
5
|
-
import Button from './button'
|
|
6
|
-
import useTheme from '../hooks/useTheme'
|
|
7
|
-
import useDispatch from '../hooks/useDispatch'
|
|
8
|
-
import useStore from '../hooks/useStore'
|
|
9
|
-
import { STORE_FORM_KEY } from '../context/AppProvider'
|
|
10
|
-
import {
|
|
11
|
-
UPDATE_FORM_FIELD
|
|
12
|
-
} from '../actions'
|
|
13
|
-
import { ClassNames } from '@emotion/react'
|
|
14
|
-
|
|
15
|
-
function Checkbox(props) {
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
checked,
|
|
19
|
-
as,
|
|
20
|
-
name,
|
|
21
|
-
form,
|
|
22
|
-
touched,
|
|
23
|
-
onChange
|
|
24
|
-
} = props;
|
|
25
|
-
|
|
26
|
-
const [_checked, setChecked] = useState(checked || false)
|
|
27
|
-
const theme = useTheme();
|
|
28
|
-
|
|
29
|
-
const dispatch = useDispatch(STORE_FORM_KEY)
|
|
30
|
-
const { forms } = useStore(state => state[STORE_FORM_KEY], false)
|
|
31
|
-
|
|
32
|
-
const switchCheck = useCallback(() => {
|
|
33
|
-
let nextVal = !_checked;
|
|
34
|
-
onChange && onChange(nextVal)
|
|
35
|
-
setChecked(nextVal)
|
|
36
|
-
dispatch( dispatch( UPDATE_FORM_FIELD( form || 'orphan', name, nextVal, forms ) ) );
|
|
37
|
-
}, [_checked])
|
|
38
|
-
|
|
39
|
-
const defaultCSS = `cursor: pointer;&:before {
|
|
40
|
-
background: ${!_checked ? `transparent` : theme.color} !important;
|
|
41
|
-
}`
|
|
42
|
-
|
|
43
|
-
const _name = useMemo(() => name || nanoid(), [name])
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<ClassNames>
|
|
47
|
-
{({ css, cx }) => <>
|
|
48
|
-
<input
|
|
49
|
-
onChange={switchCheck}
|
|
50
|
-
id={`zuz${_name}`}
|
|
51
|
-
// className={`${_checked ? 'y' : 'n'} ${as ? ` ${as} ` : ``}f ${cx(css`opacity: 0;position: absolute;&:checked {${defaultCSSChecked}}`)}`}
|
|
52
|
-
className={`zuz-checkbox`}
|
|
53
|
-
name={_name}
|
|
54
|
-
type={`checkbox`}
|
|
55
|
-
value={`checked`}
|
|
56
|
-
/>
|
|
57
|
-
<label
|
|
58
|
-
className={`${as ? `${as} ` : ``}f ${cx(css`${defaultCSS}`)}`}
|
|
59
|
-
htmlFor={`zuz${_name}`} />
|
|
60
|
-
</>}
|
|
61
|
-
</ClassNames>
|
|
62
|
-
// <Button
|
|
63
|
-
// overflow={`hidden`}
|
|
64
|
-
// name={name || nanoid()}
|
|
65
|
-
// onClick={switchCheck}
|
|
66
|
-
// w={38} h={22} r={20} bg={`#ddd`} rel>
|
|
67
|
-
// <Box w={38} h={22} anim={`0.2`} abs top={0} r={20} left={0} transform={`translateX(${_checked ? 0 : -16}px)`} bg={theme.color}>
|
|
68
|
-
// <Box w={18} h={18} abs right={2} top={2} bg={`#fff`} r={20} boxShadow={`0px 0px 0px 5px ${_checked ? theme.color : `#ddd`}`} />
|
|
69
|
-
// </Box>
|
|
70
|
-
// </Button>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export default Checkbox;
|
package/src/comps/component.tsx
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
forwardRef
|
|
3
|
-
} from 'react';
|
|
4
|
-
import styled from '@emotion/styled'
|
|
5
|
-
import { css } from '@emotion/react'
|
|
6
|
-
import {
|
|
7
|
-
buildCSS,
|
|
8
|
-
filterHTMLProps
|
|
9
|
-
} from '../core'
|
|
10
|
-
|
|
11
|
-
// const CoreBlock = styled.section`display: block;`
|
|
12
|
-
// const buildComponent = (props: any) => Block.withComponent(props.for || `div`)`${buildCSS(props)}`
|
|
13
|
-
|
|
14
|
-
const Component = forwardRef((props: any, ref: any) => {
|
|
15
|
-
|
|
16
|
-
const Tag = props.for;
|
|
17
|
-
const Block = (
|
|
18
|
-
typeof props.for == 'string' ?
|
|
19
|
-
styled[props.for || `div`] : Tag
|
|
20
|
-
)`${buildCSS(props)}`;
|
|
21
|
-
// const Block = styled.`${buildCSS(props)}`;
|
|
22
|
-
// const Block = CoreBlock.withComponent(props.for)`background: red`
|
|
23
|
-
// console.log(props)
|
|
24
|
-
// console.log(Styles)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// return <button>{props.children}</button>
|
|
28
|
-
return <Block className={props.as || ``} {...filterHTMLProps(props)} />
|
|
29
|
-
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
export default Component;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FC,
|
|
3
|
-
LegacyRef,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
useEffect,
|
|
8
|
-
} from 'react';
|
|
9
|
-
import Box from './box'
|
|
10
|
-
import Button from './button'
|
|
11
|
-
|
|
12
|
-
const ContextMenu = forwardRef((props : { [ key: string ] : any }, ref : LegacyRef<HTMLHeadingElement>) => {
|
|
13
|
-
|
|
14
|
-
const { ID, p, items, hide } = props;
|
|
15
|
-
// const [p, setP] = useState(p)
|
|
16
|
-
const nodeRef = useRef(null);
|
|
17
|
-
|
|
18
|
-
const checkBoundaries = () => {
|
|
19
|
-
|
|
20
|
-
let x = p.x
|
|
21
|
-
let y = p.y
|
|
22
|
-
|
|
23
|
-
if (nodeRef.current) {
|
|
24
|
-
const { innerWidth, innerHeight } = window;
|
|
25
|
-
const { offsetWidth, offsetHeight } = nodeRef.current;
|
|
26
|
-
|
|
27
|
-
if (x + offsetWidth > innerWidth) x -= x + offsetWidth - innerWidth;
|
|
28
|
-
|
|
29
|
-
if (y + offsetHeight > innerHeight) y -= y + offsetHeight - innerHeight;
|
|
30
|
-
}
|
|
31
|
-
// setP({x: x, y: y})
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
// checkBoundaries();
|
|
36
|
-
}, [])
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<Box
|
|
40
|
-
bref={nodeRef}
|
|
41
|
-
flex dir={`cols`}
|
|
42
|
-
fixed
|
|
43
|
-
top={p.x}
|
|
44
|
-
left={p.y}
|
|
45
|
-
as={`zuz-contextmenu ${ID}`}>
|
|
46
|
-
{items && items.map((m, i) => m.id == `line` ? <Box as={`line`} key={`line-${i}-${m.id}`} /> : <button
|
|
47
|
-
key={`cm-${i}-${m.id}`}
|
|
48
|
-
onClick={ev => {
|
|
49
|
-
if(m.onClick){
|
|
50
|
-
m.onClick(ev, m)
|
|
51
|
-
}else{
|
|
52
|
-
console.log(`No onClick eventFound`)
|
|
53
|
-
}
|
|
54
|
-
hide()
|
|
55
|
-
}}>{m.label}</button>)}
|
|
56
|
-
</Box>
|
|
57
|
-
)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
export default ContextMenu;
|
package/src/comps/cover.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Box from './box'
|
|
3
|
-
import Spinner from './spinner'
|
|
4
|
-
import Heading from './heading'
|
|
5
|
-
import PropTypes from 'prop-types'
|
|
6
|
-
|
|
7
|
-
const Cover = (props) => {
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<Box key={`cover-cloud`} abs fill
|
|
11
|
-
bgFilter={props.backdrop ? `saturate(${props.backdrop.saturate}%) blur(${props.backdrop.blur}px)` : undefined}
|
|
12
|
-
zIndex={`2`}
|
|
13
|
-
bg={props.bg}>
|
|
14
|
-
<Box key={`cover-shadow`} abs abc aic jcc flex dir={`cols`} gap={20}>
|
|
15
|
-
<Spinner key={`cover-spinner`} />
|
|
16
|
-
{props.label && <Heading key={`cover-label`} size={16} as={`f`} opacity={0.7}>{props.label}</Heading>}
|
|
17
|
-
</Box>
|
|
18
|
-
</Box>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
Cover.defaultProps = {
|
|
23
|
-
bg: `rgba(0,0,0,0.5)`,
|
|
24
|
-
backdrop: { saturate: 80, blur: 10 },
|
|
25
|
-
label: null
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Cover.propTypes = {
|
|
29
|
-
bg: PropTypes.string,
|
|
30
|
-
backdrop: PropTypes.object,
|
|
31
|
-
label: PropTypes.string,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default Cover;
|
package/src/comps/form.tsx
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Ref,
|
|
3
|
-
LegacyRef,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useState,
|
|
6
|
-
createElement,
|
|
7
|
-
useEffect,
|
|
8
|
-
useImperativeHandle
|
|
9
|
-
} from 'react';
|
|
10
|
-
import PropTypes from 'prop-types'
|
|
11
|
-
import Box from './box'
|
|
12
|
-
import Cover from './cover'
|
|
13
|
-
import { addProps } from '../core'
|
|
14
|
-
import useDispatch from '../hooks/useDispatch'
|
|
15
|
-
import useStore from '../hooks/useStore'
|
|
16
|
-
import { STORE_FORM_KEY, STORE_DEFAUTLS } from '../context/AppProvider'
|
|
17
|
-
import { nanoid } from 'nanoid'
|
|
18
|
-
import {
|
|
19
|
-
ADD_FORM,
|
|
20
|
-
UPDATE_FORM_FIELD
|
|
21
|
-
} from '../actions'
|
|
22
|
-
|
|
23
|
-
const Form = forwardRef((props : { [ key: string ] : any }, ref : Ref<any>) => {
|
|
24
|
-
|
|
25
|
-
const {
|
|
26
|
-
name,
|
|
27
|
-
children,
|
|
28
|
-
onSubmit,
|
|
29
|
-
cover,
|
|
30
|
-
debug
|
|
31
|
-
} = props;
|
|
32
|
-
|
|
33
|
-
const [_html, setHTML] = useState(null);
|
|
34
|
-
const [_loading, setLoading] = useState(debug?.loading || false);
|
|
35
|
-
const dispatch = useDispatch(STORE_FORM_KEY)
|
|
36
|
-
const { forms } = useStore(state => state[STORE_FORM_KEY], false)
|
|
37
|
-
|
|
38
|
-
const buildFields = () => {
|
|
39
|
-
return addProps(children, { form : name, touched: undefined, loading: undefined, onSubmit: onSubmit ? onSubmit : () => console.log(`onSubmit Missing`) })
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const update = (e : object) => Object.keys(e).map(k => {
|
|
43
|
-
dispatch( UPDATE_FORM_FIELD( name || 'orphan', k, e[k], forms ) )
|
|
44
|
-
if(k == 'loading') setLoading(e[k])
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
const get = (k : string) => forms[name][k] || null
|
|
48
|
-
|
|
49
|
-
useImperativeHandle(ref, () => ({
|
|
50
|
-
update,
|
|
51
|
-
get
|
|
52
|
-
}))
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
let f = buildFields();
|
|
56
|
-
setHTML(f.children);
|
|
57
|
-
if(!forms[name]){
|
|
58
|
-
dispatch(ADD_FORM(name, f.fields, forms))
|
|
59
|
-
}
|
|
60
|
-
}, [children, forms[name]?.loading])
|
|
61
|
-
|
|
62
|
-
return createElement(
|
|
63
|
-
Box,
|
|
64
|
-
{
|
|
65
|
-
rel: true,
|
|
66
|
-
...props,
|
|
67
|
-
as: name
|
|
68
|
-
},
|
|
69
|
-
[
|
|
70
|
-
_loading? <Cover key={`form-${name}-cover`} backdrop={cover?.filter || { saturate: 80, blur: 10 }} bg={cover?.bg || `rgba(0,0,0,0.5)`} /> : null,
|
|
71
|
-
_html
|
|
72
|
-
]
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
Form.defaultProps = {
|
|
78
|
-
name: 'form1',
|
|
79
|
-
onSubmit: () => { console.log(`onSubmit not provided`) }
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
Form.propTypes = {
|
|
83
|
-
name: PropTypes.string.isRequired,
|
|
84
|
-
children: PropTypes.node.isRequired,
|
|
85
|
-
onSubmit: PropTypes.func.isRequired
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
export default Form
|
package/src/comps/heading.tsx
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FC,
|
|
3
|
-
LegacyRef,
|
|
4
|
-
forwardRef,
|
|
5
|
-
HTMLAttributes
|
|
6
|
-
} from 'react';
|
|
7
|
-
import { ClassNames } from '@emotion/react'
|
|
8
|
-
import { buildCSS } from '../core'
|
|
9
|
-
|
|
10
|
-
const Heading = forwardRef((props : { [ key: string ] : any }, ref : LegacyRef<HTMLHeadingElement>) => {
|
|
11
|
-
|
|
12
|
-
const {
|
|
13
|
-
children,
|
|
14
|
-
as,
|
|
15
|
-
h
|
|
16
|
-
} = props;
|
|
17
|
-
|
|
18
|
-
let Tag : string = `h${h || 1}`;
|
|
19
|
-
const HeadingTag = Tag as `h1` | `h2` | `h3` | `h4` | `h5` | `h6`
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<ClassNames>
|
|
23
|
-
{({ css, cx }) => <HeadingTag
|
|
24
|
-
className={`${as ? `${as} ` : ``}${cx(css`${buildCSS(props)}`)}`}
|
|
25
|
-
ref={ref}
|
|
26
|
-
>{props.html ? <span dangerouslySetInnerHTML={{ __html: props.html }} /> : children}</HeadingTag>}
|
|
27
|
-
</ClassNames>
|
|
28
|
-
)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
export default Heading;
|
package/src/comps/icon.tsx
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FC,
|
|
3
|
-
LegacyRef,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useRef,
|
|
6
|
-
SyntheticEvent,
|
|
7
|
-
} from 'react';
|
|
8
|
-
import Box from './box'
|
|
9
|
-
|
|
10
|
-
const Icon = forwardRef((props : { [ key: string ] : any }, ref : LegacyRef<HTMLHeadingElement>) => {
|
|
11
|
-
|
|
12
|
-
const {
|
|
13
|
-
as,
|
|
14
|
-
path,
|
|
15
|
-
size,
|
|
16
|
-
color,
|
|
17
|
-
hover
|
|
18
|
-
} = props;
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Box
|
|
22
|
-
hover={hover || {}}
|
|
23
|
-
flex
|
|
24
|
-
bref={ref}
|
|
25
|
-
as={`icon-${as}`}
|
|
26
|
-
ai={`c`}
|
|
27
|
-
jc={`c`}
|
|
28
|
-
size={size || 24}
|
|
29
|
-
color={color || `#111111`}
|
|
30
|
-
>
|
|
31
|
-
{path && Array(path).fill(undefined).map((p : any, i : any) => <span key={`ico-${as}-${i}`} className={`path${i+1}`} />)}
|
|
32
|
-
</Box>
|
|
33
|
-
)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
export default Icon;
|
package/src/comps/image.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
forwardRef,
|
|
3
|
-
LegacyRef
|
|
4
|
-
} from 'react'
|
|
5
|
-
import { ClassNames } from '@emotion/react'
|
|
6
|
-
import { buildCSS } from '../core'
|
|
7
|
-
import useImage from '../hooks/useImage'
|
|
8
|
-
import Box from './box'
|
|
9
|
-
|
|
10
|
-
const Image = forwardRef((props : { [ key: string ] : any }, ref : LegacyRef<HTMLImageElement>) => {
|
|
11
|
-
|
|
12
|
-
const { src, isLoading, error } = useImage({ srcList: props.src, useSuspense: false });
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<ClassNames>
|
|
16
|
-
{({ css, cx }) => <>
|
|
17
|
-
{isLoading && <Box className={`${props.as ? `${props.as} ` : ``}${cx(css`background: #eee;${buildCSS(props)}`)}`} />}
|
|
18
|
-
{!isLoading && <img src={src}
|
|
19
|
-
className={`${props.as ? `${props.as} ` : ``}${cx(css`${buildCSS(props)}`)}`}
|
|
20
|
-
ref={ref} />}
|
|
21
|
-
</>}
|
|
22
|
-
</ClassNames>
|
|
23
|
-
// <ClassNames>
|
|
24
|
-
// {({ css, cx }) => <picture className={cx(css`${buildCSS({ flex: true })}`)}>
|
|
25
|
-
// {status == 'loading' && <Box className={`${props.as ? `${props.as} ` : ``}${cx(css`background: #eee;${buildCSS(props)}`)}`} />}
|
|
26
|
-
// {status == 'loaded' && <img src={props.src}
|
|
27
|
-
// className={`${props.as ? `${props.as} ` : ``}${cx(css`${buildCSS(props)}`)}`}
|
|
28
|
-
// ref={ref} />}
|
|
29
|
-
// </picture>}
|
|
30
|
-
// </ClassNames>
|
|
31
|
-
)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
export default Image;
|