@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,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ base: 'vs-dark',
5
+ inherit: true,
6
+ rules: [
7
+ {
8
+ foreground: '75715e',
9
+ token: 'comment',
10
+ },
11
+ {
12
+ foreground: 'e6db74',
13
+ token: 'string',
14
+ },
15
+ {
16
+ foreground: 'ae81ff',
17
+ token: 'constant.numeric',
18
+ },
19
+ {
20
+ foreground: 'ae81ff',
21
+ token: 'constant.language',
22
+ },
23
+ {
24
+ foreground: 'ae81ff',
25
+ token: 'constant.character',
26
+ },
27
+ {
28
+ foreground: 'ae81ff',
29
+ token: 'constant.other',
30
+ },
31
+ {
32
+ foreground: 'f92672',
33
+ token: 'keyword',
34
+ },
35
+ {
36
+ foreground: 'f92672',
37
+ token: 'storage',
38
+ },
39
+ {
40
+ foreground: '66d9ef',
41
+ fontStyle: 'italic',
42
+ token: 'storage.type',
43
+ },
44
+ {
45
+ foreground: 'a6e22e',
46
+ fontStyle: 'underline',
47
+ token: 'entity.name.class',
48
+ },
49
+ {
50
+ foreground: 'a6e22e',
51
+ fontStyle: 'italic underline',
52
+ token: 'entity.other.inherited-class',
53
+ },
54
+ {
55
+ foreground: 'a6e22e',
56
+ token: 'entity.name.function',
57
+ },
58
+ {
59
+ foreground: 'fd971f',
60
+ fontStyle: 'italic',
61
+ token: 'variable.parameter',
62
+ },
63
+ {
64
+ foreground: 'f92672',
65
+ token: 'entity.name.tag',
66
+ },
67
+ {
68
+ foreground: 'a6e22e',
69
+ token: 'entity.other.attribute-name',
70
+ },
71
+ {
72
+ foreground: '66d9ef',
73
+ token: 'support.function',
74
+ },
75
+ {
76
+ foreground: '66d9ef',
77
+ token: 'support.constant',
78
+ },
79
+ {
80
+ foreground: '66d9ef',
81
+ fontStyle: 'italic',
82
+ token: 'support.type',
83
+ },
84
+ {
85
+ foreground: '66d9ef',
86
+ fontStyle: 'italic',
87
+ token: 'support.class',
88
+ },
89
+ {
90
+ foreground: 'f8f8f0',
91
+ background: 'f92672',
92
+ token: 'invalid',
93
+ },
94
+ {
95
+ foreground: 'f8f8f0',
96
+ background: 'ae81ff',
97
+ token: 'invalid.deprecated',
98
+ },
99
+ {
100
+ foreground: 'cfcfc2',
101
+ token: 'meta.structure.dictionary.json string.quoted.double.json',
102
+ },
103
+ {
104
+ foreground: '75715e',
105
+ token: 'meta.diff',
106
+ },
107
+ {
108
+ foreground: '75715e',
109
+ token: 'meta.diff.header',
110
+ },
111
+ {
112
+ foreground: 'f92672',
113
+ token: 'markup.deleted',
114
+ },
115
+ {
116
+ foreground: 'a6e22e',
117
+ token: 'markup.inserted',
118
+ },
119
+ {
120
+ foreground: 'e6db74',
121
+ token: 'markup.changed',
122
+ },
123
+ {
124
+ foreground: 'ae81ffa0',
125
+ token: 'constant.numeric.line-number.find-in-files - match',
126
+ },
127
+ {
128
+ foreground: 'e6db74',
129
+ token: 'entity.name.filename.find-in-files',
130
+ },
131
+ ],
132
+ colors: {
133
+ 'editor.foreground': '#F8F8F2',
134
+ 'editor.background': '#222222',
135
+ 'editor.selectionBackground': '#49483E',
136
+ 'editor.lineHighlightBackground': '#3E3D32',
137
+ 'editorCursor.foreground': '#F8F8F0',
138
+ 'editorWhitespace.foreground': '#3B3A32',
139
+ 'editorIndentGuide.activeBackground': '#9D550FB0',
140
+ 'editor.selectionHighlightBorder': '#222218',
141
+ },
142
+ };
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import './styles.less';
3
+ export interface IInput {
4
+ style?: React.CSSProperties;
5
+ className?: string;
6
+ value: any;
7
+ onChange: (value: any) => void;
8
+ exclude?: string[];
9
+ include?: string[];
10
+ }
11
+ export interface IPolyType {
12
+ type: string;
13
+ title?: string;
14
+ icon?: string;
15
+ component?: any;
16
+ checker: (value: any) => boolean;
17
+ toInputValue?: (value: any) => any;
18
+ toChangeValue?: (value: any) => any;
19
+ }
20
+ export type PolyTypes = IPolyType[];
21
+ export declare function createPolyInput(polyTypes?: PolyTypes): React.FC<IInput>;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.createPolyInput = void 0;
30
+ const jsx_runtime_1 = require("react/jsx-runtime");
31
+ const react_1 = __importStar(require("react"));
32
+ const antd_1 = require("antd");
33
+ const designable_react_1 = require("@thienvu18/designable-react");
34
+ const classnames_1 = __importDefault(require("classnames"));
35
+ require("./styles.less");
36
+ const isValid = (val) => val !== undefined && val !== null;
37
+ const getEventValue = (event) => {
38
+ if (event?.target) {
39
+ if (isValid(event.target.value))
40
+ return event.target.value;
41
+ if (isValid(event.target.checked))
42
+ return event.target.checked;
43
+ return;
44
+ }
45
+ return event;
46
+ };
47
+ const createTypes = (types, exclude, include) => {
48
+ return types.filter(({ type }) => {
49
+ if (Array.isArray(include) && include.length) {
50
+ return include.includes(type);
51
+ }
52
+ if (Array.isArray(exclude) && exclude.length) {
53
+ return !exclude.includes(type);
54
+ }
55
+ return true;
56
+ });
57
+ };
58
+ function createPolyInput(polyTypes = []) {
59
+ return ({ className, style, value, onChange, exclude, include, ...props }) => {
60
+ const prefix = (0, designable_react_1.usePrefix)('poly-input');
61
+ const types = createTypes(polyTypes, exclude, include);
62
+ const [current, setCurrent] = (0, react_1.useState)(types[0]?.type);
63
+ const type = types?.find(({ type }) => type === current);
64
+ const component = type?.component;
65
+ const typesValue = (0, react_1.useRef)({});
66
+ (0, react_1.useEffect)(() => {
67
+ types?.forEach(({ checker, type }) => {
68
+ if (checker(value)) {
69
+ setCurrent(type);
70
+ }
71
+ });
72
+ }, [value]);
73
+ const getNextType = () => {
74
+ const currentIndex = types?.findIndex(({ type }) => type === current);
75
+ const nextIndex = currentIndex + 1 > types?.length - 1 ? 0 : currentIndex + 1;
76
+ return types[nextIndex];
77
+ };
78
+ const transformOnChangeValue = (value, type) => {
79
+ return type?.toChangeValue ? type?.toChangeValue(value) : value;
80
+ };
81
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(prefix, className), style: style, children: [component && ((0, jsx_runtime_1.jsx)("div", { className: prefix + '-content', children: react_1.default.createElement(component, {
82
+ ...props,
83
+ value: type?.toInputValue ? type?.toInputValue(value) : value,
84
+ onChange: (event) => {
85
+ const value = getEventValue(event);
86
+ typesValue.current[type?.type] = value;
87
+ onChange?.(transformOnChangeValue(value, type));
88
+ },
89
+ }) })), (0, jsx_runtime_1.jsx)(antd_1.Button, { className: prefix + '-controller', style: {
90
+ width: !component ? '100%' : 'auto',
91
+ }, block: true, onClick: () => {
92
+ const nextType = getNextType();
93
+ if (nextType === type)
94
+ return;
95
+ setCurrent(nextType?.type);
96
+ onChange?.(transformOnChangeValue(typesValue.current[nextType?.type], nextType));
97
+ }, children: type?.icon ? ((0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, { infer: type.icon })) : (type?.title || type?.type) })] }));
98
+ };
99
+ }
100
+ exports.createPolyInput = createPolyInput;
@@ -0,0 +1,31 @@
1
+ @ant-prefix: ant;
2
+ .dn-poly-input {
3
+ display: flex;
4
+ width: 100%;
5
+ align-items: center;
6
+
7
+ .dn-poly-input-content {
8
+ flex-grow: 2;
9
+ margin-right: 2px;
10
+ display: flex;
11
+
12
+ .@{ant-prefix}-select {
13
+ width: 100%;
14
+ }
15
+
16
+ .@{ant-prefix}-input-number {
17
+ width: 100%;
18
+ }
19
+ }
20
+
21
+ .dn-poly-input-controller {
22
+ border: 1px solid var(--dn-color-border, #d9d9d9);
23
+ border-radius: 2px;
24
+ cursor: pointer;
25
+ padding: 0 8px;
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: center;
29
+ flex-grow: 0;
30
+ }
31
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './styles.less';
3
+ export interface IPositionInputProps {
4
+ className?: string;
5
+ style?: React.CSSProperties;
6
+ value?: string;
7
+ onChange?: (value: string) => void;
8
+ }
9
+ export declare const PositionInput: React.FC<IPositionInputProps>;
@@ -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.PositionInput = 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 PositionInput = (props) => {
13
+ const prefix = (0, designable_react_1.usePrefix)('position-input');
14
+ const [current, setCurrent] = (0, react_1.useState)(props.value);
15
+ (0, react_1.useEffect)(() => {
16
+ if (!props.value) {
17
+ setCurrent('center');
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.jsx)("div", { className: prefix + '-row', children: (0, jsx_runtime_1.jsx)("div", { ...createCellProps('top'), children: "\u2533" }) }), (0, jsx_runtime_1.jsxs)("div", { className: prefix + '-row', children: [(0, jsx_runtime_1.jsx)("div", { ...createCellProps('left'), children: "\u2523" }), (0, jsx_runtime_1.jsx)("div", { ...createCellProps('center'), children: "\u254B" }), (0, jsx_runtime_1.jsx)("div", { ...createCellProps('right'), children: "\u252B" })] }), (0, jsx_runtime_1.jsx)("div", { className: prefix + '-row', children: (0, jsx_runtime_1.jsx)("div", { ...createCellProps('bottom'), children: "\u253B" }) })] }));
28
+ };
29
+ exports.PositionInput = PositionInput;
@@ -0,0 +1,28 @@
1
+
2
+ .dn-position-input {
3
+ display: flex;
4
+ flex-direction: column;
5
+
6
+ &-row {
7
+ display: flex;
8
+ justify-content: center;
9
+ }
10
+
11
+ &-cell {
12
+ width: 26px;
13
+ height: 26px;
14
+ box-sizing: border-box;
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ cursor: pointer;
19
+ border-radius: 3px;
20
+ color: rgba(0, 0, 0, 0.6);
21
+ margin: 5px;
22
+ color: var(--dn-color-text, rgba(0, 0, 0, 0.88));
23
+
24
+ &.active {
25
+ background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.2));
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const SizeInput: import("react").FC<import("../PolyInput").IInput>;
3
+ export declare const BackgroundSizeInput: import("react").FC<import("../PolyInput").IInput>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BackgroundSizeInput = exports.SizeInput = void 0;
4
+ const antd_1 = require("antd");
5
+ const PolyInput_1 = require("../PolyInput");
6
+ const takeNumber = (value) => {
7
+ const num = String(value)
8
+ .trim()
9
+ .replace(/[^\d\.]+/, '');
10
+ if (num === '')
11
+ return;
12
+ return Number(num);
13
+ };
14
+ const createUnitType = (type) => {
15
+ return {
16
+ type,
17
+ component: antd_1.InputNumber,
18
+ checker(value) {
19
+ return String(value).includes(type);
20
+ },
21
+ toInputValue(value) {
22
+ return takeNumber(value);
23
+ },
24
+ toChangeValue(value) {
25
+ return `${value || 0}${type}`;
26
+ },
27
+ };
28
+ };
29
+ const createSpecialSizeOption = (type) => ({
30
+ type: type,
31
+ checker(value) {
32
+ if (value === type)
33
+ return true;
34
+ return false;
35
+ },
36
+ toChangeValue() {
37
+ return type;
38
+ },
39
+ });
40
+ const NormalSizeOptions = [
41
+ createSpecialSizeOption('inherit'),
42
+ createSpecialSizeOption('auto'),
43
+ createUnitType('px'),
44
+ createUnitType('%'),
45
+ createUnitType('vh'),
46
+ createUnitType('em'),
47
+ ];
48
+ exports.SizeInput = (0, PolyInput_1.createPolyInput)(NormalSizeOptions);
49
+ exports.BackgroundSizeInput = (0, PolyInput_1.createPolyInput)([
50
+ createSpecialSizeOption('cover'),
51
+ createSpecialSizeOption('contain'),
52
+ createUnitType('px'),
53
+ createUnitType('%'),
54
+ createUnitType('vh'),
55
+ createUnitType('em'),
56
+ ]);
@@ -0,0 +1,23 @@
1
+
2
+ .dn-size-input {
3
+ display: flex;
4
+ width: 100%;
5
+
6
+ .@{ant-prefix}-input-number {
7
+ flex-grow: 2;
8
+ margin-right: 2px;
9
+ }
10
+
11
+ .dn-size-input-unit {
12
+ border: 1px solid var(--dn-color-border, #d9d9d9);
13
+ border-radius: 2px;
14
+ cursor: pointer;
15
+ height: 32px;
16
+ padding: 0 8px;
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ flex-grow: 0;
21
+ }
22
+ }
23
+ @ant-prefix: ant;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const ValueInput: React.FC<import("../PolyInput").IInput>;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValueInput = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const PolyInput_1 = require("../PolyInput");
6
+ const antd_1 = require("antd");
7
+ const MonacoInput_1 = require("../MonacoInput");
8
+ const designable_react_1 = require("@thienvu18/designable-react");
9
+ const STARTTAG_REX = /<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
10
+ const EXPRESSION_REX = /^\{\{([\s\S]*)\}\}$/;
11
+ const isNumber = (value) => typeof value === 'number';
12
+ const isBoolean = (value) => typeof value === 'boolean';
13
+ const isExpression = (value) => {
14
+ return typeof value === 'string' && EXPRESSION_REX.test(value);
15
+ };
16
+ const isRichText = (value) => {
17
+ return typeof value === 'string' && STARTTAG_REX.test(value);
18
+ };
19
+ const isNormalText = (value) => {
20
+ return typeof value === 'string' && !isExpression(value) && !isRichText(value);
21
+ };
22
+ const takeNumber = (value) => {
23
+ const num = String(value).replace(/[^\d\.]+/, '');
24
+ if (num === '')
25
+ return;
26
+ return Number(num);
27
+ };
28
+ exports.ValueInput = (0, PolyInput_1.createPolyInput)([
29
+ {
30
+ type: 'TEXT',
31
+ icon: 'Text',
32
+ component: antd_1.Input,
33
+ checker: isNormalText,
34
+ },
35
+ {
36
+ type: 'EXPRESSION',
37
+ icon: 'Expression',
38
+ component: (props) => {
39
+ return ((0, jsx_runtime_1.jsx)(antd_1.Popover, { content: (0, jsx_runtime_1.jsx)("div", { style: {
40
+ width: 400,
41
+ height: 200,
42
+ marginLeft: -16,
43
+ marginRight: -16,
44
+ marginBottom: -12,
45
+ }, children: (0, jsx_runtime_1.jsx)(MonacoInput_1.MonacoInput, { ...props, language: "javascript.expression" }) }), trigger: "click", children: (0, jsx_runtime_1.jsx)(antd_1.Button, { block: true, children: (0, jsx_runtime_1.jsx)(designable_react_1.TextWidget, { token: "SettingComponents.ValueInput.expression" }) }) }));
46
+ },
47
+ checker: isExpression,
48
+ toInputValue: (value) => {
49
+ if (!value || value === '{{}}')
50
+ return;
51
+ const matched = String(value).match(EXPRESSION_REX);
52
+ return matched?.[1] || value || '';
53
+ },
54
+ toChangeValue: (value) => {
55
+ if (!value || value === '{{}}')
56
+ return;
57
+ const matched = String(value).match(EXPRESSION_REX);
58
+ return `{{${matched?.[1] || value || ''}}}`;
59
+ },
60
+ },
61
+ {
62
+ type: 'BOOLEAN',
63
+ icon: 'Boolean',
64
+ component: (props) => ((0, jsx_runtime_1.jsx)(antd_1.Select, { ...props, options: [
65
+ { label: 'True', value: true },
66
+ { label: 'False', value: false },
67
+ ] })),
68
+ checker: isBoolean,
69
+ toInputValue: (value) => {
70
+ return !!value;
71
+ },
72
+ toChangeValue: (value) => {
73
+ return !!value;
74
+ },
75
+ },
76
+ {
77
+ type: 'NUMBER',
78
+ icon: 'Number',
79
+ component: antd_1.InputNumber,
80
+ checker: isNumber,
81
+ toInputValue: takeNumber,
82
+ toChangeValue: takeNumber,
83
+ },
84
+ ]);
File without changes
@@ -0,0 +1,20 @@
1
+ export * from './ColorInput';
2
+ export * from './CornerInput';
3
+ export * from './ImageInput';
4
+ export * from './PositionInput';
5
+ export * from './SizeInput';
6
+ export * from './PolyInput';
7
+ export * from './ValueInput';
8
+ export * from './MonacoInput';
9
+ export * from './DrawerSetter';
10
+ export * from './BoxStyleSetter';
11
+ export * from './BorderStyleSetter';
12
+ export * from './BorderRadiusStyleSetter';
13
+ export * from './BackgroundStyleSetter';
14
+ export * from './BoxShadowStyleSetter';
15
+ export * from './FontStyleSetter';
16
+ export * from './DisplayStyleSetter';
17
+ export * from './FlexStyleSetter';
18
+ export * from './FoldItem';
19
+ export * from './CollapseItem';
20
+ export * from './InputItems';
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ColorInput"), exports);
18
+ __exportStar(require("./CornerInput"), exports);
19
+ __exportStar(require("./ImageInput"), exports);
20
+ __exportStar(require("./PositionInput"), exports);
21
+ __exportStar(require("./SizeInput"), exports);
22
+ __exportStar(require("./PolyInput"), exports);
23
+ __exportStar(require("./ValueInput"), exports);
24
+ __exportStar(require("./MonacoInput"), exports);
25
+ __exportStar(require("./DrawerSetter"), exports);
26
+ __exportStar(require("./BoxStyleSetter"), exports);
27
+ __exportStar(require("./BorderStyleSetter"), exports);
28
+ __exportStar(require("./BorderRadiusStyleSetter"), exports);
29
+ __exportStar(require("./BackgroundStyleSetter"), exports);
30
+ __exportStar(require("./BoxShadowStyleSetter"), exports);
31
+ __exportStar(require("./FontStyleSetter"), exports);
32
+ __exportStar(require("./DisplayStyleSetter"), exports);
33
+ __exportStar(require("./FlexStyleSetter"), exports);
34
+ __exportStar(require("./FoldItem"), exports);
35
+ __exportStar(require("./CollapseItem"), exports);
36
+ __exportStar(require("./InputItems"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './useLocales';
2
+ export * from './useSnapshot';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useLocales"), exports);
18
+ __exportStar(require("./useSnapshot"), exports);
@@ -0,0 +1,2 @@
1
+ import { TreeNode } from '@thienvu18/designable-core';
2
+ export declare const useLocales: (node: TreeNode) => void;