@kne/super-select 0.1.16 → 0.1.19

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/README.md CHANGED
@@ -13,6 +13,56 @@
13
13
  npm i --save @kne/super-select
14
14
  ```
15
15
 
16
+
17
+ ### 概述
18
+
19
+ @kne/super-select 是一个功能强大的 React 组件库,专门用于处理复杂的信息选择场景。它提供了一系列灵活且可组合的组件,使得在 React 应用中实现复杂的选择功能变得简单直观。
20
+
21
+ ### 主要功能
22
+
23
+ - 支持多种选择模式(单选、多选)
24
+ - 提供灵活的列表和表格展示方式
25
+ - 内置标签式选中项展示
26
+ - 支持全选/反选功能
27
+ - 内置国际化支持(中文和英文)
28
+ - 自定义样式支持(基于CSS Modules)
29
+
30
+ ### 组件概述
31
+
32
+ #### SelectInput
33
+ 基础选择输入组件,提供核心的选择功能和状态管理。可以独立使用,也可以作为其他选择组件的基础。
34
+
35
+ #### SelectList
36
+ 基于 SelectInput 的列表选择组件,适用于常规的列表选择场景。提供了简洁的列表界面和直观的选择交互。
37
+
38
+ #### SelectTableList
39
+ 表格形式的选择组件,适用于需要展示多列数据的选择场景。支持自定义列配置和表格样式。
40
+
41
+ #### SelectedAll
42
+ 全选功能组件,提供一键选择/取消选择所有项的功能。可以与其他选择组件配合使用。
43
+
44
+ #### SelectedTagList
45
+ 已选项标签列表组件,以标签形式展示已选中的项目。支持单个标签删除和清空所有已选项。
46
+
47
+ ### 使用场景
48
+
49
+ - 复杂的数据筛选和选择
50
+ - 多条件组合查询
51
+ - 批量操作数据
52
+ - 表格数据的多选处理
53
+ - 带标签展示的数据选择
54
+ - 需要全选/反选功能的列表操作
55
+
56
+ ### 技术特点
57
+
58
+ - 基于 React 开发
59
+ - 使用 CSS Modules 进行样式隔离
60
+ - 支持 ES6+ 语法
61
+ - 模块化设计,组件可独立使用
62
+ - 支持主题定制
63
+ - 完善的类型定义支持
64
+
65
+
16
66
  ### 示例
17
67
 
18
68
 
@@ -84,7 +134,7 @@ const BaseExample = () => {
84
134
  }} />
85
135
  <SuperSelect api={{
86
136
  data: {}, loader: ({ data }) => {
87
- const { searchText } = data.searchProps;
137
+ const searchText = data.searchProps && data.searchProps.searchText;
88
138
  if (!searchText) {
89
139
  return {
90
140
  pageData: optionList, totalCount: optionList.length
@@ -178,7 +228,161 @@ render(<BaseExample />);
178
228
 
179
229
  ### API
180
230
 
181
- | 属性名 | 说明 | 类型 | 默认值 |
182
- |-----|----|----|-----|
183
- | | | | |
231
+ #### SelectInput
232
+
233
+ 基础选择输入组件,提供核心的选择功能和状态管理。
234
+
235
+ | 属性名 | 说明 | 类型 | 默认值 |
236
+ |-------------------|-------------------|-------------------------------|---------------------|
237
+ | value | 当前选中的值 | array | [] |
238
+ | onChange | 选中值变化时的回调函数 | function(value, item, {type}) | - |
239
+ | dataSource | 数据源 | array | [] |
240
+ | idField | 数据项唯一标识字段 | string | 'id' |
241
+ | multiple | 是否支持多选 | boolean | false |
242
+ | max | 最多可选数量 | number | - |
243
+ | disabled | 是否禁用 | boolean | false |
244
+ | readOnly | 是否只读 | boolean | false |
245
+ | className | 自定义类名 | string | - |
246
+ | style | 自定义样式 | object | - |
247
+ | children | 自定义渲染内容 | function(props) | - |
248
+ | locale | 国际化配置 | object | 默认中文 |
249
+ | getContainer | 指定下拉菜单挂载的 HTML 节点 | function | () => document.body |
250
+ | getPopupContainer | 菜单渲染父节点 | function(triggerNode) | () => document.body |
251
+ | onExceed | 超出最大可选数量时的回调 | function(value, item) | - |
252
+ | onSelect | 选择时的回调 | function(value, item) | - |
253
+ | onDeselect | 取消选择时的回调 | function(value, item) | - |
254
+
255
+ #### SelectList
256
+
257
+ 基于 SelectInput 的列表选择组件,适用于常规的列表选择场景。
258
+
259
+ | 属性名 | 说明 | 类型 | 默认值 |
260
+ |---------------|--------------|-------------------------------|-------|
261
+ | value | 当前选中的值 | array | [] |
262
+ | onChange | 选中值变化时的回调函数 | function(value, item, {type}) | - |
263
+ | dataSource | 数据源 | array | [] |
264
+ | idField | 数据项唯一标识字段 | string | 'id' |
265
+ | multiple | 是否支持多选 | boolean | false |
266
+ | max | 最多可选数量 | number | - |
267
+ | disabled | 是否禁用 | boolean | false |
268
+ | readOnly | 是否只读 | boolean | false |
269
+ | className | 自定义类名 | string | - |
270
+ | style | 自定义样式 | object | - |
271
+ | renderItem | 自定义列表项渲染 | function(item, index) | - |
272
+ | emptyContent | 无数据时的显示内容 | ReactNode | - |
273
+ | locale | 国际化配置 | object | 默认中文 |
274
+ | onExceed | 超出最大可选数量时的回调 | function(value, item) | - |
275
+ | onSelect | 选择时的回调 | function(value, item) | - |
276
+ | onDeselect | 取消选择时的回调 | function(value, item) | - |
277
+ | itemClassName | 列表项自定义类名 | string | - |
278
+ | itemStyle | 列表项自定义样式 | object | - |
279
+
280
+ #### SelectTableList
281
+
282
+ 表格形式的选择组件,适用于需要展示多列数据的选择场景。
283
+
284
+ | 属性名 | 说明 | 类型 | 默认值 |
285
+ |-----------------|--------------|-------------------------------|-------|
286
+ | value | 当前选中的值 | array | [] |
287
+ | onChange | 选中值变化时的回调函数 | function(value, item, {type}) | - |
288
+ | dataSource | 数据源 | array | [] |
289
+ | idField | 数据项唯一标识字段 | string | 'id' |
290
+ | multiple | 是否支持多选 | boolean | false |
291
+ | max | 最多可选数量 | number | - |
292
+ | disabled | 是否禁用 | boolean | false |
293
+ | readOnly | 是否只读 | boolean | false |
294
+ | className | 自定义类名 | string | - |
295
+ | style | 自定义样式 | object | - |
296
+ | columns | 表格列配置 | array | [] |
297
+ | emptyContent | 无数据时的显示内容 | ReactNode | - |
298
+ | locale | 国际化配置 | object | 默认中文 |
299
+ | onExceed | 超出最大可选数量时的回调 | function(value, item) | - |
300
+ | onSelect | 选择时的回调 | function(value, item) | - |
301
+ | onDeselect | 取消选择时的回调 | function(value, item) | - |
302
+ | rowClassName | 行自定义类名 | string | - |
303
+ | rowStyle | 行自定义样式 | object | - |
304
+ | headerClassName | 表头自定义类名 | string | - |
305
+ | headerStyle | 表头自定义样式 | object | - |
306
+
307
+ ##### columns 配置项
308
+
309
+ | 属性名 | 说明 | 类型 | 默认值 |
310
+ |-----------|---------------|-------------------------------|-----|
311
+ | title | 列标题 | ReactNode | - |
312
+ | dataIndex | 列数据在数据项中对应的路径 | string | - |
313
+ | key | React key | string | - |
314
+ | render | 自定义渲染函数 | function(text, record, index) | - |
315
+ | width | 列宽度 | string \| number | - |
316
+ | className | 列自定义类名 | string | - |
317
+ | style | 列自定义样式 | object | - |
318
+
319
+ #### SelectedAll
320
+
321
+ 全选功能组件,提供一键选择/取消选择所有项的功能。
322
+
323
+ | 属性名 | 说明 | 类型 | 默认值 |
324
+ |------------|-------------|-------------------------|-------|
325
+ | value | 当前选中的值 | array | [] |
326
+ | onChange | 选中值变化时的回调函数 | function(value, {type}) | - |
327
+ | dataSource | 数据源 | array | [] |
328
+ | idField | 数据项唯一标识字段 | string | 'id' |
329
+ | disabled | 是否禁用 | boolean | false |
330
+ | readOnly | 是否只读 | boolean | false |
331
+ | className | 自定义类名 | string | - |
332
+ | style | 自定义样式 | object | - |
333
+ | children | 自定义渲染内容 | function(props) | - |
334
+ | locale | 国际化配置 | object | 默认中文 |
335
+
336
+ #### SelectedTagList
337
+
338
+ 已选项标签列表组件,以标签形式展示已选中的项目。
339
+
340
+ | 属性名 | 说明 | 类型 | 默认值 |
341
+ |--------------|-------------|-------------------------------|-------|
342
+ | value | 当前选中的值 | array | [] |
343
+ | onChange | 选中值变化时的回调函数 | function(value, item, {type}) | - |
344
+ | dataSource | 数据源 | array | [] |
345
+ | idField | 数据项唯一标识字段 | string | 'id' |
346
+ | disabled | 是否禁用 | boolean | false |
347
+ | readOnly | 是否只读 | boolean | false |
348
+ | className | 自定义类名 | string | - |
349
+ | style | 自定义样式 | object | - |
350
+ | renderItem | 自定义标签渲染 | function(item, index) | - |
351
+ | emptyContent | 无数据时的显示内容 | ReactNode | - |
352
+ | locale | 国际化配置 | object | 默认中文 |
353
+ | onRemove | 移除标签时的回调 | function(value, item) | - |
354
+ | onClear | 清空所有标签时的回调 | function(value) | - |
355
+ | showClear | 是否显示清空按钮 | boolean | true |
356
+ | tagClassName | 标签自定义类名 | string | - |
357
+ | tagStyle | 标签自定义样式 | object | - |
358
+
359
+ #### 国际化配置
360
+
361
+ 组件内置了中文和英文两种语言配置,默认使用中文。可以通过 `locale` 属性进行自定义配置。
362
+
363
+ ```jsx
364
+ import { zhCN, enUS } from '@kne/super-select/locale';
365
+
366
+ // 使用英文
367
+ <SelectList locale={enUS} />
368
+
369
+ // 自定义部分文案
370
+ <SelectList locale={{
371
+ ...zhCN,
372
+ empty: '暂无数据',
373
+ selectAll: '全选',
374
+ clearAll: '清空'
375
+ }} />
376
+ ```
377
+
378
+ ##### 可配置的文案
379
+
380
+ | 键名 | 说明 | 默认中文值 |
381
+ |-----------|-----------|----------------|
382
+ | empty | 无数据时的提示文案 | 暂无数据 |
383
+ | selectAll | 全选按钮文案 | 全选 |
384
+ | clearAll | 清空按钮文案 | 清空 |
385
+ | selected | 已选文案 | 已选 |
386
+ | items | 项文案 | 项 |
387
+ | exceed | 超出限制提示文案 | 最多只能选择 {max} 项 |
184
388
 
package/dist/index.css CHANGED
@@ -69,6 +69,9 @@
69
69
 
70
70
  ._ybN30 {
71
71
  box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
72
+ min-width: unset !important;
73
+ border-radius: 4px;
74
+ overflow: hidden;
72
75
  }
73
76
  ._ybN30 .ant-popover-inner {
74
77
  padding: 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["style.module.scss"],"names":[],"mappings":"AAAA;EACE,mBAAmB;EACnB,sBAAsB;EACtB,mCAAmC;EACnC,0CAA0C;EAC1C,kBAAkB;EAClB,eAAe;EACf,gBAAgB;EAChB,kBAAkB;EAClB,eAAe;EACf,uBAAuB;AACzB;AACA;EACE,kCAAkC;AACpC;AACA;EACE,kCAAkC;AACpC;AACA;EACE,kCAAkC;EAClC,+BAA+B;EAC/B,mBAAmB;AACrB;AACA;EACE,+BAA+B;AACjC;AACA;EACE,aAAa;AACf;AACA;EACE,eAAe;AACjB;AACA;EACE,mBAAmB;AACrB;AACA;EACE,mBAAmB;AACrB;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,kBAAkB;EAClB,gBAAgB;EAChB,8BAA8B;EAC9B,mBAAmB;EACnB,uBAAuB;EACvB,OAAO;AACT;AACA;EACE,qBAAqB;AACvB;;AAEA;EACE,+BAA+B;EAC/B,eAAe;EACf,+BAA+B;AACjC;;AAEA;EACE,+BAA+B;AACjC;;AAEA;EACE,gBAAgB;EAChB,2BAA2B;EAC3B,mBAAmB;AACrB;;AAEA;EACE,oHAAoH;AACtH;AACA;EACE,UAAU;AACZ;;AAEA;EACE,4BAA4B;AAC9B;;AAEA;EACE,2BAA2B;AAC7B;AAlFA;EACE,qBAAqB;AACvB;AACA;EACE,+BAA+B;AACjC;AALA;EACE,iBAAiB;AACnB;;AAEA;EACE,sBAAsB;AACxB;AACA;EACE,kCAAkC;AACpC;;AAEA;EACE,iBAAiB;EACjB,OAAO;AACT;;AAEA;EACE,mBAAmB;EACnB,sBAAsB;AACxB;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,cAAc;EACd,gBAAgB;EAChB,mBAAmB;EACnB,uBAAuB;EACvB,gBAAgB;AAClB;AA/BA;EACE,iBAAiB;AACnB;AACA;EACE,iBAAiB;AACnB;;AAEA;EACE,kCAAkC;EAClC,mBAAmB;AACrB;AACA;EACE,+BAA+B;AACjC;AACA;EACE,oBAAoB;AACtB;;AAEA;EACE,4BAA4B;EAC5B,mBAAmB;EACnB,eAAe;EACf,4BAA4B;EAC5B,kBAAkB;EAClB,2CAA2C;AAC7C;AACA;EACE,kCAAkC;AACpC;AACA;EACE,kCAAkC;AACpC;AACA;;EAEE,2BAA2B;AAC7B;AACA;EACE,+BAA+B;EAC/B,mBAAmB;AACrB;AACA;EACE,gBAAgB;EAChB,iBAAiB;AACnB;AACA;;EAEE,uBAAuB;AACzB;AACA;EACE,+BAA+B;AACjC;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,eAAe;AACjB;AACA;EACE,aAAa;AACf;AACA;EACE,cAAc;AAChB;;AAEA;EACE,8CAA8C;AAChD;AACA;EACE,yBAAyB;AAC3B;AACA;EACE,oBAAoB;AACtB;;AAEA;EACE,aAAa;AACf;AACA;EACE,aAAa;AACf;;AAEA;EACE,mBAAmB;EACnB,gBAAgB;EAChB,uBAAuB;AACzB;AAvFA;EACE,iBAAiB;AACnB;AACA;EACE,iBAAiB;AACnB;;AAEA;EACE,8BAA8B;AAChC;AACA;EACE,kCAAkC;EAClC,kCAAkC;AACpC;;AAEA;EACE,8BAA8B;AAChC;AACA;EACE,eAAe;AACjB;AACA;EACE,mBAAmB;EACnB,kCAAkC;AACpC;AACA;EACE,oBAAoB;EACpB,+BAA+B;AACjC;AACA;EACE,kCAAkC;EAClC,2BAA2B;AAC7B;AACA;EACE,mBAAmB;AACrB;AACA;EACE,oBAAoB;EACpB,+BAA+B;AACjC;AACA;EACE,kCAAkC;AACpC;;AAEA;EACE,YAAY;EACZ,gCAAgC;AAClC;;AAEA;EACE,8BAA8B;EAC9B,YAAY;AACd;AACA;EACE,cAAc;AAChB;AACA;EACE,UAAU;AACZ;AACA;EACE,kCAAkC;AACpC;;AAEA;EACE,aAAa;EACb,oBAAoB;AACtB;;AAEA;EACE,cAAc;EACd,gBAAgB;EAChB,mBAAmB;EACnB,uBAAuB;EACvB,gBAAgB;EAChB,eAAe;AACjB;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,aAAa;AACf;AACA;EACE,YAAY;AACd;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,gCAAgC;EAChC,+BAA+B;EAC/B,iBAAiB;AACnB;AACA;EACE,mBAAmB;AACrB;;AAEA;;EAEE,mCAAmC;EACnC,iBAAiB;EACjB,6BAA6B;EAC7B,8BAA8B;EAC9B,iBAAiB;EACjB,qBAAqB;AACvB;;AAEA;EACE,kCAAkC;EAClC,6BAA6B;AAC/B;;AAEA;EACE,qBAAqB;EACrB,qBAAqB;AACvB","file":"index.css","sourcesContent":[".list {\n max-height: 300px;\n}\n.list:not(.is-popup) {\n max-height: 400px;\n}\n\n.header {\n border-left: 1px solid #f0f0f0;\n}\n.header .col {\n background: var(--bg-color-grey-1);\n transition: background-color 300ms;\n}\n\n.body {\n border-left: 1px solid #f0f0f0;\n}\n.body .col {\n cursor: pointer;\n}\n.body.is-selected-all {\n cursor: not-allowed;\n background: var(--bg-color-grey-3);\n}\n.body.is-selected-all .col {\n pointer-events: none;\n color: var(--font-color-grey-2);\n}\n.body.is-selected {\n background: var(--primary-color-1);\n color: var(--primary-color);\n}\n.body.is-disabled {\n cursor: not-allowed;\n}\n.body.is-disabled .col {\n pointer-events: none;\n color: var(--font-color-grey-2);\n}\n.body:hover:not(.is-selected-all):not(.is-selected):not(.is-disabled) .col {\n background: var(--bg-color-grey-1);\n}\n\n.col {\n padding: 8px;\n border-bottom: 1px solid #f0f0f0;\n}\n\n.right-options {\n border-left: 1px solid #f0f0f0;\n padding: 8px;\n}\n.right-options:not(.right-options:global(.is-popup)) {\n padding-top: 0;\n}\n.right-options .no-padding-btn:global(.ant-btn) {\n padding: 0;\n}\n.right-options :global .ant-tag {\n background: var(--bg-color-grey-3);\n}\n\n.tag {\n display: flex;\n margin-inline-end: 0;\n}\n\n.tag-inner {\n display: block;\n max-width: 100px;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n cursor: pointer;\n}\n\n.single-checked {\n flex: 0 0 30px;\n}\n\n.select-search {\n display: flex;\n}\n.select-search:global(.is-popup) {\n padding: 8px;\n}\n\n.tags-search {\n display: flex;\n}\n\n.descriptions {\n border-bottom: 1px solid #eeeeee;\n border-right: 1px solid #eeeeee;\n line-height: 20px;\n}\n.descriptions:not(:last-child) {\n border-bottom: none;\n}\n\n.descriptions-col-label,\n.descriptions-col-content {\n font-size: var(--font-size-default);\n padding: 8px 16px;\n border-top: 1px solid #eeeeee;\n border-left: 1px solid #eeeeee;\n line-height: 20px;\n word-break: break-all;\n}\n\n.descriptions-col-label {\n background: var(--bg-color-grey-1);\n color: var(--font-color-grey);\n}\n\n.descriptions-col-content {\n word-break: break-all;\n white-space: pre-line;\n}"]}
1
+ {"version":3,"sources":["style.module.scss"],"names":[],"mappings":"AAAA;EACE,mBAAmB;EACnB,sBAAsB;EACtB,mCAAmC;EACnC,0CAA0C;EAC1C,kBAAkB;EAClB,eAAe;EACf,gBAAgB;EAChB,kBAAkB;EAClB,eAAe;EACf,uBAAuB;AACzB;AACA;EACE,kCAAkC;AACpC;AACA;EACE,kCAAkC;AACpC;AACA;EACE,kCAAkC;EAClC,+BAA+B;EAC/B,mBAAmB;AACrB;AACA;EACE,+BAA+B;AACjC;AACA;EACE,aAAa;AACf;AACA;EACE,eAAe;AACjB;AACA;EACE,mBAAmB;AACrB;AACA;EACE,mBAAmB;AACrB;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,kBAAkB;EAClB,gBAAgB;EAChB,8BAA8B;EAC9B,mBAAmB;EACnB,uBAAuB;EACvB,OAAO;AACT;AACA;EACE,qBAAqB;AACvB;;AAEA;EACE,+BAA+B;EAC/B,eAAe;EACf,+BAA+B;AACjC;;AAEA;EACE,+BAA+B;AACjC;;AAEA;EACE,gBAAgB;EAChB,2BAA2B;EAC3B,mBAAmB;AACrB;;AAEA;EACE,oHAAoH;EACpH,2BAA2B;EAC3B,kBAAkB;EAClB,gBAAgB;AAClB;AACA;EACE,UAAU;AACZ;;AAEA;EACE,4BAA4B;AAC9B;;AAEA;EACE,2BAA2B;AAC7B;AArFA;EACE,qBAAqB;AACvB;AACA;EACE,+BAA+B;AACjC;AALA;EACE,iBAAiB;AACnB;;AAEA;EACE,sBAAsB;AACxB;AACA;EACE,kCAAkC;AACpC;;AAEA;EACE,iBAAiB;EACjB,OAAO;AACT;;AAEA;EACE,mBAAmB;EACnB,sBAAsB;AACxB;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,cAAc;EACd,gBAAgB;EAChB,mBAAmB;EACnB,uBAAuB;EACvB,gBAAgB;AAClB;AA/BA;EACE,iBAAiB;AACnB;AACA;EACE,iBAAiB;AACnB;;AAEA;EACE,kCAAkC;EAClC,mBAAmB;AACrB;AACA;EACE,+BAA+B;AACjC;AACA;EACE,oBAAoB;AACtB;;AAEA;EACE,4BAA4B;EAC5B,mBAAmB;EACnB,eAAe;EACf,4BAA4B;EAC5B,kBAAkB;EAClB,2CAA2C;AAC7C;AACA;EACE,kCAAkC;AACpC;AACA;EACE,kCAAkC;AACpC;AACA;;EAEE,2BAA2B;AAC7B;AACA;EACE,+BAA+B;EAC/B,mBAAmB;AACrB;AACA;EACE,gBAAgB;EAChB,iBAAiB;AACnB;AACA;;EAEE,uBAAuB;AACzB;AACA;EACE,+BAA+B;AACjC;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,eAAe;AACjB;AACA;EACE,aAAa;AACf;AACA;EACE,cAAc;AAChB;;AAEA;EACE,8CAA8C;AAChD;AACA;EACE,yBAAyB;AAC3B;AACA;EACE,oBAAoB;AACtB;;AAEA;EACE,aAAa;AACf;AACA;EACE,aAAa;AACf;;AAEA;EACE,mBAAmB;EACnB,gBAAgB;EAChB,uBAAuB;AACzB;AAvFA;EACE,iBAAiB;AACnB;AACA;EACE,iBAAiB;AACnB;;AAEA;EACE,8BAA8B;AAChC;AACA;EACE,kCAAkC;EAClC,kCAAkC;AACpC;;AAEA;EACE,8BAA8B;AAChC;AACA;EACE,eAAe;AACjB;AACA;EACE,mBAAmB;EACnB,kCAAkC;AACpC;AACA;EACE,oBAAoB;EACpB,+BAA+B;AACjC;AACA;EACE,kCAAkC;EAClC,2BAA2B;AAC7B;AACA;EACE,mBAAmB;AACrB;AACA;EACE,oBAAoB;EACpB,+BAA+B;AACjC;AACA;EACE,kCAAkC;AACpC;;AAEA;EACE,YAAY;EACZ,gCAAgC;AAClC;;AAEA;EACE,8BAA8B;EAC9B,YAAY;AACd;AACA;EACE,cAAc;AAChB;AACA;EACE,UAAU;AACZ;AACA;EACE,kCAAkC;AACpC;;AAEA;EACE,aAAa;EACb,oBAAoB;AACtB;;AAEA;EACE,cAAc;EACd,gBAAgB;EAChB,mBAAmB;EACnB,uBAAuB;EACvB,gBAAgB;EAChB,eAAe;AACjB;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,aAAa;AACf;AACA;EACE,YAAY;AACd;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,gCAAgC;EAChC,+BAA+B;EAC/B,iBAAiB;AACnB;AACA;EACE,mBAAmB;AACrB;;AAEA;;EAEE,mCAAmC;EACnC,iBAAiB;EACjB,6BAA6B;EAC7B,8BAA8B;EAC9B,iBAAiB;EACjB,qBAAqB;AACvB;;AAEA;EACE,kCAAkC;EAClC,6BAA6B;AAC/B;;AAEA;EACE,qBAAqB;EACrB,qBAAqB;AACvB","file":"index.css","sourcesContent":[".list {\n max-height: 300px;\n}\n.list:not(.is-popup) {\n max-height: 400px;\n}\n\n.header {\n border-left: 1px solid #f0f0f0;\n}\n.header .col {\n background: var(--bg-color-grey-1);\n transition: background-color 300ms;\n}\n\n.body {\n border-left: 1px solid #f0f0f0;\n}\n.body .col {\n cursor: pointer;\n}\n.body.is-selected-all {\n cursor: not-allowed;\n background: var(--bg-color-grey-3);\n}\n.body.is-selected-all .col {\n pointer-events: none;\n color: var(--font-color-grey-2);\n}\n.body.is-selected {\n background: var(--primary-color-1);\n color: var(--primary-color);\n}\n.body.is-disabled {\n cursor: not-allowed;\n}\n.body.is-disabled .col {\n pointer-events: none;\n color: var(--font-color-grey-2);\n}\n.body:hover:not(.is-selected-all):not(.is-selected):not(.is-disabled) .col {\n background: var(--bg-color-grey-1);\n}\n\n.col {\n padding: 8px;\n border-bottom: 1px solid #f0f0f0;\n}\n\n.right-options {\n border-left: 1px solid #f0f0f0;\n padding: 8px;\n}\n.right-options:not(.right-options:global(.is-popup)) {\n padding-top: 0;\n}\n.right-options .no-padding-btn:global(.ant-btn) {\n padding: 0;\n}\n.right-options :global .ant-tag {\n background: var(--bg-color-grey-3);\n}\n\n.tag {\n display: flex;\n margin-inline-end: 0;\n}\n\n.tag-inner {\n display: block;\n max-width: 100px;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n cursor: pointer;\n}\n\n.single-checked {\n flex: 0 0 30px;\n}\n\n.select-search {\n display: flex;\n}\n.select-search:global(.is-popup) {\n padding: 8px;\n}\n\n.tags-search {\n display: flex;\n}\n\n.descriptions {\n border-bottom: 1px solid #eeeeee;\n border-right: 1px solid #eeeeee;\n line-height: 20px;\n}\n.descriptions:not(:last-child) {\n border-bottom: none;\n}\n\n.descriptions-col-label,\n.descriptions-col-content {\n font-size: var(--font-size-default);\n padding: 8px 16px;\n border-top: 1px solid #eeeeee;\n border-left: 1px solid #eeeeee;\n line-height: 20px;\n word-break: break-all;\n}\n\n.descriptions-col-label {\n background: var(--bg-color-grey-1);\n color: var(--font-color-grey);\n}\n\n.descriptions-col-content {\n word-break: break-all;\n white-space: pre-line;\n}"]}
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ var last = require('lodash/last');
8
8
  var antd = require('antd');
9
9
  var icons = require('@ant-design/icons');
10
10
  var isEmpty = require('@kne/is-empty');
11
+ var reactIntl = require('@kne/react-intl');
11
12
  var get = require('lodash/get');
12
13
  var SimpleBar = require('simplebar-react');
13
14
  require('simplebar-react/dist/simplebar.min.css');
@@ -36,6 +37,15 @@ function _extends() {
36
37
  return n;
37
38
  }, _extends.apply(null, arguments);
38
39
  }
40
+ function _objectWithoutPropertiesLoose(r, e) {
41
+ if (null == r) return {};
42
+ var t = {};
43
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
44
+ if (-1 !== e.indexOf(n)) continue;
45
+ t[n] = r[n];
46
+ }
47
+ return t;
48
+ }
39
49
 
40
50
  const context = globalContext.createContext();
41
51
  const {
@@ -45,8 +55,29 @@ const {
45
55
 
46
56
  var style$4 = {"select-input":"_d8lGc","disabled":"_3kjwO","wrap":"_dsTM2","select-input-inner":"_NQoX9","large":"_T8ZX8","small":"_1B72H","select-input-icon":"_g8QC-","placeholder":"_r3q69","overlay-content":"_zEqGe","overlay":"_ybN30","select-input-prefix":"_4Pw75","select-input-suffix":"_Wd4pE"};
47
57
 
58
+ const locale$1 = {
59
+ placeholder: '请选择',
60
+ selectAll: '全选',
61
+ selected: '已选',
62
+ search: '搜索',
63
+ numberOf: '{number}个',
64
+ maxLengthError: '最大数量不能超过{maxLength}',
65
+ defaultChildren: '下拉内容,需要调用方实现'
66
+ };
67
+
68
+ const locale = {
69
+ placeholder: 'Please select',
70
+ selectAll: 'Select All',
71
+ selected: 'Selected',
72
+ search: 'Search',
73
+ numberOf: '{number} items',
74
+ maxLengthError: 'The maximum number cannot exceed {maxLength}',
75
+ defaultChildren: 'Dropdown content, to be implemented by the caller'
76
+ };
77
+
78
+ const _excluded$1 = ["children"];
48
79
  const numberToPx = val => {
49
- return typeof val === 'number' ? `${val}px` : val;
80
+ return typeof val === 'number' ? val + "px" : val;
50
81
  };
51
82
  const pxToNumber = value => {
52
83
  if (!value) return 0;
@@ -58,9 +89,9 @@ const pxToNumber = value => {
58
89
  };
59
90
  const ModalContent = _ref => {
60
91
  let {
61
- children,
62
- ...others
63
- } = _ref;
92
+ children
93
+ } = _ref,
94
+ others = _objectWithoutPropertiesLoose(_ref, _excluded$1);
64
95
  const {
65
96
  open,
66
97
  value: propsValue
@@ -84,35 +115,46 @@ const ModalContent = _ref => {
84
115
  value: contextProps
85
116
  }, children(contextProps));
86
117
  };
87
- const SelectInput = React.forwardRef((p, ref) => {
88
- const locale = Object.assign({}, {
89
- placeholder: '请选择',
90
- selectAll: '全选',
91
- selected: '已选',
92
- search: '搜索',
93
- numberOf: '%s个',
94
- maxLengthError: '最大数量不能超过%s',
95
- defaultChildren: '下拉内容,需要调用方实现'
96
- }, p.locale);
118
+ const SelectInput = reactIntl.createWithIntlProvider({
119
+ defaultLocale: 'zh-CN',
120
+ namespace: 'super-select',
121
+ messages: {
122
+ 'zh-CN': locale$1,
123
+ 'en-US': locale
124
+ }
125
+ })(React.forwardRef((p, ref) => {
126
+ const intl = reactIntl.useIntl();
127
+ const {
128
+ formatMessage
129
+ } = intl;
97
130
  const props = Object.assign({}, {
98
- children: () => locale.defaultChildren,
131
+ children: () => formatMessage({
132
+ id: 'defaultChildren'
133
+ }),
99
134
  maxLength: null,
100
135
  defaultOpen: false,
101
136
  single: false,
102
137
  disabled: false,
103
138
  isPopup: true,
104
- placeholder: locale.placeholder,
105
- searchPlaceholder: locale.search,
139
+ placeholder: formatMessage({
140
+ id: 'placeholder'
141
+ }),
142
+ searchPlaceholder: formatMessage({
143
+ id: 'search'
144
+ }),
145
+ completeTips: null,
106
146
  allowSelectedAll: false,
107
147
  labelKey: 'label',
108
148
  valueKey: 'value',
109
149
  selectedAllValue: {
110
150
  value: 'all',
111
- label: locale.selectAll
151
+ label: formatMessage({
152
+ id: 'selectAll'
153
+ })
112
154
  },
113
155
  placement: 'bottomLeft',
114
156
  labelWrap: false,
115
- showSelectedTag: true,
157
+ showSelectedTag: false,
116
158
  allowClear: true,
117
159
  prefix: null,
118
160
  suffix: null,
@@ -141,9 +183,7 @@ const SelectInput = React.forwardRef((p, ref) => {
141
183
  }
142
184
  }, children(contextProps));
143
185
  }
144
- }, p, {
145
- locale
146
- });
186
+ }, p);
147
187
  props.selectedAllValue = {
148
188
  [props.valueKey]: props.selectedAllValue.value,
149
189
  [props.labelKey]: props.selectedAllValue.label
@@ -201,7 +241,11 @@ const SelectInput = React.forwardRef((p, ref) => {
201
241
  } = antd.App.useApp();
202
242
  const checkMaxLength = (value, maxLength) => {
203
243
  if (Number.isInteger(maxLength) && maxLength > 0 && value.length >= maxLength) {
204
- message.error(locale.maxLengthError.replace('%s', maxLength));
244
+ message.error(formatMessage({
245
+ id: 'maxLengthError'
246
+ }, {
247
+ maxLength
248
+ }));
205
249
  return false;
206
250
  }
207
251
  return true;
@@ -330,7 +374,7 @@ const SelectInput = React.forwardRef((p, ref) => {
330
374
  arrow: false,
331
375
  overlayClassName: classnames__default["default"](style$4['overlay'], overlayClassName),
332
376
  trigger: "click",
333
- dropdownRender: () => /*#__PURE__*/React__default["default"].createElement("div", {
377
+ popupRender: () => /*#__PURE__*/React__default["default"].createElement("div", {
334
378
  style: {
335
379
  '--overlay-width': popupOverlayWidth
336
380
  },
@@ -344,11 +388,14 @@ const SelectInput = React.forwardRef((p, ref) => {
344
388
  setOpen(true);
345
389
  }
346
390
  }), /*#__PURE__*/React__default["default"].createElement(ModalContent, contextProps, renderModal)));
347
- });
391
+ }));
348
392
 
349
393
  var style$3 = {"selected-all":"_prlgN"};
350
394
 
351
- const SelectedAll = () => {
395
+ const SelectedAll = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
396
+ const {
397
+ formatMessage
398
+ } = reactIntl.useIntl();
352
399
  const {
353
400
  props,
354
401
  value,
@@ -357,10 +404,13 @@ const SelectedAll = () => {
357
404
  const {
358
405
  unit,
359
406
  selectedAllValue,
360
- locale,
361
407
  valueKey
362
408
  } = Object.assign({}, {
363
- unit: number => locale.numberOf.replace('%s', number)
409
+ unit: number => formatMessage({
410
+ id: 'numberOf'
411
+ }, {
412
+ number
413
+ })
364
414
  }, props);
365
415
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
366
416
  return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
@@ -368,7 +418,9 @@ const SelectedAll = () => {
368
418
  className: classnames__default["default"](style$3['selected-all'], 'selected-all')
369
419
  }, /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
370
420
  gap: 8
371
- }, /*#__PURE__*/React__default["default"].createElement("span", null, locale.selected, ":"), /*#__PURE__*/React__default["default"].createElement("span", null, isSelectedAll ? selectedAllValue.label : typeof unit === 'function' ? unit(value.length) : value.length)), /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement(antd.Checkbox, {
421
+ }, /*#__PURE__*/React__default["default"].createElement("span", null, formatMessage({
422
+ id: 'selected'
423
+ }), ":"), /*#__PURE__*/React__default["default"].createElement("span", null, isSelectedAll ? selectedAllValue.label : typeof unit === 'function' ? unit(value.length) : value.length)), /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement(antd.Checkbox, {
372
424
  checked: isSelectedAll,
373
425
  onChange: e => {
374
426
  const checked = e.target.checked;
@@ -378,25 +430,29 @@ const SelectedAll = () => {
378
430
  setValue([selectedAllValue]);
379
431
  }
380
432
  }
381
- }, locale.selectAll)));
382
- };
433
+ }, formatMessage({
434
+ id: 'selectAll'
435
+ }))));
436
+ });
383
437
  const computedIsSelectAll = function (value, selectedAllValue, valueKey) {
384
438
  if (valueKey === void 0) {
385
439
  valueKey = 'value';
386
440
  }
387
- return value?.length === 1 && get__default["default"](value, `[0][${valueKey}]`) === selectedAllValue[valueKey];
441
+ return (value == null ? void 0 : value.length) === 1 && get__default["default"](value, "[0][" + valueKey + "]") === selectedAllValue[valueKey];
388
442
  };
389
443
 
390
444
  var style$2 = {"label":"_l3KoW","tag-list":"_CCPzb","tag-container":"_dKZHi","tag-container-inner":"_oijCI","tag":"_WmnnS","tag-inner":"_TMcFl"};
391
445
 
392
- const SelectedTagList = () => {
446
+ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
447
+ const {
448
+ formatMessage
449
+ } = reactIntl.useIntl();
393
450
  const {
394
451
  props,
395
452
  value,
396
453
  onRemove
397
454
  } = useContext();
398
455
  const {
399
- locale,
400
456
  single,
401
457
  maxLength,
402
458
  labelKey,
@@ -407,7 +463,9 @@ const SelectedTagList = () => {
407
463
  gap: 8
408
464
  }, /*#__PURE__*/React__default["default"].createElement("div", {
409
465
  className: style$2['label']
410
- }, locale.selected, !single && value.length > 0 && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
466
+ }, formatMessage({
467
+ id: 'selected'
468
+ }), !single && value.length > 0 && "(" + value.length + (Number.isInteger(maxLength) ? "/" + maxLength : '') + ")", ":"), /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
411
469
  className: style$2['tag-container']
412
470
  }, /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
413
471
  gap: 8,
@@ -427,15 +485,16 @@ const SelectedTagList = () => {
427
485
  className: style$2['tag-inner']
428
486
  }, item[labelKey]));
429
487
  }))));
430
- };
488
+ });
431
489
 
432
490
  var style$1 = {"list":"_IsXdU","is-popup":"_-dvpa","default-list":"_QD1Mz","is-selected-all":"_M-mOy","default-list-item":"_KtOsz","is-selected":"_TQhBB","single-checked":"_2rUrh","is-disabled":"_NbwX5","selected-all":"_vN2Fx","selected-tag":"_6oITk","select-search":"_iAH9D","select-list-item-description":"_TCkeJ"};
433
491
 
492
+ const _excluded = ["children"];
434
493
  const SelectList = React.forwardRef((_ref, ref) => {
435
494
  let {
436
- children,
437
- ...p
438
- } = _ref;
495
+ children
496
+ } = _ref,
497
+ p = _objectWithoutPropertiesLoose(_ref, _excluded);
439
498
  const props = Object.assign({}, {
440
499
  renderItemContent: _ref2 => {
441
500
  let {
@@ -621,7 +680,10 @@ const SelectList = React.forwardRef((_ref, ref) => {
621
680
 
622
681
  var style = {"list":"_DrEYJ","is-popup":"_KgWTX","header":"_Vmbrg","col":"_dJmfs","body":"_704J1","is-selected-all":"_qU5zU","is-selected":"_MzyWg","is-disabled":"_5luTv","right-options":"_UXi-g","no-padding-btn":"_iaCir","tag":"_JkYqS","tag-inner":"_VZlBL","single-checked":"_Eiz-u","select-search":"_temy6","tags-search":"_7phL2","descriptions":"_ttNK9","descriptions-col-label":"_xU-i7","descriptions-col-content":"_SvfzQ"};
623
682
 
624
- const SelectTableList = React.forwardRef((p, ref) => {
683
+ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(React.forwardRef((p, ref) => {
684
+ const {
685
+ formatMessage
686
+ } = reactIntl.useIntl();
625
687
  const [tagSearchText, setTagSearchText] = React.useState('');
626
688
  const props = Object.assign({}, {
627
689
  overlayWidth: '600px',
@@ -692,7 +754,6 @@ const SelectTableList = React.forwardRef((p, ref) => {
692
754
  api,
693
755
  selectedAllValue,
694
756
  isPopup,
695
- locale,
696
757
  single,
697
758
  maxLength,
698
759
  getSearchProps,
@@ -846,7 +907,9 @@ const SelectTableList = React.forwardRef((p, ref) => {
846
907
  wrap: false,
847
908
  justify: 'space-between',
848
909
  align: 'middle'
849
- }, /*#__PURE__*/React__default["default"].createElement(antd.Col, null, locale.selected, value.length > 0 && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React__default["default"].createElement(antd.Col, null, /*#__PURE__*/React__default["default"].createElement(antd.Button, {
910
+ }, /*#__PURE__*/React__default["default"].createElement(antd.Col, null, formatMessage({
911
+ id: 'selected'
912
+ }), value.length > 0 && "(" + value.length + (Number.isInteger(maxLength) ? "/" + maxLength : '') + ")", ":"), /*#__PURE__*/React__default["default"].createElement(antd.Col, null, /*#__PURE__*/React__default["default"].createElement(antd.Button, {
850
913
  className: style['no-padding-btn'],
851
914
  type: "link",
852
915
  onClick: () => {
@@ -890,7 +953,7 @@ const SelectTableList = React.forwardRef((p, ref) => {
890
953
  }, item[labelKey])));
891
954
  })))));
892
955
  });
893
- });
956
+ }));
894
957
 
895
958
  exports.SelectInput = SelectInput;
896
959
  exports.SelectTableList = SelectTableList;