@coffic/cosy-ui 0.9.39 → 0.9.41

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 (38) hide show
  1. package/dist/app.css +1 -1
  2. package/dist/index-astro.ts +20 -13
  3. package/dist/src-astro/api-test/ApiEndpointCard.astro +254 -0
  4. package/dist/src-astro/api-test/ApiTestScript.astro +357 -0
  5. package/dist/src-astro/api-test/ApiTester.astro +111 -0
  6. package/dist/src-astro/api-test/index.ts +5 -0
  7. package/dist/src-astro/api-test/index_astro.ts +5 -0
  8. package/dist/src-astro/avatar/Avatar.astro +118 -0
  9. package/dist/src-astro/avatar/index.ts +2 -0
  10. package/dist/src-astro/avatar/types.ts +29 -0
  11. package/dist/src-astro/contact/Contact.astro +155 -172
  12. package/dist/src-astro/container/Container.astro +16 -0
  13. package/dist/src-astro/features/FeatureCard.astro +63 -0
  14. package/dist/src-astro/features/FeatureShowcase.astro +164 -0
  15. package/dist/src-astro/features/index.ts +3 -0
  16. package/dist/src-astro/heading/Heading.astro +56 -8
  17. package/dist/src-astro/icons/AppStoreIcon.astro +1 -1
  18. package/dist/src-astro/layout-app/AppLayout.astro +3 -1
  19. package/dist/src-astro/mac-window/MacWindow.astro +11 -6
  20. package/dist/src-astro/picture-book/PictureBookPage.astro +6 -3
  21. package/dist/src-astro/products/ProductShowcase.astro +159 -0
  22. package/dist/src-astro/products/ProductShowcaseItem.astro +216 -0
  23. package/dist/src-astro/products/index.ts +4 -0
  24. package/dist/src-astro/review/Review.astro +159 -0
  25. package/dist/src-astro/review/Reviews.astro +162 -0
  26. package/dist/src-astro/review/index.ts +3 -0
  27. package/dist/src-astro/review/types.ts +127 -0
  28. package/dist/src-astro/stats-display/StatsDisplay.astro +201 -0
  29. package/dist/src-astro/stats-display/index.ts +10 -0
  30. package/dist/src-astro/stats-display/types.ts +79 -0
  31. package/dist/src-astro/text/Text.astro +4 -1
  32. package/dist/src-astro/types/api-test.ts +138 -0
  33. package/dist/src-vue/container/Container.vue +64 -62
  34. package/dist/src-vue/container/types.ts +3 -3
  35. package/dist/src-vue/heading/Heading.vue +64 -10
  36. package/dist/src-vue/heading/types.ts +9 -0
  37. package/dist/src-vue/mac-window/MacWindow.vue +164 -212
  38. package/package.json +1 -1
