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