@thienvu18/designable-react-settings-form 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/esm/SchemaField.d.ts +5115 -1578
  2. package/esm/SchemaField.js +76 -41
  3. package/esm/SettingsForm.d.ts +4 -4
  4. package/esm/SettingsForm.js +99 -49
  5. package/esm/components/BackgroundStyleSetter/index.d.ts +4 -4
  6. package/esm/components/BackgroundStyleSetter/index.js +95 -42
  7. package/esm/components/BorderRadiusStyleSetter/index.d.ts +4 -4
  8. package/esm/components/BorderRadiusStyleSetter/index.js +13 -10
  9. package/esm/components/BorderStyleSetter/index.d.ts +5 -5
  10. package/esm/components/BorderStyleSetter/index.js +121 -68
  11. package/esm/components/BoxShadowStyleSetter/index.d.ts +6 -6
  12. package/esm/components/BoxShadowStyleSetter/index.js +72 -24
  13. package/esm/components/BoxStyleSetter/index.d.ts +7 -7
  14. package/esm/components/BoxStyleSetter/index.js +98 -46
  15. package/esm/components/CollapseItem/index.d.ts +6 -6
  16. package/esm/components/CollapseItem/index.js +35 -15
  17. package/esm/components/ColorInput/index.d.ts +5 -5
  18. package/esm/components/ColorInput/index.js +35 -17
  19. package/esm/components/ColorInput/styles.less +0 -5
  20. package/esm/components/CornerInput/index.d.ts +7 -7
  21. package/esm/components/CornerInput/index.js +50 -21
  22. package/esm/components/DisplayStyleSetter/index.d.ts +7 -7
  23. package/esm/components/DisplayStyleSetter/index.js +62 -33
  24. package/esm/components/DrawerSetter/index.d.ts +6 -6
  25. package/esm/components/DrawerSetter/index.js +82 -42
  26. package/esm/components/DrawerSetter/styles.less +2 -2
  27. package/esm/components/FlexStyleSetter/index.d.ts +5 -5
  28. package/esm/components/FlexStyleSetter/index.js +160 -110
  29. package/esm/components/FoldItem/index.d.ts +9 -7
  30. package/esm/components/FoldItem/index.js +80 -46
  31. package/esm/components/FontStyleSetter/index.d.ts +4 -4
  32. package/esm/components/FontStyleSetter/index.js +169 -85
  33. package/esm/components/ImageInput/index.d.ts +7 -7
  34. package/esm/components/ImageInput/index.js +59 -39
  35. package/esm/components/InputItems/index.d.ts +19 -17
  36. package/esm/components/InputItems/index.js +42 -16
  37. package/esm/components/MonacoInput/config.d.ts +1 -1
  38. package/esm/components/MonacoInput/config.js +40 -38
  39. package/esm/components/MonacoInput/format.d.ts +4 -1
  40. package/esm/components/MonacoInput/format.js +33 -29
  41. package/esm/components/MonacoInput/index.d.ts +13 -13
  42. package/esm/components/MonacoInput/index.js +298 -212
  43. package/esm/components/MonacoInput/themes/chrome.d.ts +44 -38
  44. package/esm/components/MonacoInput/themes/chrome.js +105 -105
  45. package/esm/components/MonacoInput/themes/monokai.d.ts +34 -30
  46. package/esm/components/MonacoInput/themes/monokai.js +139 -139
  47. package/esm/components/PolyInput/index.d.ts +17 -17
  48. package/esm/components/PolyInput/index.js +96 -66
  49. package/esm/components/PositionInput/index.d.ts +7 -7
  50. package/esm/components/PositionInput/index.js +48 -21
  51. package/esm/components/PositionInput/styles.less +0 -1
  52. package/esm/components/SizeInput/index.d.ts +6 -2
  53. package/esm/components/SizeInput/index.js +44 -46
  54. package/esm/components/SizeInput/styles.less +0 -1
  55. package/esm/components/ValueInput/index.d.ts +2 -2
  56. package/esm/components/ValueInput/index.js +89 -72
  57. package/esm/components/index.d.ts +20 -20
  58. package/esm/components/index.js +20 -20
  59. package/esm/effects/index.d.ts +2 -2
  60. package/esm/effects/index.js +2 -2
  61. package/esm/effects/useLocales.d.ts +2 -2
  62. package/esm/effects/useLocales.js +57 -59
  63. package/esm/effects/useSnapshot.d.ts +2 -2
  64. package/esm/effects/useSnapshot.js +9 -9
  65. package/esm/index.d.ts +5 -5
  66. package/esm/index.js +5 -5
  67. package/esm/locales/en-US.d.ts +12 -12
  68. package/esm/locales/en-US.js +10 -10
  69. package/esm/locales/index.d.ts +1 -1
  70. package/esm/locales/index.js +5 -5
  71. package/esm/locales/ko-KR.d.ts +12 -12
  72. package/esm/locales/ko-KR.js +10 -10
  73. package/esm/locales/zh-CN.d.ts +12 -12
  74. package/esm/locales/zh-CN.js +10 -10
  75. package/esm/registry.d.ts +2 -2
  76. package/esm/registry.js +11 -11
  77. package/esm/shared/context.d.ts +2 -2
  78. package/esm/shared/context.js +2 -2
  79. package/esm/shared/loadScript.d.ts +5 -5
  80. package/esm/shared/loadScript.js +27 -28
  81. package/esm/styles.less +5 -4
  82. package/esm/types.d.ts +8 -8
  83. package/esm/types.js +1 -1
  84. package/lib/SchemaField.d.ts +5115 -1578
  85. package/lib/SchemaField.js +44 -44
  86. package/lib/SettingsForm.d.ts +4 -4
  87. package/lib/SettingsForm.js +108 -55
  88. package/lib/components/BackgroundStyleSetter/index.d.ts +4 -4
  89. package/lib/components/BackgroundStyleSetter/index.js +106 -48
  90. package/lib/components/BorderRadiusStyleSetter/index.d.ts +4 -4
  91. package/lib/components/BorderRadiusStyleSetter/index.js +33 -14
  92. package/lib/components/BorderStyleSetter/index.d.ts +5 -5
  93. package/lib/components/BorderStyleSetter/index.js +138 -74
  94. package/lib/components/BoxShadowStyleSetter/index.d.ts +6 -6
  95. package/lib/components/BoxShadowStyleSetter/index.js +82 -30
  96. package/lib/components/BoxStyleSetter/index.d.ts +7 -7
  97. package/lib/components/BoxStyleSetter/index.js +122 -52
  98. package/lib/components/CollapseItem/index.d.ts +6 -6
  99. package/lib/components/CollapseItem/index.js +49 -21
  100. package/lib/components/ColorInput/index.d.ts +5 -5
  101. package/lib/components/ColorInput/index.js +39 -21
  102. package/lib/components/ColorInput/styles.less +0 -5
  103. package/lib/components/CornerInput/index.d.ts +7 -7
  104. package/lib/components/CornerInput/index.js +70 -28
  105. package/lib/components/DisplayStyleSetter/index.d.ts +7 -7
  106. package/lib/components/DisplayStyleSetter/index.js +75 -39
  107. package/lib/components/DrawerSetter/index.d.ts +6 -6
  108. package/lib/components/DrawerSetter/index.js +99 -48
  109. package/lib/components/DrawerSetter/styles.less +2 -2
  110. package/lib/components/FlexStyleSetter/index.d.ts +5 -5
  111. package/lib/components/FlexStyleSetter/index.js +208 -116
  112. package/lib/components/FoldItem/index.d.ts +9 -7
  113. package/lib/components/FoldItem/index.js +140 -72
  114. package/lib/components/FontStyleSetter/index.d.ts +4 -4
  115. package/lib/components/FontStyleSetter/index.js +216 -91
  116. package/lib/components/ImageInput/index.d.ts +7 -7
  117. package/lib/components/ImageInput/index.js +69 -47
  118. package/lib/components/InputItems/index.d.ts +19 -17
  119. package/lib/components/InputItems/index.js +101 -46
  120. package/lib/components/MonacoInput/config.d.ts +1 -1
  121. package/lib/components/MonacoInput/config.js +49 -45
  122. package/lib/components/MonacoInput/format.d.ts +4 -1
  123. package/lib/components/MonacoInput/format.js +38 -33
  124. package/lib/components/MonacoInput/index.d.ts +13 -13
  125. package/lib/components/MonacoInput/index.js +347 -241
  126. package/lib/components/MonacoInput/themes/chrome.d.ts +44 -38
  127. package/lib/components/MonacoInput/themes/chrome.js +107 -107
  128. package/lib/components/MonacoInput/themes/monokai.d.ts +34 -30
  129. package/lib/components/MonacoInput/themes/monokai.js +141 -141
  130. package/lib/components/PolyInput/index.d.ts +17 -17
  131. package/lib/components/PolyInput/index.js +151 -96
  132. package/lib/components/PositionInput/index.d.ts +7 -7
  133. package/lib/components/PositionInput/index.js +68 -28
  134. package/lib/components/PositionInput/styles.less +0 -1
  135. package/lib/components/SizeInput/index.d.ts +6 -2
  136. package/lib/components/SizeInput/index.js +47 -49
  137. package/lib/components/SizeInput/styles.less +0 -1
  138. package/lib/components/ValueInput/index.d.ts +2 -2
  139. package/lib/components/ValueInput/index.js +92 -75
  140. package/lib/components/index.d.ts +20 -20
  141. package/lib/components/index.js +52 -36
  142. package/lib/effects/index.d.ts +2 -2
  143. package/lib/effects/index.js +34 -18
  144. package/lib/effects/useLocales.d.ts +2 -2
  145. package/lib/effects/useLocales.js +67 -63
  146. package/lib/effects/useSnapshot.d.ts +2 -2
  147. package/lib/effects/useSnapshot.js +13 -13
  148. package/lib/index.d.ts +5 -5
  149. package/lib/index.js +37 -21
  150. package/lib/locales/en-US.d.ts +12 -12
  151. package/lib/locales/en-US.js +12 -12
  152. package/lib/locales/index.d.ts +1 -1
  153. package/lib/locales/index.js +16 -10
  154. package/lib/locales/ko-KR.d.ts +12 -12
  155. package/lib/locales/ko-KR.js +12 -12
  156. package/lib/locales/zh-CN.d.ts +12 -12
  157. package/lib/locales/zh-CN.js +12 -12
  158. package/lib/registry.d.ts +2 -2
  159. package/lib/registry.js +21 -19
  160. package/lib/shared/context.d.ts +2 -2
  161. package/lib/shared/context.js +5 -5
  162. package/lib/shared/loadScript.d.ts +5 -5
  163. package/lib/shared/loadScript.js +32 -32
  164. package/lib/styles.less +5 -4
  165. package/lib/types.d.ts +8 -8
  166. package/lib/types.js +2 -2
  167. package/package.json +26 -27
