@campus-admin/ui 1.0.0 → 2.0.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.
Files changed (129) hide show
  1. package/README.md +138 -335
  2. package/dist/campus/card/index.d.ts +9 -0
  3. package/dist/campus/index.d.ts +7 -0
  4. package/dist/campus/parent/index.d.ts +9 -0
  5. package/dist/campus/student/index.d.ts +9 -0
  6. package/dist/campus/teacher/index.d.ts +9 -0
  7. package/dist/campus/tel/index.d.ts +9 -0
  8. package/dist/{base/empty/src/empty.vue.d.ts → components/basic/CaIcon.vue.d.ts} +4 -7
  9. package/dist/components/basic/CaPageActions.vue.d.ts +15 -0
  10. package/dist/components/basic/icons.d.ts +48 -0
  11. package/dist/components/basic/index.d.ts +838 -0
  12. package/dist/components/button/index.d.ts +348 -0
  13. package/dist/components/chart/bar-chart/CaBarChart.vue.d.ts +31 -0
  14. package/dist/components/chart/chart-math.d.ts +178 -0
  15. package/dist/components/chart/gauge/CaGauge.vue.d.ts +31 -0
  16. package/dist/components/chart/index.d.ts +195 -0
  17. package/dist/components/chart/line-chart/CaLineChart.vue.d.ts +40 -0
  18. package/dist/components/chart/parts/ChartLegend.vue.d.ts +28 -0
  19. package/dist/{atom/slogan/src/slogan.vue.d.ts → components/chart/parts/ChartStatus.vue.d.ts} +3 -5
  20. package/dist/components/chart/parts/ChartTable.vue.d.ts +19 -0
  21. package/dist/components/chart/parts/ChartTooltip.vue.d.ts +23 -0
  22. package/dist/components/chart/pie-chart/CaPieChart.vue.d.ts +25 -0
  23. package/dist/components/chart/sparkline/CaSparkline.vue.d.ts +20 -0
  24. package/dist/components/chart/use-chart.d.ts +36 -0
  25. package/dist/components/config/CaConfigProvider.vue.d.ts +16 -0
  26. package/dist/components/config/index.d.ts +33 -0
  27. package/dist/components/display/index.d.ts +99 -0
  28. package/dist/{base/copyright/src/copyright.vue.d.ts → components/display/stat-card/CaStatCard.vue.d.ts} +7 -11
  29. package/dist/{base/skeleton/src/skeleton.vue.d.ts → components/display/status-tag/CaStatusTag.vue.d.ts} +4 -7
  30. package/dist/components/display/types.d.ts +7 -0
  31. package/dist/components/form/index.d.ts +112 -0
  32. package/dist/components/form/schema-form/CaSchemaForm.vue.d.ts +31 -0
  33. package/dist/components/form/types.d.ts +17 -0
  34. package/dist/components/index.d.ts +22 -0
  35. package/dist/components/layout/index.d.ts +34 -0
  36. package/dist/components/navigation/CaMenu.vue.d.ts +13 -0
  37. package/dist/components/navigation/index.d.ts +64 -0
  38. package/dist/components/overlay/index.d.ts +1511 -0
  39. package/dist/components/table/data-table/CaDataTable.vue.d.ts +49 -0
  40. package/dist/components/table/index.d.ts +33 -0
  41. package/dist/components/table/types.d.ts +46 -0
  42. package/dist/index.d.ts +21 -1106
  43. package/dist/index.js +2187 -0
  44. package/dist/oms/index.d.ts +3 -0
  45. package/dist/oms/school/index.d.ts +10 -0
  46. package/dist/shared/inject.d.ts +8 -0
  47. package/dist/shared/registry.d.ts +5 -0
  48. package/dist/shared/types.d.ts +9 -0
  49. package/dist/shared/wrap.d.ts +7 -0
  50. package/dist/style.css +2 -0
  51. package/package.json +17 -49
  52. package/dist/atom/attendance-badge/index.d.ts +0 -5
  53. package/dist/atom/attendance-badge/src/attendance-badge.vue.d.ts +0 -13
  54. package/dist/atom/attendance-badge/src/core.d.ts +0 -11
  55. package/dist/atom/avatar/index.d.ts +0 -3
  56. package/dist/atom/avatar/src/avatar.vue.d.ts +0 -14
  57. package/dist/atom/button/index.d.ts +0 -3
  58. package/dist/atom/button/src/button.vue.d.ts +0 -40
  59. package/dist/atom/checkbox/index.d.ts +0 -3
  60. package/dist/atom/checkbox/src/checkbox.vue.d.ts +0 -24
  61. package/dist/atom/icon/index.d.ts +0 -3
  62. package/dist/atom/icon/src/icon.vue.d.ts +0 -27
  63. package/dist/atom/index.d.ts +0 -444
  64. package/dist/atom/input/index.d.ts +0 -3
  65. package/dist/atom/input/src/input.vue.d.ts +0 -43
  66. package/dist/atom/progress/index.d.ts +0 -4
  67. package/dist/atom/progress/src/core.d.ts +0 -9
  68. package/dist/atom/progress/src/progress.vue.d.ts +0 -19
  69. package/dist/atom/select/index.d.ts +0 -5
  70. package/dist/atom/select/src/core.d.ts +0 -9
  71. package/dist/atom/select/src/select.vue.d.ts +0 -22
  72. package/dist/atom/slogan/index.d.ts +0 -3
  73. package/dist/atom/switch/index.d.ts +0 -3
  74. package/dist/atom/switch/src/switch.vue.d.ts +0 -16
  75. package/dist/atom/tag/index.d.ts +0 -3
  76. package/dist/atom/tag/src/tag.vue.d.ts +0 -31
  77. package/dist/atom/textarea/index.d.ts +0 -3
  78. package/dist/atom/textarea/src/textarea.vue.d.ts +0 -19
  79. package/dist/base/breadcrumb/index.d.ts +0 -4
  80. package/dist/base/breadcrumb/src/breadcrumb.vue.d.ts +0 -29
  81. package/dist/base/class-tree/index.d.ts +0 -5
  82. package/dist/base/class-tree/src/class-tree.vue.d.ts +0 -29
  83. package/dist/base/class-tree/src/core.d.ts +0 -30
  84. package/dist/base/copyright/index.d.ts +0 -3
  85. package/dist/base/drawer/index.d.ts +0 -3
  86. package/dist/base/drawer/src/drawer.vue.d.ts +0 -36
  87. package/dist/base/empty/index.d.ts +0 -3
  88. package/dist/base/index.d.ts +0 -651
  89. package/dist/base/menu/core.d.ts +0 -34
  90. package/dist/base/menu/index.d.ts +0 -13
  91. package/dist/base/menu/side-menu/index.d.ts +0 -5
  92. package/dist/base/menu/side-menu/src/side-menu.vue.d.ts +0 -59
  93. package/dist/base/modal/index.d.ts +0 -4
  94. package/dist/base/modal/src/core.d.ts +0 -8
  95. package/dist/base/modal/src/modal.vue.d.ts +0 -46
  96. package/dist/base/page-header/index.d.ts +0 -3
  97. package/dist/base/page-header/src/page-header.vue.d.ts +0 -27
  98. package/dist/base/pagination/index.d.ts +0 -5
  99. package/dist/base/pagination/src/core.d.ts +0 -11
  100. package/dist/base/pagination/src/pagination.vue.d.ts +0 -26
  101. package/dist/base/search-form/index.d.ts +0 -3
  102. package/dist/base/search-form/src/search-form.vue.d.ts +0 -34
  103. package/dist/base/skeleton/index.d.ts +0 -3
  104. package/dist/base/statistic/index.d.ts +0 -3
  105. package/dist/base/statistic/src/statistic.vue.d.ts +0 -16
  106. package/dist/base/table/index.d.ts +0 -5
  107. package/dist/base/table/src/core.d.ts +0 -25
  108. package/dist/base/table/src/table.vue.d.ts +0 -44
  109. package/dist/base/toast/index.d.ts +0 -5
  110. package/dist/base/toast/src/store.d.ts +0 -56
  111. package/dist/base/toast/src/toast-container.vue.d.ts +0 -3
  112. package/dist/campus-ui.css +0 -2
  113. package/dist/campus-ui.js +0 -2229
  114. package/dist/campus-ui.umd.cjs +0 -1
  115. package/dist/core/index.d.ts +0 -4
  116. package/dist/core/namespace.d.ts +0 -16
  117. package/dist/core/theme.d.ts +0 -49
  118. package/dist/feature/daily-agenda/index.d.ts +0 -5
  119. package/dist/feature/daily-agenda/src/core.d.ts +0 -25
  120. package/dist/feature/daily-agenda/src/daily-agenda.vue.d.ts +0 -12
  121. package/dist/feature/daily-agenda/src/data.d.ts +0 -3
  122. package/dist/feature/index.d.ts +0 -61
  123. package/dist/feature/student-picker/index.d.ts +0 -5
  124. package/dist/feature/student-picker/src/core.d.ts +0 -19
  125. package/dist/feature/student-picker/src/student-picker.vue.d.ts +0 -26
  126. package/dist/feature/weekly-timetable/index.d.ts +0 -6
  127. package/dist/feature/weekly-timetable/src/core.d.ts +0 -33
  128. package/dist/feature/weekly-timetable/src/data.d.ts +0 -3
  129. package/dist/feature/weekly-timetable/src/weekly-timetable.vue.d.ts +0 -7
