@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,70 +1,100 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useEffect, useState, useRef } from 'react';
3
- import { Button } from 'antd';
4
- import { usePrefix, IconWidget } from '@thienvu18/designable-react';
5
- import cls from 'classnames';
6
- import './styles.less';
7
- const isValid = (val) => val !== undefined && val !== null;
1
+ import { IconWidget, usePrefix } from '@thienvu18/designable-react'
2
+ import { Button } from 'antd'
3
+ import cls from 'classnames'
4
+ import React, { useEffect, useRef, useState } from 'react'
5
+ import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
6
+ import './styles.less'
7
+ const isValid = (val) => val !== undefined && val !== null
8
8
  const getEventValue = (event) => {
9
- if (event?.target) {
10
- if (isValid(event.target.value))
11
- return event.target.value;
12
- if (isValid(event.target.checked))
13
- return event.target.checked;
14
- return;
15
- }
16
- return event;
17
- };
9
+ if (event?.target) {
10
+ if (isValid(event.target.value)) return event.target.value
11
+ if (isValid(event.target.checked)) return event.target.checked
12
+ return
13
+ }
14
+ return event
15
+ }
18
16
  const createTypes = (types, exclude, include) => {
19
- return types.filter(({ type }) => {
20
- if (Array.isArray(include) && include.length) {
21
- return include.includes(type);
22
- }
23
- if (Array.isArray(exclude) && exclude.length) {
24
- return !exclude.includes(type);
25
- }
26
- return true;
27
- });
28
- };
17
+ return types.filter(({ type }) => {
18
+ if (Array.isArray(include) && include.length) {
19
+ return include.includes(type)
20
+ }
21
+ if (Array.isArray(exclude) && exclude.length) {
22
+ return !exclude.includes(type)
23
+ }
24
+ return true
25
+ })
26
+ }
29
27
  export function createPolyInput(polyTypes = []) {
30
- return ({ className, style, value, onChange, exclude, include, ...props }) => {
31
- const prefix = usePrefix('poly-input');
32
- const types = createTypes(polyTypes, exclude, include);
33
- const [current, setCurrent] = useState(types[0]?.type);
34
- const type = types?.find(({ type }) => type === current);
35
- const component = type?.component;
36
- const typesValue = useRef({});
37
- useEffect(() => {
38
- types?.forEach(({ checker, type }) => {
39
- if (checker(value)) {
40
- setCurrent(type);
41
- }
42
- });
43
- }, [value]);
44
- const getNextType = () => {
45
- const currentIndex = types?.findIndex(({ type }) => type === current);
46
- const nextIndex = currentIndex + 1 > types?.length - 1 ? 0 : currentIndex + 1;
47
- return types[nextIndex];
48
- };
49
- const transformOnChangeValue = (value, type) => {
50
- return type?.toChangeValue ? type?.toChangeValue(value) : value;
51
- };
52
- return (_jsxs("div", { className: cls(prefix, className), style: style, children: [component && (_jsx("div", { className: prefix + '-content', children: React.createElement(component, {
53
- ...props,
54
- value: type?.toInputValue ? type?.toInputValue(value) : value,
55
- onChange: (event) => {
56
- const value = getEventValue(event);
57
- typesValue.current[type?.type] = value;
58
- onChange?.(transformOnChangeValue(value, type));
59
- },
60
- }) })), _jsx(Button, { className: prefix + '-controller', style: {
61
- width: !component ? '100%' : 'auto',
62
- }, block: true, onClick: () => {
63
- const nextType = getNextType();
64
- if (nextType === type)
65
- return;
66
- setCurrent(nextType?.type);
67
- onChange?.(transformOnChangeValue(typesValue.current[nextType?.type], nextType));
68
- }, children: type?.icon ? (_jsx(IconWidget, { infer: type.icon })) : (type?.title || type?.type) })] }));
69
- };
28
+ return ({
29
+ className,
30
+ style,
31
+ value,
32
+ onChange,
33
+ exclude,
34
+ include,
35
+ ...props
36
+ }) => {
37
+ const prefix = usePrefix('poly-input')
38
+ const types = createTypes(polyTypes, exclude, include)
39
+ const [current, setCurrent] = useState(types[0]?.type)
40
+ const type = types?.find(({ type }) => type === current)
41
+ const component = type?.component
42
+ const typesValue = useRef({})
43
+ useEffect(() => {
44
+ types?.forEach(({ checker, type }) => {
45
+ if (checker(value)) {
46
+ setCurrent(type)
47
+ }
48
+ })
49
+ }, [value])
50
+ const getNextType = () => {
51
+ const currentIndex = types?.findIndex(({ type }) => type === current)
52
+ const nextIndex =
53
+ currentIndex + 1 > types?.length - 1 ? 0 : currentIndex + 1
54
+ return types[nextIndex]
55
+ }
56
+ const transformOnChangeValue = (value, type) => {
57
+ return type?.toChangeValue ? type?.toChangeValue(value) : value
58
+ }
59
+ return _jsxs('div', {
60
+ className: cls(prefix, className),
61
+ style: style,
62
+ children: [
63
+ component &&
64
+ _jsx('div', {
65
+ className: prefix + '-content',
66
+ children: React.createElement(component, {
67
+ ...props,
68
+ value: type?.toInputValue ? type?.toInputValue(value) : value,
69
+ onChange: (event) => {
70
+ const value = getEventValue(event)
71
+ typesValue.current[type?.type] = value
72
+ onChange?.(transformOnChangeValue(value, type))
73
+ },
74
+ }),
75
+ }),
76
+ _jsx(Button, {
77
+ className: prefix + '-controller',
78
+ style: {
79
+ width: !component ? '100%' : 'auto',
80
+ },
81
+ block: true,
82
+ onClick: () => {
83
+ const nextType = getNextType()
84
+ if (nextType === type) return
85
+ setCurrent(nextType?.type)
86
+ onChange?.(
87
+ transformOnChangeValue(
88
+ typesValue.current[nextType?.type],
89
+ nextType
90
+ )
91
+ )
92
+ },
93
+ children: type?.icon
94
+ ? _jsx(IconWidget, { infer: type.icon })
95
+ : type?.title || type?.type,
96
+ }),
97
+ ],
98
+ })
99
+ }
70
100
  }
