@thienvu18/designable-react-settings-form 2.0.0

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 (191) hide show
  1. package/LICENSE.md +20 -0
  2. package/README.md +1 -0
  3. package/esm/SchemaField.d.ts +1580 -0
  4. package/esm/SchemaField.js +42 -0
  5. package/esm/SettingsForm.d.ts +4 -0
  6. package/esm/SettingsForm.js +54 -0
  7. package/esm/components/BackgroundStyleSetter/index.d.ts +6 -0
  8. package/esm/components/BackgroundStyleSetter/index.js +43 -0
  9. package/esm/components/BorderRadiusStyleSetter/index.d.ts +6 -0
  10. package/esm/components/BorderRadiusStyleSetter/index.js +11 -0
  11. package/esm/components/BorderStyleSetter/index.d.ts +7 -0
  12. package/esm/components/BorderStyleSetter/index.js +74 -0
  13. package/esm/components/BorderStyleSetter/styles.less +70 -0
  14. package/esm/components/BoxShadowStyleSetter/index.d.ts +8 -0
  15. package/esm/components/BoxShadowStyleSetter/index.js +25 -0
  16. package/esm/components/BoxStyleSetter/index.d.ts +9 -0
  17. package/esm/components/BoxStyleSetter/index.js +49 -0
  18. package/esm/components/CollapseItem/index.d.ts +8 -0
  19. package/esm/components/CollapseItem/index.js +16 -0
  20. package/esm/components/CollapseItem/styles.less +45 -0
  21. package/esm/components/ColorInput/index.d.ts +7 -0
  22. package/esm/components/ColorInput/index.js +18 -0
  23. package/esm/components/ColorInput/styles.less +17 -0
  24. package/esm/components/CornerInput/index.d.ts +9 -0
  25. package/esm/components/CornerInput/index.js +22 -0
  26. package/esm/components/CornerInput/styles.less +25 -0
  27. package/esm/components/DisplayStyleSetter/index.d.ts +9 -0
  28. package/esm/components/DisplayStyleSetter/index.js +34 -0
  29. package/esm/components/DisplayStyleSetter/styles.less +15 -0
  30. package/esm/components/DrawerSetter/index.d.ts +8 -0
  31. package/esm/components/DrawerSetter/index.js +43 -0
  32. package/esm/components/DrawerSetter/styles.less +54 -0
  33. package/esm/components/FlexStyleSetter/index.d.ts +7 -0
  34. package/esm/components/FlexStyleSetter/index.js +111 -0
  35. package/esm/components/FlexStyleSetter/styles.less +23 -0
  36. package/esm/components/FoldItem/index.d.ts +7 -0
  37. package/esm/components/FoldItem/index.js +49 -0
  38. package/esm/components/FoldItem/styles.less +42 -0
  39. package/esm/components/FontStyleSetter/index.d.ts +6 -0
  40. package/esm/components/FontStyleSetter/index.js +88 -0
  41. package/esm/components/ImageInput/index.d.ts +9 -0
  42. package/esm/components/ImageInput/index.js +41 -0
  43. package/esm/components/ImageInput/styles.less +3 -0
  44. package/esm/components/InputItems/index.d.ts +23 -0
  45. package/esm/components/InputItems/index.js +18 -0
  46. package/esm/components/InputItems/styles.less +45 -0
  47. package/esm/components/MonacoInput/config.d.ts +1 -0
  48. package/esm/components/MonacoInput/config.js +39 -0
  49. package/esm/components/MonacoInput/format.d.ts +1 -0
  50. package/esm/components/MonacoInput/format.js +31 -0
  51. package/esm/components/MonacoInput/index.d.ts +16 -0
  52. package/esm/components/MonacoInput/index.js +216 -0
  53. package/esm/components/MonacoInput/styles.less +33 -0
  54. package/esm/components/MonacoInput/themes/chrome.d.ts +39 -0
  55. package/esm/components/MonacoInput/themes/chrome.js +106 -0
  56. package/esm/components/MonacoInput/themes/monokai.d.ts +31 -0
  57. package/esm/components/MonacoInput/themes/monokai.js +140 -0
  58. package/esm/components/PolyInput/index.d.ts +21 -0
  59. package/esm/components/PolyInput/index.js +70 -0
  60. package/esm/components/PolyInput/styles.less +31 -0
  61. package/esm/components/PositionInput/index.d.ts +9 -0
  62. package/esm/components/PositionInput/index.js +22 -0
  63. package/esm/components/PositionInput/styles.less +28 -0
  64. package/esm/components/SizeInput/index.d.ts +3 -0
  65. package/esm/components/SizeInput/index.js +53 -0
  66. package/esm/components/SizeInput/styles.less +23 -0
  67. package/esm/components/ValueInput/index.d.ts +2 -0
  68. package/esm/components/ValueInput/index.js +81 -0
  69. package/esm/components/ValueInput/styles.less +0 -0
  70. package/esm/components/index.d.ts +20 -0
  71. package/esm/components/index.js +20 -0
  72. package/esm/effects/index.d.ts +2 -0
  73. package/esm/effects/index.js +2 -0
  74. package/esm/effects/useLocales.d.ts +2 -0
  75. package/esm/effects/useLocales.js +63 -0
  76. package/esm/effects/useSnapshot.d.ts +2 -0
  77. package/esm/effects/useSnapshot.js +10 -0
  78. package/esm/index.d.ts +5 -0
  79. package/esm/index.js +5 -0
  80. package/esm/locales/en-US.d.ts +13 -0
  81. package/esm/locales/en-US.js +12 -0
  82. package/esm/locales/index.d.ts +1 -0
  83. package/esm/locales/index.js +5 -0
  84. package/esm/locales/ko-KR.d.ts +13 -0
  85. package/esm/locales/ko-KR.js +12 -0
  86. package/esm/locales/zh-CN.d.ts +13 -0
  87. package/esm/locales/zh-CN.js +12 -0
  88. package/esm/registry.d.ts +2 -0
  89. package/esm/registry.js +13 -0
  90. package/esm/shared/context.d.ts +3 -0
  91. package/esm/shared/context.js +2 -0
  92. package/esm/shared/loadScript.d.ts +7 -0
  93. package/esm/shared/loadScript.js +29 -0
  94. package/esm/styles.less +121 -0
  95. package/esm/types.d.ts +10 -0
  96. package/esm/types.js +1 -0
  97. package/lib/SchemaField.d.ts +1580 -0
  98. package/lib/SchemaField.js +45 -0
  99. package/lib/SettingsForm.d.ts +4 -0
  100. package/lib/SettingsForm.js +60 -0
  101. package/lib/components/BackgroundStyleSetter/index.d.ts +6 -0
  102. package/lib/components/BackgroundStyleSetter/index.js +49 -0
  103. package/lib/components/BorderRadiusStyleSetter/index.d.ts +6 -0
  104. package/lib/components/BorderRadiusStyleSetter/index.js +15 -0
  105. package/lib/components/BorderStyleSetter/index.d.ts +7 -0
  106. package/lib/components/BorderStyleSetter/index.js +80 -0
  107. package/lib/components/BorderStyleSetter/styles.less +70 -0
  108. package/lib/components/BoxShadowStyleSetter/index.d.ts +8 -0
  109. package/lib/components/BoxShadowStyleSetter/index.js +31 -0
  110. package/lib/components/BoxStyleSetter/index.d.ts +9 -0
  111. package/lib/components/BoxStyleSetter/index.js +55 -0
  112. package/lib/components/CollapseItem/index.d.ts +8 -0
  113. package/lib/components/CollapseItem/index.js +22 -0
  114. package/lib/components/CollapseItem/styles.less +45 -0
  115. package/lib/components/ColorInput/index.d.ts +7 -0
  116. package/lib/components/ColorInput/index.js +22 -0
  117. package/lib/components/ColorInput/styles.less +17 -0
  118. package/lib/components/CornerInput/index.d.ts +9 -0
  119. package/lib/components/CornerInput/index.js +29 -0
  120. package/lib/components/CornerInput/styles.less +25 -0
  121. package/lib/components/DisplayStyleSetter/index.d.ts +9 -0
  122. package/lib/components/DisplayStyleSetter/index.js +40 -0
  123. package/lib/components/DisplayStyleSetter/styles.less +15 -0
  124. package/lib/components/DrawerSetter/index.d.ts +8 -0
  125. package/lib/components/DrawerSetter/index.js +49 -0
  126. package/lib/components/DrawerSetter/styles.less +54 -0
  127. package/lib/components/FlexStyleSetter/index.d.ts +7 -0
  128. package/lib/components/FlexStyleSetter/index.js +117 -0
  129. package/lib/components/FlexStyleSetter/styles.less +23 -0
  130. package/lib/components/FoldItem/index.d.ts +7 -0
  131. package/lib/components/FoldItem/index.js +78 -0
  132. package/lib/components/FoldItem/styles.less +42 -0
  133. package/lib/components/FontStyleSetter/index.d.ts +6 -0
  134. package/lib/components/FontStyleSetter/index.js +94 -0
  135. package/lib/components/ImageInput/index.d.ts +9 -0
  136. package/lib/components/ImageInput/index.js +49 -0
  137. package/lib/components/ImageInput/styles.less +3 -0
  138. package/lib/components/InputItems/index.d.ts +23 -0
  139. package/lib/components/InputItems/index.js +48 -0
  140. package/lib/components/InputItems/styles.less +45 -0
  141. package/lib/components/MonacoInput/config.d.ts +1 -0
  142. package/lib/components/MonacoInput/config.js +46 -0
  143. package/lib/components/MonacoInput/format.d.ts +1 -0
  144. package/lib/components/MonacoInput/format.js +35 -0
  145. package/lib/components/MonacoInput/index.d.ts +16 -0
  146. package/lib/components/MonacoInput/index.js +246 -0
  147. package/lib/components/MonacoInput/styles.less +33 -0
  148. package/lib/components/MonacoInput/themes/chrome.d.ts +39 -0
  149. package/lib/components/MonacoInput/themes/chrome.js +108 -0
  150. package/lib/components/MonacoInput/themes/monokai.d.ts +31 -0
  151. package/lib/components/MonacoInput/themes/monokai.js +142 -0
  152. package/lib/components/PolyInput/index.d.ts +21 -0
  153. package/lib/components/PolyInput/index.js +100 -0
  154. package/lib/components/PolyInput/styles.less +31 -0
  155. package/lib/components/PositionInput/index.d.ts +9 -0
  156. package/lib/components/PositionInput/index.js +29 -0
  157. package/lib/components/PositionInput/styles.less +28 -0
  158. package/lib/components/SizeInput/index.d.ts +3 -0
  159. package/lib/components/SizeInput/index.js +56 -0
  160. package/lib/components/SizeInput/styles.less +23 -0
  161. package/lib/components/ValueInput/index.d.ts +2 -0
  162. package/lib/components/ValueInput/index.js +84 -0
  163. package/lib/components/ValueInput/styles.less +0 -0
  164. package/lib/components/index.d.ts +20 -0
  165. package/lib/components/index.js +36 -0
  166. package/lib/effects/index.d.ts +2 -0
  167. package/lib/effects/index.js +18 -0
  168. package/lib/effects/useLocales.d.ts +2 -0
  169. package/lib/effects/useLocales.js +67 -0
  170. package/lib/effects/useSnapshot.d.ts +2 -0
  171. package/lib/effects/useSnapshot.js +14 -0
  172. package/lib/index.d.ts +5 -0
  173. package/lib/index.js +21 -0
  174. package/lib/locales/en-US.d.ts +13 -0
  175. package/lib/locales/en-US.js +14 -0
  176. package/lib/locales/index.d.ts +1 -0
  177. package/lib/locales/index.js +10 -0
  178. package/lib/locales/ko-KR.d.ts +13 -0
  179. package/lib/locales/ko-KR.js +14 -0
  180. package/lib/locales/zh-CN.d.ts +13 -0
  181. package/lib/locales/zh-CN.js +14 -0
  182. package/lib/registry.d.ts +2 -0
  183. package/lib/registry.js +21 -0
  184. package/lib/shared/context.d.ts +3 -0
  185. package/lib/shared/context.js +5 -0
  186. package/lib/shared/loadScript.d.ts +7 -0
  187. package/lib/shared/loadScript.js +33 -0
  188. package/lib/styles.less +121 -0
  189. package/lib/types.d.ts +10 -0
  190. package/lib/types.js +2 -0
  191. package/package.json +71 -0