package/README.md CHANGED
@@ -1,367 +1,170 @@
1
- # @campus-admin/ui
1
+ # @campus-admin/ui: component package
2
2
 
3
- 面向智慧校园后台管理场景的 Vue 3 组件库,共 27 个组件,分**原子 / 基础 / 功能**三层。
3
+ English | [简体中文](README.zh-CN.md)
4
4
 
5
- 组件只负责渲染,**不访问接口、不读全局状态**:数据通过 Props 传入,
6
- 用户操作通过 Events 抛出。
5
+ The platform's only component entry. Platforms use only `Ca`-prefixed components and never import the base library (Element Plus) directly;
6
+ the base library's version, replacement and style tweaks stay inside the framework, which is what lets platforms upgrade the framework without changing code.
7
7
 
8
- 主题支持**明暗两套配色**与**运行时品牌换色**:一行代码切换暗色,一行代码把主色换成学校品牌色。
8
+ ## Layout: `components` holds generic components, `campus` / `oms` hold business-scenario components
9
9
 
10
- ## 安装
10
+ ```text
11
+ src/
12
+ components/
13
+ basic/ Basic pieces: CaIcon, CaCard, CaTag, CaAlert, CaPageActions
14
+ button/ Buttons: CaButton, CaButtonGroup
15
+ chart/ Charts (hand-drawn SVG): CaLineChart, CaBarChart, CaPieChart, CaSparkline, CaGauge
16
+ config/ Global config: CaConfigProvider
17
+ display/ Data display: CaStatCard, CaStatusTag
18
+ layout/ Layout: containers, grid, spacing, splitter
19
+ form/ Forms: control wrappers + schema-driven form
20
+ navigation/ Navigation: breadcrumb, dropdown, menu
21
+ overlay/ Overlay containers: CaDialog, CaDrawer
22
+ table/ Tables (one sub-folder per style)
23
+ data-table/CaDataTable.vue
24
+ index.ts Collects each category's registry (duplicate names throw)
25
+ campus/ Components for campus business scenarios, scenarios side by side (all empty for now)
26
+ student/ teacher/ parent/ card/ tel/ ...
27
+ index.ts Collects each scenario's registry
28
+ oms/ Components for the operations platform (also empty for now)
29
+ school/ ... School management etc., added as needed
30
+ index.ts Collects each scenario's registry
31
+ shared/ Utilities and types shared across directories
32
+ index.ts Package entry, installUi
33
+ ```
34
+
35
+ Categories are flat, with no "domain" level. Category names follow the base library's component overview (basic, config, form, data, navigation, feedback, other),
36
+ split by the framework's own needs (for example buttons form their own category). When adding a category, add a row to the table below and to `components/index.ts`.
37
+
38
+ | Directory | Contents | Existing components |
39
+ |---|---|---|
40
+ | basic | Element-level basics | CaLink, CaText, CaScrollbar, CaDivider, CaWatermark, CaAlert, CaCard, CaIcon, CaPageActions, CaTag |
41
+ | button | Buttons and variants | CaButton, CaButtonGroup |
42
+ | chart | Charts, hand-drawn SVG, no chart library or base dependency | CaLineChart, CaBarChart, CaPieChart, CaSparkline, CaGauge |
43
+ | config | Global config container | CaConfigProvider |
44
+ | display | Data display | CaAvatar, CaAvatarGroup, CaBadge, CaCalendar, CaCarousel, CaCarouselItem, CaCollapse, CaCollapseItem, CaDescriptions, CaDescriptionsItem, CaEmpty, CaImage, CaImageViewer, CaPagination, CaProgress, CaResult, CaSkeleton, CaSkeletonItem, CaTimeline, CaTimelineItem, CaTour, CaTourStep, CaTree, CaTreeV2, CaSegmented, CaStatistic, CaCountdown, CaCheckTag, CaStatCard, CaStatusTag |
45
+ | form | Data entry and schema-driven forms | CaAutocomplete, CaCascader, CaCascaderPanel, CaCheckbox, CaCheckboxGroup, CaCheckboxButton, CaColorPickerPanel, CaDatePickerPanel, CaInputTag, CaInputOtp, CaMention, CaRate, CaSelectV2, CaSlider, CaTimePicker, CaTimeSelect, CaTransfer, CaTreeSelect, CaUpload, CaOptionGroup, CaRadio, CaColorPicker, CaDatePicker, CaForm, CaFormItem, CaInput, CaInputNumber, CaOption, CaRadioButton, CaRadioGroup, CaSelect, CaSwitch, CaSchemaForm |
46
+ | layout | Containers, grid, spacing and splitter | CaContainer, CaHeader, CaAside, CaMain, CaFooter, CaRow, CaCol, CaSpace, CaSplitter, CaSplitterPanel |
47
+ | navigation | Navigation and page switching | CaAffix, CaAnchor, CaAnchorLink, CaBacktop, CaPageHeader, CaSteps, CaStep, CaTabs, CaTabPane, CaMenuItemGroup, CaBreadcrumb, CaBreadcrumbItem, CaDropdown, CaDropdownItem, CaDropdownMenu, CaMenu, CaMenuItem, CaSubMenu |
48
+ | overlay | Template-declared overlays | CaPopover, CaPopconfirm, CaTooltip, CaDialog, CaDrawer |
49
+ | table | Thin table wrappers and the composed data table | CaTable, CaTableColumn, CaTableV2, CaAutoResizer, CaDataTable |
50
+
51
+ Alerts, confirmations, toasts, notifications and imperative loading all live in core's `services/feedback.ts` and are exposed through `ca`. That file is the one place core may reference the base library for feedback, so the layering exceptions do not grow. The loading and infinite-scroll directives are registered by `installUi` in this package and are not mixed into the component registries.
52
+
53
+ ## How business components grow
54
+
55
+ Business components are not designed up front; every scenario under `campus/` and `oms/` is empty for now. The flow is:
56
+
57
+ 1. Implement it in the platform first (campus telephone and similar start in platform code).
58
+ 2. Once it is reused and its boundary is clear, **extract it to `campus/<scenario>/`**: student, teacher, parent,
59
+ card (campus card), tel (campus phone: call records, family numbers, etc.); more scenario folders are added as needed.
60
+ 3. Operations-platform components follow the same path into `oms/<scenario>/` (only `oms/school/` for now).
61
+ 4. When a scenario grows large or needs independent releases, split it into its own package.
62
+
63
+ Rules:
64
+ - `campus` and `oms` may depend on `components` (generic components) and `shared`;
65
+ - `components` and `shared` must not depend on `campus` or `oms`;
66
+ - `campus` and `oms` must not depend on each other; shared parts move to `components/`.
67
+
68
+ The layering check (`pnpm run check:boundaries`) blocks these violations. `oms/school/` is "school management in the operations platform" and is a separate directory from `campus/` (campus business scenarios).
69
+
70
+ Tag names are independent of directories (always `<ca-name>`), so templates need no change when a component is extracted or moved.
71
+
72
+ ## Directory conventions
11
73
 
