@thienvu18/designable-react-settings-form 2.0.1 → 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 +4 -4
@@ -1,21 +1,21 @@
1
- import React from 'react';
2
- import './styles.less';
1
+ import React from 'react'
2
+ import './styles.less'
3
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[];
4
+ style?: React.CSSProperties
5
+ className?: string
6
+ value: any
7
+ onChange: (value: any) => void
8
+ exclude?: string[]
9
+ include?: string[]
10
10
  }
11
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;
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
19
  }
20
- export type PolyTypes = IPolyType[];
21
- export declare function createPolyInput(polyTypes?: PolyTypes): React.FC<IInput>;
20
+ export type PolyTypes = IPolyType[]
21
+ export declare function createPolyInput(polyTypes?: PolyTypes): React.FC<IInput>
@@ -1,100 +1,155 @@
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;
1
+ 'use strict'
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k
7
+ var desc = Object.getOwnPropertyDescriptor(m, k)
8
+ if (
9
+ !desc ||
10
+ ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)
11
+ ) {
12
+ desc = {
13
+ enumerable: true,
14
+ get: function () {
15
+ return m[k]
16
+ },
17
+ }
18
+ }
19
+ Object.defineProperty(o, k2, desc)
20
+ }
21
+ : function (o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k
23
+ o[k2] = m[k]
24
+ })
25
+ var __setModuleDefault =
26
+ (this && this.__setModuleDefault) ||
27
+ (Object.create
28
+ ? function (o, v) {
29
+ Object.defineProperty(o, 'default', { enumerable: true, value: v })
30
+ }
31
+ : function (o, v) {
32
+ o['default'] = v
33
+ })
34
+ var __importStar =
35
+ (this && this.__importStar) ||
36
+ function (mod) {
37
+ if (mod && mod.__esModule) return mod
38
+ var result = {}
39
+ if (mod != null)
40
+ for (var k in mod)
41
+ if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k))
42
+ __createBinding(result, mod, k)
43
+ __setModuleDefault(result, mod)
44
+ return result
45
+ }
46
+ var __importDefault =
47
+ (this && this.__importDefault) ||
48
+ function (mod) {
49
+ return mod && mod.__esModule ? mod : { default: mod }
50
+ }
51
+ Object.defineProperty(exports, '__esModule', { value: true })
52
+ exports.createPolyInput = void 0
53
+ const jsx_runtime_1 = require('react/jsx-runtime')
54
+ const react_1 = __importStar(require('react'))
55
+ const antd_1 = require('antd')
56
+ const designable_react_1 = require('@thienvu18/designable-react')
57
+ const classnames_1 = __importDefault(require('classnames'))
58
+ require('./styles.less')
59
+ const isValid = (val) => val !== undefined && val !== null
37
60
  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
- };
61
+ if (event?.target) {
62
+ if (isValid(event.target.value)) return event.target.value
63
+ if (isValid(event.target.checked)) return event.target.checked
64
+ return
65
+ }
66
+ return event
67
+ }
47
68
  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
- };
69
+ return types.filter(({ type }) => {
70
+ if (Array.isArray(include) && include.length) {
71
+ return include.includes(type)
72
+ }
73
+ if (Array.isArray(exclude) && exclude.length) {
74
+ return !exclude.includes(type)
75
+ }
76
+ return true
77
+ })
78
+ }
58
79
  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
