@kne/super-select 0.1.15 → 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;
@@ -201,6 +204,12 @@
201
204
  ._iAH9D.is-popup {
202
205
  padding: 12px;
203
206
  }
207
+
208
+ ._TCkeJ {
209
+ white-space: nowrap;
210
+ overflow: hidden;
211
+ text-overflow: ellipsis;
212
+ }
204
213
  ._DrEYJ {
205
214
  max-height: 300px;
206
215
  }
@@ -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;AAjFA;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,11 +8,13 @@ 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');
14
15
  var SearchInput = require('@kne/search-input');
15
16
  var scrollLoader = require('@kne/scroll-loader');
17
+ require('@kne/scroll-loader/dist/index.css');
16
18
 
17
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
20
 
@@ -39,7 +41,7 @@ function _objectWithoutPropertiesLoose(r, e) {
39
41
  if (null == r) return {};
40
42
  var t = {};
41
43
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
42
- if (e.includes(n)) continue;
44
+ if (-1 !== e.indexOf(n)) continue;
43
45
  t[n] = r[n];
44
46
  }
45
47
  return t;
@@ -53,6 +55,26 @@ const {
53
55
 
54
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"};
55
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
+
56
78
  const _excluded$1 = ["children"];
57
79
  const numberToPx = val => {
58
80
  return typeof val === 'number' ? val + "px" : val;
@@ -93,35 +115,46 @@ const ModalContent = _ref => {
93
115
  value: contextProps
94
116
  }, children(contextProps));
95
117
  };
96
- const SelectInput = React.forwardRef((p, ref) => {
97
- const locale = Object.assign({}, {
98
- placeholder: '请选择',
99
- selectAll: '全选',
100
- selected: '已选',
101
- search: '搜索',
102
- numberOf: '%s个',
103
- maxLengthError: '最大数量不能超过%s',
104
- defaultChildren: '下拉内容,需要调用方实现'
105
- }, 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;
106
130
  const props = Object.assign({}, {
107
- children: () => locale.defaultChildren,
131
+ children: () => formatMessage({
132
+ id: 'defaultChildren'
133
+ }),
108
134
  maxLength: null,
109
135
  defaultOpen: false,
110
136
  single: false,
111
137
  disabled: false,
112
138
  isPopup: true,
113
- placeholder: locale.placeholder,
114
- searchPlaceholder: locale.search,
139
+ placeholder: formatMessage({
140
+ id: 'placeholder'
141
+ }),
142
+ searchPlaceholder: formatMessage({
143
+ id: 'search'
144
+ }),
145
+ completeTips: null,
115
146
  allowSelectedAll: false,
116
147
  labelKey: 'label',
117
148
  valueKey: 'value',
118
149
  selectedAllValue: {
119
150
  value: 'all',
120
- label: locale.selectAll
151
+ label: formatMessage({
152
+ id: 'selectAll'
153
+ })
121
154
  },
122
155
  placement: 'bottomLeft',
123
156
  labelWrap: false,
124
- showSelectedTag: true,
157
+ showSelectedTag: false,
125
158
  allowClear: true,
126
159
  prefix: null,
127
160
  suffix: null,
@@ -150,9 +183,7 @@ const SelectInput = React.forwardRef((p, ref) => {
150
183
  }
151
184
  }, children(contextProps));
152
185
  }
153
- }, p, {
154
- locale
155
- });
186
+ }, p);
156
187
  props.selectedAllValue = {
157
188
  [props.valueKey]: props.selectedAllValue.value,
158
189
  [props.labelKey]: props.selectedAllValue.label
@@ -210,7 +241,11 @@ const SelectInput = React.forwardRef((p, ref) => {
210
241
  } = antd.App.useApp();
211
242
  const checkMaxLength = (value, maxLength) => {
212
243
  if (Number.isInteger(maxLength) && maxLength > 0 && value.length >= maxLength) {
213
- message.error(locale.maxLengthError.replace('%s', maxLength));
244
+ message.error(formatMessage({
245
+ id: 'maxLengthError'
246
+ }, {
247
+ maxLength
248
+ }));
214
249
  return false;
215
250
  }
216
251
  return true;
@@ -339,7 +374,7 @@ const SelectInput = React.forwardRef((p, ref) => {
339
374
  arrow: false,
340
375
  overlayClassName: classnames__default["default"](style$4['overlay'], overlayClassName),
341
376
  trigger: "click",
342
- dropdownRender: () => /*#__PURE__*/React__default["default"].createElement("div", {
377
+ popupRender: () => /*#__PURE__*/React__default["default"].createElement("div", {
343
378
  style: {
344
379
  '--overlay-width': popupOverlayWidth
345
380
  },
@@ -353,11 +388,14 @@ const SelectInput = React.forwardRef((p, ref) => {
353
388
  setOpen(true);
354
389
  }
355
390
  }), /*#__PURE__*/React__default["default"].createElement(ModalContent, contextProps, renderModal)));
356
- });
391
+ }));
357
392
 
358
393
  var style$3 = {"selected-all":"_prlgN"};
359
394
 
360
- const SelectedAll = () => {
395
+ const SelectedAll = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
396
+ const {
397
+ formatMessage
398
+ } = reactIntl.useIntl();
361
399
  const {
362
400
  props,
363
401
  value,
@@ -366,10 +404,13 @@ const SelectedAll = () => {
366
404
  const {
367
405
  unit,
368
406
  selectedAllValue,
369
- locale,
370
407
  valueKey
371
408
  } = Object.assign({}, {
372
- unit: number => locale.numberOf.replace('%s', number)
409
+ unit: number => formatMessage({
410
+ id: 'numberOf'
411
+ }, {
412
+ number
413
+ })
373
414
  }, props);
374
415
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
375
416
  return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
@@ -377,7 +418,9 @@ const SelectedAll = () => {
377
418
  className: classnames__default["default"](style$3['selected-all'], 'selected-all')
378
419
  }, /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
379
420
  gap: 8
380
- }, /*#__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, {
381
424
  checked: isSelectedAll,
382
425
  onChange: e => {
383
426
  const checked = e.target.checked;
@@ -387,8 +430,10 @@ const SelectedAll = () => {
387
430
  setValue([selectedAllValue]);
388
431
  }
389
432
  }
390
- }, locale.selectAll)));
391
- };
433
+ }, formatMessage({
434
+ id: 'selectAll'
435
+ }))));
436
+ });
392
437
  const computedIsSelectAll = function (value, selectedAllValue, valueKey) {
393
438
  if (valueKey === void 0) {
394
439
  valueKey = 'value';
@@ -398,14 +443,16 @@ const computedIsSelectAll = function (value, selectedAllValue, valueKey) {
398
443
 
399
444
  var style$2 = {"label":"_l3KoW","tag-list":"_CCPzb","tag-container":"_dKZHi","tag-container-inner":"_oijCI","tag":"_WmnnS","tag-inner":"_TMcFl"};
400
445
 
401
- const SelectedTagList = () => {
446
+ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
447
+ const {
448
+ formatMessage
449
+ } = reactIntl.useIntl();
402
450
  const {
403
451
  props,
404
452
  value,
405
453
  onRemove
406
454
  } = useContext();
407
455
  const {
408
- locale,
409
456
  single,
410
457
  maxLength,
411
458
  labelKey,
@@ -416,7 +463,9 @@ const SelectedTagList = () => {
416
463
  gap: 8
417
464
  }, /*#__PURE__*/React__default["default"].createElement("div", {
418
465
  className: style$2['label']
419
- }, 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"], {
420
469
  className: style$2['tag-container']
421
470
  }, /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
422
471
  gap: 8,
@@ -436,9 +485,9 @@ const SelectedTagList = () => {
436
485
  className: style$2['tag-inner']
437
486
  }, item[labelKey]));
438
487
  }))));