@@ -1,88 +1,172 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { usePrefix, IconWidget } from '@thienvu18/designable-react';
3
- import { useField, Field, observer } from '@formily/react';
4
- import { Select, Radio, NumberPicker } from '@thienvu18/formily-antd-v6';
5
- import { FoldItem } from '../FoldItem';
6
- import { InputItems } from '../InputItems';
7
- import { SizeInput } from '../SizeInput';
8
- import { ColorInput } from '../ColorInput';
9
- import cls from 'classnames';
1
+ import { Field, observer, useField } from '@formily/react'
2
+ import { IconWidget, usePrefix } from '@thienvu18/designable-react'
3
+ import { NumberPicker, Radio, Select } from '@thienvu18/formily-antd-v6'
4
+ import cls from 'classnames'
5
+ import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
6
+ import { ColorInput } from '../ColorInput'
7
+ import { FoldItem } from '../FoldItem'
8
+ import { InputItems } from '../InputItems'
9
+ import { SizeInput } from '../SizeInput'
10
10
  const createFontFamilyOptions = (fonts) => {
11
- return fonts.map((font) => {
12
- const splited = font.split('=');
13
- const label = splited?.[0];
14
- const value = splited?.[1];
15
- return {
16
- label: _jsx("span", { style: { fontFamily: value }, children: label }),
17
- value,
18
- };
19
- });
20
- };
11
+ return fonts.map((font) => {
12
+ const splited = font.split('=')
13
+ const label = splited?.[0]
14
+ const value = splited?.[1]
15
+ return {
16
+ label: _jsx('span', { style: { fontFamily: value }, children: label }),
17
+ value,
18
+ }
19
+ })
20
+ }
21
21
  const FontFamilyOptions = createFontFamilyOptions([
22
- '宋体=SimSun',
23
- '微软雅黑=Microsoft Yahei',
24
- '苹方=PingFang SC',
25
- 'Andale Mono=andale mono,monospace',
26
- 'Arial=arial,helvetica,sans-serif',
27
- 'Arial Black=arial black,sans-serif',
28
- 'Book Antiqua=book antiqua,palatino,serif',
29
- 'Comic Sans MS=comic sans ms,sans-serif',
30
- 'Courier New=courier new,courier,monospace',
31
- 'Georgia=georgia,palatino,serif',
32
- 'Helvetica Neue=Helvetica Neue',
33
- 'Helvetica=helvetica,arial,sans-serif',
34
- 'Impact=impact,sans-serif',
35
- 'Symbol=symbol',
36
- 'Tahoma=tahoma,arial,helvetica,sans-serif',
37
- 'Terminal=terminal,monaco,monospace',
38
- 'Times New Roman=times new roman,times,serif',
39
- 'Trebuchet MS=trebuchet ms,geneva,sans-serif',
40
- 'Verdana=verdana,geneva,sans-serif',
41
- ]);
22
+ '宋体=SimSun',
23
+ '微软雅黑=Microsoft Yahei',
24
+ '苹方=PingFang SC',
25
+ 'Andale Mono=andale mono,monospace',
26
+ 'Arial=arial,helvetica,sans-serif',
27
+ 'Arial Black=arial black,sans-serif',
28
+ 'Book Antiqua=book antiqua,palatino,serif',
29
+ 'Comic Sans MS=comic sans ms,sans-serif',
30
+ 'Courier New=courier new,courier,monospace',
31
+ 'Georgia=georgia,palatino,serif',
32
+ 'Helvetica Neue=Helvetica Neue',
33
+ 'Helvetica=helvetica,arial,sans-serif',
34
+ 'Impact=impact,sans-serif',
35
+ 'Symbol=symbol',
36
+ 'Tahoma=tahoma,arial,helvetica,sans-serif',
37
+ 'Terminal=terminal,monaco,monospace',
38
+ 'Times New Roman=times new roman,times,serif',
39
+ 'Trebuchet MS=trebuchet ms,geneva,sans-serif',
40
+ 'Verdana=verdana,geneva,sans-serif',
41
+ ])
42
42
  export const FontStyleSetter = observer((props) => {
43
- const field = useField();
44
- const prefix = usePrefix('font-style-setter');
45
- return (_jsxs(FoldItem, { label: field.title, className: cls(prefix, props.className), style: props.style, children: [_jsx(FoldItem.Base, { children: _jsx(Field, { name: "fontFamily", basePath: field.address.parent(), component: [
46
- Select,
47
- { style: { width: '100%' }, placeholder: 'Helvetica Neue' },
48
- ], dataSource: FontFamilyOptions }) }), _jsx(FoldItem.Extra, { children: _jsxs(InputItems, { children: [_jsx(InputItems.Item, { icon: "FontWeight", width: "50%", children: _jsx(Field, { name: "fontWeight", basePath: field.address.parent(), component: [NumberPicker, { placeholder: '400' }] }) }), _jsx(InputItems.Item, { icon: "FontStyle", width: "50%", children: _jsx(Field, { name: "fontStyle", basePath: field.address.parent(), dataSource: [
49
- {
50
- label: _jsx(IconWidget, { infer: "NormalFontStyle" }),
51
- value: 'normal',
52
- },
53
- {
54
- label: _jsx(IconWidget, { infer: "ItalicFontStyle" }),
55
- value: 'italic',
56
- },
57
- ], component: [Radio.Group, { optionType: 'button' }] }) }), _jsx(InputItems.Item, { icon: "FontColor", width: "100%", children: _jsx(Field, { name: "color", basePath: field.address.parent(), component: [ColorInput] }) }), _jsx(InputItems.Item, { icon: "FontSize", width: "50%", children: _jsx(Field, { name: "fontSize", basePath: field.address.parent(), component: [SizeInput, { exclude: ['auto'] }] }) }), _jsx(InputItems.Item, { icon: "LineHeight", width: "50%", children: _jsx(Field, { name: "lineHeight", basePath: field.address.parent(), component: [SizeInput, { exclude: ['auto'] }] }) }), _jsx(InputItems.Item, { icon: "TextAlign", children: _jsx(Field, { name: "textAlign", basePath: field.address.parent(), dataSource: [
58
- {
59
- label: _jsx(IconWidget, { infer: "TextAlignLeft" }),
60
- value: 'left',
61
- },
62
- {
63
- label: _jsx(IconWidget, { infer: "TextAlignCenter" }),
64
- value: 'center',
65
- },
66
- {
67
- label: _jsx(IconWidget, { infer: "TextAlignRight" }),
68
- value: 'right',
69
- },
70
- {
71
- label: _jsx(IconWidget, { infer: "TextAlignJustify" }),
72
- value: 'justify',
73
- },
74
- ], component: [Radio.Group, { optionType: 'button' }] }) }), _jsx(InputItems.Item, { icon: "TextDecoration", children: _jsx(Field, { name: "textDecoration", basePath: field.address.parent(), dataSource: [
75
- {
76
- label: '--',
77
- value: 'none',
78
- },
79
- {
80
- label: _jsx(IconWidget, { infer: "TextUnderline" }),
81
- value: 'underline',
82
- },
83
- {
84
- label: _jsx(IconWidget, { infer: "TextLineThrough" }),
85
- value: 'line-through',
86
- },
87
- ], component: [Radio.Group, { optionType: 'button' }] }) })] }) })] }));
88
- });
43
+ const field = useField()
44
+ const prefix = usePrefix('font-style-setter')
45
+ return _jsxs(FoldItem, {
46
+ label: field.title,
47
+ className: cls(prefix, props.className),
48
+ style: props.style,
49
+ children: [
50
+ _jsx(FoldItem.Base, {
51
+ children: _jsx(Field, {
52
+ name: 'fontFamily',
53
+ basePath: field.address.parent(),
54
+ component: [
55
+ Select,
56
+ { style: { width: '100%' }, placeholder: 'Helvetica Neue' },
57
+ ],
58
+ dataSource: FontFamilyOptions,
59
+ }),
60
+ }),
61
+ _jsx(FoldItem.Extra, {
62
+ children: _jsxs(InputItems, {
63
+ children: [
64
+ _jsx(InputItems.Item, {
65
+ icon: 'FontWeight',
66
+ width: '50%',
67
+ children: _jsx(Field, {
68
+ name: 'fontWeight',
69
+ basePath: field.address.parent(),
70
+ component: [NumberPicker, { placeholder: '400' }],
71
+ }),
72
+ }),
73
+ _jsx(InputItems.Item, {
74
+ icon: 'FontStyle',
75
+ width: '50%',
76
+ children: _jsx(Field, {
77
+ name: 'fontStyle',
78
+ basePath: field.address.parent(),
79
+ dataSource: [
80
+ {
81
+ label: _jsx(IconWidget, { infer: 'NormalFontStyle' }),
82
+ value: 'normal',
83
+ },
84
+ {
85
+ label: _jsx(IconWidget, { infer: 'ItalicFontStyle' }),
86
+ value: 'italic',
87
+ },
88
+ ],
89
+ component: [Radio.Group, { optionType: 'button' }],
90
+ }),
91
+ }),
92
+ _jsx(InputItems.Item, {
93
+ icon: 'FontColor',
94
+ width: '100%',
95
+ children: _jsx(Field, {
96
+ name: 'color',
97
+ basePath: field.address.parent(),
98
+ component: [ColorInput],
99
+ }),
100
+ }),
101
+ _jsx(InputItems.Item, {
102
+ icon: 'FontSize',
103
+ width: '50%',
104
+ children: _jsx(Field, {
105
+ name: 'fontSize',
106
+ basePath: field.address.parent(),
107
+ component: [SizeInput, { exclude: ['auto'] }],
108
+ }),
109
+ }),
110
+ _jsx(InputItems.Item, {
111
+ icon: 'LineHeight',
112
+ width: '50%',
113
+ children: _jsx(Field, {
114
+ name: 'lineHeight',
115
+ basePath: field.address.parent(),
116
+ component: [SizeInput, { exclude: ['auto'] }],
117
+ }),
118
+ }),
119
+ _jsx(InputItems.Item, {
120
+ icon: 'TextAlign',
121
+ children: _jsx(Field, {
122
+ name: 'textAlign',
123
+ basePath: field.address.parent(),
124
+ dataSource: [
125
+ {
126
+ label: _jsx(IconWidget, { infer: 'TextAlignLeft' }),
127
+ value: 'left',
128
+ },
129
+ {
130
+ label: _jsx(IconWidget, { infer: 'TextAlignCenter' }),
131
+ value: 'center',
132
+ },
133
+ {
134
+ label: _jsx(IconWidget, { infer: 'TextAlignRight' }),
135
+ value: 'right',
136
+ },
137
+ {
138
+ label: _jsx(IconWidget, { infer: 'TextAlignJustify' }),
139
+ value: 'justify',
140
+ },
141
+ ],
142
+ component: [Radio.Group, { optionType: 'button' }],
143
+ }),
144
+ }),
145
+ _jsx(InputItems.Item, {
146
+ icon: 'TextDecoration',
147
+ children: _jsx(Field, {
148
+ name: 'textDecoration',
149
+ basePath: field.address.parent(),
150
+ dataSource: [
151
+ {
152
+ label: '--',
153
+ value: 'none',
154
+ },
155
+ {
156
+ label: _jsx(IconWidget, { infer: 'TextUnderline' }),
157
+ value: 'underline',
158
+ },
159
+ {
160
+ label: _jsx(IconWidget, { infer: 'TextLineThrough' }),
161
+ value: 'line-through',
162
+ },
163
+ ],
164
+ component: [Radio.Group, { optionType: 'button' }],
165
+ }),
166
+ }),
167
+ ],
168
+ }),
169
+ }),
170
+ ],
171
+ })
172
+ })
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
- import { InputProps } from 'antd';
3
- import './styles.less';
1
+ import { InputProps } from 'antd'
2
+ import React from 'react'
3
+ import './styles.less'
4
4
  export interface ImageInputProps extends Omit<InputProps, 'onChange'> {
5
- value?: string;
6
- onChange?: (value: string) => void;
5
+ value?: string
6
+ onChange?: (value: string) => void
7
7
  }