12
- ```bash
13
- pnpm add @campus-admin/ui
74
+ ```text
75
+ components/<category>/, campus/<scenario>/ or oms/<scenario>/
76
+ index.ts Exports this directory's components and a <Name>Components registry
77
+ types.ts Types shared by this category (optional)
78
+ <component-name>/
79
+ Ca<Name>.vue The component itself
14
80
  ```
15
81
 
16
- 通常不需要单独安装——[`@campus-admin/core`](../core) 已包含它。
17
-
18
- 依赖:`vue@^3.5.42`、`@lucide/vue@^1.44.0`(均为 peerDependency)。
82
+ - Component names always carry the `Ca` prefix; folders use kebab-case.
83
+ - **Tag names are independent of directories**: every component is written `<ca-name>` (`<ca-button>`, and a future `<ca-student-picker>` too);
84
+ the category appears only in the directory, never in the tag. Components are registered globally, so names must be unique across all categories;
85
+ a duplicate throws when the registries are merged (see `src/shared/registry.ts`) instead of silently overriding. Moving a component between directories keeps its tag name, so platform templates need no change.
86
+ - Different styles of the same category sit side by side and share that category's `types.ts`.
87
+ Tables work this way: besides `table/data-table/`, card-style, tree and editable tables will each get a sub-folder
88
+ sharing the same column, search-condition and request conventions, so platform data functions can be reused.
89
+ - Colors, radii and shadows always use `--ca-*` variables, never hard-coded values.
90
+ - Copy is not hard-coded in components: use `useTranslate()` to read messages, which live in the locale package.
19
91
 
20
- ## 两种引入方式
92
+ ## Steps to add a component
21
93
 
22
- ### 按需引入(推荐)
94
+ 1. Pick the category; only add a new one if none fits, and add a row to the table in this file and to `components/index.ts`.
95
+ 2. Create the component folder and write detailed comments (responsibility, props, and why it is done this way).
96
+ 3. Export it from the category's `index.ts` and add it to the registry, importing the component's base styles (`element-plus/es/components/<component>/style/css`); a new category must also be merged in `components/index.ts`.
97
+ 4. Sync the demo site's `catalog.ts` and run `check:catalog` to verify exports, registration and the catalog. New components need a real render check; documentation demo pages are added in stages by the component-docs tasks.
98
+ 5. Think twice about generic pieces: if the base library already does the job, make only a thin wrapper.
23
99
 
24
- ```vue
25
- <script setup lang="ts">
26
- import { CaButton, CaTable, toast } from '@campus-admin/ui'
27
- import type { TableColumn } from '@campus-admin/ui'
28
- import '@campus-admin/ui/style.css'
29
- </script>
30
- ```
100
+ ## Thin-wrapper compatibility and styles
31
101
 
32
- ### 全局注册
102
+ `wrap()` keeps the base component itself, so props, events, slots, public methods and types are all preserved. Exports and global registration names remain `CaXxx`. Do not add an extra instance layer or change the base library's runtime names: menus look up injections by parent instance, and containers, descriptions and nested table columns recognize child component names.
33
103
 
34
- ```ts
35
- import { createApp } from 'vue'
36
- import CampusUI from '@campus-admin/ui'
37
- import '@campus-admin/ui/style.css'
104
+ Child components are exported, registered and cataloged together with their parent. Each component imports its own `style/css`; `CaAutoResizer` belongs to Table V2, whose base library has no separate auto-resizer style entry, so it comes with `table-v2/style/css`. Infinite scroll is a directive with no CSS file. Date-time selection uses `ca-date-picker` with `type="datetime"` rather than a separate component.
38
105
 
