@vertigis/react-ui 11.35.1 → 12.0.1
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.
- package/Autocomplete/index.d.ts +1 -0
- package/Autocomplete/index.js +1 -0
- package/ColorInput/ColorInput.js +2 -2
- package/FormLabelAutocompleteField/FormLabelAutocompleteField .d.ts +37 -0
- package/FormLabelAutocompleteField/FormLabelAutocompleteField .js +20 -0
- package/FormLabelAutocompleteField/index.d.ts +2 -0
- package/FormLabelAutocompleteField/index.js +2 -0
- package/SymbolInput/FontInput.d.ts +28 -0
- package/SymbolInput/FontInput.js +101 -0
- package/SymbolInput/SimpleFillSymbolInput.d.ts +49 -0
- package/SymbolInput/SimpleFillSymbolInput.js +175 -0
- package/SymbolInput/SimpleLineSymbolInput.d.ts +38 -0
- package/SymbolInput/SimpleLineSymbolInput.js +125 -0
- package/SymbolInput/SimpleMarkerSymbolInput.d.ts +38 -0
- package/SymbolInput/SimpleMarkerSymbolInput.js +162 -0
- package/SymbolInput/SymbolInput.d.ts +15 -64
- package/SymbolInput/SymbolInput.js +18 -449
- package/SymbolInput/SymbolJson.d.ts +111 -1
- package/SymbolInput/TextSymbolInput.d.ts +58 -0
- package/SymbolInput/TextSymbolInput.js +131 -0
- package/SymbolInput/UnsupportedSymbol.d.ts +21 -0
- package/SymbolInput/UnsupportedSymbol.js +22 -0
- package/SymbolInput/fonts.d.ts +9 -0
- package/SymbolInput/fonts.js +352 -0
- package/SymbolInput/utilities.d.ts +83 -0
- package/SymbolInput/utilities.js +158 -0
- package/package.json +1 -1
|
@@ -1,457 +1,26 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import SimpleFillSymbolInput, {} from "./SimpleFillSymbolInput.js";
|
|
3
|
+
import SimpleLineSymbolInput, {} from "./SimpleLineSymbolInput.js";
|
|
4
|
+
import SimpleMarkerSymbolInput, {} from "./SimpleMarkerSymbolInput.js";
|
|
5
|
+
import TextSymbolInput, {} from "./TextSymbolInput.js";
|
|
6
|
+
import UnsupportedSymbol from "./UnsupportedSymbol.js";
|
|
3
7
|
import Box, {} from "../Box/index.js";
|
|
4
|
-
import FormLabelColorField, {} from "../FormLabelColorField/index.js";
|
|
5
|
-
import FormLabelSliderField, {} from "../FormLabelSliderField/index.js";
|
|
6
|
-
import FormLabelTextField, {} from "../FormLabelTextField/index.js";
|
|
7
|
-
import Typography from "../Typography/index.js";
|
|
8
8
|
export function symbolIsSupported(symbol) {
|
|
9
9
|
const type = symbol.type;
|
|
10
|
-
return type === "esriSMS" || type === "esriSLS" || type === "esriSFS";
|
|
10
|
+
return type === "esriSMS" || type === "esriSLS" || type === "esriSFS" || type === "esriTS";
|
|
11
11
|
}
|
|
12
12
|
const SymbolInput = props => {
|
|
13
|
-
const { onChange, symbol, languageResources, colorResources, children,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const { onChange, symbol, languageResources, colorResources, children, isSupported = symbolIsSupported, AutoCompleteComponent, TextInputComponent, NumberInputComponent, ColorInputComponent, textSymbolDisplayOptions, ...other } = props;
|
|
14
|
+
const symbolProps = {
|
|
15
|
+
onChange,
|
|
16
|
+
symbol,
|
|
17
|
+
languageResources,
|
|
18
|
+
colorResources,
|
|
19
|
+
TextInputComponent,
|
|
20
|
+
NumberInputComponent,
|
|
21
|
+
ColorInputComponent,
|
|
17
22
|
};
|
|
18
|
-
const isSupportedSymbol = isSupported(symbol);
|
|
19
|
-
|
|
20
|
-
const colors = { ...DEFAULT_COLORS, ...colorResources };
|
|
21
|
-
const { type } = symbol;
|
|
22
|
-
const FormTextInput = TextInputComponent ?? FormLabelTextField;
|
|
23
|
-
const FormNumberInput = NumberInputComponent ?? FormLabelSliderField;
|
|
24
|
-
const FormColorInput = ColorInputComponent ?? FormLabelColorField;
|
|
25
|
-
const [lineStyle, setLineStyle] = useState(getLineStyle(symbol));
|
|
26
|
-
const [fillStyle, setFillStyle] = useState(getFillStyle(symbol));
|
|
27
|
-
const [lineColor, setLineColor] = useState(getLineColor(symbol));
|
|
28
|
-
const [fillColor, setFillColor] = useState(getFillColor(symbol));
|
|
29
|
-
const [lineWidth, setLineWidth] = useState(getLineWidth(symbol));
|
|
30
|
-
const [markerStyle, setMarkerStyle] = useState(getMarkerProperty(symbol, "style"));
|
|
31
|
-
const [markerSize, setMarkerSize] = useState(getMarkerProperty(symbol, "size") ?? 1);
|
|
32
|
-
const [markerAngle, setMarkerAngle] = useState(getMarkerProperty(symbol, "angle") ?? 0);
|
|
33
|
-
const [xOffset, setXOffset] = useState(getMarkerProperty(symbol, "xoffset") ?? 0);
|
|
34
|
-
const [yOffset, setYOffset] = useState(getMarkerProperty(symbol, "yoffset") ?? 0);
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
setLineColor(getLineColor(symbol));
|
|
37
|
-
setLineStyle(getLineStyle(symbol));
|
|
38
|
-
setLineWidth(getLineWidth(symbol));
|
|
39
|
-
setFillColor(getFillColor(symbol));
|
|
40
|
-
setFillStyle(getFillStyle(symbol));
|
|
41
|
-
setMarkerAngle(getMarkerProperty(symbol, "angle") ?? 0);
|
|
42
|
-
setMarkerSize(getMarkerProperty(symbol, "size") ?? 1);
|
|
43
|
-
setMarkerStyle(getMarkerProperty(symbol, "style"));
|
|
44
|
-
setXOffset(getMarkerProperty(symbol, "xoffset") ?? 0);
|
|
45
|
-
setYOffset(getMarkerProperty(symbol, "yoffset") ?? 0);
|
|
46
|
-
}, [symbol]);
|
|
47
|
-
const handleLineWidthBlur = useCallback((event) => {
|
|
48
|
-
setLineWidth(Math.min(100, Math.max(0, lineWidth ?? 0)));
|
|
49
|
-
LineWidthProps?.onBlur?.(event);
|
|
50
|
-
}, [lineWidth, LineWidthProps]);
|
|
51
|
-
const handleMarkerSizeBlur = useCallback((event) => {
|
|
52
|
-
setMarkerSize(Math.min(100, Math.max(0, markerSize ?? 0)));
|
|
53
|
-
MarkerSizeProps?.onBlur?.(event);
|
|
54
|
-
}, [markerSize, MarkerSizeProps]);
|
|
55
|
-
const handleXOffsetBlur = useCallback((event) => {
|
|
56
|
-
setXOffset(Math.min(100, Math.max(0, xOffset ?? 0)));
|
|
57
|
-
MarkerXOffsetProps?.onBlur?.(event);
|
|
58
|
-
}, [xOffset, MarkerXOffsetProps]);
|
|
59
|
-
const handleYOffsetBlur = useCallback((event) => {
|
|
60
|
-
setYOffset(Math.min(100, Math.max(0, yOffset ?? 0)));
|
|
61
|
-
MarkerYOffsetProps?.onBlur?.(event);
|
|
62
|
-
}, [yOffset, MarkerYOffsetProps]);
|
|
63
|
-
const handleMarkerAngleBlur = useCallback((event) => {
|
|
64
|
-
setMarkerAngle(Math.min(360, Math.max(0, markerAngle ?? 0)));
|
|
65
|
-
MarkerAngleProps?.onBlur?.(event);
|
|
66
|
-
}, [markerAngle, MarkerAngleProps]);
|
|
67
|
-
// The rule is correct, but without the useless constraint, the TSX parser
|
|
68
|
-
// gets confused and tries to interpret it as a React element.
|
|
69
|
-
//
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
71
|
-
const handleStateChange = (state, propName, setState) => {
|
|
72
|
-
setState(state);
|
|
73
|
-
onChange?.(getCurrentProperties({ [propName]: state }));
|
|
74
|
-
};
|
|
75
|
-
const getCurrentProperties = (newState = {}) => {
|
|
76
|
-
switch (type) {
|
|
77
|
-
case "esriSFS":
|
|
78
|
-
return {
|
|
79
|
-
type,
|
|
80
|
-
color: newState.fillColor ?? fillColor,
|
|
81
|
-
outline: {
|
|
82
|
-
color: newState.lineColor ?? lineColor,
|
|
83
|
-
width: newState.lineWidth ?? lineWidth,
|
|
84
|
-
style: newState.lineStyle ?? lineStyle,
|
|
85
|
-
type: "esriSLS",
|
|
86
|
-
},
|
|
87
|
-
style: newState.fillStyle ?? fillStyle,
|
|
88
|
-
};
|
|
89
|
-
case "esriSLS":
|
|
90
|
-
return {
|
|
91
|
-
type,
|
|
92
|
-
color: newState.lineColor ?? lineColor,
|
|
93
|
-
width: newState.lineWidth ?? lineWidth,
|
|
94
|
-
style: newState.lineStyle ?? lineStyle,
|
|
95
|
-
};
|
|
96
|
-
case "esriSMS":
|
|
97
|
-
return {
|
|
98
|
-
type,
|
|
99
|
-
color: newState.fillColor ?? fillColor,
|
|
100
|
-
outline: {
|
|
101
|
-
color: newState.lineColor ?? lineColor,
|
|
102
|
-
width: newState.lineWidth ?? lineWidth,
|
|
103
|
-
style: newState.lineStyle ?? lineStyle,
|
|
104
|
-
type: "esriSLS",
|
|
105
|
-
},
|
|
106
|
-
style: newState.markerStyle ?? markerStyle,
|
|
107
|
-
size: newState.markerSize ?? markerSize,
|
|
108
|
-
angle: newState.markerAngle ?? markerAngle,
|
|
109
|
-
xoffset: newState.xOffset ?? xOffset,
|
|
110
|
-
yoffset: newState.yOffset ?? yOffset,
|
|
111
|
-
};
|
|
112
|
-
default:
|
|
113
|
-
return { type };
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
return (_jsxs(Box, { ...other, children: [!isSupportedSymbol && (_jsx(Typography, { sx: {
|
|
117
|
-
mb: 1,
|
|
118
|
-
p: 0.5,
|
|
119
|
-
backgroundColor: colors.errorBackground,
|
|
120
|
-
color: colors.errorForeground,
|
|
121
|
-
borderRadius: 1,
|
|
122
|
-
}, children: text.symbolUnsupportedErrorMessage })), children, isSupportedSymbol ? (_jsxs(_Fragment, { children: [_jsx(FormColorInput, { fullWidth: true, ...LineColorProps, label: text.lineColorTitle, onChange: (value) => {
|
|
123
|
-
handleStateChange(toColor(value), "lineColor", setLineColor);
|
|
124
|
-
LineColorProps?.onChange?.(value);
|
|
125
|
-
}, value: toRgbaString(lineColor), disabled: !isSupportedSymbol || LineColorProps?.disabled }), type !== "esriSMS" && (_jsx(FormTextInput, { fullWidth: true, ...LineStyleProps, nativeSelect: true, label: text.lineStyleTitle, value: lineStyle, onChange: event => {
|
|
126
|
-
const { value } = event.target;
|
|
127
|
-
handleStateChange(value, "lineStyle", setLineStyle);
|
|
128
|
-
LineStyleProps?.onChange?.(event);
|
|
129
|
-
}, disabled: !isSupportedSymbol || LineStyleProps?.disabled, children: getSimpleLineStyles(text).map(ls => (_jsx("option", { value: ls.id, children: ls.label }, ls.id))) })), _jsx(FormNumberInput, { fullWidth: true, ...LineWidthProps, SliderProps: {
|
|
130
|
-
step: 0.5,
|
|
131
|
-
min: 0,
|
|
132
|
-
max: 25,
|
|
133
|
-
...LineWidthProps?.SliderProps,
|
|
134
|
-
disabled: !isSupportedSymbol || LineWidthProps?.SliderProps?.disabled,
|
|
135
|
-
}, InputProps: {
|
|
136
|
-
onBlur: handleLineWidthBlur,
|
|
137
|
-
min: 0,
|
|
138
|
-
max: 25,
|
|
139
|
-
...LineWidthProps?.InputProps,
|
|
140
|
-
disabled: !isSupportedSymbol || LineWidthProps?.InputProps?.disabled,
|
|
141
|
-
}, label: text.lineWidthTitle, value: lineWidth, onChange: value => {
|
|
142
|
-
handleStateChange(value, "lineWidth", setLineWidth);
|
|
143
|
-
LineWidthProps?.onChange?.(value);
|
|
144
|
-
} }), type === "esriSFS" && (_jsxs(_Fragment, { children: [_jsx(FormColorInput, { fullWidth: true, ...FillColorProps, label: text.fillColorTitle, onChange: (value) => {
|
|
145
|
-
handleStateChange(toColor(value), "fillColor", setFillColor);
|
|
146
|
-
FillColorProps?.onChange?.(value);
|
|
147
|
-
}, value: toRgbaString(fillColor), disabled: !isSupportedSymbol || FillColorProps?.disabled }), _jsx(FormTextInput, { fullWidth: true, ...FillStyleProps, nativeSelect: true, label: text.fillStyleTitle, value: fillStyle, onChange: event => {
|
|
148
|
-
const { value } = event.target;
|
|
149
|
-
handleStateChange(value, "fillStyle", setFillStyle);
|
|
150
|
-
FillStyleProps?.onChange?.(event);
|
|
151
|
-
}, disabled: !isSupportedSymbol || FillStyleProps?.disabled, children: getSimpleFillStyles(text).map(fillStyle => (_jsx("option", { value: fillStyle.id, children: fillStyle.label }, fillStyle.id))) })] })), type === "esriSMS" && (_jsxs(_Fragment, { children: [_jsx(FormColorInput, { fullWidth: true, ...FillColorProps, label: text.fillColorTitle, onChange: (value) => {
|
|
152
|
-
handleStateChange(toColor(value), "fillColor", setFillColor);
|
|
153
|
-
FillColorProps?.onChange?.(value);
|
|
154
|
-
}, value: toRgbaString(fillColor), disabled: !isSupportedSymbol ||
|
|
155
|
-
NO_FILL_MARKER_STYLES.includes(markerStyle) ||
|
|
156
|
-
FillColorProps?.disabled }), _jsx(FormTextInput, { fullWidth: true, ...MarkerStyleProps, nativeSelect: true, label: text.markerStyleTitle, value: markerStyle, onChange: event => {
|
|
157
|
-
const { value } = event.target;
|
|
158
|
-
handleStateChange(value, "markerStyle", setMarkerStyle);
|
|
159
|
-
MarkerStyleProps?.onChange?.(event);
|
|
160
|
-
}, disabled: !isSupportedSymbol || MarkerStyleProps?.disabled, children: getSimpleMarkerStyles(text).map(markerStyle => (_jsx("option", { value: markerStyle.id, children: markerStyle.label }, markerStyle.id))) }), _jsx(FormNumberInput, { fullWidth: true, ...MarkerSizeProps, label: text.markerSizeTitle, value: markerSize, onChange: value => {
|
|
161
|
-
handleStateChange(value, "markerSize", setMarkerSize);
|
|
162
|
-
MarkerSizeProps?.onChange?.(value);
|
|
163
|
-
}, SliderProps: {
|
|
164
|
-
step: 1,
|
|
165
|
-
min: 0,
|
|
166
|
-
max: 25,
|
|
167
|
-
...MarkerSizeProps?.SliderProps,
|
|
168
|
-
disabled: !isSupportedSymbol ||
|
|
169
|
-
MarkerSizeProps?.SliderProps?.disabled,
|
|
170
|
-
}, InputProps: {
|
|
171
|
-
min: 0,
|
|
172
|
-
max: 25,
|
|
173
|
-
...MarkerSizeProps?.InputProps,
|
|
174
|
-
onBlur: handleMarkerSizeBlur,
|
|
175
|
-
disabled: !isSupportedSymbol || MarkerSizeProps?.disabled,
|
|
176
|
-
} }), _jsx(FormNumberInput, { fullWidth: true, ...MarkerAngleProps, label: text.markerAngleTitle, value: markerAngle, onChange: value => {
|
|
177
|
-
handleStateChange(value, "markerAngle", setMarkerAngle);
|
|
178
|
-
MarkerAngleProps?.onChange?.(value);
|
|
179
|
-
}, SliderProps: {
|
|
180
|
-
step: 1,
|
|
181
|
-
min: 0,
|
|
182
|
-
max: 360,
|
|
183
|
-
...MarkerAngleProps?.SliderProps,
|
|
184
|
-
disabled: !isSupportedSymbol ||
|
|
185
|
-
MarkerAngleProps?.SliderProps?.disabled,
|
|
186
|
-
}, InputProps: {
|
|
187
|
-
min: 0,
|
|
188
|
-
max: 360,
|
|
189
|
-
...MarkerAngleProps?.InputProps,
|
|
190
|
-
onBlur: handleMarkerAngleBlur,
|
|
191
|
-
disabled: !isSupportedSymbol ||
|
|
192
|
-
MarkerAngleProps?.InputProps?.disabled,
|
|
193
|
-
} }), _jsx(FormNumberInput, { fullWidth: true, ...MarkerXOffsetProps, label: text.xOffsetTitle, value: xOffset, onChange: value => {
|
|
194
|
-
handleStateChange(value, "xOffset", setXOffset);
|
|
195
|
-
MarkerXOffsetProps?.onChange?.(value);
|
|
196
|
-
}, SliderProps: {
|
|
197
|
-
step: 1,
|
|
198
|
-
min: -25,
|
|
199
|
-
max: 25,
|
|
200
|
-
...MarkerXOffsetProps?.SliderProps,
|
|
201
|
-
disabled: !isSupportedSymbol ||
|
|
202
|
-
MarkerXOffsetProps?.SliderProps?.disabled,
|
|
203
|
-
}, InputProps: {
|
|
204
|
-
min: -25,
|
|
205
|
-
max: 25,
|
|
206
|
-
...MarkerXOffsetProps?.InputProps,
|
|
207
|
-
onBlur: handleXOffsetBlur,
|
|
208
|
-
disabled: !isSupportedSymbol ||
|
|
209
|
-
MarkerXOffsetProps?.InputProps?.disabled,
|
|
210
|
-
} }), _jsx(FormNumberInput, { fullWidth: true, ...MarkerYOffsetProps, label: text.yOffsetTitle, value: yOffset, onChange: value => {
|
|
211
|
-
handleStateChange(value, "yOffset", setYOffset);
|
|
212
|
-
MarkerYOffsetProps?.onChange?.(value);
|
|
213
|
-
}, SliderProps: {
|
|
214
|
-
step: 1,
|
|
215
|
-
min: -25,
|
|
216
|
-
max: 25,
|
|
217
|
-
...MarkerYOffsetProps?.SliderProps,
|
|
218
|
-
disabled: !isSupportedSymbol ||
|
|
219
|
-
MarkerYOffsetProps?.SliderProps?.disabled,
|
|
220
|
-
}, InputProps: {
|
|
221
|
-
min: -25,
|
|
222
|
-
max: 25,
|
|
223
|
-
...MarkerYOffsetProps?.InputProps,
|
|
224
|
-
onBlur: handleYOffsetBlur,
|
|
225
|
-
disabled: !isSupportedSymbol ||
|
|
226
|
-
MarkerYOffsetProps?.InputProps?.disabled,
|
|
227
|
-
} })] }))] })) : null] }));
|
|
23
|
+
const isSupportedSymbol = symbolIsSupported(symbol) && isSupported(symbol);
|
|
24
|
+
return (_jsxs(Box, { ...other, children: [!isSupportedSymbol && _jsx(UnsupportedSymbol, { ...props }), children, symbol.type === "esriSFS" && (_jsx(SimpleFillSymbolInput, { ...symbolProps, isSupported: props.isSupported })), symbol.type === "esriSLS" && (_jsx(SimpleLineSymbolInput, { ...symbolProps, isSupported: props.isSupported })), symbol.type === "esriSMS" && (_jsx(SimpleMarkerSymbolInput, { ...symbolProps, isSupported: props.isSupported })), symbol.type === "esriTS" && (_jsx(TextSymbolInput, { ...symbolProps, isSupported: props.isSupported, AutoCompleteComponent: AutoCompleteComponent, displayOptions: textSymbolDisplayOptions }))] }));
|
|
228
25
|
};
|
|
229
26
|
export default SymbolInput;
|
|
230
|
-
const DEFAULT_LANGUAGE = {
|
|
231
|
-
fillColorTitle: "Fill Color",
|
|
232
|
-
fillStyleTitle: "Fill Style",
|
|
233
|
-
lineColorTitle: "Line Color",
|
|
234
|
-
lineStyleTitle: "Line Style",
|
|
235
|
-
lineWidthTitle: "Line Width",
|
|
236
|
-
markerAngleTitle: "Marker Angle",
|
|
237
|
-
xOffsetTitle: "X Offset",
|
|
238
|
-
yOffsetTitle: "Y Offset",
|
|
239
|
-
markerSizeTitle: "Marker Size",
|
|
240
|
-
markerStyleTitle: "Marker Style",
|
|
241
|
-
symbolUnsupportedErrorMessage: "You are attempting to edit a symbol that is not currently supported.",
|
|
242
|
-
markerStyleCircle: "Circle",
|
|
243
|
-
markerStyleCross: "Cross",
|
|
244
|
-
markerStyleDiamond: "Diamond",
|
|
245
|
-
markerStyleSquare: "Square",
|
|
246
|
-
markerStyleTriangle: "Triangle",
|
|
247
|
-
markerStyleX: "X",
|
|
248
|
-
lineStyleDash: "Dash",
|
|
249
|
-
lineStyleDashDot: "Dash Dot",
|
|
250
|
-
lineStyleDot: "Dot",
|
|
251
|
-
lineStyleLongDashDot: "Long Dash Dot",
|
|
252
|
-
lineStyleLongDash: "Long Dash",
|
|
253
|
-
lineStyleNone: "None",
|
|
254
|
-
lineStyleShortDashDotDot: "Short Dash Dot Dot",
|
|
255
|
-
lineStyleShortDashDot: "Short Dash Dot",
|
|
256
|
-
lineStyleShortDash: "Short Dash",
|
|
257
|
-
lineStyleShortDot: "Short Dot",
|
|
258
|
-
lineStyleSolid: "Solid",
|
|
259
|
-
fillStyleBackwardDiagonal: "Backward Diagonal",
|
|
260
|
-
fillStyleCross: "Cross",
|
|
261
|
-
fillStyleDiagonalCross: "Diagonal Cross",
|
|
262
|
-
fillStyleForwardDiagonal: "Forward Diagonal",
|
|
263
|
-
fillStyleHorizontal: "Horizontal",
|
|
264
|
-
fillStyleNone: "None",
|
|
265
|
-
fillStyleSolid: "Solid",
|
|
266
|
-
fillStyleVertical: "Vertical",
|
|
267
|
-
};
|
|
268
|
-
const DEFAULT_COLORS = {
|
|
269
|
-
errorBackground: "#B22222",
|
|
270
|
-
errorForeground: "#FFFFFF",
|
|
271
|
-
};
|
|
272
|
-
const NO_FILL_MARKER_STYLES = ["esriSMSCross", "esriSMSX"];
|
|
273
|
-
const DEFAULT_PARSE_NUMBER = (s) => (typeof s === "string" ? +s : 0);
|
|
274
|
-
const DEFAULT_FORMAT_NUMBER = (n) => typeof n === "number" ? `${n}` : "0";
|
|
275
|
-
const getSimpleFillStyles = (t) => {
|
|
276
|
-
return [
|
|
277
|
-
{
|
|
278
|
-
id: "esriSFSBackwardDiagonal",
|
|
279
|
-
label: t.fillStyleBackwardDiagonal,
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
id: "esriSFSCross",
|
|
283
|
-
label: t.fillStyleCross,
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
id: "esriSFSDiagonalCross",
|
|
287
|
-
label: t.fillStyleDiagonalCross,
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
id: "esriSFSForwardDiagonal",
|
|
291
|
-
label: t.fillStyleForwardDiagonal,
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
id: "esriSFSHorizontal",
|
|
295
|
-
label: t.fillStyleHorizontal,
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
id: "esriSFSNull",
|
|
299
|
-
label: t.fillStyleNone,
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
id: "esriSFSSolid",
|
|
303
|
-
label: t.fillStyleSolid,
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
id: "esriSFSVertical",
|
|
307
|
-
label: t.fillStyleVertical,
|
|
308
|
-
},
|
|
309
|
-
];
|
|
310
|
-
};
|
|
311
|
-
const getSimpleLineStyles = (t) => {
|
|
312
|
-
return [
|
|
313
|
-
{
|
|
314
|
-
id: "esriSLSDash",
|
|
315
|
-
label: t.lineStyleDash,
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
id: "esriSLSDashDot",
|
|
319
|
-
label: t.lineStyleDashDot,
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
id: "esriSLSDot",
|
|
323
|
-
label: t.lineStyleDot,
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
id: "esriSLSLongDash",
|
|
327
|
-
label: t.lineStyleLongDash,
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
id: "esriSLSLongDashDot",
|
|
331
|
-
label: t.lineStyleLongDashDot,
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
id: "esriSLSNull",
|
|
335
|
-
label: t.lineStyleNone,
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
id: "esriSLSShortDash",
|
|
339
|
-
label: t.lineStyleShortDash,
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
id: "esriSLSShortDashDot",
|
|
343
|
-
label: t.lineStyleShortDashDot,
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
id: "esriSLSShortDashDotDot",
|
|
347
|
-
label: t.lineStyleShortDashDotDot,
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
id: "esriSLSShortDot",
|
|
351
|
-
label: t.lineStyleShortDot,
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
id: "esriSLSSolid",
|
|
355
|
-
label: t.lineStyleSolid,
|
|
356
|
-
},
|
|
357
|
-
];
|
|
358
|
-
};
|
|
359
|
-
const getSimpleMarkerStyles = (t) => {
|
|
360
|
-
return [
|
|
361
|
-
{ id: "esriSMSCircle", label: t.markerStyleCircle },
|
|
362
|
-
{ id: "esriSMSCross", label: t.markerStyleCross },
|
|
363
|
-
{ id: "esriSMSDiamond", label: t.markerStyleDiamond },
|
|
364
|
-
{ id: "esriSMSSquare", label: t.markerStyleSquare },
|
|
365
|
-
{ id: "esriSMSTriangle", label: t.markerStyleTriangle },
|
|
366
|
-
{ id: "esriSMSX", label: t.markerStyleX },
|
|
367
|
-
];
|
|
368
|
-
};
|
|
369
|
-
const getLineStyle = (symbol) => {
|
|
370
|
-
switch (symbol?.type) {
|
|
371
|
-
case "esriSMS":
|
|
372
|
-
case "esriSFS":
|
|
373
|
-
return symbol.outline?.style;
|
|
374
|
-
case "esriSLS":
|
|
375
|
-
return symbol.style;
|
|
376
|
-
default:
|
|
377
|
-
return undefined;
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
const getFillStyle = (symbol) => {
|
|
381
|
-
switch (symbol?.type) {
|
|
382
|
-
case "esriSFS":
|
|
383
|
-
return symbol.style;
|
|
384
|
-
default:
|
|
385
|
-
return undefined;
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
const getLineColor = (symbol) => {
|
|
389
|
-
switch (symbol?.type) {
|
|
390
|
-
case "esriSMS":
|
|
391
|
-
case "esriSFS":
|
|
392
|
-
return symbol.outline?.color;
|
|
393
|
-
case "esriSLS":
|
|
394
|
-
return symbol.color;
|
|
395
|
-
default:
|
|
396
|
-
return undefined;
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
const getFillColor = (symbol) => {
|
|
400
|
-
switch (symbol?.type) {
|
|
401
|
-
case "esriSMS":
|
|
402
|
-
case "esriSFS":
|
|
403
|
-
return symbol.color;
|
|
404
|
-
default:
|
|
405
|
-
return undefined;
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
const getLineWidth = (symbol) => {
|
|
409
|
-
switch (symbol?.type) {
|
|
410
|
-
case "esriSMS":
|
|
411
|
-
case "esriSFS":
|
|
412
|
-
return symbol.outline?.width;
|
|
413
|
-
case "esriSLS":
|
|
414
|
-
return symbol.width;
|
|
415
|
-
default:
|
|
416
|
-
return undefined;
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
const getMarkerProperty = (symbol, property) => {
|
|
420
|
-
if (symbol?.type !== "esriSMS") {
|
|
421
|
-
return undefined;
|
|
422
|
-
}
|
|
423
|
-
return symbol[property];
|
|
424
|
-
};
|
|
425
|
-
const toRgbaString = (color) => {
|
|
426
|
-
if (!color) {
|
|
427
|
-
return DEFAULT_RGBA_STRING;
|
|
428
|
-
}
|
|
429
|
-
const [r, g, b, a] = color;
|
|
430
|
-
const aVal = a / 255;
|
|
431
|
-
return `rgba(${r}, ${g}, ${b}, ${isNaN(aVal) ? 1 : aVal})`;
|
|
432
|
-
};
|
|
433
|
-
const toColor = (color) => {
|
|
434
|
-
if (!color) {
|
|
435
|
-
return DEFAULT_COLOR;
|
|
436
|
-
}
|
|
437
|
-
return fromRgbaString(color) ?? fromRgbString(color) ?? DEFAULT_COLOR;
|
|
438
|
-
};
|
|
439
|
-
const fromRgbString = (color) => {
|
|
440
|
-
const result = /rgb\(([\d.]+), ([\d.]+), ([\d.]+)\)/.exec(color);
|
|
441
|
-
if (result) {
|
|
442
|
-
const [, r, g, b] = result;
|
|
443
|
-
return [+r, +g, +b, 255];
|
|
444
|
-
}
|
|
445
|
-
return undefined;
|
|
446
|
-
};
|
|
447
|
-
const fromRgbaString = (color) => {
|
|
448
|
-
const result = /rgba\(([\d.]+), ([\d.]+), ([\d.]+), ([\d.]+)\)/.exec(color);
|
|
449
|
-
if (result) {
|
|
450
|
-
const [, r, g, b, a] = result;
|
|
451
|
-
const aVal = +a * 255;
|
|
452
|
-
return [+r, +g, +b, isNaN(aVal) ? 255 : aVal];
|
|
453
|
-
}
|
|
454
|
-
return undefined;
|
|
455
|
-
};
|
|
456
|
-
const DEFAULT_COLOR = [255, 255, 255, 255];
|
|
457
|
-
const DEFAULT_RGBA_STRING = "rgba(255, 255, 255, 1)";
|
|
@@ -9,7 +9,7 @@ export type SymbolJson = Symbol2DJson;
|
|
|
9
9
|
/**
|
|
10
10
|
* Symbol types used in web maps.
|
|
11
11
|
*/
|
|
12
|
-
export type Symbol2DJson = SimpleFillSymbolJson | SimpleLineSymbolJson | SimpleMarkerSymbolJson;
|
|
12
|
+
export type Symbol2DJson = SimpleFillSymbolJson | SimpleLineSymbolJson | SimpleMarkerSymbolJson | TextSymbolJson;
|
|
13
13
|
/**
|
|
14
14
|
* Color is represented as a four-element array. The four elements represent
|
|
15
15
|
* values for red, green, blue, and alpha in that order. Values range from 0
|
|
@@ -18,6 +18,33 @@ export type Symbol2DJson = SimpleFillSymbolJson | SimpleLineSymbolJson | SimpleM
|
|
|
18
18
|
* {@link https://developers.arcgis.com/web-scene-specification/objects/color/}.
|
|
19
19
|
*/
|
|
20
20
|
export type ColorJson = number[];
|
|
21
|
+
/**
|
|
22
|
+
* Font used for text symbols.
|
|
23
|
+
*
|
|
24
|
+
* See {@link https://developers.arcgis.com/web-map-specification/objects/font/}.
|
|
25
|
+
*/
|
|
26
|
+
export interface FontJson {
|
|
27
|
+
/**
|
|
28
|
+
* The font decoration.
|
|
29
|
+
*/
|
|
30
|
+
decoration?: "line-through" | "none" | "underline";
|
|
31
|
+
/**
|
|
32
|
+
* The font family.
|
|
33
|
+
*/
|
|
34
|
+
family?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The font size in points.
|
|
37
|
+
*/
|
|
38
|
+
size?: number;
|
|
39
|
+
/**
|
|
40
|
+
* The font style.
|
|
41
|
+
*/
|
|
42
|
+
style?: "italic" | "normal" | "oblique";
|
|
43
|
+
/**
|
|
44
|
+
* The text weight.
|
|
45
|
+
*/
|
|
46
|
+
weight?: "bold" | "bolder" | "lighter" | "normal";
|
|
47
|
+
}
|
|
21
48
|
/**
|
|
22
49
|
* Base class for all symbols.
|
|
23
50
|
*/
|
|
@@ -128,6 +155,89 @@ export interface SimpleMarkerSymbolJson extends SymbolJsonBase {
|
|
|
128
155
|
*/
|
|
129
156
|
type: "esriSMS";
|
|
130
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Text symbols are used to add text to a feature (labeling).
|
|
160
|
+
*
|
|
161
|
+
* See
|
|
162
|
+
* {@link https://developers.arcgis.com/web-map-specification/objects/esriTS_symbol/}.
|
|
163
|
+
*/
|
|
164
|
+
export interface TextSymbolJson extends SymbolJsonBase {
|
|
165
|
+
/**
|
|
166
|
+
* A numeric value that defines the number of degrees (0 to 360) that a text
|
|
167
|
+
* symbol is rotated. The rotation is from East in a counter-clockwise
|
|
168
|
+
* direction where East is the 0° axis.
|
|
169
|
+
*/
|
|
170
|
+
angle?: number;
|
|
171
|
+
/**
|
|
172
|
+
* Background color of the text.
|
|
173
|
+
*/
|
|
174
|
+
backgroundColor?: ColorJson;
|
|
175
|
+
/**
|
|
176
|
+
* Value indicating the the color of the border line.
|
|
177
|
+
*/
|
|
178
|
+
borderLineColor?: ColorJson;
|
|
179
|
+
/**
|
|
180
|
+
* Numeric value indicating the the size of the border line in points.
|
|
181
|
+
*/
|
|
182
|
+
borderLineSize?: number;
|
|
183
|
+
/**
|
|
184
|
+
* Color is represented as a four-element array. The four elements represent
|
|
185
|
+
* values for red, green, blue, and alpha in that order. Values range from 0
|
|
186
|
+
* through 255. If color is undefined for a symbol, the color value is
|
|
187
|
+
* null.
|
|
188
|
+
*/
|
|
189
|
+
color?: ColorJson;
|
|
190
|
+
/**
|
|
191
|
+
* Font used for text symbols.
|
|
192
|
+
*/
|
|
193
|
+
font?: FontJson;
|
|
194
|
+
/**
|
|
195
|
+
* Color of the halo around the text.
|
|
196
|
+
*/
|
|
197
|
+
haloColor?: ColorJson;
|
|
198
|
+
/**
|
|
199
|
+
* Numeric value indicating the point size of a halo around the text symbol.
|
|
200
|
+
*/
|
|
201
|
+
haloSize?: number;
|
|
202
|
+
/**
|
|
203
|
+
* The horizontal alignment of the text.
|
|
204
|
+
*/
|
|
205
|
+
horizontalAlignment?: "left" | "right" | "center" | "justify";
|
|
206
|
+
/**
|
|
207
|
+
* Boolean value indicating whether to adjust the spacing between characters
|
|
208
|
+
* in the text string.
|
|
209
|
+
*/
|
|
210
|
+
kerning?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Boolean value, set to true if using Hebrew or Arabic fonts.
|
|
213
|
+
*/
|
|
214
|
+
rightToLeft?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Boolean value indicating whether every character in the text string is
|
|
217
|
+
* rotated.
|
|
218
|
+
*/
|
|
219
|
+
rotated?: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Only applicable when specified as a client-side graphic.
|
|
222
|
+
*/
|
|
223
|
+
text?: string;
|
|
224
|
+
/**
|
|
225
|
+
* The vertical alignment of the text.
|
|
226
|
+
*/
|
|
227
|
+
verticalAlignment?: "baseline" | "top" | "middle" | "bottom";
|
|
228
|
+
/**
|
|
229
|
+
* Numeric value indicating the offset on the x-axis in pixels.
|
|
230
|
+
*/
|
|
231
|
+
xoffset?: number;
|
|
232
|
+
/**
|
|
233
|
+
* Numeric value indicating the offset on the y-axis in pixels.
|
|
234
|
+
*/
|
|
235
|
+
yoffset?: number;
|
|
236
|
+
/**
|
|
237
|
+
* @inheritDoc
|
|
238
|
+
*/
|
|
239
|
+
type: "esriTS";
|
|
240
|
+
}
|
|
131
241
|
/**
|
|
132
242
|
* The type of the Symbol.
|
|
133
243
|
*/
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { FontInputProps } from "./FontInput.js";
|
|
3
|
+
import type { SymbolJson, TextSymbolJson } from "./SymbolJson.js";
|
|
4
|
+
import { type UnsupportedSymbolProps } from "./UnsupportedSymbol.js";
|
|
5
|
+
import type { FontFamily } from "./fonts.js";
|
|
6
|
+
import type { BoxProps } from "../Box/index.js";
|
|
7
|
+
import type { FormLabelAutocompleteFieldProps } from "../FormLabelAutocompleteField/index.js";
|
|
8
|
+
import { type FormLabelColorFieldProps } from "../FormLabelColorField/index.js";
|
|
9
|
+
import { type FormLabelSliderFieldProps } from "../FormLabelSliderField/index.js";
|
|
10
|
+
import { type FormLabelTextFieldProps } from "../FormLabelTextField/index.js";
|
|
11
|
+
export interface LanguageResources {
|
|
12
|
+
angleTitle?: string;
|
|
13
|
+
backgroundColor?: string;
|
|
14
|
+
borderLineColor?: string;
|
|
15
|
+
borderLineSize?: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
haloColor?: string;
|
|
18
|
+
haloSize?: string;
|
|
19
|
+
horizontalAlignment?: string;
|
|
20
|
+
horizontalAlignmentLeft?: string;
|
|
21
|
+
horizontalAlignmentRight?: string;
|
|
22
|
+
horizontalAlignmentCenter?: string;
|
|
23
|
+
verticalAlignment?: string;
|
|
24
|
+
verticalAlignmentBaseline?: string;
|
|
25
|
+
verticalAlignmentTop?: string;
|
|
26
|
+
verticalAlignmentMiddle?: string;
|
|
27
|
+
verticalAlignmentBottom?: string;
|
|
28
|
+
xOffsetTitle?: string;
|
|
29
|
+
yOffsetTitle?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface TextSymbolDisplayOptions {
|
|
32
|
+
showAngle?: boolean;
|
|
33
|
+
showAlignments?: boolean | {
|
|
34
|
+
showVertical?: boolean;
|
|
35
|
+
showHorizontal?: boolean;
|
|
36
|
+
};
|
|
37
|
+
showColor?: boolean;
|
|
38
|
+
showBorder?: boolean;
|
|
39
|
+
showFont?: boolean;
|
|
40
|
+
showHalo?: boolean;
|
|
41
|
+
showOffset?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface TextSymbolInputProps extends Omit<BoxProps, "onChange"> {
|
|
44
|
+
onChange: (symbol: SymbolJson) => void;
|
|
45
|
+
displayOptions?: TextSymbolDisplayOptions;
|
|
46
|
+
symbol: SymbolJson;
|
|
47
|
+
colorResources?: UnsupportedSymbolProps["colorResources"];
|
|
48
|
+
languageResources?: LanguageResources & FontInputProps["languageResources"] & UnsupportedSymbolProps["languageResources"];
|
|
49
|
+
isSupported?: (symbol: SymbolJson) => symbol is TextSymbolJson;
|
|
50
|
+
AutoCompleteComponent?: FC<FormLabelAutocompleteFieldProps<FontFamily, false, true, false>>;
|
|
51
|
+
TextInputComponent?: FC<FormLabelTextFieldProps>;
|
|
52
|
+
NumberInputComponent?: FC<FormLabelSliderFieldProps>;
|
|
53
|
+
ColorInputComponent?: FC<FormLabelColorFieldProps>;
|
|
54
|
+
fontFamilies?: FontFamily[];
|
|
55
|
+
}
|
|
56
|
+
export declare function symbolIsSupported(symbol: SymbolJson): symbol is TextSymbolJson;
|
|
57
|
+
declare const TextSymbolInput: FC<TextSymbolInputProps>;
|
|
58
|
+
export default TextSymbolInput;
|