@smartos-lib/components 1.7.0-beta.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.
Files changed (128) hide show
  1. package/.eslintrc +12 -0
  2. package/.eslintrc-auto-import.json +332 -0
  3. package/Components.code-workspace +143 -0
  4. package/LICENSE +21 -0
  5. package/dist/smart-docx-editor/index.d.ts +2 -0
  6. package/dist/smart-docx-editor/index.js +68 -0
  7. package/dist/smart-file-preview/index.d.ts +18 -0
  8. package/dist/smart-file-preview/index.js +37 -0
  9. package/dist/smart-upload/index.d.ts +2 -0
  10. package/dist/smart-upload/index.js +800 -0
  11. package/index.html +16 -0
  12. package/package.json +23 -0
  13. package/public/favicon.svg +6 -0
  14. package/scripts/components.vite.config.ts +96 -0
  15. package/scripts/shared.ts +9 -0
  16. package/src/App.vue +28 -0
  17. package/src/components/Logo/index.vue +15 -0
  18. package/src/components-private/.gitkeep +0 -0
  19. package/src/composables/useElementStyle.ts +23 -0
  20. package/src/composables/useNaiveStyle.ts +43 -0
  21. package/src/composables/useNaiveTheme.ts +71 -0
  22. package/src/composables/useSmart.ts +36 -0
  23. package/src/layouts/default.vue +3 -0
  24. package/src/main.ts +33 -0
  25. package/src/modules/pinia/index.ts +8 -0
  26. package/src/modules/progress/index.ts +12 -0
  27. package/src/modules/router/install.ts +9 -0
  28. package/src/modules/router/routes.ts +40 -0
  29. package/src/pages/[...all].vue +21 -0
  30. package/src/pages/frame/component/[name].vue +14 -0
  31. package/src/pages/frame/index.vue +81 -0
  32. package/src/pages/index/composables/useTabsManage.ts +46 -0
  33. package/src/pages/index/index.vue +111 -0
  34. package/src/pages/index/type.ts +13 -0
  35. package/src/pages/index/utils/index.ts +41 -0
  36. package/src/settings.ts +9 -0
  37. package/src/shared/components.ts +52 -0
  38. package/src/shared/env.ts +11 -0
  39. package/src/shared/unocss.theme.ts +1600 -0
  40. package/src/stores/theme.ts +29 -0
  41. package/src/styles/element.scss +3 -0
  42. package/src/styles/styles.scss +21 -0
  43. package/src/types.ts +20 -0
  44. package/src/utils/callCustomElementExposed.ts +6 -0
  45. package/src/utils/deepCloneESModule.ts +10 -0
  46. package/src/utils/defineCustomElements.ts +18 -0
  47. package/src/utils/formatComponentsGlob.ts +16 -0
  48. package/src/utils/getFileMD5.ts +31 -0
  49. package/src/utils/getFileNameAndExt.ts +11 -0
  50. package/src/utils/isFileEqual.ts +13 -0
  51. package/src/utils/jsonToFormData.ts +8 -0
  52. package/src/web-components/smart-docx-drive-page/App.vue +37 -0
  53. package/src/web-components/smart-docx-drive-page/apis/doc.ts +85 -0
  54. package/src/web-components/smart-docx-drive-page/apis/file.ts +278 -0
  55. package/src/web-components/smart-docx-drive-page/apis/folder.ts +72 -0
  56. package/src/web-components/smart-docx-drive-page/children/Home.vue +8 -0
  57. package/src/web-components/smart-docx-drive-page/children/Me.vue +47 -0
  58. package/src/web-components/smart-docx-drive-page/components/CustomImage.vue +26 -0
  59. package/src/web-components/smart-docx-drive-page/components/CustomPopover.vue +62 -0
  60. package/src/web-components/smart-docx-drive-page/components/DocxDir.vue +99 -0
  61. package/src/web-components/smart-docx-drive-page/components/DocxDoc.vue +132 -0
  62. package/src/web-components/smart-docx-drive-page/components/DocxDownloadPopoverItem.vue +41 -0
  63. package/src/web-components/smart-docx-drive-page/components/DocxFileList.vue +156 -0
  64. package/src/web-components/smart-docx-drive-page/components/DocxPreview.vue +33 -0
  65. package/src/web-components/smart-docx-drive-page/components/DocxUpload.vue +164 -0
  66. package/src/web-components/smart-docx-drive-page/components/FileIcon.vue +62 -0
  67. package/src/web-components/smart-docx-drive-page/components-private/Header.vue +65 -0
  68. package/src/web-components/smart-docx-drive-page/components-private/Logo.vue +15 -0
  69. package/src/web-components/smart-docx-drive-page/components-private/Menu.vue +34 -0
  70. package/src/web-components/smart-docx-drive-page/components-private/Navbar.vue +36 -0
  71. package/src/web-components/smart-docx-drive-page/composables/useFullscreenElDialog.ts +41 -0
  72. package/src/web-components/smart-docx-drive-page/composables/usePrompt.ts +73 -0
  73. package/src/web-components/smart-docx-drive-page/data.ts +10 -0
  74. package/src/web-components/smart-docx-drive-page/external-style/custom-popover.sass +8 -0
  75. package/src/web-components/smart-docx-drive-page/external-style/index.sass +1 -0
  76. package/src/web-components/smart-docx-drive-page/index.ts +20 -0
  77. package/src/web-components/smart-docx-drive-page/index.vue +39 -0
  78. package/src/web-components/smart-docx-drive-page/info.ts +2 -0
  79. package/src/web-components/smart-docx-drive-page/stores/menu.ts +60 -0
  80. package/src/web-components/smart-docx-drive-page/types.ts +51 -0
  81. package/src/web-components/smart-docx-drive-page/utils/file-actions.ts +63 -0
  82. package/src/web-components/smart-docx-drive-page/utils/file.ts +31 -0
  83. package/src/web-components/smart-docx-editor/App.vue +32 -0
  84. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components/Markdown.vue +202 -0
  85. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components/Menu.vue +100 -0
  86. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components/types.ts +6 -0
  87. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components-react/Markdown.tsx +71 -0
  88. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components-react/MarkdownElement.tsx +81 -0
  89. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components-react/elements/Blockquote/index.sass +6 -0
  90. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components-react/elements/Blockquote/index.tsx +12 -0
  91. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components-react/elements/Heading/index.sass +14 -0
  92. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components-react/elements/Heading/index.tsx +17 -0
  93. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components-react/elements/List/index.scss +16 -0
  94. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components-react/elements/List/index.tsx +39 -0
  95. package/src/web-components/smart-docx-editor/MarkdownShortcuts/components-react/types/custom-types.d.ts +69 -0
  96. package/src/web-components/smart-docx-editor/MarkdownShortcuts/composables/useTextSelection.ts +50 -0
  97. package/src/web-components/smart-docx-editor/MarkdownShortcuts/index.sass +19 -0
  98. package/src/web-components/smart-docx-editor/MarkdownShortcuts/index.vue +21 -0
  99. package/src/web-components/smart-docx-editor/MarkdownShortcuts/shared/const.ts +23 -0
  100. package/src/web-components/smart-docx-editor/MarkdownShortcuts/utils/slateHelpers.ts +23 -0
  101. package/src/web-components/smart-docx-editor/data.ts +38 -0
  102. package/src/web-components/smart-docx-editor/demo.vue +11 -0
  103. package/src/web-components/smart-docx-editor/index.md +3 -0
  104. package/src/web-components/smart-docx-editor/index.ts +5 -0
  105. package/src/web-components/smart-docx-editor/index.vue +12 -0
  106. package/src/web-components/smart-docx-editor/info.ts +2 -0
  107. package/src/web-components/smart-file-preview/category/Code.vue +171 -0
  108. package/src/web-components/smart-file-preview/category/Image.vue +49 -0
  109. package/src/web-components/smart-file-preview/category/Pdf.vue +14 -0
  110. package/src/web-components/smart-file-preview/category/Video.vue +27 -0
  111. package/src/web-components/smart-file-preview/demo.vue +34 -0
  112. package/src/web-components/smart-file-preview/index.md +5 -0
  113. package/src/web-components/smart-file-preview/index.ts +29 -0
  114. package/src/web-components/smart-file-preview/index.vue +56 -0
  115. package/src/web-components/smart-file-preview/info.ts +2 -0
  116. package/src/web-components/smart-file-preview/shared/const.ts +4 -0
  117. package/src/web-components/smart-file-preview/types.ts +38 -0
  118. package/src/web-components/smart-upload/index.ts +5 -0
  119. package/src/web-components/smart-upload/index.vue +101 -0
  120. package/src/web-components/smart-upload/info.ts +2 -0
  121. package/src/web-components/smart-upload/types.ts +28 -0
  122. package/tsconfig.json +15 -0
  123. package/types/auto-imports.d.ts +975 -0
  124. package/types/components.d.ts +14 -0
  125. package/types/env.d.ts +8 -0
  126. package/types/shims.d.ts +6 -0
  127. package/unocss.config.ts +23 -0
  128. package/vite.config.ts +60 -0
