@yimoka/designable-playground 0.0.0-stage → 0.1.1
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/README.md +8 -2
- package/dist/demo/components/Alert/index.d.ts +4 -0
- package/dist/demo/components/Alert/index.js +41 -0
- package/dist/demo/components/ArrayCards/index.d.ts +17 -0
- package/dist/demo/components/ArrayCards/index.js +62 -0
- package/dist/demo/components/ArrayList/index.d.ts +25 -0
- package/dist/demo/components/ArrayList/index.js +143 -0
- package/dist/demo/components/ArrayTable/index.d.ts +39 -0
- package/dist/demo/components/ArrayTable/index.js +247 -0
- package/dist/demo/components/AutoComplete/index.d.ts +4 -0
- package/dist/demo/components/AutoComplete/index.js +52 -0
- package/dist/demo/components/Avatar/index.d.ts +4 -0
- package/dist/demo/components/Avatar/index.js +34 -0
- package/dist/demo/components/Badge/index.d.ts +4 -0
- package/dist/demo/components/Badge/index.js +35 -0
- package/dist/demo/components/Button/index.d.ts +4 -0
- package/dist/demo/components/Button/index.js +86 -0
- package/dist/demo/components/Card/index.d.ts +4 -0
- package/dist/demo/components/Card/index.js +72 -0
- package/dist/demo/components/Carousel/index.d.ts +4 -0
- package/dist/demo/components/Carousel/index.js +33 -0
- package/dist/demo/components/Cascader/index.d.ts +4 -0
- package/dist/demo/components/Cascader/index.js +60 -0
- package/dist/demo/components/Checkbox/index.d.ts +8 -0
- package/dist/demo/components/Checkbox/index.js +55 -0
- package/dist/demo/components/ColorPicker/index.d.ts +4 -0
- package/dist/demo/components/ColorPicker/index.js +38 -0
- package/dist/demo/components/DatePicker/index.d.ts +4 -0
- package/dist/demo/components/DatePicker/index.js +61 -0
- package/dist/demo/components/DateRangePicker/index.d.ts +4 -0
- package/dist/demo/components/DateRangePicker/index.js +58 -0
- package/dist/demo/components/Divider/index.d.ts +4 -0
- package/dist/demo/components/Divider/index.js +39 -0
- package/dist/demo/components/Empty/index.d.ts +4 -0
- package/dist/demo/components/Empty/index.js +29 -0
- package/dist/demo/components/Flex/index.d.ts +4 -0
- package/dist/demo/components/Flex/index.js +51 -0
- package/dist/demo/components/Form/index.d.ts +21 -0
- package/dist/demo/components/Form/index.js +116 -0
- package/dist/demo/components/FormCollapse/index.d.ts +28 -0
- package/dist/demo/components/FormCollapse/index.js +164 -0
- package/dist/demo/components/FormGrid/index.d.ts +22 -0
- package/dist/demo/components/FormGrid/index.js +134 -0
- package/dist/demo/components/FormItem/index.d.ts +14 -0
- package/dist/demo/components/FormItem/index.js +33 -0
- package/dist/demo/components/FormLayout/index.d.ts +26 -0
- package/dist/demo/components/FormLayout/index.js +260 -0
- package/dist/demo/components/FormTab/index.d.ts +15 -0
- package/dist/demo/components/FormTab/index.js +186 -0
- package/dist/demo/components/GridCol/index.d.ts +4 -0
- package/dist/demo/components/GridCol/index.js +53 -0
- package/dist/demo/components/GridRow/index.d.ts +4 -0
- package/dist/demo/components/GridRow/index.js +70 -0
- package/dist/demo/components/HTMLContent/index.d.ts +4 -0
- package/dist/demo/components/HTMLContent/index.js +34 -0
- package/dist/demo/components/I18nEditor/index.d.ts +8 -0
- package/dist/demo/components/I18nEditor/index.js +64 -0
- package/dist/demo/components/Image/index.d.ts +4 -0
- package/dist/demo/components/Image/index.js +36 -0
- package/dist/demo/components/Input/index.d.ts +4 -0
- package/dist/demo/components/Input/index.js +36 -0
- package/dist/demo/components/InputSearch/index.d.ts +4 -0
- package/dist/demo/components/InputSearch/index.js +40 -0
- package/dist/demo/components/Link/index.d.ts +4 -0
- package/dist/demo/components/Link/index.js +37 -0
- package/dist/demo/components/Mentions/index.d.ts +4 -0
- package/dist/demo/components/Mentions/index.js +41 -0
- package/dist/demo/components/NumberPicker/index.d.ts +6 -0
- package/dist/demo/components/NumberPicker/index.js +63 -0
- package/dist/demo/components/ObjectContainer/index.d.ts +14 -0
- package/dist/demo/components/ObjectContainer/index.js +46 -0
- package/dist/demo/components/Password/index.d.ts +6 -0
- package/dist/demo/components/Password/index.js +44 -0
- package/dist/demo/components/QRCode/index.d.ts +4 -0
- package/dist/demo/components/QRCode/index.js +34 -0
- package/dist/demo/components/Radio/index.d.ts +6 -0
- package/dist/demo/components/Radio/index.js +49 -0
- package/dist/demo/components/Rate/index.d.ts +6 -0
- package/dist/demo/components/Rate/index.js +43 -0
- package/dist/demo/components/Search/index.d.ts +4 -0
- package/dist/demo/components/Search/index.js +42 -0
- package/dist/demo/components/SearchSelect/index.d.ts +4 -0
- package/dist/demo/components/SearchSelect/index.js +53 -0
- package/dist/demo/components/Select/index.d.ts +4 -0
- package/dist/demo/components/Select/index.js +59 -0
- package/dist/demo/components/Slider/index.d.ts +6 -0
- package/dist/demo/components/Slider/index.js +61 -0
- package/dist/demo/components/Space/index.d.ts +9 -0
- package/dist/demo/components/Space/index.js +61 -0
- package/dist/demo/components/Statistic/index.d.ts +4 -0
- package/dist/demo/components/Statistic/index.js +33 -0
- package/dist/demo/components/Switch/index.d.ts +4 -0
- package/dist/demo/components/Switch/index.js +49 -0
- package/dist/demo/components/Tabs/index.d.ts +10 -0
- package/dist/demo/components/Tabs/index.js +181 -0
- package/dist/demo/components/Tag/index.d.ts +4 -0
- package/dist/demo/components/Tag/index.js +33 -0
- package/dist/demo/components/Text/index.d.ts +11 -0
- package/dist/demo/components/Text/index.js +64 -0
- package/dist/demo/components/TextArea/index.d.ts +6 -0
- package/dist/demo/components/TextArea/index.js +43 -0
- package/dist/demo/components/TimePicker/index.d.ts +4 -0
- package/dist/demo/components/TimePicker/index.js +69 -0
- package/dist/demo/components/TimeRangePicker/index.d.ts +4 -0
- package/dist/demo/components/TimeRangePicker/index.js +68 -0
- package/dist/demo/components/Transfer/index.d.ts +6 -0
- package/dist/demo/components/Transfer/index.js +59 -0
- package/dist/demo/components/TreeSelect/index.d.ts +4 -0
- package/dist/demo/components/TreeSelect/index.js +63 -0
- package/dist/demo/components/Upload/index.d.ts +8 -0
- package/dist/demo/components/Upload/index.js +64 -0
- package/dist/demo/components/index.d.ts +55 -0
- package/dist/demo/components/index.js +55 -0
- package/dist/demo/components/shared.d.ts +143 -0
- package/dist/demo/components/shared.js +315 -0
- package/dist/src/Playground.d.ts +3 -0
- package/dist/src/Playground.js +304 -0
- package/dist/src/antd/AntdPlayground.d.ts +16 -0
- package/dist/src/antd/AntdPlayground.js +136 -0
- package/dist/src/antd/index.d.ts +1 -0
- package/dist/src/antd/index.js +1 -0
- package/dist/src/context.d.ts +4 -0
- package/dist/src/context.js +13 -0
- package/dist/src/examples/index.d.ts +267 -0
- package/dist/src/examples/index.js +824 -0
- package/dist/src/hooks/index.d.ts +4 -0
- package/dist/src/hooks/index.js +4 -0
- package/dist/src/hooks/remoteSchemaAdapter.d.ts +53 -0
- package/dist/src/hooks/remoteSchemaAdapter.js +262 -0
- package/dist/src/hooks/usePlayground.d.ts +38 -0
- package/dist/src/hooks/usePlayground.js +642 -0
- package/dist/src/hooks/usePlaygroundRemotePersistence.d.ts +135 -0
- package/dist/src/hooks/usePlaygroundRemotePersistence.js +736 -0
- package/dist/src/hooks/useSchemaEditorDraft.d.ts +4 -0
- package/dist/src/hooks/useSchemaEditorDraft.js +44 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +14 -0
- package/dist/src/layouts/PlaygroundLayout/ErrorBoundaries.d.ts +59 -0
- package/dist/src/layouts/PlaygroundLayout/ErrorBoundaries.js +161 -0
- package/dist/src/layouts/PlaygroundLayout/index.d.ts +7 -0
- package/dist/src/layouts/PlaygroundLayout/index.js +443 -0
- package/dist/src/layouts/index.d.ts +1 -0
- package/dist/src/layouts/index.js +1 -0
- package/dist/src/panels/CompositePanel/index.d.ts +6 -0
- package/dist/src/panels/CompositePanel/index.js +139 -0
- package/dist/src/panels/ToolbarPanel/index.d.ts +3 -0
- package/dist/src/panels/ToolbarPanel/index.js +24 -0
- package/dist/src/panels/index.d.ts +2 -0
- package/dist/src/panels/index.js +2 -0
- package/dist/src/presets/antd.d.ts +19 -0
- package/dist/src/presets/antd.js +112 -0
- package/dist/src/presets/index.d.ts +4 -0
- package/dist/src/presets/index.js +3 -0
- package/dist/src/presets/runtime-array-helpers.d.ts +8 -0
- package/dist/src/presets/runtime-array-helpers.js +147 -0
- package/dist/src/presets/runtime-component-props.d.ts +3 -0
- package/dist/src/presets/runtime-component-props.js +5 -0
- package/dist/src/presets/runtime-components.d.ts +5 -0
- package/dist/src/presets/runtime-components.js +419 -0
- package/dist/src/presets/runtime-form-components.d.ts +9 -0
- package/dist/src/presets/runtime-form-components.js +94 -0
- package/dist/src/presets/scenario-catalog.d.ts +6 -0
- package/dist/src/presets/scenario-catalog.js +128 -0
- package/dist/src/presets/scenarios.d.ts +52 -0
- package/dist/src/presets/scenarios.js +603 -0
- package/dist/src/runtime/actions.d.ts +19 -0
- package/dist/src/runtime/actions.js +307 -0
- package/dist/src/runtime/contracts.d.ts +149 -0
- package/dist/src/runtime/contracts.js +1 -0
- package/dist/src/runtime/document-bindings.d.ts +3 -0
- package/dist/src/runtime/document-bindings.js +101 -0
- package/dist/src/runtime/document-core.d.ts +57 -0
- package/dist/src/runtime/document-core.js +379 -0
- package/dist/src/runtime/document-entity.d.ts +12 -0
- package/dist/src/runtime/document-entity.js +351 -0
- package/dist/src/runtime/document-expressions.d.ts +35 -0
- package/dist/src/runtime/document-expressions.js +346 -0
- package/dist/src/runtime/document-security.d.ts +34 -0
- package/dist/src/runtime/document-security.js +538 -0
- package/dist/src/runtime/document.d.ts +16 -0
- package/dist/src/runtime/document.js +212 -0
- package/dist/src/runtime/environment.d.ts +16 -0
- package/dist/src/runtime/environment.js +76 -0
- package/dist/src/runtime/i18n-schema.d.ts +36 -0
- package/dist/src/runtime/i18n-schema.js +338 -0
- package/dist/src/runtime/i18n.d.ts +25 -0
- package/dist/src/runtime/i18n.js +447 -0
- package/dist/src/runtime/index.d.ts +8 -0
- package/dist/src/runtime/index.js +8 -0
- package/dist/src/runtime/navigation.d.ts +5 -0
- package/dist/src/runtime/navigation.js +43 -0
- package/dist/src/runtime/playground.d.ts +30 -0
- package/dist/src/runtime/playground.js +243 -0
- package/dist/src/runtime/preview-boundaries.d.ts +13 -0
- package/dist/src/runtime/preview-boundaries.js +43 -0
- package/dist/src/runtime/preview.d.ts +44 -0
- package/dist/src/runtime/preview.js +574 -0
- package/dist/src/runtime/settings/RuntimeJsonEditor.d.ts +10 -0
- package/dist/src/runtime/settings/RuntimeJsonEditor.js +21 -0
- package/dist/src/runtime/settings/RuntimeStoreEntitySettings.d.ts +15 -0
- package/dist/src/runtime/settings/RuntimeStoreEntitySettings.js +65 -0
- package/dist/src/runtime/templates.d.ts +1560 -0
- package/dist/src/runtime/templates.js +508 -0
- package/dist/src/runtime/website-contact-template.d.ts +1 -0
- package/dist/src/runtime/website-contact-template.js +66 -0
- package/dist/src/runtime/website-template-shared.d.ts +14 -0
- package/dist/src/runtime/website-template-shared.js +210 -0
- package/dist/src/runtime/website-templates.d.ts +5 -0
- package/dist/src/runtime/website-templates.js +976 -0
- package/dist/src/shared/clipboard.d.ts +4 -0
- package/dist/src/shared/clipboard.js +56 -0
- package/dist/src/shared/componentRegistry.d.ts +133 -0
- package/dist/src/shared/componentRegistry.js +381 -0
- package/dist/src/shared/formilyCompatibility.d.ts +8 -0
- package/dist/src/shared/formilyCompatibility.js +40 -0
- package/dist/src/shared/index.d.ts +6 -0
- package/dist/src/shared/index.js +6 -0
- package/dist/src/shared/productionAcceptance.d.ts +63 -0
- package/dist/src/shared/productionAcceptance.js +201 -0
- package/dist/src/shared/schema-options.d.ts +16 -0
- package/dist/src/shared/schema-options.js +138 -0
- package/dist/src/shared/schema.d.ts +63 -0
- package/dist/src/shared/schema.js +627 -0
- package/dist/src/shared/styleSecurity.d.ts +2 -0
- package/dist/src/shared/styleSecurity.js +35 -0
- package/dist/src/transformers/formily.d.ts +34 -0
- package/dist/src/transformers/formily.js +943 -0
- package/dist/src/transformers/index.d.ts +1 -0
- package/dist/src/transformers/index.js +1 -0
- package/dist/src/types.d.ts +186 -0
- package/dist/src/types.js +1 -0
- package/dist/src/widgets/ActionsWidget/index.d.ts +3 -0
- package/dist/src/widgets/ActionsWidget/index.js +10 -0
- package/dist/src/widgets/ComponentTreeWidget/index.d.ts +3 -0
- package/dist/src/widgets/ComponentTreeWidget/index.js +333 -0
- package/dist/src/widgets/NodeActionsWidget/index.d.ts +2 -0
- package/dist/src/widgets/NodeActionsWidget/index.js +125 -0
- package/dist/src/widgets/OutlineTreeWidget/index.d.ts +3 -0
- package/dist/src/widgets/OutlineTreeWidget/index.js +432 -0
- package/dist/src/widgets/OutlineTreeWidget/shared.d.ts +32 -0
- package/dist/src/widgets/OutlineTreeWidget/shared.js +79 -0
- package/dist/src/widgets/PreviewWidget/index.d.ts +2 -0
- package/dist/src/widgets/PreviewWidget/index.js +1566 -0
- package/dist/src/widgets/ProductionReadinessWidget/index.d.ts +18 -0
- package/dist/src/widgets/ProductionReadinessWidget/index.js +356 -0
- package/dist/src/widgets/RemotePersistenceStatusWidget/index.d.ts +18 -0
- package/dist/src/widgets/RemotePersistenceStatusWidget/index.js +438 -0
- package/dist/src/widgets/RemoteVersionHistoryWidget/index.d.ts +39 -0
- package/dist/src/widgets/RemoteVersionHistoryWidget/index.js +475 -0
- package/dist/src/widgets/ResourceWidget/index.d.ts +3 -0
- package/dist/src/widgets/ResourceWidget/index.js +491 -0
- package/dist/src/widgets/SchemaCodeView/index.d.ts +7 -0
- package/dist/src/widgets/SchemaCodeView/index.js +225 -0
- package/dist/src/widgets/SchemaEditorWidget/index.d.ts +10 -0
- package/dist/src/widgets/SchemaEditorWidget/index.js +484 -0
- package/dist/src/widgets/SettingsPanelWidget/index.d.ts +3 -0
- package/dist/src/widgets/SettingsPanelWidget/index.js +190 -0
- package/dist/src/widgets/StorageActionsWidget/index.d.ts +2 -0
- package/dist/src/widgets/StorageActionsWidget/index.js +284 -0
- package/dist/src/widgets/index.d.ts +13 -0
- package/dist/src/widgets/index.js +13 -0
- package/package.json +100 -4
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { observer } from '@formily/reactive-react';
|
|
3
|
+
import { IconWidget, TextWidget, usePrefix } from '@yimoka/designable-react';
|
|
4
|
+
import { Collapse } from 'antd';
|
|
5
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { useMaybePlaygroundContext } from "../../context.js";
|
|
7
|
+
const getResourceInitials = (title, fallback) => {
|
|
8
|
+
const rawText = typeof title === 'string' ? title : fallback;
|
|
9
|
+
const text = rawText.replace(/[^0-9a-zA-Z\u4e00-\u9fa5]/g, '');
|
|
10
|
+
return (text.slice(0, 2) || '?').toUpperCase();
|
|
11
|
+
};
|
|
12
|
+
const getContentText = (value, fallback = '') => {
|
|
13
|
+
if (typeof value === 'string' || typeof value === 'number')
|
|
14
|
+
return String(value);
|
|
15
|
+
if (value && typeof value === 'object' && !React.isValidElement(value)) {
|
|
16
|
+
const firstText = Object.values(value).find(item => typeof item === 'string');
|
|
17
|
+
return firstText ?? fallback;
|
|
18
|
+
}
|
|
19
|
+
return fallback;
|
|
20
|
+
};
|
|
21
|
+
const renderResourceText = (value, fallback) => (typeof value === 'string'
|
|
22
|
+
? _jsx(TextWidget, { children: value })
|
|
23
|
+
: _jsx(TextWidget, { defaultMessage: fallback, token: value }));
|
|
24
|
+
const normalizeSearchText = (value) => (value
|
|
25
|
+
.toLowerCase()
|
|
26
|
+
.replace(/[\s_\-.]/g, ''));
|
|
27
|
+
const DEFAULT_RESOURCE_KEYWORDS = {
|
|
28
|
+
Alert: ['提示', '警告', '公告', '反馈'],
|
|
29
|
+
AutoComplete: ['自动完成', '联想输入', '输入建议'],
|
|
30
|
+
Avatar: ['头像', '用户头像', '图片'],
|
|
31
|
+
Badge: ['徽标', '角标', '状态点', '数量'],
|
|
32
|
+
Button: ['按钮', '操作', '提交'],
|
|
33
|
+
Card: ['卡片', '容器', '区块'],
|
|
34
|
+
Cascader: ['级联', '级联选择', '地区'],
|
|
35
|
+
Checkbox: ['复选框', '勾选', '多选'],
|
|
36
|
+
ColorPicker: ['颜色', '颜色选择', '取色器'],
|
|
37
|
+
DatePicker: ['日期', '日期选择'],
|
|
38
|
+
DateRangePicker: ['日期范围', '起止日期', '时间段'],
|
|
39
|
+
Divider: ['分割线', '分隔线', '分组线'],
|
|
40
|
+
Empty: ['空状态', '暂无数据', '无数据'],
|
|
41
|
+
Form: ['表单', '表单容器'],
|
|
42
|
+
FormCollapse: ['折叠', '折叠面板', '分组'],
|
|
43
|
+
Flex: ['弹性布局', 'flex布局', '水平布局', '垂直布局'],
|
|
44
|
+
FormGrid: ['栅格', '表单栅格', '网格'],
|
|
45
|
+
FormLayout: ['布局', '表单布局'],
|
|
46
|
+
FormTab: ['标签页', '选项卡', '页签'],
|
|
47
|
+
GridCol: ['列', '栅格列'],
|
|
48
|
+
GridRow: ['行', '栅格行'],
|
|
49
|
+
HTMLContent: ['富文本', 'html', '内容块'],
|
|
50
|
+
Image: ['图片', '图像', '照片'],
|
|
51
|
+
Input: ['输入框', '单行文本', '文本框'],
|
|
52
|
+
InputSearch: ['搜索输入', '搜索框', '查询输入'],
|
|
53
|
+
Link: ['链接', '跳转', '超链接'],
|
|
54
|
+
Mentions: ['提及', '@', '成员选择'],
|
|
55
|
+
NumberPicker: ['数字', '数字输入', '计数器'],
|
|
56
|
+
Password: ['密码', '密码框'],
|
|
57
|
+
QRCode: ['二维码', '扫码', 'qr'],
|
|
58
|
+
Radio: ['单选', '单选框'],
|
|
59
|
+
Rate: ['评分', '星级'],
|
|
60
|
+
Search: ['搜索', '远程搜索', '自动搜索'],
|
|
61
|
+
SearchSelect: ['搜索选择', '远程选择', '下拉搜索'],
|
|
62
|
+
Select: ['选择器', '下拉', '下拉选择'],
|
|
63
|
+
Slider: ['滑块', '范围', '拖动条'],
|
|
64
|
+
Space: ['间距', '排列', '空隙'],
|
|
65
|
+
Statistic: ['统计', '指标', '数值'],
|
|
66
|
+
Switch: ['开关', '启用', '禁用'],
|
|
67
|
+
Tabs: ['标签页', '选项卡', '页签'],
|
|
68
|
+
Tag: ['标签', '标记', '状态标签'],
|
|
69
|
+
Text: ['文本', '说明', '标题'],
|
|
70
|
+
TextArea: ['多行文本', '文本域', '备注'],
|
|
71
|
+
TimePicker: ['时间', '时间选择'],
|
|
72
|
+
TimeRangePicker: ['时间范围', '起止时间'],
|
|
73
|
+
Transfer: ['穿梭框', '转移', '双栏选择'],
|
|
74
|
+
TreeSelect: ['树选择', '树形选择', '层级选择'],
|
|
75
|
+
Upload: ['上传', '文件上传', '附件'],
|
|
76
|
+
};
|
|
77
|
+
const DEFAULT_EXPANDED_CATEGORY_LIMIT = 3;
|
|
78
|
+
const normalizeActiveKeys = (keys) => (Array.isArray(keys) ? keys : [keys]);
|
|
79
|
+
const getDefaultExpandedCategoryKeys = (categories, explicitKeys) => {
|
|
80
|
+
const categoryKeys = categories?.map(category => category.key) ?? [];
|
|
81
|
+
if (explicitKeys?.length) {
|
|
82
|
+
const keySet = new Set(categoryKeys);
|
|
83
|
+
return explicitKeys.filter(key => keySet.has(key));
|
|
84
|
+
}
|
|
85
|
+
const defaultKeys = categoryKeys.slice(0, DEFAULT_EXPANDED_CATEGORY_LIMIT);
|
|
86
|
+
const priorityPattern = /(biz|business|custom|extra|业务|自定义|扩展)/i;
|
|
87
|
+
const priorityKeys = categories
|
|
88
|
+
?.filter((category) => {
|
|
89
|
+
const titleText = getContentText(category.title, category.key);
|
|
90
|
+
return priorityPattern.test(category.key) || priorityPattern.test(titleText);
|
|
91
|
+
})
|
|
92
|
+
.map(category => category.key) ?? [];
|
|
93
|
+
return Array.from(new Set([...defaultKeys, ...priorityKeys]));
|
|
94
|
+
};
|
|
95
|
+
const RESOURCE_ITEM_ACTIVE_STYLE = {
|
|
96
|
+
borderColor: '#70b8ff',
|
|
97
|
+
boxShadow: '0 0 0 2px rgba(22, 119, 255, 0.12), 0 8px 18px rgba(24, 96, 180, 0.12)',
|
|
98
|
+
transform: 'translateY(-1px)',
|
|
99
|
+
};
|
|
100
|
+
const RESOURCE_ITEM_IDLE_STYLE = {
|
|
101
|
+
borderColor: '#e6ebf2',
|
|
102
|
+
boxShadow: '0 1px 2px rgba(15, 23, 42, 0.03)',
|
|
103
|
+
transform: 'none',
|
|
104
|
+
};
|
|
105
|
+
const setResourceItemStyle = (element, style) => {
|
|
106
|
+
element.style.setProperty('border-color', style.borderColor);
|
|
107
|
+
element.style.setProperty('box-shadow', style.boxShadow);
|
|
108
|
+
element.style.setProperty('transform', style.transform);
|
|
109
|
+
};
|
|
110
|
+
const applyResourceItemActiveStyle = (element) => {
|
|
111
|
+
setResourceItemStyle(element, RESOURCE_ITEM_ACTIVE_STYLE);
|
|
112
|
+
};
|
|
113
|
+
const resetResourceItemStyle = (element) => {
|
|
114
|
+
setResourceItemStyle(element, RESOURCE_ITEM_IDLE_STYLE);
|
|
115
|
+
};
|
|
116
|
+
const renderResourceInitials = (displayTitle, componentName) => (_jsx("span", { style: {
|
|
117
|
+
color: '#1677ff',
|
|
118
|
+
fontSize: 9,
|
|
119
|
+
fontWeight: 700,
|
|
120
|
+
letterSpacing: 0,
|
|
121
|
+
lineHeight: '12px',
|
|
122
|
+
}, children: getResourceInitials(displayTitle, componentName) }));
|
|
123
|
+
const renderResourceIconContent = (icon, displayTitle, componentName) => {
|
|
124
|
+
if (React.isValidElement(icon))
|
|
125
|
+
return icon;
|
|
126
|
+
return renderResourceInitials(displayTitle, componentName);
|
|
127
|
+
};
|
|
128
|
+
const ResourceItemIcon = ({ componentName, displayTitle, displayTitleText, icon, thumb, }) => {
|
|
129
|
+
if (thumb) {
|
|
130
|
+
return (_jsx("img", { alt: displayTitleText, draggable: false, src: thumb, style: { flex: '0 0 auto', height: 18, objectFit: 'contain', pointerEvents: 'none', width: 18 } }));
|
|
131
|
+
}
|
|
132
|
+
return (_jsx("div", { style: {
|
|
133
|
+
alignItems: 'center',
|
|
134
|
+
background: '#eef6ff',
|
|
135
|
+
border: '1px solid #d8eaff',
|
|
136
|
+
borderRadius: 5,
|
|
137
|
+
color: '#1677ff',
|
|
138
|
+
display: 'flex',
|
|
139
|
+
flex: '0 0 auto',
|
|
140
|
+
height: 18,
|
|
141
|
+
justifyContent: 'center',
|
|
142
|
+
pointerEvents: 'none',
|
|
143
|
+
width: 18,
|
|
144
|
+
}, children: renderResourceIconContent(icon, displayTitle, componentName) }));
|
|
145
|
+
};
|
|
146
|
+
const ResourceItemView = ({ componentName, displayTitle, displayTitleText, icon, index, nodeId, thumb, }) => (_jsxs("div", { "aria-label": `${displayTitleText} 组件资源,拖拽到画布添加`, "data-designer-source-id": nodeId, "data-resource-component": componentName, "data-resource-index": index, "data-resource-title": displayTitleText, draggable: false, role: "listitem", style: {
|
|
147
|
+
alignItems: 'center',
|
|
148
|
+
background: '#fff',
|
|
149
|
+
border: '1px solid #e6ebf2',
|
|
150
|
+
borderRadius: 5,
|
|
151
|
+
boxShadow: '0 1px 2px rgba(15, 23, 42, 0.03)',
|
|
152
|
+
boxSizing: 'border-box',
|
|
153
|
+
color: '#1f2a37',
|
|
154
|
+
cursor: 'grab',
|
|
155
|
+
display: 'flex',
|
|
156
|
+
gap: 5,
|
|
157
|
+
minHeight: 32,
|
|
158
|
+
outline: 'none',
|
|
159
|
+
padding: '4px 5px',
|
|
160
|
+
transition: 'border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease',
|
|
161
|
+
userSelect: 'none',
|
|
162
|
+
}, tabIndex: 0, title: `${displayTitleText} 组件资源`, onBlur: e => resetResourceItemStyle(e.currentTarget), onFocus: e => applyResourceItemActiveStyle(e.currentTarget), onKeyDown: (e) => {
|
|
163
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
}
|
|
166
|
+
}, onMouseEnter: (e) => {
|
|
167
|
+
applyResourceItemActiveStyle(e.currentTarget);
|
|
168
|
+
}, onMouseLeave: (e) => {
|
|
169
|
+
if (document.activeElement !== e.currentTarget) {
|
|
170
|
+
resetResourceItemStyle(e.currentTarget);
|
|
171
|
+
}
|
|
172
|
+
}, children: [_jsx(ResourceItemIcon, { componentName: componentName, displayTitle: displayTitle, displayTitleText: displayTitleText, icon: icon, thumb: thumb }), _jsx("span", { style: {
|
|
173
|
+
color: '#253040',
|
|
174
|
+
fontSize: 12,
|
|
175
|
+
lineHeight: '14px',
|
|
176
|
+
minWidth: 0,
|
|
177
|
+
maxWidth: '100%',
|
|
178
|
+
overflow: 'hidden',
|
|
179
|
+
pointerEvents: 'none',
|
|
180
|
+
textOverflow: 'ellipsis',
|
|
181
|
+
whiteSpace: 'nowrap',
|
|
182
|
+
}, children: renderResourceText(displayTitle, displayTitleText) })] }));
|
|
183
|
+
const getComponentResourceCount = (components, componentName) => (components?.[componentName]?.Resource?.length ?? 0);
|
|
184
|
+
const getResourceWidgetStyleText = (prefix) => `
|
|
185
|
+
.${prefix} .ant-collapse-header {
|
|
186
|
+
align-items: center !important;
|
|
187
|
+
min-height: 28px;
|
|
188
|
+
padding: 3px 0 !important;
|
|
189
|
+
}
|
|
190
|
+
.${prefix} .ant-collapse-content-box {
|
|
191
|
+
padding: 0 0 5px !important;
|
|
192
|
+
}
|
|
193
|
+
.${prefix} .ant-collapse-item {
|
|
194
|
+
border-bottom-color: #edf2f7 !important;
|
|
195
|
+
}
|
|
196
|
+
`;
|
|
197
|
+
const useResourceWidgetStyles = (prefix) => {
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
if (typeof document === 'undefined')
|
|
200
|
+
return;
|
|
201
|
+
const styleId = `designable-${prefix}-styles`;
|
|
202
|
+
let style = document.getElementById(styleId);
|
|
203
|
+
if (!style) {
|
|
204
|
+
style = document.createElement('style');
|
|
205
|
+
style.id = styleId;
|
|
206
|
+
style.setAttribute('data-designable-resource-style', prefix);
|
|
207
|
+
document.head.appendChild(style);
|
|
208
|
+
}
|
|
209
|
+
style.textContent = getResourceWidgetStyleText(prefix);
|
|
210
|
+
}, [prefix]);
|
|
211
|
+
};
|
|
212
|
+
const getDefaultExpandedSignature = (keys) => (keys === undefined ? '__auto__' : keys.join('\u0001'));
|
|
213
|
+
const areStringSetsEqual = (current, next) => {
|
|
214
|
+
if (current.size !== next.size)
|
|
215
|
+
return false;
|
|
216
|
+
for (const value of current) {
|
|
217
|
+
if (!next.has(value))
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
return true;
|
|
221
|
+
};
|
|
222
|
+
const resolveNextExpandedCategories = (current, categoryKeys, previousCategoryKeys, defaultExpandedCategoryKeys) => {
|
|
223
|
+
const nextExpanded = new Set();
|
|
224
|
+
const defaultExpandedSet = new Set(defaultExpandedCategoryKeys);
|
|
225
|
+
categoryKeys.forEach((key) => {
|
|
226
|
+
if (current.has(key) || (!previousCategoryKeys.has(key) && defaultExpandedSet.has(key))) {
|
|
227
|
+
nextExpanded.add(key);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
if (nextExpanded.size === 0 && current.size === 0 && previousCategoryKeys.size === 0) {
|
|
231
|
+
defaultExpandedCategoryKeys.forEach(key => nextExpanded.add(key));
|
|
232
|
+
}
|
|
233
|
+
return nextExpanded;
|
|
234
|
+
};
|
|
235
|
+
const useExpandedResourceCategories = (categoryKeys, defaultExpandedCategoryKeys, defaultExpandedSignature) => {
|
|
236
|
+
const previousCategoryKeysRef = useRef(new Set(categoryKeys));
|
|
237
|
+
const previousDefaultExpandedSignatureRef = useRef(defaultExpandedSignature);
|
|
238
|
+
const [expandedCategories, setExpandedCategories] = useState(() => new Set(defaultExpandedCategoryKeys));
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
const previousCategoryKeys = previousCategoryKeysRef.current;
|
|
241
|
+
const nextCategoryKeys = new Set(categoryKeys);
|
|
242
|
+
const defaultExpandedChanged = previousDefaultExpandedSignatureRef.current !== defaultExpandedSignature;
|
|
243
|
+
setExpandedCategories((current) => {
|
|
244
|
+
if (defaultExpandedChanged) {
|
|
245
|
+
const nextExpanded = new Set(defaultExpandedCategoryKeys);
|
|
246
|
+
return areStringSetsEqual(current, nextExpanded) ? current : nextExpanded;
|
|
247
|
+
}
|
|
248
|
+
const nextExpanded = resolveNextExpandedCategories(current, categoryKeys, previousCategoryKeys, defaultExpandedCategoryKeys);
|
|
249
|
+
return areStringSetsEqual(current, nextExpanded) ? current : nextExpanded;
|
|
250
|
+
});
|
|
251
|
+
previousCategoryKeysRef.current = nextCategoryKeys;
|
|
252
|
+
previousDefaultExpandedSignatureRef.current = defaultExpandedSignature;
|
|
253
|
+
}, [categoryKeys, defaultExpandedCategoryKeys, defaultExpandedSignature]);
|
|
254
|
+
return [expandedCategories, setExpandedCategories];
|
|
255
|
+
};
|
|
256
|
+
const getResourceDisplayTitle = (componentName, resource) => (resource.title
|
|
257
|
+
|| resource.node?.children?.[0]?.getMessage('title')
|
|
258
|
+
|| componentName);
|
|
259
|
+
const renderComponentResources = (components, componentName) => {
|
|
260
|
+
const component = components?.[componentName];
|
|
261
|
+
if (!component?.Resource?.length)
|
|
262
|
+
return [];
|
|
263
|
+
return component.Resource.flatMap((resource, index) => {
|
|
264
|
+
const { node } = resource;
|
|
265
|
+
if (!node)
|
|
266
|
+
return [];
|
|
267
|
+
const displayTitle = getResourceDisplayTitle(componentName, resource);
|
|
268
|
+
const displayTitleText = getContentText(displayTitle, componentName);
|
|
269
|
+
return (_jsx(ResourceItemView, { componentName: componentName, displayTitle: displayTitle, displayTitleText: displayTitleText, icon: resource.icon, index: index, nodeId: node.id, thumb: resource.thumb }, `${componentName}-${index}`));
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
const getComponentResourceTexts = (components, resourceKeywords, componentName) => {
|
|
273
|
+
const component = components?.[componentName];
|
|
274
|
+
const keywords = [
|
|
275
|
+
...(DEFAULT_RESOURCE_KEYWORDS[componentName] ?? []),
|
|
276
|
+
...(resourceKeywords?.[componentName] ?? []),
|
|
277
|
+
];
|
|
278
|
+
if (!component?.Resource?.length)
|
|
279
|
+
return [componentName, ...keywords];
|
|
280
|
+
return component.Resource.map((resource) => {
|
|
281
|
+
const displayTitle = getResourceDisplayTitle(componentName, resource);
|
|
282
|
+
return `${componentName} ${getContentText(displayTitle, componentName)} ${keywords.join(' ')}`;
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
const isComponentMatched = (components, resourceKeywords, normalizedKeyword, componentName) => {
|
|
286
|
+
if (!normalizedKeyword)
|
|
287
|
+
return true;
|
|
288
|
+
return getComponentResourceTexts(components, resourceKeywords, componentName)
|
|
289
|
+
.some(text => normalizeSearchText(text).includes(normalizedKeyword));
|
|
290
|
+
};
|
|
291
|
+
const isCategoryMatched = (category, normalizedKeyword) => (normalizedKeyword
|
|
292
|
+
? normalizeSearchText(getContentText(category.title, category.key)).includes(normalizedKeyword)
|
|
293
|
+
: true);
|
|
294
|
+
const getMatchedCategoryComponentNames = (category, components, resourceKeywords, normalizedKeyword) => {
|
|
295
|
+
const categoryMatched = isCategoryMatched(category, normalizedKeyword);
|
|
296
|
+
return category.components
|
|
297
|
+
.filter(name => components?.[name])
|
|
298
|
+
.filter(name => categoryMatched || isComponentMatched(components, resourceKeywords, normalizedKeyword, name));
|
|
299
|
+
};
|
|
300
|
+
const renderCategoryIcon = (category) => {
|
|
301
|
+
if (!category.icon)
|
|
302
|
+
return null;
|
|
303
|
+
if (React.isValidElement(category.icon)) {
|
|
304
|
+
return category.icon;
|
|
305
|
+
}
|
|
306
|
+
return _jsx(IconWidget, { infer: category.icon });
|
|
307
|
+
};
|
|
308
|
+
const renderCategory = (category, components, resourceKeywords, normalizedKeyword) => {
|
|
309
|
+
const categoryComponents = getMatchedCategoryComponentNames(category, components, resourceKeywords, normalizedKeyword).flatMap(componentName => renderComponentResources(components, componentName));
|
|
310
|
+
if (categoryComponents.length === 0)
|
|
311
|
+
return null;
|
|
312
|
+
const categoryTitleText = getContentText(category.title, category.key);
|
|
313
|
+
return {
|
|
314
|
+
forceRender: true,
|
|
315
|
+
key: category.key,
|
|
316
|
+
label: (_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 }, children: [renderCategoryIcon(category), _jsx("span", { style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis' }, children: renderResourceText(category.title, categoryTitleText) }), _jsx("span", { "aria-hidden": "true", "data-resource-category-count": category.key, style: {
|
|
317
|
+
background: '#f3f6fa',
|
|
318
|
+
border: '1px solid #e7edf5',
|
|
319
|
+
borderRadius: 999,
|
|
320
|
+
color: '#8a96a8',
|
|
321
|
+
flex: '0 0 auto',
|
|
322
|
+
fontSize: 10,
|
|
323
|
+
fontWeight: 600,
|
|
324
|
+
lineHeight: '15px',
|
|
325
|
+
minWidth: 18,
|
|
326
|
+
padding: '0 5px',
|
|
327
|
+
textAlign: 'center',
|
|
328
|
+
}, title: `${categoryTitleText} 匹配资源数:${categoryComponents.length}`, children: categoryComponents.length })] })),
|
|
329
|
+
children: (_jsx("div", { role: "list", style: {
|
|
330
|
+
display: 'grid',
|
|
331
|
+
gap: 4,
|
|
332
|
+
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
|
|
333
|
+
padding: '0 0 2px',
|
|
334
|
+
}, children: categoryComponents })),
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
const getMatchedResourceCount = (categories, components, resourceKeywords, normalizedKeyword) => (categories.reduce((count, category) => (count + getMatchedCategoryComponentNames(category, components, resourceKeywords, normalizedKeyword).reduce((componentCount, name) => (componentCount + getComponentResourceCount(components, name)), 0)), 0));
|
|
338
|
+
const getActiveCategoryKeys = (normalizedKeyword, collapseItems, expandedCategories) => (normalizedKeyword
|
|
339
|
+
? collapseItems?.map(item => String(item?.key)).filter(Boolean) ?? []
|
|
340
|
+
: Array.from(expandedCategories));
|
|
341
|
+
export const ResourceWidget = observer((props) => {
|
|
342
|
+
const context = useMaybePlaygroundContext();
|
|
343
|
+
const rootRef = useRef(null);
|
|
344
|
+
const prefix = usePrefix('resource-panel');
|
|
345
|
+
useResourceWidgetStyles(prefix);
|
|
346
|
+
const contextCategories = context?.categories;
|
|
347
|
+
const categories = useMemo(() => props.categories ?? contextCategories ?? [], [contextCategories, props.categories]);
|
|
348
|
+
const components = props.components ?? context?.components ?? {};
|
|
349
|
+
const categoryKeys = useMemo(() => categories.map(cat => cat.key), [categories]);
|
|
350
|
+
const defaultExpandedCategoryKeys = useMemo(() => getDefaultExpandedCategoryKeys(categories, props.defaultExpandedCategoryKeys), [categories, props.defaultExpandedCategoryKeys]);
|
|
351
|
+
const defaultExpandedSignature = getDefaultExpandedSignature(props.defaultExpandedCategoryKeys);
|
|
352
|
+
const [expandedCategories, setExpandedCategories] = useExpandedResourceCategories(categoryKeys, defaultExpandedCategoryKeys, defaultExpandedSignature);
|
|
353
|
+
const [keyword, setKeyword] = useState('');
|
|
354
|
+
const searchable = props.searchable !== false;
|
|
355
|
+
const normalizedKeyword = normalizeSearchText(keyword.trim());
|
|
356
|
+
const renderSearch = () => {
|
|
357
|
+
if (!searchable)
|
|
358
|
+
return null;
|
|
359
|
+
return (_jsxs("div", { style: {
|
|
360
|
+
height: 28,
|
|
361
|
+
marginBottom: 5,
|
|
362
|
+
position: 'relative',
|
|
363
|
+
width: '100%',
|
|
364
|
+
}, children: [_jsx("input", { "aria-label": "\u641C\u7D22\u7EC4\u4EF6", placeholder: props.searchPlaceholder ?? '搜索组件 / 中文名', style: {
|
|
365
|
+
background: '#f7faff',
|
|
366
|
+
border: '1px solid #d9e4f2',
|
|
367
|
+
borderRadius: 8,
|
|
368
|
+
boxSizing: 'border-box',
|
|
369
|
+
color: '#253040',
|
|
370
|
+
fontSize: 12,
|
|
371
|
+
height: '100%',
|
|
372
|
+
outline: 'none',
|
|
373
|
+
padding: normalizedKeyword ? '0 29px 0 10px' : '0 10px',
|
|
374
|
+
width: '100%',
|
|
375
|
+
}, type: "search", value: keyword, onChange: event => setKeyword(event.currentTarget.value), onKeyDown: (event) => {
|
|
376
|
+
if (event.key !== 'Escape' || !keyword)
|
|
377
|
+
return;
|
|
378
|
+
event.preventDefault();
|
|
379
|
+
setKeyword('');
|
|
380
|
+
} }), normalizedKeyword ? (_jsx("button", { "aria-label": "\u6E05\u7A7A\u641C\u7D22\u5173\u952E\u8BCD", style: {
|
|
381
|
+
alignItems: 'center',
|
|
382
|
+
background: '#fff',
|
|
383
|
+
border: '1px solid #d9e4f2',
|
|
384
|
+
borderRadius: 999,
|
|
385
|
+
color: '#7b8797',
|
|
386
|
+
cursor: 'pointer',
|
|
387
|
+
display: 'inline-flex',
|
|
388
|
+
fontSize: 12,
|
|
389
|
+
height: 20,
|
|
390
|
+
justifyContent: 'center',
|
|
391
|
+
lineHeight: 1,
|
|
392
|
+
padding: 0,
|
|
393
|
+
position: 'absolute',
|
|
394
|
+
right: 5,
|
|
395
|
+
top: 4,
|
|
396
|
+
width: 20,
|
|
397
|
+
}, type: "button", onClick: () => setKeyword(''), children: "\u00D7" })) : null] }));
|
|
398
|
+
};
|
|
399
|
+
const renderEmpty = () => (_jsxs("div", { style: {
|
|
400
|
+
alignItems: 'center',
|
|
401
|
+
color: '#8a96a8',
|
|
402
|
+
display: 'flex',
|
|
403
|
+
flexDirection: 'column',
|
|
404
|
+
fontSize: 12,
|
|
405
|
+
gap: 8,
|
|
406
|
+
padding: '28px 8px',
|
|
407
|
+
textAlign: 'center',
|
|
408
|
+
}, children: [_jsx("span", { children: normalizedKeyword ? `未找到“${keyword.trim()}”相关组件` : '暂无组件' }), normalizedKeyword ? (_jsx("button", { style: {
|
|
409
|
+
background: '#fff',
|
|
410
|
+
border: '1px solid #d9e4f2',
|
|
411
|
+
borderRadius: 999,
|
|
412
|
+
color: '#1677ff',
|
|
413
|
+
cursor: 'pointer',
|
|
414
|
+
fontSize: 12,
|
|
415
|
+
height: 24,
|
|
416
|
+
padding: '0 10px',
|
|
417
|
+
}, type: "button", onClick: () => setKeyword(''), children: "\u6E05\u7A7A\u641C\u7D22" })) : null] }));
|
|
418
|
+
const renderSearchSummary = (resourceCount) => {
|
|
419
|
+
if (!searchable || !normalizedKeyword)
|
|
420
|
+
return null;
|
|
421
|
+
return (_jsxs("div", { "aria-live": "polite", role: "status", style: {
|
|
422
|
+
alignItems: 'center',
|
|
423
|
+
color: '#7b8797',
|
|
424
|
+
display: 'flex',
|
|
425
|
+
fontSize: 11,
|
|
426
|
+
justifyContent: 'space-between',
|
|
427
|
+
lineHeight: '16px',
|
|
428
|
+
margin: '-2px 0 5px',
|
|
429
|
+
minHeight: 16,
|
|
430
|
+
padding: '0 1px',
|
|
431
|
+
}, children: [_jsx("span", { children: resourceCount > 0 ? `匹配 ${resourceCount} 个资源` : '未找到匹配资源' }), resourceCount > 0 ? (_jsx("span", { style: { color: '#1677ff', fontWeight: 600 }, children: "\u53EF\u62D6\u62FD\u6DFB\u52A0" })) : null] }));
|
|
432
|
+
};
|
|
433
|
+
useEffect(() => {
|
|
434
|
+
if (!normalizedKeyword)
|
|
435
|
+
return;
|
|
436
|
+
const firstMatchedResource = rootRef.current
|
|
437
|
+
?.querySelector('[data-designer-source-id]');
|
|
438
|
+
if (typeof firstMatchedResource?.scrollIntoView !== 'function')
|
|
439
|
+
return;
|
|
440
|
+
firstMatchedResource.scrollIntoView({ block: 'nearest' });
|
|
441
|
+
}, [categoryKeys.length, normalizedKeyword]);
|
|
442
|
+
if (categories.length === 0) {
|
|
443
|
+
const allComponents = Object.keys(components)
|
|
444
|
+
.filter(name => isComponentMatched(components, props.resourceKeywords, normalizedKeyword, name))
|
|
445
|
+
.flatMap(name => renderComponentResources(components, name));
|
|
446
|
+
return (_jsxs("div", { ref: rootRef, className: [prefix, props.className].filter(Boolean).join(' '), "data-resource-panel": "true", style: {
|
|
447
|
+
display: 'flex',
|
|
448
|
+
flexDirection: 'column',
|
|
449
|
+
height: '100%',
|
|
450
|
+
minHeight: 0,
|
|
451
|
+
...props.style,
|
|
452
|
+
}, children: [renderSearch(), renderSearchSummary(allComponents.length), _jsx("div", { "data-resource-list": "true", style: {
|
|
453
|
+
flex: 1,
|
|
454
|
+
minHeight: 0,
|
|
455
|
+
overflowX: 'hidden',
|
|
456
|
+
overflowY: 'auto',
|
|
457
|
+
overscrollBehavior: 'contain',
|
|
458
|
+
paddingRight: 2,
|
|
459
|
+
scrollbarGutter: 'stable',
|
|
460
|
+
}, children: allComponents.length > 0 ? (_jsx("div", { role: "list", style: {
|
|
461
|
+
display: 'grid',
|
|
462
|
+
gap: 4,
|
|
463
|
+
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
|
|
464
|
+
}, children: allComponents })) : renderEmpty() })] }));
|
|
465
|
+
}
|
|
466
|
+
const collapseItems = categories
|
|
467
|
+
.map(category => renderCategory(category, components, props.resourceKeywords, normalizedKeyword))
|
|
468
|
+
.filter(Boolean);
|
|
469
|
+
const matchedResourceCount = getMatchedResourceCount(categories, components, props.resourceKeywords, normalizedKeyword);
|
|
470
|
+
const activeCategoryKeys = getActiveCategoryKeys(normalizedKeyword, collapseItems, expandedCategories);
|
|
471
|
+
return (_jsxs("div", { ref: rootRef, className: [prefix, props.className].filter(Boolean).join(' '), "data-resource-panel": "true", style: {
|
|
472
|
+
display: 'flex',
|
|
473
|
+
flexDirection: 'column',
|
|
474
|
+
height: '100%',
|
|
475
|
+
minHeight: 0,
|
|
476
|
+
...props.style,
|
|
477
|
+
}, children: [renderSearch(), renderSearchSummary(matchedResourceCount), _jsx("div", { "data-resource-list": "true", style: {
|
|
478
|
+
flex: 1,
|
|
479
|
+
minHeight: 0,
|
|
480
|
+
overflowX: 'hidden',
|
|
481
|
+
overflowY: 'auto',
|
|
482
|
+
overscrollBehavior: 'contain',
|
|
483
|
+
paddingRight: 2,
|
|
484
|
+
scrollbarGutter: 'stable',
|
|
485
|
+
}, children: collapseItems?.length ? (_jsx(Collapse, { ghost: true, activeKey: activeCategoryKeys, items: collapseItems, size: "small", onChange: (keys) => {
|
|
486
|
+
if (normalizedKeyword)
|
|
487
|
+
return;
|
|
488
|
+
setExpandedCategories(new Set(normalizeActiveKeys(keys)));
|
|
489
|
+
} })) : renderEmpty() })] }));
|
|
490
|
+
});
|
|
491
|
+
ResourceWidget.displayName = 'ResourceWidget';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ISchemaCodeViewProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
3
|
+
'data-testid'?: string;
|
|
4
|
+
fileName?: string;
|
|
5
|
+
getSchema: () => unknown;
|
|
6
|
+
}
|
|
7
|
+
export declare const SchemaCodeView: React.FC<ISchemaCodeViewProps>;
|