@variousjs/create 2.0.1 → 3.0.1

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.
Files changed (50) hide show
  1. package/.eslintignore +1 -1
  2. package/.gitignore.copy +1 -0
  3. package/package-lock.json.copy +7558 -3688
  4. package/package.json +20 -16
  5. package/package.json.copy +18 -14
  6. package/public/dist/app.js +2 -0
  7. package/public/dist/app.js.map +1 -0
  8. package/public/dist/card.js +2 -0
  9. package/public/dist/card.js.map +1 -0
  10. package/public/dist/next.js +2 -0
  11. package/public/dist/next.js.map +1 -0
  12. package/public/dist/top.js +2 -0
  13. package/public/dist/top.js.map +1 -0
  14. package/public/index.html +48 -0
  15. package/src/{entry → components/app}/actions.ts +2 -2
  16. package/src/components/app/container.less +45 -0
  17. package/src/{entry → components/app}/container.tsx +17 -20
  18. package/src/components/app/error.tsx +14 -0
  19. package/src/components/app/index.ts +16 -0
  20. package/src/{entry → components/app}/loader.tsx +1 -2
  21. package/src/components/card/index.tsx +42 -0
  22. package/src/components/next/index.tsx +54 -0
  23. package/src/components/top/index.tsx +29 -0
  24. package/src/declaration.d.ts +0 -26
  25. package/src/index.html +14 -0
  26. package/src/types.ts +2 -2
  27. package/tsconfig.json +4 -2
  28. package/various.config.js +85 -0
  29. package/webpack/{entry.js → app.js} +2 -2
  30. package/webpack/base.js +28 -39
  31. package/webpack/component.js +2 -2
  32. package/demo/dist/card.js +0 -2
  33. package/demo/dist/card.js.map +0 -1
  34. package/demo/dist/entry.js +0 -2
  35. package/demo/dist/entry.js.map +0 -1
  36. package/demo/dist/next.js +0 -2
  37. package/demo/dist/next.js.map +0 -1
  38. package/demo/dist/top.js +0 -2
  39. package/demo/dist/top.js.map +0 -1
  40. package/demo/index.html +0 -62
  41. package/src/components/card.less +0 -3
  42. package/src/components/card.tsx +0 -52
  43. package/src/components/next.tsx +0 -49
  44. package/src/components/top.tsx +0 -55
  45. package/src/entry/entry.less +0 -9
  46. package/src/entry/error.tsx +0 -19
  47. package/src/entry/index.ts +0 -5
  48. /package/src/{entry → components/app}/store.ts +0 -0
  49. /package/src/components/{i18n → next/i18n}/en.json +0 -0
  50. /package/src/components/{i18n → next/i18n}/zh.json +0 -0
