@vertigis/react-ui 11.35.0 → 12.0.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.
- 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/FormLabelNumberField/FormLabelNumberField.js +2 -2
- 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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import type { SymbolJson, SimpleMarkerSymbolJson } from "./SymbolJson.js";
|
|
3
|
+
import type { UnsupportedSymbolProps } from "./UnsupportedSymbol.js";
|
|
4
|
+
import { type SelectValues } from "./utilities.js";
|
|
5
|
+
import { type BoxProps } from "../Box/index.js";
|
|
6
|
+
import { type FormLabelColorFieldProps } from "../FormLabelColorField/index.js";
|
|
7
|
+
import { type FormLabelSliderFieldProps } from "../FormLabelSliderField/index.js";
|
|
8
|
+
import { type FormLabelTextFieldProps } from "../FormLabelTextField/index.js";
|
|
9
|
+
export interface LanguageResources {
|
|
10
|
+
lineColorTitle?: string;
|
|
11
|
+
lineWidthTitle?: string;
|
|
12
|
+
fillColorTitle?: string;
|
|
13
|
+
markerSizeTitle?: string;
|
|
14
|
+
markerStyleTitle?: string;
|
|
15
|
+
markerAngleTitle?: string;
|
|
16
|
+
xOffsetTitle?: string;
|
|
17
|
+
yOffsetTitle?: string;
|
|
18
|
+
markerStyleCircle?: string;
|
|
19
|
+
markerStyleCross?: string;
|
|
20
|
+
markerStyleDiamond?: string;
|
|
21
|
+
markerStyleSquare?: string;
|
|
22
|
+
markerStyleTriangle?: string;
|
|
23
|
+
markerStyleX?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function symbolIsSupported(symbol: SymbolJson): boolean;
|
|
26
|
+
export interface SimpleMarkerSymbolInputProps extends Omit<BoxProps, "onChange"> {
|
|
27
|
+
onChange: (symbol: SymbolJson) => void;
|
|
28
|
+
symbol: SymbolJson;
|
|
29
|
+
languageResources?: LanguageResources & UnsupportedSymbolProps["languageResources"];
|
|
30
|
+
colorResources?: UnsupportedSymbolProps["colorResources"];
|
|
31
|
+
isSupported?: (symbol: SymbolJson) => symbol is SimpleMarkerSymbolJson;
|
|
32
|
+
TextInputComponent?: FC<FormLabelTextFieldProps>;
|
|
33
|
+
NumberInputComponent?: FC<FormLabelSliderFieldProps>;
|
|
34
|
+
ColorInputComponent?: FC<FormLabelColorFieldProps>;
|
|
35
|
+
}
|
|
36
|
+
declare const SimpleMarkerSymbolInput: FC<SimpleMarkerSymbolInputProps>;
|
|
37
|
+
export default SimpleMarkerSymbolInput;
|
|
38
|
+
export declare const getSimpleMarkerStyles: (t: Required<LanguageResources>) => SelectValues<Required<SimpleMarkerSymbolJson>["style"]>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useCallback, useState } from "react";
|
|
3
|
+
import UnsupportedSymbol from "./UnsupportedSymbol.js";
|
|
4
|
+
import { NO_FILL_MARKER_STYLES, toColor, toRgbaString, DEFAULT_LANGUAGE, DEFAULT_PARSE_NUMBER, DEFAULT_FORMAT_NUMBER, getLineStyle, getLineColor, getFillColor, getLineWidth, getMarkerProperty, } from "./utilities.js";
|
|
5
|
+
import Box, {} from "../Box/index.js";
|
|
6
|
+
import FormLabelColorField, {} from "../FormLabelColorField/index.js";
|
|
7
|
+
import FormLabelSliderField, {} from "../FormLabelSliderField/index.js";
|
|
8
|
+
import FormLabelTextField, {} from "../FormLabelTextField/index.js";
|
|
9
|
+
export function symbolIsSupported(symbol) {
|
|
10
|
+
const type = symbol.type;
|
|
11
|
+
return type === "esriSMS";
|
|
12
|
+
}
|
|
13
|
+
const SimpleMarkerSymbolInput = props => {
|
|
14
|
+
const { onChange, symbol, languageResources, colorResources, children, parseNumber, formatNumber, isSupported = symbolIsSupported, TextInputComponent, NumberInputComponent, ColorInputComponent, ...other } = {
|
|
15
|
+
parseNumber: DEFAULT_PARSE_NUMBER,
|
|
16
|
+
formatNumber: DEFAULT_FORMAT_NUMBER,
|
|
17
|
+
...props,
|
|
18
|
+
};
|
|
19
|
+
const isSupportedSymbol = isSupported(symbol);
|
|
20
|
+
const text = {
|
|
21
|
+
...DEFAULT_LANGUAGE,
|
|
22
|
+
...languageResources,
|
|
23
|
+
};
|
|
24
|
+
const { type } = symbol;
|
|
25
|
+
const FormTextInput = TextInputComponent ?? FormLabelTextField;
|
|
26
|
+
const FormNumberInput = NumberInputComponent ?? FormLabelSliderField;
|
|
27
|
+
const FormColorInput = ColorInputComponent ?? FormLabelColorField;
|
|
28
|
+
const [lineStyle, setLineStyle] = useState(getLineStyle(symbol));
|
|
29
|
+
const [lineColor, setLineColor] = useState(getLineColor(symbol));
|
|
30
|
+
const [fillColor, setFillColor] = useState(getFillColor(symbol));
|
|
31
|
+
const [lineWidth, setLineWidth] = useState(getLineWidth(symbol));
|
|
32
|
+
const [markerStyle, setMarkerStyle] = useState(getMarkerProperty(symbol, "style"));
|
|
33
|
+
const [markerSize, setMarkerSize] = useState(getMarkerProperty(symbol, "size") ?? 1);
|
|
34
|
+
const [markerAngle, setMarkerAngle] = useState(getMarkerProperty(symbol, "angle") ?? 0);
|
|
35
|
+
const [xOffset, setXOffset] = useState(getMarkerProperty(symbol, "xoffset") ?? 0);
|
|
36
|
+
const [yOffset, setYOffset] = useState(getMarkerProperty(symbol, "yoffset") ?? 0);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
setLineColor(getLineColor(symbol));
|
|
39
|
+
setLineStyle(getLineStyle(symbol));
|
|
40
|
+
setLineWidth(getLineWidth(symbol));
|
|
41
|
+
setFillColor(getFillColor(symbol));
|
|
42
|
+
setMarkerAngle(getMarkerProperty(symbol, "angle") ?? 0);
|
|
43
|
+
setMarkerSize(getMarkerProperty(symbol, "size") ?? 1);
|
|
44
|
+
setMarkerStyle(getMarkerProperty(symbol, "style"));
|
|
45
|
+
setXOffset(getMarkerProperty(symbol, "xoffset") ?? 0);
|
|
46
|
+
setYOffset(getMarkerProperty(symbol, "yoffset") ?? 0);
|
|
47
|
+
}, [symbol]);
|
|
48
|
+
const handleLineWidthBlur = useCallback((event) => {
|
|
49
|
+
setLineWidth(Math.min(100, Math.max(0, lineWidth ?? 0)));
|
|
50
|
+
}, [lineWidth]);
|
|
51
|
+
const handleMarkerSizeBlur = useCallback((event) => {
|
|
52
|
+
setMarkerSize(Math.min(100, Math.max(0, markerSize ?? 0)));
|
|
53
|
+
}, [markerSize]);
|
|
54
|
+
const handleXOffsetBlur = useCallback((event) => {
|
|
55
|
+
setXOffset(Math.min(100, Math.max(0, xOffset ?? 0)));
|
|
56
|
+
}, [xOffset]);
|
|
57
|
+
const handleYOffsetBlur = useCallback((event) => {
|
|
58
|
+
setYOffset(Math.min(100, Math.max(0, yOffset ?? 0)));
|
|
59
|
+
}, [yOffset]);
|
|
60
|
+
const handleMarkerAngleBlur = useCallback((event) => {
|
|
61
|
+
setMarkerAngle(Math.min(360, Math.max(0, markerAngle ?? 0)));
|
|
62
|
+
}, [markerAngle]);
|
|
63
|
+
// The rule is correct, but without the useless constraint, the TSX parser
|
|
64
|
+
// gets confused and tries to interpret it as a React element.
|
|
65
|
+
//
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
67
|
+
const handleStateChange = (state, propName, setState) => {
|
|
68
|
+
setState(state);
|
|
69
|
+
onChange?.(getCurrentProperties({ [propName]: state }));
|
|
70
|
+
};
|
|
71
|
+
const getCurrentProperties = (newState = {}) => {
|
|
72
|
+
switch (type) {
|
|
73
|
+
case "esriSMS":
|
|
74
|
+
return {
|
|
75
|
+
type,
|
|
76
|
+
color: newState.fillColor ?? fillColor,
|
|
77
|
+
outline: {
|
|
78
|
+
color: newState.lineColor ?? lineColor,
|
|
79
|
+
width: newState.lineWidth ?? lineWidth,
|
|
80
|
+
style: newState.lineStyle ?? lineStyle,
|
|
81
|
+
type: "esriSLS",
|
|
82
|
+
},
|
|
83
|
+
style: newState.markerStyle ?? markerStyle,
|
|
84
|
+
size: newState.markerSize ?? markerSize,
|
|
85
|
+
angle: newState.markerAngle ?? markerAngle,
|
|
86
|
+
xoffset: newState.xOffset ?? xOffset,
|
|
87
|
+
yoffset: newState.yOffset ?? yOffset,
|
|
88
|
+
};
|
|
89
|
+
default:
|
|
90
|
+
return { type };
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return (_jsxs(Box, { ...other, children: [!isSupportedSymbol && (_jsx(UnsupportedSymbol, { colorResources: colorResources, languageResources: languageResources })), children, isSupportedSymbol && (_jsxs(_Fragment, { children: [_jsx(FormColorInput, { fullWidth: true, label: text.lineColorTitle, onChange: (value) => {
|
|
94
|
+
handleStateChange(toColor(value), "lineColor", setLineColor);
|
|
95
|
+
}, value: toRgbaString(lineColor) }), _jsx(FormNumberInput, { fullWidth: true, SliderProps: {
|
|
96
|
+
step: 0.5,
|
|
97
|
+
min: 0,
|
|
98
|
+
max: 25,
|
|
99
|
+
}, InputProps: {
|
|
100
|
+
onBlur: handleLineWidthBlur,
|
|
101
|
+
min: 0,
|
|
102
|
+
max: 25,
|
|
103
|
+
}, label: text.lineWidthTitle, value: lineWidth, onChange: value => {
|
|
104
|
+
handleStateChange(value, "lineWidth", setLineWidth);
|
|
105
|
+
} }), _jsx(FormColorInput, { fullWidth: true, label: text.fillColorTitle, onChange: (value) => {
|
|
106
|
+
handleStateChange(toColor(value), "fillColor", setFillColor);
|
|
107
|
+
}, value: toRgbaString(fillColor), disabled: NO_FILL_MARKER_STYLES.includes(markerStyle) }), _jsx(FormTextInput, { fullWidth: true, nativeSelect: true, label: text.markerStyleTitle, value: markerStyle, onChange: event => {
|
|
108
|
+
const { value } = event.target;
|
|
109
|
+
handleStateChange(value, "markerStyle", setMarkerStyle);
|
|
110
|
+
}, children: getSimpleMarkerStyles(text).map(markerStyle => (_jsx("option", { value: markerStyle.id, children: markerStyle.label }, markerStyle.id))) }), _jsx(FormNumberInput, { fullWidth: true, label: text.markerSizeTitle, value: markerSize, onChange: value => {
|
|
111
|
+
handleStateChange(value, "markerSize", setMarkerSize);
|
|
112
|
+
}, SliderProps: {
|
|
113
|
+
step: 1,
|
|
114
|
+
min: 0,
|
|
115
|
+
max: 25,
|
|
116
|
+
}, InputProps: {
|
|
117
|
+
min: 0,
|
|
118
|
+
max: 25,
|
|
119
|
+
onBlur: handleMarkerSizeBlur,
|
|
120
|
+
} }), _jsx(FormNumberInput, { fullWidth: true, label: text.markerAngleTitle, value: markerAngle, onChange: value => {
|
|
121
|
+
handleStateChange(value, "markerAngle", setMarkerAngle);
|
|
122
|
+
}, SliderProps: {
|
|
123
|
+
step: 1,
|
|
124
|
+
min: 0,
|
|
125
|
+
max: 360,
|
|
126
|
+
}, InputProps: {
|
|
127
|
+
min: 0,
|
|
128
|
+
max: 360,
|
|
129
|
+
onBlur: handleMarkerAngleBlur,
|
|
130
|
+
} }), _jsx(FormNumberInput, { fullWidth: true, label: text.xOffsetTitle, value: xOffset, onChange: value => {
|
|
131
|
+
handleStateChange(value, "xOffset", setXOffset);
|
|
132
|
+
}, SliderProps: {
|
|
133
|
+
step: 1,
|
|
134
|
+
min: -25,
|
|
135
|
+
max: 25,
|
|
136
|
+
}, InputProps: {
|
|
137
|
+
min: -25,
|
|
138
|
+
max: 25,
|
|
139
|
+
onBlur: handleXOffsetBlur,
|
|
140
|
+
} }), _jsx(FormNumberInput, { fullWidth: true, label: text.yOffsetTitle, value: yOffset, onChange: value => {
|
|
141
|
+
handleStateChange(value, "yOffset", setYOffset);
|
|
142
|
+
}, SliderProps: {
|
|
143
|
+
step: 1,
|
|
144
|
+
min: -25,
|
|
145
|
+
max: 25,
|
|
146
|
+
}, InputProps: {
|
|
147
|
+
min: -25,
|
|
148
|
+
max: 25,
|
|
149
|
+
onBlur: handleYOffsetBlur,
|
|
150
|
+
} })] }))] }));
|
|
151
|
+
};
|
|
152
|
+
export default SimpleMarkerSymbolInput;
|
|
153
|
+
export const getSimpleMarkerStyles = (t) => {
|
|
154
|
+
return [
|
|
155
|
+
{ id: "esriSMSCircle", label: t.markerStyleCircle },
|
|
156
|
+
{ id: "esriSMSCross", label: t.markerStyleCross },
|
|
157
|
+
{ id: "esriSMSDiamond", label: t.markerStyleDiamond },
|
|
158
|
+
{ id: "esriSMSSquare", label: t.markerStyleSquare },
|
|
159
|
+
{ id: "esriSMSTriangle", label: t.markerStyleTriangle },
|
|
160
|
+
{ id: "esriSMSX", label: t.markerStyleX },
|
|
161
|
+
];
|
|
162
|
+
};
|
|
@@ -1,77 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import { type SimpleFillSymbolInputProps } from "./SimpleFillSymbolInput.js";
|
|
3
|
+
import { type SimpleLineSymbolInputProps } from "./SimpleLineSymbolInput.js";
|
|
4
|
+
import { type SimpleMarkerSymbolInputProps } from "./SimpleMarkerSymbolInput.js";
|
|
2
5
|
import type { SymbolJson } from "./SymbolJson.js";
|
|
6
|
+
import { type TextSymbolInputProps } from "./TextSymbolInput.js";
|
|
7
|
+
import type { UnsupportedSymbolProps } from "./UnsupportedSymbol.js";
|
|
8
|
+
import type { FontFamily } from "./fonts.js";
|
|
3
9
|
import { type BoxProps } from "../Box/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
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
|
-
}
|
|
10
|
+
import type { FormLabelAutocompleteFieldProps } from "../FormLabelAutocompleteField/index.js";
|
|
11
|
+
import type { FormLabelColorFieldProps } from "../FormLabelColorField/FormLabelColorField.js";
|
|
12
|
+
import type { FormLabelSliderFieldProps } from "../FormLabelSliderField/FormLabelSliderField.js";
|
|
13
|
+
import type { FormLabelTextFieldProps } from "../FormLabelTextField/FormLabelTextField.js";
|
|
55
14
|
export declare function symbolIsSupported(symbol: SymbolJson): boolean;
|
|
56
15
|
export interface SymbolInputProps extends Omit<BoxProps, "onChange"> {
|
|
57
16
|
onChange: (symbol: SymbolJson) => void;
|
|
58
17
|
symbol: SymbolJson;
|
|
59
|
-
languageResources?:
|
|
60
|
-
colorResources?:
|
|
18
|
+
languageResources?: SimpleFillSymbolInputProps["languageResources"] & SimpleLineSymbolInputProps["languageResources"] & SimpleMarkerSymbolInputProps["languageResources"] & TextSymbolInputProps["languageResources"];
|
|
19
|
+
colorResources?: UnsupportedSymbolProps["colorResources"];
|
|
61
20
|
isSupported?: (symbol: SymbolJson) => boolean;
|
|
21
|
+
AutoCompleteComponent?: FC<FormLabelAutocompleteFieldProps<FontFamily, false, true, false>>;
|
|
62
22
|
TextInputComponent?: FC<FormLabelTextFieldProps>;
|
|
63
23
|
NumberInputComponent?: FC<FormLabelSliderFieldProps>;
|
|
64
24
|
ColorInputComponent?: FC<FormLabelColorFieldProps>;
|
|
65
|
-
|
|
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;
|
|
25
|
+
textSymbolDisplayOptions?: TextSymbolInputProps["displayOptions"];
|
|
75
26
|
}
|
|
76
27
|
declare const SymbolInput: FC<SymbolInputProps>;
|
|
77
28
|
export default SymbolInput;
|