@lark-apaas/coding-template-nestjs-react-fullstack 0.1.72-alpha.20261122094734 → 0.1.72-alpha.20261123065914

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/coding-template-nestjs-react-fullstack",
3
- "version": "0.1.72-alpha.20261122094734",
3
+ "version": "0.1.72-alpha.20261123065914",
4
4
  "description": "NestJS + React fullstack template for miaoda coding",
5
5
  "type": "module",
6
6
  "files": [
@@ -2,67 +2,119 @@
2
2
 
3
3
  **组件路径**:`@/components/business-ui/chat-select`
4
4
 
5
- ## 群组类型与 ID
5
+ ---
6
6
 
7
- `Chat` 是组件公开的群组对象:
7
+ ## 群组类型
8
8
 
9
9
  ```typescript
10
- import type { ChatInfo } from '@/components/business-ui/chat-select';
11
-
10
+ /** 群组数据结构 */
12
11
  interface Chat {
12
+ /** 唯一标识:对应 chatID */
13
13
  id: string;
14
+ /** 群组名称:内部优先 zh_cn,其次 en_us */
14
15
  name: string;
15
- avatar?: string;
16
- raw?: ChatInfo;
16
+ /** 头像:URL 或 16 进制 RGB 颜色 */
17
+ avatar: string;
17
18
  }
18
19
  ```
19
20
 
20
- 选择结果的 `id` 对应 `raw.chatID`,是平台数字 ID 的**字符串**,用于群详情查询。`raw` 保留原始群信息,其中可选的 `openChatID` 是通知等飞书群组能力使用的标识;外部接口字段常叫 `open_chat_id` 或 `chat_id`,值常以 `oc_` 开头。两者属于不同命名空间,不要因字段名相似而视为等价,也不要转成 Number 或从前缀拼造转换。
21
+ ---
21
22
 
22
23
  ## 功能概述
23
24
 
24
- - 群组字段选择组件,内置搜索,无需额外传搜索接口或数据源。
25
- - 默认 `valueType="string"`,对外值为详情查询用的 `chatID` 字符串;显式指定 `valueType="object"` 可接收和传入真实 `Chat` 对象。
26
- - 选中后展示群头像和名称,多选以 tag 形式展示。受控字符串值需通过详情查询才能回显,查询失败显示未知群组;对象值直接展示。
25
+ - 群组字段选择组件,用于表单中录入"群组"字段
26
+ - 通过触发器打开弹层,弹层内置搜索功能(始终可用)
27
+ - **仅支持 ID 模式**:`value/onChange` 只使用群组 `chatID`(string),该 ID 为飞书群聊 ID。
28
+ - 组件在 UI 上可展示群组信息(头像/名称),但对外值仅返回/接收 `chatID`
29
+ - 选择后自动回显已选群组信息:群头像 + 群名称(多选以 tag 形式展示)
30
+ - 组件自带群组检索能力,无需额外传搜索接口/数据源
27
31
 
28
- ## 值类型与 Props
32
+ ## 类型定义
29
33
 
30
- | `valueType` | `multiple` | `value` / `defaultValue` 和 `onChange` 的值 |
31
- |------|------|------|
32
- | `'string'`(默认) | `false`(默认) | `string \| null` |
33
- | `'string'` | `true` | `string[]` |
34
- | `'object'` | `false`(默认) | `Chat \| null` |
35
- | `'object'` | `true` | `Chat[]` |
34
+ ```typescript
35
+ /** 触发器类型 */
36
+ type TriggerType = 'button' | 'search' | 'custom';
37
+
38
+ /** 单选模式 Props */
39
+ interface ChatSelectSingleProps {
40
+ /** 当前选中的群组 ID,空值为 null */
41
+ value: string | null;
42
+ /** 选中变化回调 */
43
+ onChange: (value: string | null) => void;
44
+ /** 是否多选,单选时为 false 或不传 */
45
+ multiple?: false;
46
+ /** 触发器类型,仅影响样式,不影响搜索功能 */
47
+ triggerType?: TriggerType;
48
+ /** 是否禁用 */
49
+ disabled?: boolean;
50
+ /** 占位文本 */
51
+ placeholder?: string;
52
+ }
53
+
54
+ /** 多选模式 Props */
55
+ interface ChatSelectMultipleProps {
56
+ /** 当前选中的群组 ID 列表,空值为 [] */
57
+ value: string[];
58
+ /** 选中变化回调 */
59
+ onChange: (value: string[]) => void;
60
+ /** 是否多选,多选时为 true */
61
+ multiple: true;
62
+ /** 触发器类型 */
63
+ triggerType?: TriggerType;
64
+ /** 是否禁用 */
65
+ disabled?: boolean;
66
+ /** 占位文本 */
67
+ placeholder?: string;
68
+ }
69
+
70
+ type ChatSelectProps = ChatSelectSingleProps | ChatSelectMultipleProps;
71
+ ```
72
+
73
+ ## Props 说明
36
74
 
37
75
  | 属性 | 类型 | 默认值 | 说明 |
38
76
  |------|------|--------|------|
39
- | `value` | 见上表 | - | 受控值,可选 |
40
- | `defaultValue` | 见上表 | - | 非受控初始值,可选 |
41
- | `onChange` | `(value) => void` | - | 可选,参数形态见上表 |
42
- | `valueType` | `'string' \| 'object'` | `'string'` | 值的模式 |
77
+ | `value` | `string \| null` / `string[]` | - | **必填**。单选传 `string \| null`(群组 ID),多选传 `string[]` |
78
+ | `onChange` | `function` | - | **必填**。值变化回调,返回值形态与 `value` 匹配 |
43
79
  | `multiple` | `boolean` | `false` | 是否多选 |
44
80
  | `triggerType` | `'button' \| 'search' \| 'custom'` | `'button'` | 触发器类型,仅影响样式 |
45
81
  | `disabled` | `boolean` | `false` | 是否禁用 |
46
82
  | `placeholder` | `string` | `'请选择'` | 占位文本 |
47
- | `getOptionDisabled` | `(chat: Chat) => boolean` | - | 判断选项是否禁用 |
83
+ | `getOptionDisabled` | `(chat) => boolean` | - | 判断选项是否禁用 |
84
+
85
+ ## 受控规范
48
86
 
49
- 表单推荐使用 `value` + `onChange` 受控:单选空值用 `null`,多选空值用 `[]`;值与回调的类型应匹配所选模式。组件的 props 可选;非空字符串 `defaultValue`(见上表)需要异步查询,当前实现查询完成后不会更新非受控初始值。用可信数字 ID 回填时请使用受控 `value`;已有真实对象可用对象模式的 `defaultValue`。
87
+ > ⚠️ **强约束**
88
+
89
+ 1. **必须受控**:始终传 `value` + `onChange`
90
+ 2. **禁止传**:`undefined` / 群组对象 / 其他类型
91
+ 3. **空值规则**:
92
+ - 单选清空:`null`
93
+ - 多选清空:`[]`
50
94
 
51
95
  ## 使用示例
52
96
 
53
97
  ```tsx
54
98
  import { useState } from 'react';
55
- import { ChatSelect, type Chat } from '@/components/business-ui/chat-select';
99
+ import { ChatSelect } from '@/components/business-ui/chat-select';
56
100
 
57
- // 字符串单选:保存/回填的是详情查询用的数字 ID 字符串
101
+ // 单选
58
102
  function SingleSelectExample() {
59
103
  const [chatId, setChatId] = useState<string | null>(null);
60
- return <ChatSelect value={chatId} onChange={setChatId} placeholder="请选择群组" />;
104
+
105
+ return (
106
+ <ChatSelect
107
+ value={chatId}
108
+ onChange={setChatId}
109
+ placeholder="请选择群组"
110
+ />
111
+ );
61
112
  }
62
113
 
63
- // 字符串多选
114
+ // 多选
64
115
  function MultipleSelectExample() {
65
116
  const [chatIds, setChatIds] = useState<string[]>([]);
117
+
66
118
  return (
67
119
  <ChatSelect
68
120
  multiple
@@ -73,56 +125,4 @@ function MultipleSelectExample() {
73
125
  />
74
126
  );
75
127
  }
76
-
77
- // 对象单选:需要原始群信息时使用
78
- function SingleObjectExample() {
79
- const [chat, setChat] = useState<Chat | null>(null);
80
- return <ChatSelect valueType="object" value={chat} onChange={setChat} />;
81
- }
82
-
83
- // 对象多选
84
- function MultipleObjectExample() {
85
- const [chats, setChats] = useState<Chat[]>([]);
86
- return <ChatSelect valueType="object" multiple value={chats} onChange={setChats} />;
87
- }
88
128
  ```
89
-
90
- ## 通知配置的保存与回填
91
-
92
- 通知接口需要通知标识时,从对象模式的真实选择结果取 `chat.raw?.openChatID`。缺 `raw`、`openChatID` 为 `undefined` 或空字符串时,当前结果不足以保存通知配置;提示缺少数据并保留原配置,不能以 `chat.id` 替代。
93
-
94
- 以下示例的业务保存接口只有一个 ID 槽位 `chatId`,该槽位约定存通知标识。`saveNotificationSetting` 由业务方提供,不是组件 API:
95
-
96
- ```tsx
97
- import { useState } from 'react';
98
- import { ChatSelect, type Chat } from '@/components/business-ui/chat-select';
99
-
100
- function NotificationSelect({ saveNotificationSetting }: {
101
- saveNotificationSetting: (setting: { chatId: string; chatName: string }) => Promise<void>;
102
- }) {
103
- const [chat, setChat] = useState<Chat | null>(null);
104
- const [error, setError] = useState('');
105
-
106
- async function save() {
107
- const openChatID = chat?.raw?.openChatID;
108
- if (!chat || !openChatID) {
109
- setError('缺少可用的群通知标识,原配置未更改');
110
- return;
111
- }
112
- await saveNotificationSetting({ chatId: openChatID, chatName: chat.name });
113
- setError('');
114
- }
115
-
116
- return (
117
- <>
118
- <ChatSelect valueType="object" value={chat} onChange={setChat} />
119
- <button type="button" onClick={save}>保存</button>
120
- {error && <p>{error}</p>}
121
- </>
122
- );
123
- }
124
- ```
125
-
126
- 此单 ID 合同不能扩展时,只保存通知 ID 和名称;当前会话可保留真实选择对象,但不能承诺刷新后重建。若业务合同允许保存并读回对应真实信息,可同时保留实际 `chatID`、名称等回显所需信息:已有可信数字 ID 可用字符串模式回填,已有真实 `Chat` 可用对象模式回填。
127
-
128
- 历史配置若只有通知 ID,先通过已有可信群信息取得对应数字 ID 或真实对象,再按对应模式回填;不能用通知 ID 和名称伪造 `Chat`。没有可信映射或第二存储位置且无权扩展合同时,保留原配置,说明回填数据不足或请求业务合同授权;需要完整刷新回显时,在授权下补充合同或可信来源。
@@ -7,13 +7,11 @@ import type { I18nText } from '@client/src/components/business-ui/entity-combobo
7
7
  export type { I18nText };
8
8
 
9
9
  /**
10
- * 群组原始信息(对应 SearchChatEntity,保存在 Chat.raw 中)
10
+ * 群组原始信息(对应 SearchChatEntity)
11
11
  */
12
12
  export type ChatInfo = {
13
- /** 平台数字群组 ID 的字符串,用于详情查询 */
13
+ /** 群组 ID */
14
14
  chatID: string;
15
- /** 飞书群组通知等能力使用的 open ID */
16
- openChatID?: string;
17
15
  /** 群组名称(国际化文本) */
18
16
  name: I18nText;
19
17
  /** 头像:URL 或 16 进制 RGB 颜色 */
@@ -25,13 +23,13 @@ export type ChatInfo = {
25
23
  };
26
24
 
27
25
  /**
28
- * 标准化后的群组数据(用于 BaseCombobox):id 对应 chatID,raw 保留原始信息
26
+ * 标准化后的群组数据(用于 BaseCombobox)
29
27
  */
30
28
  export type Chat = ItemValue<ChatInfo>;
31
29
 
32
30
  /**
33
31
  * 值类型
34
- * - 'string': value 为详情查询用的 chatID 字符串
32
+ * - 'string': value 为 chatID 字符串
35
33
  * - 'object': value 为 Chat 对象
36
34
  * @default 'string'
37
35
  */
@@ -60,7 +58,7 @@ type ChatSelectBaseProps<
60
58
  > & {
61
59
  /**
62
60
  * 值类型
63
- * - 'string': value 为详情查询用的 chatID 字符串
61
+ * - 'string': value 为 chatID 字符串
64
62
  * - 'object': value 为 Chat 对象
65
63
  * @default 'string'
66
64
  */
@@ -1568,6 +1568,16 @@
1568
1568
  "styled-jsx": ">=5.0.0"
1569
1569
  }
1570
1570
  },
1571
+ "node_modules/@lark-apaas/client-toolkit/node_modules/clsx": {
1572
+ "version": "2.0.1",
1573
+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.0.1.tgz",
1574
+ "integrity": "sha512-PrYqtepbSWwrFmtHX0IHv3zUEbWn1psIqaIZyjB3b9wEGpRAkpyeKbCCCkCXJYiHZPjK7jckJvf2sEB/8VKPgQ==",
1575
+ "dev": true,
1576
+ "license": "MIT",
1577
+ "engines": {
1578
+ "node": ">=6"
1579
+ }
1580
+ },
1571
1581
  "node_modules/@lark-apaas/client-toolkit/node_modules/crypto-js": {
1572
1582
  "version": "3.1.9-1",
1573
1583
  "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-3.1.9-1.tgz",
@@ -1575,6 +1585,20 @@
1575
1585
  "dev": true,
1576
1586
  "license": "MIT"
1577
1587
  },
1588
+ "node_modules/@lark-apaas/client-toolkit/node_modules/tailwind-merge": {
1589
+ "version": "2.0.0",
1590
+ "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.0.0.tgz",
1591
+ "integrity": "sha512-WO8qghn9yhsldLSg80au+3/gY9E4hFxIvQ3qOmlpXnqpDKoMruKfi/56BbbMg6fHTQJ9QD3cc79PoWqlaQE4rw==",
1592
+ "dev": true,
1593
+ "license": "MIT",
1594
+ "dependencies": {
1595
+ "@babel/runtime": "^7.23.1"
1596
+ },
1597
+ "funding": {
1598
+ "type": "github",
1599
+ "url": "https://github.com/sponsors/dcastil"
1600
+ }
1601
+ },
1578
1602
  "node_modules/@lark-apaas/coding-preset-vite-react": {
1579
1603
  "version": "1.0.33",
1580
1604
  "resolved": "https://registry.npmmirror.com/@lark-apaas/coding-preset-vite-react/-/coding-preset-vite-react-1.0.33.tgz",
@@ -1628,6 +1652,17 @@
1628
1652
  "dev": true,
1629
1653
  "license": "MIT"
1630
1654
  },
1655
+ "node_modules/@lark-apaas/coding-preset-vite-react/node_modules/tailwind-merge": {
1656
+ "version": "2.6.2",
1657
+ "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.6.2.tgz",
1658
+ "integrity": "sha512-o2TX9QB8K2cfaJYgMwv96uAUQK5SqpRJHD2vGDK5nyF/tk9PQTZFpwgsDsySQjlIbYdZ6ZDkk5W+bSuWSe92AA==",
1659
+ "dev": true,
1660
+ "license": "MIT",
1661
+ "funding": {
1662
+ "type": "github",
1663
+ "url": "https://github.com/sponsors/dcastil"
1664
+ }
1665
+ },
1631
1666
  "node_modules/@lark-apaas/dataloom": {
1632
1667
  "version": "0.1.6",
1633
1668
  "resolved": "https://registry.npmmirror.com/@lark-apaas/dataloom/-/dataloom-0.1.6.tgz",
@@ -1755,6 +1790,30 @@
1755
1790
  "react": ">=16.8.0"
1756
1791
  }
1757
1792
  },
