@rainbow-oh/yee-c 0.8.17 → 0.8.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.
Files changed (58) hide show
  1. package/dist/cjs/Checkbox/checkbox-group.js +1 -1
  2. package/dist/cjs/Form/Group.js +1 -3
  3. package/dist/cjs/Form/style/index.less +2 -0
  4. package/dist/cjs/Form/utils/validate.d.ts +1 -0
  5. package/dist/cjs/Form/utils/validate.js +3 -2
  6. package/dist/cjs/Select/demo/loading.d.ts +3 -0
  7. package/dist/cjs/Select/demo/loading.js +61 -0
  8. package/dist/cjs/Select/interface.d.ts +6 -1
  9. package/dist/cjs/Select/select.js +3 -0
  10. package/dist/cjs/Selector/selector.js +10 -1
  11. package/dist/cjs/TableSelect/interface.d.ts +5 -0
  12. package/dist/cjs/TableSelect/table-select.js +3 -0
  13. package/dist/cjs/TreeSelect/interface.d.ts +5 -0
  14. package/dist/cjs/TreeSelect/tree-select.js +4 -1
  15. package/dist/cjs/style/themes.css +1 -1
  16. package/dist/cjs/style/variables.css +1 -1
  17. package/dist/cjs/version.d.ts +1 -1
  18. package/dist/cjs/version.js +1 -1
  19. package/dist/esm/Checkbox/checkbox-group.js +1 -1
  20. package/dist/esm/Form/Group.js +2 -2
  21. package/dist/esm/Form/style/index.less +2 -0
  22. package/dist/esm/Form/utils/validate.d.ts +1 -0
  23. package/dist/esm/Form/utils/validate.js +2 -2
  24. package/dist/esm/Select/demo/loading.d.ts +3 -0
  25. package/dist/esm/Select/demo/loading.js +32 -0
  26. package/dist/esm/Select/interface.d.ts +6 -1
  27. package/dist/esm/Select/select.js +3 -1
  28. package/dist/esm/Selector/selector.js +5 -1
  29. package/dist/esm/TableSelect/interface.d.ts +5 -0
  30. package/dist/esm/TableSelect/table-select.js +3 -1
  31. package/dist/esm/TreeSelect/interface.d.ts +5 -0
  32. package/dist/esm/TreeSelect/tree-select.js +3 -1
  33. package/dist/esm/style/themes.css +1 -1
  34. package/dist/esm/style/variables.css +1 -1
  35. package/dist/esm/version.d.ts +1 -1
  36. package/dist/esm/version.js +1 -1
  37. package/dist/umd/yee-c.min.css +1 -1
  38. package/dist/umd/yee-c.min.js +1 -1
  39. package/package.json +1 -1
  40. package/src/Checkbox/checkbox-group.tsx +1 -1
  41. package/src/Form/Group.tsx +2 -4
  42. package/src/Form/style/index.less +2 -0
  43. package/src/Form/utils/validate.ts +7 -2
  44. package/src/Select/demo/loading.tsx +28 -0
  45. package/src/Select/index.en-US.md +2 -0
  46. package/src/Select/index.zh-CN.md +2 -0
  47. package/src/Select/interface.ts +10 -3
  48. package/src/Select/select.tsx +2 -0
  49. package/src/Selector/selector.tsx +10 -1
  50. package/src/TableSelect/index.en-US.md +1 -0
  51. package/src/TableSelect/index.zh-CN.md +1 -0
  52. package/src/TableSelect/interface.ts +5 -0
  53. package/src/TableSelect/table-select.tsx +2 -0
  54. package/src/TreeSelect/index.en-US.md +1 -0
  55. package/src/TreeSelect/index.zh-CN.md +1 -0
  56. package/src/TreeSelect/interface.ts +5 -0
  57. package/src/TreeSelect/tree-select.tsx +2 -0
  58. package/src/version.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainbow-oh/yee-c",
3
- "version": "0.8.17",
3
+ "version": "0.8.19",
4
4
  "description": "yee basic components",
