@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,80 +1,144 @@
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'];
1
+ 'use strict'
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod }
6
+ }
7
+ Object.defineProperty(exports, '__esModule', { value: true })
8
+ exports.BorderStyleSetter = void 0
9
+ const jsx_runtime_1 = require('react/jsx-runtime')
10
+ const react_1 = require('react')
11
+ const designable_react_1 = require('@thienvu18/designable-react')
12
+ const shared_1 = require('@formily/shared')
13
+ const formily_antd_v6_1 = require('@thienvu18/formily-antd-v6')
14
+ const reactive_1 = require('@formily/reactive')
15
+ const react_2 = require('@formily/react')
16
+ const FoldItem_1 = require('../FoldItem')
17
+ const ColorInput_1 = require('../ColorInput')
18
+ const SizeInput_1 = require('../SizeInput')
19
+ const PositionInput_1 = require('../PositionInput')
20
+ const classnames_1 = __importDefault(require('classnames'))
21
+ require('./styles.less')
22
+ const Positions = ['center', 'top', 'right', 'bottom', 'left']
21
23
  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
- ];
24
+ {
25
+ label: 'None',
26
+ value: 'none',
27
+ },
28
+ {
29
+ label: (0, jsx_runtime_1.jsx)('span', {
30
+ className: 'border-style-solid-line',
31
+ }),
32
+ value: 'solid',
33
+ },
34
+ {
35
+ label: (0, jsx_runtime_1.jsx)('span', {
36
+ className: 'border-style-dashed-line',
37
+ }),
38
+ value: 'dashed',
39
+ },
40
+ {
41
+ label: (0, jsx_runtime_1.jsx)('span', {
42
+ className: 'border-style-dotted-line',
43
+ }),
44
+ value: 'dotted',
45
+ },
46
+ ]
39
47
  const createBorderProp = (position, key) => {
40
- const insert = position === 'center' ? '' : `-${position}`;
41
- return (0, shared_1.camelCase)(`border${insert}-${key}`);
42
- };
48
+ const insert = position === 'center' ? '' : `-${position}`
49
+ return (0, shared_1.camelCase)(`border${insert}-${key}`)
50
+ }
43
51
  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
- }
52
+ const basePath = field.address.parent()
53
+ for (let i = 0; i < Positions.length; i++) {
54
+ const position = Positions[i]
55
+ const stylePath = `${basePath}.${createBorderProp(position, 'style')}`
56
+ const widthPath = `${basePath}.${createBorderProp(position, 'width')}`
57
+ const colorPath = `${basePath}.${createBorderProp(position, 'color')}`
58
+ if (
59
+ field.query(stylePath).value() ||
60
+ field.query(widthPath).value() ||
61
+ field.query(colorPath).value()
62
+ ) {
63
+ return position
55
64
  }
56
- return 'center';
57
- };
65
+ }
66
+ return 'center'
67
+ }
58
68
  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)({
69
+ const field = (0, react_2.useField)()
70
+ const currentPosition = (0, react_1.useMemo)(
71
+ () =>
72
+ (0, reactive_1.observable)({
61
73
  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
- });
74
+ }),
75
+ [field.value]
76
+ )
77
+ const prefix = (0, designable_react_1.usePrefix)('border-style-setter')
78
+ const createReaction = (position) => (field) => {
79
+ field.display = currentPosition.value === position ? 'visible' : 'hidden'
80
+ if (position !== 'center') {
81
+ const borderStyle = field.query('.borderStyle').value()
82
+ const borderWidth = field.query('.borderWidth').value()
83
+ const borderColor = field.query('.borderColor').value()
84
+ if (borderStyle || borderWidth || borderColor) {
85
+ field.value = undefined
86
+ }
87
+ }
88
+ }
89
+ return (0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem, {
90
+ label: field.title,
91
+ children: (0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Extra, {
92
+ children: (0, jsx_runtime_1.jsxs)('div', {
93
+ className: (0, classnames_1.default)(prefix, className),
94
+ style: style,
95
+ children: [
96
+ (0, jsx_runtime_1.jsx)('div', {
97
+ className: prefix + '-position',
98
+ children: (0, jsx_runtime_1.jsx)(PositionInput_1.PositionInput, {
99
+ value: currentPosition.value,
100
+ onChange: (value) => {
101
+ currentPosition.value = value
102
+ },
103
+ }),
104
+ }),
105
+ (0, jsx_runtime_1.jsx)('div', {
106
+ className: prefix + '-input',
107
+ children: Positions.map((position, key) => {
108
+ return (0, jsx_runtime_1.jsxs)(
109
+ react_1.Fragment,
110
+ {
111
+ children: [
112
+ (0, jsx_runtime_1.jsx)(react_2.Field, {
113
+ name: createBorderProp(position, 'style'),
114
+ basePath: field.address.parent(),
115
+ dataSource: BorderStyleOptions,
116
+ reactions: createReaction(position),
117
+ component: [
118
+ formily_antd_v6_1.Select,
119
+ { placeholder: 'Please Select' },
120
+ ],
121
+ }),
122
+ (0, jsx_runtime_1.jsx)(react_2.Field, {
123
+ name: createBorderProp(position, 'width'),
124
+ basePath: field.address.parent(),
125
+ reactions: createReaction(position),
126
+ component: [SizeInput_1.SizeInput, { exclude: ['auto'] }],
127
+ }),
128
+ (0, jsx_runtime_1.jsx)(react_2.Field, {
129
+ name: createBorderProp(position, 'color'),
130
+ basePath: field.address.parent(),
131
+ reactions: createReaction(position),
132
+ component: [ColorInput_1.ColorInput],
133
+ }),
134
+ ],
135
+ },
136
+ key
137
+ )
138
+ }),
139
+ }),
140
+ ],
141
+ }),
142
+ }),
143
+ })
144
+ })
@@ -1,8 +1,8 @@
1
- import React from 'react';
1
+ import React from 'react'
2
2
  export interface IBoxShadowStyleSetterProps {
3
- className?: string;
4
- style?: React.CSSProperties;
5
- value?: string;
6
- onChange?: (value: string) => void;
3
+ className?: string
4
+ style?: React.CSSProperties
5
+ value?: string
6
+ onChange?: (value: string) => void
7
7
  }