- };
80
+ return ({
81
+ className,
82
+ style,
83
+ value,
84
+ onChange,
85
+ exclude,
86
+ include,
87
+ ...props
88
+ }) => {
89
+ const prefix = (0, designable_react_1.usePrefix)('poly-input')
90
+ const types = createTypes(polyTypes, exclude, include)
91
+ const [current, setCurrent] = (0, react_1.useState)(types[0]?.type)
92
+ const type = types?.find(({ type }) => type === current)
93
+ const component = type?.component
94
+ const typesValue = (0, react_1.useRef)({})
95
+ ;(0, react_1.useEffect)(() => {
96
+ types?.forEach(({ checker, type }) => {
97
+ if (checker(value)) {
98
+ setCurrent(type)
99
+ }
100
+ })
101
+ }, [value])
102
+ const getNextType = () => {
103
+ const currentIndex = types?.findIndex(({ type }) => type === current)
104
+ const nextIndex =
105
+ currentIndex + 1 > types?.length - 1 ? 0 : currentIndex + 1
106
+ return types[nextIndex]
107
+ }
108
+ const transformOnChangeValue = (value, type) => {
109
+ return type?.toChangeValue ? type?.toChangeValue(value) : value
110
+ }
111
+ return (0, jsx_runtime_1.jsxs)('div', {
112
+ className: (0, classnames_1.default)(prefix, className),
113
+ style: style,
114
+ children: [
115
+ component &&
116
+ (0, jsx_runtime_1.jsx)('div', {
117
+ className: prefix + '-content',
118
+ children: react_1.default.createElement(component, {
119
+ ...props,
120
+ value: type?.toInputValue ? type?.toInputValue(value) : value,
121
+ onChange: (event) => {
122
+ const value = getEventValue(event)
123
+ typesValue.current[type?.type] = value
124
+ onChange?.(transformOnChangeValue(value, type))
125
+ },
126
+ }),
127
+ }),
128
+ (0, jsx_runtime_1.jsx)(antd_1.Button, {
129
+ className: prefix + '-controller',
130
+ style: {
131
+ width: !component ? '100%' : 'auto',
132
+ },
133
+ block: true,
134
+ onClick: () => {
135
+ const nextType = getNextType()
136
+ if (nextType === type) return
137
+ setCurrent(nextType?.type)
138
+ onChange?.(
139
+ transformOnChangeValue(
140
+ typesValue.current[nextType?.type],
141
+ nextType
142
+ )
143
+ )
144
+ },
145
+ children: type?.icon
146
+ ? (0, jsx_runtime_1.jsx)(designable_react_1.IconWidget, {
147
+ infer: type.icon,
148
+ })
149
+ : type?.title || type?.type,
150
+ }),
151
+ ],
152
+ })
153
+ }
99
154
  }
100
- exports.createPolyInput = createPolyInput;
155
+ exports.createPolyInput = createPolyInput
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
- import './styles.less';
1
+ import React from 'react'
2
+ import './styles.less'
3
3
  export interface IPositionInputProps {
4
- className?: string;
5
- style?: React.CSSProperties;
6
- value?: string;
7
- onChange?: (value: string) => void;
4
+ className?: string
5
+ style?: React.CSSProperties
6
+ value?: string
7
+ onChange?: (value: string) => void
8
8
  }
9
- export declare const PositionInput: React.FC<IPositionInputProps>;
9
+ export declare const PositionInput: React.FC<IPositionInputProps>
@@ -1,29 +1,69 @@
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");
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.PositionInput = 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 classnames_1 = __importDefault(require('classnames'))
13
+ require('./styles.less')
12
14
  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;
