@endfield-ui/react 0.0.0-stage → 0.2.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 (240) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +27 -0
  3. package/README.md +818 -2
  4. package/dist/index.d.ts +3445 -0
  5. package/dist/index.js +8706 -0
  6. package/dist/styles.css +2 -0
  7. package/package.json +83 -3
  8. package/src/components/README.md +179 -0
  9. package/src/components/accordion/Accordion.tsx +168 -0
  10. package/src/components/accordion/index.ts +8 -0
  11. package/src/components/alert/Alert.tsx +106 -0
  12. package/src/components/alert/index.ts +1 -0
  13. package/src/components/avatar/Avatar.tsx +92 -0
  14. package/src/components/avatar/AvatarSwitcher.tsx +261 -0
  15. package/src/components/avatar/index.ts +8 -0
  16. package/src/components/back-to-top/BackToTop.tsx +124 -0
  17. package/src/components/back-to-top/index.ts +5 -0
  18. package/src/components/badge/Badge.tsx +75 -0
  19. package/src/components/badge/index.ts +1 -0
  20. package/src/components/bracket-title/BracketTitle.tsx +40 -0
  21. package/src/components/bracket-title/index.ts +1 -0
  22. package/src/components/breadcrumb/Breadcrumb.tsx +161 -0
  23. package/src/components/breadcrumb/index.ts +6 -0
  24. package/src/components/button/Button.tsx +357 -0
  25. package/src/components/button/ButtonGroup.tsx +55 -0
  26. package/src/components/button/index.ts +13 -0
  27. package/src/components/calendar/Calendar.tsx +443 -0
  28. package/src/components/calendar/index.ts +7 -0
  29. package/src/components/carousel/Carousel.tsx +252 -0
  30. package/src/components/carousel/index.ts +7 -0
  31. package/src/components/carousel/snap-track.ts +74 -0
  32. package/src/components/checkbox/Checkbox.tsx +94 -0
  33. package/src/components/checkbox/choice-style.ts +30 -0
  34. package/src/components/checkbox/index.ts +1 -0
  35. package/src/components/chip/FilterChip.tsx +68 -0
  36. package/src/components/chip/ResourceChip.tsx +63 -0
  37. package/src/components/chip/capsule-style.ts +22 -0
  38. package/src/components/chip/index.ts +6 -0
  39. package/src/components/combobox/Combobox.tsx +450 -0
  40. package/src/components/combobox/index.ts +10 -0
  41. package/src/components/completion-banner/CompletionBanner.tsx +72 -0
  42. package/src/components/completion-banner/index.ts +4 -0
  43. package/src/components/context-menu/ContextMenu.tsx +70 -0
  44. package/src/components/context-menu/index.ts +5 -0
  45. package/src/components/corner-brackets/CornerBrackets.tsx +43 -0
  46. package/src/components/corner-brackets/index.ts +5 -0
  47. package/src/components/countdown/Countdown.tsx +145 -0
  48. package/src/components/countdown/index.ts +6 -0
  49. package/src/components/dash-indicator/DashIndicator.tsx +44 -0
  50. package/src/components/dash-indicator/index.ts +1 -0
  51. package/src/components/data-row/DataRow.tsx +282 -0
  52. package/src/components/data-row/index.ts +8 -0
  53. package/src/components/date-picker/DateField.tsx +159 -0
  54. package/src/components/date-picker/DatePicker.tsx +182 -0
  55. package/src/components/date-picker/DateRangePicker.tsx +203 -0
  56. package/src/components/date-picker/index.ts +7 -0
  57. package/src/components/dialog/Dialog.tsx +203 -0
  58. package/src/components/dialog/index.ts +7 -0
  59. package/src/components/dialog/initial-focus.ts +19 -0
  60. package/src/components/dialog/overlay-style.ts +28 -0
  61. package/src/components/drawer/Drawer.tsx +213 -0
  62. package/src/components/drawer/index.ts +6 -0
  63. package/src/components/dropdown-menu/DropdownMenu.tsx +427 -0
  64. package/src/components/dropdown-menu/MenuCheck.tsx +44 -0
  65. package/src/components/dropdown-menu/index.ts +22 -0
  66. package/src/components/dropdown-menu/menu-style.ts +47 -0
  67. package/src/components/empty-state/EmptyState.tsx +79 -0
  68. package/src/components/empty-state/index.ts +1 -0
  69. package/src/components/field/Field.tsx +203 -0
  70. package/src/components/field/index.ts +6 -0
  71. package/src/components/file-upload/FileItem.tsx +201 -0
  72. package/src/components/file-upload/FileUpload.tsx +425 -0
  73. package/src/components/file-upload/index.ts +9 -0
  74. package/src/components/flyout-bar/FlyoutBar.tsx +158 -0
  75. package/src/components/flyout-bar/index.ts +7 -0
  76. package/src/components/ghost-text/GhostText.tsx +47 -0
  77. package/src/components/ghost-text/index.ts +5 -0
  78. package/src/components/hatch/Hatch.tsx +35 -0
  79. package/src/components/hatch/index.ts +1 -0
  80. package/src/components/hazard-stripe/HazardStripe.tsx +35 -0
  81. package/src/components/hazard-stripe/index.ts +5 -0
  82. package/src/components/hover-card/HoverCard.tsx +101 -0
  83. package/src/components/hover-card/index.ts +6 -0
  84. package/src/components/icon-button/IconButton.tsx +95 -0
  85. package/src/components/icon-button/index.ts +6 -0
  86. package/src/components/image-viewer/ImageViewer.tsx +427 -0
  87. package/src/components/image-viewer/index.ts +7 -0
  88. package/src/components/input/Input.tsx +109 -0
  89. package/src/components/input/control-box.ts +71 -0
  90. package/src/components/input/index.ts +6 -0
  91. package/src/components/input/value-chip.ts +34 -0
  92. package/src/components/item-slot/ItemGrid.tsx +207 -0
  93. package/src/components/item-slot/ItemSlot.tsx +284 -0
  94. package/src/components/item-slot/index.ts +7 -0
  95. package/src/components/kbd/Kbd.tsx +33 -0
  96. package/src/components/kbd/index.ts +1 -0
  97. package/src/components/link-element/LinkElement.tsx +25 -0
  98. package/src/components/list/List.tsx +229 -0
  99. package/src/components/list/band-style.ts +18 -0
  100. package/src/components/list/index.ts +8 -0
  101. package/src/components/loader/Loader.tsx +154 -0
  102. package/src/components/loader/index.ts +1 -0
  103. package/src/components/marquee/Marquee.tsx +96 -0
  104. package/src/components/marquee/index.ts +1 -0
  105. package/src/components/media-card/MediaCard.tsx +139 -0
  106. package/src/components/media-card/index.ts +5 -0
  107. package/src/components/nav-action/NavAction.tsx +142 -0
  108. package/src/components/nav-action/index.ts +5 -0
  109. package/src/components/nav-menu/NavMenu.tsx +288 -0
  110. package/src/components/nav-menu/index.ts +6 -0
  111. package/src/components/navigator/Navigator.tsx +136 -0
  112. package/src/components/navigator/index.ts +5 -0
  113. package/src/components/otp-input/OtpInput.tsx +211 -0
  114. package/src/components/otp-input/index.ts +7 -0
  115. package/src/components/page-header/PageHeader.tsx +182 -0
  116. package/src/components/page-header/index.ts +6 -0
  117. package/src/components/pagination/Pagination.tsx +181 -0
  118. package/src/components/pagination/index.ts +5 -0
  119. package/src/components/panel/Panel.tsx +114 -0
  120. package/src/components/panel/index.ts +13 -0
  121. package/src/components/play-button/PlayButton.tsx +92 -0
  122. package/src/components/play-button/index.ts +7 -0
  123. package/src/components/popover/Popover.tsx +97 -0
  124. package/src/components/popover/index.ts +8 -0
  125. package/src/components/popover/panel-style.ts +15 -0
  126. package/src/components/progress/Progress.tsx +133 -0
  127. package/src/components/progress/ProgressRing.tsx +123 -0
  128. package/src/components/progress/index.ts +2 -0
  129. package/src/components/radio/Radio.tsx +182 -0
  130. package/src/components/radio/index.ts +7 -0
  131. package/src/components/rec-indicator/RecIndicator.tsx +47 -0
  132. package/src/components/rec-indicator/index.ts +1 -0
  133. package/src/components/registration-strip/RegistrationStrip.tsx +51 -0
  134. package/src/components/registration-strip/index.ts +5 -0
  135. package/src/components/schedule/Schedule.tsx +457 -0
  136. package/src/components/schedule/index.ts +9 -0
  137. package/src/components/scroll-area/ScrollArea.tsx +137 -0
  138. package/src/components/scroll-area/index.ts +5 -0
  139. package/src/components/scroll-hint/ScrollHint.tsx +78 -0
  140. package/src/components/scroll-hint/index.ts +5 -0
  141. package/src/components/section-title/SectionTitle.tsx +202 -0
  142. package/src/components/section-title/index.ts +5 -0
  143. package/src/components/segmented-control/SegmentedControl.tsx +220 -0
  144. package/src/components/segmented-control/index.ts +8 -0
  145. package/src/components/select/Select.tsx +390 -0
  146. package/src/components/select/index.ts +15 -0
  147. package/src/components/side-rail/SideRail.tsx +317 -0
  148. package/src/components/side-rail/SideRailSub.tsx +298 -0
  149. package/src/components/side-rail/index.ts +14 -0
  150. package/src/components/skeleton/Skeleton.tsx +70 -0
  151. package/src/components/skeleton/index.ts +1 -0
  152. package/src/components/slider/Slider.tsx +219 -0
  153. package/src/components/slider/index.ts +8 -0
  154. package/src/components/sparkline/Sparkline.tsx +122 -0
  155. package/src/components/sparkline/index.ts +6 -0
  156. package/src/components/spinner/Spinner.tsx +64 -0
  157. package/src/components/spinner/index.ts +1 -0
  158. package/src/components/stat/Stat.tsx +79 -0
  159. package/src/components/stat/index.ts +1 -0
  160. package/src/components/stepper/Stepper.tsx +316 -0
  161. package/src/components/stepper/index.ts +1 -0
  162. package/src/components/steps/Steps.tsx +302 -0
  163. package/src/components/steps/index.ts +10 -0
  164. package/src/components/switch/Switch.tsx +120 -0
  165. package/src/components/switch/index.ts +1 -0
  166. package/src/components/table/Table.tsx +560 -0
  167. package/src/components/table/index.ts +20 -0
  168. package/src/components/tabs/Tabs.tsx +313 -0
  169. package/src/components/tabs/index.ts +12 -0
  170. package/src/components/tag/Tag.tsx +66 -0
  171. package/src/components/tag/TagPair.tsx +34 -0
  172. package/src/components/tag/index.ts +2 -0
  173. package/src/components/tag-input/TagInput.tsx +502 -0
  174. package/src/components/tag-input/index.ts +8 -0
  175. package/src/components/term/Term.tsx +53 -0
  176. package/src/components/term/index.ts +1 -0
  177. package/src/components/textarea/Textarea.tsx +99 -0
  178. package/src/components/textarea/index.ts +1 -0
  179. package/src/components/texture/Texture.tsx +45 -0
  180. package/src/components/texture/index.ts +1 -0
  181. package/src/components/tick-ring/TickRing.tsx +77 -0
  182. package/src/components/tick-ring/index.ts +1 -0
  183. package/src/components/timeline/Timeline.tsx +84 -0
  184. package/src/components/timeline/index.ts +7 -0
  185. package/src/components/toast/Toast.tsx +257 -0
  186. package/src/components/toast/index.ts +10 -0
  187. package/src/components/toc/Toc.tsx +263 -0
  188. package/src/components/toc/index.ts +7 -0
  189. package/src/components/toolbar/Toolbar.tsx +389 -0
  190. package/src/components/toolbar/index.ts +17 -0
  191. package/src/components/tooltip/Tooltip.tsx +175 -0
  192. package/src/components/tooltip/index.ts +8 -0
  193. package/src/components/top-bar/TopBar.tsx +47 -0
  194. package/src/components/top-bar/index.ts +1 -0
  195. package/src/components/viewfinder/Viewfinder.tsx +97 -0
  196. package/src/components/viewfinder/index.ts +6 -0
  197. package/src/hooks/README.md +14 -0
  198. package/src/hooks/index.ts +4 -0
  199. package/src/hooks/useControllableState.ts +30 -0
  200. package/src/hooks/useInView.ts +44 -0
  201. package/src/hooks/useOverflowing.ts +28 -0
  202. package/src/hooks/usePortalScope.ts +68 -0
  203. package/src/hooks/useScrollPosition.ts +57 -0
  204. package/src/hooks/useTheme.ts +102 -0
  205. package/src/icons/ArrowCorner.tsx +7 -0
  206. package/src/icons/ArrowLeft.tsx +6 -0
  207. package/src/icons/ArrowRight.tsx +6 -0
  208. package/src/icons/CalendarIcon.tsx +10 -0
  209. package/src/icons/Check.tsx +4 -0
  210. package/src/icons/ChevronDown.tsx +3 -0
  211. package/src/icons/ChevronLeft.tsx +6 -0
  212. package/src/icons/ChevronRight.tsx +6 -0
  213. package/src/icons/Close.tsx +3 -0
  214. package/src/icons/Crosshair.tsx +7 -0
  215. package/src/icons/Lock.tsx +6 -0
  216. package/src/icons/Menu.tsx +4 -0
  217. package/src/icons/Minus.tsx +4 -0
  218. package/src/icons/Plus.tsx +3 -0
  219. package/src/icons/README.md +31 -0
  220. package/src/icons/StatusDanger.tsx +7 -0
  221. package/src/icons/StatusInfo.tsx +7 -0
  222. package/src/icons/StatusSuccess.tsx +10 -0
  223. package/src/icons/StatusWarning.tsx +7 -0
  224. package/src/icons/TriangleRight.tsx +7 -0
  225. package/src/icons/Upload.tsx +7 -0
  226. package/src/icons/createIcon.tsx +34 -0
  227. package/src/icons/index.ts +21 -0
  228. package/src/index.ts +87 -0
  229. package/src/lib/README.md +17 -0
  230. package/src/lib/cn.ts +34 -0
  231. package/src/lib/date.ts +125 -0
  232. package/src/lib/decor.ts +6 -0
  233. package/src/lib/defined.ts +9 -0
  234. package/src/lib/file.ts +61 -0
  235. package/src/lib/focus-ring.ts +11 -0
  236. package/src/lib/merge-refs.ts +11 -0
  237. package/src/styles/README.md +70 -0
  238. package/src/styles/index.css +25 -0
  239. package/src/styles/theme.css +568 -0
  240. package/src/styles/utilities.css +241 -0