@@ -1,3 +0,0 @@
1
- .container {
2
- margin-top: 30px;
3
- }
@@ -1,52 +0,0 @@
1
- import React, { FC } from 'react'
2
- import { ComponentProps, Invoker } from '@variousjs/various'
3
- import { useParams } from 'react-router-dom'
4
- import { Card, Button, message } from 'antd'
5
- import { Store } from '../types'
6
- import csses from './card.less'
7
-
8
- const H: FC<ComponentProps<Store>> & { getName: Invoker } = (props) => {
9
- const { id } = useParams<{ id: string }>()
10
-
11
- return (
12
- <div className={csses.container}>
13
- <Card
14
- hoverable
15
- style={{ width: 240 }}
16
- cover={<img alt="example" src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png" />}
17
- actions={[
18
- id ? <Button
19
- key="next"
20
- onClick={() => props.$dispatch('next', 'setValue', 1)}
21
- >
22
- Next
23
- </Button> : <Button
24
- key="locale"
25
- onClick={() => props.$dispatch('store', 'setLocale', props.$store.locale === 'zh' ? 'en' : 'zh')}
26
- >
27
- locale
28
- </Button>,
29
- <Button
30
- key="store"
31
- type="primary"
32
- onClick={async () => {
33
- await props.$dispatch('store', 'setName', `${Math.random().toFixed(2)}`)
34
- message.info('changed')
35
- }}
36
- >
37
- Store
38
- </Button>
39
- ]}
40
- >
41
- <Card.Meta
42
- title="Route Params"
43
- description={id || 'none'}
44
- />
45
- </Card>
46
- </div>
47
- )
48
- }
49
-
50
- H.getName = (e) => message.info(e)
51
-
52
- export default H
@@ -1,49 +0,0 @@
1
- import React, { Component } from 'react'
2
- import { ComponentProps, Store, Invoker, Ii8n } from '@variousjs/various'
3
- import { Descriptions } from 'antd'
4
- import { Store as GlobalStore } from '../types'
5
- import zh from './i18n/zh.json'
6
- import en from './i18n/en.json'
7
-
8
- type S = { value: number }
9
-
10
- const {
11
- createStore,
12
- connect,
13
- emit,
14
- getStore,
15
- } = new Store<S>()
16
-
17
- createStore({ value: 0 })
18
-
19
- class X extends Component<S & ComponentProps<GlobalStore>> {
20
- static setValue: Invoker = async (value) => {
21
- const store = getStore()
22
- emit({ value: value + store.value }, true)
23
- }
24
-
25
- static $i18n: Ii8n = () => ({
26
- localeKey: 'locale',
27
- resources: { zh, en },
28
- })
29
-
30
- render() {
31
- const { user } = this.props.$store
32
- const { value, $t } = this.props
33
-
34
- return (
35
- <Descriptions
36
- style={{ marginTop: 30 }}
37
- bordered
38
- title="Next Component"
39
- size="small"
40
- >
41
- <Descriptions.Item label="Store">{user.name}</Descriptions.Item>
42
- <Descriptions.Item label="Value">{value}</Descriptions.Item>
43
- <Descriptions.Item label="Title">{$t('title', { name: 'various' })}</Descriptions.Item>
44
- </Descriptions>
45
- )
46
- }
47
- }
48
-
49
- export default connect('value')(X)
@@ -1,55 +0,0 @@
1
- import React, { FC, useState, useEffect } from 'react'
2
- import { ComponentProps, getConfig } from '@variousjs/various'
3
- import { useLocation, useHistory } from 'react-router-dom'
4
- import { Radio, Badge, Button } from 'antd'
5
- import { Config, Store } from '../types'
6
-
7
- const H: FC<ComponentProps<Store>> = (props) => {
8
- const $config = getConfig() as Config
9
- const { pathname } = useLocation()
10
- const history = useHistory()
11
- const [path, setPath] = useState('')
12
-
13
- useEffect(() => {
14
- setPath(pathname)
15
- }, [])
16
-
17
- const onRouterChange = (e: any) => {
18
- history.push(e.target.value)
19
- setPath(e.target.value)
20
- }
21
-
22
- return (
23
- <>
24
- <Radio.Group
25
- size="large"
26
- value={path}
27
- onChange={onRouterChange}
28
- buttonStyle="solid"
29
- >
30
- {
31
- $config.links.map(({ path, name }) => (
32
- <Radio.Button key={path} value={path}>
33
- {name}
34
- </Radio.Button>
35
- ))
36
- }
37
- </Radio.Group>
38
- <div>
39
- Store:
40
- <Badge
41
- style={{ marginLeft: 10 }}
42
- count={props.$store.user.name}
43
- />
44
- <Button
45
- style={{ marginLeft: 10 }}
46
- onClick={() => props.$dispatch('card', 'getName', 'Card')}
47
- >
48
- Card Name
49
- </Button>
50
- </div>
51
- </>
52
- )
53
- }
54
-
55
- export default H
@@ -1,9 +0,0 @@
1
- .container {
2
- background: #fff;
3
- padding: 50px;
4
- }
5
- .top {
6
- display: flex;
7
- align-items: center;
8
- justify-content: space-between;
9
- }
@@ -1,19 +0,0 @@
1
- import React, { FC } from 'react'
2
- import { Alert, Button } from 'antd'
3
- import { ErrorProps } from '@variousjs/various'
4
-
5
- const errorComponent: FC<ErrorProps> = ({ $reload, $type, $message }) => (
6
- <>
7
- <Alert
8
- message="Error"
9
- description={`[${$type}]: ${$message || '组件错误'}`}
10
- type="error"
11
- style={{ marginTop: 30 }}
12
- />
13
- {
14
- $reload && <Button onClick={$reload}>刷新</Button>
15
- }
16
- </>
17
- )
18
-
19
- export default errorComponent
@@ -1,5 +0,0 @@
1
- export { default as actions } from './actions'
2
- export { default as store } from './store'
3
- export { default as Container } from './container'
4
- export { default as Loader } from './loader'
5
- export { default as Error } from './error'
File without changes
File without changes
File without changes