@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,70 +1,100 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import './styles.less'
|
|
7
|
-
const isValid = (val) => val !== undefined && val !== null
|
|
1
|
+
import { IconWidget, usePrefix } from '@thienvu18/designable-react'
|
|
2
|
+
import { Button } from 'antd'
|
|
3
|
+
import cls from 'classnames'
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
|
|
6
|
+
import './styles.less'
|
|
7
|
+
const isValid = (val) => val !== undefined && val !== null
|
|
8
8
|
const getEventValue = (event) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return event;
|
|
17
|
-
};
|
|
9
|
+
if (event?.target) {
|
|
10
|
+
if (isValid(event.target.value)) return event.target.value
|
|
11
|
+
if (isValid(event.target.checked)) return event.target.checked
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
return event
|
|
15
|
+
}
|
|
18
16
|
const createTypes = (types, exclude, include) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
17
|
+
return types.filter(({ type }) => {
|
|
18
|
+
if (Array.isArray(include) && include.length) {
|
|
19
|
+
return include.includes(type)
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(exclude) && exclude.length) {
|
|
22
|
+
return !exclude.includes(type)
|
|
23
|
+
}
|
|
24
|
+
return true
|
|
25
|
+
})
|
|
26
|
+
}
|
|
29
27
|
export function createPolyInput(polyTypes = []) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
28
|
+
return ({
|
|
29
|
+
className,
|
|
30
|
+
style,
|
|
31
|
+
value,
|
|
32
|
+
onChange,
|
|
33
|
+
exclude,
|
|
34
|
+
include,
|
|
35
|
+
...props
|
|
36
|
+
}) => {
|
|
37
|
+
const prefix = usePrefix('poly-input')
|
|
38
|
+
const types = createTypes(polyTypes, exclude, include)
|
|
39
|
+
const [current, setCurrent] = useState(types[0]?.type)
|
|
40
|
+
const type = types?.find(({ type }) => type === current)
|
|
41
|
+
const component = type?.component
|
|
42
|
+
const typesValue = useRef({})
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
types?.forEach(({ checker, type }) => {
|
|
45
|
+
if (checker(value)) {
|
|
46
|
+
setCurrent(type)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}, [value])
|
|
50
|
+
const getNextType = () => {
|
|
51
|
+
const currentIndex = types?.findIndex(({ type }) => type === current)
|
|
52
|
+
const nextIndex =
|
|
53
|
+
currentIndex + 1 > types?.length - 1 ? 0 : currentIndex + 1
|
|
54
|
+
return types[nextIndex]
|
|
55
|
+
}
|
|
56
|
+
const transformOnChangeValue = (value, type) => {
|
|
57
|
+
return type?.toChangeValue ? type?.toChangeValue(value) : value
|
|
58
|
+
}
|
|
59
|
+
return _jsxs('div', {
|
|
60
|
+
className: cls(prefix, className),
|
|
61
|
+
style: style,
|
|
62
|
+
children: [
|
|
63
|
+
component &&
|
|
64
|
+
_jsx('div', {
|
|
65
|
+
className: prefix + '-content',
|
|
66
|
+
children: React.createElement(component, {
|
|
67
|
+
...props,
|
|
68
|
+
value: type?.toInputValue ? type?.toInputValue(value) : value,
|
|
69
|
+
onChange: (event) => {
|
|
70
|
+
const value = getEventValue(event)
|
|
71
|
+
typesValue.current[type?.type] = value
|
|
72
|
+
onChange?.(transformOnChangeValue(value, type))
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
}),
|
|
76
|
+
_jsx(Button, {
|
|
77
|
+
className: prefix + '-controller',
|
|
78
|
+
style: {
|
|
79
|
+
width: !component ? '100%' : 'auto',
|
|
80
|
+
},
|
|
81
|
+
block: true,
|
|
82
|
+
onClick: () => {
|
|
83
|
+
const nextType = getNextType()
|
|
84
|
+
if (nextType === type) return
|
|
85
|
+
setCurrent(nextType?.type)
|
|
86
|
+
onChange?.(
|
|
87
|
+
transformOnChangeValue(
|
|
88
|
+
typesValue.current[nextType?.type],
|
|
89
|
+
nextType
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
},
|
|
93
|
+
children: type?.icon
|
|
94
|
+
? _jsx(IconWidget, { infer: type.icon })
|
|
95
|
+
: type?.title || type?.type,
|
|
96
|
+
}),
|
|
97
|
+
],
|
|
98
|
+
})
|
|
99
|
+
}
|
|
70
100
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import './styles.less'
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import './styles.less'
|
|
3
3
|
export interface IPositionInputProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
className?: string
|
|
5
|
+
style?: React.CSSProperties
|
|
6
|
+
value?: string
|
|
7
|
+
onChange?: (value: string) => void
|
|
8
8
|
}
|
|
9
|
-
export declare const PositionInput: React.FC<IPositionInputProps
|
|
9
|
+
export declare const PositionInput: React.FC<IPositionInputProps>
|
|
@@ -1,22 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import './styles.less'
|
|
1
|
+
import { usePrefix } from '@thienvu18/designable-react'
|
|
2
|
+
import cls from 'classnames'
|
|
3
|
+
import { useEffect, useState } from 'react'
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
|
|
5
|
+
import './styles.less'
|
|
6
6
|
export const PositionInput = (props) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
const prefix = usePrefix('position-input')
|
|
8
|
+
const [current, setCurrent] = useState(props.value)
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!props.value) {
|
|
11
|
+
setCurrent('center')
|
|
12
|
+
}
|
|
13
|
+
}, [props.value])
|
|
14
|
+
const createCellProps = (type) => ({
|
|
15
|
+
className: cls(prefix + '-cell', { active: current === type }),
|
|
16
|
+
onClick() {
|
|
17
|
+
setCurrent(type)
|
|
18
|
+
props.onChange?.(type)
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
return _jsxs('div', {
|
|
22
|
+
className: cls(prefix, props.className),
|
|
23
|
+
style: props.style,
|
|
24
|
+
children: [
|
|
25
|
+
_jsx('div', {
|
|
26
|
+
className: prefix + '-row',
|
|
27
|
+
children: _jsx('div', {
|
|
28
|
+
...createCellProps('top'),
|
|
29
|
+
children: '\u2533',
|
|
30
|
+
}),
|
|
31
|
+
}),
|
|
32
|
+
_jsxs('div', {
|
|
33
|
+
className: prefix + '-row',
|
|
34
|
+
children: [
|
|
35
|
+
_jsx('div', { ...createCellProps('left'), children: '\u2523' }),
|
|
36
|
+
_jsx('div', { ...createCellProps('center'), children: '\u254B' }),
|
|
37
|
+
_jsx('div', { ...createCellProps('right'), children: '\u252B' }),
|
|
38
|
+
],
|
|
39
|
+
}),
|
|
40
|
+
_jsx('div', {
|
|
41
|
+
className: prefix + '-row',
|
|
42
|
+
children: _jsx('div', {
|
|
43
|
+
...createCellProps('bottom'),
|
|
44
|
+
children: '\u253B',
|
|
45
|
+
}),
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
})
|
|
49
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const SizeInput: import(
|
|
3
|
-
|
|
2
|
+
export declare const SizeInput: import('react').FC<
|
|
3
|
+
import('../PolyInput').IInput
|
|
4
|
+
>
|
|
5
|
+
export declare const BackgroundSizeInput: import('react').FC<
|
|
6
|
+
import('../PolyInput').IInput
|
|
7
|
+
>
|
|
@@ -1,53 +1,51 @@
|
|
|
1
|
-
import { InputNumber } from 'antd'
|
|
2
|
-
import { createPolyInput } from '../PolyInput'
|
|
1
|
+
import { InputNumber } from 'antd'
|
|
2
|
+
import { createPolyInput } from '../PolyInput'
|
|
3
3
|
const takeNumber = (value) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
4
|
+
const num = String(value)
|
|
5
|
+
.trim()
|
|
6
|
+
.replace(/[^\d\.]+/, '')
|
|
7
|
+
if (num === '') return
|
|
8
|
+
return Number(num)
|
|
9
|
+
}
|
|
11
10
|
const createUnitType = (type) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
checker(value) {
|
|
16
|
-
return String(value).includes(type);
|
|
17
|
-
},
|
|
18
|
-
toInputValue(value) {
|
|
19
|
-
return takeNumber(value);
|
|
20
|
-
},
|
|
21
|
-
toChangeValue(value) {
|
|
22
|
-
return `${value || 0}${type}`;
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const createSpecialSizeOption = (type) => ({
|
|
27
|
-
type: type,
|
|
11
|
+
return {
|
|
12
|
+
type,
|
|
13
|
+
component: InputNumber,
|
|
28
14
|
checker(value) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
return String(value).includes(type)
|
|
16
|
+
},
|
|
17
|
+
toInputValue(value) {
|
|
18
|
+
return takeNumber(value)
|
|
32
19
|
},
|
|
33
|
-
toChangeValue() {
|
|
34
|
-
|
|
20
|
+
toChangeValue(value) {
|
|
21
|
+
return `${value || 0}${type}`
|
|
35
22
|
},
|
|
36
|
-
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const createSpecialSizeOption = (type) => ({
|
|
26
|
+
type: type,
|
|
27
|
+
checker(value) {
|
|
28
|
+
if (value === type) return true
|
|
29
|
+
return false
|
|
30
|
+
},
|
|
31
|
+
toChangeValue() {
|
|
32
|
+
return type
|
|
33
|
+
},
|
|
34
|
+
})
|
|
37
35
|
const NormalSizeOptions = [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
]
|
|
45
|
-
export const SizeInput = createPolyInput(NormalSizeOptions)
|
|
36
|
+
createSpecialSizeOption('inherit'),
|
|
37
|
+
createSpecialSizeOption('auto'),
|
|
38
|
+
createUnitType('px'),
|
|
39
|
+
createUnitType('%'),
|
|
40
|
+
createUnitType('vh'),
|
|
41
|
+
createUnitType('em'),
|
|
42
|
+
]
|
|
43
|
+
export const SizeInput = createPolyInput(NormalSizeOptions)
|
|
46
44
|
export const BackgroundSizeInput = createPolyInput([
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
])
|
|
45
|
+
createSpecialSizeOption('cover'),
|
|
46
|
+
createSpecialSizeOption('contain'),
|
|
47
|
+
createUnitType('px'),
|
|
48
|
+
createUnitType('%'),
|
|
49
|
+
createUnitType('vh'),
|
|
50
|
+
createUnitType('em'),
|
|
51
|
+
])
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
export declare const ValueInput: React.FC<import(
|
|
1
|
+
import React from 'react'
|
|
2
|
+
export declare const ValueInput: React.FC<import('../PolyInput').IInput>
|
|
@@ -1,81 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { MonacoInput } from '../MonacoInput'
|
|
5
|
-
import {
|
|
6
|
-
const STARTTAG_REX =
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
1
|
+
import { TextWidget } from '@thienvu18/designable-react'
|
|
2
|
+
import { Button, Input, InputNumber, Popover, Select } from 'antd'
|
|
3
|
+
import { jsx as _jsx } from 'react/jsx-runtime'
|
|
4
|
+
import { MonacoInput } from '../MonacoInput'
|
|
5
|
+
import { createPolyInput } from '../PolyInput'
|
|
6
|
+
const STARTTAG_REX =
|
|
7
|
+
/<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/
|
|
8
|
+
const EXPRESSION_REX = /^\{\{([\s\S]*)\}\}$/
|
|
9
|
+
const isNumber = (value) => typeof value === 'number'
|
|
10
|
+
const isBoolean = (value) => typeof value === 'boolean'
|
|
10
11
|
const isExpression = (value) => {
|
|
11
|
-
|
|
12
|
-
}
|
|
12
|
+
return typeof value === 'string' && EXPRESSION_REX.test(value)
|
|
13
|
+
}
|
|
13
14
|
const isRichText = (value) => {
|
|
14
|
-
|
|
15
|
-
}
|
|
15
|
+
return typeof value === 'string' && STARTTAG_REX.test(value)
|
|
16
|
+
}
|
|
16
17
|
const isNormalText = (value) => {
|
|
17
|
-
|
|
18
|
-
}
|
|
18
|
+
return typeof value === 'string' && !isExpression(value) && !isRichText(value)
|
|
19
|
+
}
|
|
19
20
|
const takeNumber = (value) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
21
|
+
const num = String(value).replace(/[^\d\.]+/, '')
|
|
22
|
+
if (num === '') return
|
|
23
|
+
return Number(num)
|
|
24
|
+
}
|
|
25
25
|
export const ValueInput = createPolyInput([
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
{
|
|
27
|
+
type: 'TEXT',
|
|
28
|
+
icon: 'Text',
|
|
29
|
+
component: Input,
|
|
30
|
+
checker: isNormalText,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'EXPRESSION',
|
|
34
|
+
icon: 'Expression',
|
|
35
|
+
component: (props) => {
|
|
36
|
+
return _jsx(Popover, {
|
|
37
|
+
content: _jsx('div', {
|
|
38
|
+
style: {
|
|
39
|
+
width: 400,
|
|
40
|
+
height: 200,
|
|
41
|
+
marginLeft: -16,
|
|
42
|
+
marginRight: -16,
|
|
43
|
+
marginBottom: -12,
|
|
44
|
+
},
|
|
45
|
+
children: _jsx(MonacoInput, {
|
|
46
|
+
...props,
|
|
47
|
+
language: 'javascript.expression',
|
|
48
|
+
}),
|
|
49
|
+
}),
|
|
50
|
+
trigger: 'click',
|
|
51
|
+
children: _jsx(Button, {
|
|
52
|
+
block: true,
|
|
53
|
+
children: _jsx(TextWidget, {
|
|
54
|
+
token: 'SettingComponents.ValueInput.expression',
|
|
55
|
+
}),
|
|
56
|
+
}),
|
|
57
|
+
})
|
|
31
58
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
width: 400,
|
|
38
|
-
height: 200,
|
|
39
|
-
marginLeft: -16,
|
|
40
|
-
marginRight: -16,
|
|
41
|
-
marginBottom: -12,
|
|
42
|
-
}, children: _jsx(MonacoInput, { ...props, language: "javascript.expression" }) }), trigger: "click", children: _jsx(Button, { block: true, children: _jsx(TextWidget, { token: "SettingComponents.ValueInput.expression" }) }) }));
|
|
43
|
-
},
|
|
44
|
-
checker: isExpression,
|
|
45
|
-
toInputValue: (value) => {
|
|
46
|
-
if (!value || value === '{{}}')
|
|
47
|
-
return;
|
|
48
|
-
const matched = String(value).match(EXPRESSION_REX);
|
|
49
|
-
return matched?.[1] || value || '';
|
|
50
|
-
},
|
|
51
|
-
toChangeValue: (value) => {
|
|
52
|
-
if (!value || value === '{{}}')
|
|
53
|
-
return;
|
|
54
|
-
const matched = String(value).match(EXPRESSION_REX);
|
|
55
|
-
return `{{${matched?.[1] || value || ''}}}`;
|
|
56
|
-
},
|
|
59
|
+
checker: isExpression,
|
|
60
|
+
toInputValue: (value) => {
|
|
61
|
+
if (!value || value === '{{}}') return
|
|
62
|
+
const matched = String(value).match(EXPRESSION_REX)
|
|
63
|
+
return matched?.[1] || value || ''
|
|
57
64
|
},
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{ label: 'True', value: true },
|
|
63
|
-
{ label: 'False', value: false },
|
|
64
|
-
] })),
|
|
65
|
-
checker: isBoolean,
|
|
66
|
-
toInputValue: (value) => {
|
|
67
|
-
return !!value;
|
|
68
|
-
},
|
|
69
|
-
toChangeValue: (value) => {
|
|
70
|
-
return !!value;
|
|
71
|
-
},
|
|
65
|
+
toChangeValue: (value) => {
|
|
66
|
+
if (!value || value === '{{}}') return
|
|
67
|
+
const matched = String(value).match(EXPRESSION_REX)
|
|
68
|
+
return `{{${matched?.[1] || value || ''}}}`
|
|
72
69
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: 'BOOLEAN',
|
|
73
|
+
icon: 'Boolean',
|
|
74
|
+
component: (props) =>
|
|
75
|
+
_jsx(Select, {
|
|
76
|
+
...props,
|
|
77
|
+
options: [
|
|
78
|
+
{ label: 'True', value: true },
|
|
79
|
+
{ label: 'False', value: false },
|
|
80
|
+
],
|
|
81
|
+
}),
|
|
82
|
+
checker: isBoolean,
|
|
83
|
+
toInputValue: (value) => {
|
|
84
|
+
return !!value
|
|
80
85
|
},
|
|
81
|
-
|
|
86
|
+
toChangeValue: (value) => {
|
|
87
|
+
return !!value
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'NUMBER',
|
|
92
|
+
icon: 'Number',
|
|
93
|
+
component: InputNumber,
|
|
94
|
+
checker: isNumber,
|
|
95
|
+
toInputValue: takeNumber,
|
|
96
|
+
toChangeValue: takeNumber,
|
|
97
|
+
},
|
|
98
|
+
])
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
1
|
+
export * from './BackgroundStyleSetter'
|
|
2
|
+
export * from './BorderRadiusStyleSetter'
|
|
3
|
+
export * from './BorderStyleSetter'
|
|
4
|
+
export * from './BoxShadowStyleSetter'
|
|
5
|
+
export * from './BoxStyleSetter'
|
|
6
|
+
export * from './CollapseItem'
|
|
7
|
+
export * from './ColorInput'
|
|
8
|
+
export * from './CornerInput'
|
|
9
|
+
export * from './DisplayStyleSetter'
|
|
10
|
+
export * from './DrawerSetter'
|
|
11
|
+
export * from './FlexStyleSetter'
|
|
12
|
+
export * from './FoldItem'
|
|
13
|
+
export * from './FontStyleSetter'
|
|
14
|
+
export * from './ImageInput'
|
|
15
|
+
export * from './InputItems'
|
|
16
|
+
export * from './MonacoInput'
|
|
17
|
+
export * from './PolyInput'
|
|
18
|
+
export * from './PositionInput'
|
|
19
|
+
export * from './SizeInput'
|
|
20
|
+
export * from './ValueInput'
|
package/esm/components/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
1
|
+
export * from './BackgroundStyleSetter'
|
|
2
|
+
export * from './BorderRadiusStyleSetter'
|
|
3
|
+
export * from './BorderStyleSetter'
|
|
4
|
+
export * from './BoxShadowStyleSetter'
|
|
5
|
+
export * from './BoxStyleSetter'
|
|
6
|
+
export * from './CollapseItem'
|
|
7
|
+
export * from './ColorInput'
|
|
8
|
+
export * from './CornerInput'
|
|
9
|
+
export * from './DisplayStyleSetter'
|
|
10
|
+
export * from './DrawerSetter'
|
|
11
|
+
export * from './FlexStyleSetter'
|
|
12
|
+
export * from './FoldItem'
|
|
13
|
+
export * from './FontStyleSetter'
|
|
14
|
+
export * from './ImageInput'
|
|
15
|
+
export * from './InputItems'
|
|
16
|
+
export * from './MonacoInput'
|
|
17
|
+
export * from './PolyInput'
|
|
18
|
+
export * from './PositionInput'
|
|
19
|
+
export * from './SizeInput'
|
|
20
|
+
export * from './ValueInput'
|
package/esm/effects/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './useLocales'
|
|
2
|
-
export * from './useSnapshot'
|
|
1
|
+
export * from './useLocales'
|
|
2
|
+
export * from './useSnapshot'
|
package/esm/effects/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './useLocales'
|
|
2
|
-
export * from './useSnapshot'
|
|
1
|
+
export * from './useLocales'
|
|
2
|
+
export * from './useSnapshot'
|