@@ -0,0 +1,111 @@
1
+ <template>
2
+ <div class="size-screen p-3" un:grid="~ rows-[auto_1fr] gap-3">
3
+ <!-- 操作区 -->
4
+ <n-space justify="space-between" item-style="position: relative">
5
+ <!-- 左侧组件相关功能 -->
6
+ <n-space>
7
+ <n-select
8
+ v-model:value="componentsSelectValue"
9
+ class="!w-72"
10
+ :options="componentsOptions" :render-label="renderOptionLabel" :consistent-menu-width="false"
11
+ placeholder="请选择组件" clearable
12
+ />
13
+ <n-button type="primary" :disabled="!componentsSelectValue" @click="createTab(componentsSelectValue)">新增</n-button>
14
+ <template v-if="componentsSelectValue">
15
+ <router-link class="no-underline!" :to="{ name: 'Frame/Component', params: { name: componentsSelectValue } }" target="_blank">
16
+ <n-button type="primary">新窗口打开</n-button>
17
+ </router-link>
18
+ </template>
19
+ </n-space>
20
+ <!-- 右侧项目相关信息 -->
21
+ <n-space class="absolute -top-1 -right-1 <xs:hidden!" :wrap="false">
22
+ <Logo />
23
+ <div class="h-full flex-(~ col items-center justify-around) [&>*]-(text-lg op-60 transition-all duration-300) [&>*:hover]-(text-primary op-100)">
24
+ <!-- 切换深色模式 -->
25
+ <button title="切换暗色模式" @click="theme.toggle()">
26
+ <i-mdi-theme-light-dark v-if="theme.value === 'auto'" />
27
+ <i-ph-moon v-else-if="theme.value === 'dark'" />
28
+ <i-ic-outline-wb-sunny v-else />
29
+ </button>
30
+ <!-- 跳转到 Github -->
31
+ <button>
32
+ <a class="c-inherit!" href="https://github.com/MoomFE-Starter-Template/Web-Components-Editor" target="_blank" rel="noopener noreferrer">
33
+ <i-mdi-github />
34
+ </a>
35
+ </button>
36
+ </div>
37
+ </n-space>
38
+ </n-space>
39
+
40
+ <!-- 组件展示区 -->
41
+ <div ref="tabsWrapRef" class="size-full overflow-hidden">
42
+ <n-tabs
43
+ v-model:value="activeTabId"
44
+ :class="{ 'hidden-tabs-pad-border': tabs.length }"
45
+ type="card" closable animated
46
+ @close="closeTab"
47
+ >
48
+ <!-- 所有的组件预览区 -->
49
+ <template v-if="tabs.length">
50
+ <template v-for="tab in tabs" :key="tab.id!">
51
+ <n-tab-pane class="tab-pane-shadow !p-3" :name="tab.id!" :tab="renderTabTitle(tab.component)" :style="{ height: tabPaneHeight }" display-directive="show:lazy">
52
+ <iframe class="size-full" src="/frame" :name="tab.id!" frameborder="0" />
53
+ </n-tab-pane>
54
+ </template>
55
+ </template>
56
+ <!-- 无组件预览时 -->
57
+ <n-tab-pane v-else name="noop" tab="无组件预览" :closable="false" disabled />
58
+ <!-- 组件测试数据选择 -->
59
+ <template v-if="activeTabData" #suffix>
60
+ <!-- 使用函数返回测试数据时, 重新运行函数生成测试数据 -->
61
+ <n-tooltip v-if="activeTab!.data && isFunction(activeTabData[activeTab!.data])">
62
+ <template #trigger>
63
+ <i class="cursor-pointer mr-2" un:i-mdi-reload @click="dataReload" />
64
+ </template>
65
+ <div un:text="sm">当前测试数据由函数返回, 点击重新运行函数生成测试数据</div>
66
+ </n-tooltip>
67
+ <!-- 组件测试数据选择下拉框 -->
68
+ <n-select v-model:value="activeTab!.data" class="!w-36" size="small" placeholder="选择测试数据" :options="genTabDataOptions(activeTabData)" clearable />
69
+ </template>
70
+ </n-tabs>
71
+ </div>
72
+ </div>
73
+ </template>
74
+
75
+ <script lang="ts" setup>
76
+ import { isFunction } from 'mixte';
77
+ import { useTabsManage } from './composables/useTabsManage';
78
+ import { genTabDataOptions, renderOptionLabel, renderTabTitle, useTabPaneHeight } from './utils';
79
+ import { componentsOptions } from '@/shared/components';
80
+
81
+ const theme = useThemeStore();
82
+
83
+ /** 选项卡容器 */
84
+ const tabsWrapRef = ref<HTMLElement>();
85
+
86
+ /** 选项卡管理 */
87
+ const { activeTab, activeTabId, activeTabData, tabs, createTab, closeTab } = useTabsManage();
88
+ /** 选项卡面板的高度 */
89
+ const tabPaneHeight = useTabPaneHeight(tabsWrapRef);
90
+
91
+ /** 操作区选中的组件列表 */
92
+ const componentsSelectValue = ref();
93
+
94
+ /** 重载数据 */
95
+ function dataReload() {
96
+ activeTab.value!.dataReloadCount = (activeTab.value!.dataReloadCount ?? 0) + 1;
97
+ }
98
+ </script>
99
+
100
+ <route lang="yaml">
101
+ name: Index
102
+ </route>
103
+
104
+ <style lang="scss" scoped>
105
+ .hidden-tabs-pad-border :deep(.n-tabs-pad){
106
+ border-bottom: 0 !important;
107
+ }
108
+ .tab-pane-shadow{
109
+ box-shadow: inset 0px 0px 4px 0px rgba(0,0,0,0.2);
110
+ }
111
+ </style>
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 单个选项卡存储的信息
3
+ */
4
+ export interface Tab {
5
+ /** ID */
6
+ id?: string
7
+ /** 选项卡内的组件 */
8
+ component: string
9
+ /** 当前选中的测试数据 */
10
+ data?: string
11
+ /** 重载数据使用 */
12
+ dataReloadCount?: number
13
+ }
@@ -0,0 +1,41 @@
1
+ import { type Ref, type VNodeChild } from 'vue';
2
+ import { type SelectOption } from 'naive-ui';
3
+ import { components } from '@/shared/components';
4
+
5
+ // @unocss-include
6
+
7
+ /** 渲染下拉框 Label */
8
+ export function renderOptionLabel(option: SelectOption): VNodeChild {
9
+ return [
10
+ h('span', { class: 'text-sm' }, option.label as string),
11
+ h('span', { class: 'text-xs color-gray-400 ml-1' }, `( ${option.value} )`),
12
+ ];
13
+ }
14
+
15
+ /**
16
+ * 渲染选项卡名称
17
+ * @param component 选项卡内的组件
18
+ */
19
+ export function renderTabTitle(component: string) {
20
+ return () => renderOptionLabel({ label: components[component]?.info.name, value: component });
21
+ }
22
+
23
+ /** 选项卡面板的高度 */
24
+ export function useTabPaneHeight(tabsWrapRef: Ref<HTMLElement | undefined>) {
25
+ /** 选项卡导航 */
26
+ const tabNav = computed(() => tabsWrapRef.value?.querySelector('.n-tabs-nav'));
27
+
28
+ /** 选项卡容器高度 */
29
+ const tabsWrapHeight = useElementSize(tabsWrapRef).height;
30
+ /** 选项卡导航高度 */ // @ts-expect-error xxx
31
+ const tabNavHeight = useElementSize(tabNav).height;
32
+
33
+ return computed(() => {
34
+ return `${tabsWrapHeight.value - tabNavHeight.value}px`;
35
+ });
36
+ }
37
+
38
+ /** 生成测试数据下拉框选项 */
39
+ export function genTabDataOptions(data: any) {
40
+ return Object.keys(data).map(key => ({ label: key, value: key }));
41
+ }
@@ -0,0 +1,9 @@
1
+ import type { Settings } from '@/types';
2
+
3
+ /**
4
+ * 项目配置
5
+ */
6
+ export const settings: Settings = {
7
+ /** 项目名称 */
8
+ name: 'Web Components Editor',
9
+ };
@@ -0,0 +1,52 @@
1
+ import { formatComponentsGlob } from '@/utils/formatComponentsGlob';
2
+ import { deepCloneESModule } from '@/utils/deepCloneESModule';
3
+
4
+ /** 组件注册文件引用 */
5
+ type ComponentsIndex = () => Promise<any>;
6
+
7
+ /** 组件信息 */
8
+ interface ComponentsInfo {
9
+ /** 组件名称 */
10
+ name: string
11
+ /** 组件标签名 */
12
+ tag: string
13
+ }
14
+
15
+ type Components = Record<string, {
16
+ /** 组件信息 */
17
+ info: ComponentsInfo
18
+ /** 组件注册文件引用 */
19
+ index: ComponentsIndex
20
+ /** 组件测试数据 */
21
+ data: any
22
+ }>;
23
+
24
+ /** 所有组件注册文件引用 */
25
+ const componentsIndex: Record<string, ComponentsIndex> = formatComponentsGlob(import.meta.glob('@/web-components/*/index.(ts|tsx)'));
26
+ /** 所有组件信息文件 */
27
+ const componentsInfo: Record<string, ComponentsInfo> = formatComponentsGlob(import.meta.glob('@/web-components/*/info.ts', { eager: true }));
28
+ /** 所有组件的测试数据 */
29
+ const componentsData: Record<string, any> = formatComponentsGlob(import.meta.glob('@/web-components/*/data.ts', { eager: true }));
30
+
31
+ /** 所有组件相关信息 */
32
+ export const components: Components = {};
33
+
34
+ // 保存所有的组件相关信息
35
+ Object.entries(componentsInfo).forEach(([name, info]) => {
36
+ // index.ts 和 info.ts 必须同时存在, 才承认这是个组件
37
+ if (!componentsIndex[name]) return;
38
+
39
+ components[info.tag] = {
40
+ info: deepCloneESModule(info),
41
+ index: componentsIndex[name],
42
+ data: deepCloneESModule(componentsData[name]),
43
+ };
44
+ });
45
+
46
+ /** 所有组件相关信息 - 下拉框选项 */
47
+ export const componentsOptions = Object.values(components).map(({ info }) => {
48
+ return {
49
+ label: info.name,
50
+ value: info.tag,
51
+ };
52
+ });
@@ -0,0 +1,11 @@
1
+ import type { LoadingBarProviderInst } from 'naive-ui';
2
+
3
+ interface App {
4
+ /** 当前应用的加载条模块 */
5
+ loadingBar?: LoadingBarProviderInst
6
+ }
7
+
8
+ /** 当前应用的一些环境变量 */
9
+ export const app: App = {
10
+
11
+ };