1793
+ "node_modules/@lark-apaas/miaoda-inspector/node_modules/clsx": {
1794
+ "version": "2.0.1",
1795
+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.0.1.tgz",
1796
+ "integrity": "sha512-PrYqtepbSWwrFmtHX0IHv3zUEbWn1psIqaIZyjB3b9wEGpRAkpyeKbCCCkCXJYiHZPjK7jckJvf2sEB/8VKPgQ==",
1797
+ "dev": true,
1798
+ "license": "MIT",
1799
+ "engines": {
1800
+ "node": ">=6"
1801
+ }
1802
+ },
1803
+ "node_modules/@lark-apaas/miaoda-inspector/node_modules/tailwind-merge": {
1804
+ "version": "2.0.0",
1805
+ "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.0.0.tgz",
1806
+ "integrity": "sha512-WO8qghn9yhsldLSg80au+3/gY9E4hFxIvQ3qOmlpXnqpDKoMruKfi/56BbbMg6fHTQJ9QD3cc79PoWqlaQE4rw==",
1807
+ "dev": true,
1808
+ "license": "MIT",
1809
+ "dependencies": {
1810
+ "@babel/runtime": "^7.23.1"
1811
+ },
1812
+ "funding": {
1813
+ "type": "github",
1814
+ "url": "https://github.com/sponsors/dcastil"
1815
+ }
1816
+ },
1758
1817
  "node_modules/@lark-apaas/nestjs-authnpaas": {
1759
1818
  "version": "1.0.11",
1760
1819
  "resolved": "https://registry.npmmirror.com/@lark-apaas/nestjs-authnpaas/-/nestjs-authnpaas-1.0.11.tgz",
@@ -20956,6 +21015,17 @@
20956
21015
  "tailwindcss": "*"
20957
21016
  }
