@evergis/react 3.1.86 → 3.1.88

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,20 +7776,25 @@ 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, control, placeholder = t("selectValue", { ns: "dashboard", defaultValue: "Выберите значение" }) } = options || {};
7783
+ const attribute = useMemo(() => attributes?.find(({ name }) => name === attributeName), [attributes, attributeName]);
7783
7784
  const dataSource = useMemo(() => getDataSource(relatedDataSource, dataSources), [relatedDataSource, dataSources]);
7784
7785
  const items = useMemo(() => {
7785
7786
  if (!dataSource?.features?.length || !attributeName) {
7786
7787
  return [];
7787
7788
  }
7788
- return dataSource.features.map(({ attributes }) => ({
7789
- value: attributes?.[attributeName] || "",
7790
- text: attributes?.[attributeName] || "",
7789
+ return dataSource.features.map(item => ({
7790
+ value: item.attributes?.[attributeName] || "",
7791
+ text: item.attributes?.[control?.attributeAlias || attributeName] || "",
7791
7792
  }));
7792
- }, [dataSource?.features, attributeName]);
7793
+ }, [control?.attributeAlias, dataSource?.features, attributeName]);
7794
+ const isDisabled = useMemo(() => {
7795
+ const attr = layerInfo?.configuration?.attributesConfiguration?.attributes?.find(item => item.attributeName === attributeName);
7796
+ return !attr?.isEditable;
7797
+ }, [attributeName, layerInfo?.configuration?.attributesConfiguration?.attributes]);
7793
7798
  const handleChange = useCallback(([option]) => {
7794
7799
  setValue(option?.value);
7795
7800
  if (attributeName && changeControls) {
@@ -7798,7 +7803,7 @@ const ElementControl = ({ elementConfig }) => {
7798
7803
  });
7799
7804
  }
7800
7805
  }, [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 }));
7806
+ return (jsx(Dropdown, { zIndex: 1000, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, label: label, options: items, value: controls?.[attributeName] ?? value ?? attribute?.value, placeholder: placeholder, disabled: isDisabled, onChange: handleChange }));
7802
7807
  };
7803
7808
 
7804
7809
  const StyledIconFontSizeMixin = css `