8
- export declare const BoxShadowStyleSetter: React.FC<IBoxShadowStyleSetterProps>;
8
+ export declare const BoxShadowStyleSetter: React.FC<IBoxShadowStyleSetterProps>
@@ -1,31 +1,83 @@
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"));
1
+ 'use strict'
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod }
6
+ }
7
+ Object.defineProperty(exports, '__esModule', { value: true })
8
+ exports.BoxShadowStyleSetter = void 0
9
+ const jsx_runtime_1 = require('react/jsx-runtime')
10
+ const designable_react_1 = require('@thienvu18/designable-react')
11
+ const react_1 = require('@formily/react')
12
+ const FoldItem_1 = require('../FoldItem')
13
+ const ColorInput_1 = require('../ColorInput')
14
+ const SizeInput_1 = require('../SizeInput')
15
+ const InputItems_1 = require('../InputItems')
16
+ const classnames_1 = __importDefault(require('classnames'))
15
17
  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
- });
18
+ const field = (0, react_1.useField)()
19
+ const prefix = (0, designable_react_1.usePrefix)('shadow-style-setter')
20
+ const createBoxShadowConnector = (position) => {
21
+ const splited = String(props.value || '')
22
+ .trim()
23
+ .split(' ')
24
+ return {
25
+ value: splited[position],
26
+ onChange: (value) => {
27
+ splited[position] = value
28
+ props.onChange?.(
29
+ `${splited[0] || ''} ${splited[1] || ''} ${splited[2] || ''} ${
30
+ splited[3] || ''
31
+ } ${splited[4] || ''}`
32
+ )
33
+ },
34
+ }
35
+ }
36
+ return (0, jsx_runtime_1.jsxs)(FoldItem_1.FoldItem, {
37
+ className: (0, classnames_1.default)(prefix, props.className),
38
+ style: props.style,
39
+ label: field.title,
40
+ children: [
41
+ (0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Base, {
42
+ children: (0, jsx_runtime_1.jsx)(ColorInput_1.ColorInput, {
43
+ ...createBoxShadowConnector(4),
44
+ }),
45
+ }),
46
+ (0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Extra, {
47
+ children: (0, jsx_runtime_1.jsxs)(InputItems_1.InputItems, {
48
+ width: '50%',
49
+ children: [
50
+ (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, {
51
+ icon: 'AxisX',
52
+ children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, {
53
+ exclude: ['inherit', 'auto'],
54
+ ...createBoxShadowConnector(0),
55
+ }),
56
+ }),
57
+ (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, {
58
+ icon: 'AxisY',
59
+ children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, {
60
+ exclude: ['inherit', 'auto'],
61
+ ...createBoxShadowConnector(1),
62
+ }),
63
+ }),
64
+ (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, {
65
+ icon: 'Blur',
66
+ children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, {
67
+ exclude: ['inherit', 'auto'],
68
+ ...createBoxShadowConnector(2),
69
+ }),
70
+ }),
71
+ (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, {
72
+ icon: 'Shadow',
73
+ children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, {
74
+ exclude: ['inherit', 'auto'],
75
+ ...createBoxShadowConnector(3),
76
+ }),
77
+ }),
78
+ ],
79
+ }),
80
+ }),
81
+ ],
82
+ })
83
+ })
@@ -1,9 +1,9 @@
1
- import React from 'react';
1
+ import React from 'react'
2
2
  export interface IMarginStyleSetterProps {
3
- className?: string;
4
- style?: React.CSSProperties;
5
- labels?: React.ReactNode[];
6
- value?: string;
7
- onChange?: (value: string) => void;
3
+ className?: string
4
+ style?: React.CSSProperties
5
+ labels?: React.ReactNode[]
6
+ value?: string
7
+ onChange?: (value: string) => void
8
8
  }