20958
21017
  },
21018
+ "node_modules/tailwind-variants/node_modules/tailwind-merge": {
21019
+ "version": "2.5.4",
21020
+ "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.5.4.tgz",
21021
+ "integrity": "sha512-0q8cfZHMu9nuYP/b5Shb7Y7Sh1B7Nnl5GqNr1U+n2p6+mybvRtayrQ+0042Z5byvTA8ihjlP8Odo8/VnHbZu4Q==",
21022
+ "dev": true,
21023
+ "license": "MIT",
21024
+ "funding": {
21025
+ "type": "github",
21026
+ "url": "https://github.com/sponsors/dcastil"
21027
+ }
21028
+ },
20959
21029
  "node_modules/tailwindcss": {
20960
21030
  "version": "4.3.3",
20961
21031
  "resolved": "https://registry.npmmirror.com/tailwindcss/-/tailwindcss-4.3.3.tgz",
@@ -136,14 +136,6 @@
136
136
  "vite": "^8",
137
137
  "zod": "^4.3.6"
138
138
  },
139
- "overrides": {
140
- "dayjs": "^1.11.15",
141
- "clsx": "^2.1.1",
142
- "tailwind-merge": "^3.5.0",
143
- "zod": "^4.3.6",
144
- "echarts": "^6.1.0",
145
- "stylelint": "^17.3.0"
146
- },
147
139
  "engines": {
148
140
  "node": ">=22.0.0",
149
141
  "npm": ">=10.0.0"