@@ -0,0 +1,61 @@
1
+ /** 文件的纯函数:按 `accept` 认类型、把字节数写成人读的大小。`FileUpload` 用,不对外导出 */
2
+
3
+ /**
4
+ * 这个文件合不合 `accept`。写法和原生的 `<input accept>` 一样,逗号分开:
5
+ * `.pdf`(扩展名)、`image/*`(一类)、`text/plain`(一种)。不分大小写;没写就是都行。
6
+ */
7
+ export function matchesAccept(
8
+ file: { name: string; type: string },
9
+ accept: string | undefined,
10
+ ): boolean {
11
+ const rules = (accept ?? "")
12
+ .split(",")
13
+ .map((rule) => rule.trim().toLowerCase())
14
+ .filter(Boolean);
15
+ if (rules.length === 0) return true;
16
+
17
+ const name = file.name.toLowerCase();
18
+ const type = file.type.toLowerCase();
19
+ return rules.some((rule) => {
20
+ if (rule.startsWith(".")) return name.endsWith(rule);
21
+ if (rule.endsWith("/*")) return type.startsWith(rule.slice(0, -1));
22
+ return type === rule;
23
+ });
24
+ }
25
+
26
+ const UNITS = ["B", "KB", "MB", "GB", "TB"];
27
+
28
+ /**
29
+ * 字节数写成 `1.2 MB`:按 1024 进位;不到 100 的留一位小数(`.0` 不写),再大就取整。
30
+ * 字节不带小数。
31
+ */
32
+ export function formatFileSize(bytes: number): string {
33
+ if (!Number.isFinite(bytes) || bytes < 0) return "";
34
+ let value = bytes;
35
+ let unit = 0;
36
+ const round = () =>
37
+ unit === 0 || value >= 100
38
+ ? Math.round(value)
39
+ : Math.round(value * 10) / 10;
40
+
41
+ while (unit < UNITS.length - 1 && round() >= 1024) {
42
+ value /= 1024;
43
+ unit += 1;
44
+ }
45
+ return `${round()} ${UNITS[unit]}`;
46
+ }
47
+
48
+ /** 扩展名,大写、不带点:`report.final.PDF` → `PDF`。没有、或者长得不像扩展名时是空的 */
49
+ export function fileExtension(name: string): string {
50
+ const dot = name.lastIndexOf(".");
51
+ if (dot <= 0 || dot === name.length - 1) return "";
52
+ const extension = name.slice(dot + 1);
53
+ return /^[a-z0-9]{1,5}$/i.test(extension) ? extension.toUpperCase() : "";
54
+ }
55
+
56
+ /** 是不是同一个文件:名字、大小、修改时间都一样 */
57
+ export function sameFile(a: File, b: File): boolean {
58
+ return (
59
+ a.name === b.name && a.size === b.size && a.lastModified === b.lastModified
60
+ );
61
+ }
@@ -0,0 +1,11 @@
1
+ /** 2px `focus` 色的环,与元素间隔 2px;仅键盘聚焦时出现。 */
2
+ export const focusRing =
3
+ "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus";
4
+
5
+ /** 画在元素内侧的焦点环,用在会被滚动容器裁切的地方。 */
6
+ export const focusRingInset =
7
+ "focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus";
8
+
9
+ /** 外框自己不能聚焦、里面的控件能:控件聚焦时把环画在外框上(输入框)。 */
10
+ export const focusRingWithin =
11
+ "has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-focus";
@@ -0,0 +1,11 @@
1
+ import type { Ref, RefCallback } from "react";
2
+
3
+ /** 把几个 ref 合成一个:组件自己要用节点,同时还得把它交给使用方。 */
4
+ export function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): RefCallback<T> {
5
+ return (node) => {
6
+ for (const ref of refs) {
7
+ if (typeof ref === "function") ref(node);
8
+ else if (ref) ref.current = node;
9
+ }
10
+ };
11
+ }
@@ -0,0 +1,70 @@
1
+ # styles
2
+
3
+ | 文件 | 内容 |
4
+ | --- | --- |
5
+ | [theme.css](theme.css) | 设计令牌:语义变量(亮 / 暗)+ Tailwind v4 `@theme` 映射 |
6
+ | [utilities.css](utilities.css) | `@utility`:母题工具类(斜纹、切角、斜楔、角括号、镂空字、警示条纹、竖条变箭头),以及菱形表单符号的开关 |
7
+ | [index.css](index.css) | 入口:`tailwindcss` → `theme.css` → `utilities.css` → 基础样式 → `@source` |
8
+
9
+ 对外的三个入口(见包的 `exports`):
10
+
11
+ | 引入路径 | 对应 | 给谁用 |
12
+ | --- | --- | --- |
13
+ | `@endfield-ui/react/tailwind.css` | `index.css` | 用 Tailwind v4 的项目,代替 `@import "tailwindcss"` |
14
+ | `@endfield-ui/react/styles.css` | `dist/styles.css` | 不用 Tailwind 的项目,预编译产物 |
15
+ | `@endfield-ui/react/theme.css` | `theme.css` | 只要令牌、不要组件 |
16
+
17
+ ## theme.css 的结构
18
+
19
+ 1. **语义变量**:亮色定义在 `:root` 与 `[data-theme="light"]`(对齐官网的纸白基底),`[data-theme="dark"]` 覆盖为暗色(对齐游戏 HUD 与官网深色版块)。两种取值都可以加在局部容器上。
20
+ - `[data-theme="inverse"]` 是"和所在主题相反",给反转块(标题带、表头带)用:底和字取所在主题的 `surface-inverse` / `ink-inverse`,其余取相反主题的值。亮、暗两块里的 `--ef-x-*` 就是给它准备的那份"相反主题的取值",**改亮、暗任何一个值时要把另一块里对应的 `--ef-x-*` 一起改**——[theme.test.ts](theme.test.ts) 会核对。
21
+ 2. **`@theme`**:不随主题变化的原始令牌——色板、字体、字阶、圆角、阴影、缓动、动画、切角尺寸(`--cut-sm` / `md` / `lg`),以及层叠值(`--z-float` 100、`--z-nav` 200、`--z-overlay` 300、`--z-toast` 400、`--z-loader` 1000,用法是 `z-(--z-overlay)`)。
22
+ 3. **`@theme inline`**:把第 1 步的语义变量映射成 Tailwind 颜色,生成 `bg-surface`、`text-ink`、`border-line` 这类工具类。
23
+
24
+ ## 只用令牌
25
+
26
+ ```css
27
+ @import "tailwindcss";
28
+ @import "@endfield-ui/react/theme.css";
29
+ ```
30
+
31
+ ```html
32
+ <html data-theme="dark">
33
+ <button class="bg-action text-on-action font-sans text-lg">前往游戏</button>
34
+ </html>
35
+ ```
36
+
37
+ ## 修改令牌
38
+
39
+ 令牌值的依据写在 [docs/design/foundations](../../../../docs/design/foundations/color.md)。改动任何一个值时,同步改对应文档里的表格;文档里每个值都标了来源等级(实测 / 观察 / 社区 / 推断),替换"社区"和"推断"级别的值时请在文档里写明新的依据。
40
+
41
+ 新增或改名自定义的字阶、阴影、缓动、动画、字距令牌时,还要同步 [lib/cn.ts](../lib/cn.ts) 里登记给 `tailwind-merge` 的清单,否则 `cn()` 会把它们归错类。
42
+
43
+ ## 母题工具类
44
+
45
+ | 工具类 | 作用 | 可调的变量 |
46
+ | --- | --- | --- |
47
+ | `hatch`,加 `hatch-mid` / `hatch-fine` | 45° 斜纹的粗、中、细三档 | `--hatch-color`、`--hatch-width` |
48
+ | `hazard` | 黄黑警示条纹 | `--hazard-size` |
49
+ | `cut-tr`、`cut-br`、`cut-diagonal`,加 `cut-sm` / `cut-md` / `cut-lg` | 切角与切口大小 | `--cut` |
50
+ | `wedge`、`wedge-l`、`wedge-r` | 两侧 / 单侧斜切 | `--wedge` |
51
+ | `corner-brackets` | 四角的 L 形短线,画在 `::after` 上 | `--bracket-color`、`--bracket-arm`、`--bracket-width`、`--bracket-offset` |
52
+ | `ghost-hatch`、`ghost-outline` | 镂空字的斜纹与描边两种画法 | `--ghost-ink` |
53
+ | `dot-grid` | 点阵底纹 | `--dot-color`、`--dot-size`、`--dot-gap` |
54
+ | `blueprint-grid` | 工程网格底纹 | `--grid-color`、`--grid-gap` |
55
+ | `contour` | 等高线底纹,贴在右下角、朝左上淡出 | `--contour-color`、`--contour-size`、`--contour-position`、`--contour-image` |
56
+ | `marker-bar`、`marker-arrow` | 按钮里竖条变箭头的两个形状 | `--marker-bar` |
57
+
58
+ - 跟着主题走的颜色(斜纹、角括号、镂空字、三种底纹)默认取 `--ef-ink`;警示条纹和斜纹的"中"档有意不随主题变。
59
+ - `cut-*` 与 `wedge*` 用的是 `clip-path`,会把焦点环一起裁掉。可聚焦的元素把它们写在伪元素上:`before:cut-tr before:bg-action`。
60
+ - `corner-brackets` 不替宿主设 `position`,宿主自己要是 `relative` 或 `absolute`。
61
+ - `contour` 是遮罩(`mask-image`),会把元素自己的内容一起遮掉:只能写在空的装饰层上。`dot-grid` 和 `blueprint-grid` 是背景,没有这个限制,但同样建议画在独立的装饰层上。
62
+ - 镂空字不叫 `text-hatch`:`text-*` 是字号和文字颜色的名字空间,`cn()` 合并类名时会把它当成颜色。
63
+
64
+ 这些类只画形状。什么东西可以切角、哪里能放斜纹,见 [docs/design/elements](../../../../docs/design/elements/corner-and-wedge.md) 各篇的"什么时候用"。预编译的 `styles.css` 里只有组件自己用到的那几个;不用 Tailwind 的项目用对应的装饰组件。
65
+
66
+ 文件末尾还有一个自定义变体 `choice-diamond:`,在祖先带 `data-choice="diamond"` 时生效,复选与单选靠它整体换成菱形符号。
67
+
68
+ ## 注意
69
+
70
+ `index.css` 里的 `@source "../"` 扫的是整个 `src`,不能缩成只扫 `components`:焦点环这类共用的类名写在 `lib` 里,扫不到就不会生成。
@@ -0,0 +1,25 @@
1
+ /*
2
+ * endfield-ui 样式入口
3
+ *
4
+ * 已经在用 Tailwind CSS v4 的项目,用它代替 `@import "tailwindcss"`:
5
+ * @import "@endfield-ui/react/tailwind.css";
6
+ *
7
+ * 不用 Tailwind 的项目,引入预编译好的 `@endfield-ui/react/styles.css`。
8
+ */
9
+
10
+ @import "tailwindcss";
11
+ @import "./theme.css";
12
+ @import "./utilities.css";
13
+
14
+ /*
15
+ * 让 Tailwind 扫到本包用到的类名。要扫整个 src,不能只扫 components:
16
+ * 焦点环这类共用的类名写在 lib 里。
17
+ */
18
+ @source "../";
19
+
20
+ @layer base {
21
+ body {
22
+ background-color: var(--ef-surface);
23
+ color: var(--ef-ink);
24
+ }
25
+ }