@evergis/react 3.1.120 → 3.1.121
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.
|
@@ -45,6 +45,7 @@ export interface BaseMapSettings {
|
|
|
45
45
|
export type EditAttributeValue = string | number | boolean;
|
|
46
46
|
export interface EditAttribute {
|
|
47
47
|
name: string;
|
|
48
|
+
type?: "dropdown" | "checkbox" | "chip" | "autocomplete";
|
|
48
49
|
defaultValue?: EditAttributeValue;
|
|
49
50
|
relatedDataSource?: string;
|
|
50
51
|
}
|
package/dist/index.js
CHANGED
|
@@ -7383,14 +7383,24 @@ const EditContainer = ({ type, elementConfig, renderElement }) => {
|
|
|
7383
7383
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: style, children: [jsxRuntime.jsx(ContainerAlias, { hasBottomMargin: true, children: renderElement({ id: "alias" }) }), jsxRuntime.jsx(ContainerValue, { children: renderElement({ id: "value" }) })] })] }));
|
|
7384
7384
|
};
|
|
7385
7385
|
|
|
7386
|
+
const getControlTemplateName = (type) => {
|
|
7387
|
+
switch (type) {
|
|
7388
|
+
case "dropdown":
|
|
7389
|
+
default: return exports.ContainerTemplate.EditDropdown;
|
|
7390
|
+
}
|
|
7391
|
+
};
|
|
7392
|
+
|
|
7386
7393
|
const EditGroupContainer = React.memo(({ type, elementConfig, renderElement }) => {
|
|
7387
7394
|
const { config, attributes, layerInfo, expandedContainers } = useWidgetContext(type);
|
|
7388
7395
|
const getRenderContainerItem = useRenderContainerItem(type, renderElement);
|
|
7389
7396
|
const { id, options } = elementConfig || {};
|
|
7390
7397
|
const { editAttributes } = options || {};
|
|
7391
7398
|
const renderContainer = React.useCallback((attribute) => {
|
|
7399
|
+
const editAttribute = editAttributes?.find(({ name }) => name === attribute);
|
|
7392
7400
|
const itemAttribute = attributes.find(({ name }) => name === attribute);
|
|
7393
|
-
const templateName =
|
|
7401
|
+
const templateName = editAttribute?.type
|
|
7402
|
+
? getControlTemplateName(editAttribute.type)
|
|
7403
|
+
: getTemplateNameFromAttribute(itemAttribute);
|
|
7394
7404
|
const itemConfig = {
|
|
7395
7405
|
...elementConfig,
|
|
7396
7406
|
children: elementConfig.children.map(child => ({ ...child, attributeName: attribute })),
|
|
@@ -7403,7 +7413,7 @@ const EditGroupContainer = React.memo(({ type, elementConfig, renderElement }) =
|
|
|
7403
7413
|
return null;
|
|
7404
7414
|
}
|
|
7405
7415
|
return (jsxRuntime.jsx(ContainerTemplateValue, { id: attribute, type: type, config: config, elementConfig: itemConfig, layerInfo: layerInfo, attributes: attributes, innerComponent: getContainerComponent(templateName), isVisible: isVisibleContainer(id, expandable, expanded, expandedContainers), renderElement: render }, attribute));
|
|
7406
|
-
}, [id, attributes, elementConfig, expandedContainers]);
|
|
7416
|
+
}, [id, attributes, elementConfig, expandedContainers, editAttributes]);
|
|
7407
7417
|
return editAttributes?.length ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: editAttributes.map(attribute => renderContainer(attribute.name)) })) : (renderContainer());
|
|
7408
7418
|
});
|
|
7409
7419
|
|
|
@@ -7415,7 +7425,7 @@ const useEditAttribute = (type, elementConfig) => {
|
|
|
7415
7425
|
const valueElement = children.find(({ id }) => id === "value");
|
|
7416
7426
|
return valueElement?.attributeName;
|
|
7417
7427
|
}, [children]);
|
|
7418
|
-
const editAttribute = React.useMemo(() => editAttributes
|
|
7428
|
+
const editAttribute = React.useMemo(() => editAttributes?.find(({ name }) => name === attributeName), [editAttributes, attributeName]);
|
|
7419
7429
|
const attributeValue = React.useMemo(() => {
|
|
7420
7430
|
const value = controls[attributeName] === undefined
|
|
7421
7431
|
? attributes.find(({ name }) => name === attributeName)?.value
|
|
@@ -7462,12 +7472,12 @@ const EditDropdownContainer = ({ type, elementConfig, renderElement }) => {
|
|
|
7462
7472
|
const { id, style, options } = elementConfig || {};
|
|
7463
7473
|
const { placeholder, label, width } = options || {};
|
|
7464
7474
|
const optionsList = React.useMemo(() => dataSource?.features.map(item => {
|
|
7465
|
-
const value = item[editAttribute?.name] || null;
|
|
7475
|
+
const value = item.attributes[editAttribute?.name] || null;
|
|
7466
7476
|
return { text: value, value };
|
|
7467
7477
|
}), [dataSource?.features, editAttribute.name]);
|
|
7468
7478
|
const onChange = React.useCallback(([option]) => {
|
|
7469
|
-
changeControls({ [editAttribute?.name]: option });
|
|
7470
|
-
}, [editAttribute
|
|
7479
|
+
changeControls({ [editAttribute?.name]: option.value });
|
|
7480
|
+
}, [editAttribute?.name, changeControls]);
|
|
7471
7481
|
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_STYLE, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsx(ContainerValue, { children: jsxRuntime.jsx(uilibGl.Dropdown, { zIndex: 1000, label: label, placeholder: placeholder, options: optionsList, value: attributeValue ?? editAttribute.defaultValue, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, onChange: onChange }) })] }));
|
|
7472
7482
|
};
|
|
7473
7483
|
|