8
- export declare const ImageInput: React.FC<ImageInputProps>;
9
- export declare const BackgroundImageInput: React.FC<ImageInputProps>;
8
+ export declare const ImageInput: React.FC<ImageInputProps>
9
+ export declare const BackgroundImageInput: React.FC<ImageInputProps>
@@ -1,41 +1,61 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useContext } from 'react';
3
- import { Input, Upload } from 'antd';
4
- import { usePrefix, IconWidget } from '@thienvu18/designable-react';
5
- import { SettingsFormContext } from '../../shared/context';
6
- import cls from 'classnames';
7
- import './styles.less';
1
+ import { IconWidget, usePrefix } from '@thienvu18/designable-react'
2
+ import { Input, Upload } from 'antd'
3
+ import cls from 'classnames'
4
+ import { useContext } from 'react'
5
+ import { jsx as _jsx } from 'react/jsx-runtime'
6
+ import { SettingsFormContext } from '../../shared/context'
7
+ import './styles.less'
8
8
  export const ImageInput = ({ className, style, ...props }) => {
9
- const prefix = usePrefix('image-input');
10
- const context = useContext(SettingsFormContext);
11
- return (_jsx("div", { className: cls(prefix, className), style: style, children: _jsx(Input, { ...props, onChange: (e) => {
12
- props.onChange?.(e?.target?.['value']);
13
- }, prefix: _jsx(Upload, { action: context.uploadAction, itemRender: () => null, maxCount: 1, onChange: (params) => {
14
- const response = params.file?.response;
15
- const url = response?.url ||
16
- response?.downloadURL ||
17
- response?.imageURL ||
18
- response?.thumbUrl;
19
- if (!url)
20
- return;
21
- props.onChange?.(url);
22
- }, children: _jsx(IconWidget, { infer: "CloudUpload", style: { cursor: 'pointer' } }) }) }) }));
23
- };
9
+ const prefix = usePrefix('image-input')
10
+ const context = useContext(SettingsFormContext)
11
+ return _jsx('div', {
12
+ className: cls(prefix, className),
13
+ style: style,
14
+ children: _jsx(Input, {
15
+ ...props,
16
+ onChange: (e) => {
17
+ props.onChange?.(e?.target?.['value'])
18
+ },
19
+ prefix: _jsx(Upload, {
20
+ action: context.uploadAction,
21
+ itemRender: () => null,
22
+ maxCount: 1,
23
+ onChange: (params) => {
24
+ const response = params.file?.response
25
+ const url =
26
+ response?.url ||
27
+ response?.downloadURL ||
28
+ response?.imageURL ||
29
+ response?.thumbUrl
30
+ if (!url) return
31
+ props.onChange?.(url)
32
+ },
33
+ children: _jsx(IconWidget, {
34
+ infer: 'CloudUpload',
35
+ style: { cursor: 'pointer' },
36
+ }),
37
+ }),
38
+ }),
39
+ })
40
+ }
24
41
  export const BackgroundImageInput = (props) => {
25
- const addBgValue = (value) => {
26
- if (/url\([^)]+\)/.test(value)) {
27
- return value;
28
- }
29
- return `url(${value})`;
30
- };
31
- const removeBgValue = (value) => {
32
- const matched = String(value).match(/url\(\s*([^)]+)\s*\)/);
33
- if (matched?.[1]) {
34
- return matched?.[1];
35
- }
36
- return value;
37
- };
38
- return (_jsx(ImageInput, { value: removeBgValue(props.value), onChange: (url) => {
39
- props.onChange?.(addBgValue(url));
40
- } }));
41
- };
42
+ const addBgValue = (value) => {
43
+ if (/url\([^)]+\)/.test(value)) {
44
+ return value
45
+ }
46
+ return `url(${value})`
47
+ }
48
+ const removeBgValue = (value) => {
49
+ const matched = String(value).match(/url\(\s*([^)]+)\s*\)/)
50
+ if (matched?.[1]) {
51
+ return matched?.[1]
52
+ }
53
+ return value
54
+ }
55
+ return _jsx(ImageInput, {
56
+ value: removeBgValue(props.value),
57
+ onChange: (url) => {
58
+ props.onChange?.(addBgValue(url))
59
+ },
60
+ })
61
+ }
@@ -1,23 +1,25 @@
1
- import React from 'react';
2
- import './styles.less';
1
+ import React from 'react'
2
+ import './styles.less'
3
3
  export interface IInputItemsContext {
4
- width?: string | number;
5
- vertical?: boolean;
4
+ width?: string | number
5
+ vertical?: boolean
6
6
  }
