@oceanbase/design 1.0.0-alpha.16 → 1.0.0-alpha.18

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 (52) hide show
  1. package/dist/design.min.js +1 -1
  2. package/es/_util/genComponentStyleHook.js +6 -2
  3. package/es/alert/index.d.ts +1 -1
  4. package/es/alert/index.js +4 -2
  5. package/es/config-provider/index.d.ts +2 -0
  6. package/es/config-provider/index.js +68 -38
  7. package/es/filter/FilterContext.d.ts +1 -1
  8. package/es/filter/components/FilterButton.js +31 -7
  9. package/es/filter/components/FilterCascader/components/FlatCascaderContent/index.d.ts +4 -3
  10. package/es/filter/components/FilterCascader/components/FlatCascaderContent/index.js +20 -6
  11. package/es/filter/components/FilterCascader/components/NormalCascaderContent.js +2 -7
  12. package/es/filter/components/FilterCheckbox.js +29 -7
  13. package/es/filter/components/FilterInput.d.ts +2 -0
  14. package/es/filter/components/FilterInput.js +18 -4
  15. package/es/filter/components/FilterSlot.d.ts +28 -0
  16. package/es/filter/components/FilterSlot.js +189 -0
  17. package/es/filter/components/FilterWrap.js +39 -1
  18. package/es/filter/components/ResponsiveFilterGroup.js +284 -356
  19. package/es/filter/index.d.ts +2 -0
  20. package/es/filter/index.js +13 -7
  21. package/es/filter/style/index.js +1 -1
  22. package/es/filter/type.d.ts +2 -0
  23. package/es/table/index.d.ts +2 -2
  24. package/es/table/style/index.js +34 -16
  25. package/es/theme/default.d.ts +12 -0
  26. package/es/theme/default.js +27 -5
  27. package/lib/_util/genComponentStyleHook.js +6 -2
  28. package/lib/alert/index.d.ts +1 -1
  29. package/lib/alert/index.js +3 -1
  30. package/lib/config-provider/index.d.ts +2 -0
  31. package/lib/config-provider/index.js +38 -2
  32. package/lib/filter/FilterContext.d.ts +1 -1
  33. package/lib/filter/components/FilterButton.js +23 -4
  34. package/lib/filter/components/FilterCascader/components/FlatCascaderContent/index.d.ts +4 -3
  35. package/lib/filter/components/FilterCascader/components/FlatCascaderContent/index.js +12 -5
  36. package/lib/filter/components/FilterCascader/components/NormalCascaderContent.js +2 -7
  37. package/lib/filter/components/FilterCheckbox.js +29 -7
  38. package/lib/filter/components/FilterInput.d.ts +2 -0
  39. package/lib/filter/components/FilterInput.js +18 -3
  40. package/lib/filter/components/FilterSlot.d.ts +28 -0
  41. package/lib/filter/components/FilterSlot.js +174 -0
  42. package/lib/filter/components/FilterWrap.js +36 -1
  43. package/lib/filter/components/ResponsiveFilterGroup.js +242 -339
  44. package/lib/filter/index.d.ts +2 -0
  45. package/lib/filter/index.js +13 -7
  46. package/lib/filter/style/index.js +1 -1
  47. package/lib/filter/type.d.ts +2 -0
  48. package/lib/table/index.d.ts +2 -2
  49. package/lib/table/style/index.js +28 -19
  50. package/lib/theme/default.d.ts +12 -0
  51. package/lib/theme/default.js +29 -6
  52. package/package.json +2 -2
@@ -7,6 +7,7 @@ export type { FilterCascaderProps, CascaderOption } from './components/FilterCas
7
7
  export type { FilterSwitchProps } from './components/FilterSwitch';
8
8
  export type { FilterRangeProps, RangeOption } from './components/FilterRange';
9
9
  export type { FilterInputProps } from './components/FilterInput';
10
+ export type { FilterSlotProps } from './components/FilterSlot';
10
11
  export type { FilterWrapProps } from './components/FilterWrap';
11
12
  export type { ResponsiveFilterGroupProps } from './components/ResponsiveFilterGroup';