9
- export declare const BoxStyleSetter: React.FC<IMarginStyleSetterProps>;
9
+ export declare const BoxStyleSetter: React.FC<IMarginStyleSetterProps>
@@ -1,55 +1,125 @@
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"));
1
+ 'use strict'
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod }
6
+ }
7
+ Object.defineProperty(exports, '__esModule', { value: true })
8
+ exports.BoxStyleSetter = void 0
9
+ const jsx_runtime_1 = require('react/jsx-runtime')
10
+ const react_1 = require('@formily/react')
11
+ const designable_react_1 = require('@thienvu18/designable-react')
12
+ const FoldItem_1 = require('../FoldItem')
13
+ const SizeInput_1 = require('../SizeInput')
14
+ const InputItems_1 = require('../InputItems')
15
+ const classnames_1 = __importDefault(require('classnames'))
14
16
  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\.+-]+))?)?)?/;
17
+ top: 1,
18
+ right: 2,
19
+ bottom: 3,
20
+ left: 4,
21
+ all: 1,
22
+ }
23
+ const BoxRex =
24
+ /([\d\.]+[^\d\s\.+-]+)(?:\s+([\d\.]+[^\d\s\.+-]+)(?:\s+([\d\.]+[^\d\s\.+-]+)(?:\s+([\d\.]+[^\d\s\.+-]+))?)?)?/
22
25
  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
- ];
26
+ (0, jsx_runtime_1.jsx)(
27
+ designable_react_1.IconWidget,
28
+ { infer: 'Top', size: 16 },
29
+ '1'
30
+ ),
31
+ (0, jsx_runtime_1.jsx)(
32
+ designable_react_1.IconWidget,
33
+ { infer: 'Right', size: 16 },
34
+ '2'
35
+ ),
36
+ (0, jsx_runtime_1.jsx)(
37
+ designable_react_1.IconWidget,
38
+ { infer: 'Bottom', size: 16 },
39
+ '3'
40
+ ),
41
+ (0, jsx_runtime_1.jsx)(
42
+ designable_react_1.IconWidget,
43
+ { infer: 'Left', size: 16 },
44
+ '4'
45
+ ),
46
+ ]
28
47
  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