7
7
  export interface IInputItemsProps {
8
- className?: string;
9
- style?: React.CSSProperties;
10
- width?: string | number;
11
- vertical?: boolean;
8
+ className?: string
9
+ style?: React.CSSProperties
10
+ width?: string | number
11
+ vertical?: boolean
12
12
  }
13
13
  export interface IInputItemProps {
14
- className?: string;
15
- style?: React.CSSProperties;
16
- icon?: React.ReactNode;
17
- width?: string | number;
18
- vertical?: boolean;
19
- title?: React.ReactNode;
14
+ className?: string
15
+ style?: React.CSSProperties
16
+ icon?: React.ReactNode
17
+ width?: string | number
18
+ vertical?: boolean
19
+ title?: React.ReactNode
20
+ }
21
+ export declare const InputItems: React.FC<
22
+ React.PropsWithChildren<IInputItemsProps>
23
+ > & {
24
+ Item: React.FC<React.PropsWithChildren<IInputItemProps>>
20
25
  }
21
- export declare const InputItems: React.FC<React.PropsWithChildren<IInputItemsProps>> & {
22
- Item: React.FC<React.PropsWithChildren<IInputItemProps>>;
23
- };
@@ -1,18 +1,44 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useContext } from 'react';
3
- import { usePrefix, IconWidget } from '@thienvu18/designable-react';
4
- import cls from 'classnames';
5
- import './styles.less';
6
- const InputItemsContext = React.createContext(null);
1
+ import { IconWidget, usePrefix } from '@thienvu18/designable-react'
2
+ import cls from 'classnames'
3
+ import React, { useContext } from 'react'
4
+ import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
5
+ import './styles.less'
6
+ const InputItemsContext = React.createContext(null)
7
7
  export const InputItems = (props) => {
8
- const { width = '100%', className, style, children } = props;
9
- const prefix = usePrefix('input-items');
10
- return (_jsx(InputItemsContext.Provider, { value: { width, vertical: props.vertical }, children: _jsx("div", { className: cls(prefix, className), style: style, children: children }) }));
11
- };
8
+ const { width = '100%', className, style, children } = props
9
+ const prefix = usePrefix('input-items')
10
+ return _jsx(InputItemsContext.Provider, {
11
+ value: { width, vertical: props.vertical },
12
+ children: _jsx('div', {
13
+ className: cls(prefix, className),
14
+ style: style,
15
+ children: children,
16
+ }),
17
+ })
18
+ }
12
19
  InputItems.Item = (props) => {
13
- const prefix = usePrefix('input-items-item');
14
- const ctx = useContext(InputItemsContext);
15
- return (_jsxs("div", { className: cls(prefix, props.className, {
16
- vertical: props.vertical || ctx?.vertical,
17
- }), style: { width: props.width || ctx?.width, ...props.style }, children: [props.icon && (_jsx("div", { className: prefix + '-icon', children: typeof props.icon === 'string' ? (_jsx(IconWidget, { infer: props.icon, size: 16 })) : (props.icon) })), props.title && _jsx("div", { className: prefix + '-title', children: props.title }), _jsx("div", { className: prefix + '-controller', children: props.children })] }));
18
- };
20
+ const prefix = usePrefix('input-items-item')
21
+ const ctx = useContext(InputItemsContext)
22
+ return _jsxs('div', {
23
+ className: cls(prefix, props.className, {
24
+ vertical: props.vertical || ctx?.vertical,
25
+ }),
26
+ style: { width: props.width || ctx?.width, ...props.style },
27
+ children: [
28
+ props.icon &&
29
+ _jsx('div', {
30
+ className: prefix + '-icon',
31
+ children:
32
+ typeof props.icon === 'string'
33
+ ? _jsx(IconWidget, { infer: props.icon, size: 16 })
34
+ : props.icon,
35
+ }),
36
+ props.title &&
37
+ _jsx('div', { className: prefix + '-title', children: props.title }),
38
+ _jsx('div', {
39
+ className: prefix + '-controller',
40
+ children: props.children,
41
+ }),
42
+ ],
43
+ })
44
+ }
@@ -1 +1 @@
1
- export declare const initMonaco: () => void;
1
+ export declare const initMonaco: () => void
@@ -1,39 +1,41 @@
1
- import { loader } from '@monaco-editor/react';
2
- import chromeTheme from './themes/chrome';
3
- import monokaiTheme from './themes/monokai';
4
- import { format } from './format';
5
- let initialized = false;
1
+ import { loader } from '@monaco-editor/react'
2
+ import { format } from './format'
3
+ import chromeTheme from './themes/chrome'
4
+ import monokaiTheme from './themes/monokai'
5
+ let initialized = false
6
6
  export const initMonaco = () => {
7
- if (initialized)
8
- return;
9
- loader.init().then((monaco) => {
10
- monaco.editor.defineTheme('monokai', monokaiTheme);
11
- monaco.editor.defineTheme('chrome-devtools', chromeTheme);
12
- monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
13
- target: monaco.languages.typescript.ScriptTarget.Latest,
14
- allowNonTsExtensions: true,
15
- moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
16
- module: monaco.languages.typescript.ModuleKind.CommonJS,
17
- noEmit: true,
18
- esModuleInterop: true,
19
- jsx: monaco.languages.typescript.JsxEmit.React,
20
- reactNamespace: 'React',
21
- allowJs: true,
22
- });
23
- monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
24
- noSemanticValidation: false,
25
- noSyntaxValidation: true,
26
- });
27
- monaco.languages.registerDocumentFormattingEditProvider('typescript', {
28
- async provideDocumentFormattingEdits(model) {
29
- return [
30
- {
31
- text: await format(model['getDesignerLanguage']?.() || 'typescript', model.getValue()),
32
- range: model.getFullModelRange(),
33
- },
34
- ];
35
- },
36
- });
37
- initialized = true;
38
- });
39
- };
7
+ if (initialized) return
8
+ loader.init().then((monaco) => {
9
+ monaco.editor.defineTheme('monokai', monokaiTheme)
10
+ monaco.editor.defineTheme('chrome-devtools', chromeTheme)
11
+ monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
12
+ target: monaco.languages.typescript.ScriptTarget.Latest,
13
+ allowNonTsExtensions: true,
14
+ moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
15
+ module: monaco.languages.typescript.ModuleKind.CommonJS,
16
+ noEmit: true,
17
+ esModuleInterop: true,
18
+ jsx: monaco.languages.typescript.JsxEmit.React,
19
+ reactNamespace: 'React',
20
+ allowJs: true,
21
+ })
22
+ monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
23
+ noSemanticValidation: false,
24
+ noSyntaxValidation: true,
25
+ })
26
+ monaco.languages.registerDocumentFormattingEditProvider('typescript', {
27
+ async provideDocumentFormattingEdits(model) {
28
+ return [
29
+ {
30
+ text: await format(
31
+ model['getDesignerLanguage']?.() || 'typescript',
32
+ model.getValue()
33
+ ),
34
+ range: model.getFullModelRange(),
35
+ },
36
+ ]
37
+ },
38
+ })
39
+ initialized = true
40
+ })
41
+ }
@@ -1 +1,4 @@
1
- export declare const format: (language: string, source: string) => Promise<string>;
1
+ export declare const format: (
2
+ language: string,
3
+ source: string
4
+ ) => Promise<string>
@@ -1,31 +1,35 @@
1
- import { parse } from '@babel/parser';
2
- import { getNpmCDNRegistry } from '../../registry';
1
+ import { parse } from '@babel/parser'
2
+ import { getNpmCDNRegistry } from '../../registry'
3
3
  const cache = {
4
- prettier: null,
5
- };
4
+ prettier: null,
5
+ }
6
6
  export const format = async (language, source) => {
7
- cache.prettier =
8
- cache.prettier ||
9
- new Function(`return import("${getNpmCDNRegistry()}/prettier@2.x/esm/standalone.mjs")`)();
10
- return cache.prettier.then((module) => {
11
- if (language === 'javascript.expression' ||
12
- language === 'typescript.expression') {
13
- return source;
14
- }
15
- if (/(?:javascript|typescript)/gi.test(language)) {
16
- return module.default.format(source, {
17
- semi: false,
18
- parser(text) {
19
- return parse(text, {
20
- sourceType: 'module',
21
- plugins: ['typescript', 'jsx'],
22
- });
23
- },
24
- });
25
- }
26
- if (language === 'json') {
27
- return JSON.stringify(JSON.parse(source), null, 2);
28
- }
29
- return source;
30
- });
31
- };
7
+ cache.prettier =
8
+ cache.prettier ||
9
+ new Function(
10
+ `return import("${getNpmCDNRegistry()}/prettier@2.x/esm/standalone.mjs")`
11
+ )()
12
+ return cache.prettier.then((module) => {
13
+ if (
14
+ language === 'javascript.expression' ||
15
+ language === 'typescript.expression'
16
+ ) {
17
+ return source
18
+ }
19
+ if (/(?:javascript|typescript)/gi.test(language)) {
20
+ return module.default.format(source, {
21
+ semi: false,
22
+ parser(text) {
23
+ return parse(text, {
24
+ sourceType: 'module',
25
+ plugins: ['typescript', 'jsx'],
26
+ })
27
+ },
28
+ })
29
+ }
30
+ if (language === 'json') {
31
+ return JSON.stringify(JSON.parse(source), null, 2)
32
+ }
33
+ return source
34
+ })
35
+ }