@@ -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,22 +1,49 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useEffect } from 'react';
3
- import { usePrefix } from '@thienvu18/designable-react';
4
- import cls from 'classnames';
5
- import './styles.less';
1
+ import { usePrefix } from '@thienvu18/designable-react'
2
+ import cls from 'classnames'
3
+ import { useEffect, useState } from 'react'
4
+ import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
5
+ import './styles.less'
6
6
  export const PositionInput = (props) => {
7
- const prefix = usePrefix('position-input');
8
- const [current, setCurrent] = useState(props.value);
9
- useEffect(() => {
10
- if (!props.value) {
11
- setCurrent('center');
12
- }
13
- }, [props.value]);
14
- const createCellProps = (type) => ({
15
- className: cls(prefix + '-cell', { active: current === type }),
16
- onClick() {
17
- setCurrent(type);
18
- props.onChange?.(type);
19
- },
20
- });
21
- return (_jsxs("div", { className: cls(prefix, props.className), style: props.style, children: [_jsx("div", { className: prefix + '-row', children: _jsx("div", { ...createCellProps('top'), children: "\u2533" }) }), _jsxs("div", { className: prefix + '-row', children: [_jsx("div", { ...createCellProps('left'), children: "\u2523" }), _jsx("div", { ...createCellProps('center'), children: "\u254B" }), _jsx("div", { ...createCellProps('right'), children: "\u252B" })] }), _jsx("div", { className: prefix + '-row', children: _jsx("div", { ...createCellProps('bottom'), children: "\u253B" }) })] }));
22
- };
7
+ const prefix = usePrefix('position-input')
8
+ const [current, setCurrent] = useState(props.value)
9
+ useEffect(() => {
10
+ if (!props.value) {
11
+ setCurrent('center')
12
+ }
13
+ }, [props.value])
14
+ const createCellProps = (type) => ({
15
+ className: cls(prefix + '-cell', { active: current === type }),
16
+ onClick() {
17
+ setCurrent(type)
18
+ props.onChange?.(type)
19
+ },
20
+ })
21
+ return _jsxs('div', {
22
+ className: cls(prefix, props.className),
23
+ style: props.style,
24
+ children: [
25
+ _jsx('div', {
26
+ className: prefix + '-row',
27
+ children: _jsx('div', {
28
+ ...createCellProps('top'),
29
+ children: '\u2533',
30
+ }),
31
+ }),
32
+ _jsxs('div', {
33
+ className: prefix + '-row',
34
+ children: [
35
+ _jsx('div', { ...createCellProps('left'), children: '\u2523' }),
36
+ _jsx('div', { ...createCellProps('center'), children: '\u254B' }),
37
+ _jsx('div', { ...createCellProps('right'), children: '\u252B' }),
38
+ ],
39
+ }),
40
+ _jsx('div', {
41
+ className: prefix + '-row',
42
+ children: _jsx('div', {
43
+ ...createCellProps('bottom'),
44
+ children: '\u253B',
45
+ }),
46
+ }),
47
+ ],
48
+ })
49
+ }
@@ -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,53 +1,51 @@
1
- import { InputNumber } from 'antd';
2
- import { createPolyInput } from '../PolyInput';
1
+ import { InputNumber } from 'antd'
2
+ import { createPolyInput } from '../PolyInput'
3
3
  const takeNumber = (value) => {
4
- const num = String(value)
5
- .trim()
6
- .replace(/[^\d\.]+/, '');
7
- if (num === '')
8
- return;
9
- return Number(num);
10
- };
4
+ const num = String(value)
5
+ .trim()
6
+ .replace(/[^\d\.]+/, '')
7
+ if (num === '') return
8
+ return Number(num)
9
+ }
11
10
  const createUnitType = (type) => {
12
- return {
13
- type,
14
- component: InputNumber,
15
- checker(value) {
16
- return String(value).includes(type);
17
- },
18
- toInputValue(value) {
19
- return takeNumber(value);
20
- },
21
- toChangeValue(value) {
22
- return `${value || 0}${type}`;
23
- },
24
- };
25
- };
26
- const createSpecialSizeOption = (type) => ({
27
- type: type,
11
+ return {
12
+ type,
13
+ component: InputNumber,
28
14
  checker(value) {
29
- if (value === type)
30
- return true;
31
- return false;
15
+ return String(value).includes(type)
16
+ },
17
+ toInputValue(value) {
18
+ return takeNumber(value)
32
19
  },
33
- toChangeValue() {
34
- return type;
20
+ toChangeValue(value) {
21
+ return `${value || 0}${type}`
35
22
  },
36
- });
23
+ }
24
+ }
25
+ const createSpecialSizeOption = (type) => ({
26
+ type: type,
27
+ checker(value) {
28
+ if (value === type) return true
29
+ return false
30
+ },
31
+ toChangeValue() {
32
+ return type
33
+ },
34
+ })
37
35
  const NormalSizeOptions = [
38
- createSpecialSizeOption('inherit'),
39
- createSpecialSizeOption('auto'),
40
- createUnitType('px'),
41
- createUnitType('%'),
42
- createUnitType('vh'),
43
- createUnitType('em'),
44
- ];
45
- export const SizeInput = createPolyInput(NormalSizeOptions);
36
+ createSpecialSizeOption('inherit'),
37
+ createSpecialSizeOption('auto'),
38
+ createUnitType('px'),
39
+ createUnitType('%'),
40
+ createUnitType('vh'),
41
+ createUnitType('em'),
42
+ ]
43
+ export const SizeInput = createPolyInput(NormalSizeOptions)
46
44
  export const BackgroundSizeInput = createPolyInput([
47
- createSpecialSizeOption('cover'),
48
- createSpecialSizeOption('contain'),
49
- createUnitType('px'),
50
- createUnitType('%'),
51
- createUnitType('vh'),
52
- createUnitType('em'),
53
- ]);
45
+ createSpecialSizeOption('cover'),
46
+ createSpecialSizeOption('contain'),
47
+ createUnitType('px'),
48
+ createUnitType('%'),
49
+ createUnitType('vh'),
50
+ createUnitType('em'),
51
+ ])
@@ -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>
@@ -1,81 +1,98 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createPolyInput } from '../PolyInput';
3
- import { Input, Button, Popover, InputNumber, Select } from 'antd';
4
- import { MonacoInput } from '../MonacoInput';
5
- import { TextWidget } from '@thienvu18/designable-react';
6
- const STARTTAG_REX = /<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
7
- const EXPRESSION_REX = /^\{\{([\s\S]*)\}\}$/;
8
- const isNumber = (value) => typeof value === 'number';
9
- const isBoolean = (value) => typeof value === 'boolean';
1
+ import { TextWidget } from '@thienvu18/designable-react'
2
+ import { Button, Input, InputNumber, Popover, Select } from 'antd'
3
+ import { jsx as _jsx } from 'react/jsx-runtime'
4
+ import { MonacoInput } from '../MonacoInput'
5
+ import { createPolyInput } from '../PolyInput'
6
+ const STARTTAG_REX =
7
+ /<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/
8
+ const EXPRESSION_REX = /^\{\{([\s\S]*)\}\}$/
9
+ const isNumber = (value) => typeof value === 'number'
10
+ const isBoolean = (value) => typeof value === 'boolean'
10
11
  const isExpression = (value) => {
11
- return typeof value === 'string' && EXPRESSION_REX.test(value);
12
- };
12
+ return typeof value === 'string' && EXPRESSION_REX.test(value)
13
+ }
13
14
  const isRichText = (value) => {
14
- return typeof value === 'string' && STARTTAG_REX.test(value);
15
- };
15
+ return typeof value === 'string' && STARTTAG_REX.test(value)
16
+ }
16
17
  const isNormalText = (value) => {
17
- return typeof value === 'string' && !isExpression(value) && !isRichText(value);
18
- };
18
+ return typeof value === 'string' && !isExpression(value) && !isRichText(value)
19
+ }
19
20
  const takeNumber = (value) => {
20
- const num = String(value).replace(/[^\d\.]+/, '');
21
- if (num === '')
22
- return;
23
- return Number(num);
24
- };
21
+ const num = String(value).replace(/[^\d\.]+/, '')
22
+ if (num === '') return
23
+ return Number(num)
24
+ }
25
25
  export const ValueInput = createPolyInput([
26
- {
27
- type: 'TEXT',
28
- icon: 'Text',
29
- component: Input,
30
- checker: isNormalText,
26
+ {
27
+ type: 'TEXT',
28
+ icon: 'Text',
29
+ component: Input,
30
+ checker: isNormalText,
31
+ },
32
+ {
33
+ type: 'EXPRESSION',
34
+ icon: 'Expression',
35
+ component: (props) => {
36
+ return _jsx(Popover, {
37
+ content: _jsx('div', {
38
+ style: {
39
+ width: 400,
40
+ height: 200,
41
+ marginLeft: -16,
42
+ marginRight: -16,
43
+ marginBottom: -12,
44
+ },
45
+ children: _jsx(MonacoInput, {
46
+ ...props,
47
+ language: 'javascript.expression',
48
+ }),
49
+ }),
50
+ trigger: 'click',
51
+ children: _jsx(Button, {
52
+ block: true,
53
+ children: _jsx(TextWidget, {
54
+ token: 'SettingComponents.ValueInput.expression',
55
+ }),
56
+ }),
57
+ })
31
58
  },
32
- {
33
- type: 'EXPRESSION',
34
- icon: 'Expression',
35
- component: (props) => {
36
- return (_jsx(Popover, { content: _jsx("div", { style: {
37
- width: 400,
38
- height: 200,
39
- marginLeft: -16,
40
- marginRight: -16,
41
- marginBottom: -12,
42
- }, children: _jsx(MonacoInput, { ...props, language: "javascript.expression" }) }), trigger: "click", children: _jsx(Button, { block: true, children: _jsx(TextWidget, { token: "SettingComponents.ValueInput.expression" }) }) }));
43
- },
44
- checker: isExpression,
45
- toInputValue: (value) => {
46
- if (!value || value === '{{}}')
47
- return;
48
- const matched = String(value).match(EXPRESSION_REX);
49
- return matched?.[1] || value || '';
50
- },
51
- toChangeValue: (value) => {
52
- if (!value || value === '{{}}')
53
- return;
54
- const matched = String(value).match(EXPRESSION_REX);
55
- return `{{${matched?.[1] || value || ''}}}`;
56
- },
59
+ checker: isExpression,
60
+ toInputValue: (value) => {
61
+ if (!value || value === '{{}}') return
62
+ const matched = String(value).match(EXPRESSION_REX)
63
+ return matched?.[1] || value || ''
57
64
  },
58
- {
59
- type: 'BOOLEAN',
60
- icon: 'Boolean',
61
- component: (props) => (_jsx(Select, { ...props, options: [
62
- { label: 'True', value: true },
63
- { label: 'False', value: false },
64
- ] })),
65
- checker: isBoolean,
66
- toInputValue: (value) => {
67
- return !!value;
68
- },
69
- toChangeValue: (value) => {
70
- return !!value;
71
- },
65
+ toChangeValue: (value) => {
66
+ if (!value || value === '{{}}') return
67
+ const matched = String(value).match(EXPRESSION_REX)
68
+ return `{{${matched?.[1] || value || ''}}}`
72
69
  },
73
- {
74
- type: 'NUMBER',
75
- icon: 'Number',
76
- component: InputNumber,
77
- checker: isNumber,
78
- toInputValue: takeNumber,
79
- toChangeValue: takeNumber,
70
+ },
71
+ {
72
+ type: 'BOOLEAN',
73
+ icon: 'Boolean',
74
+ component: (props) =>
75
+ _jsx(Select, {
76
+ ...props,
77
+ options: [
78
+ { label: 'True', value: true },
79
+ { label: 'False', value: false },
80
+ ],
81
+ }),
82
+ checker: isBoolean,
83
+ toInputValue: (value) => {
84
+ return !!value
80
85
  },
81
- ]);
86
+ toChangeValue: (value) => {
87
+ return !!value
88
+ },
89
+ },
90
+ {
91
+ type: 'NUMBER',
92
+ icon: 'Number',
93
+ component: InputNumber,
94
+ checker: isNumber,
95
+ toInputValue: takeNumber,
96
+ toChangeValue: takeNumber,
97
+ },
98
+ ])
@@ -1,20 +1,20 @@
1
- export * from './ColorInput';
2
- export * from './CornerInput';
3
- export * from './ImageInput';
4
- export * from './PositionInput';
5
- export * from './SizeInput';
6
- export * from './PolyInput';
7
- export * from './ValueInput';
8
- export * from './MonacoInput';
9
- export * from './DrawerSetter';
10
- export * from './BoxStyleSetter';
11
- export * from './BorderStyleSetter';
12
- export * from './BorderRadiusStyleSetter';
13
- export * from './BackgroundStyleSetter';
14
- export * from './BoxShadowStyleSetter';
15
- export * from './FontStyleSetter';
16
- export * from './DisplayStyleSetter';
17
- export * from './FlexStyleSetter';
18
- export * from './FoldItem';
19
- export * from './CollapseItem';
20
- export * from './InputItems';
1
+ export * from './BackgroundStyleSetter'
2
+ export * from './BorderRadiusStyleSetter'
3
+ export * from './BorderStyleSetter'
4
+ export * from './BoxShadowStyleSetter'
5
+ export * from './BoxStyleSetter'
6
+ export * from './CollapseItem'
7
+ export * from './ColorInput'
8
+ export * from './CornerInput'
9
+ export * from './DisplayStyleSetter'
10
+ export * from './DrawerSetter'
11
+ export * from './FlexStyleSetter'
12
+ export * from './FoldItem'
13
+ export * from './FontStyleSetter'
14
+ export * from './ImageInput'
15
+ export * from './InputItems'
16
+ export * from './MonacoInput'
17
+ export * from './PolyInput'
18
+ export * from './PositionInput'
19
+ export * from './SizeInput'
20
+ export * from './ValueInput'
@@ -1,20 +1,20 @@
1
- export * from './ColorInput';
2
- export * from './CornerInput';
3
- export * from './ImageInput';
4
- export * from './PositionInput';
5
- export * from './SizeInput';
6
- export * from './PolyInput';
7
- export * from './ValueInput';
8
- export * from './MonacoInput';
9
- export * from './DrawerSetter';
10
- export * from './BoxStyleSetter';
11
- export * from './BorderStyleSetter';
12
- export * from './BorderRadiusStyleSetter';
13
- export * from './BackgroundStyleSetter';
14
- export * from './BoxShadowStyleSetter';
15
- export * from './FontStyleSetter';
16
- export * from './DisplayStyleSetter';
17
- export * from './FlexStyleSetter';
18
- export * from './FoldItem';
19
- export * from './CollapseItem';
20
- export * from './InputItems';
1
+ export * from './BackgroundStyleSetter'
2
+ export * from './BorderRadiusStyleSetter'
3
+ export * from './BorderStyleSetter'
4
+ export * from './BoxShadowStyleSetter'
5
+ export * from './BoxStyleSetter'
6
+ export * from './CollapseItem'
7
+ export * from './ColorInput'
8
+ export * from './CornerInput'
9
+ export * from './DisplayStyleSetter'
10
+ export * from './DrawerSetter'
11
+ export * from './FlexStyleSetter'
12
+ export * from './FoldItem'
13
+ export * from './FontStyleSetter'
14
+ export * from './ImageInput'
15
+ export * from './InputItems'
16
+ export * from './MonacoInput'
17
+ export * from './PolyInput'
18
+ export * from './PositionInput'
19
+ export * from './SizeInput'
20
+ export * from './ValueInput'
@@ -1,2 +1,2 @@
1
- export * from './useLocales';
2
- export * from './useSnapshot';
1
+ export * from './useLocales'
2
+ export * from './useSnapshot'
@@ -1,2 +1,2 @@
1
- export * from './useLocales';
2
- export * from './useSnapshot';
1
+ export * from './useLocales'
2
+ export * from './useSnapshot'