@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.
@@ -128,6 +128,7 @@ export interface ConfigOptions {
128
128
  tabId?: string;
129
129
  column?: boolean;
130
130
  relatedDataSource?: string;
131
+ controlName?: string;
131
132
  filterName?: string;
132
133
  searchFilterName?: string;
133
134
  colorAttribute?: string;
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 || !attributeName) {
7788
+ if (!dataSource?.features?.length || !attrName) {
7788
7789
  return [];
7789
7790
  }
7790
7791
  return dataSource.features.map(({ attributes }) => ({
7791
- value: attributes?.[attributeName] || "",
7792
- text: attributes?.[attributeName] || "",
7792
+ value: attributes?.[attrName] || "",
7793
+ text: attributes?.[attrName] || "",
7793
7794
  }));
7794
- }, [dataSource?.features, attributeName]);
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 (attributeName && changeControls) {
7802
+ if (attrName && changeControls) {
7798
7803
  changeControls({
7799
- [attributeName]: option?.value,
7804
+ [attrName]: option?.value,
7800
7805
  });
7801
7806
  }
7802
- }, [changeControls, attributeName]);
7803
- return (jsxRuntime.jsx(uilibGl.Dropdown, { zIndex: 1000, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, label: label, options: items, value: controls?.[attributeName] ?? value, placeholder: placeholder, onChange: handleChange }));
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 `