12
13
  declare const Filter: {
@@ -17,6 +18,7 @@ declare const Filter: {
17
18
  Cascader: import("react").FC<import("./components/FilterCascader/types").FilterCascaderProps>;
18
19
  Switch: import("react").FC<import("./components/FilterSwitch").FilterSwitchProps>;
19
20
  Input: import("react").FC<import("./components/FilterInput").FilterInputProps>;
21
+ Slot: import("react").FC<import("./components/FilterSlot").FilterSlotProps>;
20
22
  ResponsiveGroup: import("react").FC<import("./components/ResponsiveFilterGroup").ResponsiveFilterGroupProps>;
21
23
  };
22
24
  export default Filter;
@@ -4,18 +4,24 @@ import Checkbox from "./components/FilterCheckbox";
4
4
  import Range from "./components/FilterRange";
5
5
  import Input from "./components/FilterInput";
6
6
  import Select from "./components/FilterSelect";
7
+ import Slot from "./components/FilterSlot";
7
8
  import Switch from "./components/FilterSwitch";
8
9
  import Wrap from "./components/FilterWrap";
9
10
  import ResponsiveGroup from "./components/ResponsiveFilterGroup";
10
11
  export { FilterProvider, useFilterContext } from "./FilterContext";
12
+ function markAsFilterComponent(component) {
13
+ component.__isFilterComponent = true;
14
+ return component;
15
+ }
11
16
  var Filter = {
12
- Select: Select,
13
- Checkbox: Checkbox,
14
- Range: Range,
15
- Wrap: Wrap,
16
- Cascader: Cascader,
17
- Switch: Switch,
18
- Input: Input,
17
+ Select: markAsFilterComponent(Select),
18
+ Checkbox: markAsFilterComponent(Checkbox),
19
+ Range: markAsFilterComponent(Range),
20
+ Wrap: markAsFilterComponent(Wrap),
21
+ Cascader: markAsFilterComponent(Cascader),
22
+ Switch: markAsFilterComponent(Switch),
23
+ Input: markAsFilterComponent(Input),
24
+ Slot: markAsFilterComponent(Slot),
19
25
  ResponsiveGroup: ResponsiveGroup
20
26
  };
21
27
  export default Filter;
@@ -151,7 +151,7 @@ var genFilterButtonStyle = function genFilterButtonStyle(token) {
151
151
  justifyContent: 'right',
152
152
  color: token.colorText,
153
153
  whiteSpace: 'nowrap',
154
- maxWidth: '260px',
154
+ maxWidth: '268px',
155
155
  '&:hover': _defineProperty(_defineProperty({}, "".concat(componentCls, "-arrow-icon"), {
156
156
  opacity: 0,
157
157
  visibility: 'hidden'
@@ -21,6 +21,8 @@ export interface BaseFilterProps extends Omit<PopoverProps, 'title' | 'content'
21
21
  alwaysCollapse?: boolean;
22
22
  /** 是否显示后缀图标区域(包括下拉箭头和清除图标),默认 true */
23
23
  showSuffixIcon?: boolean;
24
+ /** 是否显示清除按钮,默认 true */
25
+ allowClear?: boolean;
24
26
  }
25
27
  /** 内部属性,用于标记组件是否在折叠模式中 */
26
28
  export interface InternalFilterProps {
@@ -38,8 +38,8 @@ declare const _default: (<RecordType extends AnyObject = AnyObject>(props: Table
38
38
  SELECTION_ALL: "SELECT_ALL";
39
39
  SELECTION_INVERT: "SELECT_INVERT";
40
40
  SELECTION_NONE: "SELECT_NONE";
41
- Column: <RecordType_1 extends import("antd/es/_util/type").AnyObject>(_: import("antd").TableColumnProps<RecordType_1>) => null;
42
- ColumnGroup: <RecordType_2 extends import("antd/es/_util/type").AnyObject>(_: import("antd/es/table/ColumnGroup").ColumnGroupProps<RecordType_2>) => null;
41
+ Column: <RecordType extends import("antd/es/_util/type").AnyObject>(_: import("antd").TableColumnProps<RecordType>) => null;
42
+ ColumnGroup: <RecordType_1 extends import("antd/es/_util/type").AnyObject>(_: import("antd/es/table/ColumnGroup").ColumnGroupProps<RecordType_1>) => null;
43
43
  Summary: typeof Summary;
44
44
  useStyle: (prefixCls: string, rootCls?: string) => readonly [(node: ReactElement<any, string | React.JSXElementConstructor<any>>) => ReactElement<any, string | React.JSXElementConstructor<any>>, string, string];
45
45
  useDefaultPagination: (pagination?: false | import("antd").TablePaginationConfig) => false | import("antd").TablePaginationConfig;
@@ -5,19 +5,34 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { unit } from '@ant-design/cssinjs';
8
+ import { prepareComponentToken } from 'antd/es/table/style';
8
9
  import { genStyleHooks } from "../../_util/genComponentStyleHook";
10
+ /**
11
+ * 单元格是否与全局正文同档(`cellFontSize === token.fontSize`)。
12
+ */
13
+ var isTableCellBodyFontScale = function isTableCellBodyFontScale(token) {
14
+ return token.cellFontSize === token.fontSize;
15
+ };
16
+ var getTableCellLineHeight = function getTableCellLineHeight(token) {
17
+ return isTableCellBodyFontScale(token) ? token.lineHeight : token.lineHeightSM;
18
+ };
19
+ var getTableEmbeddedControlHeight = function getTableEmbeddedControlHeight(token) {
20
+ return isTableCellBodyFontScale(token) ? token.controlHeight : token.controlHeightSM;
21
+ };
9
22
  var genSmallBtnStyle = function genSmallBtnStyle(token) {
10
23
  var antCls = token.antCls;
24
+ var cellLineHeight = getTableCellLineHeight(token);
25
+ var controlH = getTableEmbeddedControlHeight(token);
11
26
  return _defineProperty({}, "".concat(antCls, "-btn:not(").concat(antCls, "-btn-sm):not(").concat(antCls, "-btn-lg)"), _defineProperty(_defineProperty(_defineProperty({
12
- height: token.controlHeightSM,
13
- fontSize: token.fontSizeSM,
14
- lineHeight: token.lineHeightSM
27
+ height: controlH,
28
+ fontSize: token.cellFontSize,
29
+ lineHeight: cellLineHeight
15
30
  }, "&:not(".concat(antCls, "-btn-icon-only):not(").concat(antCls, "-btn-circle)"), {
16
31
  paddingInline: token.paddingXS
17
32
  }), "&".concat(antCls, "-btn-icon-only"), {
18
- width: token.controlHeightSM
33
+ width: controlH
19
34
  }), "&".concat(antCls, "-btn-circle"), {
20
- minWidth: token.controlHeightSM
35
+ minWidth: controlH
21
36
  }));
22
37
  };
23
38
  export var genTableStyle = function genTableStyle(token) {
@@ -37,9 +52,10 @@ export var genTableStyle = function genTableStyle(token) {
37
52
  marginLG = token.marginLG,
38
53
  marginXS = token.marginXS,
39
54
  calc = token.calc;
55
+ var cellLineHeight = getTableCellLineHeight(token);
56
+ var embeddedControlH = getTableEmbeddedControlHeight(token);
40
57
  return _ref2 = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref2, "".concat(componentCls, "-wrapper ").concat(componentCls), _defineProperty(_defineProperty(_defineProperty({
41
- // to match fontSizeSM lineHeight
42
- lineHeight: token.lineHeightSM,
58
+ lineHeight: cellLineHeight,
43
59
  color: colorText,
44
60
  backgroundColor: colorBgBase,
45
61
  borderRadius: borderRadiusLG
@@ -91,8 +107,8 @@ export var genTableStyle = function genTableStyle(token) {
91
107
  backgroundColor: colorBgBase
92
108
  }), "a", {
93
109
  fontWeight: token.fontWeightStrong,
94
- // work for ProTable link style
95
- fontSize: token.fontSizeSM
110
+ // work for ProTable link style;与单元格字号一致
111
+ fontSize: token.cellFontSize
96
112
  })), genSmallBtnStyle(token)), {}, _defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls, "-placeholder td"), {}), "".concat(componentCls, "-empty-wrapper"), {
97
113
  minHeight: calc(360).sub(calc(token.paddingXS).mul(2).equal()).equal(),
98
114
  display: 'flex',
@@ -182,19 +198,19 @@ export var genTableStyle = function genTableStyle(token) {
182
198
  // hide empty when Table loading
183
199
  visibility: 'hidden'
184
200
  }))), "".concat(componentCls, "-wrapper"), _defineProperty({}, "".concat(componentCls, "-pagination"), _defineProperty(_defineProperty({}, "&".concat(antCls, "-pagination"), _defineProperty(_defineProperty(_defineProperty({
185
- fontSize: token.fontSizeSM,
201
+ fontSize: token.cellFontSize,
186
202
  padding: "".concat(unit(token.paddingSM), " 0"),
187
203
  margin: 0
188
204
  }, "".concat(componentCls, "-wrapper").concat(componentCls, "-has-bordered &"), {
189
205
  marginInlineEnd: marginLG
190
206
  }), "".concat(antCls, "-pagination-item, ").concat(antCls, "-pagination-total-text, ").concat(antCls, "-pagination-prev, ").concat(antCls, "-pagination-next"), {
191
- height: token.controlHeightSM,
192
- minWidth: token.controlHeightSM,
193
- lineHeight: unit(calc(token.controlHeightSM).sub(calc(token.lineWidth).mul(2)).equal())
207
+ height: embeddedControlH,
208
+ minWidth: embeddedControlH,
209
+ lineHeight: unit(calc(embeddedControlH).sub(calc(token.lineWidth).mul(2)).equal())
194
210
  }), "".concat(antCls, "-pagination-options ").concat(antCls, "-select-single"), _defineProperty({
195
- height: token.controlHeightSM
211
+ height: embeddedControlH
196
212
  }, "".concat(antCls, "-select-selector"), {
197
- fontSize: token.fontSizeSM,
213
+ fontSize: token.cellFontSize,
198
214
  paddingInline: calc(token.paddingXS).sub(token.lineWidth).equal()
199
215
  }))), "".concat(componentCls, "-batch-operation-bar"), _objectSpread(_defineProperty({
200
216
  position: 'absolute',
@@ -207,6 +223,8 @@ export var genTableStyle = function genTableStyle(token) {
207
223
  minHeight: 'auto'
208
224
  })));
209
225
  };
226
+
227
+ // 经 genComponentStyleHook 注册为 ['Table','oceanbase']:合并 components.Table,且不与 antd 主 Table 样式钩子冲突。
210
228
  export default genStyleHooks('Table', function (token) {
211
229
  return [genTableStyle(token)];
212
- });
230
+ }, prepareComponentToken);
@@ -46,5 +46,17 @@ export declare const fontFamilyEn = "Inter, 'Noto sans', sans-serif, Roboto, 'Op
46
46
  export declare const fontWeightWeakEn = 300;
47
47
  export declare const fontWeightEn = 500;
48
48
  export declare const fontWeightStrongEn = 600;
49
+ /** 正文字号(非 Cn),与 token.fontSize 一致;命名对齐 fontFamilyEn / fontWeightEn */
50
+ export declare const fontSizeEn = 13;
51
+ /** Table 单元格字号(非 Cn),与 components.Table.cellFontSize 默认值一致 */
52
+ export declare const tableCellFontSizeEn = 12;
53
+ /** Cn 正文/表内字号补丁(由 config-provider `getLocaleFontSizeThemePatch` 消费) */
54
+ export declare const fontSizeCn = 14;
55
+ export declare const fontHeightCn = 22;
56
+ export declare const lineHeightCn: number;
49
57
  declare const _default: import("antd").ThemeConfig;
50
58
  export default _default;
59
+ /**
60
+ * Whether the BCP 47 locale should use Cn typography sizing (14px body + table cells; zh/ja/ko).
61
+ */
62
+ export declare function isCnLikeLocale(locale: string | undefined): boolean;
@@ -89,6 +89,17 @@ export var fontFamilyEn = "Inter, 'Noto sans', sans-serif, Roboto, 'Open Sans',
89
89
  export var fontWeightWeakEn = 300;
90
90
  export var fontWeightEn = 500;
91
91
  export var fontWeightStrongEn = 600;
92
+
93
+ /** 正文字号(非 Cn),与 token.fontSize 一致;命名对齐 fontFamilyEn / fontWeightEn */
94
+ export var fontSizeEn = 13;
95
+
96
+ /** Table 单元格字号(非 Cn),与 components.Table.cellFontSize 默认值一致 */
97
+ export var tableCellFontSizeEn = fontSizeSM;
98
+
99
+ /** Cn 正文/表内字号补丁(由 config-provider `getLocaleFontSizeThemePatch` 消费) */
100
+ export var fontSizeCn = 14;
101
+ export var fontHeightCn = 22;
102
+ export var lineHeightCn = fontHeightCn / fontSizeCn;
92
103
  var lineHeightSM = 20 / 12;
93
104
  var defaultTheme = {
94
105
  token: {
@@ -102,9 +113,9 @@ var defaultTheme = {
102
113
  borderRadiusMD: borderRadiusMD,
103
114
  borderRadiusLG: borderRadiusLG,
104
115
  fontSizeSM: fontSizeSM,
105
- fontSize: 13,
116
+ fontSize: fontSizeEn,
106
117
  lineHeightSM: lineHeightSM,
107
- lineHeight: 20 / 13,
118
+ lineHeight: 20 / fontSizeEn,
108
119
  lineHeightLG: 24 / 16,
109
120
  fontHeight: 20,
110
121
  fontSizeLG: 16,
@@ -112,12 +123,12 @@ var defaultTheme = {
112
123
  fontSizeHeading2: 20,
113
124
  fontSizeHeading3: 18,
114
125
  fontSizeHeading4: 16,
115
- fontSizeHeading5: 13,
126
+ fontSizeHeading5: fontSizeEn,
116
127
  lineHeightHeading1: 32 / 24,
117
128
  lineHeightHeading2: 28 / 20,
118
129
  lineHeightHeading3: 26 / 18,
119
130
  lineHeightHeading4: 24 / 16,
120
- lineHeightHeading5: 20 / 13,
131
+ lineHeightHeading5: 20 / fontSizeEn,
121
132
  controlHeightSM: 24,
122
133
  controlHeight: 28,
123
134
  colorLinkHover: blue5,
@@ -443,4 +454,15 @@ defaultTheme.token = _objectSpread(_objectSpread({}, defaultTheme.token), {}, {
443
454
  yellow: defaultTheme === null || defaultTheme === void 0 || (_defaultTheme$token3 = defaultTheme.token) === null || _defaultTheme$token3 === void 0 ? void 0 : _defaultTheme$token3.colorWarning,
444
455
  red: defaultTheme === null || defaultTheme === void 0 || (_defaultTheme$token4 = defaultTheme.token) === null || _defaultTheme$token4 === void 0 ? void 0 : _defaultTheme$token4.colorError
445
456
  });
446
- export default formatTheme(defaultTheme);
457
+ export default formatTheme(defaultTheme);
458
+
459
+ /**
460
+ * Whether the BCP 47 locale should use Cn typography sizing (14px body + table cells; zh/ja/ko).
461
+ */
462
+ export function isCnLikeLocale(locale) {
463
+ if (locale == null || locale === '') {
464
+ return false;
465
+ }
466
+ var primary = String(locale).toLowerCase().replace(/_/g, '-').split('-')[0];
467
+ return primary === 'zh' || primary === 'ja' || primary === 'ko';
468
+ }
@@ -33,8 +33,12 @@ exports.genSelectCommonStyle = genSelectCommonStyle;
33
33
  function genStyleHooks(componentName, styleFn, getDefaultToken, options) {
34
34
  const normalizedComponentName = Array.isArray(componentName) ? componentName[0] : componentName;
35
35
 
36
- // Create the component name with OB- prefix
37
- const obComponentName = Array.isArray(componentName) ? [`OB-${normalizedComponentName}`, componentName[1]] : `OB-${normalizedComponentName}`;
36
+ /**
37
+ * 使用 [Component, subName] 注册,第一维与 antd 一致以便合并 `theme.components[Component]`(如 Table.cellFontSize);
38
+ * 第二维与 antd 默认样式区分,避免覆盖/顶替同组件的主样式钩子。
39
+ */
40
+ const OCEANBASE_SUB_STYLE = 'oceanbase';
41
+ const obComponentName = Array.isArray(componentName) ? [normalizedComponentName, `${OCEANBASE_SUB_STYLE}-${componentName[1]}`] : [normalizedComponentName, OCEANBASE_SUB_STYLE];
38
42
  return (0, _internal.genStyleHooks)(obComponentName, token => {
39
43
  const styles = [];
40
44
 
@@ -6,7 +6,7 @@ export interface AlertProps extends AntAlertProps {
6
6
  mini?: boolean;
7
7
  }
8
8
  declare const Alert: {
9
- ({ type: typeProp, showIcon, closable, ghost, mini, banner, action, prefixCls: customizePrefixCls, className, ...restProps }: AlertProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
9
+ ({ type: typeProp, showIcon, closable, closeIcon, ghost, mini, banner, action, prefixCls: customizePrefixCls, className, ...restProps }: AlertProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
10
10
  ErrorBoundary: typeof import("antd/es/alert/ErrorBoundary").default;
11
11
  displayName: string;
12
12
  };
@@ -37,6 +37,7 @@ const Alert = ({
37
37
  type: typeProp,
38
38
  showIcon = true,
39
39
  closable,
40
+ closeIcon,
40
41
  ghost,
41
42
  mini,
42
43
  banner,
@@ -53,7 +54,7 @@ const Alert = ({
53
54
  const prefixCls = getPrefixCls('alert', customizePrefixCls);
54
55
  const [wrapCSSVar] = (0, _style.default)(prefixCls);
55
56
  const alertCls = (0, _classnames.default)({
56
- [`${prefixCls}-closable`]: closable,
57
+ [`${prefixCls}-closable`]: closable || closeIcon,
57
58
  [`${prefixCls}-ghost`]: ghost,
58
59
  [`${prefixCls}-mini`]: mini,
59
60
  [`${prefixCls}-with-action`]: !!action
@@ -62,6 +63,7 @@ const Alert = ({
62
63
  type: type,
63
64
  showIcon: showIcon,
64
65
  closable: closable,
66
+ closeIcon: closeIcon,
65
67
  banner: banner,
66
68
  icon: iconMapOutlined[type],
67
69
  action: action,
@@ -63,5 +63,7 @@ export type ConfigProviderType = React.FC<ConfigProviderProps> & {
63
63
  config: typeof AntConfigProvider.config;
64
64
  useConfig: typeof AntConfigProvider.useConfig;
65
65
  };
66
+ /** Cn 字号补丁(正文 + Table 单元格),供单测与 ConfigProvider 共用。 */
67
+ export declare function getLocaleFontSizeThemePatch(mergedLocale: Locale, mergedTheme: ThemeConfig, resolvedFontSize: number | undefined): ThemeConfig;
66
68
  declare const ConfigProvider: ConfigProviderType;
67
69
  export default ConfigProvider;
@@ -3,8 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _exportNames = {};
6
+ var _exportNames = {
7
+ getLocaleFontSizeThemePatch: true
8
+ };
7
9
  exports.default = void 0;
10
+ exports.getLocaleFontSizeThemePatch = getLocaleFontSizeThemePatch;
8
11
  var _react = _interopRequireDefault(require("react"));
9
12
  var _antd = require("antd");
10
13
  var _cssinjs = require("@ant-design/cssinjs");
@@ -90,6 +93,7 @@ const ExtendedConfigContext = /*#__PURE__*/_react.default.createContext({
90
93
  hideOnSinglePage: false,
91
94
  injectStaticFunction: true
92
95
  });
96
+ /** `en` / `en-gb` → `tokenValueEn`(与 `fontFamilyEn` 等一致)。 */
93
97
  const getLocaleTokenValue = (mergedThemeToken, locale, tokenKey, tokenValue, tokenValueEn) => {
94
98
  return tokenValue !== mergedThemeToken[tokenKey] ? {
95
99
  [tokenKey]: tokenValue
@@ -97,6 +101,37 @@ const getLocaleTokenValue = (mergedThemeToken, locale, tokenKey, tokenValue, tok
97
101
  [tokenKey]: tokenValueEn
98
102
  } : {};
99
103
  };
104
+
105
+ /** Cn(zh/ja/ko)且仍为拉丁基线 `tokenValueEn` 时 → `tokenValueCn`,结构上与 {@link getLocaleTokenValue} 对称。 */
106
+ const getLocaleTokenValueCn = (mergedThemeToken, locale, tokenKey, tokenValue, tokenValueEn, tokenValueCn) => {
107
+ return tokenValue !== mergedThemeToken[tokenKey] ? {
108
+ [tokenKey]: tokenValue
109
+ } : (0, _default2.isCnLikeLocale)(locale.locale) && (tokenValue === undefined || tokenValue === tokenValueEn) ? {
110
+ [tokenKey]: tokenValueCn
111
+ } : {};
112
+ };
113
+
114
+ /** Cn 字号补丁(正文 + Table 单元格),供单测与 ConfigProvider 共用。 */
115
+ function getLocaleFontSizeThemePatch(mergedLocale, mergedTheme, resolvedFontSize) {
116
+ const tokenPatch = getLocaleTokenValueCn(mergedTheme.token ?? {}, mergedLocale, 'fontSize', resolvedFontSize, _default2.fontSizeEn, _default2.fontSizeCn);
117
+ const patch = {};
118
+ if ('fontSize' in tokenPatch && tokenPatch.fontSize !== undefined) {
119
+ patch.token = {
120
+ fontSize: tokenPatch.fontSize,
121
+ lineHeight: _default2.lineHeightCn,
122
+ fontHeight: _default2.fontHeightCn
123
+ };
124
+ }
125
+ const cellFs = mergedTheme.components?.Table?.cellFontSize;
126
+ if ((cellFs === undefined || cellFs === _default2.tableCellFontSizeEn) && (0, _default2.isCnLikeLocale)(mergedLocale.locale)) {
127
+ patch.components = {
128
+ Table: {
129
+ cellFontSize: _default2.fontSizeCn
130
+ }
131
+ };
132
+ }
133
+ return patch;
134
+ }
100
135
  const ConfigProvider = ({
101
136
  children,
102
137
  theme,
@@ -142,6 +177,7 @@ const ConfigProvider = ({
142
177
  token
143
178
  } = _theme.default.useToken();
144
179
  const fontFamily = mergedTheme.token?.fontFamily || token.fontFamily;
180
+ const fontSize = mergedTheme.token?.fontSize ?? token.fontSize;
145
181
  const fontWeightWeak = mergedTheme.token?.fontWeightWeak || token.fontWeightWeak;
146
182
  const fontWeight = mergedTheme.token?.fontWeight || token.fontWeight;
147
183
  const fontWeightStrong = mergedTheme.token?.fontWeightStrong || token.fontWeightStrong;
@@ -186,7 +222,7 @@ const ConfigProvider = ({
186
222
  }
187
223
  }, parentContext.table, table),
188
224
  tabs: (0, _lodash.merge)({}, parentContext.tabs, tabs),
189
- theme: (0, _lodash.merge)({}, mergedTheme, {
225
+ theme: (0, _lodash.merge)({}, mergedTheme, getLocaleFontSizeThemePatch(mergedLocale, mergedTheme, fontSize), {
190
226
  token: {
191
227
  ...getLocaleTokenValue(mergedTheme.token || {}, mergedLocale, 'fontFamily', fontFamily, _default2.fontFamilyEn),
192
228
  ...getLocaleTokenValue(mergedTheme.token || {}, mergedLocale, 'fontWeightWeak', fontWeightWeak, _default2.fontWeightWeakEn),
@@ -1,5 +1,5 @@
1
1
  import type { FC, ReactNode } from 'react';
2
- export type FilterComponentName = 'select' | 'checkbox' | 'cascader' | 'switch' | 'range' | 'input';
2
+ export type FilterComponentName = 'select' | 'checkbox' | 'cascader' | 'switch' | 'range' | 'input' | 'slot';
3
3
  export type FilterValue = string | string[] | string[][] | boolean | [any, any] | null | undefined;
4
4
  export interface FilterValueItem {
5
5
  id: string;
@@ -37,6 +37,7 @@ const FilterButton = /*#__PURE__*/(0, _react.forwardRef)(({
37
37
  _isInWrapComponent = false,
38
38
  _isFlat = false,
39
39
  style,
40
+ allowClear = true,
40
41
  ...restProps
41
42
  }, ref) => {
42
43
  const {
@@ -46,6 +47,7 @@ const FilterButton = /*#__PURE__*/(0, _react.forwardRef)(({
46
47
  isCollapsed
47
48
  } = (0, _FilterContext.useFilterContext)();
48
49
  const [open, setOpen] = (0, _react.useState)(false);
50
+ const [popoverWidth, setPopoverWidth] = (0, _react.useState)();
49
51
  const {
50
52
  wrapSSR,
51
53
  prefixCls
@@ -77,11 +79,24 @@ const FilterButton = /*#__PURE__*/(0, _react.forwardRef)(({
77
79
  const handleOpenChange = newOpen => {
78
80
  if (!disabled) {
79
81
  setOpen(newOpen);
80
- // 调用外部传入的 onOpenChange 回调,让父组件能够实时监听状态变化
81
82
  externalOnOpenChange?.(newOpen);
82
83
  }
83
84
  };
84
85
 
86
+ // 折叠模式下实时监听按钮宽度变化,同步到 Popover 面板宽度
87
+ (0, _react.useEffect)(() => {
88
+ if (!open || !isCollapsed || _isInWrapComponent || !innerRef.current) {
89
+ return;
90
+ }
91
+ const el = innerRef.current;
92
+ setPopoverWidth(el.offsetWidth);
93
+ const observer = new ResizeObserver(() => {
94
+ setPopoverWidth(el.offsetWidth);
95
+ });
96
+ observer.observe(el);
97
+ return () => observer.disconnect();
98
+ }, [open, isCollapsed, _isInWrapComponent]);
99
+
85
100
  // 使用 useMemo 缓存 content,避免每次都重新创建
86
101
  const popoverContent = (0, _react.useMemo)(() => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
87
102
  children: [!_isFlat && (!isCollapsed || _isInWrapComponent) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Flex, {
@@ -111,11 +126,15 @@ const FilterButton = /*#__PURE__*/(0, _react.forwardRef)(({
111
126
  content: popoverContent,
112
127
  open: open && !disabled,
113
128
  onOpenChange: handleOpenChange,
129
+ forceRender: _isInWrapComponent,
114
130
  styles: {
115
131
  body: {
116
132
  padding: 0,
117
133
  maxWidth: 300,
118
- minWidth: 120
134
+ minWidth: 120,
135
+ ...(isCollapsed && !_isInWrapComponent && popoverWidth ? {
136
+ width: popoverWidth
137
+ } : {})
119
138
  }
120
139
  },
121
140
  ...popoverProps,
@@ -152,11 +171,11 @@ const FilterButton = /*#__PURE__*/(0, _react.forwardRef)(({
152
171
  }) : showSuffixIcon ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
153
172
  className: (0, _style.getFilterCls)(prefixCls, 'icon-wrapper'),
154
173
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.DownOutlined, {
155
- className: selected ? (0, _style.getFilterCls)(prefixCls, 'arrow-icon') : '',
174
+ className: selected && allowClear ? (0, _style.getFilterCls)(prefixCls, 'arrow-icon') : '',
156
175
  style: disabled ? {
157
176
  color: 'var(--ob-color-icon-disabled)'
158
177
  } : undefined
159
- }), selected && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
178
+ }), selected && allowClear && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
160
179
  className: (0, _style.getFilterCls)(prefixCls, 'clear-icon'),
161
180
  onClick: e => {
162
181
  if (!disabled) {
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
+ import type { CascaderPanelProps } from 'antd';
2
3
  import type { CascaderOption } from '../../types';
3
4
  import type { FilterButtonRef } from '../../../FilterButton';
4
- interface FlatCascaderContentProps {
5
+ interface FlatCascaderContentProps extends CascaderPanelProps {
5
6
  options: CascaderOption[];
6
- currentValue: string[][];
7
+ currentValue: (string | number)[][];
7
8
  multiple: boolean;
8
9
  filterButtonRef: React.RefObject<FilterButtonRef>;
9
- onValueChange: (value: string[][]) => void;
10
+ onValueChange: (value: (string | number)[][]) => void;
10
11
  }
11
12
  /**
12
13
  * Flat 模式的级联内容容器组件
@@ -23,7 +23,8 @@ const FlatCascaderContent = ({
23
23
  currentValue,
24
24
  filterButtonRef,
25
25
  multiple = false,
26
- onValueChange
26
+ onValueChange,
27
+ ...restProps
27
28
  }) => {
28
29
  // 将组件内部的值格式转换为 Cascader.Panel 需要的格式
29
30
  // 组件内部:[[parent, child], ...] 或 [[parent, child]]
@@ -43,7 +44,7 @@ const FlatCascaderContent = ({
43
44
  }, [currentValue, multiple]);
44
45
 
45
46
  // 处理 Cascader.Panel 的值变化
46
- const handleCascaderChange = (value, _selectedOptions) => {
47
+ const handleCascaderChange = value => {
47
48
  if (multiple) {
48
49
  // 多选:value 是 string[][],如 [['frontend', 'react'], ['backend', 'java']]
49
50
  onValueChange(value);
@@ -55,16 +56,22 @@ const FlatCascaderContent = ({
55
56
  };
56
57
 
57
58
  // 使用条件渲染来处理 multiple 属性的类型问题
58
- return multiple ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Cascader.Panel, {
59
+ return multiple ?
60
+ /*#__PURE__*/
61
+ // @ts-ignore-next-line
62
+ (0, _jsxRuntime.jsx)(_antd.Cascader.Panel, {
59
63
  options: options,
60
64
  value: cascaderValue,
61
65
  onChange: handleCascaderChange,
62
- multiple: multiple
66
+ multiple: multiple,
67
+ showCheckedStrategy: _antd.Cascader.SHOW_CHILD,
68
+ ...restProps
63
69
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Cascader.Panel, {
64
70
  options: options,
65
71
  value: cascaderValue,
66
72
  onChange: handleCascaderChange,
67
- multiple: false
73
+ multiple: false,
74
+ ...restProps
68
75
  });
69
76
  };
70
77
  exports.FlatCascaderContent = FlatCascaderContent;
@@ -11,7 +11,6 @@ var _theme = _interopRequireDefault(require("../../../../theme"));
11
11
  var _input = _interopRequireDefault(require("../../../../input"));
12
12
  var _empty = _interopRequireDefault(require("../../../../empty"));
13
13
  var _icons = require("@oceanbase/icons");
14
- var _classnames = _interopRequireDefault(require("classnames"));
15
14
  var _style = require("../../../style");
16
15
  var _constants = require("../constants");
17
16
  var _jsxRuntime = require("react/jsx-runtime");
@@ -109,9 +108,7 @@ const NormalCascaderContent = ({
109
108
  },
110
109
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Flex, {
111
110
  gap: _constants.GAP_SIZE_SMALL * 2,
112
- className: (0, _classnames.default)((0, _style.getFilterCls)(prefixCls, 'select-option'), {
113
- [(0, _style.getFilterCls)(prefixCls, 'has-selected')]: isNodeSelected
114
- }),
111
+ className: (0, _style.getFilterCls)(prefixCls, 'select-option'),
115
112
  justify: "space-between",
116
113
  align: "center",
117
114
  onClick: handleNodeClick,
@@ -207,9 +204,7 @@ const NormalCascaderContent = ({
207
204
  },
208
205
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Flex, {
209
206
  gap: _constants.GAP_SIZE_SMALL * 2,
210
- className: (0, _classnames.default)((0, _style.getFilterCls)(prefixCls, 'select-option'), {
211
- [(0, _style.getFilterCls)(prefixCls, 'has-selected')]: hasSelectedChildren
212
- }),
207
+ className: (0, _style.getFilterCls)(prefixCls, 'select-option'),
213
208
  justify: "space-between",
214
209
  align: "center",
215
210
  style: {
@@ -143,8 +143,30 @@ const FilterCheckbox = ({
143
143
  const iconWidth = 10;
144
144
  const iconWidthUnselected = 8;
145
145
  const overlapDistance = 6;
146
- const containerWidth = iconWidth + (options.length - 1) * overlapDistance + 1;
147
- const selectedStatuses = selectedValues || [];
146
+
147
+ // 按颜色分组选项,并检查每种颜色是否有选中的选项
148
+ const colorGroups = [];
149
+ const colorMap = new Map();
150
+ options.forEach(option => {
151
+ if (option.color) {
152
+ const isSelected = selectedValues.includes(option.value);
153
+ const existing = colorMap.get(option.color);
154
+ if (existing) {
155
+ // 如果已有该颜色,更新选中状态(只要有一个选中即为选中)
156
+ if (isSelected) {
157
+ existing.hasSelected = true;
158
+ }
159
+ } else {
160
+ const group = {
161
+ color: option.color,
162
+ hasSelected: isSelected
163
+ };
164
+ colorMap.set(option.color, group);
165
+ colorGroups.push(group);
166
+ }
167
+ }
168
+ });
169
+ const containerWidth = iconWidth + (colorGroups.length - 1) * overlapDistance + 1;
148
170
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
149
171
  style: {
150
172
  position: 'relative',
@@ -153,8 +175,8 @@ const FilterCheckbox = ({
153
175
  display: 'flex',
154
176
  alignItems: 'center'
155
177
  },
156
- children: options.map((item, index) => {
157
- const isSelected = selectedStatuses.includes(item.value) && item.color;
178
+ children: colorGroups.map((group, index) => {
179
+ const isSelected = group.hasSelected;
158
180
  const baseSize = isSelected ? iconWidth : iconWidthUnselected;
159
181
  return isSelected ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
160
182
  style: {
@@ -164,10 +186,10 @@ const FilterCheckbox = ({
164
186
  height: baseSize,
165
187
  borderRadius: '50%',
166
188
  zIndex: index,
167
- backgroundColor: item.color,
189
+ backgroundColor: group.color,
168
190
  border: `1px solid ${token.white}`
169
191
  }
170
- }, item.value) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
192
+ }, group.color) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
171
193
  style: {
172
194
  position: 'absolute',
173
195
  left: index * overlapDistance,
@@ -184,7 +206,7 @@ const FilterCheckbox = ({
184
206
  border: `1px solid ${token.colorBorderSecondary}`
185
207
  }
186
208
  })
187
- }, item.value);
209
+ }, group.color);
188
210
  })
189
211
  });
190
212
  }, [isStatusMode, options, selectedValues, token]);
@@ -11,6 +11,8 @@ export interface FilterInputProps extends BaseFilterProps {
11
11
  inputProps?: InputProps;
12
12
  /** Switch 组件的额外属性 */
13
13
  switchProps?: SwitchProps;
14
+ /** 是否显示开关,默认为 false */
15
+ showSwitch?: boolean;
14
16
  }
15
17
  declare const FilterInput: FC<FilterInputProps>;
16
18
  export default FilterInput;