@evergis/react 4.0.23-alpha.2 → 4.0.23-alpha.3
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/index.js
CHANGED
|
@@ -7503,7 +7503,10 @@ const EditGroupContainer = React.memo(({ type, elementConfig, renderElement }) =
|
|
|
7503
7503
|
layerInfo,
|
|
7504
7504
|
expandedContainers,
|
|
7505
7505
|
]);
|
|
7506
|
-
|
|
7506
|
+
if (!controls?.length) {
|
|
7507
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: attributes.map(({ attributeName }) => renderContainer(attributeName)) }));
|
|
7508
|
+
}
|
|
7509
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: controls.map(({ targetAttributeName }) => renderContainer(targetAttributeName)) }));
|
|
7507
7510
|
});
|
|
7508
7511
|
|
|
7509
7512
|
const useEditControl = (type, elementConfig) => {
|
|
@@ -7512,25 +7515,26 @@ const useEditControl = (type, elementConfig) => {
|
|
|
7512
7515
|
const { controls: controlsOption } = options || {};
|
|
7513
7516
|
const valueElement = React.useMemo(() => children.find(({ id }) => id === "value"), [children]);
|
|
7514
7517
|
const control = React.useMemo(() => controlsOption?.find(item => item.targetAttributeName === valueElement.attributeName), [controlsOption, valueElement.attributeName]);
|
|
7518
|
+
const attributeName = (control?.targetAttributeName ?? valueElement?.attributeName);
|
|
7515
7519
|
const value = React.useMemo(() => {
|
|
7516
|
-
const currentValue = controls[
|
|
7517
|
-
? attributes.find(({ attributeName }) =>
|
|
7518
|
-
: controls[
|
|
7520
|
+
const currentValue = controls[attributeName] === undefined
|
|
7521
|
+
? attributes.find(({ attributeName: name }) => name === attributeName)?.value
|
|
7522
|
+
: controls[attributeName];
|
|
7519
7523
|
return currentValue ?? control?.defaultValue;
|
|
7520
7524
|
}, [
|
|
7521
7525
|
controls,
|
|
7522
|
-
|
|
7526
|
+
attributeName,
|
|
7523
7527
|
control?.defaultValue,
|
|
7524
7528
|
attributes,
|
|
7525
7529
|
]);
|
|
7526
|
-
const dataSource = React.useMemo(() => dataSources?.find(({ name }) => name === control
|
|
7530
|
+
const dataSource = React.useMemo(() => dataSources?.find(({ name }) => name === control?.relatedDataSource), [control?.relatedDataSource, dataSources]);
|
|
7527
7531
|
const items = React.useMemo(() => control?.variants?.map(v => String(v.text || v.value)) ||
|
|
7528
7532
|
dataSource?.features.map(item => item.properties[control?.attributeName] || null) || [], [control?.variants, dataSource?.features, control?.attributeName]);
|
|
7529
7533
|
const onChange = React.useCallback((newValue) => {
|
|
7530
7534
|
changeControls({
|
|
7531
|
-
[
|
|
7535
|
+
[attributeName]: newValue,
|
|
7532
7536
|
});
|
|
7533
|
-
}, [changeControls,
|
|
7537
|
+
}, [changeControls, attributeName]);
|
|
7534
7538
|
return React.useMemo(() => ({ control, value, dataSource, items, onChange }), [control, value, dataSource, items, onChange]);
|
|
7535
7539
|
};
|
|
7536
7540
|
|
|
@@ -7558,14 +7562,14 @@ const EditStringContainer = ({ type, elementConfig, renderElement, }) => {
|
|
|
7558
7562
|
const EditNumberContainer = ({ type, elementConfig, renderElement, }) => {
|
|
7559
7563
|
const { value, control, onChange } = useEditControl(type, elementConfig);
|
|
7560
7564
|
const { id, style } = elementConfig || {};
|
|
7561
|
-
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_CONTAINER_STYLE, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsxs(ContainerValue, { column: true, children: [jsxRuntime.jsx(uilibGl.Input, { value: value?.toString(), width: "100%", onChange: (e) => onChange(e.target.value) }), jsxRuntime.jsx(uilibGl.Slider, { value: value, min: control
|
|
7565
|
+
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_CONTAINER_STYLE, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsxs(ContainerValue, { column: true, children: [jsxRuntime.jsx(uilibGl.Input, { value: value?.toString(), width: "100%", onChange: (e) => onChange(e.target.value) }), jsxRuntime.jsx(uilibGl.Slider, { value: value, min: control?.minValue, max: control?.maxValue, step: control?.step, sliderWidth: "100%", primary: true, onChange: onChange })] })] }));
|
|
7562
7566
|
};
|
|
7563
7567
|
|
|
7564
7568
|
const EditDropdownContainer = ({ type, elementConfig, renderElement, }) => {
|
|
7565
7569
|
const { value, control, items, onChange } = useEditControl(type, elementConfig);
|
|
7566
7570
|
const { id, style } = elementConfig || {};
|
|
7567
7571
|
const optionsList = React.useMemo(() => items.map(item => ({ text: item, value: item })), [items]);
|
|
7568
|
-
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_CONTAINER_STYLE, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsx(ContainerValue, { column: true, children: jsxRuntime.jsx(uilibGl.Dropdown, { zIndex: 1000, label: control
|
|
7572
|
+
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_CONTAINER_STYLE, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsx(ContainerValue, { column: true, children: jsxRuntime.jsx(uilibGl.Dropdown, { zIndex: 1000, label: control?.label, placeholder: control?.placeholder, options: optionsList, value: value, width: `${control?.width ?? DEFAULT_DROPDOWN_WIDTH}px`, onChange: ([option]) => onChange(option.value) }) })] }));
|
|
7569
7573
|
};
|
|
7570
7574
|
|
|
7571
7575
|
const CheckboxWrapper = styled(ContainerValue) `
|