@coffic/cosy-ui 0.9.20 → 0.9.23

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 (37) hide show
  1. package/dist/app.css +1 -1
  2. package/dist/index-astro.ts +1 -1
  3. package/dist/src-astro/alert/Alert.astro +28 -1
  4. package/dist/src-astro/confirm-dialog/ConfirmDialog.astro +29 -4
  5. package/dist/src-astro/container/Container.astro +40 -0
  6. package/dist/src-astro/container/index.ts +0 -15
  7. package/dist/src-astro/errors/404.astro +4 -8
  8. package/dist/src-astro/heading/Heading.astro +202 -83
  9. package/dist/src-astro/heading/HeadingAnchor.astro +33 -0
  10. package/dist/src-astro/language-switcher/LanguageSwitcher.astro +1 -3
  11. package/dist/src-astro/layout-app/AppLayout.astro +160 -4
  12. package/dist/src-astro/layout-basic/BaseLayout.astro +2 -5
  13. package/dist/src-astro/layout-basic/index.ts +2 -0
  14. package/dist/src-astro/{types → layout-basic}/meta.ts +4 -0
  15. package/dist/src-astro/layout-dashboard/index.ts +1 -1
  16. package/dist/src-astro/modal/CloseButton.astro +28 -0
  17. package/dist/src-astro/modal/Modal.astro +47 -44
  18. package/dist/src-astro/placeholder/PlaceHolder.astro +142 -0
  19. package/dist/src-astro/placeholder/index.ts +2 -0
  20. package/dist/src-astro/placeholder/types.ts +16 -0
  21. package/dist/src-astro/products/ProductCard.astro +3 -1
  22. package/dist/src-astro/products/Products.astro +48 -0
  23. package/dist/src-astro/sidebar/Sidebar.astro +19 -20
  24. package/dist/src-astro/sidebar/SidebarNav.astro +6 -9
  25. package/dist/src-astro/types/layout.ts +1 -1
  26. package/package.json +17 -17
  27. package/dist/src-astro/container/EContainerBasic.astro +0 -15
  28. package/dist/src-astro/container/EContainerBasicContainer.astro +0 -11
  29. package/dist/src-astro/container/EContainerFlexBetween.astro +0 -23
  30. package/dist/src-astro/container/EContainerFlexCenter.astro +0 -30
  31. package/dist/src-astro/container/EContainerFlexColumn.astro +0 -23
  32. package/dist/src-astro/container/EContainerFlexContainer.astro +0 -34
  33. package/dist/src-astro/container/EContainerFlexRow.astro +0 -23
  34. package/dist/src-astro/container/EContainerPadding.astro +0 -32
  35. package/dist/src-astro/container/EContainerPaddingContainer.astro +0 -11
  36. package/dist/src-astro/container/EContainerSizes.astro +0 -36
  37. package/dist/src-astro/container/EContainerSizesContainer.astro +0 -11
@@ -27,14 +27,19 @@ import { getMarginTopClass, getMarginBottomClass } from './utils.ts';
27
27
  import MobileNav from './MobileNav.astro';
28
28
  import type { ISidebarProps } from '../../index-astro';
29
29
 
30
- export interface Props extends ISidebarProps {}
30
+ export interface Props extends ISidebarProps {
31
+ topClass?: string;
32
+ heightClass?: string;
33
+ }
31
34
 
32
35
  const {
33
36
  sidebarItems,
34
37
  class: className,
35
38
  debug = false,
36
- marginTop = 'md',
37
- marginBottom = 'md',
39
+ marginTop = 'none',
40
+ marginBottom = 'none',
41
+ topClass = 'cosy:top-12',
42
+ heightClass = 'cosy:h-[calc(100vh-3rem)]',
38
43
  } = Astro.props;
39
44
 
40
45
  // 自动获取当前路径
@@ -67,26 +72,24 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
67
72
 
68
73
  {/* 桌面端侧边栏 */}
69
74
  <aside
70
- data-sidebar
75
+ data-desktop-sidebar
71
76
  data-current-path={currentPath}
72
77
  data-margin-top={marginTop}