5
5
  "keywords": [
6
6
  "react",
@@ -76,7 +76,7 @@ const CheckboxGroup = (baseprops: CheckboxGroupProps) => {
76
76
  <Checkbox
77
77
  disabled={disabled}
78
78
  {...option}
79
- checked={mergedValue.includes(option.value)}
79
+ checked={mergedValue?.includes(option.value)}
80
80
  key={option.value || index}
81
81
  >
82
82
  {option.label}
@@ -12,7 +12,7 @@ import Grid from '../Grid';
12
12
  import FieldContext from './FieldContext';
13
13
  import FormContext from './FormContext';
14
14
  import type { FieldGroupProps, NamePath, ValidateMessage } from './interface';
15
- import { runValidator } from './utils/validate';
15
+ import { isEmpty, runValidator } from './utils/validate';
16
16
 
17
17
  const Group: React.FC<FieldGroupProps> = (props) => {
18
18
  const { label, required, rules, cols, children, style, className } = props;
@@ -54,9 +54,7 @@ const Group: React.FC<FieldGroupProps> = (props) => {
54
54
 
55
55
  // Required validation: error if any child field is empty
56
56
  if (required) {
57
- const hasEmpty = childNames.some(
58
- (name) => !values[name] && values[name] !== 0,
59
- );
57
+ const hasEmpty = childNames.some((name) => isEmpty(values[name]));
60
58
  if (hasEmpty) {
61
59
  errors.push({
62
60
  name: childNames,
@@ -88,12 +88,14 @@
88
88
  --yee-input-border-color: var(--yee-error-color);
89
89
  --yee-input-hover-border-color: var(--yee-error-color-hover);
90
90
  --yee-input-focus-bs-color: var(--yee-error-color-border);
91
+ --yee-checkbox-border-color: var(--yee-error-color);
91
92
  }
92
93
 
93
94
  &&-warning {
94
95
  --yee-input-border-color: var(--yee-warning-color);
95
96
  --yee-input-hover-border-color: var(--yee-warning-color-hover);
96
97
  --yee-input-focus-bs-color: var(--yee-warning-color-border);
98
+ --yee-checkbox-border-color: var(--yee-warning-color);
97
99
  }
98
100
  }
99
101
  }
@@ -1,7 +1,12 @@
1
1
  import type { Rule } from '../interface';
2
2
 
3
- function isEmpty(v: unknown) {
4
- return v === undefined || v === null || v === '' ? true : false;
3
+ export function isEmpty(value: unknown) {
4
+ return (
5
+ value === undefined ||
6
+ value === null ||
7
+ value === '' ||
8
+ (Array.isArray(value) && value.length === 0)
9
+ );
5
10
  }
6
11
 
7
12
  function verifyRuleOfMin(min: number, value: unknown) {
@@ -0,0 +1,28 @@
1
+ import { Select, Space } from '@rainbow-oh/yee-c';
2
+ import React from 'react';
3
+
4
+ const options = [
5
+ { label: 'Apple', value: 'apple' },
6
+ { label: 'Banana', value: 'banana' },
7
+ { label: 'Orange', value: 'orange' },
8
+ ];
9
+
10
+ export default () => {
11
+ return (
12
+ <Space direction="vertical">
13
+ <Select
14
+ loading
15
+ options={options}
16
+ style={{ width: 200 }}
17
+ placeholder="Loading"
18
+ />
19
+ <Select
20
+ loading
21
+ disabled
22
+ defaultValue="apple"
23
+ options={options}
24
+ style={{ width: 200 }}
25
+ />
26
+ </Space>
27
+ );
28
+ };
@@ -17,6 +17,7 @@ Select component for choosing from a set of options.
17
17
  <code src="./demo/basic.tsx" title="Basic" description="Basic usage of Select"></code>
18
18
  <code src="./demo/size.tsx" title="Size" description="Different sizes of Select"></code>
19
19
  <code src="./demo/disabled.tsx" title="Disabled" description="Disabled Select"></code>
20
+ <code src="./demo/loading.tsx" title="Loading" description="Loading Select, optionally combined with disabled"></code>
20
21
  <code src="./demo/allowClear.tsx" title="Allow Clear" description="Allow clear selected value"></code>
21
22
  <code src="./demo/multiple.tsx" title="Multiple" description="Multiple selection mode"></code>
22
23
  <code src="./demo/search.tsx" title="Search" description="Searchable Select"></code>
@@ -39,6 +40,7 @@ Select component for choosing from a set of options.
39
40
  | defaultValue | `string \| number \| Array<string \| number>` | Default value | - |
40
41
  | value | `string \| number \| Array<string \| number>` | Controlled value | - |
41
42
  | disabled | `boolean` | Whether disabled | - |
43
+ | loading | `boolean` | Whether data is loading; displays a spinner in the selector suffix | `false` |
42
44
  | placeholder | `string` | Placeholder text | - |
43
45
  | placement | `'top' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight'` | Dropdown position | - |
44
46
  | searchable | `boolean` | Whether searchable | - |
@@ -17,6 +17,7 @@ toc: 'content'
17
17
  <code src="./demo/basic.tsx" title="基础用法" description="Select的基础用法"></code>
18
18
  <code src="./demo/size.tsx" title="尺寸" description="不同尺寸的Select"></code>
19
19
  <code src="./demo/disabled.tsx" title="禁用" description="禁用的Select"></code>
20
+ <code src="./demo/loading.tsx" title="加载中" description="加载中的 Select,可与 disabled 组合使用"></code>
20
21
  <code src="./demo/allowClear.tsx" title="可清除" description="可清除已选值"></code>
21
22
  <code src="./demo/multiple.tsx" title="多选" description="多选模式"></code>
22
23
  <code src="./demo/search.tsx" title="可搜索" description="可搜索的Select"></code>
@@ -39,6 +40,7 @@ toc: 'content'
39
40
  | defaultValue | `string \| number \| Array<string \| number>` | 默认值 | - |
40
41
  | value | `string \| number \| Array<string \| number>` | 受控值 | - |
41
42
  | disabled | `boolean` | 是否禁用 | - |
43
+ | loading | `boolean` | 是否处于加载状态,加载时选择框后缀显示加载图标 | `false` |
42
44
  | placeholder | `string` | 选择框默认文本 | - |
43
45
  | placement | `'top' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight'` | 下拉框弹出位置 | - |
44
46
  | searchable | `boolean` | 是否可搜索 | - |
@@ -1,7 +1,6 @@
1
- import type { TriggerProps } from '../Trigger';
2
1
  import type { SelectorProps } from '../Selector';
2
+ import type { TriggerProps } from '../Trigger';
3
3
  import type { DataAttributeProps } from '../utils/types';
4
-
5
4
  export type Option = {
6
5
  /**
7
6
  * Whether disabled
@@ -26,7 +25,10 @@ export type Option = {
26
25
  };
27
26
 
28
27
  export interface SelectProps
29
- extends DataAttributeProps, Pick<SelectorProps, 'size'>, Omit<TriggerProps, 'popup' | 'children'> {
28
+ extends
29
+ DataAttributeProps,
30
+ Pick<SelectorProps, 'size'>,
31
+ Omit<TriggerProps, 'popup' | 'children'> {
30
32
  /**
31
33
  * Custom class name prefix
32
34
  * */
@@ -60,6 +62,11 @@ export interface SelectProps
60
62
  * Whether disabled
61
63
  */
62
64
  disabled?: boolean;
65
+ /**
66
+ * Whether data is loading
67
+ * @default false
68
+ */
69
+ loading?: boolean;
63
70
  /**
64
71
  * Placeholder text for the select box
65
72
  */
@@ -51,6 +51,7 @@ const Select = (baseprops: SelectProps) => {
51
51
  defaultValue,
52
52
  optionFilterProp = 'label',
53
53
  disabled,
54
+ loading,
54
55
  onChange,
55
56
  onFilter,
56
57
  virtual,
@@ -233,6 +234,7 @@ const Select = (baseprops: SelectProps) => {
233
234
  value={searchValue}
234
235
  options={options}
235
236
  disabled={disabled}
237
+ loading={loading}
236
238
  selectedKeys={mergedValue}
237
239
  onOpenChange={handleOpenChange}
238
240
  onClear={handleClear}
@@ -224,7 +224,16 @@ const Selector = React.forwardRef(
224
224
  return (
225
225
  <span className={`${prefixCls}-arrow`}>
226
226
  {loading ? (
227
- <Spin size="small" />
227
+ <Spin
228
+ variant="ring"
229
+ size="small"
230
+ style={
231
+ {
232
+ '--m-indicator-dot-bg-color':
233
+ 'var(--yee-text-color-secondary)',
234
+ } as React.CSSProperties
235
+ }
236
+ />
228
237
  ) : suffix ? (
229
238
  typeof suffix === 'function' ? (
230
239
  suffix()
@@ -43,6 +43,7 @@ A component for selecting one or more options from table data, combining feature
43
43
  | value | `SelectionKeyType \| SelectionKeyType[]` | Controlled value | - |
44
44
  | defaultValue | `SelectionKeyType \| SelectionKeyType[]` | Default value | - |
45
45
  | disabled | `boolean` | Whether disabled | - |
46
+ | loading | `boolean` | Whether data is loading; displays a gray loading indicator | `false` |
46
47
  | placement | `'bottomLeft' \| 'topLeft'` | Popup placement | `'bottomLeft'` |
47
48
  | searchable | `boolean` | Whether searchable | `true` |
48
49
  | searchOnInput | `boolean` | Whether to search while typing | `true` |
@@ -43,6 +43,7 @@ toc: 'content'
43
43
  | value | `SelectionKeyType \| SelectionKeyType[]` | 受控值 | - |
44
44
  | defaultValue | `SelectionKeyType \| SelectionKeyType[]` | 默认值 | - |
45
45
  | disabled | `boolean` | 是否禁用 | - |
46
+ | loading | `boolean` | 是否处于加载状态,加载时显示灰色加载图标 | `false` |
46
47
  | placement | `'bottomLeft' \| 'topLeft'` | 弹出层位置 | `'bottomLeft'` |
47
48
  | searchable | `boolean` | 是否可搜索 | `true` |
48
49
  | searchOnInput | `boolean` | 是否边输入边搜索 | `true` |
@@ -131,6 +131,11 @@ export interface TableSelectProps
131
131
  * Whether disabled
132
132
  */
133
133
  disabled?: boolean;
134
+ /**
135
+ * Whether data is loading
136
+ * @default false
137
+ */
138
+ loading?: boolean;
134
139
  /**
135
140
  * Input direction (for special scenarios)
136
141
  */
@@ -37,6 +37,7 @@ const TableSelect = (baseprops: TableSelectProps) => {
37
37
  defaultValue,
38
38
  placement = 'bottomLeft',
39
39
  disabled,
40
+ loading,
40
41
  rowSelection,
41
42
  dataSource,
42
43
  rowKey = 'id',
@@ -175,6 +176,7 @@ const TableSelect = (baseprops: TableSelectProps) => {
175
176
  options: selectorOptions,
176
177
  open: open,
177
178
  disabled: disabled,
179
+ loading: loading,
178
180
  value: searchValue,
179
181
  selectedKeys: mergedValue,
180
182
  onSearch: handleSearch,
@@ -37,6 +37,7 @@ Tree selection control.
37
37
  | defaultValue | `string \| number \| Array<string \| number>` | Default selected value | - |
38
38
  | value | `string \| number \| Array<string \| number>` | Selected value (controlled) | - |
39
39
  | disabled | `boolean` | Disable the component | - |
40
+ | loading | `boolean` | Whether data is loading; displays a gray loading indicator | `false` |
40
41
  | placeholder | `string` | Placeholder text | - |
41
42
  | placement | `'top' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight'` | Dropdown placement | `'bottomLeft'` |
42
43
  | searchable | `boolean` | Enable search functionality | `true` |
@@ -37,6 +37,7 @@ toc: 'content'
37
37
  | defaultValue | `string \| number \| Array<string \| number>` | 默认值 | - |
38
38
  | value | `string \| number \| Array<string \| number>` | 受控值 | - |
39
39
  | disabled | `boolean` | 是否禁用 | - |
40
+ | loading | `boolean` | 是否处于加载状态,加载时显示灰色加载图标 | `false` |
40
41
  | placeholder | `string` | 选择框默认文本 | - |
41
42
  | placement | `'top' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight'` | 下拉框弹出位置 | `'bottomLeft'` |
42
43
  | searchable | `boolean` | 是否可搜索 | `true` |
@@ -37,6 +37,11 @@ export interface TreeSelectProps<T = any>
37
37
  * Whether disabled
38
38
  */
39
39
  disabled?: boolean;
40
+ /**
41
+ * Whether data is loading
42
+ * @default false
43
+ */
44
+ loading?: boolean;
40
45
  /**
41
46
  * Placeholder text for the select box
42
47
  */
@@ -32,6 +32,7 @@ const TreeSelect = <T extends Record<string, unknown> = any>(
32
32
  defaultValue,
33
33
  checkable = false,
34
34
  multiple = false, // eslint-disable-line @typescript-eslint/no-unused-vars
35
+ loading,
35
36
  optionLabelProp = 'label',
36
37
  onChange,
37
38
  onFilter,
@@ -242,6 +243,7 @@ const TreeSelect = <T extends Record<string, unknown> = any>(
242
243
  mode={mode}
243
244
  value={searchValue}
244
245
  options={selectedOptions}
246
+ loading={loading}
245
247
  selectedKeys={mergedValue}
246
248
  onOpenChange={handleOpenChange}
247
249
  onClear={handleClear}
package/src/version.ts CHANGED
@@ -4,7 +4,7 @@ declare global {
4
4
  }
5
5
  }
6
6
 
7
- export const version = "0.8.17";
7
+ export const version = "0.8.19";
8
8
 
9
9
  if (typeof window !== 'undefined') {
10
10
  window.__yee_c_version__ = version;