@thienvu18/designable-react-settings-form 2.0.0 → 2.0.2
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/esm/SchemaField.d.ts +5115 -1578
- package/esm/SchemaField.js +76 -41
- package/esm/SettingsForm.d.ts +4 -4
- package/esm/SettingsForm.js +99 -49
- package/esm/components/BackgroundStyleSetter/index.d.ts +4 -4
- package/esm/components/BackgroundStyleSetter/index.js +95 -42
- package/esm/components/BorderRadiusStyleSetter/index.d.ts +4 -4
- package/esm/components/BorderRadiusStyleSetter/index.js +13 -10
- package/esm/components/BorderStyleSetter/index.d.ts +5 -5
- package/esm/components/BorderStyleSetter/index.js +121 -68
- package/esm/components/BoxShadowStyleSetter/index.d.ts +6 -6
- package/esm/components/BoxShadowStyleSetter/index.js +72 -24
- package/esm/components/BoxStyleSetter/index.d.ts +7 -7
- package/esm/components/BoxStyleSetter/index.js +98 -46
- package/esm/components/CollapseItem/index.d.ts +6 -6
- package/esm/components/CollapseItem/index.js +35 -15
- package/esm/components/ColorInput/index.d.ts +5 -5
- package/esm/components/ColorInput/index.js +35 -17
- package/esm/components/ColorInput/styles.less +0 -5
- package/esm/components/CornerInput/index.d.ts +7 -7
- package/esm/components/CornerInput/index.js +50 -21
- package/esm/components/DisplayStyleSetter/index.d.ts +7 -7
- package/esm/components/DisplayStyleSetter/index.js +62 -33
- package/esm/components/DrawerSetter/index.d.ts +6 -6
- package/esm/components/DrawerSetter/index.js +82 -42
- package/esm/components/DrawerSetter/styles.less +2 -2
- package/esm/components/FlexStyleSetter/index.d.ts +5 -5
- package/esm/components/FlexStyleSetter/index.js +160 -110
- package/esm/components/FoldItem/index.d.ts +9 -7
- package/esm/components/FoldItem/index.js +80 -46
- package/esm/components/FontStyleSetter/index.d.ts +4 -4
- package/esm/components/FontStyleSetter/index.js +169 -85
- package/esm/components/ImageInput/index.d.ts +7 -7
- package/esm/components/ImageInput/index.js +59 -39
- package/esm/components/InputItems/index.d.ts +19 -17
- package/esm/components/InputItems/index.js +42 -16
- package/esm/components/MonacoInput/config.d.ts +1 -1
- package/esm/components/MonacoInput/config.js +40 -38
- package/esm/components/MonacoInput/format.d.ts +4 -1
- package/esm/components/MonacoInput/format.js +33 -29
- package/esm/components/MonacoInput/index.d.ts +13 -13
- package/esm/components/MonacoInput/index.js +298 -212
- package/esm/components/MonacoInput/themes/chrome.d.ts +44 -38
- package/esm/components/MonacoInput/themes/chrome.js +105 -105
- package/esm/components/MonacoInput/themes/monokai.d.ts +34 -30
- package/esm/components/MonacoInput/themes/monokai.js +139 -139
- package/esm/components/PolyInput/index.d.ts +17 -17
- package/esm/components/PolyInput/index.js +96 -66
- package/esm/components/PositionInput/index.d.ts +7 -7
- package/esm/components/PositionInput/index.js +48 -21
- package/esm/components/PositionInput/styles.less +0 -1
- package/esm/components/SizeInput/index.d.ts +6 -2
- package/esm/components/SizeInput/index.js +44 -46
- package/esm/components/SizeInput/styles.less +0 -1
- package/esm/components/ValueInput/index.d.ts +2 -2
- package/esm/components/ValueInput/index.js +89 -72
- package/esm/components/index.d.ts +20 -20
- package/esm/components/index.js +20 -20
- package/esm/effects/index.d.ts +2 -2
- package/esm/effects/index.js +2 -2
- package/esm/effects/useLocales.d.ts +2 -2
- package/esm/effects/useLocales.js +57 -59
- package/esm/effects/useSnapshot.d.ts +2 -2
- package/esm/effects/useSnapshot.js +9 -9
- package/esm/index.d.ts +5 -5
- package/esm/index.js +5 -5
- package/esm/locales/en-US.d.ts +12 -12
- package/esm/locales/en-US.js +10 -10
- package/esm/locales/index.d.ts +1 -1
- package/esm/locales/index.js +5 -5
- package/esm/locales/ko-KR.d.ts +12 -12
- package/esm/locales/ko-KR.js +10 -10
- package/esm/locales/zh-CN.d.ts +12 -12
- package/esm/locales/zh-CN.js +10 -10
- package/esm/registry.d.ts +2 -2
- package/esm/registry.js +11 -11
- package/esm/shared/context.d.ts +2 -2
- package/esm/shared/context.js +2 -2
- package/esm/shared/loadScript.d.ts +5 -5
- package/esm/shared/loadScript.js +27 -28
- package/esm/styles.less +5 -4
- package/esm/types.d.ts +8 -8
- package/esm/types.js +1 -1
- package/lib/SchemaField.d.ts +5115 -1578
- package/lib/SchemaField.js +44 -44
- package/lib/SettingsForm.d.ts +4 -4
- package/lib/SettingsForm.js +108 -55
- package/lib/components/BackgroundStyleSetter/index.d.ts +4 -4
- package/lib/components/BackgroundStyleSetter/index.js +106 -48
- package/lib/components/BorderRadiusStyleSetter/index.d.ts +4 -4
- package/lib/components/BorderRadiusStyleSetter/index.js +33 -14
- package/lib/components/BorderStyleSetter/index.d.ts +5 -5
- package/lib/components/BorderStyleSetter/index.js +138 -74
- package/lib/components/BoxShadowStyleSetter/index.d.ts +6 -6
- package/lib/components/BoxShadowStyleSetter/index.js +82 -30
- package/lib/components/BoxStyleSetter/index.d.ts +7 -7
- package/lib/components/BoxStyleSetter/index.js +122 -52
- package/lib/components/CollapseItem/index.d.ts +6 -6
- package/lib/components/CollapseItem/index.js +49 -21
- package/lib/components/ColorInput/index.d.ts +5 -5
- package/lib/components/ColorInput/index.js +39 -21
- package/lib/components/ColorInput/styles.less +0 -5
- package/lib/components/CornerInput/index.d.ts +7 -7
- package/lib/components/CornerInput/index.js +70 -28
- package/lib/components/DisplayStyleSetter/index.d.ts +7 -7
- package/lib/components/DisplayStyleSetter/index.js +75 -39
- package/lib/components/DrawerSetter/index.d.ts +6 -6
- package/lib/components/DrawerSetter/index.js +99 -48
- package/lib/components/DrawerSetter/styles.less +2 -2
- package/lib/components/FlexStyleSetter/index.d.ts +5 -5
- package/lib/components/FlexStyleSetter/index.js +208 -116
- package/lib/components/FoldItem/index.d.ts +9 -7
- package/lib/components/FoldItem/index.js +140 -72
- package/lib/components/FontStyleSetter/index.d.ts +4 -4
- package/lib/components/FontStyleSetter/index.js +216 -91
- package/lib/components/ImageInput/index.d.ts +7 -7
- package/lib/components/ImageInput/index.js +69 -47
- package/lib/components/InputItems/index.d.ts +19 -17
- package/lib/components/InputItems/index.js +101 -46
- package/lib/components/MonacoInput/config.d.ts +1 -1
- package/lib/components/MonacoInput/config.js +49 -45
- package/lib/components/MonacoInput/format.d.ts +4 -1
- package/lib/components/MonacoInput/format.js +38 -33
- package/lib/components/MonacoInput/index.d.ts +13 -13
- package/lib/components/MonacoInput/index.js +347 -241
- package/lib/components/MonacoInput/themes/chrome.d.ts +44 -38
- package/lib/components/MonacoInput/themes/chrome.js +107 -107
- package/lib/components/MonacoInput/themes/monokai.d.ts +34 -30
- package/lib/components/MonacoInput/themes/monokai.js +141 -141
- package/lib/components/PolyInput/index.d.ts +17 -17
- package/lib/components/PolyInput/index.js +151 -96
- package/lib/components/PositionInput/index.d.ts +7 -7
- package/lib/components/PositionInput/index.js +68 -28
- package/lib/components/PositionInput/styles.less +0 -1
- package/lib/components/SizeInput/index.d.ts +6 -2
- package/lib/components/SizeInput/index.js +47 -49
- package/lib/components/SizeInput/styles.less +0 -1
- package/lib/components/ValueInput/index.d.ts +2 -2
- package/lib/components/ValueInput/index.js +92 -75
- package/lib/components/index.d.ts +20 -20
- package/lib/components/index.js +52 -36
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +34 -18
- package/lib/effects/useLocales.d.ts +2 -2
- package/lib/effects/useLocales.js +67 -63
- package/lib/effects/useSnapshot.d.ts +2 -2
- package/lib/effects/useSnapshot.js +13 -13
- package/lib/index.d.ts +5 -5
- package/lib/index.js +37 -21
- package/lib/locales/en-US.d.ts +12 -12
- package/lib/locales/en-US.js +12 -12
- package/lib/locales/index.d.ts +1 -1
- package/lib/locales/index.js +16 -10
- package/lib/locales/ko-KR.d.ts +12 -12
- package/lib/locales/ko-KR.js +12 -12
- package/lib/locales/zh-CN.d.ts +12 -12
- package/lib/locales/zh-CN.js +12 -12
- package/lib/registry.d.ts +2 -2
- package/lib/registry.js +21 -19
- package/lib/shared/context.d.ts +2 -2
- package/lib/shared/context.js +5 -5
- package/lib/shared/loadScript.d.ts +5 -5
- package/lib/shared/loadScript.js +32 -32
- package/lib/styles.less +5 -4
- package/lib/types.d.ts +8 -8
- package/lib/types.js +2 -2
- package/package.json +26 -27
|
@@ -1,74 +1,127 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Select } from '@thienvu18/formily-antd-v6'
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { ColorInput } from '../ColorInput'
|
|
10
|
-
import {
|
|
11
|
-
import { PositionInput } from '../PositionInput'
|
|
12
|
-
import
|
|
13
|
-
import './styles.less'
|
|
14
|
-
const Positions = ['center', 'top', 'right', 'bottom', 'left']
|
|
1
|
+
import { Field, observer, useField } from '@formily/react'
|
|
2
|
+
import { observable } from '@formily/reactive'
|
|
3
|
+
import { camelCase } from '@formily/shared'
|
|
4
|
+
import { usePrefix } from '@thienvu18/designable-react'
|
|
5
|
+
import { Select } from '@thienvu18/formily-antd-v6'
|
|
6
|
+
import cls from 'classnames'
|
|
7
|
+
import { Fragment, useMemo } from 'react'
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
|
|
9
|
+
import { ColorInput } from '../ColorInput'
|
|
10
|
+
import { FoldItem } from '../FoldItem'
|
|
11
|
+
import { PositionInput } from '../PositionInput'
|
|
12
|
+
import { SizeInput } from '../SizeInput'
|
|
13
|
+
import './styles.less'
|
|
14
|
+
const Positions = ['center', 'top', 'right', 'bottom', 'left']
|
|
15
15
|
const BorderStyleOptions = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
]
|
|
16
|
+
{
|
|
17
|
+
label: 'None',
|
|
18
|
+
value: 'none',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: _jsx('span', { className: 'border-style-solid-line' }),
|
|
22
|
+
value: 'solid',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: _jsx('span', { className: 'border-style-dashed-line' }),
|
|
26
|
+
value: 'dashed',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: _jsx('span', { className: 'border-style-dotted-line' }),
|
|
30
|
+
value: 'dotted',
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
33
|
const createBorderProp = (position, key) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
34
|
+
const insert = position === 'center' ? '' : `-${position}`
|
|
35
|
+
return camelCase(`border${insert}-${key}`)
|
|
36
|
+
}
|
|
37
37
|
const parseInitPosition = (field) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
const basePath = field.address.parent()
|
|
39
|
+
for (let i = 0; i < Positions.length; i++) {
|
|
40
|
+
const position = Positions[i]
|
|
41
|
+
const stylePath = `${basePath}.${createBorderProp(position, 'style')}`
|
|
42
|
+
const widthPath = `${basePath}.${createBorderProp(position, 'width')}`
|
|
43
|
+
const colorPath = `${basePath}.${createBorderProp(position, 'color')}`
|
|
44
|
+
if (
|
|
45
|
+
field.query(stylePath).value() ||
|
|
46
|
+
field.query(widthPath).value() ||
|
|
47
|
+
field.query(colorPath).value()
|
|
48
|
+
) {
|
|
49
|
+
return position
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
}
|
|
52
|
+
return 'center'
|
|
53
|
+
}
|
|
52
54
|
export const BorderStyleSetter = observer(({ className, style }) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const field = useField()
|
|
56
|
+
const currentPosition = useMemo(
|
|
57
|
+
() =>
|
|
58
|
+
observable({
|
|
55
59
|
value: parseInitPosition(field),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
}),
|
|
61
|
+
[field.value]
|
|
62
|
+
)
|
|
63
|
+
const prefix = usePrefix('border-style-setter')
|
|
64
|
+
const createReaction = (position) => (field) => {
|
|
65
|
+
field.display = currentPosition.value === position ? 'visible' : 'hidden'
|
|
66
|
+
if (position !== 'center') {
|
|
67
|
+
const borderStyle = field.query('.borderStyle').value()
|
|
68
|
+
const borderWidth = field.query('.borderWidth').value()
|
|
69
|
+
const borderColor = field.query('.borderColor').value()
|
|
70
|
+
if (borderStyle || borderWidth || borderColor) {
|
|
71
|
+
field.value = undefined
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return _jsx(FoldItem, {
|
|
76
|
+
label: field.title,
|
|
77
|
+
children: _jsx(FoldItem.Extra, {
|
|
78
|
+
children: _jsxs('div', {
|
|
79
|
+
className: cls(prefix, className),
|
|
80
|
+
style: style,
|
|
81
|
+
children: [
|
|
82
|
+
_jsx('div', {
|
|
83
|
+
className: prefix + '-position',
|
|
84
|
+
children: _jsx(PositionInput, {
|
|
85
|
+
value: currentPosition.value,
|
|
86
|
+
onChange: (value) => {
|
|
87
|
+
currentPosition.value = value
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
}),
|
|
91
|
+
_jsx('div', {
|
|
92
|
+
className: prefix + '-input',
|
|
93
|
+
children: Positions.map((position, key) => {
|
|
94
|
+
return _jsxs(
|
|
95
|
+
Fragment,
|
|
96
|
+
{
|
|
97
|
+
children: [
|
|
98
|
+
_jsx(Field, {
|
|
99
|
+
name: createBorderProp(position, 'style'),
|
|
100
|
+
basePath: field.address.parent(),
|
|
101
|
+
dataSource: BorderStyleOptions,
|
|
102
|
+
reactions: createReaction(position),
|
|
103
|
+
component: [Select, { placeholder: 'Please Select' }],
|
|
104
|
+
}),
|
|
105
|
+
_jsx(Field, {
|
|
106
|
+
name: createBorderProp(position, 'width'),
|
|
107
|
+
basePath: field.address.parent(),
|
|
108
|
+
reactions: createReaction(position),
|
|
109
|
+
component: [SizeInput, { exclude: ['auto'] }],
|
|
110
|
+
}),
|
|
111
|
+
_jsx(Field, {
|
|
112
|
+
name: createBorderProp(position, 'color'),
|
|
113
|
+
basePath: field.address.parent(),
|
|
114
|
+
reactions: createReaction(position),
|
|
115
|
+
component: [ColorInput],
|
|
116
|
+
}),
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
key
|
|
120
|
+
)
|
|
121
|
+
}),
|
|
122
|
+
}),
|
|
123
|
+
],
|
|
124
|
+
}),
|
|
125
|
+
}),
|
|
126
|
+
})
|
|
127
|
+
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React from 'react'
|
|
2
2
|
export interface IBoxShadowStyleSetterProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
className?: string
|
|
4
|
+
style?: React.CSSProperties
|
|
5
|
+
value?: string
|
|
6
|
+
onChange?: (value: string) => void
|
|
7
7
|
}
|
|
8
|
-
export declare const BoxShadowStyleSetter: React.FC<IBoxShadowStyleSetterProps
|
|
8
|
+
export declare const BoxShadowStyleSetter: React.FC<IBoxShadowStyleSetterProps>
|
|
@@ -1,25 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { usePrefix } from '@thienvu18/designable-react'
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { ColorInput } from '../ColorInput'
|
|
6
|
-
import {
|
|
7
|
-
import { InputItems } from '../InputItems'
|
|
8
|
-
import
|
|
1
|
+
import { observer, useField } from '@formily/react'
|
|
2
|
+
import { usePrefix } from '@thienvu18/designable-react'
|
|
3
|
+
import cls from 'classnames'
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
|
|
5
|
+
import { ColorInput } from '../ColorInput'
|
|
6
|
+
import { FoldItem } from '../FoldItem'
|
|
7
|
+
import { InputItems } from '../InputItems'
|
|
8
|
+
import { SizeInput } from '../SizeInput'
|
|
9
9
|
export const BoxShadowStyleSetter = observer((props) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
10
|
+
const field = useField()
|
|
11
|
+
const prefix = usePrefix('shadow-style-setter')
|
|
12
|
+
const createBoxShadowConnector = (position) => {
|
|
13
|
+
const splited = String(props.value || '')
|
|
14
|
+
.trim()
|
|
15
|
+
.split(' ')
|
|
16
|
+
return {
|
|
17
|
+
value: splited[position],
|
|
18
|
+
onChange: (value) => {
|
|
19
|
+
splited[position] = value
|
|
20
|
+
props.onChange?.(
|
|
21
|
+
`${splited[0] || ''} ${splited[1] || ''} ${splited[2] || ''} ${
|
|
22
|
+
splited[3] || ''
|
|
23
|
+
} ${splited[4] || ''}`
|
|
24
|
+
)
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return _jsxs(FoldItem, {
|
|
29
|
+
className: cls(prefix, props.className),
|
|
30
|
+
style: props.style,
|
|
31
|
+
label: field.title,
|
|
32
|
+
children: [
|
|
33
|
+
_jsx(FoldItem.Base, {
|
|
34
|
+
children: _jsx(ColorInput, { ...createBoxShadowConnector(4) }),
|
|
35
|
+
}),
|
|
36
|
+
_jsx(FoldItem.Extra, {
|
|
37
|
+
children: _jsxs(InputItems, {
|
|
38
|
+
width: '50%',
|
|
39
|
+
children: [
|
|
40
|
+
_jsx(InputItems.Item, {
|
|
41
|
+
icon: 'AxisX',
|
|
42
|
+
children: _jsx(SizeInput, {
|
|
43
|
+
exclude: ['inherit', 'auto'],
|
|
44
|
+
...createBoxShadowConnector(0),
|
|
45
|
+
}),
|
|
46
|
+
}),
|
|
47
|
+
_jsx(InputItems.Item, {
|
|
48
|
+
icon: 'AxisY',
|
|
49
|
+
children: _jsx(SizeInput, {
|
|
50
|
+
exclude: ['inherit', 'auto'],
|
|
51
|
+
...createBoxShadowConnector(1),
|
|
52
|
+
}),
|
|
53
|
+
}),
|
|
54
|
+
_jsx(InputItems.Item, {
|
|
55
|
+
icon: 'Blur',
|
|
56
|
+
children: _jsx(SizeInput, {
|
|
57
|
+
exclude: ['inherit', 'auto'],
|
|
58
|
+
...createBoxShadowConnector(2),
|
|
59
|
+
}),
|
|
60
|
+
}),
|
|
61
|
+
_jsx(InputItems.Item, {
|
|
62
|
+
icon: 'Shadow',
|
|
63
|
+
children: _jsx(SizeInput, {
|
|
64
|
+
exclude: ['inherit', 'auto'],
|
|
65
|
+
...createBoxShadowConnector(3),
|
|
66
|
+
}),
|
|
67
|
+
}),
|
|
68
|
+
],
|
|
69
|
+
}),
|
|
70
|
+
}),
|
|
71
|
+
],
|
|
72
|
+
})
|
|
73
|
+
})
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React from 'react'
|
|
2
2
|
export interface IMarginStyleSetterProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
className?: string
|
|
4
|
+
style?: React.CSSProperties
|
|
5
|
+
labels?: React.ReactNode[]
|
|
6
|
+
value?: string
|
|
7
|
+
onChange?: (value: string) => void
|
|
8
8
|
}
|
|
9
|
-
export declare const BoxStyleSetter: React.FC<IMarginStyleSetterProps
|
|
9
|
+
export declare const BoxStyleSetter: React.FC<IMarginStyleSetterProps>
|
|
@@ -1,49 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { InputItems } from '../InputItems'
|
|
7
|
-
import
|
|
1
|
+
import { observer, useField } from '@formily/react'
|
|
2
|
+
import { IconWidget, usePrefix } from '@thienvu18/designable-react'
|
|
3
|
+
import cls from 'classnames'
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
|
|
5
|
+
import { FoldItem } from '../FoldItem'
|
|
6
|
+
import { InputItems } from '../InputItems'
|
|
7
|
+
import { SizeInput } from '../SizeInput'
|
|
8
8
|
const PositionMap = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
const BoxRex =
|
|
9
|
+
top: 1,
|
|
10
|
+
right: 2,
|
|
11
|
+
bottom: 3,
|
|
12
|
+
left: 4,
|
|
13
|
+
all: 1,
|
|
14
|
+
}
|
|
15
|
+
const BoxRex =
|
|
16
|
+
/([\d\.]+[^\d\s\.+-]+)(?:\s+([\d\.]+[^\d\s\.+-]+)(?:\s+([\d\.]+[^\d\s\.+-]+)(?:\s+([\d\.]+[^\d\s\.+-]+))?)?)?/
|
|
16
17
|
const defaultLabels = [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
]
|
|
18
|
+
_jsx(IconWidget, { infer: 'Top', size: 16 }, '1'),
|
|
19
|
+
_jsx(IconWidget, { infer: 'Right', size: 16 }, '2'),
|
|
20
|
+
_jsx(IconWidget, { infer: 'Bottom', size: 16 }, '3'),
|
|
21
|
+
_jsx(IconWidget, { infer: 'Left', size: 16 }, '4'),
|
|
22
|
+
]
|
|
22
23
|
export const BoxStyleSetter = observer((props) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
24
|
+
const { labels = defaultLabels, className } = props
|
|
25
|
+
const field = useField()
|
|
26
|
+
const prefix = usePrefix('box-style-setter')
|
|
27
|
+
const createPositionHandler = (position, setterProps) => {
|
|
28
|
+
const matched = String(setterProps.value).match(BoxRex) || []
|
|
29
|
+
const value = matched[PositionMap[position]]
|
|
30
|
+
const v1 = matched[1]
|
|
31
|
+
const v2 = matched[2]
|
|
32
|
+
const v3 = matched[3]
|
|
33
|
+
const v4 = matched[4]
|
|
34
|
+
const allEqualls = v1 === v2 && v2 === v3 && v3 === v4
|
|
35
|
+
return {
|
|
36
|
+
...setterProps,
|
|
37
|
+
value: position === 'all' ? (allEqualls ? v1 : undefined) : value,
|
|
38
|
+
onChange(val) {
|
|
39
|
+
if (position === 'all') {
|
|
40
|
+
setterProps.onChange?.(
|
|
41
|
+
`${val || '0px'} ${val || '0px'} ${val || '0px'} ${val || '0px'}`
|
|
42
|
+
)
|
|
43
|
+
} else {
|
|
44
|
+
matched[PositionMap[position]] = val
|
|
45
|
+
setterProps.onChange?.(
|
|
46
|
+
`${matched[1] || '0px'} ${matched[2] || '0px'} ${
|
|
47
|
+
matched[3] || '0px'
|
|
48
|
+
} ${matched[4] || '0px'}`
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return _jsxs(FoldItem, {
|
|
55
|
+
className: cls(prefix, className),
|
|
56
|
+
label: field.title,
|
|
57
|
+
children: [
|
|
58
|
+
_jsx(FoldItem.Base, {
|
|
59
|
+
children: _jsx(SizeInput, {
|
|
60
|
+
...createPositionHandler('all', props),
|
|
61
|
+
exclude: ['inherit', 'auto'],
|
|
62
|
+
}),
|
|
63
|
+
}),
|
|
64
|
+
_jsx(FoldItem.Extra, {
|
|
65
|
+
children: _jsxs(InputItems, {
|
|
66
|
+
width: '50%',
|
|
67
|
+
children: [
|
|
68
|
+
_jsx(InputItems.Item, {
|
|
69
|
+
icon: labels[0],
|
|
70
|
+
children: _jsx(SizeInput, {
|
|
71
|
+
...createPositionHandler('top', props),
|
|
72
|
+
exclude: ['inherit', 'auto'],
|
|
73
|
+
}),
|
|
74
|
+
}),
|
|
75
|
+
_jsx(InputItems.Item, {
|
|
76
|
+
icon: labels[1],
|
|
77
|
+
children: _jsx(SizeInput, {
|
|
78
|
+
...createPositionHandler('right', props),
|
|
79
|
+
exclude: ['inherit', 'auto'],
|
|
80
|
+
}),
|
|
81
|
+
}),
|
|
82
|
+
_jsx(InputItems.Item, {
|
|
83
|
+
icon: labels[2],
|
|
84
|
+
children: _jsx(SizeInput, {
|
|
85
|
+
...createPositionHandler('bottom', props),
|
|
86
|
+
exclude: ['inherit', 'auto'],
|
|
87
|
+
}),
|
|
88
|
+
}),
|
|
89
|
+
_jsx(InputItems.Item, {
|
|
90
|
+
icon: labels[3],
|
|
91
|
+
children: _jsx(SizeInput, {
|
|
92
|
+
...createPositionHandler('left', props),
|
|
93
|
+
exclude: ['inherit', 'auto'],
|
|
94
|
+
}),
|
|
95
|
+
}),
|
|
96
|
+
],
|
|
97
|
+
}),
|
|
98
|
+
}),
|
|
99
|
+
],
|
|
100
|
+
})
|
|
101
|
+
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import './styles.less'
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import './styles.less'
|
|
3
3
|
export interface ICollapseItemProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
className?: string
|
|
5
|
+
style?: React.CSSProperties
|
|
6
|
+
defaultExpand?: boolean
|
|
7
7
|
}
|
|
8
|
-
export declare const CollapseItem: React.FC<ICollapseItemProps
|
|
8
|
+
export declare const CollapseItem: React.FC<ICollapseItemProps>
|
|
@@ -1,16 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import './styles.less'
|
|
1
|
+
import { observer, useField } from '@formily/react'
|
|
2
|
+
import { IconWidget, usePrefix } from '@thienvu18/designable-react'
|
|
3
|
+
import cls from 'classnames'
|
|
4
|
+
import { useState } from 'react'
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
|
|
6
|
+
import './styles.less'
|
|
7
7
|
export const CollapseItem = observer((props) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const prefix = usePrefix('collapse-item')
|
|
9
|
+
const field = useField()
|
|
10
|
+
const [expand, setExpand] = useState(props.defaultExpand ?? true)
|
|
11
|
+
return _jsxs('div', {
|
|
12
|
+
className: cls(prefix, props.className, { expand }),
|
|
13
|
+
style: props.style,
|
|
14
|
+
children: [
|
|
15
|
+
_jsxs('div', {
|
|
16
|
+
className: prefix + '-header',
|
|
17
|
+
onClick: (e) => {
|
|
18
|
+
e.stopPropagation()
|
|
19
|
+
e.preventDefault()
|
|
20
|
+
setExpand(!expand)
|
|
21
|
+
},
|
|
22
|
+
children: [
|
|
23
|
+
_jsx('div', {
|
|
24
|
+
className: prefix + '-header-expand',
|
|
25
|
+
children: _jsx(IconWidget, { infer: 'Expand', size: 10 }),
|
|
26
|
+
}),
|
|
27
|
+
_jsx('div', {
|
|
28
|
+
className: prefix + '-header-content',
|
|
29
|
+
children: field.title,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
}),
|
|
33
|
+
_jsx('div', { className: prefix + '-content', children: props.children }),
|
|
34
|
+
],
|
|
35
|
+
})
|
|
36
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import './styles.less'
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import './styles.less'
|
|
3
3
|
export interface IColorInputProps {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
value?: string
|
|
5
|
+
onChange?: (color: string) => void
|
|
6
6
|
}
|
|
7
|
-
export declare const ColorInput: React.FC<IColorInputProps
|
|
7
|
+
export declare const ColorInput: React.FC<IColorInputProps>
|
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import './styles.less';
|
|
1
|
+
import { usePrefix } from '@thienvu18/designable-react'
|
|
2
|
+
import { ColorPicker, Input } from 'antd'
|
|
3
|
+
import { useRef } from 'react'
|
|
4
|
+
import { jsx as _jsx } from 'react/jsx-runtime'
|
|
5
|
+
import './styles.less'
|
|
7
6
|
export const ColorInput = (props) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
7
|
+
const container = useRef(null)
|
|
8
|
+
const prefix = usePrefix('color-input')
|
|
9
|
+
const color = props.value
|
|
10
|
+
return _jsx('div', {
|
|
11
|
+
ref: container,
|
|
12
|
+
className: prefix,
|
|
13
|
+
children: _jsx(Input, {
|
|
14
|
+
value: props.value,
|
|
15
|
+
onChange: (e) => {
|
|
16
|
+
props.onChange?.(e.target.value)
|
|
17
|
+
},
|
|
18
|
+
placeholder: 'Color',
|
|
19
|
+
prefix: _jsx(ColorPicker, {
|
|
20
|
+
value: color,
|
|
21
|
+
autoAdjustOverflow: true,
|
|
22
|
+
getPopupContainer: () => container.current || document.body,
|
|
23
|
+
onChange: (nextColor) => {
|
|
24
|
+
const { r, g, b, a } = nextColor.toRgb()
|
|
25
|
+
props.onChange?.(`rgba(${r},${g},${b},${a})`)
|
|
26
|
+
},
|
|
27
|
+
children: _jsx('div', {
|
|
28
|
+
className: prefix + '-color-tips',
|
|
29
|
+
style: {
|
|
30
|
+
backgroundColor: color,
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
}),
|
|
34
|
+
}),
|
|
35
|
+
})
|
|
36
|
+
}
|