15
+ const prefix = (0, designable_react_1.usePrefix)('position-input')
16
+ const [current, setCurrent] = (0, react_1.useState)(props.value)
17
+ ;(0, react_1.useEffect)(() => {
18
+ if (!props.value) {
19
+ setCurrent('center')
20
+ }
21
+ }, [props.value])
22
+ const createCellProps = (type) => ({
23
+ className: (0, classnames_1.default)(prefix + '-cell', {
24
+ active: current === type,
25
+ }),
26
+ onClick() {
27
+ setCurrent(type)
28
+ props.onChange?.(type)
29
+ },
30
+ })
31
+ return (0, jsx_runtime_1.jsxs)('div', {
32
+ className: (0, classnames_1.default)(prefix, props.className),
33
+ style: props.style,
34
+ children: [
35
+ (0, jsx_runtime_1.jsx)('div', {
36
+ className: prefix + '-row',
37
+ children: (0, jsx_runtime_1.jsx)('div', {
38
+ ...createCellProps('top'),
39
+ children: '\u2533',
40
+ }),
41
+ }),
42
+ (0, jsx_runtime_1.jsxs)('div', {
43
+ className: prefix + '-row',
44
+ children: [
45
+ (0, jsx_runtime_1.jsx)('div', {
46
+ ...createCellProps('left'),
47
+ children: '\u2523',
48
+ }),
49
+ (0, jsx_runtime_1.jsx)('div', {
50
+ ...createCellProps('center'),
51
+ children: '\u254B',
52
+ }),
53
+ (0, jsx_runtime_1.jsx)('div', {
54
+ ...createCellProps('right'),
55
+ children: '\u252B',
56
+ }),
57
+ ],
58
+ }),
59
+ (0, jsx_runtime_1.jsx)('div', {
60
+ className: prefix + '-row',
61
+ children: (0, jsx_runtime_1.jsx)('div', {
62
+ ...createCellProps('bottom'),
63
+ children: '\u253B',
64
+ }),
65
+ }),
66
+ ],
67
+ })
68
+ }
69
+ exports.PositionInput = PositionInput
@@ -1,4 +1,3 @@
1
-
2
1
  .dn-position-input {
3
2
  display: flex;
4
3
  flex-direction: column;
@@ -1,3 +1,7 @@
1
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>;
2
+ export declare const SizeInput: import('react').FC<
3
+ import('../PolyInput').IInput
4
+ >
5
+ export declare const BackgroundSizeInput: import('react').FC<
6
+ import('../PolyInput').IInput
7
+ >
@@ -1,56 +1,54 @@
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");
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
6
  const takeNumber = (value) => {
7
- const num = String(value)
8
- .trim()
9
- .replace(/[^\d\.]+/, '');
10
- if (num === '')
11
- return;
12
- return Number(num);
13
- };
7
+ const num = String(value)
8
+ .trim()
9
+ .replace(/[^\d\.]+/, '')
10
+ if (num === '') return
11
+ return Number(num)
12
+ }
14
13
  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,
14
+ return {
15
+ type,
16
+ component: antd_1.InputNumber,
31
17
  checker(value) {
32
- if (value === type)
33
- return true;
34
- return false;
18
+ return String(value).includes(type)
19
+ },
20
+ toInputValue(value) {
21
+ return takeNumber(value)
35
22
  },
36
- toChangeValue() {
37
- return type;
23
+ toChangeValue(value) {
24
+ return `${value || 0}${type}`
38
25
  },
39
- });
26
+ }
27
+ }
28
+ const createSpecialSizeOption = (type) => ({
29
+ type: type,
30
+ checker(value) {
31
+ if (value === type) return true
32
+ return false
33
+ },
34
+ toChangeValue() {
35
+ return type
36
+ },
37
+ })
40
38
  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);
39
+ createSpecialSizeOption('inherit'),
40
+ createSpecialSizeOption('auto'),
41
+ createUnitType('px'),
42
+ createUnitType('%'),
43
+ createUnitType('vh'),
44
+ createUnitType('em'),
45
+ ]
46
+ exports.SizeInput = (0, PolyInput_1.createPolyInput)(NormalSizeOptions)
49
47
  exports.BackgroundSizeInput = (0, PolyInput_1.createPolyInput)([
50
- createSpecialSizeOption('cover'),
51
- createSpecialSizeOption('contain'),
52
- createUnitType('px'),
53
- createUnitType('%'),
54
- createUnitType('vh'),
55
- createUnitType('em'),
56
- ]);
48
+ createSpecialSizeOption('cover'),
49
+ createSpecialSizeOption('contain'),
50
+ createUnitType('px'),
51
+ createUnitType('%'),
52
+ createUnitType('vh'),
53
+ createUnitType('em'),
54
+ ])
@@ -1,4 +1,3 @@
1
-
2
1
  .dn-size-input {
3
2
  display: flex;
4
3
  width: 100%;
@@ -1,2 +1,2 @@
1
- import React from 'react';
2
- export declare const ValueInput: React.FC<import("../PolyInput").IInput>;
1
+ import React from 'react'
2
+ export declare const ValueInput: React.FC<import('../PolyInput').IInput>