- });
48
+ const { labels = defaultLabels, className } = props
49
+ const field = (0, react_1.useField)()
50
+ const prefix = (0, designable_react_1.usePrefix)('box-style-setter')
51
+ const createPositionHandler = (position, setterProps) => {
52
+ const matched = String(setterProps.value).match(BoxRex) || []
53
+ const value = matched[PositionMap[position]]
54
+ const v1 = matched[1]
55
+ const v2 = matched[2]
56
+ const v3 = matched[3]
57
+ const v4 = matched[4]
58
+ const allEqualls = v1 === v2 && v2 === v3 && v3 === v4
59
+ return {
60
+ ...setterProps,
61
+ value: position === 'all' ? (allEqualls ? v1 : undefined) : value,
62
+ onChange(val) {
63
+ if (position === 'all') {
64
+ setterProps.onChange?.(
65
+ `${val || '0px'} ${val || '0px'} ${val || '0px'} ${val || '0px'}`
66
+ )
67
+ } else {
68
+ matched[PositionMap[position]] = val
69
+ setterProps.onChange?.(
70
+ `${matched[1] || '0px'} ${matched[2] || '0px'} ${
71
+ matched[3] || '0px'
72
+ } ${matched[4] || '0px'}`
73
+ )
74
+ }
75
+ },
76
+ }
77
+ }
78
+ return (0, jsx_runtime_1.jsxs)(FoldItem_1.FoldItem, {
79
+ className: (0, classnames_1.default)(prefix, className),
80
+ label: field.title,
81
+ children: [
82
+ (0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Base, {
83
+ children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, {
84
+ ...createPositionHandler('all', props),
85
+ exclude: ['inherit', 'auto'],
86
+ }),
87
+ }),
88
+ (0, jsx_runtime_1.jsx)(FoldItem_1.FoldItem.Extra, {
89
+ children: (0, jsx_runtime_1.jsxs)(InputItems_1.InputItems, {
90
+ width: '50%',
91
+ children: [
92
+ (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, {
93
+ icon: labels[0],
94
+ children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, {
95
+ ...createPositionHandler('top', props),
96
+ exclude: ['inherit', 'auto'],
97
+ }),
98
+ }),
99
+ (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, {
100
+ icon: labels[1],
101
+ children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, {
102
+ ...createPositionHandler('right', props),
103
+ exclude: ['inherit', 'auto'],
104
+ }),
105
+ }),
106
+ (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, {
107
+ icon: labels[2],
108
+ children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, {
109
+ ...createPositionHandler('bottom', props),
110
+ exclude: ['inherit', 'auto'],
111
+ }),
112
+ }),
113
+ (0, jsx_runtime_1.jsx)(InputItems_1.InputItems.Item, {
114
+ icon: labels[3],
115
+ children: (0, jsx_runtime_1.jsx)(SizeInput_1.SizeInput, {
116
+ ...createPositionHandler('left', props),
117
+ exclude: ['inherit', 'auto'],
118
+ }),
119
+ }),
120
+ ],
121
+ }),
122
+ }),
123
+ ],
124
+ })
125
+ })
@@ -1,8 +1,8 @@
1
- import React from 'react';
2
- import './styles.less';
1
+ import React from 'react'
2
+ import './styles.less'
3
3
  export interface ICollapseItemProps {
4
- className?: string;
5
- style?: React.CSSProperties;
6
- defaultExpand?: boolean;
4
+ className?: string
5
+ style?: React.CSSProperties
6
+ defaultExpand?: boolean
7
7
  }
8
- export declare const CollapseItem: React.FC<ICollapseItemProps>;
8
+ export declare const CollapseItem: React.FC<ICollapseItemProps>
@@ -1,22 +1,50 @@
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");
1
+ 'use strict'
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod }
6
+ }
7
+ Object.defineProperty(exports, '__esModule', { value: true })
8
+ exports.CollapseItem = void 0
9
+ const jsx_runtime_1 = require('react/jsx-runtime')
10
+ const react_1 = require('react')
11
+ const react_2 = require('@formily/react')
12
+ const designable_react_1 = require('@thienvu18/designable-react')
13
+ const classnames_1 = __importDefault(require('classnames'))
14
+ require('./styles.less')
13
15
  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
- });
16
+ const prefix = (0, designable_react_1.usePrefix)('collapse-item')
17
+ const field = (0, react_2.useField)()
18
+ const [expand, setExpand] = (0, react_1.useState)(props.defaultExpand ?? true)
19
+ return (0, jsx_runtime_1.jsxs)('div', {
20
+ className: (0, classnames_1.default)(prefix, props.className, { expand }),
21
+ style: props.style,
22
+ children: [
23
+ (0, jsx_runtime_1.jsxs)('div', {
24
+ className: prefix + '-header',
25
+ onClick: (e) => {
26
+ e.stopPropagation()
27
+ e.preventDefault()
28
+ setExpand(!expand)
29
+ },
30
+ children: [
31
+ (0, jsx_runtime_1.jsx)('div', {
32
+ className: prefix + '-header-expand',
33
+ children: (0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, {
34
+ infer: 'Expand',
35
+ size: 10,
36
+ }),
37
+ }),
38
+ (0, jsx_runtime_1.jsx)('div', {
39
+ className: prefix + '-header-content',
40
+ children: field.title,
41
+ }),
42
+ ],
43
+ }),
44
+ (0, jsx_runtime_1.jsx)('div', {
45
+ className: prefix + '-content',
46
+ children: props.children,
47
+ }),
48
+ ],
49
+ })
50
+ })