@evergis/react 3.1.85 → 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
@@ -5573,10 +5573,13 @@ const ChartLegendName = styled.div `
5573
5573
  const ContainerAlias = styled(uilibGl.Flex) `
5574
5574
  align-items: center;
5575
5575
  flex-wrap: nowrap;
5576
- margin-bottom: ${({ hasBottomMargin }) => (hasBottomMargin ? 0.25 : 0)}rem;
5577
5576
  font-size: 0.75rem;
5578
5577
  color: ${({ theme: { palette } }) => palette.textSecondary};
5579
5578
 
5579
+ &&& {
5580
+ margin-bottom: ${({ hasBottomMargin }) => (hasBottomMargin ? 0.25 : 0)}rem;
5581
+ }
5582
+
5580
5583
  span[kind] {
5581
5584
  margin-right: 0.5rem;
5582
5585
 
@@ -7775,29 +7778,34 @@ const ElementChips = React.memo(({ type, elementConfig }) => {
7775
7778
 
7776
7779
  const ElementControl = ({ elementConfig }) => {
7777
7780
  const { t } = useGlobalContext();
7778
- const { dataSources, controls, changeControls } = useWidgetContext(exports.WidgetType.FeatureCard);
7781
+ const { attributes, layerInfo, dataSources, controls, changeControls } = useWidgetContext(exports.WidgetType.FeatureCard);
7779
7782
  const [value, setValue] = React.useState();
7780
7783
  const { options, attributeName } = elementConfig || {};
7781
- 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;
7782
7786
  const dataSource = React.useMemo(() => getDataSource(relatedDataSource, dataSources), [relatedDataSource, dataSources]);
7783
7787
  const items = React.useMemo(() => {
7784
- if (!dataSource?.features?.length || !attributeName) {
7788
+ if (!dataSource?.features?.length || !attrName) {
7785
7789
  return [];
7786
7790
  }
7787
7791
  return dataSource.features.map(({ attributes }) => ({
7788
- value: attributes?.[attributeName] || "",
7789
- text: attributes?.[attributeName] || "",
7792
+ value: attributes?.[attrName] || "",
7793
+ text: attributes?.[attrName] || "",
7790
7794
  }));
7791
- }, [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]);
7792
7800
  const handleChange = React.useCallback(([option]) => {
7793
7801
  setValue(option?.value);
7794
- if (attributeName && changeControls) {
7802
+ if (attrName && changeControls) {
7795
7803
  changeControls({
7796
- [attributeName]: option?.value,
7804
+ [attrName]: option?.value,
7797
7805
  });
7798
7806
  }
7799
- }, [changeControls, attributeName]);
7800
- 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 }));
7801
7809
  };
7802
7810
 
7803
7811
  const StyledIconFontSizeMixin = styled.css `