@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
package/Autocomplete/index.d.ts
CHANGED
package/Autocomplete/index.js
CHANGED
package/ColorInput/ColorInput.js
CHANGED
|
@@ -67,7 +67,7 @@ const Root = styled(Box)(({ theme: { palette, shape, typography } }) => ({
|
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
69
|
}));
|
|
70
|
-
export const ColorInput = forwardRef(function ColorInput({ ButtonProps, className, classes: classesProp, disabled, presetColors, onChange, value: unsanitizedValue, sketchPickerStyle = {}, ...others }, ref) {
|
|
70
|
+
export const ColorInput = forwardRef(function ColorInput({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ButtonProps, className, classes: classesProp, disabled, presetColors, onChange, value: unsanitizedValue, sketchPickerStyle = {}, ...others }, ref) {
|
|
71
71
|
const theme = useTheme();
|
|
72
72
|
const [buttonEl, setButtonEl] = useState();
|
|
73
73
|
const handleColorPopoverOpen = (event) => setButtonEl(event.currentTarget);
|
|
@@ -88,7 +88,7 @@ export const ColorInput = forwardRef(function ColorInput({ ButtonProps, classNam
|
|
|
88
88
|
// The rgb object will be used for passing values to the color picker component
|
|
89
89
|
const rgb = color ? color.rgb().object() : defaultRgbColor;
|
|
90
90
|
const classes = mergeStyles(colorInputClasses, classesProp);
|
|
91
|
-
return (_jsxs(Root, { className: clsx(classes.root, className), ...others, ref: ref, children: [_jsx(Button, { ...ButtonProps, disabled: disabled ?? muiFormControl?.disabled, className: classes.pickerButton, "data-test": "ColorInput-picker-button", onClick: handleColorPopoverOpen, children: _jsx("div", { className: classes.pickerButtonBackground, children: _jsx("div", { className: classes.pickerButtonColor, "data-test": "ColorInput-picker-button-color", style: {
|
|
91
|
+
return (_jsxs(Root, { className: clsx(classes.root, className), ...others, ref: ref, children: [_jsx(Button, { "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...ButtonProps, disabled: disabled ?? muiFormControl?.disabled, className: classes.pickerButton, "data-test": "ColorInput-picker-button", onClick: handleColorPopoverOpen, children: _jsx("div", { className: classes.pickerButtonBackground, children: _jsx("div", { className: classes.pickerButtonColor, "data-test": "ColorInput-picker-button-color", style: {
|
|
92
92
|
// The rgb CSS string will be used for styling the color picker button
|
|
93
93
|
background: color ? color.rgb().string() : "transparent",
|
|
94
94
|
} }) }) }), _jsx(Popover, { anchorEl: buttonEl, open: !!buttonEl, anchorOrigin: {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { AutocompleteProps } from "../Autocomplete";
|
|
3
|
+
import type { ChipTypeMap } from "../Chip";
|
|
4
|
+
import type { FormControlProps } from "../FormControl/index.js";
|
|
5
|
+
import { type FormHelperTextProps } from "../FormHelperText/index.js";
|
|
6
|
+
export type FormLabelAutocompleteFieldProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap["defaultComponent"]> = Omit<FormControlProps, "defaultValue" | "onBlur" | "onChange" | "onFocus" | "value"> & {
|
|
7
|
+
/**
|
|
8
|
+
* The label content.
|
|
9
|
+
*/
|
|
10
|
+
label?: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Props applied to the
|
|
13
|
+
* [`FormHelperText`](/material-ui/api/form-helper-text/) element.
|
|
14
|
+
*/
|
|
15
|
+
FormHelperTextProps?: Partial<FormHelperTextProps>;
|
|
16
|
+
/**
|
|
17
|
+
* The helper text content.
|
|
18
|
+
*/
|
|
19
|
+
helperText?: React.ReactNode;
|
|
20
|
+
defaultValue?: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["defaultValue"];
|
|
21
|
+
disableClearable: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["disableClearable"];
|
|
22
|
+
disabled?: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["disabled"];
|
|
23
|
+
filterOptions?: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["filterOptions"];
|
|
24
|
+
getOptionLabel: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["getOptionLabel"];
|
|
25
|
+
onBlur?: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["onBlur"];
|
|
26
|
+
onChange?: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["onChange"];
|
|
27
|
+
onFocus?: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["onFocus"];
|
|
28
|
+
options: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["options"];
|
|
29
|
+
value: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["value"];
|
|
30
|
+
AutocompleteProps?: Partial<AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Like TextField, but uses a FormLabel instead of an InputLabel. Also allows
|
|
34
|
+
* for inline help.
|
|
35
|
+
*/
|
|
36
|
+
declare const FormLabelAutocompleteField: import("react").ForwardRefExoticComponent<Pick<any, string | number | symbol> & import("react").RefAttributes<HTMLDivElement>>;
|
|
37
|
+
export default FormLabelAutocompleteField;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import Autocomplete from "../Autocomplete/index.js";
|
|
4
|
+
import FormControl from "../FormControl/index.js";
|
|
5
|
+
import FormHelperText, {} from "../FormHelperText/index.js";
|
|
6
|
+
import FormLabel from "../FormLabel/index.js";
|
|
7
|
+
import Input from "../Input/index.js";
|
|
8
|
+
import { useId } from "../utils/react.js";
|
|
9
|
+
/**
|
|
10
|
+
* Like TextField, but uses a FormLabel instead of an InputLabel. Also allows
|
|
11
|
+
* for inline help.
|
|
12
|
+
*/
|
|
13
|
+
const FormLabelAutocompleteField = forwardRef(function FormLabelAutocompleteField(props, ref) {
|
|
14
|
+
const { AutocompleteProps, defaultValue, disableClearable, disabled, filterOptions, FormHelperTextProps, fullWidth = false, getOptionLabel, helperText, id: idProp, label, onBlur, onChange, onFocus, options, placeholder, value, ...other } = props;
|
|
15
|
+
const id = useId(idProp);
|
|
16
|
+
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
17
|
+
const inputLabelId = label && id ? `${id}-label` : undefined;
|
|
18
|
+
return (_jsxs(FormControl, { fullWidth: fullWidth, ref: ref, disabled: disabled, ...other, children: [label && (_jsx(FormLabel, { htmlFor: id, id: inputLabelId, children: label })), helperText && (_jsx(FormHelperText, { id: helperTextId, ...FormHelperTextProps, children: helperText })), _jsx(Autocomplete, { "aria-labelledby": inputLabelId, defaultValue: defaultValue, disableClearable: disableClearable, disabled: disabled, getOptionLabel: getOptionLabel, onBlur: onBlur, onChange: onChange, onFocus: onFocus, options: options, filterOptions: filterOptions, renderInput: params => (_jsx(Input, { ...params.InputProps, inputProps: { ...params.inputProps }, sx: { width: "100%" } })), value: value, ...AutocompleteProps })] }));
|
|
19
|
+
});
|
|
20
|
+
export default FormLabelAutocompleteField;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import type { FontJson } from "./SymbolJson.js";
|
|
3
|
+
import { type FontFamily } from "./fonts.js";
|
|
4
|
+
import type { BoxProps } from "../Box";
|
|
5
|
+
import type { FormLabelAutocompleteFieldProps } from "../FormLabelAutocompleteField/FormLabelAutocompleteField .js";
|
|
6
|
+
import type { FormLabelSliderFieldProps } from "../FormLabelSliderField";
|
|
7
|
+
import type { FormLabelTextFieldProps } from "../FormLabelTextField";
|
|
8
|
+
export interface FontInputProps extends Omit<BoxProps, "onChange"> {
|
|
9
|
+
onChange: (symbol: FontJson) => void;
|
|
10
|
+
font?: FontJson;
|
|
11
|
+
fontFamilies?: FontFamily[];
|
|
12
|
+
languageResources?: LanguageResources;
|
|
13
|
+
AutoCompleteComponent?: FC<FormLabelAutocompleteFieldProps<FontFamily, false, true, false>>;
|
|
14
|
+
TextInputComponent?: FC<FormLabelTextFieldProps>;
|
|
15
|
+
NumberInputComponent?: FC<FormLabelSliderFieldProps>;
|
|
16
|
+
}
|
|
17
|
+
export interface LanguageResources {
|
|
18
|
+
font?: string;
|
|
19
|
+
fontSize?: string;
|
|
20
|
+
fontFamily?: string;
|
|
21
|
+
fontStyle?: string;
|
|
22
|
+
fontWeight?: string;
|
|
23
|
+
decoration?: string;
|
|
24
|
+
decorationNone?: string;
|
|
25
|
+
decorationLineThrough?: string;
|
|
26
|
+
decorationLineUnderline?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const FontInput: FC<FontInputProps>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { fonts } from "./fonts.js";
|
|
4
|
+
import { DEFAULT_LANGUAGE } from "./utilities.js";
|
|
5
|
+
import Box from "../Box/index.js";
|
|
6
|
+
import FormLabelAutocompleteField from "../FormLabelAutocompleteField/FormLabelAutocompleteField .js";
|
|
7
|
+
import FormLabelSliderField from "../FormLabelSliderField/index.js";
|
|
8
|
+
import FormLabelTextField from "../FormLabelTextField/index.js";
|
|
9
|
+
import { useId } from "../utils/react.js";
|
|
10
|
+
const getDecorationValues = (t) => {
|
|
11
|
+
return [
|
|
12
|
+
{ id: "none", label: t.decorationNone },
|
|
13
|
+
{ id: "line-through", label: t.decorationLineThrough },
|
|
14
|
+
{ id: "underline", label: t.decorationLineUnderline },
|
|
15
|
+
];
|
|
16
|
+
};
|
|
17
|
+
const capitalizeFirstLetter = (value) => `${value.charAt(0).toUpperCase() + value.slice(1)}`;
|
|
18
|
+
const defaultFontJson = {
|
|
19
|
+
size: 9,
|
|
20
|
+
style: "normal",
|
|
21
|
+
decoration: "none",
|
|
22
|
+
weight: "normal",
|
|
23
|
+
family: "sans-serif",
|
|
24
|
+
};
|
|
25
|
+
export const FontInput = ({ font, fontFamilies, languageResources, onChange, AutoCompleteComponent, TextInputComponent, NumberInputComponent, ...props }) => {
|
|
26
|
+
const AutocompleteInput = AutoCompleteComponent ?? FormLabelAutocompleteField;
|
|
27
|
+
const FormTextInput = TextInputComponent ?? FormLabelTextField;
|
|
28
|
+
const FormNumberInput = NumberInputComponent ?? FormLabelSliderField;
|
|
29
|
+
const { current: fontList } = useRef([...(fontFamilies ?? fonts)]);
|
|
30
|
+
const text = { ...DEFAULT_LANGUAGE, ...languageResources };
|
|
31
|
+
const labelId = useId();
|
|
32
|
+
const clampValue = (key, minValue = 0, maxValue = 100) => {
|
|
33
|
+
const clampedValue = Math.min(maxValue, Math.max(minValue, font?.[key] ?? minValue));
|
|
34
|
+
if (font?.[key] !== clampedValue) {
|
|
35
|
+
onChange({ ...font, [key]: clampedValue });
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const updateValue = (key, value) => {
|
|
39
|
+
onChange({ ...font, [key]: value });
|
|
40
|
+
};
|
|
41
|
+
if (!font) {
|
|
42
|
+
onChange(defaultFontJson);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
// https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Font.html
|
|
46
|
+
const fontWithDefaults = {
|
|
47
|
+
family: font.family ?? "sans-serif",
|
|
48
|
+
style: font.style ?? "normal",
|
|
49
|
+
weight: font.weight ?? "normal",
|
|
50
|
+
decoration: font.decoration ?? "none",
|
|
51
|
+
size: font.size ?? 9,
|
|
52
|
+
};
|
|
53
|
+
let fontFamily = fontList.find(f => f.font.family == fontWithDefaults.family &&
|
|
54
|
+
f.font.style === fontWithDefaults.style &&
|
|
55
|
+
f.font.weight === fontWithDefaults.weight);
|
|
56
|
+
if (!fontFamily) {
|
|
57
|
+
let name = fontWithDefaults.family.split("-").map(capitalizeFirstLetter).join(" ");
|
|
58
|
+
if (font.style !== "normal") {
|
|
59
|
+
name += ` ${capitalizeFirstLetter(fontWithDefaults.style)}`;
|
|
60
|
+
}
|
|
61
|
+
if (font.weight !== "normal") {
|
|
62
|
+
name += ` ${capitalizeFirstLetter(fontWithDefaults.weight)}`;
|
|
63
|
+
}
|
|
64
|
+
fontFamily = {
|
|
65
|
+
name,
|
|
66
|
+
font: {
|
|
67
|
+
family: fontWithDefaults.family,
|
|
68
|
+
style: fontWithDefaults.style,
|
|
69
|
+
weight: fontWithDefaults.weight,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
fontList.push(fontFamily);
|
|
73
|
+
}
|
|
74
|
+
return (_jsxs(Box, { ...props, children: [_jsx(AutocompleteInput, { fullWidth: true, disableClearable: true, options: fontList, label: text.fontFamily, "aria-labelledby": labelId, filterOptions: (options, state) => {
|
|
75
|
+
return fontList.filter(f => f.name
|
|
76
|
+
.toLocaleLowerCase()
|
|
77
|
+
.indexOf(state.inputValue.toLocaleLowerCase()) !== -1);
|
|
78
|
+
}, getOptionLabel: option => option.name, value: fontFamily, onChange: (event, newValue, reason, details) => {
|
|
79
|
+
onChange({
|
|
80
|
+
...font,
|
|
81
|
+
family: newValue.font.family,
|
|
82
|
+
style: newValue.font.style,
|
|
83
|
+
weight: newValue.font.weight,
|
|
84
|
+
});
|
|
85
|
+
} }), _jsx(FormNumberInput, { fullWidth: true, SliderProps: {
|
|
86
|
+
step: 0.5,
|
|
87
|
+
min: 0,
|
|
88
|
+
max: 100,
|
|
89
|
+
}, InputProps: {
|
|
90
|
+
onBlur: (event) => {
|
|
91
|
+
clampValue("size", 0, 100);
|
|
92
|
+
},
|
|
93
|
+
min: 0,
|
|
94
|
+
max: 100,
|
|
95
|
+
}, label: text.fontSize, value: font.size, onChange: value => {
|
|
96
|
+
updateValue("size", value);
|
|
97
|
+
} }), _jsx(FormTextInput, { fullWidth: true, nativeSelect: true, label: text.decoration, value: font.decoration, onChange: event => {
|
|
98
|
+
const { value } = event.target;
|
|
99
|
+
updateValue("decoration", value);
|
|
100
|
+
}, children: getDecorationValues(text).map(ls => (_jsx("option", { value: ls.id, children: ls.label }, ls.id))) })] }));
|
|
101
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import type { SymbolJson, SimpleFillSymbolJson, SimpleLineSymbolJson } 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
|
+
lineStyleTitle?: string;
|
|
12
|
+
lineWidthTitle?: string;
|
|
13
|
+
fillColorTitle?: string;
|
|
14
|
+
fillStyleTitle?: string;
|
|
15
|
+
lineStyleDash?: string;
|
|
16
|
+
lineStyleDashDot?: string;
|
|
17
|
+
lineStyleDot?: string;
|
|
18
|
+
lineStyleLongDash?: string;
|
|
19
|
+
lineStyleLongDashDot?: string;
|
|
20
|
+
lineStyleNone?: string;
|
|
21
|
+
lineStyleShortDash?: string;
|
|
22
|
+
lineStyleShortDashDot?: string;
|
|
23
|
+
lineStyleShortDashDotDot?: string;
|
|
24
|
+
lineStyleShortDot?: string;
|
|
25
|
+
lineStyleSolid?: string;
|
|
26
|
+
fillStyleBackwardDiagonal?: string;
|
|
27
|
+
fillStyleCross?: string;
|
|
28
|
+
fillStyleDiagonalCross?: string;
|
|
29
|
+
fillStyleForwardDiagonal?: string;
|
|
30
|
+
fillStyleHorizontal?: string;
|
|
31
|
+
fillStyleNone?: string;
|
|
32
|
+
fillStyleSolid?: string;
|
|
33
|
+
fillStyleVertical?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function symbolIsSupported(symbol: SymbolJson): boolean;
|
|
36
|
+
export interface SimpleFillSymbolInputProps extends Omit<BoxProps, "onChange"> {
|
|
37
|
+
onChange: (symbol: SymbolJson) => void;
|
|
38
|
+
symbol: SymbolJson;
|
|
39
|
+
languageResources?: LanguageResources & UnsupportedSymbolProps["languageResources"];
|
|
40
|
+
colorResources?: UnsupportedSymbolProps["colorResources"];
|
|
41
|
+
isSupported?: (symbol: SymbolJson) => symbol is SimpleFillSymbolJson;
|
|
42
|
+
TextInputComponent?: FC<FormLabelTextFieldProps>;
|
|
43
|
+
NumberInputComponent?: FC<FormLabelSliderFieldProps>;
|
|
44
|
+
ColorInputComponent?: FC<FormLabelColorFieldProps>;
|
|
45
|
+
}
|
|
46
|
+
declare const SimpleFillSymbolInput: FC<SimpleFillSymbolInputProps>;
|
|
47
|
+
export default SimpleFillSymbolInput;
|
|
48
|
+
export declare const getSimpleFillStyles: (t: Required<LanguageResources>) => SelectValues<Required<SimpleFillSymbolJson>["style"]>;
|
|
49
|
+
export declare const getSimpleLineStyles: (t: Required<LanguageResources>) => SelectValues<Required<SimpleLineSymbolJson>["style"]>;
|
|
@@ -0,0 +1,175 @@
|
|
|
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 { DEFAULT_FORMAT_NUMBER, DEFAULT_LANGUAGE, DEFAULT_PARSE_NUMBER, getFillColor, getFillStyle, getLineColor, getLineStyle, getLineWidth, toColor, toRgbaString, } 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 === "esriSFS";
|
|
12
|
+
}
|
|
13
|
+
const SimpleFillSymbolInput = 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 [fillStyle, setFillStyle] = useState(getFillStyle(symbol));
|
|
30
|
+
const [lineColor, setLineColor] = useState(getLineColor(symbol));
|
|
31
|
+
const [fillColor, setFillColor] = useState(getFillColor(symbol));
|
|
32
|
+
const [lineWidth, setLineWidth] = useState(getLineWidth(symbol));
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
setLineColor(getLineColor(symbol));
|
|
35
|
+
setLineStyle(getLineStyle(symbol));
|
|
36
|
+
setLineWidth(getLineWidth(symbol));
|
|
37
|
+
setFillColor(getFillColor(symbol));
|
|
38
|
+
setFillStyle(getFillStyle(symbol));
|
|
39
|
+
}, [symbol]);
|
|
40
|
+
const handleLineWidthBlur = useCallback((event) => {
|
|
41
|
+
setLineWidth(Math.min(100, Math.max(0, lineWidth ?? 0)));
|
|
42
|
+
}, [lineWidth]);
|
|
43
|
+
// The rule is correct, but without the useless constraint, the TSX parser
|
|
44
|
+
// gets confused and tries to interpret it as a React element.
|
|
45
|
+
//
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
47
|
+
const handleStateChange = (state, propName, setState) => {
|
|
48
|
+
setState(state);
|
|
49
|
+
onChange?.(getCurrentProperties({ [propName]: state }));
|
|
50
|
+
};
|
|
51
|
+
const getCurrentProperties = (newState = {}) => {
|
|
52
|
+
switch (type) {
|
|
53
|
+
case "esriSFS":
|
|
54
|
+
return {
|
|
55
|
+
type,
|
|
56
|
+
color: newState.fillColor ?? fillColor,
|
|
57
|
+
outline: {
|
|
58
|
+
color: newState.lineColor ?? lineColor,
|
|
59
|
+
width: newState.lineWidth ?? lineWidth,
|
|
60
|
+
style: newState.lineStyle ?? lineStyle,
|
|
61
|
+
type: "esriSLS",
|
|
62
|
+
},
|
|
63
|
+
style: newState.fillStyle ?? fillStyle,
|
|
64
|
+
};
|
|
65
|
+
default:
|
|
66
|
+
return { type };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return (_jsxs(Box, { ...other, children: [!isSupportedSymbol && (_jsx(UnsupportedSymbol, { languageResources: languageResources, colorResources: colorResources })), children, isSupportedSymbol && (_jsxs(_Fragment, { children: [_jsx(FormColorInput, { fullWidth: true, label: text.lineColorTitle, onChange: (value) => {
|
|
70
|
+
handleStateChange(toColor(value), "lineColor", setLineColor);
|
|
71
|
+
}, value: toRgbaString(lineColor) }), _jsx(FormTextInput, { fullWidth: true, nativeSelect: true, label: text.lineStyleTitle, value: lineStyle, onChange: event => {
|
|
72
|
+
const { value } = event.target;
|
|
73
|
+
handleStateChange(value, "lineStyle", setLineStyle);
|
|
74
|
+
}, children: getSimpleLineStyles(text).map(ls => (_jsx("option", { value: ls.id, children: ls.label }, ls.id))) }), _jsx(FormNumberInput, { fullWidth: true, SliderProps: {
|
|
75
|
+
step: 0.5,
|
|
76
|
+
min: 0,
|
|
77
|
+
max: 25,
|
|
78
|
+
}, InputProps: {
|
|
79
|
+
onBlur: handleLineWidthBlur,
|
|
80
|
+
min: 0,
|
|
81
|
+
max: 25,
|
|
82
|
+
}, label: text.lineWidthTitle, value: lineWidth, onChange: value => {
|
|
83
|
+
handleStateChange(value, "lineWidth", setLineWidth);
|
|
84
|
+
} }), _jsx(FormColorInput, { fullWidth: true, label: text.fillColorTitle, onChange: (value) => {
|
|
85
|
+
handleStateChange(toColor(value), "fillColor", setFillColor);
|
|
86
|
+
}, value: toRgbaString(fillColor) }), _jsx(FormTextInput, { fullWidth: true, nativeSelect: true, label: text.fillStyleTitle, value: fillStyle, onChange: event => {
|
|
87
|
+
const { value } = event.target;
|
|
88
|
+
handleStateChange(value, "fillStyle", setFillStyle);
|
|
89
|
+
}, children: getSimpleFillStyles(text).map(fillStyle => (_jsx("option", { value: fillStyle.id, children: fillStyle.label }, fillStyle.id))) })] }))] }));
|
|
90
|
+
};
|
|
91
|
+
export default SimpleFillSymbolInput;
|
|
92
|
+
export const getSimpleFillStyles = (t) => {
|
|
93
|
+
return [
|
|
94
|
+
{
|
|
95
|
+
id: "esriSFSBackwardDiagonal",
|
|
96
|
+
label: t.fillStyleBackwardDiagonal,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: "esriSFSCross",
|
|
100
|
+
label: t.fillStyleCross,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: "esriSFSDiagonalCross",
|
|
104
|
+
label: t.fillStyleDiagonalCross,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "esriSFSForwardDiagonal",
|
|
108
|
+
label: t.fillStyleForwardDiagonal,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: "esriSFSHorizontal",
|
|
112
|
+
label: t.fillStyleHorizontal,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: "esriSFSNull",
|
|
116
|
+
label: t.fillStyleNone,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "esriSFSSolid",
|
|
120
|
+
label: t.fillStyleSolid,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: "esriSFSVertical",
|
|
124
|
+
label: t.fillStyleVertical,
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
};
|
|
128
|
+
export const getSimpleLineStyles = (t) => {
|
|
129
|
+
return [
|
|
130
|
+
{
|
|
131
|
+
id: "esriSLSDash",
|
|
132
|
+
label: t.lineStyleDash,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: "esriSLSDashDot",
|
|
136
|
+
label: t.lineStyleDashDot,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: "esriSLSDot",
|
|
140
|
+
label: t.lineStyleDot,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: "esriSLSLongDash",
|
|
144
|
+
label: t.lineStyleLongDash,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: "esriSLSLongDashDot",
|
|
148
|
+
label: t.lineStyleLongDashDot,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: "esriSLSNull",
|
|
152
|
+
label: t.lineStyleNone,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: "esriSLSShortDash",
|
|
156
|
+
label: t.lineStyleShortDash,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: "esriSLSShortDashDot",
|
|
160
|
+
label: t.lineStyleShortDashDot,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: "esriSLSShortDashDotDot",
|
|
164
|
+
label: t.lineStyleShortDashDotDot,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: "esriSLSShortDot",
|
|
168
|
+
label: t.lineStyleShortDot,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
id: "esriSLSSolid",
|
|
172
|
+
label: t.lineStyleSolid,
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import type { SymbolJson, SimpleLineSymbolJson } 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 declare function symbolIsSupported(symbol: SymbolJson): symbol is SimpleLineSymbolJson;
|
|
10
|
+
export interface LanguageResources {
|
|
11
|
+
lineColorTitle?: string;
|
|
12
|
+
lineStyleTitle?: string;
|
|
13
|
+
lineWidthTitle?: string;
|
|
14
|
+
lineStyleDash?: string;
|
|
15
|
+
lineStyleDashDot?: string;
|
|
16
|
+
lineStyleDot?: string;
|
|
17
|
+
lineStyleLongDash?: string;
|
|
18
|
+
lineStyleLongDashDot?: string;
|
|
19
|
+
lineStyleNone?: string;
|
|
20
|
+
lineStyleShortDash?: string;
|
|
21
|
+
lineStyleShortDashDot?: string;
|
|
22
|
+
lineStyleShortDashDotDot?: string;
|
|
23
|
+
lineStyleShortDot?: string;
|
|
24
|
+
lineStyleSolid?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface SimpleLineSymbolInputProps 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 SimpleLineSymbolJson;
|
|
32
|
+
TextInputComponent?: FC<FormLabelTextFieldProps>;
|
|
33
|
+
NumberInputComponent?: FC<FormLabelSliderFieldProps>;
|
|
34
|
+
ColorInputComponent?: FC<FormLabelColorFieldProps>;
|
|
35
|
+
}
|
|
36
|
+
declare const SimpleLineSymbolInput: FC<SimpleLineSymbolInputProps>;
|
|
37
|
+
export default SimpleLineSymbolInput;
|
|
38
|
+
export declare const getSimpleLineStyles: (t: Required<LanguageResources>) => SelectValues<Required<SimpleLineSymbolJson>["style"]>;
|
|
@@ -0,0 +1,125 @@
|
|
|
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 { DEFAULT_PARSE_NUMBER, DEFAULT_FORMAT_NUMBER, DEFAULT_LANGUAGE, toRgbaString, toColor, getLineColor, getLineStyle, getLineWidth, } 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 === "esriSLS";
|
|
12
|
+
}
|
|
13
|
+
const SimpleLineSymbolInput = 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 [lineWidth, setLineWidth] = useState(getLineWidth(symbol));
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setLineColor(getLineColor(symbol));
|
|
33
|
+
setLineStyle(getLineStyle(symbol));
|
|
34
|
+
setLineWidth(getLineWidth(symbol));
|
|
35
|
+
}, [symbol]);
|
|
36
|
+
const handleLineWidthBlur = useCallback((event) => {
|
|
37
|
+
setLineWidth(Math.min(100, Math.max(0, lineWidth ?? 0)));
|
|
38
|
+
}, [lineWidth]);
|
|
39
|
+
// The rule is correct, but without the useless constraint, the TSX parser
|
|
40
|
+
// gets confused and tries to interpret it as a React element.
|
|
41
|
+
//
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
43
|
+
const handleStateChange = (state, propName, setState) => {
|
|
44
|
+
setState(state);
|
|
45
|
+
onChange?.(getCurrentProperties({ [propName]: state }));
|
|
46
|
+
};
|
|
47
|
+
const getCurrentProperties = (newState = {}) => {
|
|
48
|
+
switch (type) {
|
|
49
|
+
case "esriSLS":
|
|
50
|
+
return {
|
|
51
|
+
type,
|
|
52
|
+
color: newState.lineColor ?? lineColor,
|
|
53
|
+
width: newState.lineWidth ?? lineWidth,
|
|
54
|
+
style: newState.lineStyle ?? lineStyle,
|
|
55
|
+
};
|
|
56
|
+
default:
|
|
57
|
+
return { type };
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
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) => {
|
|
61
|
+
handleStateChange(toColor(value), "lineColor", setLineColor);
|
|
62
|
+
}, value: toRgbaString(lineColor) }), _jsx(FormTextInput, { fullWidth: true, nativeSelect: true, label: text.lineStyleTitle, value: lineStyle, onChange: event => {
|
|
63
|
+
const { value } = event.target;
|
|
64
|
+
handleStateChange(value, "lineStyle", setLineStyle);
|
|
65
|
+
}, children: getSimpleLineStyles(text).map(ls => (_jsx("option", { value: ls.id, children: ls.label }, ls.id))) }), _jsx(FormNumberInput, { fullWidth: true, SliderProps: {
|
|
66
|
+
step: 0.5,
|
|
67
|
+
min: 0,
|
|
68
|
+
max: 25,
|
|
69
|
+
}, InputProps: {
|
|
70
|
+
onBlur: handleLineWidthBlur,
|
|
71
|
+
min: 0,
|
|
72
|
+
max: 25,
|
|
73
|
+
}, label: text.lineWidthTitle, value: lineWidth, onChange: value => {
|
|
74
|
+
handleStateChange(value, "lineWidth", setLineWidth);
|
|
75
|
+
} })] }))] }));
|
|
76
|
+
};
|
|
77
|
+
export default SimpleLineSymbolInput;
|
|
78
|
+
export const getSimpleLineStyles = (t) => {
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
id: "esriSLSDash",
|
|
82
|
+
label: t.lineStyleDash,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "esriSLSDashDot",
|
|
86
|
+
label: t.lineStyleDashDot,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: "esriSLSDot",
|
|
90
|
+
label: t.lineStyleDot,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: "esriSLSLongDash",
|
|
94
|
+
label: t.lineStyleLongDash,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: "esriSLSLongDashDot",
|
|
98
|
+
label: t.lineStyleLongDashDot,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "esriSLSNull",
|
|
102
|
+
label: t.lineStyleNone,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "esriSLSShortDash",
|
|
106
|
+
label: t.lineStyleShortDash,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: "esriSLSShortDashDot",
|
|
110
|
+
label: t.lineStyleShortDashDot,
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: "esriSLSShortDashDotDot",
|
|
114
|
+
label: t.lineStyleShortDashDotDot,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: "esriSLSShortDot",
|
|
118
|
+
label: t.lineStyleShortDot,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: "esriSLSSolid",
|
|
122
|
+
label: t.lineStyleSolid,
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
};
|
|
@@ -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"]>;
|