@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/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 || !attributeName) {
7786
+ if (!dataSource?.features?.length || !attrName) {
7786
7787
  return [];
7787
7788
  }
7788
7789
  return dataSource.features.map(({ attributes }) => ({
7789
- value: attributes?.[attributeName] || "",
7790
- text: attributes?.[attributeName] || "",
7790
+ value: attributes?.[attrName] || "",
7791
+ text: attributes?.[attrName] || "",
7791
7792
  }));
7792
- }, [dataSource?.features, attributeName]);
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 (attributeName && changeControls) {
7800
+ if (attrName && changeControls) {
7796
7801
  changeControls({
7797
- [attributeName]: option?.value,
7802
+ [attrName]: option?.value,
7798
7803
  });
7799
7804
  }
7800
- }, [changeControls, attributeName]);
7801
- return (jsx(Dropdown, { zIndex: 1000, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, label: label, options: items, value: controls?.[attributeName] ?? value, placeholder: placeholder, onChange: handleChange }));
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 `