@gravity-ui/querieskit 1.3.1 → 1.4.0
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/build/cjs/components/AttachmentList/AttachmentList.d.ts +2 -2
- package/build/cjs/components/AttachmentList/AttachmentList.js +9 -1
- package/build/cjs/components/AttachmentList/AttachmentList.js.map +1 -1
- package/build/cjs/components/AttachmentList/AttachmentList.stories.d.ts +36 -20
- package/build/cjs/components/AttachmentList/AttachmentList.stories.js +3 -0
- package/build/cjs/components/AttachmentList/AttachmentList.stories.js.map +1 -1
- package/build/cjs/components/AttachmentList/helpers/isInteractiveTarget.d.ts +2 -0
- package/build/cjs/components/AttachmentList/helpers/isInteractiveTarget.js +11 -0
- package/build/cjs/components/AttachmentList/helpers/isInteractiveTarget.js.map +1 -0
- package/build/cjs/components/LazyList/LazyList.js +12 -1
- package/build/cjs/components/LazyList/LazyList.js.map +1 -1
- package/build/cjs/components/RowLink/RowLink.d.ts +4 -4
- package/build/cjs/components/RowLink/RowLink.js +15 -4
- package/build/cjs/components/RowLink/RowLink.js.map +1 -1
- package/build/cjs/components/SearchRowLayout/SearchRowLayout.d.ts +2 -0
- package/build/cjs/components/SearchRowLayout/SearchRowLayout.js +2 -0
- package/build/cjs/components/SearchRowLayout/SearchRowLayout.js.map +1 -1
- package/build/cjs/helpers/getListKey.d.ts +1 -0
- package/build/cjs/helpers/getListKey.js +5 -4
- package/build/cjs/helpers/getListKey.js.map +1 -1
- package/build/cjs/helpers/useListKey.d.ts +2 -0
- package/build/cjs/helpers/useListKey.js +32 -0
- package/build/cjs/helpers/useListKey.js.map +1 -0
- package/build/cjs/helpers/useLoadMoreSentinel.d.ts +1 -1
- package/build/cjs/helpers/useLoadMoreSentinel.js +12 -3
- package/build/cjs/helpers/useLoadMoreSentinel.js.map +1 -1
- package/build/cjs/modules/Attachments/Attachments.css +4 -0
- package/build/cjs/modules/Attachments/Attachments.css.map +1 -1
- package/build/cjs/modules/Attachments/Attachments.d.ts +2 -1
- package/build/cjs/modules/Attachments/Attachments.js +8 -1
- package/build/cjs/modules/Attachments/Attachments.js.map +1 -1
- package/build/cjs/modules/Attachments/Attachments.stories.d.ts +2 -1
- package/build/cjs/modules/Attachments/Attachments.stories.js +7 -3
- package/build/cjs/modules/Attachments/Attachments.stories.js.map +1 -1
- package/build/cjs/modules/HistoryHeader/HistoryHeader.d.ts +1 -0
- package/build/cjs/modules/HistoryHeader/HistoryHeader.js +8 -6
- package/build/cjs/modules/HistoryHeader/HistoryHeader.js.map +1 -1
- package/build/cjs/modules/HistoryRow/HistoryRow.d.ts +1 -1
- package/build/cjs/modules/HistoryRow/HistoryRow.js +3 -1
- package/build/cjs/modules/HistoryRow/HistoryRow.js.map +1 -1
- package/build/cjs/modules/HistorySearchRow/HistorySearchRow.d.ts +1 -1
- package/build/cjs/modules/HistorySearchRow/HistorySearchRow.js +3 -1
- package/build/cjs/modules/HistorySearchRow/HistorySearchRow.js.map +1 -1
- package/build/cjs/modules/QueriesList/QueriesList.d.ts +6 -2
- package/build/cjs/modules/QueriesList/QueriesList.js +14 -3
- package/build/cjs/modules/QueriesList/QueriesList.js.map +1 -1
- package/build/cjs/modules/RowsList/RowsList.d.ts +6 -2
- package/build/cjs/modules/RowsList/RowsList.js +13 -7
- package/build/cjs/modules/RowsList/RowsList.js.map +1 -1
- package/build/cjs/modules/RowsList/helpers/prepareRowData.d.ts +3 -2
- package/build/cjs/modules/RowsList/helpers/prepareRowData.js +4 -2
- package/build/cjs/modules/RowsList/helpers/prepareRowData.js.map +1 -1
- package/build/cjs/types/queryList.d.ts +4 -1
- package/build/cjs/types/queryList.js.map +1 -1
- package/build/cjs/widgets/QueriesHistory/QueriesHistory.d.ts +6 -2
- package/build/cjs/widgets/QueriesHistory/QueriesHistory.js +9 -1
- package/build/cjs/widgets/QueriesHistory/QueriesHistory.js.map +1 -1
- package/build/cjs/widgets/QueriesHistory/QueriesHistory.stories.d.ts +5 -0
- package/build/cjs/widgets/QueriesHistory/QueriesHistory.stories.js +200 -6
- package/build/cjs/widgets/QueriesHistory/QueriesHistory.stories.js.map +1 -1
- package/build/cjs/widgets/TutorialsHistory/TutorialsHistory.js +3 -1
- package/build/cjs/widgets/TutorialsHistory/TutorialsHistory.js.map +1 -1
- package/build/esm/components/AttachmentList/AttachmentList.d.ts +2 -2
- package/build/esm/components/AttachmentList/AttachmentList.js +9 -1
- package/build/esm/components/AttachmentList/AttachmentList.js.map +1 -1
- package/build/esm/components/AttachmentList/AttachmentList.stories.d.ts +36 -20
- package/build/esm/components/AttachmentList/AttachmentList.stories.js +3 -0
- package/build/esm/components/AttachmentList/AttachmentList.stories.js.map +1 -1
- package/build/esm/components/AttachmentList/helpers/isInteractiveTarget.d.ts +2 -0
- package/build/esm/components/AttachmentList/helpers/isInteractiveTarget.js +5 -0
- package/build/esm/components/AttachmentList/helpers/isInteractiveTarget.js.map +1 -0
- package/build/esm/components/LazyList/LazyList.js +13 -2
- package/build/esm/components/LazyList/LazyList.js.map +1 -1
- package/build/esm/components/RowLink/RowLink.d.ts +4 -4
- package/build/esm/components/RowLink/RowLink.js +15 -4
- package/build/esm/components/RowLink/RowLink.js.map +1 -1
- package/build/esm/components/SearchRowLayout/SearchRowLayout.d.ts +2 -0
- package/build/esm/components/SearchRowLayout/SearchRowLayout.js +2 -0
- package/build/esm/components/SearchRowLayout/SearchRowLayout.js.map +1 -1
- package/build/esm/helpers/getListKey.d.ts +1 -0
- package/build/esm/helpers/getListKey.js +4 -3
- package/build/esm/helpers/getListKey.js.map +1 -1
- package/build/esm/helpers/useListKey.d.ts +2 -0
- package/build/esm/helpers/useListKey.js +26 -0
- package/build/esm/helpers/useListKey.js.map +1 -0
- package/build/esm/helpers/useLoadMoreSentinel.d.ts +1 -1
- package/build/esm/helpers/useLoadMoreSentinel.js +12 -3
- package/build/esm/helpers/useLoadMoreSentinel.js.map +1 -1
- package/build/esm/modules/Attachments/Attachments.css +4 -0
- package/build/esm/modules/Attachments/Attachments.css.map +1 -1
- package/build/esm/modules/Attachments/Attachments.d.ts +2 -1
- package/build/esm/modules/Attachments/Attachments.js +8 -1
- package/build/esm/modules/Attachments/Attachments.js.map +1 -1
- package/build/esm/modules/Attachments/Attachments.scss +5 -0
- package/build/esm/modules/Attachments/Attachments.stories.d.ts +2 -1
- package/build/esm/modules/Attachments/Attachments.stories.js +7 -3
- package/build/esm/modules/Attachments/Attachments.stories.js.map +1 -1
- package/build/esm/modules/HistoryHeader/HistoryHeader.d.ts +1 -0
- package/build/esm/modules/HistoryHeader/HistoryHeader.js +8 -6
- package/build/esm/modules/HistoryHeader/HistoryHeader.js.map +1 -1
- package/build/esm/modules/HistoryRow/HistoryRow.d.ts +1 -1
- package/build/esm/modules/HistoryRow/HistoryRow.js +3 -1
- package/build/esm/modules/HistoryRow/HistoryRow.js.map +1 -1
- package/build/esm/modules/HistorySearchRow/HistorySearchRow.d.ts +1 -1
- package/build/esm/modules/HistorySearchRow/HistorySearchRow.js +3 -1
- package/build/esm/modules/HistorySearchRow/HistorySearchRow.js.map +1 -1
- package/build/esm/modules/QueriesList/QueriesList.d.ts +6 -2
- package/build/esm/modules/QueriesList/QueriesList.js +14 -3
- package/build/esm/modules/QueriesList/QueriesList.js.map +1 -1
- package/build/esm/modules/RowsList/RowsList.d.ts +6 -2
- package/build/esm/modules/RowsList/RowsList.js +13 -7
- package/build/esm/modules/RowsList/RowsList.js.map +1 -1
- package/build/esm/modules/RowsList/helpers/prepareRowData.d.ts +3 -2
- package/build/esm/modules/RowsList/helpers/prepareRowData.js +4 -2
- package/build/esm/modules/RowsList/helpers/prepareRowData.js.map +1 -1
- package/build/esm/types/queryList.d.ts +4 -1
- package/build/esm/types/queryList.js.map +1 -1
- package/build/esm/widgets/QueriesHistory/QueriesHistory.d.ts +6 -2
- package/build/esm/widgets/QueriesHistory/QueriesHistory.js +9 -1
- package/build/esm/widgets/QueriesHistory/QueriesHistory.js.map +1 -1
- package/build/esm/widgets/QueriesHistory/QueriesHistory.stories.d.ts +5 -0
- package/build/esm/widgets/QueriesHistory/QueriesHistory.stories.js +200 -6
- package/build/esm/widgets/QueriesHistory/QueriesHistory.stories.js.map +1 -1
- package/build/esm/widgets/TutorialsHistory/TutorialsHistory.js +3 -1
- package/build/esm/widgets/TutorialsHistory/TutorialsHistory.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { QueryListComparisonConfig, QueryListEditingConfig, QueryListItem, QueryListRow, QueryListRowAction, QueryListRowRenderData, QueryListRowVariant, QueryListVisibleFieldsConfig } from '../../types/queryList';
|
|
2
|
+
import { QueryListComparisonConfig, QueryListEditingConfig, QueryListItem, QueryListLinkRenderer, QueryListRow, QueryListRowAction, QueryListRowRenderData, QueryListRowVariant, QueryListVisibleFieldsConfig } from '../../types/queryList';
|
|
3
3
|
import './RowsList.scss';
|
|
4
4
|
export type RowsListProps<T extends QueryListRow> = {
|
|
5
5
|
items: QueryListItem<T>[];
|
|
@@ -11,7 +11,11 @@ export type RowsListProps<T extends QueryListRow> = {
|
|
|
11
11
|
getRowActions?: (item: T) => QueryListRowAction<T>[];
|
|
12
12
|
renderRow: (data: QueryListRowRenderData<T>) => React.ReactNode;
|
|
13
13
|
showFiltersHint?: boolean;
|
|
14
|
+
hasMore?: boolean;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
onLoadMore?: () => void;
|
|
17
|
+
renderLink?: QueryListLinkRenderer;
|
|
14
18
|
className?: string;
|
|
15
19
|
onItemClick?: (item: QueryListItem<T>, index: number) => void;
|
|
16
20
|
};
|
|
17
|
-
export declare const RowsList: <T extends QueryListRow>({ items, selectedRowId, rowVariant, visibleFields, editing, comparison, getRowActions, renderRow, showFiltersHint, className, onItemClick, }: RowsListProps<T>) => React.JSX.Element;
|
|
21
|
+
export declare const RowsList: <T extends QueryListRow>({ items, selectedRowId, rowVariant, visibleFields, editing, comparison, getRowActions, renderRow, showFiltersHint, hasMore, loading, onLoadMore, renderLink, className, onItemClick, }: RowsListProps<T>) => React.JSX.Element;
|
|
@@ -20,6 +20,10 @@ export var RowsList = function RowsList(_ref) {
|
|
|
20
20
|
getRowActions = _ref.getRowActions,
|
|
21
21
|
renderRow = _ref.renderRow,
|
|
22
22
|
showFiltersHint = _ref.showFiltersHint,
|
|
23
|
+
hasMore = _ref.hasMore,
|
|
24
|
+
loading = _ref.loading,
|
|
25
|
+
onLoadMore = _ref.onLoadMore,
|
|
26
|
+
renderLink = _ref.renderLink,
|
|
23
27
|
className = _ref.className,
|
|
24
28
|
onItemClick = _ref.onItemClick;
|
|
25
29
|
var getItemHeight = function getItemHeight(item) {
|
|
@@ -36,12 +40,6 @@ export var RowsList = function RowsList(_ref) {
|
|
|
36
40
|
var selected = comparison.comparedRowIds.includes(item.id);
|
|
37
41
|
comparison.onChange(item, !selected);
|
|
38
42
|
};
|
|
39
|
-
if (!items.length) {
|
|
40
|
-
return /*#__PURE__*/_jsx(EmptyContent, {
|
|
41
|
-
variant: showFiltersHint ? 'nothing-found' : 'no-files',
|
|
42
|
-
className: className
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
43
|
return /*#__PURE__*/_jsx(LazyList, {
|
|
46
44
|
className: block(null, className),
|
|
47
45
|
items: items,
|
|
@@ -55,10 +53,18 @@ export var RowsList = function RowsList(_ref) {
|
|
|
55
53
|
visibleFields: visibleFields,
|
|
56
54
|
editing: editing,
|
|
57
55
|
comparison: comparison,
|
|
58
|
-
getRowActions: getRowActions
|
|
56
|
+
getRowActions: getRowActions,
|
|
57
|
+
renderLink: renderLink
|
|
59
58
|
}));
|
|
60
59
|
},
|
|
61
60
|
selectedItemIndex: selectedItemIndex,
|
|
61
|
+
hasMore: hasMore,
|
|
62
|
+
loading: loading,
|
|
63
|
+
onLoadMore: onLoadMore,
|
|
64
|
+
emptyContent: /*#__PURE__*/_jsx(EmptyContent, {
|
|
65
|
+
variant: showFiltersHint ? 'nothing-found' : 'no-files',
|
|
66
|
+
className: className
|
|
67
|
+
}),
|
|
62
68
|
onItemClick: handleItemClick
|
|
63
69
|
});
|
|
64
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","cn","EmptyContent","LazyList","prepareRowData","SEARCH_ROW_HEIGHT","jsx","_jsx","block","RowsList","_ref","items","selectedRowId","_ref$rowVariant","rowVariant","visibleFields","editing","comparison","getRowActions","renderRow","showFiltersHint","className","onItemClick","getItemHeight","item","height","selectedItemIndex","undefined","findIndex","id","handleItemClick","index","enabled","selected","comparedRowIds","includes","onChange","
|
|
1
|
+
{"version":3,"names":["React","cn","EmptyContent","LazyList","prepareRowData","SEARCH_ROW_HEIGHT","jsx","_jsx","block","RowsList","_ref","items","selectedRowId","_ref$rowVariant","rowVariant","visibleFields","editing","comparison","getRowActions","renderRow","showFiltersHint","hasMore","loading","onLoadMore","renderLink","className","onItemClick","getItemHeight","item","height","selectedItemIndex","undefined","findIndex","id","handleItemClick","index","enabled","selected","comparedRowIds","includes","onChange","itemHeight","renderItem","isActive","variant","emptyContent"],"sources":["RowsList.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'bem-cn-lite';\nimport {\n QueryListComparisonConfig,\n QueryListEditingConfig,\n QueryListItem,\n QueryListLinkRenderer,\n QueryListRow,\n QueryListRowAction,\n QueryListRowRenderData,\n QueryListRowVariant,\n QueryListVisibleFieldsConfig,\n} from '../../types/queryList';\nimport {EmptyContent, LazyList} from '../../components';\nimport {prepareRowData} from './helpers/prepareRowData';\nimport {SEARCH_ROW_HEIGHT} from '../../constants/row';\nimport './RowsList.scss';\n\nconst block = cn('qp-rows-list');\n\nexport type RowsListProps<T extends QueryListRow> = {\n items: QueryListItem<T>[];\n selectedRowId?: T['id'];\n rowVariant?: QueryListRowVariant;\n visibleFields?: QueryListVisibleFieldsConfig<T>;\n editing?: QueryListEditingConfig<T>;\n comparison?: QueryListComparisonConfig<T>;\n getRowActions?: (item: T) => QueryListRowAction<T>[];\n renderRow: (data: QueryListRowRenderData<T>) => React.ReactNode;\n showFiltersHint?: boolean;\n hasMore?: boolean;\n loading?: boolean;\n onLoadMore?: () => void;\n renderLink?: QueryListLinkRenderer;\n className?: string;\n onItemClick?: (item: QueryListItem<T>, index: number) => void;\n};\n\nexport const RowsList = <T extends QueryListRow>({\n items,\n selectedRowId,\n rowVariant = 'default',\n visibleFields,\n editing,\n comparison,\n getRowActions,\n renderRow,\n showFiltersHint,\n hasMore,\n loading,\n onLoadMore,\n renderLink,\n className,\n onItemClick,\n}: RowsListProps<T>) => {\n const getItemHeight = (item: QueryListItem<T>) =>\n rowVariant === 'search' && !('header' in item) ? SEARCH_ROW_HEIGHT : item.height;\n const selectedItemIndex =\n selectedRowId === undefined\n ? undefined\n : items.findIndex((item) => !('header' in item) && item.id === selectedRowId);\n\n const handleItemClick = (item: QueryListItem<T>, index: number) => {\n if ('header' in item || !comparison?.enabled) {\n onItemClick?.(item, index);\n return;\n }\n\n const selected = comparison.comparedRowIds.includes(item.id);\n comparison.onChange(item, !selected);\n };\n\n return (\n <LazyList<QueryListItem<T>>\n className={block(null, className)}\n items={items}\n itemHeight={getItemHeight}\n renderItem={(item, isActive, index) =>\n renderRow(\n prepareRowData({\n item,\n isActive,\n index,\n variant: rowVariant,\n visibleFields,\n editing,\n comparison,\n getRowActions,\n renderLink,\n }),\n )\n }\n selectedItemIndex={selectedItemIndex}\n hasMore={hasMore}\n loading={loading}\n onLoadMore={onLoadMore}\n emptyContent={\n <EmptyContent\n variant={showFiltersHint ? 'nothing-found' : 'no-files'}\n className={className}\n />\n }\n onItemClick={handleItemClick}\n />\n );\n};\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QueryListComparisonConfig, QueryListEditingConfig, QueryListItem, QueryListRow, QueryListRowAction, QueryListRowRenderData, QueryListRowVariant, QueryListVisibleFieldsConfig } from '../../../types/queryList';
|
|
1
|
+
import { QueryListComparisonConfig, QueryListEditingConfig, QueryListItem, QueryListLinkRenderer, QueryListRow, QueryListRowAction, QueryListRowRenderData, QueryListRowVariant, QueryListVisibleFieldsConfig } from '../../../types/queryList';
|
|
2
2
|
type Props<T extends QueryListRow> = {
|
|
3
3
|
item: QueryListItem<T>;
|
|
4
4
|
isActive: boolean;
|
|
@@ -8,6 +8,7 @@ type Props<T extends QueryListRow> = {
|
|
|
8
8
|
editing?: QueryListEditingConfig<T>;
|
|
9
9
|
comparison?: QueryListComparisonConfig<T>;
|
|
10
10
|
getRowActions?: (item: T) => QueryListRowAction<T>[];
|
|
11
|
+
renderLink?: QueryListLinkRenderer;
|
|
11
12
|
};
|
|
12
|
-
export declare const prepareRowData: <T extends QueryListRow>({ item, isActive, index, variant, visibleFields, editing, comparison, getRowActions, }: Props<T>) => QueryListRowRenderData<T>;
|
|
13
|
+
export declare const prepareRowData: <T extends QueryListRow>({ item, isActive, index, variant, visibleFields, editing, comparison, getRowActions, renderLink, }: Props<T>) => QueryListRowRenderData<T>;
|
|
13
14
|
export {};
|
|
@@ -8,7 +8,8 @@ export var prepareRowData = function prepareRowData(_ref) {
|
|
|
8
8
|
visibleFields = _ref.visibleFields,
|
|
9
9
|
editing = _ref.editing,
|
|
10
10
|
comparison = _ref.comparison,
|
|
11
|
-
getRowActions = _ref.getRowActions
|
|
11
|
+
getRowActions = _ref.getRowActions,
|
|
12
|
+
renderLink = _ref.renderLink;
|
|
12
13
|
var isRow = !('header' in item);
|
|
13
14
|
var actions = isRow && getRowActions ? getRowActions(item) : undefined;
|
|
14
15
|
var editingData = isRow && editing ? {
|
|
@@ -28,7 +29,8 @@ export var prepareRowData = function prepareRowData(_ref) {
|
|
|
28
29
|
visibleFields: visibleFields,
|
|
29
30
|
actions: actions,
|
|
30
31
|
editing: editingData,
|
|
31
|
-
comparison: comparisonData
|
|
32
|
+
comparison: comparisonData,
|
|
33
|
+
renderLink: renderLink
|
|
32
34
|
};
|
|
33
35
|
};
|
|
34
36
|
// #sourceMappingURL=prepareRowData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["prepareRowData","_ref","item","isActive","index","variant","visibleFields","editing","comparison","getRowActions","isRow","actions","undefined","editingData","enabled","rowId","id","onSubmit","onCancel","comparisonData","checked","comparedRowIds","includes"],"sources":["prepareRowData.ts"],"sourcesContent":["import {\n QueryListComparisonConfig,\n QueryListEditingConfig,\n QueryListItem,\n QueryListRow,\n QueryListRowAction,\n QueryListRowRenderData,\n QueryListRowVariant,\n QueryListVisibleFieldsConfig,\n} from '../../../types/queryList';\n\ntype Props<T extends QueryListRow> = {\n item: QueryListItem<T>;\n isActive: boolean;\n index: number;\n variant: QueryListRowVariant;\n visibleFields?: QueryListVisibleFieldsConfig<T>;\n editing?: QueryListEditingConfig<T>;\n comparison?: QueryListComparisonConfig<T>;\n getRowActions?: (item: T) => QueryListRowAction<T>[];\n};\n\nexport const prepareRowData = <T extends QueryListRow>({\n item,\n isActive,\n index,\n variant,\n visibleFields,\n editing,\n comparison,\n getRowActions,\n}: Props<T>): QueryListRowRenderData<T> => {\n const isRow = !('header' in item);\n const actions = isRow && getRowActions ? getRowActions(item) : undefined;\n const editingData =\n isRow && editing\n ? {\n enabled: editing.rowId === item.id,\n onSubmit: editing.onSubmit,\n onCancel: editing.onCancel,\n }\n : undefined;\n const comparisonData =\n isRow && comparison && comparison.enabled\n ? {\n enabled: true,\n checked: comparison.comparedRowIds.includes(item.id),\n }\n : undefined;\n\n return {\n item,\n index,\n isActive,\n variant,\n visibleFields,\n actions,\n editing: editingData,\n comparison: comparisonData,\n };\n};\n"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["prepareRowData","_ref","item","isActive","index","variant","visibleFields","editing","comparison","getRowActions","renderLink","isRow","actions","undefined","editingData","enabled","rowId","id","onSubmit","onCancel","comparisonData","checked","comparedRowIds","includes"],"sources":["prepareRowData.ts"],"sourcesContent":["import {\n QueryListComparisonConfig,\n QueryListEditingConfig,\n QueryListItem,\n QueryListLinkRenderer,\n QueryListRow,\n QueryListRowAction,\n QueryListRowRenderData,\n QueryListRowVariant,\n QueryListVisibleFieldsConfig,\n} from '../../../types/queryList';\n\ntype Props<T extends QueryListRow> = {\n item: QueryListItem<T>;\n isActive: boolean;\n index: number;\n variant: QueryListRowVariant;\n visibleFields?: QueryListVisibleFieldsConfig<T>;\n editing?: QueryListEditingConfig<T>;\n comparison?: QueryListComparisonConfig<T>;\n getRowActions?: (item: T) => QueryListRowAction<T>[];\n renderLink?: QueryListLinkRenderer;\n};\n\nexport const prepareRowData = <T extends QueryListRow>({\n item,\n isActive,\n index,\n variant,\n visibleFields,\n editing,\n comparison,\n getRowActions,\n renderLink,\n}: Props<T>): QueryListRowRenderData<T> => {\n const isRow = !('header' in item);\n const actions = isRow && getRowActions ? getRowActions(item) : undefined;\n const editingData =\n isRow && editing\n ? {\n enabled: editing.rowId === item.id,\n onSubmit: editing.onSubmit,\n onCancel: editing.onCancel,\n }\n : undefined;\n const comparisonData =\n isRow && comparison && comparison.enabled\n ? {\n enabled: true,\n checked: comparison.comparedRowIds.includes(item.id),\n }\n : undefined;\n\n return {\n item,\n index,\n isActive,\n variant,\n visibleFields,\n actions,\n editing: editingData,\n comparison: comparisonData,\n renderLink,\n };\n};\n"],"mappings":";;AAwBA,OAAO,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CAAAC,IAAA,EAUgB;EAAA,IATvCC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IACPC,aAAa,GAAAL,IAAA,CAAbK,aAAa;IACbC,OAAO,GAAAN,IAAA,CAAPM,OAAO;IACPC,UAAU,GAAAP,IAAA,CAAVO,UAAU;IACVC,aAAa,GAAAR,IAAA,CAAbQ,aAAa;IACbC,UAAU,GAAAT,IAAA,CAAVS,UAAU;EAEV,IAAMC,KAAK,GAAG,EAAE,QAAQ,IAAIT,IAAI,CAAC;EACjC,IAAMU,OAAO,GAAGD,KAAK,IAAIF,aAAa,GAAGA,aAAa,CAACP,IAAI,CAAC,GAAGW,SAAS;EACxE,IAAMC,WAAW,GACbH,KAAK,IAAIJ,OAAO,GACV;IACIQ,OAAO,EAAER,OAAO,CAACS,KAAK,KAAKd,IAAI,CAACe,EAAE;IAClCC,QAAQ,EAAEX,OAAO,CAACW,QAAQ;IAC1BC,QAAQ,EAAEZ,OAAO,CAACY;EACtB,CAAC,GACDN,SAAS;EACnB,IAAMO,cAAc,GAChBT,KAAK,IAAIH,UAAU,IAAIA,UAAU,CAACO,OAAO,GACnC;IACIA,OAAO,EAAE,IAAI;IACbM,OAAO,EAAEb,UAAU,CAACc,cAAc,CAACC,QAAQ,CAACrB,IAAI,CAACe,EAAE;EACvD,CAAC,GACDJ,SAAS;EAEnB,OAAO;IACHX,IAAI,EAAJA,IAAI;IACJE,KAAK,EAALA,KAAK;IACLD,QAAQ,EAARA,QAAQ;IACRE,OAAO,EAAPA,OAAO;IACPC,aAAa,EAAbA,aAAa;IACbM,OAAO,EAAPA,OAAO;IACPL,OAAO,EAAEO,WAAW;IACpBN,UAAU,EAAEY,cAAc;IAC1BV,UAAU,EAAVA;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { RegisteredFormFields } from './forms';
|
|
3
3
|
/** ISO 8601 date string or Unix timestamp in milliseconds. */
|
|
4
4
|
export type QueryTimestamp = string | number;
|
|
@@ -16,6 +16,7 @@ export type QueryListRow = {
|
|
|
16
16
|
} & QueryListRowRenderProps;
|
|
17
17
|
export type QueryListItem<T extends QueryListRow = QueryListRow> = QueryListHeader | T;
|
|
18
18
|
export type QueryListRowVariant = 'default' | 'search';
|
|
19
|
+
export type QueryListLinkRenderer = (props: ComponentPropsWithoutRef<'a'>) => ReactElement;
|
|
19
20
|
export type QueryListRowAction<T extends QueryListRow = QueryListRow> = {
|
|
20
21
|
text: ReactNode;
|
|
21
22
|
icon?: ReactNode;
|
|
@@ -27,6 +28,7 @@ export type QueryListRowAction<T extends QueryListRow = QueryListRow> = {
|
|
|
27
28
|
export type QueryListSearchConfig = {
|
|
28
29
|
value?: string;
|
|
29
30
|
fullSearch?: boolean;
|
|
31
|
+
fullSearchAvailable?: boolean;
|
|
30
32
|
hasClear?: boolean;
|
|
31
33
|
onUpdate: (data: {
|
|
32
34
|
value: string;
|
|
@@ -79,5 +81,6 @@ export type QueryListRowRenderData<T extends QueryListRow = QueryListRow> = {
|
|
|
79
81
|
visibleFields?: QueryListVisibleFieldsConfig<T>;
|
|
80
82
|
actions?: QueryListRowAction<T>[];
|
|
81
83
|
editing?: QueryListEditingRenderData<T>;
|
|
84
|
+
renderLink?: QueryListLinkRenderer;
|
|
82
85
|
};
|
|
83
86
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["queryList.ts"],"sourcesContent":["import {ReactNode} from 'react';\nimport {RegisteredFormFields} from './forms';\n\n/** ISO 8601 date string or Unix timestamp in milliseconds. */\nexport type QueryTimestamp = string | number;\n\nexport type QueryListRowRenderProps = {height: number};\n\nexport type QueryListHeader = {header: string} & QueryListRowRenderProps;\n\nexport type QueryListRow = {\n id: number | string;\n title: string;\n query?: string;\n href?: string;\n} & QueryListRowRenderProps;\n\nexport type QueryListItem<T extends QueryListRow = QueryListRow> = QueryListHeader | T;\n\nexport type QueryListRowVariant = 'default' | 'search';\n\nexport type QueryListRowAction<T extends QueryListRow = QueryListRow> = {\n text: ReactNode;\n icon?: ReactNode;\n theme?: 'normal' | 'danger';\n hidden?: boolean;\n disabled?: boolean;\n onClick: (item: T) => void;\n};\n\nexport type QueryListSearchConfig = {\n value?: string;\n fullSearch?: boolean;\n hasClear?: boolean;\n onUpdate: (data: {value: string; fullSearch: boolean}) => void;\n};\n\nexport type QueryListFilterConfig = {\n fields?: RegisteredFormFields[];\n values?: Record<string, any>;\n initialValues?: Record<string, any>;\n isChanged?: boolean;\n onApply?: (values: Record<string, any>) => void;\n onReset?: () => void;\n};\n\nexport type QueryListEditingConfig<T extends QueryListRow = QueryListRow> = {\n rowId?: T['id'];\n onSubmit?: (item: T, title: string) => void;\n onCancel?: (item: T) => void;\n};\n\nexport type QueryListComparisonConfig<T extends QueryListRow = QueryListRow> = {\n enabled: boolean;\n comparedRowIds: T['id'][];\n onChange: (item: T, selected: boolean) => void;\n onCancel: () => void;\n onCompare: () => void;\n};\n\ntype RowFieldKey<T extends QueryListRow> = Exclude<keyof T & string, keyof QueryListRowRenderProps>;\n\nexport type QueryListFieldKey<T extends QueryListRow = QueryListRow> = RowFieldKey<T> | 'duration';\n\nexport type QueryListFieldOption<K extends string = string> = {\n id: K;\n title: ReactNode;\n};\n\nexport type QueryListVisibleFieldsConfig<T extends QueryListRow = QueryListRow> = {\n value: QueryListFieldKey<T>[];\n fields: QueryListFieldOption<QueryListFieldKey<T>>[];\n onChange: (value: QueryListFieldKey<T>[]) => void;\n};\n\nexport type QueryListEditingRenderData<T extends QueryListRow = QueryListRow> = {\n enabled: boolean;\n} & Pick<QueryListEditingConfig<T>, 'onSubmit' | 'onCancel'>;\n\nexport type QueryListRowRenderData<T extends QueryListRow = QueryListRow> = {\n item: QueryListItem<T>;\n index: number;\n isActive: boolean;\n variant: QueryListRowVariant;\n comparison?: {\n enabled: boolean;\n checked: boolean;\n };\n visibleFields?: QueryListVisibleFieldsConfig<T>;\n actions?: QueryListRowAction<T>[];\n editing?: QueryListEditingRenderData<T>;\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["queryList.ts"],"sourcesContent":["import type {ComponentPropsWithoutRef, ReactElement, ReactNode} from 'react';\nimport {RegisteredFormFields} from './forms';\n\n/** ISO 8601 date string or Unix timestamp in milliseconds. */\nexport type QueryTimestamp = string | number;\n\nexport type QueryListRowRenderProps = {height: number};\n\nexport type QueryListHeader = {header: string} & QueryListRowRenderProps;\n\nexport type QueryListRow = {\n id: number | string;\n title: string;\n query?: string;\n href?: string;\n} & QueryListRowRenderProps;\n\nexport type QueryListItem<T extends QueryListRow = QueryListRow> = QueryListHeader | T;\n\nexport type QueryListRowVariant = 'default' | 'search';\n\nexport type QueryListLinkRenderer = (props: ComponentPropsWithoutRef<'a'>) => ReactElement;\n\nexport type QueryListRowAction<T extends QueryListRow = QueryListRow> = {\n text: ReactNode;\n icon?: ReactNode;\n theme?: 'normal' | 'danger';\n hidden?: boolean;\n disabled?: boolean;\n onClick: (item: T) => void;\n};\n\nexport type QueryListSearchConfig = {\n value?: string;\n fullSearch?: boolean;\n fullSearchAvailable?: boolean;\n hasClear?: boolean;\n onUpdate: (data: {value: string; fullSearch: boolean}) => void;\n};\n\nexport type QueryListFilterConfig = {\n fields?: RegisteredFormFields[];\n values?: Record<string, any>;\n initialValues?: Record<string, any>;\n isChanged?: boolean;\n onApply?: (values: Record<string, any>) => void;\n onReset?: () => void;\n};\n\nexport type QueryListEditingConfig<T extends QueryListRow = QueryListRow> = {\n rowId?: T['id'];\n onSubmit?: (item: T, title: string) => void;\n onCancel?: (item: T) => void;\n};\n\nexport type QueryListComparisonConfig<T extends QueryListRow = QueryListRow> = {\n enabled: boolean;\n comparedRowIds: T['id'][];\n onChange: (item: T, selected: boolean) => void;\n onCancel: () => void;\n onCompare: () => void;\n};\n\ntype RowFieldKey<T extends QueryListRow> = Exclude<keyof T & string, keyof QueryListRowRenderProps>;\n\nexport type QueryListFieldKey<T extends QueryListRow = QueryListRow> = RowFieldKey<T> | 'duration';\n\nexport type QueryListFieldOption<K extends string = string> = {\n id: K;\n title: ReactNode;\n};\n\nexport type QueryListVisibleFieldsConfig<T extends QueryListRow = QueryListRow> = {\n value: QueryListFieldKey<T>[];\n fields: QueryListFieldOption<QueryListFieldKey<T>>[];\n onChange: (value: QueryListFieldKey<T>[]) => void;\n};\n\nexport type QueryListEditingRenderData<T extends QueryListRow = QueryListRow> = {\n enabled: boolean;\n} & Pick<QueryListEditingConfig<T>, 'onSubmit' | 'onCancel'>;\n\nexport type QueryListRowRenderData<T extends QueryListRow = QueryListRow> = {\n item: QueryListItem<T>;\n index: number;\n isActive: boolean;\n variant: QueryListRowVariant;\n comparison?: {\n enabled: boolean;\n checked: boolean;\n };\n visibleFields?: QueryListVisibleFieldsConfig<T>;\n actions?: QueryListRowAction<T>[];\n editing?: QueryListEditingRenderData<T>;\n renderLink?: QueryListLinkRenderer;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { QueryListComparisonConfig, QueryListEditingConfig, QueryListFilterConfig, QueryListItem, QueryListRowAction, QueryListRowRenderData, QueryListSearchConfig, QueryListVisibleFieldsConfig } from '../../types/queryList';
|
|
2
|
+
import { QueryListComparisonConfig, QueryListEditingConfig, QueryListFilterConfig, QueryListItem, QueryListLinkRenderer, QueryListRowAction, QueryListRowRenderData, QueryListSearchConfig, QueryListVisibleFieldsConfig } from '../../types/queryList';
|
|
3
3
|
import { QueryHistoryRow } from '../../types/history';
|
|
4
4
|
import './QueriesHistory.scss';
|
|
5
5
|
export type QueriesHistoryProps<T extends QueryHistoryRow = QueryHistoryRow> = {
|
|
@@ -16,5 +16,9 @@ export type QueriesHistoryProps<T extends QueryHistoryRow = QueryHistoryRow> = {
|
|
|
16
16
|
renderRowItem?: (data: QueryListRowRenderData<T>) => React.ReactNode;
|
|
17
17
|
getRowActions?: (item: T) => QueryListRowAction<T>[];
|
|
18
18
|
onListItemClick?: (item: QueryListItem<T>) => void;
|
|
19
|
+
hasMore?: boolean;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
onLoadMore?: () => void;
|
|
22
|
+
renderLink?: QueryListLinkRenderer;
|
|
19
23
|
};
|
|
20
|
-
export declare const QueriesHistory: <T extends QueryHistoryRow>({ title, logo, search, filter, items, selectedRowId, editing, comparison, visibleFields, renderRowItem, getRowActions, onListItemClick, className, }: QueriesHistoryProps<T>) => React.JSX.Element;
|
|
24
|
+
export declare const QueriesHistory: <T extends QueryHistoryRow>({ title, logo, search, filter, items, selectedRowId, editing, comparison, visibleFields, renderRowItem, getRowActions, onListItemClick, hasMore, loading, onLoadMore, renderLink, className, }: QueriesHistoryProps<T>) => React.JSX.Element;
|
|
@@ -25,6 +25,10 @@ export var QueriesHistory = function QueriesHistory(_ref) {
|
|
|
25
25
|
renderRowItem = _ref.renderRowItem,
|
|
26
26
|
getRowActions = _ref.getRowActions,
|
|
27
27
|
onListItemClick = _ref.onListItemClick,
|
|
28
|
+
hasMore = _ref.hasMore,
|
|
29
|
+
loading = _ref.loading,
|
|
30
|
+
onLoadMore = _ref.onLoadMore,
|
|
31
|
+
renderLink = _ref.renderLink,
|
|
28
32
|
className = _ref.className;
|
|
29
33
|
return /*#__PURE__*/_jsx(QueriesList, {
|
|
30
34
|
className: block(null, className),
|
|
@@ -41,7 +45,11 @@ export var QueriesHistory = function QueriesHistory(_ref) {
|
|
|
41
45
|
renderRow: function renderRow(data) {
|
|
42
46
|
return renderRowItem ? renderRowItem(data) : /*#__PURE__*/_jsx(HistoryRowContent, _objectSpread({}, data));
|
|
43
47
|
},
|
|
44
|
-
onListItemClick: onListItemClick
|
|
48
|
+
onListItemClick: onListItemClick,
|
|
49
|
+
hasMore: hasMore,
|
|
50
|
+
loading: loading,
|
|
51
|
+
onLoadMore: onLoadMore,
|
|
52
|
+
renderLink: renderLink
|
|
45
53
|
});
|
|
46
54
|
};
|
|
47
55
|
// #sourceMappingURL=QueriesHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","cn","QueriesList","HistoryRowContent","jsx","_jsx","block","QueriesHistory","_ref","title","logo","search","filter","items","selectedRowId","editing","comparison","visibleFields","renderRowItem","getRowActions","onListItemClick","className","renderRow","data","_objectSpread"],"sources":["QueriesHistory.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'bem-cn-lite';\nimport {QueriesList} from '../../modules';\nimport {\n QueryListComparisonConfig,\n QueryListEditingConfig,\n QueryListFilterConfig,\n QueryListItem,\n QueryListRowAction,\n QueryListRowRenderData,\n QueryListSearchConfig,\n QueryListVisibleFieldsConfig,\n} from '../../types/queryList';\nimport {QueryHistoryRow} from '../../types/history';\nimport {HistoryRowContent} from './internal/HistoryRowContent';\nimport './QueriesHistory.scss';\n\nexport type QueriesHistoryProps<T extends QueryHistoryRow = QueryHistoryRow> = {\n className?: string;\n title?: string;\n logo?: React.ReactNode;\n search: QueryListSearchConfig;\n filter?: QueryListFilterConfig;\n items: QueryListItem<T>[];\n selectedRowId?: T['id'];\n editing?: QueryListEditingConfig<T>;\n comparison?: QueryListComparisonConfig<T>;\n visibleFields?: QueryListVisibleFieldsConfig<T>;\n renderRowItem?: (data: QueryListRowRenderData<T>) => React.ReactNode;\n getRowActions?: (item: T) => QueryListRowAction<T>[];\n onListItemClick?: (item: QueryListItem<T>) => void;\n};\n\nconst block = cn('qp-query-history');\n\nexport const QueriesHistory = <T extends QueryHistoryRow>({\n title,\n logo,\n search,\n filter,\n items,\n selectedRowId,\n editing,\n comparison,\n visibleFields,\n renderRowItem,\n getRowActions,\n onListItemClick,\n className,\n}: QueriesHistoryProps<T>) => {\n return (\n <QueriesList\n className={block(null, className)}\n title={title}\n logo={logo}\n search={search}\n filter={filter}\n items={items}\n selectedRowId={selectedRowId}\n visibleFields={visibleFields}\n editing={editing}\n comparison={comparison}\n getRowActions={getRowActions}\n renderRow={(data) =>\n renderRowItem ? renderRowItem(data) : <HistoryRowContent {...data} />\n }\n onListItemClick={onListItemClick}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,EAAE,MAAM,aAAa;AAC5B,SAAQC,WAAW;
|
|
1
|
+
{"version":3,"names":["React","cn","QueriesList","HistoryRowContent","jsx","_jsx","block","QueriesHistory","_ref","title","logo","search","filter","items","selectedRowId","editing","comparison","visibleFields","renderRowItem","getRowActions","onListItemClick","hasMore","loading","onLoadMore","renderLink","className","renderRow","data","_objectSpread"],"sources":["QueriesHistory.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'bem-cn-lite';\nimport {QueriesList} from '../../modules';\nimport {\n QueryListComparisonConfig,\n QueryListEditingConfig,\n QueryListFilterConfig,\n QueryListItem,\n QueryListLinkRenderer,\n QueryListRowAction,\n QueryListRowRenderData,\n QueryListSearchConfig,\n QueryListVisibleFieldsConfig,\n} from '../../types/queryList';\nimport {QueryHistoryRow} from '../../types/history';\nimport {HistoryRowContent} from './internal/HistoryRowContent';\nimport './QueriesHistory.scss';\n\nexport type QueriesHistoryProps<T extends QueryHistoryRow = QueryHistoryRow> = {\n className?: string;\n title?: string;\n logo?: React.ReactNode;\n search: QueryListSearchConfig;\n filter?: QueryListFilterConfig;\n items: QueryListItem<T>[];\n selectedRowId?: T['id'];\n editing?: QueryListEditingConfig<T>;\n comparison?: QueryListComparisonConfig<T>;\n visibleFields?: QueryListVisibleFieldsConfig<T>;\n renderRowItem?: (data: QueryListRowRenderData<T>) => React.ReactNode;\n getRowActions?: (item: T) => QueryListRowAction<T>[];\n onListItemClick?: (item: QueryListItem<T>) => void;\n hasMore?: boolean;\n loading?: boolean;\n onLoadMore?: () => void;\n renderLink?: QueryListLinkRenderer;\n};\n\nconst block = cn('qp-query-history');\n\nexport const QueriesHistory = <T extends QueryHistoryRow>({\n title,\n logo,\n search,\n filter,\n items,\n selectedRowId,\n editing,\n comparison,\n visibleFields,\n renderRowItem,\n getRowActions,\n onListItemClick,\n hasMore,\n loading,\n onLoadMore,\n renderLink,\n className,\n}: QueriesHistoryProps<T>) => {\n return (\n <QueriesList\n className={block(null, className)}\n title={title}\n logo={logo}\n search={search}\n filter={filter}\n items={items}\n selectedRowId={selectedRowId}\n visibleFields={visibleFields}\n editing={editing}\n comparison={comparison}\n getRowActions={getRowActions}\n renderRow={(data) =>\n renderRowItem ? renderRowItem(data) : <HistoryRowContent {...data} />\n }\n onListItemClick={onListItemClick}\n hasMore={hasMore}\n loading={loading}\n onLoadMore={onLoadMore}\n renderLink={renderLink}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,EAAE,MAAM,aAAa;AAC5B,SAAQC,WAAW;AAanB,SAAQC,iBAAiB;AACzB;AAA+B,SAAAC,GAAA,IAAAC,IAAA;AAsB/B,IAAMC,KAAK,GAAGL,EAAE,CAAC,kBAAkB,CAAC;AAEpC,OAAO,IAAMM,cAAc,GAAG,SAAjBA,cAAcA,CAAAC,IAAA,EAkBG;EAAA,IAjB1BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,MAAM,GAAAH,IAAA,CAANG,MAAM;IACNC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,KAAK,GAAAL,IAAA,CAALK,KAAK;IACLC,aAAa,GAAAN,IAAA,CAAbM,aAAa;IACbC,OAAO,GAAAP,IAAA,CAAPO,OAAO;IACPC,UAAU,GAAAR,IAAA,CAAVQ,UAAU;IACVC,aAAa,GAAAT,IAAA,CAAbS,aAAa;IACbC,aAAa,GAAAV,IAAA,CAAbU,aAAa;IACbC,aAAa,GAAAX,IAAA,CAAbW,aAAa;IACbC,eAAe,GAAAZ,IAAA,CAAfY,eAAe;IACfC,OAAO,GAAAb,IAAA,CAAPa,OAAO;IACPC,OAAO,GAAAd,IAAA,CAAPc,OAAO;IACPC,UAAU,GAAAf,IAAA,CAAVe,UAAU;IACVC,UAAU,GAAAhB,IAAA,CAAVgB,UAAU;IACVC,SAAS,GAAAjB,IAAA,CAATiB,SAAS;EAET,oBACIpB,IAAA,CAACH,WAAW;IACRuB,SAAS,EAAEnB,KAAK,CAAC,IAAI,EAAEmB,SAAS,CAAE;IAClChB,KAAK,EAAEA,KAAM;IACbC,IAAI,EAAEA,IAAK;IACXC,MAAM,EAAEA,MAAO;IACfC,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEA,KAAM;IACbC,aAAa,EAAEA,aAAc;IAC7BG,aAAa,EAAEA,aAAc;IAC7BF,OAAO,EAAEA,OAAQ;IACjBC,UAAU,EAAEA,UAAW;IACvBG,aAAa,EAAEA,aAAc;IAC7BO,SAAS,EAAE,SAAXA,SAASA,CAAGC,IAAI;MAAA,OACZT,aAAa,GAAGA,aAAa,CAACS,IAAI,CAAC,gBAAGtB,IAAA,CAACF,iBAAiB,EAAAyB,aAAA,KAAKD,IAAI,CAAG,CAAC;IAAA,CACxE;IACDP,eAAe,EAAEA,eAAgB;IACjCC,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IACjBC,UAAU,EAAEA,UAAW;IACvBC,UAAU,EAAEA;EAAW,CAC1B,CAAC;AAEV,CAAC","ignoreList":[]}
|
|
@@ -5,4 +5,9 @@ export default meta;
|
|
|
5
5
|
type Story = StoryObj<typeof QueriesHistory>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
7
|
export declare const Empty: Story;
|
|
8
|
+
export declare const InitialLoading: Story;
|
|
9
|
+
export declare const Paginated: Story;
|
|
10
|
+
export declare const FullSearchUnavailable: Story;
|
|
11
|
+
export declare const RouterLinks: Story;
|
|
12
|
+
export declare const CustomRowRenderer: Story;
|
|
8
13
|
export declare const WithHeader: Story;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
5
|
+
var _excluded = ["onClick"];
|
|
4
6
|
import "core-js/modules/es.array.concat.js";
|
|
5
7
|
import "core-js/modules/es.array.filter.js";
|
|
6
8
|
import "core-js/modules/es.array.find-index.js";
|
|
7
9
|
import "core-js/modules/es.array.includes.js";
|
|
10
|
+
import "core-js/modules/es.array.map.js";
|
|
8
11
|
import "core-js/modules/es.array.slice.js";
|
|
9
12
|
import "core-js/modules/es.date.now.js";
|
|
10
13
|
import "core-js/modules/es.iterator.constructor.js";
|
|
11
14
|
import "core-js/modules/es.iterator.filter.js";
|
|
12
15
|
import "core-js/modules/es.object.to-string.js";
|
|
13
16
|
import "core-js/modules/es.string.includes.js";
|
|
17
|
+
import "core-js/modules/web.timers.js";
|
|
14
18
|
import React, { useState } from 'react';
|
|
15
|
-
import { SegmentedRadioGroup } from '@gravity-ui/uikit';
|
|
19
|
+
import { SegmentedRadioGroup, Text } from '@gravity-ui/uikit';
|
|
20
|
+
import { HistoryGroupHeader, RowLink } from "../../components";
|
|
16
21
|
import { QueriesHistory } from "./QueriesHistory";
|
|
17
22
|
import { action } from 'storybook/actions';
|
|
18
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -101,6 +106,12 @@ var BASE_ITEMS = [{
|
|
|
101
106
|
query: QUERY,
|
|
102
107
|
height: 52
|
|
103
108
|
}];
|
|
109
|
+
var LINK_ITEMS = BASE_ITEMS.map(function (item) {
|
|
110
|
+
return 'id' in item ? _objectSpread(_objectSpread({}, item), {}, {
|
|
111
|
+
href: "/queries/".concat(item.id)
|
|
112
|
+
}) : item;
|
|
113
|
+
});
|
|
114
|
+
var PAGINATION_PAGES = [LINK_ITEMS.slice(0, 3), LINK_ITEMS.slice(3, 6), LINK_ITEMS.slice(6)];
|
|
104
115
|
var activeFields = ['duration', 'mode', 'startTime', 'engine', 'isPrivate'];
|
|
105
116
|
var fields = [{
|
|
106
117
|
id: 'duration',
|
|
@@ -142,6 +153,21 @@ var filterFields = [{
|
|
|
142
153
|
}];
|
|
143
154
|
var logFilterApply = action('onFilterApply');
|
|
144
155
|
var logFilterReset = action('onFilterReset');
|
|
156
|
+
var renderRouterLink = function renderRouterLink(_ref) {
|
|
157
|
+
var _onClick = _ref.onClick,
|
|
158
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
159
|
+
return /*#__PURE__*/_jsx("a", _objectSpread(_objectSpread({}, props), {}, {
|
|
160
|
+
"data-router-link": true,
|
|
161
|
+
onClick: function onClick(event) {
|
|
162
|
+
_onClick === null || _onClick === void 0 || _onClick(event);
|
|
163
|
+
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
action('routerNavigate')(props.href);
|
|
168
|
+
}
|
|
169
|
+
}));
|
|
170
|
+
};
|
|
145
171
|
var meta = {
|
|
146
172
|
title: 'Widgets/QueriesHistory',
|
|
147
173
|
component: QueriesHistory,
|
|
@@ -159,7 +185,7 @@ var operationFilterOptions = [{
|
|
|
159
185
|
}];
|
|
160
186
|
export default meta;
|
|
161
187
|
var DefaultStory = function DefaultStory() {
|
|
162
|
-
var _useState = useState(
|
|
188
|
+
var _useState = useState(_toConsumableArray(LINK_ITEMS)),
|
|
163
189
|
_useState2 = _slicedToArray(_useState, 2),
|
|
164
190
|
items = _useState2[0],
|
|
165
191
|
setItems = _useState2[1];
|
|
@@ -218,10 +244,10 @@ var DefaultStory = function DefaultStory() {
|
|
|
218
244
|
var handleOnSearch = function handleOnSearch(data) {
|
|
219
245
|
setSearch(data);
|
|
220
246
|
if (!data.value) {
|
|
221
|
-
setItems(
|
|
247
|
+
setItems(LINK_ITEMS);
|
|
222
248
|
return;
|
|
223
249
|
}
|
|
224
|
-
var newItems =
|
|
250
|
+
var newItems = LINK_ITEMS.filter(function (item) {
|
|
225
251
|
var _item$query;
|
|
226
252
|
if (!('id' in item)) return false;
|
|
227
253
|
var title = item.title.toLowerCase();
|
|
@@ -283,7 +309,8 @@ var DefaultStory = function DefaultStory() {
|
|
|
283
309
|
rowId: editingId,
|
|
284
310
|
onSubmit: handleEditSubmit,
|
|
285
311
|
onCancel: handleEditCancel
|
|
286
|
-
}
|
|
312
|
+
},
|
|
313
|
+
renderLink: renderRouterLink
|
|
287
314
|
})
|
|
288
315
|
});
|
|
289
316
|
};
|
|
@@ -353,6 +380,134 @@ var WithHeaderStory = function WithHeaderStory() {
|
|
|
353
380
|
})
|
|
354
381
|
});
|
|
355
382
|
};
|
|
383
|
+
var PaginatedStory = function PaginatedStory() {
|
|
384
|
+
var _useState17 = useState(PAGINATION_PAGES[0]),
|
|
385
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
386
|
+
items = _useState18[0],
|
|
387
|
+
setItems = _useState18[1];
|
|
388
|
+
var _useState19 = useState(1),
|
|
389
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
390
|
+
page = _useState20[0],
|
|
391
|
+
setPage = _useState20[1];
|
|
392
|
+
var _useState21 = useState(false),
|
|
393
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
394
|
+
loading = _useState22[0],
|
|
395
|
+
setLoading = _useState22[1];
|
|
396
|
+
var handleLoadMore = function handleLoadMore() {
|
|
397
|
+
var nextPage = PAGINATION_PAGES[page];
|
|
398
|
+
if (loading || !nextPage) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
action('onLoadMore')(page);
|
|
402
|
+
setLoading(true);
|
|
403
|
+
window.setTimeout(function () {
|
|
404
|
+
setItems(function (currentItems) {
|
|
405
|
+
return [].concat(_toConsumableArray(currentItems), _toConsumableArray(nextPage));
|
|
406
|
+
});
|
|
407
|
+
setPage(function (currentPage) {
|
|
408
|
+
return currentPage + 1;
|
|
409
|
+
});
|
|
410
|
+
setLoading(false);
|
|
411
|
+
}, 700);
|
|
412
|
+
};
|
|
413
|
+
return /*#__PURE__*/_jsx("div", {
|
|
414
|
+
style: {
|
|
415
|
+
width: 300,
|
|
416
|
+
height: 300
|
|
417
|
+
},
|
|
418
|
+
children: /*#__PURE__*/_jsx(QueriesHistory, {
|
|
419
|
+
title: "Paginated history",
|
|
420
|
+
items: items,
|
|
421
|
+
selectedRowId: 2,
|
|
422
|
+
loading: loading,
|
|
423
|
+
hasMore: page < PAGINATION_PAGES.length,
|
|
424
|
+
onLoadMore: handleLoadMore,
|
|
425
|
+
search: {
|
|
426
|
+
onUpdate: action('onSearchUpdate')
|
|
427
|
+
}
|
|
428
|
+
})
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
var FullSearchUnavailableStory = function FullSearchUnavailableStory() {
|
|
432
|
+
var _useState23 = useState({
|
|
433
|
+
value: 'Query',
|
|
434
|
+
fullSearch: true
|
|
435
|
+
}),
|
|
436
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
437
|
+
search = _useState24[0],
|
|
438
|
+
setSearch = _useState24[1];
|
|
439
|
+
return /*#__PURE__*/_jsx("div", {
|
|
440
|
+
style: {
|
|
441
|
+
width: 300,
|
|
442
|
+
height: 500
|
|
443
|
+
},
|
|
444
|
+
children: /*#__PURE__*/_jsx(QueriesHistory, {
|
|
445
|
+
title: "Basic search only",
|
|
446
|
+
items: LINK_ITEMS,
|
|
447
|
+
search: _objectSpread(_objectSpread({}, search), {}, {
|
|
448
|
+
fullSearchAvailable: false,
|
|
449
|
+
hasClear: true,
|
|
450
|
+
onUpdate: function onUpdate(data) {
|
|
451
|
+
action('onSearchUpdate')(data);
|
|
452
|
+
setSearch(data);
|
|
453
|
+
}
|
|
454
|
+
})
|
|
455
|
+
})
|
|
456
|
+
});
|
|
457
|
+
};
|
|
458
|
+
var RouterLinksStory = function RouterLinksStory() {
|
|
459
|
+
var _useState25 = useState({
|
|
460
|
+
value: '',
|
|
461
|
+
fullSearch: false
|
|
462
|
+
}),
|
|
463
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
|
464
|
+
search = _useState26[0],
|
|
465
|
+
setSearch = _useState26[1];
|
|
466
|
+
return /*#__PURE__*/_jsx("div", {
|
|
467
|
+
style: {
|
|
468
|
+
width: 500,
|
|
469
|
+
height: 500
|
|
470
|
+
},
|
|
471
|
+
children: /*#__PURE__*/_jsx(QueriesHistory, {
|
|
472
|
+
title: "Router links",
|
|
473
|
+
items: LINK_ITEMS,
|
|
474
|
+
renderLink: renderRouterLink,
|
|
475
|
+
search: _objectSpread(_objectSpread({}, search), {}, {
|
|
476
|
+
hasClear: true,
|
|
477
|
+
onUpdate: setSearch
|
|
478
|
+
})
|
|
479
|
+
})
|
|
480
|
+
});
|
|
481
|
+
};
|
|
482
|
+
var CustomRowRendererStory = function CustomRowRendererStory() {
|
|
483
|
+
return /*#__PURE__*/_jsx("div", {
|
|
484
|
+
style: {
|
|
485
|
+
width: 300,
|
|
486
|
+
height: 300
|
|
487
|
+
},
|
|
488
|
+
children: /*#__PURE__*/_jsx(QueriesHistory, {
|
|
489
|
+
title: "Custom row renderer",
|
|
490
|
+
items: LINK_ITEMS.slice(0, 3),
|
|
491
|
+
renderLink: renderRouterLink,
|
|
492
|
+
renderRowItem: function renderRowItem(_ref2) {
|
|
493
|
+
var item = _ref2.item,
|
|
494
|
+
renderLink = _ref2.renderLink;
|
|
495
|
+
return 'header' in item ? /*#__PURE__*/_jsx(HistoryGroupHeader, {
|
|
496
|
+
title: item.header
|
|
497
|
+
}) : /*#__PURE__*/_jsx(RowLink, {
|
|
498
|
+
href: item.href,
|
|
499
|
+
renderLink: renderLink,
|
|
500
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
501
|
+
children: item.title
|
|
502
|
+
})
|
|
503
|
+
});
|
|
504
|
+
},
|
|
505
|
+
search: {
|
|
506
|
+
onUpdate: action('onSearchUpdate')
|
|
507
|
+
}
|
|
508
|
+
})
|
|
509
|
+
});
|
|
510
|
+
};
|
|
356
511
|
export var Default = {
|
|
357
512
|
render: function render() {
|
|
358
513
|
return /*#__PURE__*/_jsx(DefaultStory, {});
|
|
@@ -363,6 +518,45 @@ export var Empty = {
|
|
|
363
518
|
return /*#__PURE__*/_jsx(EmptyStory, {});
|
|
364
519
|
}
|
|
365
520
|
};
|
|
521
|
+
export var InitialLoading = {
|
|
522
|
+
args: {
|
|
523
|
+
title: 'Loading history',
|
|
524
|
+
items: [],
|
|
525
|
+
loading: true,
|
|
526
|
+
search: {
|
|
527
|
+
onUpdate: action('onSearchUpdate')
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
decorators: [function (StoryComponent) {
|
|
531
|
+
return /*#__PURE__*/_jsx("div", {
|
|
532
|
+
style: {
|
|
533
|
+
width: 300,
|
|
534
|
+
height: 500
|
|
535
|
+
},
|
|
536
|
+
children: /*#__PURE__*/_jsx(StoryComponent, {})
|
|
537
|
+
});
|
|
538
|
+
}]
|
|
539
|
+
};
|
|
540
|
+
export var Paginated = {
|
|
541
|
+
render: function render() {
|
|
542
|
+
return /*#__PURE__*/_jsx(PaginatedStory, {});
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
export var FullSearchUnavailable = {
|
|
546
|
+
render: function render() {
|
|
547
|
+
return /*#__PURE__*/_jsx(FullSearchUnavailableStory, {});
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
export var RouterLinks = {
|
|
551
|
+
render: function render() {
|
|
552
|
+
return /*#__PURE__*/_jsx(RouterLinksStory, {});
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
export var CustomRowRenderer = {
|
|
556
|
+
render: function render() {
|
|
557
|
+
return /*#__PURE__*/_jsx(CustomRowRendererStory, {});
|
|
558
|
+
}
|
|
559
|
+
};
|
|
366
560
|
export var WithHeader = {
|
|
367
561
|
render: function render() {
|
|
368
562
|
return /*#__PURE__*/_jsx(WithHeaderStory, {});
|