@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.
- package/LICENSE.md +20 -0
- package/README.md +1 -0
- package/esm/SchemaField.d.ts +1580 -0
- package/esm/SchemaField.js +42 -0
- package/esm/SettingsForm.d.ts +4 -0
- package/esm/SettingsForm.js +54 -0
- package/esm/components/BackgroundStyleSetter/index.d.ts +6 -0
- package/esm/components/BackgroundStyleSetter/index.js +43 -0
- package/esm/components/BorderRadiusStyleSetter/index.d.ts +6 -0
- package/esm/components/BorderRadiusStyleSetter/index.js +11 -0
- package/esm/components/BorderStyleSetter/index.d.ts +7 -0
- package/esm/components/BorderStyleSetter/index.js +74 -0
- package/esm/components/BorderStyleSetter/styles.less +70 -0
- package/esm/components/BoxShadowStyleSetter/index.d.ts +8 -0
- package/esm/components/BoxShadowStyleSetter/index.js +25 -0
- package/esm/components/BoxStyleSetter/index.d.ts +9 -0
- package/esm/components/BoxStyleSetter/index.js +49 -0
- package/esm/components/CollapseItem/index.d.ts +8 -0
- package/esm/components/CollapseItem/index.js +16 -0
- package/esm/components/CollapseItem/styles.less +45 -0
- package/esm/components/ColorInput/index.d.ts +7 -0
- package/esm/components/ColorInput/index.js +18 -0
- package/esm/components/ColorInput/styles.less +17 -0
- package/esm/components/CornerInput/index.d.ts +9 -0
- package/esm/components/CornerInput/index.js +22 -0
- package/esm/components/CornerInput/styles.less +25 -0
- package/esm/components/DisplayStyleSetter/index.d.ts +9 -0
- package/esm/components/DisplayStyleSetter/index.js +34 -0
- package/esm/components/DisplayStyleSetter/styles.less +15 -0
- package/esm/components/DrawerSetter/index.d.ts +8 -0
- package/esm/components/DrawerSetter/index.js +43 -0
- package/esm/components/DrawerSetter/styles.less +54 -0
- package/esm/components/FlexStyleSetter/index.d.ts +7 -0
- package/esm/components/FlexStyleSetter/index.js +111 -0
- package/esm/components/FlexStyleSetter/styles.less +23 -0
- package/esm/components/FoldItem/index.d.ts +7 -0
- package/esm/components/FoldItem/index.js +49 -0
- package/esm/components/FoldItem/styles.less +42 -0
- package/esm/components/FontStyleSetter/index.d.ts +6 -0
- package/esm/components/FontStyleSetter/index.js +88 -0
- package/esm/components/ImageInput/index.d.ts +9 -0
- package/esm/components/ImageInput/index.js +41 -0
- package/esm/components/ImageInput/styles.less +3 -0
- package/esm/components/InputItems/index.d.ts +23 -0
- package/esm/components/InputItems/index.js +18 -0
- package/esm/components/InputItems/styles.less +45 -0
- package/esm/components/MonacoInput/config.d.ts +1 -0
- package/esm/components/MonacoInput/config.js +39 -0
- package/esm/components/MonacoInput/format.d.ts +1 -0
- package/esm/components/MonacoInput/format.js +31 -0
- package/esm/components/MonacoInput/index.d.ts +16 -0
- package/esm/components/MonacoInput/index.js +216 -0
- package/esm/components/MonacoInput/styles.less +33 -0
- package/esm/components/MonacoInput/themes/chrome.d.ts +39 -0
- package/esm/components/MonacoInput/themes/chrome.js +106 -0
- package/esm/components/MonacoInput/themes/monokai.d.ts +31 -0
- package/esm/components/MonacoInput/themes/monokai.js +140 -0
- package/esm/components/PolyInput/index.d.ts +21 -0
- package/esm/components/PolyInput/index.js +70 -0
- package/esm/components/PolyInput/styles.less +31 -0
- package/esm/components/PositionInput/index.d.ts +9 -0
- package/esm/components/PositionInput/index.js +22 -0
- package/esm/components/PositionInput/styles.less +28 -0
- package/esm/components/SizeInput/index.d.ts +3 -0
- package/esm/components/SizeInput/index.js +53 -0
- package/esm/components/SizeInput/styles.less +23 -0
- package/esm/components/ValueInput/index.d.ts +2 -0
- package/esm/components/ValueInput/index.js +81 -0
- package/esm/components/ValueInput/styles.less +0 -0
- package/esm/components/index.d.ts +20 -0
- package/esm/components/index.js +20 -0
- package/esm/effects/index.d.ts +2 -0
- package/esm/effects/index.js +2 -0
- package/esm/effects/useLocales.d.ts +2 -0
- package/esm/effects/useLocales.js +63 -0
- package/esm/effects/useSnapshot.d.ts +2 -0
- package/esm/effects/useSnapshot.js +10 -0
- package/esm/index.d.ts +5 -0
- package/esm/index.js +5 -0
- package/esm/locales/en-US.d.ts +13 -0
- package/esm/locales/en-US.js +12 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +5 -0
- package/esm/locales/ko-KR.d.ts +13 -0
- package/esm/locales/ko-KR.js +12 -0
- package/esm/locales/zh-CN.d.ts +13 -0
- package/esm/locales/zh-CN.js +12 -0
- package/esm/registry.d.ts +2 -0
- package/esm/registry.js +13 -0
- package/esm/shared/context.d.ts +3 -0
- package/esm/shared/context.js +2 -0
- package/esm/shared/loadScript.d.ts +7 -0
- package/esm/shared/loadScript.js +29 -0
- package/esm/styles.less +121 -0
- package/esm/types.d.ts +10 -0
- package/esm/types.js +1 -0
- package/lib/SchemaField.d.ts +1580 -0
- package/lib/SchemaField.js +45 -0
- package/lib/SettingsForm.d.ts +4 -0
- package/lib/SettingsForm.js +60 -0
- package/lib/components/BackgroundStyleSetter/index.d.ts +6 -0
- package/lib/components/BackgroundStyleSetter/index.js +49 -0
- package/lib/components/BorderRadiusStyleSetter/index.d.ts +6 -0
- package/lib/components/BorderRadiusStyleSetter/index.js +15 -0
- package/lib/components/BorderStyleSetter/index.d.ts +7 -0
- package/lib/components/BorderStyleSetter/index.js +80 -0
- package/lib/components/BorderStyleSetter/styles.less +70 -0
- package/lib/components/BoxShadowStyleSetter/index.d.ts +8 -0
- package/lib/components/BoxShadowStyleSetter/index.js +31 -0
- package/lib/components/BoxStyleSetter/index.d.ts +9 -0
- package/lib/components/BoxStyleSetter/index.js +55 -0
- package/lib/components/CollapseItem/index.d.ts +8 -0
- package/lib/components/CollapseItem/index.js +22 -0
- package/lib/components/CollapseItem/styles.less +45 -0
- package/lib/components/ColorInput/index.d.ts +7 -0
- package/lib/components/ColorInput/index.js +22 -0
- package/lib/components/ColorInput/styles.less +17 -0
- package/lib/components/CornerInput/index.d.ts +9 -0
- package/lib/components/CornerInput/index.js +29 -0
- package/lib/components/CornerInput/styles.less +25 -0
- package/lib/components/DisplayStyleSetter/index.d.ts +9 -0
- package/lib/components/DisplayStyleSetter/index.js +40 -0
- package/lib/components/DisplayStyleSetter/styles.less +15 -0
- package/lib/components/DrawerSetter/index.d.ts +8 -0
- package/lib/components/DrawerSetter/index.js +49 -0
- package/lib/components/DrawerSetter/styles.less +54 -0
- package/lib/components/FlexStyleSetter/index.d.ts +7 -0
- package/lib/components/FlexStyleSetter/index.js +117 -0
- package/lib/components/FlexStyleSetter/styles.less +23 -0
- package/lib/components/FoldItem/index.d.ts +7 -0
- package/lib/components/FoldItem/index.js +78 -0
- package/lib/components/FoldItem/styles.less +42 -0
- package/lib/components/FontStyleSetter/index.d.ts +6 -0
- package/lib/components/FontStyleSetter/index.js +94 -0
- package/lib/components/ImageInput/index.d.ts +9 -0
- package/lib/components/ImageInput/index.js +49 -0
- package/lib/components/ImageInput/styles.less +3 -0
- package/lib/components/InputItems/index.d.ts +23 -0
- package/lib/components/InputItems/index.js +48 -0
- package/lib/components/InputItems/styles.less +45 -0
- package/lib/components/MonacoInput/config.d.ts +1 -0
- package/lib/components/MonacoInput/config.js +46 -0
- package/lib/components/MonacoInput/format.d.ts +1 -0
- package/lib/components/MonacoInput/format.js +35 -0
- package/lib/components/MonacoInput/index.d.ts +16 -0
- package/lib/components/MonacoInput/index.js +246 -0
- package/lib/components/MonacoInput/styles.less +33 -0
- package/lib/components/MonacoInput/themes/chrome.d.ts +39 -0
- package/lib/components/MonacoInput/themes/chrome.js +108 -0
- package/lib/components/MonacoInput/themes/monokai.d.ts +31 -0
- package/lib/components/MonacoInput/themes/monokai.js +142 -0
- package/lib/components/PolyInput/index.d.ts +21 -0
- package/lib/components/PolyInput/index.js +100 -0
- package/lib/components/PolyInput/styles.less +31 -0
- package/lib/components/PositionInput/index.d.ts +9 -0
- package/lib/components/PositionInput/index.js +29 -0
- package/lib/components/PositionInput/styles.less +28 -0
- package/lib/components/SizeInput/index.d.ts +3 -0
- package/lib/components/SizeInput/index.js +56 -0
- package/lib/components/SizeInput/styles.less +23 -0
- package/lib/components/ValueInput/index.d.ts +2 -0
- package/lib/components/ValueInput/index.js +84 -0
- package/lib/components/ValueInput/styles.less +0 -0
- package/lib/components/index.d.ts +20 -0
- package/lib/components/index.js +36 -0
- package/lib/effects/index.d.ts +2 -0
- package/lib/effects/index.js +18 -0
- package/lib/effects/useLocales.d.ts +2 -0
- package/lib/effects/useLocales.js +67 -0
- package/lib/effects/useSnapshot.d.ts +2 -0
- package/lib/effects/useSnapshot.js +14 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +21 -0
- package/lib/locales/en-US.d.ts +13 -0
- package/lib/locales/en-US.js +14 -0
- package/lib/locales/index.d.ts +1 -0
- package/lib/locales/index.js +10 -0
- package/lib/locales/ko-KR.d.ts +13 -0
- package/lib/locales/ko-KR.js +14 -0
- package/lib/locales/zh-CN.d.ts +13 -0
- package/lib/locales/zh-CN.js +14 -0
- package/lib/registry.d.ts +2 -0
- package/lib/registry.js +21 -0
- package/lib/shared/context.d.ts +3 -0
- package/lib/shared/context.js +5 -0
- package/lib/shared/loadScript.d.ts +7 -0
- package/lib/shared/loadScript.js +33 -0
- package/lib/styles.less +121 -0
- package/lib/types.d.ts +10 -0
- package/lib/types.js +2 -0
- package/package.json +71 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaField = void 0;
|
|
4
|
+
const react_1 = require("@formily/react");
|
|
5
|
+
const formily_antd_v6_1 = require("@thienvu18/formily-antd-v6");
|
|
6
|
+
const antd_1 = require("antd");
|
|
7
|
+
const components_1 = require("./components");
|
|
8
|
+
exports.SchemaField = (0, react_1.createSchemaField)({
|
|
9
|
+
components: {
|
|
10
|
+
FormItem: formily_antd_v6_1.FormItem,
|
|
11
|
+
CollapseItem: components_1.CollapseItem,
|
|
12
|
+
Input: formily_antd_v6_1.Input,
|
|
13
|
+
ValueInput: components_1.ValueInput,
|
|
14
|
+
SizeInput: components_1.SizeInput,
|
|
15
|
+
ColorInput: components_1.ColorInput,
|
|
16
|
+
ImageInput: components_1.ImageInput,
|
|
17
|
+
MonacoInput: components_1.MonacoInput,
|
|
18
|
+
PositionInput: components_1.PositionInput,
|
|
19
|
+
CornerInput: components_1.CornerInput,
|
|
20
|
+
BackgroundImageInput: components_1.BackgroundImageInput,
|
|
21
|
+
BackgroundStyleSetter: components_1.BackgroundStyleSetter,
|
|
22
|
+
BoxStyleSetter: components_1.BoxStyleSetter,
|
|
23
|
+
BorderStyleSetter: components_1.BorderStyleSetter,
|
|
24
|
+
BorderRadiusStyleSetter: components_1.BorderRadiusStyleSetter,
|
|
25
|
+
DisplayStyleSetter: components_1.DisplayStyleSetter,
|
|
26
|
+
BoxShadowStyleSetter: components_1.BoxShadowStyleSetter,
|
|
27
|
+
FlexStyleSetter: components_1.FlexStyleSetter,
|
|
28
|
+
FontStyleSetter: components_1.FontStyleSetter,
|
|
29
|
+
DrawerSetter: components_1.DrawerSetter,
|
|
30
|
+
NumberPicker: formily_antd_v6_1.NumberPicker,
|
|
31
|
+
DatePicker: formily_antd_v6_1.DatePicker,
|
|
32
|
+
TimePicker: formily_antd_v6_1.TimePicker,
|
|
33
|
+
Select: formily_antd_v6_1.Select,
|
|
34
|
+
Radio: formily_antd_v6_1.Radio,
|
|
35
|
+
Slider: antd_1.Slider,
|
|
36
|
+
Switch: formily_antd_v6_1.Switch,
|
|
37
|
+
Space: formily_antd_v6_1.Space,
|
|
38
|
+
ArrayItems: formily_antd_v6_1.ArrayItems,
|
|
39
|
+
ArrayTable: formily_antd_v6_1.ArrayTable,
|
|
40
|
+
FormCollapse: formily_antd_v6_1.FormCollapse,
|
|
41
|
+
FormGrid: formily_antd_v6_1.FormGrid,
|
|
42
|
+
FormLayout: formily_antd_v6_1.FormLayout,
|
|
43
|
+
FormTab: formily_antd_v6_1.FormTab,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SettingsForm = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const core_1 = require("@formily/core");
|
|
10
|
+
const formily_antd_v6_1 = require("@thienvu18/formily-antd-v6");
|
|
11
|
+
const react_2 = require("@formily/react");
|
|
12
|
+
const designable_shared_1 = require("@thienvu18/designable-shared");
|
|
13
|
+
const designable_react_1 = require("@thienvu18/designable-react");
|
|
14
|
+
const SchemaField_1 = require("./SchemaField");
|
|
15
|
+
const context_1 = require("./shared/context");
|
|
16
|
+
const effects_1 = require("./effects");
|
|
17
|
+
const antd_1 = require("antd");
|
|
18
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
19
|
+
require("./styles.less");
|
|
20
|
+
const GlobalState = {
|
|
21
|
+
idleRequest: null,
|
|
22
|
+
};
|
|
23
|
+
exports.SettingsForm = (0, react_2.observer)((props) => {
|
|
24
|
+
const workbench = (0, designable_react_1.useWorkbench)();
|
|
25
|
+
const currentWorkspace = workbench?.activeWorkspace || workbench?.currentWorkspace;
|
|
26
|
+
const currentWorkspaceId = currentWorkspace?.id;
|
|
27
|
+
const operation = (0, designable_react_1.useOperation)(currentWorkspaceId);
|
|
28
|
+
const node = (0, designable_react_1.useSelectedNode)(currentWorkspaceId);
|
|
29
|
+
const selected = (0, designable_react_1.useSelected)(currentWorkspaceId);
|
|
30
|
+
const prefix = (0, designable_react_1.usePrefix)('settings-form');
|
|
31
|
+
const schema = node?.designerProps?.propsSchema;
|
|
32
|
+
const isEmpty = !(node &&
|
|
33
|
+
node.designerProps?.propsSchema &&
|
|
34
|
+
selected.length === 1);
|
|
35
|
+
const form = (0, react_1.useMemo)(() => {
|
|
36
|
+
return (0, core_1.createForm)({
|
|
37
|
+
initialValues: node?.designerProps?.defaultProps,
|
|
38
|
+
values: node?.props,
|
|
39
|
+
effects(form) {
|
|
40
|
+
(0, effects_1.useLocales)(node);
|
|
41
|
+
(0, effects_1.useSnapshot)(operation);
|
|
42
|
+
props.effects?.(form);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}, [node, node?.props, schema, operation, isEmpty]);
|
|
46
|
+
const render = () => {
|
|
47
|
+
if (!isEmpty) {
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(prefix, props.className), style: props.style, children: (0, jsx_runtime_1.jsx)(context_1.SettingsFormContext.Provider, { value: props, children: (0, jsx_runtime_1.jsx)(formily_antd_v6_1.Form, { form: form, colon: false, labelWidth: 120, labelAlign: "left", wrapperAlign: "right", feedbackLayout: "none", tooltipLayout: "text", children: (0, jsx_runtime_1.jsx)(SchemaField_1.SchemaField, { schema: schema, components: props.components, scope: { $node: node, ...props.scope } }) }) }) }, node.id));
|
|
49
|
+
}
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: prefix + '-empty', children: (0, jsx_runtime_1.jsx)(antd_1.Empty, {}) }));
|
|
51
|
+
};
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(designable_react_1.IconWidget.Provider, { tooltip: true, children: (0, jsx_runtime_1.jsxs)("div", { className: prefix + '-wrapper', children: [!isEmpty && (0, jsx_runtime_1.jsx)(designable_react_1.NodePathWidget, { workspaceId: currentWorkspaceId }), (0, jsx_runtime_1.jsx)("div", { className: prefix + '-content', children: render() })] }) }));
|
|
53
|
+
}, {
|
|
54
|
+
scheduler: (update) => {
|
|
55
|
+
(0, designable_shared_1.cancelIdle)(GlobalState.idleRequest);
|
|
56
|
+
GlobalState.idleRequest = (0, designable_shared_1.requestIdle)(update, {
|
|
57
|
+
timeout: 500,
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BackgroundStyleSetter = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("@formily/react");
|
|
9
|
+
const designable_react_1 = require("@thienvu18/designable-react");
|
|
10
|
+
const formily_antd_v6_1 = require("@thienvu18/formily-antd-v6");
|
|
11
|
+
const FoldItem_1 = require("../FoldItem");
|
|
12
|
+
const ColorInput_1 = require("../ColorInput");
|
|
13
|
+
const SizeInput_1 = require("../SizeInput");
|
|
14
|
+
const ImageInput_1 = require("../ImageInput");
|
|
15
|
+
const InputItems_1 = require("../InputItems");
|
|
16
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
17
|
+
exports.BackgroundStyleSetter = (0, react_1.observer)((props) => {
|
|
18
|
+
const field = (0, react_1.useField)();
|
|
19
|
+
const prefix = (0, designable_react_1.usePrefix)('background-style-setter');
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)(FoldItem_1.FoldItem, { className: (0, classnames_1.default)(prefix, props.className), label: field.title, children: [(0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Base, { children: (0, jsx_runtime_1.jsx)(react_1.Field, { name: "backgroundColor", basePath: field.address.parent(), component: [ColorInput_1.ColorInput] }) }), (0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Extra, { children: (0, jsx_runtime_1.jsxs)(InputItems_1.InputItems, { children: [(0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: "Image", children: (0, jsx_runtime_1.jsx)(react_1.Field, { name: "backgroundImage", basePath: field.address.parent(), component: [ImageInput_1.BackgroundImageInput] }) }), (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: "ImageSize", width: "50%", children: (0, jsx_runtime_1.jsx)(react_1.Field, { name: "backgroundSize", basePath: field.address.parent(), component: [SizeInput_1.BackgroundSizeInput] }) }), (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: "Repeat", width: "50%", children: (0, jsx_runtime_1.jsx)(react_1.Field, { name: "backgroundRepeat", basePath: field.address.parent(), component: [
|
|
21
|
+
formily_antd_v6_1.Select,
|
|
22
|
+
{ style: { width: '100%' }, placeholder: 'Repeat' },
|
|
23
|
+
], dataSource: [
|
|
24
|
+
{
|
|
25
|
+
label: 'No Repeat',
|
|
26
|
+
value: 'no-repeat',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: 'Repeat',
|
|
30
|
+
value: 'repeat',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: 'Repeat X',
|
|
34
|
+
value: 'repeat-x',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: 'Repeat Y',
|
|
38
|
+
value: 'repeat-y',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'Space',
|
|
42
|
+
value: 'space',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: 'Round',
|
|
46
|
+
value: 'round',
|
|
47
|
+
},
|
|
48
|
+
] }) }), (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: "Position", children: (0, jsx_runtime_1.jsx)(react_1.Field, { name: "backgroundPosition", basePath: field.address.parent(), component: [formily_antd_v6_1.Input, { placeholder: 'center center' }] }) })] }) })] }));
|
|
49
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BorderRadiusStyleSetter = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const designable_react_1 = require("@thienvu18/designable-react");
|
|
6
|
+
const BoxStyleSetter_1 = require("../BoxStyleSetter");
|
|
7
|
+
const BorderRadiusStyleSetter = (props) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(BoxStyleSetter_1.BoxStyleSetter, { ...props, labels: [
|
|
9
|
+
(0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, { infer: "TopLeft", size: 16 }, "1"),
|
|
10
|
+
(0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, { infer: "TopRight", size: 16 }, "2"),
|
|
11
|
+
(0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, { infer: "BottomRight", size: 16 }, "3"),
|
|
12
|
+
(0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, { infer: "BottomLeft", size: 16 }, "4"),
|
|
13
|
+
] }));
|
|
14
|
+
};
|
|
15
|
+
exports.BorderRadiusStyleSetter = BorderRadiusStyleSetter;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BorderStyleSetter = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const designable_react_1 = require("@thienvu18/designable-react");
|
|
10
|
+
const shared_1 = require("@formily/shared");
|
|
11
|
+
const formily_antd_v6_1 = require("@thienvu18/formily-antd-v6");
|
|
12
|
+
const reactive_1 = require("@formily/reactive");
|
|
13
|
+
const react_2 = require("@formily/react");
|
|
14
|
+
const FoldItem_1 = require("../FoldItem");
|
|
15
|
+
const ColorInput_1 = require("../ColorInput");
|
|
16
|
+
const SizeInput_1 = require("../SizeInput");
|
|
17
|
+
const PositionInput_1 = require("../PositionInput");
|
|
18
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
19
|
+
require("./styles.less");
|
|
20
|
+
const Positions = ['center', 'top', 'right', 'bottom', 'left'];
|
|
21
|
+
const BorderStyleOptions = [
|
|
22
|
+
{
|
|
23
|
+
label: 'None',
|
|
24
|
+
value: 'none',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: (0, jsx_runtime_1.jsx)("span", { className: "border-style-solid-line" }),
|
|
28
|
+
value: 'solid',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: (0, jsx_runtime_1.jsx)("span", { className: "border-style-dashed-line" }),
|
|
32
|
+
value: 'dashed',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: (0, jsx_runtime_1.jsx)("span", { className: "border-style-dotted-line" }),
|
|
36
|
+
value: 'dotted',
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
const createBorderProp = (position, key) => {
|
|
40
|
+
const insert = position === 'center' ? '' : `-${position}`;
|
|
41
|
+
return (0, shared_1.camelCase)(`border${insert}-${key}`);
|
|
42
|
+
};
|
|
43
|
+
const parseInitPosition = (field) => {
|
|
44
|
+
const basePath = field.address.parent();
|
|
45
|
+
for (let i = 0; i < Positions.length; i++) {
|
|
46
|
+
const position = Positions[i];
|
|
47
|
+
const stylePath = `${basePath}.${createBorderProp(position, 'style')}`;
|
|
48
|
+
const widthPath = `${basePath}.${createBorderProp(position, 'width')}`;
|
|
49
|
+
const colorPath = `${basePath}.${createBorderProp(position, 'color')}`;
|
|
50
|
+
if (field.query(stylePath).value() ||
|
|
51
|
+
field.query(widthPath).value() ||
|
|
52
|
+
field.query(colorPath).value()) {
|
|
53
|
+
return position;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return 'center';
|
|
57
|
+
};
|
|
58
|
+
exports.BorderStyleSetter = (0, react_2.observer)(({ className, style }) => {
|
|
59
|
+
const field = (0, react_2.useField)();
|
|
60
|
+
const currentPosition = (0, react_1.useMemo)(() => (0, reactive_1.observable)({
|
|
61
|
+
value: parseInitPosition(field),
|
|
62
|
+
}), [field.value]);
|
|
63
|
+
const prefix = (0, designable_react_1.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 ((0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem, { label: field.title, children: (0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Extra, { children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(prefix, className), style: style, children: [(0, jsx_runtime_1.jsx)("div", { className: prefix + '-position', children: (0, jsx_runtime_1.jsx)(PositionInput_1.PositionInput, { value: currentPosition.value, onChange: (value) => {
|
|
76
|
+
currentPosition.value = value;
|
|
77
|
+
} }) }), (0, jsx_runtime_1.jsx)("div", { className: prefix + '-input', children: Positions.map((position, key) => {
|
|
78
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_2.Field, { name: createBorderProp(position, 'style'), basePath: field.address.parent(), dataSource: BorderStyleOptions, reactions: createReaction(position), component: [formily_antd_v6_1.Select, { placeholder: 'Please Select' }] }), (0, jsx_runtime_1.jsx)(react_2.Field, { name: createBorderProp(position, 'width'), basePath: field.address.parent(), reactions: createReaction(position), component: [SizeInput_1.SizeInput, { exclude: ['auto'] }] }), (0, jsx_runtime_1.jsx)(react_2.Field, { name: createBorderProp(position, 'color'), basePath: field.address.parent(), reactions: createReaction(position), component: [ColorInput_1.ColorInput] })] }, key));
|
|
79
|
+
}) })] }) }) }));
|
|
80
|
+
});
|
|
@@ -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,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BoxShadowStyleSetter = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const designable_react_1 = require("@thienvu18/designable-react");
|
|
9
|
+
const react_1 = require("@formily/react");
|
|
10
|
+
const FoldItem_1 = require("../FoldItem");
|
|
11
|
+
const ColorInput_1 = require("../ColorInput");
|
|
12
|
+
const SizeInput_1 = require("../SizeInput");
|
|
13
|
+
const InputItems_1 = require("../InputItems");
|
|
14
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
15
|
+
exports.BoxShadowStyleSetter = (0, react_1.observer)((props) => {
|
|
16
|
+
const field = (0, react_1.useField)();
|
|
17
|
+
const prefix = (0, designable_react_1.usePrefix)('shadow-style-setter');
|
|
18
|
+
const createBoxShadowConnector = (position) => {
|
|
19
|
+
const splited = String(props.value || '')
|
|
20
|
+
.trim()
|
|
21
|
+
.split(' ');
|
|
22
|
+
return {
|
|
23
|
+
value: splited[position],
|
|
24
|
+
onChange: (value) => {
|
|
25
|
+
splited[position] = value;
|
|
26
|
+
props.onChange?.(`${splited[0] || ''} ${splited[1] || ''} ${splited[2] || ''} ${splited[3] || ''} ${splited[4] || ''}`);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
return ((0, jsx_runtime_1.jsxs)(FoldItem_1.FoldItem, { className: (0, classnames_1.default)(prefix, props.className), style: props.style, label: field.title, children: [(0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Base, { children: (0, jsx_runtime_1.jsx)(ColorInput_1.ColorInput, { ...createBoxShadowConnector(4) }) }), (0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Extra, { children: (0, jsx_runtime_1.jsxs)(InputItems_1.InputItems, { width: "50%", children: [(0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: "AxisX", children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, { exclude: ['inherit', 'auto'], ...createBoxShadowConnector(0) }) }), (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: "AxisY", children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, { exclude: ['inherit', 'auto'], ...createBoxShadowConnector(1) }) }), (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: "Blur", children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, { exclude: ['inherit', 'auto'], ...createBoxShadowConnector(2) }) }), (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: "Shadow", children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, { exclude: ['inherit', 'auto'], ...createBoxShadowConnector(3) }) })] }) })] }));
|
|
31
|
+
});
|
|
@@ -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,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BoxStyleSetter = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("@formily/react");
|
|
9
|
+
const designable_react_1 = require("@thienvu18/designable-react");
|
|
10
|
+
const FoldItem_1 = require("../FoldItem");
|
|
11
|
+
const SizeInput_1 = require("../SizeInput");
|
|
12
|
+
const InputItems_1 = require("../InputItems");
|
|
13
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
14
|
+
const PositionMap = {
|
|
15
|
+
top: 1,
|
|
16
|
+
right: 2,
|
|
17
|
+
bottom: 3,
|
|
18
|
+
left: 4,
|
|
19
|
+
all: 1,
|
|
20
|
+
};
|
|
21
|
+
const BoxRex = /([\d\.]+[^\d\s\.+-]+)(?:\s+([\d\.]+[^\d\s\.+-]+)(?:\s+([\d\.]+[^\d\s\.+-]+)(?:\s+([\d\.]+[^\d\s\.+-]+))?)?)?/;
|
|
22
|
+
const defaultLabels = [
|
|
23
|
+
(0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, { infer: "Top", size: 16 }, "1"),
|
|
24
|
+
(0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, { infer: "Right", size: 16 }, "2"),
|
|
25
|
+
(0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, { infer: "Bottom", size: 16 }, "3"),
|
|
26
|
+
(0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, { infer: "Left", size: 16 }, "4"),
|
|
27
|
+
];
|
|
28
|
+
exports.BoxStyleSetter = (0, react_1.observer)((props) => {
|
|
29
|
+
const { labels = defaultLabels, className } = props;
|
|
30
|
+
const field = (0, react_1.useField)();
|
|
31
|
+
const prefix = (0, designable_react_1.usePrefix)('box-style-setter');
|
|
32
|
+
const createPositionHandler = (position, setterProps) => {
|
|
33
|
+
const matched = String(setterProps.value).match(BoxRex) || [];
|
|
34
|
+
const value = matched[PositionMap[position]];
|
|
35
|
+
const v1 = matched[1];
|
|
36
|
+
const v2 = matched[2];
|
|
37
|
+
const v3 = matched[3];
|
|
38
|
+
const v4 = matched[4];
|
|
39
|
+
const allEqualls = v1 === v2 && v2 === v3 && v3 === v4;
|
|
40
|
+
return {
|
|
41
|
+
...setterProps,
|
|
42
|
+
value: position === 'all' ? (allEqualls ? v1 : undefined) : value,
|
|
43
|
+
onChange(val) {
|
|
44
|
+
if (position === 'all') {
|
|
45
|
+
setterProps.onChange?.(`${val || '0px'} ${val || '0px'} ${val || '0px'} ${val || '0px'}`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
matched[PositionMap[position]] = val;
|
|
49
|
+
setterProps.onChange?.(`${matched[1] || '0px'} ${matched[2] || '0px'} ${matched[3] || '0px'} ${matched[4] || '0px'}`);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)(FoldItem_1.FoldItem, { className: (0, classnames_1.default)(prefix, className), label: field.title, children: [(0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Base, { children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, { ...createPositionHandler('all', props), exclude: ['inherit', 'auto'] }) }), (0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Extra, { children: (0, jsx_runtime_1.jsxs)(InputItems_1.InputItems, { width: "50%", children: [(0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: labels[0], children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, { ...createPositionHandler('top', props), exclude: ['inherit', 'auto'] }) }), (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: labels[1], children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, { ...createPositionHandler('right', props), exclude: ['inherit', 'auto'] }) }), (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: labels[2], children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, { ...createPositionHandler('bottom', props), exclude: ['inherit', 'auto'] }) }), (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, { icon: labels[3], children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, { ...createPositionHandler('left', props), exclude: ['inherit', 'auto'] }) })] }) })] }));
|
|
55
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CollapseItem = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const react_2 = require("@formily/react");
|
|
10
|
+
const designable_react_1 = require("@thienvu18/designable-react");
|
|
11
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
12
|
+
require("./styles.less");
|
|
13
|
+
exports.CollapseItem = (0, react_2.observer)((props) => {
|
|
14
|
+
const prefix = (0, designable_react_1.usePrefix)('collapse-item');
|
|
15
|
+
const field = (0, react_2.useField)();
|
|
16
|
+
const [expand, setExpand] = (0, react_1.useState)(props.defaultExpand ?? true);
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(prefix, props.className, { expand }), style: props.style, children: [(0, jsx_runtime_1.jsxs)("div", { className: prefix + '-header', onClick: (e) => {
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
setExpand(!expand);
|
|
21
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { className: prefix + '-header-expand', children: (0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, { infer: "Expand", size: 10 }) }), (0, jsx_runtime_1.jsx)("div", { className: prefix + '-header-content', children: field.title })] }), (0, jsx_runtime_1.jsx)("div", { className: prefix + '-content', children: props.children })] }));
|
|
22
|
+
});
|
|
@@ -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,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ColorInput = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const antd_1 = require("antd");
|
|
7
|
+
const designable_react_1 = require("@thienvu18/designable-react");
|
|
8
|
+
const react_color_1 = require("react-color");
|
|
9
|
+
require("./styles.less");
|
|
10
|
+
const ColorInput = (props) => {
|
|
11
|
+
const container = (0, react_1.useRef)(null);
|
|
12
|
+
const prefix = (0, designable_react_1.usePrefix)('color-input');
|
|
13
|
+
const color = props.value;
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: container, className: prefix, children: (0, jsx_runtime_1.jsx)(antd_1.Input, { value: props.value, onChange: (e) => {
|
|
15
|
+
props.onChange?.(e.target.value);
|
|
16
|
+
}, placeholder: "Color", prefix: (0, jsx_runtime_1.jsx)(antd_1.Popover, { autoAdjustOverflow: true, trigger: "click", styles: { content: { padding: 0 } }, getPopupContainer: () => container.current || document.body, content: (0, jsx_runtime_1.jsx)(react_color_1.SketchPicker, { color: color, onChange: ({ rgb }) => {
|
|
17
|
+
props.onChange?.(`rgba(${rgb.r},${rgb.g},${rgb.b},${rgb.a})`);
|
|
18
|
+
} }), children: (0, jsx_runtime_1.jsx)("div", { className: prefix + '-color-tips', style: {
|
|
19
|
+
backgroundColor: color,
|
|
20
|
+
} }) }) }) }));
|
|
21
|
+
};
|
|
22
|
+
exports.ColorInput = ColorInput;
|
|
@@ -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,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CornerInput = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const designable_react_1 = require("@thienvu18/designable-react");
|
|
10
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
11
|
+
require("./styles.less");
|
|
12
|
+
const CornerInput = (props) => {
|
|
13
|
+
const prefix = (0, designable_react_1.usePrefix)('corner-input');
|
|
14
|
+
const [current, setCurrent] = (0, react_1.useState)(props.value);
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
if (!props.value) {
|
|
17
|
+
setCurrent('all');
|
|
18
|
+
}
|
|
19
|
+
}, [props.value]);
|
|
20
|
+
const createCellProps = (type) => ({
|
|
21
|
+
className: (0, classnames_1.default)(prefix + '-cell', { active: current === type }),
|
|
22
|
+
onClick() {
|
|
23
|
+
setCurrent(type);
|
|
24
|
+
props.onChange?.(type);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(prefix, props.className), style: props.style, children: [(0, jsx_runtime_1.jsxs)("div", { className: prefix + '-column', children: [(0, jsx_runtime_1.jsx)("div", { ...createCellProps('topLeft'), children: "\u250F" }), (0, jsx_runtime_1.jsx)("div", { ...createCellProps('bottomLeft'), children: "\u2517" })] }), (0, jsx_runtime_1.jsx)("div", { className: prefix + '-column', children: (0, jsx_runtime_1.jsx)("div", { ...createCellProps('all'), children: "\u254B" }) }), (0, jsx_runtime_1.jsxs)("div", { className: prefix + '-column', children: [(0, jsx_runtime_1.jsx)("div", { ...createCellProps('topRight'), children: "\u2513" }), (0, jsx_runtime_1.jsx)("div", { ...createCellProps('bottomRight'), children: "\u251B" })] })] }));
|
|
28
|
+
};
|
|
29
|
+
exports.CornerInput = CornerInput;
|