clxx 3.0.1 → 3.0.4
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.
- package/AGENTS.md +49 -3
- package/README.md +6 -3
- package/build/Alert/style.js +15 -14
- package/build/CarouselNotice/style.js +2 -1
- package/build/CitySelect/data.d.ts +1 -1
- package/build/CitySelect/data.js +2277 -1674
- package/build/CitySelect/index.d.ts +2 -1
- package/build/CitySelect/index.js +35 -9
- package/build/CitySelect/style.js +52 -48
- package/build/Container/index.js +21 -1
- package/build/DatePicker/style.d.ts +1 -1
- package/build/DatePicker/style.js +39 -35
- package/build/Indicator/index.js +2 -1
- package/build/Loading/Wrapper.js +3 -2
- package/build/Loading/style.js +7 -6
- package/build/MapLocationSelection/buildSelectedLocation.d.ts +16 -0
- package/build/MapLocationSelection/buildSelectedLocation.js +123 -0
- package/build/MapLocationSelection/createProvider.d.ts +8 -0
- package/build/MapLocationSelection/createProvider.js +33 -0
- package/build/MapLocationSelection/getLocation.d.ts +8 -0
- package/build/MapLocationSelection/getLocation.js +112 -0
- package/build/MapLocationSelection/index.d.ts +16 -0
- package/build/MapLocationSelection/index.js +985 -0
- package/build/MapLocationSelection/loader.amap.d.ts +48 -0
- package/build/MapLocationSelection/loader.amap.js +125 -0
- package/build/MapLocationSelection/loader.bmap.d.ts +8 -0
- package/build/MapLocationSelection/loader.bmap.js +60 -0
- package/build/MapLocationSelection/provider.amap.d.ts +38 -0
- package/build/MapLocationSelection/provider.amap.js +659 -0
- package/build/MapLocationSelection/provider.bmap.d.ts +36 -0
- package/build/MapLocationSelection/provider.bmap.js +837 -0
- package/build/MapLocationSelection/provider.d.ts +45 -0
- package/build/MapLocationSelection/provider.js +10 -0
- package/build/MapLocationSelection/style.d.ts +4 -0
- package/build/MapLocationSelection/style.js +442 -0
- package/build/MapLocationSelection/types.d.ts +29 -0
- package/build/MapLocationSelection/types.js +22 -0
- package/build/MapLocationSelection/userMarker.d.ts +2 -0
- package/build/MapLocationSelection/userMarker.js +95 -0
- package/build/RegionPicker/data.js +974 -992
- package/build/RegionPicker/index.d.ts +3 -2
- package/build/RegionPicker/index.js +29 -10
- package/build/RegionPicker/style.js +54 -49
- package/build/ScrollView/style.js +5 -4
- package/build/Toast/style.js +6 -5
- package/build/index.d.ts +3 -0
- package/build/index.js +8 -2
- package/build/utils/rem.d.ts +1 -0
- package/build/utils/rem.js +48 -0
- package/package.json +2 -2
- package/test/src/city-select/index.jsx +28 -15
- package/test/src/index/index.jsx +5 -0
- package/test/src/index.jsx +1 -0
- package/test/src/map-location-selection/index.jsx +192 -0
- package/test/src/region-picker/index.jsx +29 -21
package/AGENTS.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
本仓库是面向移动端 H5 的基础组件库 `clxx`(React 19 + TypeScript + @emotion/react),以下规则对所有 AI Agent 在本工程内的工作均有效。
|
|
4
|
+
|
|
5
|
+
## 1. 沟通约定
|
|
6
|
+
|
|
7
|
+
- 所有回复使用中文。
|
|
8
|
+
- 不主动 push 到远程;除非用户显式要求,否则只做本地改动。
|
|
9
|
+
- 任务执行完成后,需自检产物:不允许遗留报错(编译 / 类型 / Lint),除非用户主动要求保留。
|
|
10
|
+
|
|
11
|
+
## 2. 项目结构
|
|
12
|
+
|
|
13
|
+
- `src/`:组件库源码,按 PascalCase 目录组织,每个组件一个目录(如 `Toast/`、`MapLocationSelection/`)。
|
|
14
|
+
- 目录内常见文件:`index.tsx`(导出入口)、`style.ts`(emotion 样式)、子组件 `*.tsx`。
|
|
15
|
+
- `src/Effect/` 存放自定义 hooks,`src/utils/` 存放无 React 依赖的工具函数。
|
|
16
|
+
- 对外导出统一在 `src/index.ts` 维护。
|
|
17
|
+
- `test/`:基于 Vite 的本地预览工程,**只用于演示与人工验证 `src/` 下的组件**,不得承载业务逻辑。
|
|
18
|
+
- 子目录使用 kebab-case(如 `map-location-selection/`),与 `src` 下的 PascalCase 目录一一对应。
|
|
19
|
+
|
|
20
|
+
## 3. 代码规范
|
|
21
|
+
|
|
22
|
+
- **一个文件只允许导出一个 React 组件**;同一文件内的辅助子组件必须拆分到独立文件。
|
|
23
|
+
- 组件文件使用 `.tsx`,纯逻辑 / 类型 / 工具使用 `.ts`。
|
|
24
|
+
- 样式优先使用 `@emotion/react`,写在同目录的 `style.ts` 中;避免引入新的 CSS-in-JS 方案。
|
|
25
|
+
- 公共依赖:`react@^19`、`@emotion/react`、`dayjs`、`lodash`、`history`;新增第三方依赖前先确认是否已有等价能力。
|
|
26
|
+
- TypeScript 严格类型:禁止用 `any` 屏蔽类型问题;导出的 props/类型放在组件文件顶部并显式 `export`。
|
|
27
|
+
- 注释只解释「为什么」与不易看出的约束,禁止逐行翻译代码。
|
|
28
|
+
|
|
29
|
+
## 4. Container 约束(强制)
|
|
30
|
+
|
|
31
|
+
本库所有组件的 `rem` 自适应、最大宽度居中、CSS 变量 `--clxx-max-width` 等能力均由 `src/Container` 提供。
|
|
32
|
+
|
|
33
|
+
- 任何使用本库的页面 / Demo / 测试入口,**必须把 `Container` 作为根组件**包裹其它组件,否则尺寸会失真。
|
|
34
|
+
- 修改 `Container` 时需同时验证 `Overlay`、`Fixed`、弹窗类组件(`Dialog`、`Toast`、`Alert`、`Loading`、`*Picker` 等)在 PC 端居中与最大宽度限制下的表现。
|
|
35
|
+
|
|
36
|
+
## 5. 测试与本地运行
|
|
37
|
+
|
|
38
|
+
- `test/` 工程:`cd test && npm run dev` 启动本地预览。
|
|
39
|
+
- 库本身:`npm run dev`(tsc watch)/ `npm run build`(清理后产出到 `build/`)。
|
|
40
|
+
- 新增 / 修改组件时,应在 `test/src/<对应目录>/` 下补充或更新最小可运行 Demo。
|
|
41
|
+
- 临时为调试创建、与正常逻辑无关的测试文件 / 代码,**任务完成前必须删除**。
|
|
42
|
+
|
|
43
|
+
## 6. 质量门禁
|
|
44
|
+
|
|
45
|
+
- 任何修改完成后,先自检:
|
|
46
|
+
1. 是否引入新 bug 或破坏既有用例;如有,**必须修复**。
|
|
47
|
+
2. 是否影响公共导出(`src/index.ts`)的兼容性。
|
|
48
|
+
3. 是否在 `Container` 之外破坏了自适应行为。
|
|
49
|
+
- 涉及 `peerDependencies`(React/ReactDOM)相关 API 的改动,需确保仍兼容 React 19。
|
package/README.md
CHANGED
|
@@ -481,6 +481,7 @@ showCitySelect({
|
|
|
481
481
|
| `onLetterChange` | `(letter: string) => void` | — | 侧边栏当前字母变化回调 |
|
|
482
482
|
| `getLocation` | `() => string \| null \| undefined \| Promise<string \| null \| undefined>` | — | 外部定位能力,可同步或异步,返回城市名或城市 code |
|
|
483
483
|
| `primary` | `string` | `'#2f7dff'` | 主题主色,形如 `#rrggbb`;active 态颜色自动派生 |
|
|
484
|
+
| `taiwanHKMacau` | `boolean` | `false` | 是否包含香港/澳门/台湾;false 时在列表、搜索与定位结果中均不出现 |
|
|
484
485
|
|
|
485
486
|
**SelectedCity:**
|
|
486
487
|
|
|
@@ -603,7 +604,8 @@ showRegionPicker({
|
|
|
603
604
|
| `maskClosable` | `boolean` | `true` | 点击遮罩是否可关闭(仅 `showRegionPicker` 路径生效) |
|
|
604
605
|
| `primary` | `string` | `'#2f7dff'` | 主题主色 |
|
|
605
606
|
| `rounded` | `boolean` | `true` | 顶部圆角 |
|
|
606
|
-
| `
|
|
607
|
+
| `taiwanHKMacau` | `boolean` | `false` | 是否包含香港/澳门/台湾;false 时这三个顶层省份不会出现在列表中 |
|
|
608
|
+
| `onConfirm` | `(selection: RegionSelection) => void` | — | 确认回调;选中的市无区级时选到市即可提交 |
|
|
607
609
|
| `onCancel` | `() => void` | — | 取消回调 |
|
|
608
610
|
| `onClose` | `() => void` | — | 请求关闭(由外部处理动画与卸载) |
|
|
609
611
|
|
|
@@ -617,14 +619,15 @@ interface RegionNode {
|
|
|
617
619
|
interface RegionSelection {
|
|
618
620
|
province: RegionNode;
|
|
619
621
|
city: RegionNode;
|
|
620
|
-
|
|
622
|
+
// 部分城市无区级时为 null
|
|
623
|
+
district: RegionNode | null;
|
|
621
624
|
}
|
|
622
625
|
```
|
|
623
626
|
|
|
624
627
|
**特性:**
|
|
625
628
|
- **tabs 联动**:选中后自动跳到下一级;切换上级会清空所有下级。
|
|
626
629
|
- **滚动定位**:切 tab 时把当前选中项对齐到列表顶部(用 `getBoundingClientRect` 差分计算偏移,不依赖 offsetParent)。
|
|
627
|
-
-
|
|
630
|
+
- **选择未完成时**:确认按钮置灰禁用;选中的市无区级时,选到市使可提交。
|
|
628
631
|
|
|
629
632
|
---
|
|
630
633
|
|
package/build/Alert/style.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.style = void 0;
|
|
4
4
|
const theme_1 = require("../utils/theme");
|
|
5
|
+
const rem_1 = require("../utils/rem");
|
|
5
6
|
// 1px 硬边框(高清屏 hairline)
|
|
6
7
|
const hairline = 1 / (typeof window !== "undefined" ? window.devicePixelRatio : 1);
|
|
7
8
|
// iOS 风色板
|
|
@@ -13,20 +14,20 @@ exports.style = {
|
|
|
13
14
|
position: "relative",
|
|
14
15
|
overflow: "hidden",
|
|
15
16
|
backgroundColor: "#ffffff",
|
|
16
|
-
borderRadius:
|
|
17
|
-
width: (750 * 0.78)
|
|
17
|
+
borderRadius: (0, rem_1.r)(28),
|
|
18
|
+
width: (0, rem_1.r)(750 * 0.78),
|
|
18
19
|
fontFamily: theme_1.fontStack,
|
|
19
20
|
color: textPrimary,
|
|
20
21
|
WebkitFontSmoothing: "antialiased",
|
|
21
22
|
MozOsxFontSmoothing: "grayscale",
|
|
22
|
-
boxShadow:
|
|
23
|
+
boxShadow: `0 ${(0, rem_1.r)(20)} ${(0, rem_1.r)(60)} rgba(0,0,0,.18)`,
|
|
23
24
|
},
|
|
24
25
|
content: {
|
|
25
26
|
position: "relative",
|
|
26
|
-
paddingTop:
|
|
27
|
-
paddingBottom:
|
|
28
|
-
paddingLeft:
|
|
29
|
-
paddingRight:
|
|
27
|
+
paddingTop: (0, rem_1.r)(40),
|
|
28
|
+
paddingBottom: (0, rem_1.r)(40),
|
|
29
|
+
paddingLeft: (0, rem_1.r)(36),
|
|
30
|
+
paddingRight: (0, rem_1.r)(36),
|
|
30
31
|
"&:after,&::after": {
|
|
31
32
|
content: "''",
|
|
32
33
|
position: "absolute",
|
|
@@ -43,21 +44,21 @@ exports.style = {
|
|
|
43
44
|
textAlign: "center",
|
|
44
45
|
lineHeight: 1.45,
|
|
45
46
|
color: textPrimary,
|
|
46
|
-
fontSize:
|
|
47
|
+
fontSize: (0, rem_1.r)(34),
|
|
47
48
|
fontWeight: 600,
|
|
48
|
-
letterSpacing:
|
|
49
|
+
letterSpacing: (0, rem_1.r)(1),
|
|
49
50
|
},
|
|
50
51
|
desc: {
|
|
51
52
|
textAlign: "center",
|
|
52
53
|
lineHeight: 1.55,
|
|
53
54
|
color: textSecondary,
|
|
54
|
-
fontSize:
|
|
55
|
-
marginTop:
|
|
55
|
+
fontSize: (0, rem_1.r)(28),
|
|
56
|
+
marginTop: (0, rem_1.r)(18),
|
|
56
57
|
wordBreak: "break-word",
|
|
57
58
|
},
|
|
58
59
|
btnBox: {
|
|
59
60
|
position: "relative",
|
|
60
|
-
height:
|
|
61
|
+
height: (0, rem_1.r)(92),
|
|
61
62
|
},
|
|
62
63
|
btnBoxWithCancel: {
|
|
63
64
|
"&:after,&::after": {
|
|
@@ -79,9 +80,9 @@ exports.style = {
|
|
|
79
80
|
alignItems: "center",
|
|
80
81
|
justifyContent: "center",
|
|
81
82
|
userSelect: "none",
|
|
82
|
-
fontSize:
|
|
83
|
+
fontSize: (0, rem_1.r)(32),
|
|
83
84
|
fontWeight: 500,
|
|
84
|
-
letterSpacing:
|
|
85
|
+
letterSpacing: (0, rem_1.r)(1),
|
|
85
86
|
cursor: "pointer",
|
|
86
87
|
transition: "background-color .12s",
|
|
87
88
|
},
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.style = exports.Bubble = void 0;
|
|
4
4
|
const react_1 = require("@emotion/react");
|
|
5
|
+
const rem_1 = require("../utils/rem");
|
|
5
6
|
// translate 走百分比;fill-mode: forwards 保证动画结束后定格在 -50%,
|
|
6
7
|
// 与 React 的 setState 提交顺序解耦,杜绝"动画结束帧"回弹到 0 造成的闪烁
|
|
7
8
|
exports.Bubble = (0, react_1.keyframes) `
|
|
@@ -16,7 +17,7 @@ exports.style = {
|
|
|
16
17
|
box: {
|
|
17
18
|
position: "relative",
|
|
18
19
|
overflow: "hidden",
|
|
19
|
-
height:
|
|
20
|
+
height: (0, rem_1.r)(80),
|
|
20
21
|
},
|
|
21
22
|
wrapper: {
|
|
22
23
|
position: "absolute",
|