39
- createApp(App).use(CampusUI).mount('#app')
40
- ```
41
-
42
- 注册后模板里直接写 `<CaButton>`,无需 import。
43
-
44
- ## 组件清单
45
-
46
- **原子(`src/atom`)** —— 元素级,不占版面,多为其他组件的零件
47
-
48
- | 组件 | 用途 |
49
- | --- | --- |
50
- | `CaButton` | 操作按钮 |
51
- | `CaIcon` | 单色图标容器 |
52
- | `CaTag` | 状态/分类标记 |
53
- | `CaAvatar` | 用户/学生头像 |
54
- | `CaInput` | 单行文本 |
55
- | `CaTextarea` | 多行文本 |
56
- | `CaSelect` | 下拉选择 |
57
- | `CaCheckbox` | 勾选 / 半选 |
58
- | `CaSwitch` | 开关 |
59
- | `CaProgress` | 进度条 / 环形进度 |
60
- | `CaAttendanceBadge` | 考勤状态标签 |
61
-
62
- **基础(`src/base`)** —— 区域级,可直接放进页面布局,与业务无关
63
-
64
- | 组件 | 用途 |
65
- | --- | --- |
66
- | `CaTable` | 数据表格(泛型 + 排序) |
67
- | `CaPagination` | 分页 |
68
- | `CaStatistic` | 指标数值 |
69
- | `CaModal` | 对话框 |
70
- | `CaDrawer` | 抽屉 |
71
- | `CaEmpty` | 空状态 |
72
- | `CaSkeleton` | 骨架屏 |
73
- | `CaToastContainer` + `toast` | 轻提示(挂载式) |
74
- | `CaBreadcrumb` | 面包屑 |
75
- | `CaSideMenu` | 侧边多级菜单 |
76
- | `CaPageHeader` | 页面标题栏 |
77
- | `CaSearchForm` | 查询表单 |
78
- | `CaClassTree` | 年级班级树 |
79
-
80
- **功能(`src/feature`)** —— 多个组件组合起来完成一件事,不区分角色
81
-
82
- | 组件 | 用途 |
83
- | --- | --- |
84
- | `CaStudentPicker` | 学生选择器 |
85
- | `CaWeeklyTimetable` | 课程表 |
86
- | `CaDailyAgenda` | 日程安排 |
87
-
88
- 每个组件的 `.vue` 文件顶部都有使用说明(用法、Props、事件、插槽),
89
- 各层的判据与目录约定见 `src/atom/README.md`、`src/base/README.md`、`src/feature/README.md`。
90
-
91
- ## 快速示例
92
-
93
- ### 数据表格
94
-
95
- ```vue
96
- <script setup lang="ts">
97
- import { ref } from 'vue'
98
- import { CaPagination, CaTable } from '@campus-admin/ui'
99
- import type { TableColumn } from '@campus-admin/ui'
100
-
101
- interface StudentRow {
102
- id: string
103
- name: string
104
- className: string
105
- balance: number
106
- }
106
+ There are currently 114 global Ca component exports (81 added this round, including child components and the completed CaRadio). The catalog still has 82 entries: 74 wrapped, 5 services or directives, 3 specifications, 0 waiting. `Border / Color / Typography` are token specifications, not components; fonts have no standalone `--ca-font-*` variable yet. Registering everything globally means the build includes these components' code and styles; category style entries are still declared on demand, which does not mean registration is trimmed by platform usage.
107
107
 
