@vertigis/react-ui 11.29.1 → 11.30.0

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.
@@ -0,0 +1,77 @@
1
+ import { type FC } from "react";
2
+ import type { SymbolJson } from "./SymbolJson.js";
3
+ import { type BoxProps } from "../Box/index.js";
4
+ import { type FormLabelColorFieldProps } from "../FormLabelColorField/index.js";
5
+ import { type FormLabelSliderFieldProps } from "../FormLabelSliderField/index.js";
6
+ import { type FormLabelTextFieldProps } from "../FormLabelTextField/index.js";
7
+ export interface LanguageResources {
8
+ symbolUnsupportedErrorMessage?: string;
9
+ lineColorTitle?: string;
10
+ lineStyleTitle?: string;
11
+ lineWidthTitle?: string;
12
+ fillColorTitle?: string;
13
+ fillStyleTitle?: string;
14
+ markerSizeTitle?: string;
15
+ markerStyleTitle?: string;
16
+ markerAngleTitle?: string;
17
+ xOffsetTitle?: string;
18
+ yOffsetTitle?: string;
19
+ markerStyleCircle?: string;
20
+ markerStyleCross?: string;
21
+ markerStyleDiamond?: string;
22
+ markerStyleSquare?: string;
23
+ markerStyleTriangle?: string;
24
+ markerStyleX?: string;
25
+ lineStyleDash?: string;
26
+ lineStyleDashDot?: string;
27
+ lineStyleDot?: string;
28
+ lineStyleLongDash?: string;
29
+ lineStyleLongDashDot?: string;
30
+ lineStyleNone?: string;
31
+ lineStyleShortDash?: string;
32
+ lineStyleShortDashDot?: string;
33
+ lineStyleShortDashDotDot?: string;
34
+ lineStyleShortDot?: string;
35
+ lineStyleSolid?: string;
36
+ fillStyleBackwardDiagonal?: string;
37
+ fillStyleCross?: string;
38
+ fillStyleDiagonalCross?: string;
39
+ fillStyleForwardDiagonal?: string;
40
+ fillStyleHorizontal?: string;
41
+ fillStyleNone?: string;
42
+ fillStyleSolid?: string;
43
+ fillStyleVertical?: string;
44
+ }
45
+ export interface ColorResources {
46
+ /**
47
+ * Color value for error text, in any valid CSS format.
48
+ */
49
+ errorForeground?: string;
50
+ /**
51
+ * Color value for error text background, in any valid CSS format.
52
+ */
53
+ errorBackground?: string;
54
+ }
55
+ export declare function symbolIsSupported(symbol: SymbolJson): boolean;
56
+ export interface SymbolInputProps extends Omit<BoxProps, "onChange"> {
57
+ onChange: (symbol: SymbolJson) => void;
58
+ symbol: SymbolJson;
59
+ languageResources?: LanguageResources;
60
+ colorResources?: ColorResources;
61
+ isSupported?: (symbol: SymbolJson) => boolean;
62
+ TextInputComponent?: FC<FormLabelTextFieldProps>;
63
+ NumberInputComponent?: FC<FormLabelSliderFieldProps>;
64
+ ColorInputComponent?: FC<FormLabelColorFieldProps>;
65
+ LineColorProps?: FormLabelColorFieldProps;
66
+ FillColorProps?: FormLabelColorFieldProps;
67
+ LineStyleProps?: FormLabelTextFieldProps;
68
+ FillStyleProps?: FormLabelTextFieldProps;
69
+ MarkerStyleProps?: FormLabelTextFieldProps;
70
+ MarkerSizeProps?: FormLabelSliderFieldProps;
71
+ LineWidthProps?: FormLabelSliderFieldProps;
72
+ MarkerAngleProps?: FormLabelSliderFieldProps;
73
+ MarkerXOffsetProps?: FormLabelSliderFieldProps;
74
+ MarkerYOffsetProps?: FormLabelSliderFieldProps;
75
+ }
76
+ declare const SymbolInput: FC<SymbolInputProps>;
77
+ export default SymbolInput;
@@ -0,0 +1,457 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useCallback, useState } from "react";
3
+ 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
+ export function symbolIsSupported(symbol) {
9
+ const type = symbol.type;
10
+ return type === "esriSMS" || type === "esriSLS" || type === "esriSFS";
11
+ }
12
+ const SymbolInput = props => {
13
+ const { onChange, symbol, languageResources, colorResources, children, parseNumber, formatNumber, isSupported = symbolIsSupported, LineColorProps, FillColorProps, LineWidthProps, LineStyleProps, FillStyleProps, MarkerStyleProps, MarkerSizeProps, MarkerAngleProps, MarkerXOffsetProps, MarkerYOffsetProps, TextInputComponent, NumberInputComponent, ColorInputComponent, ...other } = {
14
+ parseNumber: DEFAULT_PARSE_NUMBER,
15
+ formatNumber: DEFAULT_FORMAT_NUMBER,
16
+ ...props,
17
+ };
18
+ const isSupportedSymbol = isSupported(symbol);
19
+ const text = { ...DEFAULT_LANGUAGE, ...languageResources };
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: 1,
132
+ max: 25,
133
+ ...LineWidthProps?.SliderProps,
134
+ disabled: !isSupportedSymbol || LineWidthProps?.SliderProps?.disabled,
135
+ }, InputProps: {
136
+ onBlur: handleLineWidthBlur,
137
+ min: 1,
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: 1,
166
+ max: 25,
167
+ ...MarkerSizeProps?.SliderProps,
168
+ disabled: !isSupportedSymbol ||
169
+ MarkerSizeProps?.SliderProps?.disabled,
170
+ }, InputProps: {
171
+ min: 1,
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] }));
228
+ };
229
+ 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)";
@@ -0,0 +1,134 @@
1
+ /**
2
+ * A symbol representing a feature on the map.
3
+ *
4
+ * Part of the Esri ArcGIS REST API (see
5
+ * http://resources.arcgis.com/en/help/rest/apiref/symbol.html). See
6
+ * {@link https://developers.arcgis.com/web-map-specification/objects/symbol/}.
7
+ */
8
+ export type SymbolJson = Symbol2DJson;
9
+ /**
10
+ * Symbol types used in web maps.
11
+ */
12
+ export type Symbol2DJson = SimpleFillSymbolJson | SimpleLineSymbolJson | SimpleMarkerSymbolJson;
13
+ /**
14
+ * Color is represented as a four-element array. The four elements represent
15
+ * values for red, green, blue, and alpha in that order. Values range from 0
16
+ * through 255. If color is undefined for a symbol, the color value is null. See
17
+ * {@link https://developers.arcgis.com/web-map-specification/objects/color/}
18
+ * {@link https://developers.arcgis.com/web-scene-specification/objects/color/}.
19
+ */
20
+ export type ColorJson = number[];
21
+ /**
22
+ * Base class for all symbols.
23
+ */
24
+ export interface SymbolJsonBase {
25
+ /**
26
+ * The type of symbol. See {@link SymbolJsonType}.
27
+ */
28
+ type: SymbolJsonType;
29
+ }
30
+ /**
31
+ * Simple fill symbols can be used to symbolize polygon geometries.
32
+ *
33
+ * See
34
+ * {@link https://developers.arcgis.com/web-map-specification/objects/esriSFS_symbol/}.
35
+ */
36
+ export interface SimpleFillSymbolJson extends SymbolJsonBase {
37
+ /**
38
+ * Color is represented as a four-element array. The four elements represent
39
+ * values for red, green, blue, and alpha in that order. Values range from 0
40
+ * through 255. If color is undefined for a symbol, the color value is
41
+ * null.
42
+ */
43
+ color?: ColorJson;
44
+ /**
45
+ * Sets the outline of the fill symbol.
46
+ */
47
+ outline?: SimpleLineSymbolJson;
48
+ /**
49
+ * The fill style.
50
+ */
51
+ style?: "esriSFSBackwardDiagonal" | "esriSFSCross" | "esriSFSDiagonalCross" | "esriSFSForwardDiagonal" | "esriSFSHorizontal" | "esriSFSNull" | "esriSFSSolid" | "esriSFSVertical";
52
+ /**
53
+ * @inheritDoc
54
+ */
55
+ type: "esriSFS";
56
+ }
57
+ /**
58
+ * Simple line symbols can be used to symbolize polyline geometries or outlines
59
+ * for polygon fills.
60
+ *
61
+ * See
62
+ * {@link https://developers.arcgis.com/web-map-specification/objects/esriSLS_symbol/}.
63
+ */
64
+ export interface SimpleLineSymbolJson extends SymbolJsonBase {
65
+ /**
66
+ * Color is represented as a four-element array. The four elements represent
67
+ * values for red, green, blue, and alpha in that order. Values range from 0
68
+ * through 255. If color is undefined for a symbol, the color value is
69
+ * null.
70
+ */
71
+ color?: ColorJson;
72
+ /**
73
+ * The line style.
74
+ */
75
+ style?: "esriSLSDash" | "esriSLSDashDot" | "esriSLSDashDotDot" | "esriSLSDot" | "esriSLSLongDash" | "esriSLSLongDashDot" | "esriSLSLongDashDotDot" | "esriSLSNull" | "esriSLSShortDash" | "esriSLSShortDashDot" | "esriSLSShortDashDotDot" | "esriSLSShortDot" | "esriSLSSolid";
76
+ /**
77
+ * Numeric value indicating the width of the line in pixels.
78
+ */
79
+ width?: number;
80
+ /**
81
+ * @inheritDoc
82
+ */
83
+ type: "esriSLS";
84
+ }
85
+ /**
86
+ * Simple marker symbols can be used to symbolize point geometries.
87
+ *
88
+ * See
89
+ * {@link https://developers.arcgis.com/web-map-specification/objects/esriSMS_symbol/}.
90
+ */
91
+ export interface SimpleMarkerSymbolJson extends SymbolJsonBase {
92
+ /**
93
+ * Numeric value used to rotate the symbol. The symbol is rotated
94
+ * counter-clockwise. For example, The following, angle=-30, in will create
95
+ * a symbol rotated -30 degrees counter-clockwise; that is, 30 degrees
96
+ * clockwise.
97
+ */
98
+ angle?: number;
99
+ /**
100
+ * Color is represented as a four-element array. The four elements represent
101
+ * values for red, green, blue, and alpha in that order. Values range from 0
102
+ * through 255. If color is undefined for a symbol, the color value is
103
+ * null.
104
+ */
105
+ color?: ColorJson;
106
+ /**
107
+ * Sets the outline of the marker symbol.
108
+ */
109
+ outline?: SimpleLineSymbolJson;
110
+ /**
111
+ * Numeric size of the symbol given in pixels.
112
+ */
113
+ size?: number;
114
+ /**
115
+ * The marker style.
116
+ */
117
+ style?: "esriSMSCircle" | "esriSMSCross" | "esriSMSDiamond" | "esriSMSSquare" | "esriSMSX" | "esriSMSTriangle";
118
+ /**
119
+ * Numeric value indicating the offset on the x-axis in pixels.
120
+ */
121
+ xoffset?: number;
122
+ /**
123
+ * Numeric value indicating the offset on the y-axis in pixels.
124
+ */
125
+ yoffset?: number;
126
+ /**
127
+ * @inheritDoc
128
+ */
129
+ type: "esriSMS";
130
+ }
131
+ /**
132
+ * The type of the Symbol.
133
+ */
134
+ export type SymbolJsonType = "esriSMS" | "esriSLS" | "esriSFS" | "esriPMS" | "esriPFS" | "esriTS" | "LineSymbol3D" | "MeshSymbol3D" | "PointSymbol3D" | "PolygonSymbol3D" | "LabelSymbol3D" | "styleSymbolReference" | "CIMSymbolReference";
@@ -0,0 +1,2 @@
1
+ // NOTE: This file is copied from the @vertigis/arcgis-extensions project.
2
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./SymbolInput.js";
2
+ export { default } from "./SymbolInput.js";
@@ -0,0 +1,2 @@
1
+ export * from "./SymbolInput.js";
2
+ export { default } from "./SymbolInput.js";
@@ -0,0 +1,4 @@
1
+ declare const _default: import("@mui/material/OverridableComponent.js").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
2
+ muiName: string;
3
+ };
4
+ export default _default;