439
- };
488
+ });
440
489
 
441
- 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"};
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"};
442
491
 
443
492
  const _excluded = ["children"];
444
493
  const SelectList = React.forwardRef((_ref, ref) => {
@@ -458,7 +507,7 @@ const SelectList = React.forwardRef((_ref, ref) => {
458
507
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
459
508
  className: 'select-list-item-label'
460
509
  }, item[labelKey]), item.description && /*#__PURE__*/React__default["default"].createElement("div", {
461
- className: 'select-list-item-description'
510
+ className: classnames__default["default"](style$1['select-list-item-description'], 'select-list-item-description')
462
511
  }, item.description));
463
512
  },
464
513
  renderItem: contextProps => {
@@ -631,7 +680,10 @@ const SelectList = React.forwardRef((_ref, ref) => {
631
680
 
632
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"};
633
682
 
634
- 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();
635
687
  const [tagSearchText, setTagSearchText] = React.useState('');
636
688
  const props = Object.assign({}, {
637
689
  overlayWidth: '600px',
@@ -702,7 +754,6 @@ const SelectTableList = React.forwardRef((p, ref) => {
702
754
  api,
703
755
  selectedAllValue,
704
756
  isPopup,
705
- locale,
706
757
  single,
707
758
  maxLength,
708
759
  getSearchProps,
@@ -856,7 +907,9 @@ const SelectTableList = React.forwardRef((p, ref) => {
856
907
  wrap: false,
857
908
  justify: 'space-between',
858
909
  align: 'middle'
859
- }, /*#__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, {
860
913
  className: style['no-padding-btn'],
861
914
  type: "link",
862
915
  onClick: () => {
@@ -900,7 +953,7 @@ const SelectTableList = React.forwardRef((p, ref) => {
900
953
  }, item[labelKey])));
901
954
  })))));
902
955
  });
903
- });
956
+ }));
904
957
 
905
958
  exports.SelectInput = SelectInput;
906
959
  exports.SelectTableList = SelectTableList;