108
- const columns: TableColumn<StudentRow>[] = [
109
- { key: 'name', title: '姓名' },
110
- { key: 'className', title: '班级' },
111
- { key: 'balance', title: '余额', numeric: true, sortable: true },
112
- ]
113
-
114
- const rows = ref<StudentRow[]>([])
115
- const total = ref(0)
116
- const page = ref(1)
117
- </script>
118
-
119
- <template>
120
- <CaTable :columns="columns" :data="rows" row-key="id" stripe>
121
- <!-- 单元格插槽命名为 cell-<列 key>,参数是 row / index / column -->
122
- <template #cell-name="{ row }">
123
- <CaAvatar :name="row.name" size="small" />
124
- <b>{{ row.name }}</b>
125
- </template>
126
- </CaTable>
127
-
128
- <CaPagination v-model:current="page" :total="total" />
129
- </template>
130
- ```
108
+ ## Charts (the chart category)
131
109
 
132
- 要点:
110
+ All five chart components are hand-drawn SVG: the base library has no chart component, and requirements forbid third-party chart libraries (ask the user first if one is needed).
111
+ Files are in `src/components/chart/`: pure calculation (ticks, paths, angles, stacking, thresholds) is in `chart-math.ts`, has no DOM and is covered by `test/chart-math.test.ts`;
112
+ appearance (axes, grid, legend, tooltip, animation) is in `chart.css` and uses only `--ca-*` variables; `parts/` holds internal pieces (legend, tooltip, states, data table) that are not registered publicly.
133
113
 
134
- - `columns` 是普通数组,可来自后端下发
135
- - `rowKey` 必须是稳定字段或函数,不要用数组下标
136
- - 单元格插槽名为 `cell-<列 key>`;泛型会跟着 `columns` 推导,`row` 自动获得具体字段类型
137
- - **排序有两种模式**:不传 `sort-key` / `sort-order` 时组件内部排序(点击表头按 升序 → 降序 → 取消 循环);
138
- 传入这两个 prop 且监听 `sort` 事件时用于服务端排序
114
+ | Component | Purpose | Main props |
115
+ |---|---|---|
116
+ | `<ca-line-chart>` | Line / area chart | `categories`, `series: [{ name, data, color? }]`, `smooth`, `area`, `zero`, `legend`, `y-formatter`, `value-formatter` |
117
+ | `<ca-bar-chart>` | Bar chart | `categories`, `series`, `stacked`, `horizontal`, `show-values`, `bar-size` (default max 24px) |
118
+ | `<ca-pie-chart>` | Pie / donut chart | `items: [{ name, value, color? }]`, `donut`, `size`, `center-label`, `center-value`, `legend` |
119
+ | `<ca-sparkline>` | Mini trend (inside KPI cards) | `data`, `type: 'line' \| 'bar'`, `area`, `color`, `height` |
120
+ | `<ca-gauge>` | Progress ring / gauge | `value`, `max`, `shape: 'ring' \| 'gauge' \| 'half'`, `thresholds: [{ at, color }]`, `label`; the `center` slot replaces the center text |
139
121
 
140
- ### 多级侧边菜单
122
+ Shared props: `loading` (keeps the previous chart dimmed with a "Loading data" line on top), `title` (chart name, used only for the screen-reader summary and data table caption), `width` (fixed width, follows the container by default), `height`, `animated`.
141
123
 
142
124
  ```vue