@@ -0,0 +1,42 @@
1
+ import { createSchemaField } from '@formily/react';
2
+ import { FormItem, Input, NumberPicker, DatePicker, TimePicker, Select, Radio, Switch, Space, ArrayItems, ArrayTable, FormCollapse, FormGrid, FormLayout, FormTab, } from '@thienvu18/formily-antd-v6';
3
+ import { Slider } from 'antd';
4
+ import { SizeInput, ColorInput, ImageInput, BackgroundImageInput, PositionInput, CornerInput, MonacoInput, ValueInput, BoxStyleSetter, BorderStyleSetter, BorderRadiusStyleSetter, BackgroundStyleSetter, BoxShadowStyleSetter, FontStyleSetter, DisplayStyleSetter, FlexStyleSetter, DrawerSetter, CollapseItem, } from './components';
5
+ export const SchemaField = createSchemaField({
6
+ components: {
7
+ FormItem,
8
+ CollapseItem,
9
+ Input,
10
+ ValueInput,
11
+ SizeInput,
12
+ ColorInput,
13
+ ImageInput,
14
+ MonacoInput,
15
+ PositionInput,
16
+ CornerInput,
17
+ BackgroundImageInput,
18
+ BackgroundStyleSetter,
19
+ BoxStyleSetter,
20
+ BorderStyleSetter,
21
+ BorderRadiusStyleSetter,
22
+ DisplayStyleSetter,
23
+ BoxShadowStyleSetter,
24
+ FlexStyleSetter,
25
+ FontStyleSetter,
26
+ DrawerSetter,
27
+ NumberPicker,
28
+ DatePicker,
29
+ TimePicker,
30
+ Select,
31
+ Radio,
32
+ Slider,
33
+ Switch,
34
+ Space,
35
+ ArrayItems,
36
+ ArrayTable,
37
+ FormCollapse,
38
+ FormGrid,
39
+ FormLayout,
40
+ FormTab,
41
+ },
42
+ });
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ISettingFormProps } from './types';
3
+ import './styles.less';
4
+ export declare const SettingsForm: React.FC<ISettingFormProps>;
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { createForm } from '@formily/core';
4
+ import { Form } from '@thienvu18/formily-antd-v6';
5
+ import { observer } from '@formily/react';
6
+ import { requestIdle, cancelIdle } from '@thienvu18/designable-shared';
7
+ import { usePrefix, useSelected, useOperation, useSelectedNode, useWorkbench, IconWidget, NodePathWidget, } from '@thienvu18/designable-react';
8
+ import { SchemaField } from './SchemaField';
9
+ import { SettingsFormContext } from './shared/context';
10
+ import { useLocales, useSnapshot } from './effects';
11
+ import { Empty } from 'antd';
12
+ import cls from 'classnames';
13
+ import './styles.less';
14
+ const GlobalState = {
15
+ idleRequest: null,
16
+ };
17
+ export const SettingsForm = observer((props) => {
18
+ const workbench = useWorkbench();
19
+ const currentWorkspace = workbench?.activeWorkspace || workbench?.currentWorkspace;
20
+ const currentWorkspaceId = currentWorkspace?.id;
21
+ const operation = useOperation(currentWorkspaceId);
22
+ const node = useSelectedNode(currentWorkspaceId);
23
+ const selected = useSelected(currentWorkspaceId);
24
+ const prefix = usePrefix('settings-form');
25
+ const schema = node?.designerProps?.propsSchema;
26
+ const isEmpty = !(node &&
27
+ node.designerProps?.propsSchema &&
28
+ selected.length === 1);
29
+ const form = useMemo(() => {
30
+ return createForm({
31
+ initialValues: node?.designerProps?.defaultProps,
32
+ values: node?.props,
33
+ effects(form) {
34
+ useLocales(node);
35
+ useSnapshot(operation);
36
+ props.effects?.(form);
37
+ },
38
+ });
39
+ }, [node, node?.props, schema, operation, isEmpty]);
40
+ const render = () => {
41
+ if (!isEmpty) {
42
+ return (_jsx("div", { className: cls(prefix, props.className), style: props.style, children: _jsx(SettingsFormContext.Provider, { value: props, children: _jsx(Form, { form: form, colon: false, labelWidth: 120, labelAlign: "left", wrapperAlign: "right", feedbackLayout: "none", tooltipLayout: "text", children: _jsx(SchemaField, { schema: schema, components: props.components, scope: { $node: node, ...props.scope } }) }) }) }, node.id));
43
+ }
44
+ return (_jsx("div", { className: prefix + '-empty', children: _jsx(Empty, {}) }));
45
+ };
46
+ return (_jsx(IconWidget.Provider, { tooltip: true, children: _jsxs("div", { className: prefix + '-wrapper', children: [!isEmpty && _jsx(NodePathWidget, { workspaceId: currentWorkspaceId }), _jsx("div", { className: prefix + '-content', children: render() })] }) }));
47
+ }, {
48
+ scheduler: (update) => {
49
+ cancelIdle(GlobalState.idleRequest);
50
+ GlobalState.idleRequest = requestIdle(update, {
51
+ timeout: 500,
52
+ });
53
+ },
54
+ });
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface IBackgroundStyleSetterProps {
3
+ className?: string;
4
+ style?: React.CSSProperties;
5
+ }
6
+ export declare const BackgroundStyleSetter: React.FC<IBackgroundStyleSetterProps>;
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useField, Field, observer } from '@formily/react';
3
+ import { usePrefix } from '@thienvu18/designable-react';
4
+ import { Select, Input } from '@thienvu18/formily-antd-v6';
5
+ import { FoldItem } from '../FoldItem';
6
+ import { ColorInput } from '../ColorInput';
7
+ import { BackgroundSizeInput } from '../SizeInput';
8
+ import { BackgroundImageInput } from '../ImageInput';
9
+ import { InputItems } from '../InputItems';
10
+ import cls from 'classnames';
11
+ export const BackgroundStyleSetter = observer((props) => {
12
+ const field = useField();
13
+ const prefix = usePrefix('background-style-setter');
14
+ return (_jsxs(FoldItem, { className: cls(prefix, props.className), label: field.title, children: [_jsx(FoldItem.Base, { children: _jsx(Field, { name: "backgroundColor", basePath: field.address.parent(), component: [ColorInput] }) }), _jsx(FoldItem.Extra, { children: _jsxs(InputItems, { children: [_jsx(InputItems.Item, { icon: "Image", children: _jsx(Field, { name: "backgroundImage", basePath: field.address.parent(), component: [BackgroundImageInput] }) }), _jsx(InputItems.Item, { icon: "ImageSize", width: "50%", children: _jsx(Field, { name: "backgroundSize", basePath: field.address.parent(), component: [BackgroundSizeInput] }) }), _jsx(InputItems.Item, { icon: "Repeat", width: "50%", children: _jsx(Field, { name: "backgroundRepeat", basePath: field.address.parent(), component: [
15
+ Select,
16
+ { style: { width: '100%' }, placeholder: 'Repeat' },
17
+ ], dataSource: [
18
+ {
19
+ label: 'No Repeat',
20
+ value: 'no-repeat',
21
+ },
22
+ {
23
+ label: 'Repeat',
24
+ value: 'repeat',
25
+ },
26
+ {
27
+ label: 'Repeat X',
28
+ value: 'repeat-x',
29
+ },
30
+ {
31
+ label: 'Repeat Y',
32
+ value: 'repeat-y',
33
+ },
34
+ {
35
+ label: 'Space',
36
+ value: 'space',
37
+ },
38
+ {
39
+ label: 'Round',
40
+ value: 'round',
41
+ },
42
+ ] }) }), _jsx(InputItems.Item, { icon: "Position", children: _jsx(Field, { name: "backgroundPosition", basePath: field.address.parent(), component: [Input, { placeholder: 'center center' }] }) })] }) })] }));
43
+ });
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface IBorderRadiusStyleSetterProps {
3
+ value?: string;
4
+ onChange?: (value: string) => void;
5
+ }
6
+ export declare const BorderRadiusStyleSetter: React.FC<IBorderRadiusStyleSetterProps>;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { IconWidget } from '@thienvu18/designable-react';
3
+ import { BoxStyleSetter } from '../BoxStyleSetter';
4
+ export const BorderRadiusStyleSetter = (props) => {
5
+ return (_jsx(BoxStyleSetter, { ...props, labels: [
6
+ _jsx(IconWidget, { infer: "TopLeft", size: 16 }, "1"),
7
+ _jsx(IconWidget, { infer: "TopRight", size: 16 }, "2"),
8
+ _jsx(IconWidget, { infer: "BottomRight", size: 16 }, "3"),
9
+ _jsx(IconWidget, { infer: "BottomLeft", size: 16 }, "4"),
10
+ ] }));
11
+ };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import './styles.less';
3
+ export interface IBorderStyleSetterProps {
4
+ className?: string;
5
+ style?: React.CSSProperties;
6
+ }
7
+ export declare const BorderStyleSetter: React.FC<IBorderStyleSetterProps>;
@@ -0,0 +1,74 @@
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'];
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
+ ];
33
+ const createBorderProp = (position, key) => {
34
+ const insert = position === 'center' ? '' : `-${position}`;
35
+ return camelCase(`border${insert}-${key}`);
36
+ };
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
+ }
49
+ }
50
+ return 'center';
51
+ };
52
+ export const BorderStyleSetter = observer(({ className, style }) => {
53
+ const field = useField();
54
+ const currentPosition = useMemo(() => observable({
55
+ 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
+ });
@@ -0,0 +1,70 @@
1
+ .dn-border-style-setter {
2
+ display: flex;
3
+ &-position {
4
+ margin-left: -10px;
5
+ }
6
+ &-input {
7
+ height: 110px;
8
+ display: flex;
9
+ flex-direction: column;
10
+ justify-content: space-between;
11
+ margin-bottom: 10px;
12
+ }
13
+ }
14
+
15
+ .border-style-solid-line {
16
+ position: relative;
17
+ width: 100%;
18
+ height: 100%;
19
+ display: block;
20
+
21
+ &::after {
22
+ position: absolute;
23
+ top: 50%;
24
+ left: 0;
25
+ display: block;
26
+ content: '';
27
+ height: 0;
28
+ width: 100%;
29
+ border-top: 2px solid currentColor;
30
+ transform: translateY(-50%);
31
+ }
32
+ }
33
+
34
+ .border-style-dashed-line {
35
+ position: relative;
36
+ width: 100%;
37
+ height: 100%;
38
+ display: block;
39
+
40
+ &::after {
41
+ position: absolute;
42
+ top: 50%;
43
+ left: 0;
44
+ display: block;
45
+ content: '';
46
+ height: 0;
47
+ width: 100%;
48
+ border-top: 2px dashed currentColor;
49
+ transform: translateY(-50%);
50
+ }
51
+ }
52
+
53
+ .border-style-dotted-line {
54
+ position: relative;
55
+ width: 100%;
56
+ height: 100%;
57
+ display: block;
58
+
59
+ &::after {
60
+ position: absolute;
61
+ top: 50%;
62
+ left: 0;
63
+ display: block;
64
+ content: '';
65
+ height: 0;
66
+ width: 100%;
67
+ border-top: 2px dotted currentColor;
68
+ transform: translateY(-50%);
69
+ }
70
+ }
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export interface IBoxShadowStyleSetterProps {
3
+ className?: string;
4
+ style?: React.CSSProperties;
5
+ value?: string;
6
+ onChange?: (value: string) => void;
7
+ }
8
+ export declare const BoxShadowStyleSetter: React.FC<IBoxShadowStyleSetterProps>;
@@ -0,0 +1,25 @@
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';
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
+ });
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export interface IMarginStyleSetterProps {
3
+ className?: string;
4
+ style?: React.CSSProperties;
5
+ labels?: React.ReactNode[];
6
+ value?: string;
7
+ onChange?: (value: string) => void;
8
+ }
9
+ export declare const BoxStyleSetter: React.FC<IMarginStyleSetterProps>;
@@ -0,0 +1,49 @@
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';
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\.+-]+))?)?)?/;
16
+ 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
+ ];
22
+ 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
+ });
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import './styles.less';
3
+ export interface ICollapseItemProps {
4
+ className?: string;
5
+ style?: React.CSSProperties;
6
+ defaultExpand?: boolean;
7
+ }
8
+ export declare const CollapseItem: React.FC<ICollapseItemProps>;
@@ -0,0 +1,16 @@
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';
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
+ });
@@ -0,0 +1,45 @@
1
+ .dn-collapse-item {
2
+ flex-wrap: wrap;
3
+
4
+ &-header {
5
+ display: flex;
6
+ align-items: center;
7
+ padding: 5px 20px;
8
+ margin: -1px -20px 0 -20px;
9
+ color: var(--dn-collapse-header-color);
10
+ border-top: 1px solid var(--dn-panel-border-color);
11
+ border-bottom: 1px solid var(--dn-panel-border-color);
12
+ background-color: var(--dn-panel-active-bg-color);
13
+ cursor: pointer;
14
+ transition: all 0.25s ease-in-out;
15
+ font-size: 13px;
16
+
17
+ &-expand {
18
+ margin-left: -13px;
19
+ transform: rotate(-90deg);
20
+ font-size: 12px;
21
+ transition: all 0.15s ease-in-out;
22
+ margin-right: 3px;
23
+ }
24
+ }
25
+
26
+ &-content {
27
+ display: none;
28
+ width: 100%;
29
+ padding-top: 4px;
30
+
31
+ & > div:last-child {
32
+ border-bottom: none !important;
33
+ }
34
+ }
35
+
36
+ &.expand {
37
+ .dn-collapse-item-content {
38
+ display: block;
39
+ }
40
+
41
+ .dn-collapse-item-header-expand {
42
+ transform: rotate(0);
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import './styles.less';
3
+ export interface IColorInputProps {
4
+ value?: string;
5
+ onChange?: (color: string) => void;
6
+ }
7
+ export declare const ColorInput: React.FC<IColorInputProps>;
@@ -0,0 +1,18 @@
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';
7
+ 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
+ };
@@ -0,0 +1,17 @@
1
+ @ant-prefix: ant;
2
+ .dn-color-input {
3
+ width: 100%;
4
+
5
+ .@{ant-prefix}-popover-inner-content {
6
+ padding: 0 !important;
7
+ user-select: none;
8
+ }
9
+
10
+ &-color-tips {
11
+ width: 20px;
12
+ height: 20px;
13
+ border-radius: 2px;
14
+ border: 1px solid var(--dn-color-border, #d9d9d9);
15
+ cursor: pointer;
16
+ }
17
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './styles.less';
3
+ export interface ICornerInputProps {
4
+ className?: string;
5
+ style?: React.CSSProperties;
6
+ value?: string;
7
+ onChange?: (value: string) => void;
8
+ }
9
+ export declare const CornerInput: React.FC<ICornerInputProps>;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect } from 'react';
3
+ import { usePrefix } from '@thienvu18/designable-react';
4
+ import cls from 'classnames';
5
+ import './styles.less';
6
+ export const CornerInput = (props) => {
7
+ const prefix = usePrefix('corner-input');
8
+ const [current, setCurrent] = useState(props.value);
9
+ useEffect(() => {
10
+ if (!props.value) {
11
+ setCurrent('all');
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", { className: cls(prefix, props.className), style: props.style, children: [_jsxs("div", { className: prefix + '-column', children: [_jsx("div", { ...createCellProps('topLeft'), children: "\u250F" }), _jsx("div", { ...createCellProps('bottomLeft'), children: "\u2517" })] }), _jsx("div", { className: prefix + '-column', children: _jsx("div", { ...createCellProps('all'), children: "\u254B" }) }), _jsxs("div", { className: prefix + '-column', children: [_jsx("div", { ...createCellProps('topRight'), children: "\u2513" }), _jsx("div", { ...createCellProps('bottomRight'), children: "\u251B" })] })] }));
22
+ };
@@ -0,0 +1,25 @@
1
+ .dn-corner-input {
2
+ display: flex;
3
+ &-column {
4
+ display: flex;
5
+ justify-content: center;
6
+ flex-direction: column;
7
+ align-items: center;
8
+ }
9
+
10
+ &-cell {
11
+ width: 26px;
12
+ height: 26px;
13
+ box-sizing: border-box;
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+ cursor: pointer;
18
+ border-radius: 3px;
19
+ color: rgba(0, 0, 0, 0.6);
20
+ margin: 5px;
21
+ &.active {
22
+ background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.2));
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './styles.less';
3
+ export interface IDisplayStyleSetterProps {
4
+ className?: string;
5
+ style?: React.CSSProperties;
6
+ value?: string;
7
+ onChange?: (value: string) => void;
8
+ }
9
+ export declare const DisplayStyleSetter: React.FC<IDisplayStyleSetterProps>;
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useField, Field, observer } from '@formily/react';
3
+ import { FormItem } from '@thienvu18/formily-antd-v6';
4
+ import { Radio } from 'antd';
5
+ import { usePrefix, IconWidget } from '@thienvu18/designable-react';
6
+ import { FlexStyleSetter } from '../FlexStyleSetter';
7
+ import cls from 'classnames';
8
+ import './styles.less';
9
+ export const DisplayStyleSetter = observer((props) => {
10
+ const field = useField();
11
+ const prefix = usePrefix('display-style-setter');
12
+ return (_jsxs(_Fragment, { children: [_jsx(FormItem.BaseItem, { label: field.title, className: cls(prefix, props.className), style: props.style, children: _jsx(Radio.Group, { className: prefix + '-radio', options: [
13
+ {
14
+ label: _jsx(IconWidget, { infer: "DisplayBlock", size: 16 }),
15
+ value: 'block',
16
+ },
17
+ {
18
+ label: _jsx(IconWidget, { infer: "DisplayInlineBlock", size: 16 }),
19
+ value: 'inline-block',
20
+ },
21
+ {
22
+ label: _jsx(IconWidget, { infer: "DisplayInline", size: 16 }),
23
+ value: 'inline',
24
+ },
25
+ {
26
+ label: _jsx(IconWidget, { infer: "DisplayFlex", size: 16 }),
27
+ value: 'flex',
28
+ },
29
+ ], value: props.value, onChange: (e) => {
30
+ props.onChange?.(e.target.value);
31
+ }, optionType: "button" }) }), _jsx(Field, { name: "flex", basePath: field.address.parent(), visible: false, reactions: (flexField) => {
32
+ flexField.visible = field.value === 'flex';
33
+ }, component: [FlexStyleSetter] })] }));
34
+ });