@@ -1,108 +1,3 @@
1
- <!--
2
- @component MacWindow
3
-
4
- @description
5
- MacWindow 组件模拟 macOS 风格的应用窗口,包含标题栏、工具栏按钮、标签页和状态栏。
6
- 适用于创建模拟桌面应用界面或代码编辑器等场景。
7
-
8
- @usage
9
- 基本用法:
10
- ```vue
11
- <MacWindow title="代码编辑器">
12
- <div>窗口内容</div>
13
- </MacWindow>
14
- ```
15
-
16
- 带背景色:
17
- ```vue
18
- <MacWindow title="代码编辑器" bgType="blue">
19
- <div>窗口内容</div>
20
- </MacWindow>
21
- ```
22
-
23
- 带标签页:
24
- ```vue
25
- <template>
26
- <MacWindow
27
- title="设置"
28
- :tabs="['通用', '外观', '高级']"
29
- defaultTab="外观"
30
- bgType="purple"
31
- :onTabClick="(tab) => {
32
- activeTab = tab;
33
- console.log('切换到标签:', tab);
34
- }"
35
- >
36
- <div v-if="activeTab === '通用'">通用设置内容</div>
37
- <div v-if="activeTab === '外观'">外观设置内容</div>
38
- <div v-if="activeTab === '高级'">高级设置内容</div>
39
- </MacWindow>
40
- </template>
41
-
42
- <script setup>
43
- import { ref } from 'vue';
44
- import { MacWindow } from 'cosy-ui';
45
-
46
- const activeTab = ref('外观');
47
- </script>
48
-
49
- 带自定义事件处理:
50
- ```vue
51
- <MacWindow
52
- title="文件浏览器"
53
- bgType="green"
54
- :onCloseWindow="() => handleClose()"
55
- :onTabClick="(tab) => handleTabChange(tab)"
56
- >
57
- <div>窗口内容</div>
58
- </MacWindow>
59
- ```
60
-
61
- 带工具栏和状态栏:
62
- ```vue
63
- <MacWindow title="文件浏览器" bgType="orange">
64
- <template #toolbar>
65
- <button class="cosy:btn cosy:btn-ghost cosy:btn-sm">
66
- <SearchIcon class="cosy:w-4 cosy:h-4" />
67
- </button>
68
- <button class="cosy:btn cosy:btn-ghost cosy:btn-sm">
69
- <SettingsIcon class="cosy:w-4 cosy:h-4" />
70
- </button>
71
- </template>
72
-
73
- <div>窗口内容</div>
74
-
75
- <template #status>
76
- <div class="cosy:text-xs">就绪</div>
77
- <button class="cosy:btn cosy:btn-ghost cosy:btn-xs">
78
- <InfoIcon class="cosy:w-4 cosy:h-4" />
79
- </button>
80
- </template>
81
- </MacWindow>
82
- ```
83
-
84
- @props
85
- @prop {String} [height='h-96'] - 窗口高度
86
- @prop {String} [title=''] - 窗口标题
87
- @prop {Boolean} [withShadow=true] - 是否显示阴影效果
88
- @prop {Array} [tabs=[]] - 标签页字符串数组,如 ['标签1', '标签2', '标签3']
89
- @prop {String} [defaultTab=''] - 默认选中的标签页
90
- @prop {String} [bgType='default'] - 背景色类型,可选值:default, light, dark, blue, green, purple, orange, red
91
- @prop {Function} [onCloseWindow=null] - 关闭窗口时调用的函数
92
- @prop {Function} [onMinimizeWindow=null] - 最小化窗口时调用的函数
93
- @prop {Function} [onMaximizeWindow=null] - 最大化窗口时调用的函数
94
- @prop {Function} [onTabClick=null] - 点击标签页时调用的函数,接收标签页值作为参数
95
-
96
- @slots
97
- @slot default - 窗口主要内容
98
- @slot sidebar - 侧边栏内容
99
- @slot toolbar - 工具栏内容,位于标题栏右侧
100
- @slot status - 状态栏内容,位于窗口底部
101
-
102
- @emits
103
- @emit {update:modelValue} - 切换标签页时触发,用于v-model
104
- -->
105
-
106
1
  <script setup lang="ts">
107
2
  import '../../style';
108
3
  import AlertDialog from '../alert-dialog/AlertDialog.vue';
@@ -112,34 +7,67 @@ import type { BackgroundColor } from '../container/backgrounds';
112
7
 
113
8
  /**
114
9
  * @component MacWindow
115
- * @description MacWindow 组件模拟 macOS 风格的应用窗口,包含标题栏、工具栏按钮、标签页和状态栏。
10
+ *
11
+ * @description
12
+ * MacWindow 组件模拟 macOS 风格的应用窗口,包含标题栏、工具栏按钮、标签页和状态栏。
116
13
  * 适用于创建模拟桌面应用界面或代码编辑器等场景。
14
+ *
15
+ * @usage
16
+ * 基本用法:<MacWindow title="代码编辑器"><div>窗口内容</div></MacWindow>
17
+ * 带背景色和宽度:<MacWindow title="代码编辑器" bgType="blue" width="lg"><div>窗口内容</div></MacWindow>
18
+ * 带标签页:支持 tabs 属性配置多个标签页,使用 defaultTab 设置默认标签
19
+ * 带自定义事件处理:支持 onCloseWindow、onMinimizeWindow、onMaximizeWindow、onTabClick 事件回调
20
+ * 带工具栏和状态栏:支持 toolbar 和 status 插槽
21
+ *
22
+ * @props
23
+ * @prop {String} [height='h-96'] - 窗口高度
24
+ * @prop {String} [width='md'] - 窗口宽度,支持值:xs、sm、md、lg、xl、full
25
+ * @prop {String} [title=''] - 窗口标题
26
+ * @prop {Boolean} [withShadow=true] - 是否显示阴影效果
27
+ * @prop {Array} [tabs=[]] - 标签页字符串数组,如 ['标签1', '标签2', '标签3']
28
+ * @prop {String} [defaultTab=''] - 默认选中的标签页
29
+ * @prop {String} [bgType='default'] - 背景色类型,可选值:default, light, dark, blue, green, purple, orange, red
30
+ * @prop {Function} [onCloseWindow=null] - 关闭窗口时调用的函数
31
+ * @prop {Function} [onMinimizeWindow=null] - 最小化窗口时调用的函数
32
+ * @prop {Function} [onMaximizeWindow=null] - 最大化窗口时调用的函数
33
+ * @prop {Function} [onTabClick=null] - 点击标签页时调用的函数,接收标签页值作为参数
34
+ *
35
+ * @slots
36
+ * @slot default - 窗口主要内容
37
+ * @slot sidebar - 侧边栏内容
38
+ * @slot toolbar - 工具栏内容,位于标题栏右侧
39
+ * @slot status - 状态栏内容,位于窗口底部
40
+ *
41
+ * @emits
42
+ * @emit {update:modelValue} - 切换标签页时触发,用于v-model
117
43
  */
118
44
 
119
45
  interface Props {
120
- height?: string;
121
- title?: string;
122
- withShadow?: boolean;
123
- tabs?: string[];
124
- defaultTab?: string;
125
- bgType?: BackgroundColor;
126
- onCloseWindow?: () => void;
127
- onMinimizeWindow?: () => void;
128
- onMaximizeWindow?: () => void;
129
- onTabClick?: (tab: string) => void;
46
+ height?: string;
47
+ width?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
48
+ title?: string;
49
+ withShadow?: boolean;
50
+ tabs?: string[];
51
+ defaultTab?: string;
52
+ bgType?: BackgroundColor;
53
+ onCloseWindow?: () => void;
54
+ onMinimizeWindow?: () => void;
55
+ onMaximizeWindow?: () => void;
56
+ onTabClick?: (tab: string) => void;
130
57
  }
131
58
 
132
59
  const props = withDefaults(defineProps<Props>(), {
133
- height: 'h-96',
134
- title: '',
135
- withShadow: true,
136
- tabs: () => [],
137
- defaultTab: '',
138
- bgType: 'base-100',
139
- onCloseWindow: undefined,
140
- onMinimizeWindow: undefined,
141
- onMaximizeWindow: undefined,
142
- onTabClick: undefined,
60
+ height: 'h-96',
61
+ width: 'md',
62
+ title: '',
63
+ withShadow: true,
64
+ tabs: () => [],
65
+ defaultTab: '',
66
+ bgType: 'base-100',
67
+ onCloseWindow: undefined,
68
+ onMinimizeWindow: undefined,
69
+ onMaximizeWindow: undefined,
70
+ onTabClick: undefined,
143
71
  });
144
72
 
145
73
  const showAlertDialog = ref(false);
@@ -148,122 +76,146 @@ const activeTab = ref(props.defaultTab);
148
76
 
149
77
  // 如果没有设置默认标签或默认标签不在tabs中,则选择第一个标签
150
78
  if (
151
- (!activeTab.value || !props.tabs.includes(activeTab.value)) &&
152
- props.tabs.length > 0
79
+ (!activeTab.value || !props.tabs.includes(activeTab.value)) &&
80
+ props.tabs.length > 0
153
81
  ) {
154
- activeTab.value = props.tabs[0];
82
+ activeTab.value = props.tabs[0];
155
83
  }
156
84
 
157
85
  // 计算窗口样式类
158
- const windowClasses = computed(() => [
159
- 'cosy:flex cosy:max-w-5xl cosy:mx-auto cosy:relative cosy:rounded-2xl cosy:overflow-hidden',
86
+ const windowClasses = computed(() =>
87
+ [
88
+ 'cosy:flex cosy:relative cosy:rounded-2xl cosy:overflow-hidden',
160
89
  props.height,
161
90
  props.withShadow ? 'cosy:shadow-lg' : '',
162
- ].filter(Boolean).join(' '));
91
+ ]
92
+ .filter(Boolean)
93
+ .join(' ')
94
+ );
163
95
 
164
96
  // 计算标题栏样式类
165
97
  const headerClasses = computed(() => [
166
- 'cosy:absolute cosy:top-0 cosy:left-0 cosy:right-0 cosy:flex cosy:items-center cosy:h-12 cosy:px-4 cosy:border-b cosy:border-base-300',
167
- props.bgType === 'base-100' || props.bgType === 'base-200' || props.bgType === 'base-300'
168
- ? 'cosy:bg-base-200'
169
- : 'cosy:bg-base-100/80',
98
+ 'cosy:absolute cosy:top-0 cosy:left-0 cosy:right-0 cosy:flex cosy:items-center cosy:h-12 cosy:px-4 cosy:border-b cosy:border-base-300',
99
+ props.bgType === 'base-100' ||
100
+ props.bgType === 'base-200' ||
101
+ props.bgType === 'base-300'
102
+ ? 'cosy:bg-base-200'
103
+ : 'cosy:bg-base-100/80',
170
104
  ]);
171
105
 
172
106
  // 计算状态栏样式类
173
107
  const statusBarClasses = computed(() => [
174
- 'cosy:h-6 cosy:border-t cosy:border-base-300 cosy:flex cosy:items-center cosy:justify-end cosy:px-4 cosy:text-sm',
175
- props.bgType === 'base-100' || props.bgType === 'base-200' || props.bgType === 'base-300'
176
- ? 'cosy:bg-base-200'
177
- : 'cosy:bg-base-100/80',
108
+ 'cosy:h-6 cosy:border-t cosy:border-base-300 cosy:flex cosy:items-center cosy:justify-end cosy:px-4 cosy:text-sm',
109
+ props.bgType === 'base-100' ||
110
+ props.bgType === 'base-200' ||
111
+ props.bgType === 'base-300'
112
+ ? 'cosy:bg-base-200'
113
+ : 'cosy:bg-base-100/80',
178
114
  ]);
179
115
 
180
116
  const handleCloseWindow = () => {
181
- alertMessage.value = '关闭APP窗口(这是演示,不会真实操作)';
182
- showAlertDialog.value = true;
183
- if (props.onCloseWindow) {
184
- props.onCloseWindow();
185
- }
117
+ alertMessage.value = '关闭APP窗口(这是演示,不会真实操作)';
118
+ showAlertDialog.value = true;
119
+ if (props.onCloseWindow) {
120
+ props.onCloseWindow();
121
+ }
186
122
  };
187
123
 
188
124
  const handleMinimizeWindow = () => {
189
- alertMessage.value = '最小化窗口(这是演示,不会真实操作)';
190
- showAlertDialog.value = true;
191
- if (props.onMinimizeWindow) {
192
- props.onMinimizeWindow();
193
- }
125
+ alertMessage.value = '最小化窗口(这是演示,不会真实操作)';
126
+ showAlertDialog.value = true;
127
+ if (props.onMinimizeWindow) {
128
+ props.onMinimizeWindow();
129
+ }
194
130
  };
195
131
 
196
132
  const handleMaximizeWindow = () => {
197
- alertMessage.value = '最大化窗口(这是演示,不会真实操作)';
198
- showAlertDialog.value = true;
199
- if (props.onMaximizeWindow) {
200
- props.onMaximizeWindow();
201
- }
133
+ alertMessage.value = '最大化窗口(这是演示,不会真实操作)';
134
+ showAlertDialog.value = true;
135
+ if (props.onMaximizeWindow) {
136
+ props.onMaximizeWindow();
137
+ }
202
138
  };
203
139
 
204
140
  const handleTabClick = (tab: string) => {
205
- activeTab.value = tab;
206
- if (props.onTabClick) {
207
- props.onTabClick(tab);
208
- }
141
+ activeTab.value = tab;
142
+ if (props.onTabClick) {
143
+ props.onTabClick(tab);
144
+ }
209
145
  };
210
146
  </script>
211
147
 
212
148
  <template>
213
- <Container :background="bgType" :class="windowClasses">
214
- <!-- 窗口控制按钮 -->
215
- <div :class="headerClasses">
216
- <div class="cosy:flex cosy:items-center cosy:space-x-2">
217
- <div class="cosy:w-3 cosy:h-3 cosy:rounded-full cosy:bg-error cosy:cursor-pointer hover:cosy:opacity-80 cosy:transition-opacity"
218
- @click="handleCloseWindow" />
219
- <div class="cosy:w-3 cosy:h-3 cosy:rounded-full cosy:bg-warning cosy:cursor-pointer hover:cosy:opacity-80 cosy:transition-opacity"
220
- @click="handleMinimizeWindow" />
221
- <div class="cosy:w-3 cosy:h-3 cosy:rounded-full cosy:bg-success cosy:cursor-pointer hover:cosy:opacity-80 cosy:transition-opacity"
222
- @click="handleMaximizeWindow" />
223
- </div>
224
- <div class="cosy:ml-6 cosy:text-sm cosy:font-medium cosy:text-base-content">
225
- {{ title }}
226
- </div>
227
-
228
- <!-- 标签选择器 -->
229
- <div v-if="tabs?.length" class="cosy:flex-1 cosy:flex cosy:justify-center">
230
- <div class="cosy:inline-flex cosy:rounded-lg cosy:bg-base-300 cosy:p-1">
231
- <button v-for="(tab, index) in tabs" :key="index" :class="[
232
- 'cosy:px-3 cosy:py-1 cosy:text-sm cosy:rounded-md cosy:transition-colors',
233
- activeTab === tab
234
- ? 'cosy:bg-base-100 cosy:text-base-content cosy:shadow'
235
- : 'cosy:text-base-content/70 hover:cosy:text-base-content',
236
- ]" @click="handleTabClick(tab)">
237
- {{ tab }}
238
- </button>
239
- </div>
240
- </div>
241
-
242
- <!-- 工具栏插槽 -->
243
- <div class="cosy:ml-auto cosy:flex cosy:items-center cosy:space-x-2">
244
- <slot name="toolbar"></slot>
245
- </div>
149
+ <Container :background="bgType" :width="width" :class="windowClasses">
150
+ <!-- 窗口控制按钮 -->
151
+ <div :class="headerClasses">
152
+ <div class="cosy:flex cosy:items-center cosy:space-x-2">
153
+ <div
154
+ class="cosy:w-3 cosy:h-3 cosy:rounded-full cosy:bg-error cosy:cursor-pointer hover:cosy:opacity-80 cosy:transition-opacity"
155
+ @click="handleCloseWindow"
156
+ />
157
+ <div
158
+ class="cosy:w-3 cosy:h-3 cosy:rounded-full cosy:bg-warning cosy:cursor-pointer hover:cosy:opacity-80 cosy:transition-opacity"
159
+ @click="handleMinimizeWindow"
160
+ />
161
+ <div
162
+ class="cosy:w-3 cosy:h-3 cosy:rounded-full cosy:bg-success cosy:cursor-pointer hover:cosy:opacity-80 cosy:transition-opacity"
163
+ @click="handleMaximizeWindow"
164
+ />
165
+ </div>
166
+ <div
167
+ class="cosy:ml-6 cosy:text-sm cosy:font-medium cosy:text-base-content"
168
+ >
169
+ {{ title }}
170
+ </div>
171
+
172
+ <!-- 标签选择器 -->
173
+ <div
174
+ v-if="tabs?.length"
175
+ class="cosy:flex-1 cosy:flex cosy:justify-center"
176
+ >
177
+ <div class="cosy:inline-flex cosy:rounded-lg cosy:bg-base-300 cosy:p-1">
178
+ <button
179
+ v-for="(tab, index) in tabs"
180
+ :key="index"
181
+ :class="[
182
+ 'cosy:px-3 cosy:py-1 cosy:text-sm cosy:rounded-md cosy:transition-colors',
183
+ activeTab === tab
184
+ ? 'cosy:bg-base-100 cosy:text-base-content cosy:shadow'
185
+ : 'cosy:text-base-content/70 hover:cosy:text-base-content',
186
+ ]"
187
+ @click="handleTabClick(tab)"
188
+ >
189
+ {{ tab }}
190
+ </button>
246
191
  </div>
247
-
248
- <!-- 主要内容区域 -->
249
- <div class="cosy:flex-1 cosy:flex cosy:flex-col cosy:pt-12 cosy:h-full">
250
- <div class="cosy:flex cosy:flex-1 cosy:h-full cosy:overflow-hidden">
251
- <!-- 左侧栏插槽 -->
252
- <slot name="sidebar" />
253
-
254
- <!-- 主内容插槽 -->
255
- <slot />
256
- </div>
257
-
258
- <!-- 底部状态栏 -->
259
- <div v-if="$slots.status" :class="statusBarClasses">
260
- <div class="cosy:flex cosy:items-center cosy:space-x-2">
261
- <slot name="status"></slot>
262
- </div>
263
- </div>
192
+ </div>
193
+
194
+ <!-- 工具栏插槽 -->
195
+ <div class="cosy:ml-auto cosy:flex cosy:items-center cosy:space-x-2">
196
+ <slot name="toolbar" />
197
+ </div>
198
+ </div>
199
+
200
+ <!-- 主要内容区域 -->
201
+ <div class="cosy:flex-1 cosy:flex cosy:flex-col cosy:pt-12 cosy:h-full">
202
+ <div class="cosy:flex cosy:flex-1 cosy:h-full cosy:overflow-hidden">
203
+ <!-- 左侧栏插槽 -->
204
+ <slot name="sidebar" />
205
+
206
+ <!-- 主内容插槽 -->
207
+ <slot />
208
+ </div>
209
+
210
+ <!-- 底部状态栏 -->
211
+ <div v-if="$slots.status" :class="statusBarClasses">
212
+ <div class="cosy:flex cosy:items-center cosy:space-x-2">
213
+ <slot name="status" />
264
214
  </div>
265
- </Container>
215
+ </div>
216
+ </div>
217
+ </Container>
266
218
 
267
- <!-- AlertDialog 组件 -->
268
- <AlertDialog v-model="showAlertDialog" :message="alertMessage" />
219
+ <!-- AlertDialog 组件 -->
220
+ <AlertDialog v-model="showAlertDialog" :message="alertMessage" />
269
221
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffic/cosy-ui",
3
- "version": "0.9.39",
3
+ "version": "0.9.41",
4
4
  "description": "An astro component library",
5
5
  "author": {
6
6
  "name": "nookery",