143
- <script setup lang="ts">
144
- import { CaSideMenu } from '@campus-admin/ui'
145
- import type { SideMenuItem } from '@campus-admin/ui'
146
-
147
- const items: SideMenuItem[] = [
148
- { label: '学校概况', icon: LayoutDashboard, children: [
149
- { label: '我的首页', value: '/home' },
150
- { label: '学生管理', value: '/students' },
151
- ] },
152
- { label: '教学教务', icon: BookOpen, children: [
153
- { label: '课程管理', children: [
154
- { label: '课程表', value: '/teach/course/schedule' },
155
- ] },
156
- ] },
157
- ]
158
-
159
- function go(item: SideMenuItem) {
160
- if (item.value) router.push(item.value)
161
- }
162
- </script>
163
-
164
- <template>
165
- <CaSideMenu :items="items" :model-value="route.path" :indent="2" :indent-step="32" @select="go" />
166
- </template>
167
- ```
168
-
169
- **菜单组件不认识路由**:`value` 是业务数据,跳转由使用方决定。
170
- 这样同一组件也能用于小程序或纯链接场景。
171
-
172
- ### 轻提示
173
-
174
- ```ts
175
- import { toast } from '@campus-admin/ui'
176
-
177
- toast.success('保存成功')
178
- toast.error('保存失败', '请检查网络')
179
- ```
180
-
181
- 挂载式用法:在模板里放一个 `<CaToastContainer />`。
182
- 如果用 `@campus-admin/core`,推荐改用全局的 `ca.toast()`(见下方"与 ca 的关系")。
183
-
184
- ## 与 ca 的关系
185
-
186
- `@campus-admin/core` 提供全局命令式 API `ca`,与本库的 `toast` **共用同一份消息队列**:
187
-
188
- ```js
189
- ca.toast('保存成功') // 与 toast.success('保存成功') 等效
190
- ```
191
-
192
- 本库的 `toast` 保留了描述文案等扩展能力;`ca.toast` 更简洁,适合在任意 JS 里调用。
193
-
194
- ## 主题与样式
195
-
196
- ### 引入样式
197
-
198
- ```ts
199
- import '@campus-admin/ui/style.css'
200
- ```
201
-
202
- ### 明暗主题
203
-
204
- ```ts
205
- import { setTheme } from '@campus-admin/ui'
206
-
207
- setTheme('dark') // 暗色
208
- setTheme('light') // 亮色
209
- setTheme('auto') // 跟随系统,系统切换时自动更新
125
+ <ca-line-chart title="Visits" :categories="days" :series="[{ name: 'Visits', data: visits }, { name: 'Conversions', data: orders }]" smooth area :loading="loading" />
126
+ <ca-pie-chart title="Sources" donut :items="[{ name: 'Search', value: 420 }, { name: 'Direct', value: 310 }]" />
127
+ <ca-gauge :value="72" label="Completion" :thresholds="[{ at: 0, color: 'var(--ca-danger)' }, { at: 50, color: 'var(--ca-warning)' }, { at: 80, color: 'var(--ca-success)' }]" />
210
128
  ```
211
129
 
212
- `setTheme` 只是在 `<html>` 上写 `data-ca-theme`,配色由 Token 决定,
213
- 组件样式不区分主题。也可以不用 JS,直接写 `<html data-ca-theme="dark">`。
130
+ Conventions and limits:
131
+ - **Color**: series colors come from the theme palette `--ca-chart-1…8`, picked by series index so a color follows its series (hiding one series does not recolor the others). The palette does not change with a school's primary color; for a single series that should follow the primary color, pass `color: 'var(--ca-color-primary)'` on that series. With more than 8 series, merge the tail into "Other"; the component never invents a ninth color and simply cycles through the existing eight.
132
+ - **No data / missing data**: with no valid value it shows "No data"; `null` means missing, so a line breaks there instead of treating it as 0; pie items with a value of 0 or less take no angle.
133
+ - **Accessibility**: the SVG is `role="img"` with a text summary (min / max / latest) and also outputs a visually hidden data table (up to 400 rows when there are many categories); the legend is always shown (with two or more series) and clicking toggles a series (`aria-pressed`); line, bar and pie charts are focusable, arrow keys step through items and Esc closes the tooltip. Hover tooltips are only an enhancement; every value is available in the legend, data table and summary.
134
+ - **Motion**: the entrance animation plays only on first draw and is off when the system requests reduced motion; data refreshes and hovering do not replay it.
135
+ - **Width**: a ResizeObserver watches the chart container itself, so width changes from collapsing the sidebar, content fullscreen or drawers redraw it; a zero width while the page is detached by KeepAlive is ignored and corrected on reactivation.
136
+ - **Large data**: x-axis labels thin out automatically; there is no data sampling, so aggregate first when a line has several thousand points.
137
+ - These five components are in the self-built allow-list of `scripts/check-catalog.mjs` (they are not base-library wrappers and do not enter the demo site's component catalog). Tests: `test/chart-math.test.ts` (pure calculation), `test/chart-render.test.ts` (server rendering with vite, checking structure, states, escaping and accessibility), `packages/theme/test/chart-palette.test.ts` (palette).
214
138
 
215
- ### 品牌换色(运行时)
216
-
217
- 学校品牌色不是蓝色时,只给一个主色,其余色阶自动推导:
139
+ ## Services and directives
218
140
 
219
141
  ```ts
