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