@evergis/react 4.0.164 → 4.0.166
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/components/Dashboard/componentTypes.d.ts +29 -4
- package/dist/components/Dashboard/containers/TaskContainer/components/StatusWaitingButton/index.d.ts +2 -11
- package/dist/components/Dashboard/containers/TaskContainer/components/TaskButton/index.d.ts +4 -0
- package/dist/components/Dashboard/containers/TaskContainer/components/TaskButton/styled.d.ts +2 -0
- package/dist/components/Dashboard/containers/TaskContainer/hooks/useTaskButtonState.d.ts +13 -0
- package/dist/components/Dashboard/containers/TaskContainer/types.d.ts +16 -0
- package/dist/components/Dashboard/elements/ElementButton/constants.d.ts +6 -0
- package/dist/components/Dashboard/elements/ElementButton/utils/getElementButtonProps.d.ts +8 -0
- package/dist/components/Dashboard/types.d.ts +23 -2
- package/dist/index.js +127 -34
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +127 -34
- package/dist/react.esm.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { QueryLayerServiceInfoDc } from '@evergis/api';
|
|
2
|
-
import { ClientFeatureAttribute, ConfigContainer, ConfigContainerChild, ConfigContainerHeader, ConfigOptions, ContainerProps, ContainerTemplate, FilterType, HeaderTemplate, NumericSizeOptions } from './types';
|
|
3
|
-
export type ElementButtonOptions =
|
|
3
|
+
import { ClientFeatureAttribute, ConfigButtonOptions, ConfigContainer, ConfigContainerChild, ConfigContainerHeader, ConfigOptions, ContainerProps, ContainerTemplate, FilterType, HeaderTemplate, NumericSizeOptions } from './types';
|
|
4
|
+
export type ElementButtonOptions = ConfigButtonOptions & Pick<ConfigOptions, "icon" | "radius">;
|
|
4
5
|
export interface ElementButtonConfig extends Omit<ConfigContainerChild, "options" | "type"> {
|
|
5
6
|
type?: "button";
|
|
6
7
|
options?: ElementButtonOptions;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Поведение, которое передаёт контейнер-хозяин слота `button` (например, Task).
|
|
11
|
+
* С `onClick` кнопка рисуется и без ссылки в атрибуте.
|
|
12
|
+
*/
|
|
13
|
+
export interface ElementButtonOverrides {
|
|
14
|
+
title?: string;
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
color?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
onClick?: VoidFunction;
|
|
19
|
+
}
|
|
20
|
+
export interface ElementButtonProps extends Omit<ContainerProps, "elementConfig" | "onClick">, ElementButtonOverrides {
|
|
9
21
|
elementConfig?: ElementButtonConfig;
|
|
10
22
|
}
|
|
11
23
|
export type ElementCameraOptions = Pick<ConfigOptions, "expandable" | "expanded">;
|
|
@@ -472,9 +484,22 @@ export interface TabsContainerProps extends Omit<ContainerProps, "elementConfig"
|
|
|
472
484
|
elementConfig?: TabsContainerConfig;
|
|
473
485
|
}
|
|
474
486
|
export type TaskContainerOptions = Pick<ConfigOptions, "title" | "relatedResources" | "center" | "icon" | "statusColors" | "responseFilters" | "useNotifications"> & ContainerBoxOptions;
|
|
475
|
-
export interface
|
|
487
|
+
export interface TaskButtonChild extends Omit<ElementButtonConfig, "id"> {
|
|
488
|
+
id: "button";
|
|
489
|
+
}
|
|
490
|
+
export interface TaskTitleChild extends Omit<ConfigContainerChild, "id" | "type"> {
|
|
491
|
+
id: "title";
|
|
492
|
+
type?: "text";
|
|
493
|
+
}
|
|
494
|
+
export interface TaskTitleIconChild extends Omit<ConfigContainerChild, "id" | "type"> {
|
|
495
|
+
id: "titleIcon";
|
|
496
|
+
type?: "icon";
|
|
497
|
+
}
|
|
498
|
+
export type TaskContainerChild = TaskButtonChild | TaskTitleChild | TaskTitleIconChild;
|
|
499
|
+
export interface TaskContainerConfig extends Omit<ConfigContainerChild, "options" | "templateName" | "children"> {
|
|
476
500
|
templateName?: ContainerTemplate.Task;
|
|
477
501
|
options?: TaskContainerOptions;
|
|
502
|
+
children?: TaskContainerChild[];
|
|
478
503
|
}
|
|
479
504
|
export interface TaskContainerProps extends Omit<ContainerProps, "elementConfig"> {
|
|
480
505
|
elementConfig?: TaskContainerConfig;
|
package/dist/components/Dashboard/containers/TaskContainer/components/StatusWaitingButton/index.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const StatusWaitingButton: FC<{
|
|
5
|
-
title: string;
|
|
6
|
-
icon: IconTypesKeys;
|
|
7
|
-
status: RemoteTaskStatus;
|
|
8
|
-
statusColors: Record<RemoteTaskStatus, string>;
|
|
9
|
-
isWaiting: boolean;
|
|
10
|
-
isDisabled: boolean;
|
|
11
|
-
onClick: VoidFunction;
|
|
12
|
-
}>;
|
|
2
|
+
import { TaskButtonProps } from '../../types';
|
|
3
|
+
export declare const StatusWaitingButton: FC<TaskButtonProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RemoteTaskStatus } from '@evergis/api';
|
|
2
|
+
import { IconTypesKeys } from '@evergis/uilib-gl';
|
|
3
|
+
interface UseTaskButtonStateProps {
|
|
4
|
+
status: RemoteTaskStatus;
|
|
5
|
+
title?: string;
|
|
6
|
+
icon?: IconTypesKeys;
|
|
7
|
+
}
|
|
8
|
+
/** Текст и иконка кнопки запуска: в исходном состоянии — заданные, иначе — по статусу задачи. */
|
|
9
|
+
export declare const useTaskButtonState: ({ status, title, icon }: UseTaskButtonStateProps) => {
|
|
10
|
+
title: string;
|
|
11
|
+
iconKind: "symbol" | "function" | "auto" | "button" | "data" | "label" | "legend" | "link" | "map" | "menu" | "param" | "search" | "section" | "time" | "ellipse" | "filter" | "image" | "stop" | "text" | "id" | "cursor" | "points" | "restart" | "scale" | "key" | "download" | "list" | "error" | "next" | "alert" | "grid" | "heading" | "log" | "tree" | "bold" | "paint" | "layers" | "delete" | "save" | "menu_vertical" | "menu_horizontal" | "edit" | "tools" | "filter_apply" | "date" | "zoom_to" | "geom_raster" | "geom_point" | "geom_polygon" | "geom_multipolygon" | "geom_polyline" | "share" | "refresh" | "basemap" | "plus" | "minus" | "select_rect" | "select_circle" | "select_polygon" | "clear" | "measure_length" | "measure_area" | "home" | "bookmark" | "arrow_forward" | "arrow_back" | "message" | "location_pointer" | "close" | "maximize" | "minimize" | "maximize_solid" | "minimize_solid" | "to_last" | "play" | "prev" | "to_first" | "pause" | "upload" | "hide" | "expand" | "reduce" | "input_resizer" | "input_dropdown" | "classification" | "copy" | "phone" | "like" | "export_excel" | "location_coordinate" | "sorting_asc" | "sorting_des" | "password_show" | "password_hide" | "success" | "warning" | "star" | "social_vk" | "social_fb" | "social_google" | "social_github" | "social_vk_simple" | "social_fb_simple" | "social_google_simple" | "social_medium" | "geoprocessing" | "info" | "feedback" | "panel_hide" | "panel_show" | "feature_add" | "logo" | "lock" | "unlock" | "users" | "displayfield" | "textfile" | "image_paste" | "step_back" | "step_forward" | "pipette" | "calculation" | "geom_move" | "geom_poly_vertex" | "geom_poly_hole" | "geom_poly_slice" | "geom_poly_reshape" | "geom_poly_ungroup" | "geom_poly_autocomplete" | "geom_line_vertex" | "geom_line_addpart" | "geom_line_slice" | "geom_line_reshape" | "geom_line_ungroup" | "geom_undefined" | "icon_undefined" | "inverse" | "location_current" | "tools_buffer" | "tools_zones" | "tools_print" | "tools_spatial_selection" | "tools_aggregation" | "zip" | "catalog" | "catalog_variant" | "question" | "alpha" | "betta" | "dragdrop" | "equals" | "not_equals" | "contains" | "not_contains" | "greater_than" | "greater_or_equal" | "less_than" | "less_or_equal" | "starts_with" | "not_starts_with" | "ends_with" | "not_ends_with" | "empty" | "filled" | "raster_visible" | "raster_invisible" | "editgeom_point_addpart" | "divide" | "filter_layer" | "filter_table" | "img_generate" | "finish" | "transparentize" | "textLeft" | "textRight" | "textCenter" | "textJustify" | "externalway" | "evergis" | "geometryUnite" | "geometryCrop" | "roles" | "icon_block" | "configurations" | "settings_table" | "set_edit" | "set_read" | "set_configure" | "set_time" | "snapping" | "snap_1" | "snap_2" | "snap_3" | "slide" | "tags" | "statistics" | "alphabet_sort_za" | "alphabet_sort_az" | "inside_range" | "outside_range" | "tms" | "arc_gis" | "date_outside" | "wms_link" | "object_size" | "stroke_width" | "point_select" | "select_line" | "apply_selection" | "report" | "refresh_circle" | "date_filter" | "layer_filter_applied" | "attribute_filter_applied" | "geometry_selection_applied" | "attribute_filter" | "layer_filter" | "layers_add" | "geo_location" | "geom_types" | "date_aggregation" | "public_group" | "social_tg" | "rounded_triangle" | "zoom_in" | "zoom_out" | "checkboxes" | "sum" | "datetime" | "double" | "int" | "local_tile_service" | "arcgis_service" | "wms_service" | "text_format" | "coordinates_actions" | "xy" | "group_features" | "ungroup_features" | "preview" | "triangle" | "rectangle" | "themed_symbol" | "selection" | "table_link" | "cell_size" | "symbol_library" | "globe" | "tree_folder_closed" | "tree_folder_opened" | "add_group" | "ungroup" | "feature_card" | "moon" | "sun" | "logout" | "search_selection" | "suggestions" | "social_dzen" | "social_youtube" | "query" | "table_empty" | "shared_group" | "text_frame" | "file_catalog" | "attachment" | "stats" | "loading_circle" | "layer_option" | "change_geom" | "settings_horizontal" | "text_editor" | "dashboard_loading" | "dashboard_placeholder" | "sort" | "postgresql" | "bigquery" | "amazon_s3" | "databricks" | "redshift" | "server_connection" | "service_connection" | "column_increment" | "column_unique" | "column_nullable" | "projection" | "card" | "zones_selection" | "walking" | "selection_route" | "pulse" | "tree_vertical" | "tool_settings" | "folder_outline" | "percent" | "run" | "table_view" | "text_view" | "in_map" | "tables" | "collapse" | "expand_all" | "quote" | "list_ordered" | "list_unordered" | "italic" | "filter_switcher" | "arrow_down" | "arrow_up" | "new_window" | "line_numbers" | "python" | "config" | "pc" | "social_yandex" | "tab_icon" | "disk" | "ram" | "cpu" | "select_point" | "page_add" | "page_menu" | "stack" | "calc_attribute" | "calc_attribute_attribute" | "calc_attribute_value" | "calc_geometry" | "camera" | "pdf" | "slideshow" | "edit_container" | "default_attributes" | "progress_bar" | "section_add" | "section_remove" | "connections" | "pie_chart" | "line_chart" | "stack_chart" | "datasource" | "tabs" | "check_toggle" | "cadastr" | "office" | "layer_eye" | "ai" | "bool" | "json" | "rollup" | "no_geom" | "symbol_text" | "text_circle" | "heatmap" | "cube" | "extrude" | "transition" | "stop_circle" | "token" | "star_symbol" | "text_plain" | "geom_shapes";
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RemoteTaskStatus } from '@evergis/api';
|
|
2
|
+
import { IconTypesKeys } from '@evergis/uilib-gl';
|
|
3
|
+
import { TaskButtonChild, WidgetType } from '../../types';
|
|
4
|
+
export interface TaskButtonProps {
|
|
5
|
+
title: string;
|
|
6
|
+
icon?: IconTypesKeys;
|
|
7
|
+
status: RemoteTaskStatus;
|
|
8
|
+
statusColors?: Record<RemoteTaskStatus, string>;
|
|
9
|
+
isWaiting: boolean;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
onClick: VoidFunction;
|
|
12
|
+
}
|
|
13
|
+
export interface TaskSlotButtonProps extends TaskButtonProps {
|
|
14
|
+
type?: WidgetType;
|
|
15
|
+
buttonConfig: TaskButtonChild;
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IconButtonVariant } from '@evergis/uilib-gl';
|
|
2
|
+
import { ElementButtonOptions } from '../../types';
|
|
3
|
+
/** Опции внешнего вида: хотя бы одна из них переводит кнопку-ссылку на IconButton. */
|
|
4
|
+
export declare const ELEMENT_BUTTON_APPEARANCE_KEYS: (keyof ElementButtonOptions)[];
|
|
5
|
+
export declare const ELEMENT_BUTTON_COLOR_FLAGS: readonly ["primary", "secondary", "error", "violet"];
|
|
6
|
+
export declare const DEFAULT_ELEMENT_BUTTON_VARIANT: IconButtonVariant;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IIconButtonProps } from '@evergis/uilib-gl';
|
|
2
|
+
import { ElementButtonOptions } from '../../../types';
|
|
3
|
+
export declare const hasButtonAppearance: (options?: ElementButtonOptions) => boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Пропсы IconButton из опций элемента. Без цвета и флагов цвета кнопка — primary;
|
|
6
|
+
* нейтральная задаётся явным `primary: false`. `color` контейнера перекрывает цвет из опций.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getElementButtonProps: (options?: ElementButtonOptions, color?: string) => IIconButtonProps;
|
|
@@ -2,7 +2,7 @@ import { CSSProperties, FC, ReactNode } from 'react';
|
|
|
2
2
|
import { FeatureCollection, Geometry } from 'geojson';
|
|
3
3
|
import { i18n } from 'i18next';
|
|
4
4
|
import { PieChartData, BarChartMarker } from '@evergis/charts';
|
|
5
|
-
import { IconTypesKeys, IOption } from '@evergis/uilib-gl';
|
|
5
|
+
import { IconButtonShape, IconButtonSize, IconButtonVariant, IconTypesKeys, IOption } from '@evergis/uilib-gl';
|
|
6
6
|
import { CircleLayerSpecification, FillLayerSpecification, LineLayerSpecification } from 'maplibre-gl';
|
|
7
7
|
import { AttributeType, EqlRequestDc, FeatureDc, OgcGeometryType, PagedFeaturesListDc, PositionDc, QueryLayerServiceInfoDc, RemoteTaskStatus, StringSubType, AttributesConfigurationDc } from '@evergis/api';
|
|
8
8
|
import { FeatureAttributeValue, EditGeometryType, ThemeName } from '../../types';
|
|
@@ -413,6 +413,27 @@ export interface ConfigChartOptions {
|
|
|
413
413
|
/** Подписи осей и подпись оси X. Работает только у линейного графика. */
|
|
414
414
|
axis?: ConfigChartAxisOptions;
|
|
415
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Внешний вид кнопки (`IconButton` из uilib-gl). Скругление вручную — `radius` (px)
|
|
418
|
+
* из {@link ConfigLayoutOptions}, иконка — `icon` из {@link ConfigVisualOptions}.
|
|
419
|
+
*/
|
|
420
|
+
export interface ConfigButtonOptions {
|
|
421
|
+
/** Заливка и обводка: `solid` | `soft` | `outline` | `ghost`. */
|
|
422
|
+
variant?: IconButtonVariant;
|
|
423
|
+
/** Произвольный CSS-цвет; перекрывает флаги цвета. Оттенки наведения и нажатия вычисляются. */
|
|
424
|
+
color?: string;
|
|
425
|
+
/** Флаги цвета, приоритет: primary → secondary → error → violet. Без флагов и `color` — нейтральный. */
|
|
426
|
+
primary?: boolean;
|
|
427
|
+
secondary?: boolean;
|
|
428
|
+
error?: boolean;
|
|
429
|
+
violet?: boolean;
|
|
430
|
+
/** Высота 24 / 32 / 40 / 48. */
|
|
431
|
+
size?: IconButtonSize;
|
|
432
|
+
/** `square` — скругление по размеру, `round` — пилюля/круг. */
|
|
433
|
+
shape?: IconButtonShape;
|
|
434
|
+
/** Иконка справа от текста. */
|
|
435
|
+
iconRight?: boolean;
|
|
436
|
+
}
|
|
416
437
|
/** Иконки/изображения. */
|
|
417
438
|
export interface ConfigVisualOptions {
|
|
418
439
|
icon?: IconTypesKeys;
|
|
@@ -561,7 +582,7 @@ export type ConfigNotifications = "all" | "my" | string[];
|
|
|
561
582
|
* `Pick<ConfigOptions, ...>`, продолжают работать. Для нового кода предпочтительно делать
|
|
562
583
|
* `Pick<Config<Domain>Options, ...>` — это лучше документирует, к какому домену относится опция.
|
|
563
584
|
*/
|
|
564
|
-
export interface ConfigOptions extends ConfigLayoutOptions, ConfigTypographyOptions, ConfigExpandableOptions, ConfigDataSourceBindingOptions, ConfigChartOptions, ConfigVisualOptions, ConfigTextDisplayOptions, ConfigCollectionOptions, ConfigMapLayerOptions, ConfigEditOptions, ConfigVoteOptions, ConfigMiscOptions {
|
|
585
|
+
export interface ConfigOptions extends ConfigLayoutOptions, ConfigTypographyOptions, ConfigExpandableOptions, ConfigDataSourceBindingOptions, ConfigChartOptions, ConfigButtonOptions, ConfigVisualOptions, ConfigTextDisplayOptions, ConfigCollectionOptions, ConfigMapLayerOptions, ConfigEditOptions, ConfigVoteOptions, ConfigMiscOptions {
|
|
565
586
|
}
|
|
566
587
|
/**
|
|
567
588
|
* Настройки атрибута источника данных, заданные в конфиге.
|
package/dist/index.js
CHANGED
|
@@ -14201,21 +14201,124 @@ const StyledButton = styled(uilibGl.FlatButton).withConfig({ displayName: "Style
|
|
|
14201
14201
|
`}
|
|
14202
14202
|
`;
|
|
14203
14203
|
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
const
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14204
|
+
/** Текст и иконка кнопки запуска: в исходном состоянии — заданные, иначе — по статусу задачи. */
|
|
14205
|
+
const useTaskButtonState = ({ status, title, icon }) => {
|
|
14206
|
+
const { t } = useGlobalContext();
|
|
14207
|
+
const buttonTitle = React.useMemo(() => {
|
|
14208
|
+
if (status === api.RemoteTaskStatus.Process)
|
|
14209
|
+
return t("stop", { ns: "dashboard", defaultValue: "Остановить" });
|
|
14210
|
+
if (status === api.RemoteTaskStatus.Unknown)
|
|
14211
|
+
return title;
|
|
14212
|
+
return STATUS_TITLES[status];
|
|
14213
|
+
}, [status, t, title]);
|
|
14214
|
+
const iconKind = React.useMemo(() => (status === api.RemoteTaskStatus.Unknown ? icon : STATUS_ICONS[status]), [icon, status]);
|
|
14215
|
+
return { title: buttonTitle, iconKind };
|
|
14216
|
+
};
|
|
14217
|
+
|
|
14218
|
+
const StatusWaitingButton = ({ title, icon = "play", status, statusColors, isWaiting, isDisabled, onClick, }) => {
|
|
14219
|
+
const { themeName } = useGlobalContext();
|
|
14220
|
+
const { title: renderTitle, iconKind } = useTaskButtonState({ status, title, icon });
|
|
14221
|
+
const renderIcon = React.useMemo(() => (jsxRuntime.jsx(uilibGl.Flex, { alignItems: "center", marginRight: renderTitle ? "0.5rem" : 0, children: isWaiting ? jsxRuntime.jsx(uilibGl.CircularProgress, { diameter: 1, mono: true }) : jsxRuntime.jsx(uilibGl.Icon, { kind: iconKind }) })), [iconKind, isWaiting, renderTitle]);
|
|
14216
14222
|
return (jsxRuntime.jsx(uilibGl.ThemeProvider, { theme: uilibGl.darkTheme, children: jsxRuntime.jsxs(StyledButton, { status: status, statusColors: statusColors, disabled: isDisabled, themeName: themeName, onClick: onClick, children: [renderIcon, renderTitle] }) }));
|
|
14217
14223
|
};
|
|
14218
14224
|
|
|
14225
|
+
const ImageContainerButton = styled(uilibGl.FlatButton).withConfig({ displayName: "ImageContainerButton", componentId: "sc-nq6mg4" }) `
|
|
14226
|
+
min-height: 1.5rem;
|
|
14227
|
+
border-radius: ${({ theme: { borderRadius } }) => borderRadius.large};
|
|
14228
|
+
background-color: ${({ theme: { palette } }) => palette.primary};
|
|
14229
|
+
text-transform: none;
|
|
14230
|
+
|
|
14231
|
+
:hover {
|
|
14232
|
+
background-color: ${({ theme: { palette } }) => palette.primaryDeep};
|
|
14233
|
+
}
|
|
14234
|
+
`;
|
|
14235
|
+
|
|
14236
|
+
/** Опции внешнего вида: хотя бы одна из них переводит кнопку-ссылку на IconButton. */
|
|
14237
|
+
const ELEMENT_BUTTON_APPEARANCE_KEYS = [
|
|
14238
|
+
"variant",
|
|
14239
|
+
"color",
|
|
14240
|
+
"primary",
|
|
14241
|
+
"secondary",
|
|
14242
|
+
"error",
|
|
14243
|
+
"violet",
|
|
14244
|
+
"size",
|
|
14245
|
+
"shape",
|
|
14246
|
+
"radius",
|
|
14247
|
+
"icon",
|
|
14248
|
+
"iconRight",
|
|
14249
|
+
];
|
|
14250
|
+
const ELEMENT_BUTTON_COLOR_FLAGS = ["primary", "secondary", "error", "violet"];
|
|
14251
|
+
const DEFAULT_ELEMENT_BUTTON_VARIANT = "solid";
|
|
14252
|
+
|
|
14253
|
+
const hasButtonAppearance = (options) => !!options && ELEMENT_BUTTON_APPEARANCE_KEYS.some(key => options[key] !== undefined);
|
|
14254
|
+
/**
|
|
14255
|
+
* Пропсы IconButton из опций элемента. Без цвета и флагов цвета кнопка — primary;
|
|
14256
|
+
* нейтральная задаётся явным `primary: false`. `color` контейнера перекрывает цвет из опций.
|
|
14257
|
+
*/
|
|
14258
|
+
const getElementButtonProps = (options = {}, color) => {
|
|
14259
|
+
const { variant, primary, secondary, error, violet, size, shape, radius, icon, iconRight } = options;
|
|
14260
|
+
const buttonColor = color ?? options.color;
|
|
14261
|
+
const hasColor = buttonColor !== undefined || ELEMENT_BUTTON_COLOR_FLAGS.some(flag => options[flag] !== undefined);
|
|
14262
|
+
return {
|
|
14263
|
+
variant: variant ?? DEFAULT_ELEMENT_BUTTON_VARIANT,
|
|
14264
|
+
color: buttonColor,
|
|
14265
|
+
primary: hasColor ? primary : true,
|
|
14266
|
+
secondary,
|
|
14267
|
+
error,
|
|
14268
|
+
violet,
|
|
14269
|
+
size,
|
|
14270
|
+
shape,
|
|
14271
|
+
radius,
|
|
14272
|
+
kind: icon,
|
|
14273
|
+
iconRight,
|
|
14274
|
+
};
|
|
14275
|
+
};
|
|
14276
|
+
|
|
14277
|
+
const ElementButton = React.memo(({ type, elementConfig, title, icon, color, disabled, onClick }) => {
|
|
14278
|
+
const { attributes } = useWidgetContext(type);
|
|
14279
|
+
const { value, attributeName, options } = elementConfig || {};
|
|
14280
|
+
const link = React.useMemo(() => getAttributeByName(attributeName, attributes)?.value, [attributeName, attributes]);
|
|
14281
|
+
const buttonProps = React.useMemo(() => getElementButtonProps(options, color), [options, color]);
|
|
14282
|
+
const text = React.useMemo(() => title ?? (value === undefined || value === null ? "" : String(value)), [title, value]);
|
|
14283
|
+
const openLink = React.useCallback(() => window.open(link), [link]);
|
|
14284
|
+
if (!onClick && (!link || typeof link !== "string"))
|
|
14285
|
+
return null;
|
|
14286
|
+
if (!onClick && !hasButtonAppearance(options)) {
|
|
14287
|
+
return jsxRuntime.jsx(ImageContainerButton, { onClick: openLink, children: text });
|
|
14288
|
+
}
|
|
14289
|
+
return (jsxRuntime.jsx(uilibGl.IconButton, { ...buttonProps, icon: icon, disabled: disabled, tabIndex: 0, onClick: onClick ?? openLink, children: text || undefined }));
|
|
14290
|
+
});
|
|
14291
|
+
|
|
14292
|
+
/** Спиннер ожидания в цвете текста кнопки: круг-подложка приглушён, дуга — сплошная. */
|
|
14293
|
+
const TaskButtonSpinner = styled(uilibGl.Flex).withConfig({ displayName: "TaskButtonSpinner", componentId: "sc-192613c" }) `
|
|
14294
|
+
align-items: center;
|
|
14295
|
+
|
|
14296
|
+
circle {
|
|
14297
|
+
stroke: currentColor;
|
|
14298
|
+
}
|
|
14299
|
+
|
|
14300
|
+
circle:first-of-type {
|
|
14301
|
+
opacity: 0.3;
|
|
14302
|
+
}
|
|
14303
|
+
`;
|
|
14304
|
+
|
|
14305
|
+
/** Кнопка запуска из слота `button`: вид — из слота, поведение и статусы — от контейнера. */
|
|
14306
|
+
const TaskButton = ({ type, buttonConfig, title, icon, status, statusColors, isWaiting, isDisabled, onClick, }) => {
|
|
14307
|
+
const { value, options } = buttonConfig;
|
|
14308
|
+
const slotTitle = React.useMemo(() => (value === undefined || value === null || value === "" ? title : String(value)), [
|
|
14309
|
+
title,
|
|
14310
|
+
value,
|
|
14311
|
+
]);
|
|
14312
|
+
const { title: buttonTitle, iconKind } = useTaskButtonState({ status, title: slotTitle, icon: options?.icon ?? icon });
|
|
14313
|
+
const buttonIcon = React.useMemo(() => {
|
|
14314
|
+
if (isWaiting) {
|
|
14315
|
+
return (jsxRuntime.jsx(TaskButtonSpinner, { children: jsxRuntime.jsx(uilibGl.CircularProgress, { diameter: 1 }) }));
|
|
14316
|
+
}
|
|
14317
|
+
return iconKind ? jsxRuntime.jsx(uilibGl.Icon, { kind: iconKind }) : undefined;
|
|
14318
|
+
}, [iconKind, isWaiting]);
|
|
14319
|
+
return (jsxRuntime.jsx(ElementButton, { type: type, elementConfig: buttonConfig, title: buttonTitle, icon: buttonIcon, color: statusColors?.[status], disabled: isDisabled, onClick: onClick }));
|
|
14320
|
+
};
|
|
14321
|
+
|
|
14219
14322
|
const TaskContainerWrapper = styled(uilibGl.Flex).withConfig({ displayName: "TaskContainerWrapper", componentId: "sc-1hcp670" }) `
|
|
14220
14323
|
${sizeCssMixin};
|
|
14221
14324
|
`;
|
|
@@ -14344,9 +14447,10 @@ const TaskContainer = React.memo(({ type, elementConfig, renderElement }) => {
|
|
|
14344
14447
|
const { currentPage } = useWidgetPage(type);
|
|
14345
14448
|
const dashboard = useDashboardFilterStore(type);
|
|
14346
14449
|
const { taskId, runTask, stopTask, status, openLog, loading, isLogDialogOpen, closeLog, log, lastMessage, result, } = usePythonTask();
|
|
14347
|
-
const { options } = elementConfig || {};
|
|
14450
|
+
const { options, children } = elementConfig || {};
|
|
14348
14451
|
const { title, relatedResources, center, icon, statusColors, responseFilters, useNotifications, } = options || {};
|
|
14349
14452
|
const { root, body } = useContainerRoot({ elementConfig });
|
|
14453
|
+
const buttonConfig = React.useMemo(() => children?.find((child) => child.id === "button"), [children]);
|
|
14350
14454
|
const { setNotificationDismissed } = useTaskNotifications({
|
|
14351
14455
|
enabled: !!useNotifications,
|
|
14352
14456
|
suppressed: isLogDialogOpen,
|
|
@@ -14386,7 +14490,16 @@ const TaskContainer = React.memo(({ type, elementConfig, renderElement }) => {
|
|
|
14386
14490
|
return runTask({ resourceId, parameters: newParams, script, fileName, methodName });
|
|
14387
14491
|
}));
|
|
14388
14492
|
}, [attributes, currentPage.filters, dashboard, dataSources, ewktGeometry, layerInfo, relatedResources, runTask, selectedFilters, stopTask, taskId]);
|
|
14389
|
-
|
|
14493
|
+
const buttonProps = React.useMemo(() => ({
|
|
14494
|
+
title: title || t("run", { ns: "dashboard", defaultValue: "Запуск" }),
|
|
14495
|
+
icon,
|
|
14496
|
+
status,
|
|
14497
|
+
statusColors,
|
|
14498
|
+
isWaiting: loading || !!taskId,
|
|
14499
|
+
isDisabled: !relatedResources?.length,
|
|
14500
|
+
onClick,
|
|
14501
|
+
}), [icon, loading, onClick, relatedResources?.length, status, statusColors, t, taskId, title]);
|
|
14502
|
+
return (jsxRuntime.jsxs(ContainerRoot, { ...root, children: [jsxRuntime.jsx(ContainerBackground, { elementConfig: elementConfig, renderElement: renderElement }), jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), jsxRuntime.jsxs(TaskContainerWrapper, { ...body, justifyContent: center ? "center" : "flex-start", children: [buttonConfig ? (jsxRuntime.jsx(TaskButton, { type: type, buttonConfig: buttonConfig, ...buttonProps })) : (jsxRuntime.jsx(StatusWaitingButton, { ...buttonProps })), !!(log || taskId) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(uilibGl.IconButton, { kind: "info", onClick: openLog }), jsxRuntime.jsx(LogDialog, { logs: log, status: status, statusColors: statusColors, isOpen: isLogDialogOpen, onClose: onCloseLog, onMinimize: useNotifications ? onMinimizeLog : undefined })] }))] })] }));
|
|
14390
14503
|
});
|
|
14391
14504
|
|
|
14392
14505
|
const EditContainer = ({ type, elementConfig, renderElement }) => {
|
|
@@ -15442,26 +15555,6 @@ const FeatureCardBackgroundHeader = () => {
|
|
|
15442
15555
|
}) })] }) }) }));
|
|
15443
15556
|
};
|
|
15444
15557
|
|
|
15445
|
-
const ImageContainerButton = styled(uilibGl.FlatButton).withConfig({ displayName: "ImageContainerButton", componentId: "sc-nq6mg4" }) `
|
|
15446
|
-
min-height: 1.5rem;
|
|
15447
|
-
border-radius: ${({ theme: { borderRadius } }) => borderRadius.large};
|
|
15448
|
-
background-color: ${({ theme: { palette } }) => palette.primary};
|
|
15449
|
-
text-transform: none;
|
|
15450
|
-
|
|
15451
|
-
:hover {
|
|
15452
|
-
background-color: ${({ theme: { palette } }) => palette.primaryDeep};
|
|
15453
|
-
}
|
|
15454
|
-
`;
|
|
15455
|
-
|
|
15456
|
-
const ElementButton = React.memo(({ type, elementConfig }) => {
|
|
15457
|
-
const { attributes } = useWidgetContext(type);
|
|
15458
|
-
const attribute = getAttributeByName(elementConfig?.attributeName, attributes);
|
|
15459
|
-
const link = attribute?.value;
|
|
15460
|
-
if (!link || typeof link !== "string")
|
|
15461
|
-
return null;
|
|
15462
|
-
return (jsxRuntime.jsx(ImageContainerButton, { onClick: () => window.open(attribute?.value), children: elementConfig.value || "" }));
|
|
15463
|
-
});
|
|
15464
|
-
|
|
15465
15558
|
const AttributeGalleryContainer = styled.div.withConfig({ displayName: "AttributeGalleryContainer", componentId: "sc-mhke7l" }) `
|
|
15466
15559
|
&& {
|
|
15467
15560
|
width: calc(100% + 3rem);
|