220
- import { setPrimaryColor, resetPrimaryColor } from '@campus-admin/ui'
221
-
222
- setPrimaryColor('#7c4dff') // 紫色品牌
223
- resetPrimaryColor() // 恢复默认蓝色
224
- ```
225
-
226
- 会自动生成并写入以下变量:`--ca-color-primary`、`-hover`、`-active`、`-soft`、`-text`、`-contrast`。
227
- 推导规则是:
228
-
229
- - 亮色下 hover / active 变深,暗色下变亮;
230
- - `-soft` 浅底跟随当前主题(亮色混合白、暗色混合深色卡片底);
231
- - `-text` 用于浅底上的文字,品牌色过浅时自动加深(暗色下自动提亮)以满足对比度;
232
- - `-contrast` 是主色实心背景上的文字色,浅色品牌(如黄色)自动切换成深色文字。
233
-
234
- 因此按钮、标签、菜单选中态、表格悬停、课表色块都会一起跟着变,不需要逐个组件配置。
235
-
236
- ### 覆盖 Token(更细粒度的换肤)
237
-
238
- 所有视觉都走 CSS 变量,改变量即可换肤,**不要写深层选择器覆盖**:
142
+ import { ca } from '@campus-admin/core'
239
143
 
240
- ```css
241
- :root {
242
- --ca-color-primary: #1f6fe0; /* 主色(等价于 setPrimaryColor) */
243
- --ca-color-success: #2fae85;
244
- --ca-radius-md: 6px;
245
- --ca-control-height-md: 32px; /* 控件高度,可用于调整信息密度 */
144
+ const loading = ca.loading({ target: '#panel', fullscreen: false })
145
+ try {
146
+ await loadData()
147
+ } finally {
148
+ loading.close()
246
149
  }
247
- ```
248
-
249
- Token 分三层,完整清单见 `src/styles/token.css`:
250
-
251
- ```text
252
- 基础色 palette --ca-color-blue-500、--ca-space-4、--ca-radius-md
253
- 品牌与语义色 --ca-color-primary-soft、--ca-color-success-text、--ca-text-secondary、--ca-surface-card
254
- 文字层级 --ca-text-primary、--ca-text-regular、--ca-text-secondary、--ca-text-placeholder、--ca-text-menu
255
- 主题覆盖 :root[data-ca-theme='dark'] 覆盖语义与中性色
256
- ```
257
-
258
- 层级 Token 同样可覆盖:`--ca-z-index-modal`、`--ca-z-index-message`。
259
-
260
- ### 国际化
261
-
262
- 组件库内置 zh-CN / en-US 两套词条,不需要额外安装 i18n 库。单独使用 `@campus-admin/ui` 时,
263
- 在入口建一个语言实例并注入应用:
264
-
265
- ```ts
266
- import { CampusUI, createLocale, installLocale } from '@campus-admin/ui'
267
- import { createApp } from 'vue'
268
-
269
- const app = createApp(App)
270
- const locale = createLocale({
271
- locale: 'zh-CN',
272
- // 业务词条放在自己的根键下,ca 是组件库保留的命名空间
273
- messages: { 'zh-CN': zhCN, 'en-US': enUS },
274
- })
275
-
276
- app.use(CampusUI) // 已自带一份默认语言实例,可省略下一行
277
- installLocale(app, locale)
278
- ```
279
150
 
280
- 取词与切换:
281
-
282
- ```ts
283
- import { setLocale, useLocale } from '@campus-admin/ui'
284
-
285
- const { t, te } = useLocale() // 组件内取词
286
- t('ca.pagination.total', { total: 12 }) // 共 12 条
287
-
288
- setLocale('en-US') // 非 setup 场景
151
+ const notice = ca.notify.success('Saved')
152
+ ca.notify.info('You have a new message', { title: 'Custom title', duration: 5000 })
153
+ ca.notify.warning('Please check your input')
154
+ ca.notify.error('Save failed')
155
+ notice.close()
289
156
  ```
290
157
 
291
- 日期与数字格式化走内置的 `Intl` 封装,不要自己拼中文:
292
-
293
- ```ts
294
- import { formatDay, formatMonth, formatNumber, weekdayLabels } from '@campus-admin/ui'
295
-
296
- formatMonth(new Date(2026, 8, 11), 'en-US') // September 2026
297
- weekdayLabels('zh-CN') // ['周一', ...]
298
- formatNumber(3286, 'en-US') // 3,286
299
- ```
300
-
301
- 已经用 vue-i18n 的项目不要再装第二个实例,把内置词条合并进自己的实例即可:
302
-
303
- ```ts
304
- import { caMessages } from '@campus-admin/ui'
158
+ Notifications offer success / info / warning / error just like toasts. When several notifications fire in the same tick, the base library's updateOffsets is called after mounting to lay them out again, so they do not overlap when the initial height is 0. The second argument passes notification options through (message and type are set by the method); the default title is read from the `campus.notify.*` messages in both languages, and the returned instance has `close()`.
305
159
 
306
- i18n.global.mergeLocaleMessage('zh-CN', caMessages['zh-CN'])
307
- i18n.global.mergeLocaleMessage('en-US', caMessages['en-US'])
308
- ```
309
-
310
- 完整约定(命名空间、覆盖组件文案、后端文案对接、加语言)见
311
- [Campus Admin 国际化使用指南](../../docs/Campus-Admin-国际化使用指南.md)。
312
-
313
- ### 类名约定
314
-
315
- ```text
316
- 块 .ca-button
317
- 元素 .ca-button__icon
318
- 修饰符 .ca-button--primary
319
- ```
320
-
321
- 组件样式是统一 `ca-` 前缀的 BEM 类名,**只有 Token 是稳定的公共契约**,类名不作为 API。
322
- 业务侧换肤请覆盖变量,不要写深层选择器。
323
-
324
- ## 开发约定
325
-
326
- 三层目录结构(`atom` / `base` / `feature`),每个组件目录结构统一:
327
-
328
- ```text
329
- src/<层>/<组件名>/
330
- ├── src/core.ts 纯逻辑,不依赖 Vue(可单测)
331
- ├── src/data.ts 演示数据(可选)
332
- ├── src/<组件名>.vue 只做渲染
333
- ├── style/index.css 样式,由 .vue 通过 `<style src="../style/index.css">` 引入
334
- └── index.ts 导出 Ca 前缀组件与公开类型
160
+ ```vue
161
+ <div id="panel" v-ca-loading="busy">Area being loaded</div>
162
+ <div v-ca-infinite-scroll="loadMore"
163
+ :infinite-scroll-disabled="finished || busy"
164
+ :infinite-scroll-immediate="false"
165
+ style="height: 240px; overflow: auto">
166
+ <!-- list content -->
167
+ </div>
335
168
  ```
336
169
 
337
- 新增组件只需要改两处:组件自己的目录 + 所属层的 `index.ts`(加入命名导出与注册表)。
338
- 顶层 `builtInComponents` 由三层合并,`@campus-admin/core` 会自动纳入全局注册表。
339
-
340
- ## 设计要求
341
-
342
- - **组件不访问接口**。数据用 Props 传入,操作通过 Events 抛出。
343
- - **不写死颜色**。任何颜色都必须来自 `--ca-*` Token,否则暗色主题与品牌换色会失效。
344
- - 主色实心背景上的文字用 `--ca-color-primary-contrast`,保证浅色品牌色下仍可读。
345
- - 所有 ID 使用字符串,避免后端大整数在 JavaScript 中丢失精度。
346
- - 覆盖默认、Hover、Focus、Disabled、Loading、Empty、Error 等状态。
347
- - 弹层类组件需处理 Esc 关闭、焦点锁定、关闭后焦点恢复。
348
- - 组件卸载时清理事件、计时器、Observer。
349
-
350
- ## 相关包
351
-
352
- | 包 | 关系 |
353
- | --- | --- |
354
- | [`@campus-admin/locale`](../locale) | 被本包依赖,组件通过它取词与格式化 |
355
- | [`@campus-admin/core`](../core) | 依赖本包并统一出口 |
356
-
357
- ## 版权
358
-
359
- 使用本项目时请保留版权信息(MIT 许可要求随副本保留版权声明):
360
-
361
- - 保留包内的 `LICENSE` 文件与版权声明;
362
- - 保留页面页脚中的「Powered By 众校通 ®」与联系方式(示例用 `Copyright` 组件统一渲染);
363
- - 二次分发或修改后的版本,请在显著位置保留同样的版权声明。
364
-
365
- ---
366
-
367
- Powered By 众校通 ®
170
+ The directives are registered automatically by `installUi`, which `createCampusApp` calls. Element Plus 2.14.7 warns that the infinite-scroll directive is deprecated in 3.0; this round keeps it to match the installed version and requirements, and it will be migrated when the base library's major version is upgraded. Infinite-scroll props match the base library; with async data the caller must prevent duplicate requests using busy / finished.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 校园场景:校园卡(一卡通)相关的封装组件。
3
+ *
4
+ * 现在还没有组件:按“业务组件沉淀”的流程,先在平台里实现,复用时再抽离到这里。
5
+ * 新增组件时:在本目录下建 <组件名>/Ca<名字>.vue,导出并加入下面的注册表;
6
+ * 标签名统一 <ca-名字>(不带 campus/card 这类目录名),组件名必须全局唯一。
7
+ * 依赖方向:可以使用 ../../components 里的通用组件,通用组件不能反过来依赖这里。
8
+ */
9
+ export declare const cardComponents: {};
@@ -0,0 +1,7 @@
1
+ export * from './card/index.js';
2
+ export * from './parent/index.js';
3
+ export * from './student/index.js';
4
+ export * from './teacher/index.js';
5
+ export * from './tel/index.js';
6
+ /** 校园场景的组件注册表:各场景合并而成,组件名重复会直接报错 */
7
+ export declare const campusRegistry: {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 校园场景:家长相关的封装组件。
3
+ *
4
+ * 现在还没有组件:按“业务组件沉淀”的流程,先在平台里实现,复用时再抽离到这里。
5
+ * 新增组件时:在本目录下建 <组件名>/Ca<名字>.vue,导出并加入下面的注册表;
6
+ * 标签名统一 <ca-名字>(不带 campus/parent 这类目录名),组件名必须全局唯一。
7
+ * 依赖方向:可以使用 ../../components 里的通用组件,通用组件不能反过来依赖这里。
8
+ */
9
+ export declare const parentComponents: {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 校园场景:学生相关的封装组件。
3
+ *
4
+ * 现在还没有组件:按“业务组件沉淀”的流程,先在平台里实现,复用时再抽离到这里。
5
+ * 新增组件时:在本目录下建 <组件名>/Ca<名字>.vue,导出并加入下面的注册表;
6
+ * 标签名统一 <ca-名字>(不带 campus/student 这类目录名),组件名必须全局唯一。
7
+ * 依赖方向:可以使用 ../../components 里的通用组件,通用组件不能反过来依赖这里。
8
+ */
9
+ export declare const studentComponents: {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 校园场景:教师相关的封装组件。
3
+ *
4
+ * 现在还没有组件:按“业务组件沉淀”的流程,先在平台里实现,复用时再抽离到这里。
5
+ * 新增组件时:在本目录下建 <组件名>/Ca<名字>.vue,导出并加入下面的注册表;
6
+ * 标签名统一 <ca-名字>(不带 campus/teacher 这类目录名),组件名必须全局唯一。
7
+ * 依赖方向:可以使用 ../../components 里的通用组件,通用组件不能反过来依赖这里。
8
+ */
9
+ export declare const teacherComponents: {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 校园场景:校园电话(通话记录、亲情号码等)相关的封装组件。
3
+ *
4
+ * 现在还没有组件:按“业务组件沉淀”的流程,先在平台里实现,复用时再抽离到这里。
5
+ * 新增组件时:在本目录下建 <组件名>/Ca<名字>.vue,导出并加入下面的注册表;
6
+ * 标签名统一 <ca-名字>(不带 campus/tel 这类目录名),组件名必须全局唯一。
7
+ * 依赖方向:可以使用 ../../components 里的通用组件,通用组件不能反过来依赖这里。
8
+ */
9
+ export declare const telComponents: {};
@@ -1,13 +1,10 @@
1
+ import { type IconName } from './icons.js';
1
2
  type __VLS_Props = {
2
- title?: string;
3
- description?: string;
4
- size?: 'small' | 'medium';
3
+ name?: IconName;
5
4
  };
6
- declare var __VLS_1: {}, __VLS_8: {};
5
+ declare var __VLS_12: {};
7
6
  type __VLS_Slots = {} & {
8
- icon?: (props: typeof __VLS_1) => any;
9
- } & {
10
- default?: (props: typeof __VLS_8) => any;
7
+ default?: (props: typeof __VLS_12) => any;
11
8
  };
12
9
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
10
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -0,0 +1,15 @@
1
+ declare var __VLS_7: {}, __VLS_9: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_7) => any;
4
+ } & {
5
+ default?: (props: typeof __VLS_9) => any;
6
+ };
7
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
11
+ type __VLS_WithSlots<T, S> = T & {
12
+ new (): {
13
+ $slots: S;
14
+ };
15
+ };