73
78
  data-margin-bottom={marginBottom}
74
79
  class:list={[
75
80
  className,
76
81
  debugClass,
77
- 'cosy:hidden cosy:lg:block',
82
+ 'cosy:hidden cosy:w-60 cosy:lg:block cosy:bg-base-200 cosy:px-4 cosy:overflow-y-auto cosy:sticky',
83
+ topClass,
84
+ heightClass,
78
85
  getMarginTopClass(marginTop),
79
86
  getMarginBottomClass(marginBottom),
80
87
  ]}>
81
- <div
82
- class="cosy:top-16 cosy:sticky cosy:pb-48 cosy:h-[calc(100vh-0rem)] cosy:overflow-y-auto"
83
- data-desktop-sidebar-content>
84
- <SidebarNav
85
- sidebarItems={sidebarItems}
86
- currentPath={currentPath}
87
- debug={debug}
88
- />
89
- </div>
88
+ <SidebarNav
89
+ sidebarItems={sidebarItems}
90
+ currentPath={currentPath}
91
+ debug={debug}
92
+ />
90
93
  </aside>
91
94
 
92
95
  <script>
@@ -95,9 +98,7 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
95
98
  // 处理侧边栏滚动位置保存和恢复
96
99
  document.addEventListener('astro:before-preparation', () => {
97
100
  // 保存桌面端滚动位置
98
- const desktopContent = document.querySelector(
99
- '[data-desktop-sidebar-content]'
100
- );
101
+ const desktopContent = document.querySelector('[data-desktop-sidebar]');
101
102
  if (desktopContent) {
102
103
  saveScrollPosition(desktopContent, 'sidebarScrollPosition');
103
104
  }
@@ -113,9 +114,7 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
113
114
 
114
115
  document.addEventListener('astro:page-load', () => {
115
116
  // 恢复桌面端滚动位置
116
- const desktopContent = document.querySelector(
117
- '[data-desktop-sidebar-content]'
118
- );
117
+ const desktopContent = document.querySelector('[data-desktop-sidebar]');
119
118
  if (desktopContent) {
120
119
  restoreScrollPosition(desktopContent, 'sidebarScrollPosition');
121
120
  }
@@ -8,6 +8,7 @@
8
8
  import '../../style.ts';
9
9
  import NavItem from './NavItem.astro';
10
10
  import type { ISidebarItem } from '../types/sidebar.ts';
11
+ import { Heading } from '../../index-astro.ts';
11
12
 
12
13
  interface Props {
13
14
  /**
@@ -45,20 +46,16 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
45
46
  <nav
46
47
  data-sidebar-nav
47
48
  data-current-path={currentPath}
48
- class:list={['cosy:p-4', debugClass, className]}>
49
+ class:list={['cosy:p-0', debugClass, className]}>
49
50
  {
50
51
  sidebarItems.map((section: ISidebarItem) => (
51
- <div class:list={['cosy:mb-6', debugClass]}>
52
- <h3
53
- class:list={[
54
- 'cosy:font-bold cosy:mb-2 cosy:text-base-content/70',
55
- debugClass,
56
- ]}>
52
+ <div class:list={[debugClass]}>
53
+ <Heading level={5} align="center" href={section.href}>
57
54
  {section.text}
58
- </h3>
55
+ </Heading>
59
56
  <ul
60
57
  class:list={[
61
- 'cosy:menu cosy:bg-base-200 cosy:rounded-box cosy:w-56 cosy:no-underline',
58
+ 'cosy:menu cosy:rounded-box cosy:w-full cosy:no-underline',
62
59
  debugClass,
63
60
  ]}>
64
61
  {section.items?.map((item: ISidebarItem) => (
@@ -1,7 +1,7 @@
1
1
  import type { IFooterProps } from './footer';
2
2
  import type { IHeaderProps } from './header';
3
3
  import type { IMainContentProps } from './main';
4
- import type { IMetaProps } from './meta';
4
+ import type { IMetaProps } from '../layout-basic/meta';
5
5
  import type { ISidebarProps } from './sidebar';
6
6
 
7
7
  export interface IAppLayoutProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffic/cosy-ui",
3
- "version": "0.9.20",
3
+ "version": "0.9.23",
4
4
  "description": "An astro component library",
5
5
  "author": {
6
6
  "name": "nookery",
@@ -60,38 +60,38 @@
60
60
  "astro-integration-kit": "^0.18.0",
61
61
  "fs-extra": "^11.3.0",
62
62
  "html-to-image": "^1.11.13",
63
- "shiki": "^3.7.0"
63
+ "shiki": "^3.9.1"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@astrojs/check": "^0.9.4",
67
- "@astrojs/mdx": "^4.2.6",
67
+ "@astrojs/mdx": "^4.3.3",
68
68
  "@astrojs/ts-plugin": "^1.10.4",
69
- "@eslint/js": "^9.27.0",
69
+ "@eslint/js": "^9.32.0",
70
70
  "@tailwindcss/typography": "^0.5.16",
71
- "@tailwindcss/vite": "^4.1.7",
71
+ "@tailwindcss/vite": "^4.1.11",
72
72
  "@tsconfig/node22": "^22.0.2",
73
73
  "@types/chai": "^5.2.2",
74
74
  "@types/eslint": "^9.6.1",
75
75
  "@types/fs-extra": "^11.0.4",
76
76
  "@types/mocha": "^10.0.10",
77
- "@types/node": "^22.15.19",
78
- "@types/react": "^19.1.4",
79
- "@typescript-eslint/parser": "^8.32.1",
80
- "astro": "^5.7.13",
77
+ "@types/node": "^22.17.0",
78
+ "@types/react": "^19.1.9",
79
+ "@typescript-eslint/parser": "^8.38.0",
80
+ "astro": "^5.12.8",
81
81
  "chai": "^4.5.0",
82
- "daisyui": "^5.0.35",
83
- "eslint": "^9.27.0",
82
+ "daisyui": "^5.0.50",
83
+ "eslint": "^9.32.0",
84
84
  "eslint-plugin-astro": "^1.3.1",
85
- "globals": "^16.1.0",
85
+ "globals": "^16.3.0",
86
86
  "mocha": "^10.8.2",
87
- "prettier": "^3.5.3",
87
+ "prettier": "^3.6.2",
88
88
  "prettier-plugin-astro": "^0.14.1",
89
89
  "rollup-plugin-copy": "^3.5.0",
90
90
  "sharp": "^0.33.5",
91
- "tailwindcss": "^4.1.7",
92
- "tsx": "^4.19.4",
93
- "typescript": "^5.8.3",
94
- "typescript-eslint": "^8.32.1",
91
+ "tailwindcss": "^4.1.11",
92
+ "tsx": "^4.20.3",
93
+ "typescript": "^5.9.2",
94
+ "typescript-eslint": "^8.38.0",
95
95
  "vite": "^6.3.5"
96
96
  }
97
97
  }
@@ -1,15 +0,0 @@
1
- ---
2
- /**
3
- * @component Container.Basic
4
- *
5
- * @description
6
- * 基础Container组件示例,展示最简单的容器用法。
7
- */
8
- import { Container } from '../../index-astro';
9
- ---
10
-
11
- <Container>
12
- <p class="cosy:text-center">
13
- 这是一个基础容器,内容会被限制在一个合理的宽度内并居中显示
14
- </p>
15
- </Container>
@@ -1,11 +0,0 @@
1
- ---
2
- import { CodeContainer } from '../../index-astro';
3
- import ContainerBasic from './EContainerBasic.astro';
4
- import ContainerBasicSourceCode from './EContainerBasic.astro?raw';
5
- ---
6
-
7
- <CodeContainer codes={[ContainerBasicSourceCode]}>
8
- <div id="tab-1">
9
- <ContainerBasic />
10
- </div>
11
- </CodeContainer>
@@ -1,23 +0,0 @@
1
- ---
2
- /**
3
- * @component Container.FlexBetween
4
- *
5
- * @description
6
- * 展示Container组件的两端对齐(justify="between")布局功能。
7
- */
8
- import '../../style.ts';
9
- import { Container } from '../../index-astro';
10
- ---
11
-
12
- <Container flex="row" justify="between" border padding="md">
13
- <div class="cosy:bg-primary cosy:text-primary-content cosy:p-4 cosy:rounded">
14
- 左侧
15
- </div>
16
- <div
17
- class="cosy:bg-secondary cosy:text-secondary-content cosy:p-4 cosy:rounded">
18
- 中间
19
- </div>
20
- <div class="cosy:bg-accent cosy:text-accent-content cosy:p-4 cosy:rounded">
21
- 右侧
22
- </div>
23
- </Container>
@@ -1,30 +0,0 @@
1
- ---
2
- /**
3
- * @component Container.FlexCenter
4
- *
5
- * @description
6
- * 展示Container组件的居中对齐(items="center" justify="center")布局功能。
7
- */
8
- import '../../style.ts';
9
- import { Container } from '../../index-astro';
10
- ---
11
-
12
- <Container
13
- flex="row"
14
- gap="md"
15
- items="center"
16
- justify="center"
17
- border
18
- padding="md"
19
- class="cosy:h-32">
20
- <div class="cosy:bg-primary cosy:text-primary-content cosy:p-4 cosy:rounded">
21
- 居中项
22
- </div>
23
- <div
24
- class="cosy:bg-secondary cosy:text-secondary-content cosy:p-6 cosy:rounded">
25
- 较大项
26
- </div>
27
- <div class="cosy:bg-accent cosy:text-accent-content cosy:p-2 cosy:rounded">
28
- 较小项
29
- </div>
30
- </Container>
@@ -1,23 +0,0 @@
1
- ---
2
- /**
3
- * @component Container.FlexColumn
4
- *
5
- * @description
6
- * 展示Container组件的列排列(flex="col")布局功能。
7
- */
8
- import '../../style.ts';
9
- import { Container } from '../../index-astro';
10
- ---
11
-
12
- <Container flex="col" gap="md" border padding="md">
13
- <div class="cosy:bg-primary cosy:text-primary-content cosy:p-4 cosy:rounded">
14
- 第一项
15
- </div>
16
- <div
17
- class="cosy:bg-secondary cosy:text-secondary-content cosy:p-4 cosy:rounded">
18
- 第二项
19
- </div>
20
- <div class="cosy:bg-accent cosy:text-accent-content cosy:p-4 cosy:rounded">
21
- 第三项
22
- </div>
23
- </Container>
@@ -1,34 +0,0 @@
1
- ---
2
- import { CodeContainer } from '../../index-astro';
3
- import ContainerFlexRow from './EContainerFlexRow.astro';
4
- import ContainerFlexColumn from './EContainerFlexColumn.astro';
5
- import ContainerFlexCenter from './EContainerFlexCenter.astro';
6
- import ContainerFlexBetween from './EContainerFlexBetween.astro';
7
-
8
- import ContainerFlexRowSourceCode from './EContainerFlexRow.astro?raw';
9
- import ContainerFlexColumnSourceCode from './EContainerFlexColumn.astro?raw';
10
- import ContainerFlexCenterSourceCode from './EContainerFlexCenter.astro?raw';
11
- import ContainerFlexBetweenSourceCode from './EContainerFlexBetween.astro?raw';
12
- ---
13
-
14
- <CodeContainer
15
- titles={['Row', 'Column', 'Center', 'Between']}
16
- codes={[
17
- ContainerFlexRowSourceCode,
18
- ContainerFlexColumnSourceCode,
19
- ContainerFlexCenterSourceCode,
20
- ContainerFlexBetweenSourceCode,
21
- ]}>
22
- <div id="tab-1">
23
- <ContainerFlexRow />
24
- </div>
25
- <div id="tab-2">
26
- <ContainerFlexColumn />
27
- </div>
28
- <div id="tab-3">
29
- <ContainerFlexCenter />
30
- </div>
31
- <div id="tab-4">
32
- <ContainerFlexBetween />
33
- </div>
34
- </CodeContainer>
@@ -1,23 +0,0 @@
1
- ---
2
- /**
3
- * @component Container.FlexRow
4
- *
5
- * @description
6
- * 展示Container组件的行排列(flex="row")布局功能。
7
- */
8
- import '../../style.ts';
9
- import { Container } from '../../index-astro';
10
- ---
11
-
12
- <Container flex="row" gap="md" border padding="md">
13
- <div class="cosy:bg-primary cosy:text-primary-content cosy:p-4 cosy:rounded">
14
- 第一项
15
- </div>
16
- <div
17
- class="cosy:bg-secondary cosy:text-secondary-content cosy:p-4 cosy:rounded">
18
- 第二项
19
- </div>
20
- <div class="cosy:bg-accent cosy:text-accent-content cosy:p-4 cosy:rounded">
21
- 第三项
22
- </div>
23
- </Container>
@@ -1,32 +0,0 @@
1
- ---
2
- /**
3
- * @component Container.Padding
4
- *
5
- * @description
6
- * 展示Container组件的不同内边距选项:none、sm、md、lg、xl。
7
- */
8
- import '../../style.ts';
9
- import { Container } from '../../index-astro';
10
- ---
11
-
12
- <div class="cosy:space-y-4">
13
- <Container padding="none" border>
14
- <p class="cosy:text-center">无内边距 (none)</p>
15
- </Container>
16
-
17
- <Container padding="sm" border>
18
- <p class="cosy:text-center">小内边距 (sm)</p>
19
- </Container>
20
-
21
- <Container padding="md" border>
22
- <p class="cosy:text-center">中等内边距 (md) - 默认</p>
23
- </Container>
24
-
25
- <Container padding="lg" border>
26
- <p class="cosy:text-center">大内边距 (lg)</p>
27
- </Container>
28
-
29
- <Container padding="xl" border>
30
- <p class="cosy:text-center">超大内边距 (xl)</p>
31
- </Container>
32
- </div>
@@ -1,11 +0,0 @@
1
- ---
2
- import { CodeContainer } from '../../index-astro';
3
- import ContainerPadding from './EContainerPadding.astro';
4
- import ContainerPaddingSourceCode from './EContainerPadding.astro?raw';
5
- ---
6
-
7
- <CodeContainer codes={[ContainerPaddingSourceCode]}>
8
- <div id="tab-1">
9
- <ContainerPadding />
10
- </div>
11
- </CodeContainer>
@@ -1,36 +0,0 @@
1
- ---
2
- /**
3
- * @component Container.Sizes
4
- *
5
- * @description
6
- * 展示Container组件的不同尺寸选项:xs、sm、md、lg、xl、full。
7
- */
8
- import '../../style.ts';
9
- import { Container } from '../../index-astro';
10
- ---
11
-
12
- <div class="cosy:space-y-4">
13
- <Container size="xs" border>
14
- <p class="cosy:text-center">超小尺寸容器 (xs)</p>
15
- </Container>
16
-
17
- <Container size="sm" border>
18
- <p class="cosy:text-center">小尺寸容器 (sm)</p>
19
- </Container>
20
-
21
- <Container size="md" border>
22
- <p class="cosy:text-center">中等尺寸容器 (md) - 默认</p>
23
- </Container>
24
-
25
- <Container size="lg" border>
26
- <p class="cosy:text-center">大尺寸容器 (lg)</p>
27
- </Container>
28
-
29
- <Container size="xl" border>
30
- <p class="cosy:text-center">超大尺寸容器 (xl)</p>
31
- </Container>
32
-
33
- <Container size="full" border>
34
- <p class="cosy:text-center">全宽容器 (full)</p>
35
- </Container>
36
- </div>
@@ -1,11 +0,0 @@
1
- ---
2
- import { CodeContainer } from '../../index-astro';
3
- import ContainerSizes from './EContainerSizes.astro';
4
- import ContainerSizesSourceCode from './EContainerSizes.astro?raw';
5
- ---
6
-
7
- <CodeContainer codes={[ContainerSizesSourceCode]}>
8
- <div id="tab-1">
9
- <ContainerSizes />
10
- </div>
11
- </CodeContainer>