@evergis/react 3.1.86 → 3.1.87
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/dist/components/Dashboard/types.d.ts +1 -0
- package/dist/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +15 -10
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/react.esm.js
CHANGED
|
@@ -7776,29 +7776,34 @@ const ElementChips = memo(({ type, elementConfig }) => {
|
|
|
7776
7776
|
|
|
7777
7777
|
const ElementControl = ({ elementConfig }) => {
|
|
7778
7778
|
const { t } = useGlobalContext();
|
|
7779
|
-
const { dataSources, controls, changeControls } = useWidgetContext(WidgetType.FeatureCard);
|
|
7779
|
+
const { attributes, layerInfo, dataSources, controls, changeControls } = useWidgetContext(WidgetType.FeatureCard);
|
|
7780
7780
|
const [value, setValue] = useState();
|
|
7781
7781
|
const { options, attributeName } = elementConfig || {};
|
|
7782
|
-
const { relatedDataSource, label, width, placeholder = t("selectValue", { ns: "dashboard", defaultValue: "Выберите значение" }) } = options || {};
|
|
7782
|
+
const { relatedDataSource, label, width, controlName, placeholder = t("selectValue", { ns: "dashboard", defaultValue: "Выберите значение" }) } = options || {};
|
|
7783
|
+
const attrName = controlName || attributeName;
|
|
7783
7784
|
const dataSource = useMemo(() => getDataSource(relatedDataSource, dataSources), [relatedDataSource, dataSources]);
|
|
7784
7785
|
const items = useMemo(() => {
|
|
7785
|
-
if (!dataSource?.features?.length || !
|
|
7786
|
+
if (!dataSource?.features?.length || !attrName) {
|
|
7786
7787
|
return [];
|
|
7787
7788
|
}
|
|
7788
7789
|
return dataSource.features.map(({ attributes }) => ({
|
|
7789
|
-
value: attributes?.[
|
|
7790
|
-
text: attributes?.[
|
|
7790
|
+
value: attributes?.[attrName] || "",
|
|
7791
|
+
text: attributes?.[attrName] || "",
|
|
7791
7792
|
}));
|
|
7792
|
-
}, [dataSource?.features,
|
|
7793
|
+
}, [dataSource?.features, attrName]);
|
|
7794
|
+
const isDisabled = useMemo(() => {
|
|
7795
|
+
const attr = layerInfo?.configuration?.attributesConfiguration?.attributes?.find(({ attributeName }) => attributeName === attrName);
|
|
7796
|
+
return !attr?.isEditable;
|
|
7797
|
+
}, [attrName, layerInfo?.configuration?.attributesConfiguration?.attributes]);
|
|
7793
7798
|
const handleChange = useCallback(([option]) => {
|
|
7794
7799
|
setValue(option?.value);
|
|
7795
|
-
if (
|
|
7800
|
+
if (attrName && changeControls) {
|
|
7796
7801
|
changeControls({
|
|
7797
|
-
[
|
|
7802
|
+
[attrName]: option?.value,
|
|
7798
7803
|
});
|
|
7799
7804
|
}
|
|
7800
|
-
}, [changeControls,
|
|
7801
|
-
return (jsx(Dropdown, { zIndex: 1000, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, label: label, options: items, value: controls?.[
|
|
7805
|
+
}, [changeControls, attrName]);
|
|
7806
|
+
return (jsx(Dropdown, { zIndex: 1000, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, label: label, options: items, value: controls?.[attrName] ?? value, placeholder: placeholder, disabled: isDisabled, onChange: handleChange }));
|
|
7802
7807
|
};
|
|
7803
7808
|
|
|
7804
7809
|
const StyledIconFontSizeMixin = css `
|