@oceanbase/ui 0.2.14 → 0.2.16

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 (53) hide show
  1. package/dist/ui.min.css +1 -1
  2. package/dist/ui.min.js +1 -1
  3. package/es/BasicLayout/index.js +2 -3
  4. package/es/BasicLayout/style/index.d.ts +5 -1
  5. package/es/ContentWithIcon/index.d.ts +21 -0
  6. package/es/ContentWithIcon/index.js +110 -0
  7. package/{lib/ContentWithQuestion → es/ContentWithIcon}/index.less +5 -1
  8. package/es/Highlight/index.d.ts +1 -1
  9. package/es/Lottie/index.d.ts +2 -1
  10. package/es/PageContainer/index.js +2 -3
  11. package/es/PageContainer/style/index.d.ts +5 -1
  12. package/es/TagSelect/Group.d.ts +23 -0
  13. package/es/TagSelect/Group.js +121 -0
  14. package/es/TagSelect/Item.d.ts +17 -0
  15. package/es/TagSelect/Item.js +84 -0
  16. package/es/TagSelect/TagSelectContext.d.ts +13 -0
  17. package/es/TagSelect/TagSelectContext.js +3 -0
  18. package/es/TagSelect/index.d.ts +6 -0
  19. package/es/TagSelect/index.js +6 -0
  20. package/es/TagSelect/style/index.d.ts +9 -0
  21. package/es/TagSelect/style/index.js +98 -0
  22. package/es/_util/genComponentStyleHook.d.ts +5 -1
  23. package/es/_util/useNavigate.d.ts +1 -1
  24. package/es/index.d.ts +2 -1
  25. package/es/index.js +3 -2
  26. package/lib/BasicLayout/index.js +2 -2
  27. package/lib/BasicLayout/style/index.d.ts +5 -1
  28. package/lib/ContentWithIcon/index.d.ts +21 -0
  29. package/lib/ContentWithIcon/index.js +130 -0
  30. package/{es/ContentWithQuestion → lib/ContentWithIcon}/index.less +5 -1
  31. package/lib/Highlight/index.d.ts +1 -1
  32. package/lib/Lottie/index.d.ts +2 -1
  33. package/lib/PageContainer/index.js +2 -3
  34. package/lib/PageContainer/style/index.d.ts +5 -1
  35. package/lib/TagSelect/Group.d.ts +23 -0
  36. package/lib/TagSelect/Group.js +128 -0
  37. package/lib/TagSelect/Item.d.ts +17 -0
  38. package/lib/TagSelect/Item.js +108 -0
  39. package/lib/TagSelect/TagSelectContext.d.ts +13 -0
  40. package/lib/TagSelect/TagSelectContext.js +27 -0
  41. package/lib/TagSelect/index.d.ts +6 -0
  42. package/lib/TagSelect/index.js +37 -0
  43. package/lib/TagSelect/style/index.d.ts +9 -0
  44. package/lib/TagSelect/style/index.js +152 -0
  45. package/lib/_util/genComponentStyleHook.d.ts +5 -1
  46. package/lib/_util/useNavigate.d.ts +1 -1
  47. package/lib/index.d.ts +2 -1
  48. package/lib/index.js +6 -3
  49. package/package.json +9 -9
  50. package/es/ContentWithQuestion/index.d.ts +0 -13
  51. package/es/ContentWithQuestion/index.js +0 -46
  52. package/lib/ContentWithQuestion/index.d.ts +0 -13
  53. package/lib/ContentWithQuestion/index.js +0 -76
@@ -62,9 +62,8 @@ var BasicLayout = function BasicLayout(_ref) {
62
62
  getPrefixCls = _useContext.getPrefixCls;
63
63
  var prefixCls = getPrefixCls('basic-layout', customizePrefixCls);
64
64
  var _useStyle = useStyle(prefixCls),
65
- wrapSSR = _useStyle.wrapSSR,
66
- hashId = _useStyle.hashId;
67
- var basicLayoutCls = classNames(className, hashId);
65
+ wrapSSR = _useStyle.wrapSSR;
66
+ var basicLayoutCls = classNames(className);
68
67
  var navigate = useNavigate();
69
68
  // 侧边栏导航是否收起
70
69
  var _useState = useState(defaultCollapsed),
@@ -1,5 +1,9 @@
1
+ /// <reference types="react" />
1
2
  import type { FullToken, GenerateStyle } from '@oceanbase/design/es/theme';
2
3
  export type BasicLayoutToken = FullToken<any>;
3
4
  export declare const genBasicLayoutStyle: GenerateStyle<BasicLayoutToken>;
4
- declare const _default: (prefixCls: string) => any;
5
+ declare const _default: (prefixCls: string) => {
6
+ wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
7
+ hashId: string;
8
+ };
5
9
  export default _default;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export interface ContentWithIconProps {
4
+ content?: React.ReactNode;
5
+ tooltip?: any;
6
+ prefixIcon?: React.ReactNode | boolean;
7
+ suffixIcon?: React.ReactNode;
8
+ className?: string;
9
+ iconType?: 'question' | 'info' | 'exclamation';
10
+ color?: string;
11
+ style?: React.CSSProperties;
12
+ onClick?: (e: React.SyntheticEvent) => void;
13
+ tooltipWithLink?: boolean;
14
+ textHidden?: boolean;
15
+ popOver?: any;
16
+ size?: number;
17
+ infoColor?: string;
18
+ exclamationColor?: string;
19
+ }
20
+ declare const ContentWithIcon: React.FC<ContentWithIconProps>;
21
+ export default ContentWithIcon;
@@ -0,0 +1,110 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _excluded = ["content", "tooltip", "prefixIcon", "suffixIcon", "className", "children", "iconType", "color", "tooltipWithLink", "popOver", "textHidden", "size", "infoColor", "exclamationColor"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
9
+ import React, { isValidElement } from 'react';
10
+ import { Tooltip, Space, Popover } from 'antd';
11
+ import { ExclamationCircleFilled, InfoCircleFilled, InfoCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons';
12
+ import classNames from 'classnames';
13
+ import { getPrefix } from "../_util";
14
+ import "./index.less";
15
+ var prefix = getPrefix('content-with-question');
16
+ var ContentWithIcon = function ContentWithIcon(_ref) {
17
+ var _classNames;
18
+ var content = _ref.content,
19
+ tooltip = _ref.tooltip,
20
+ _ref$prefixIcon = _ref.prefixIcon,
21
+ prefixIcon = _ref$prefixIcon === void 0 ? null : _ref$prefixIcon,
22
+ suffixIcon = _ref.suffixIcon,
23
+ className = _ref.className,
24
+ children = _ref.children,
25
+ iconType = _ref.iconType,
26
+ color = _ref.color,
27
+ _ref$tooltipWithLink = _ref.tooltipWithLink,
28
+ tooltipWithLink = _ref$tooltipWithLink === void 0 ? false : _ref$tooltipWithLink,
29
+ popOver = _ref.popOver,
30
+ _ref$textHidden = _ref.textHidden,
31
+ textHidden = _ref$textHidden === void 0 ? true : _ref$textHidden,
32
+ _ref$size = _ref.size,
33
+ size = _ref$size === void 0 ? 14 : _ref$size,
34
+ infoColor = _ref.infoColor,
35
+ _ref$exclamationColor = _ref.exclamationColor,
36
+ exclamationColor = _ref$exclamationColor === void 0 ? '#FAAD14' : _ref$exclamationColor,
37
+ restProps = _objectWithoutProperties(_ref, _excluded);
38
+ var defaultIconType = function defaultIconType() {
39
+ if (iconType === 'question') {
40
+ return /*#__PURE__*/React.createElement(QuestionCircleOutlined, {
41
+ style: {
42
+ color: color === 'default' ? '#132039' : color,
43
+ fontSize: size
44
+ },
45
+ className: "".concat(prefix, "-help")
46
+ });
47
+ }
48
+ if (iconType === 'info') {
49
+ if (infoColor) {
50
+ return /*#__PURE__*/React.createElement(InfoCircleFilled, {
51
+ style: {
52
+ color: infoColor,
53
+ fontSize: size
54
+ },
55
+ className: "".concat(prefix, "-help")
56
+ });
57
+ } else {
58
+ return /*#__PURE__*/React.createElement(InfoCircleOutlined, {
59
+ style: {
60
+ color: '3333333',
61
+ fontSize: size
62
+ },
63
+ className: "".concat(prefix, "-help")
64
+ });
65
+ }
66
+ }
67
+ if (iconType === 'exclamation') {
68
+ return /*#__PURE__*/React.createElement(ExclamationCircleFilled, {
69
+ style: {
70
+ color: exclamationColor,
71
+ fontSize: size
72
+ },
73
+ className: "".concat(prefix, "-help")
74
+ });
75
+ }
76
+ };
77
+
78
+ // 图标在文字后
79
+ suffixIcon = suffixIcon !== null && iconType ? defaultIconType() : suffixIcon; // 自定义图标,非内置
80
+
81
+ // FIXME: antd 已经废弃 icon type 的用法,该组件也需要做相应处理,后面将会是传入 Icon 的形式而非 type
82
+ var getIcon = function getIcon(iconConfig) {
83
+ return iconConfig ? !textHidden && iconType === 'info' ?
84
+ /*#__PURE__*/
85
+ // 文本描述直接展示且只在 info 类型下生效
86
+ React.createElement(Space, {
87
+ size: 4
88
+ }, iconConfig, /*#__PURE__*/React.createElement("span", {
89
+ style: {
90
+ color: '#5C6B8A'
91
+ }
92
+ }, "\u6587\u672C\u793A\u610F\u4E0D\u8D85\u8FC7\u4E8C\u5341\u5B57\u6587\u672C\u793A\u610F\u4E0D\u8D85\u8FC7\u4E8C\u5341\u5B57")) :
93
+ // 提示文案描述带有链接
94
+ tooltipWithLink ? /*#__PURE__*/React.createElement(Popover, popOver, /*#__PURE__*/isValidElement(iconConfig) ? iconConfig : defaultIconType()) : /*#__PURE__*/React.createElement(Tooltip, tooltip, /*#__PURE__*/isValidElement(iconConfig) ? iconConfig : defaultIconType()) : null;
95
+ };
96
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", _extends({
97
+ className: classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "-item"), true), _defineProperty(_classNames, className, !!className), _classNames))
98
+ }, restProps), /*#__PURE__*/React.createElement(Space, {
99
+ size: 4
100
+ }, getIcon(
101
+ // 图标在文字前
102
+ prefixIcon === true ? defaultIconType() : prefixIcon), /*#__PURE__*/React.createElement("span", {
103
+ "data-testid": "content",
104
+ style: {
105
+ color: color === 'default' ? '#5C6B8A' : color,
106
+ fontSize: size
107
+ }
108
+ }, content !== null && content !== void 0 ? content : children), getIcon(suffixIcon))));
109
+ };
110
+ export default ContentWithIcon;
@@ -1,4 +1,4 @@
1
- @prefix: ob-content-with-question;
1
+ @prefix: ob-content-with-icon;
2
2
 
3
3
  .@{prefix}-item {
4
4
  display: inline-flex;
@@ -15,4 +15,8 @@
15
15
  .@{prefix}-help {
16
16
  cursor: help;
17
17
  }
18
+ .@{prefix}-color {
19
+ color: red;
20
+
21
+ }
18
22
  }
@@ -29,7 +29,7 @@ export declare const THEME_DARK = "dark";
29
29
  export declare const THEME_LIGHT = "light";
30
30
  declare const ThemeTypes: ["dark", "light"];
31
31
  export type ThemeType = (typeof ThemeTypes)[number];
32
- declare const supportedLanguages: ("ruby" | "javascript" | "typescript" | "css" | "groovy" | "java" | "python" | "bash" | "json" | "cpp" | "http" | "markdown" | "nginx" | "sql" | "xml" | "dockerfile" | "go" | "yaml" | "solidity" | "tsx" | "jsx")[];
32
+ declare const supportedLanguages: ("ruby" | "json" | "javascript" | "typescript" | "css" | "groovy" | "java" | "python" | "bash" | "cpp" | "http" | "markdown" | "nginx" | "sql" | "xml" | "dockerfile" | "go" | "yaml" | "solidity" | "tsx" | "jsx")[];
33
33
  export type LanguageType = (typeof supportedLanguages)[number] | 'html';
34
34
  export interface HighlightProps extends LocaleWrapperProps {
35
35
  /**
@@ -1,7 +1,8 @@
1
1
  import type { AnimationConfig, AnimationItem } from 'lottie-web';
2
2
  import React from 'react';
3
3
  export interface LottieProps extends Omit<AnimationConfig, 'container'> {
4
- path: string;
4
+ path?: string;
5
+ animationData?: any;
5
6
  mode?: 'default' | 'icon';
6
7
  loop?: boolean;
7
8
  speed?: number;
@@ -33,8 +33,7 @@ var PageContainer = function PageContainer(_ref) {
33
33
  var rootPrefixCls = getPrefixCls();
34
34
  var prefixCls = getPrefixCls('pro-page-container', customizePrefixCls);
35
35
  var _useStyle = useStyle(prefixCls),
36
- wrapSSR = _useStyle.wrapSSR,
37
- hashId = _useStyle.hashId;
36
+ wrapSSR = _useStyle.wrapSSR;
38
37
  var _ref2 = header || {},
39
38
  reload = _ref2.reload,
40
39
  subTitle = _ref2.subTitle,
@@ -64,7 +63,7 @@ var PageContainer = function PageContainer(_ref) {
64
63
  var noHasHeader = ['title', 'subTitle', 'extra', 'tags', 'footer', 'avatar', 'backIcon', 'breadcrumb'].every(function (item) {
65
64
  return !(newHeader !== null && newHeader !== void 0 && newHeader[item]);
66
65
  }) && !content && !extraContent && !tabList && !tabBarExtraContent;
67
- var pageContainerCls = classNames(_defineProperty({}, "".concat(prefixCls, "-no-page-header"), noHasHeader), className, hashId);
66
+ var pageContainerCls = classNames(_defineProperty({}, "".concat(prefixCls, "-no-page-header"), noHasHeader), className);
68
67
  return wrapSSR( /*#__PURE__*/React.createElement(AntPageContainer, _extends({
69
68
  prefixCls: customizePrefixCls,
70
69
  className: pageContainerCls,
@@ -1,5 +1,9 @@
1
+ /// <reference types="react" />
1
2
  import type { PageContainerToken } from '@ant-design/pro-layout/es/components/PageContainer/style';
2
3
  import type { GenerateStyle } from '@oceanbase/design/es/theme';
3
4
  export declare const genPageContainerStyle: GenerateStyle<PageContainerToken>;
4
- declare const _default: (prefixCls: string) => any;
5
+ declare const _default: (prefixCls: string) => {
6
+ wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
7
+ hashId: string;
8
+ };
5
9
  export default _default;
@@ -0,0 +1,23 @@
1
+ import React, { ReactNode } from 'react';
2
+ export type TagSelectValueType = string | number;
3
+ export interface TagSelectOptionType {
4
+ label: React.ReactNode;
5
+ value: TagSelectValueType;
6
+ style?: React.CSSProperties;
7
+ disabled?: boolean;
8
+ onChange?: (e: any) => void;
9
+ }
10
+ export interface TagSelectGroupProps {
11
+ title?: string;
12
+ children?: ReactNode;
13
+ disabled?: boolean;
14
+ className?: string;
15
+ multiple?: boolean;
16
+ defaultValue?: TagSelectValueType | Array<TagSelectValueType>;
17
+ value?: TagSelectValueType | Array<TagSelectValueType>;
18
+ size?: string;
19
+ options?: Array<TagSelectOptionType | string | number>;
20
+ onChange?: (value: Array<TagSelectValueType> | TagSelectValueType) => void;
21
+ }
22
+ declare const Group: React.FC<TagSelectGroupProps>;
23
+ export default Group;
@@ -0,0 +1,121 @@
1
+ var _excluded = ["title", "multiple", "defaultValue", "size", "options", "children", "className"];
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
13
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
14
+ import classNames from 'classnames';
15
+ import { getPrefix } from "../_util";
16
+ import React, { useMemo, useState, useEffect } from 'react';
17
+ import TagSelectContext from "./TagSelectContext";
18
+ import Item from "./Item";
19
+ import useStyle from "./style";
20
+ function toArray(value) {
21
+ var res = value;
22
+ if (value === undefined) {
23
+ res = [];
24
+ } else if (!Array.isArray(value)) {
25
+ res = [value];
26
+ }
27
+ return res;
28
+ }
29
+ var Group = function Group(_ref) {
30
+ var title = _ref.title,
31
+ multiple = _ref.multiple,
32
+ defaultValue = _ref.defaultValue,
33
+ _ref$size = _ref.size,
34
+ size = _ref$size === void 0 ? 'middle' : _ref$size,
35
+ _ref$options = _ref.options,
36
+ options = _ref$options === void 0 ? [] : _ref$options,
37
+ children = _ref.children,
38
+ className = _ref.className,
39
+ restProps = _objectWithoutProperties(_ref, _excluded);
40
+ var prefix = getPrefix('tag-select');
41
+ var _useStyle = useStyle(prefix),
42
+ wrapSSR = _useStyle.wrapSSR,
43
+ hashId = _useStyle.hashId;
44
+ var _useState = useState(toArray(defaultValue || restProps.value)),
45
+ _useState2 = _slicedToArray(_useState, 2),
46
+ value = _useState2[0],
47
+ setValue = _useState2[1];
48
+ var _React$useState = React.useState([]),
49
+ _React$useState2 = _slicedToArray(_React$useState, 2),
50
+ registeredValues = _React$useState2[0],
51
+ setRegisteredValues = _React$useState2[1];
52
+ var registerValue = function registerValue(val) {
53
+ setRegisteredValues(function (prev) {
54
+ return [].concat(_toConsumableArray(prev), [val]);
55
+ });
56
+ };
57
+ useEffect(function () {
58
+ if ('value' in restProps) {
59
+ setValue(toArray(restProps.value));
60
+ }
61
+ }, [restProps.value]);
62
+ var handleValueChange = function handleValueChange(v) {
63
+ var _restProps$onChange;
64
+ var registeredValue = value.filter(function (v1) {
65
+ return registeredValues.includes(v1);
66
+ });
67
+ var newValue = _toConsumableArray(registeredValue);
68
+ var index = newValue.indexOf(v);
69
+ var checkedValue = index === -1 ? v : undefined;
70
+ if (multiple) {
71
+ if (index === -1) {
72
+ newValue.push(v);
73
+ } else {
74
+ newValue.splice(index, 1);
75
+ }
76
+ }
77
+ if (!('value' in restProps)) {
78
+ setValue(multiple ? newValue : [checkedValue]);
79
+ }
80
+ (_restProps$onChange = restProps.onChange) === null || _restProps$onChange === void 0 ? void 0 : _restProps$onChange.call(restProps, multiple ? newValue : checkedValue);
81
+ };
82
+ var contextValue = {
83
+ multiple: multiple,
84
+ size: size,
85
+ value: value,
86
+ disabled: restProps.disabled,
87
+ onChange: restProps.onChange,
88
+ registerValue: registerValue,
89
+ handleValueChange: handleValueChange
90
+ };
91
+ var memoOptions = useMemo(function () {
92
+ return options.map(function (option) {
93
+ if (typeof option === 'string' || typeof option === 'number') {
94
+ return {
95
+ label: option,
96
+ value: option
97
+ };
98
+ }
99
+ return option;
100
+ });
101
+ }, [options]);
102
+ var childrenNode = options.length ? memoOptions.map(function (option) {
103
+ return /*#__PURE__*/React.createElement(Item, {
104
+ key: option.value.toString(),
105
+ disabled: 'disabled' in option ? option.disabled : restProps.disabled,
106
+ value: option.value,
107
+ onChange: option.onChange,
108
+ style: option.style,
109
+ checked: value === null || value === void 0 ? void 0 : value.includes(option.value)
110
+ }, option.label);
111
+ }) : children;
112
+ var groupCls = classNames("".concat(prefix, "-container"), hashId, className);
113
+ return wrapSSR( /*#__PURE__*/React.createElement(TagSelectContext.Provider, {
114
+ value: contextValue
115
+ }, /*#__PURE__*/React.createElement("div", {
116
+ className: groupCls
117
+ }, /*#__PURE__*/React.createElement("div", {
118
+ className: "".concat(prefix, "-title")
119
+ }, title), childrenNode)));
120
+ };
121
+ export default Group;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import type { TagSelectValueType } from './Group';
3
+ export interface TagSelectItemProps {
4
+ children?: React.ReactNode;
5
+ cover?: React.ReactNode;
6
+ value?: string | number;
7
+ defaultChecked?: boolean;
8
+ checked?: boolean;
9
+ title?: string;
10
+ disabled?: boolean;
11
+ style?: React.CSSProperties;
12
+ multiple?: boolean;
13
+ handleChange?: (value: TagSelectValueType) => void;
14
+ onChange?: (e: any) => void;
15
+ }
16
+ declare const Item: React.FC<TagSelectItemProps>;
17
+ export default Item;
@@ -0,0 +1,84 @@
1
+ var _excluded = ["children", "handleChange", "onChange", "cover"];
2
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
14
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
15
+ import RcCheckBox from 'rc-checkbox';
16
+ import classNames from 'classnames';
17
+ import { isBoolean } from 'lodash';
18
+ import React, { useEffect, useState } from 'react';
19
+ import useStyle from "./style";
20
+ import { getPrefix } from "../_util";
21
+ import TagSelectContext from "./TagSelectContext";
22
+ var Item = function Item(_ref) {
23
+ var _classNames;
24
+ var children = _ref.children,
25
+ handleChange = _ref.handleChange,
26
+ _onChange = _ref.onChange,
27
+ cover = _ref.cover,
28
+ restProps = _objectWithoutProperties(_ref, _excluded);
29
+ var _useState = useState(restProps.defaultChecked),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ checked = _useState2[0],
32
+ setChecked = _useState2[1];
33
+ var coverType = _typeof(cover);
34
+ var prefixCls = getPrefix('tag-select');
35
+ var _useStyle = useStyle(prefixCls),
36
+ wrapSSR = _useStyle.wrapSSR,
37
+ hashId = _useStyle.hashId;
38
+ var tagSelectGroup = React.useContext(TagSelectContext);
39
+ var wrapperClassName = classNames("".concat(prefixCls, "-wrapper"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-checked"), checked), _defineProperty(_classNames, "multiple", tagSelectGroup.multiple), _defineProperty(_classNames, "".concat(prefixCls, "-").concat(tagSelectGroup.size), tagSelectGroup.size), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), tagSelectGroup.disabled || restProps.disabled), _defineProperty(_classNames, "".concat(prefixCls, "-img"), coverType === 'string'), _defineProperty(_classNames, "".concat(prefixCls, "-custom"), coverType !== 'string'), _classNames), hashId);
40
+ useEffect(function () {
41
+ if (isBoolean(restProps.checked)) {
42
+ setChecked(restProps.checked);
43
+ }
44
+ }, [restProps.checked]);
45
+ useEffect(function () {
46
+ var _tagSelectGroup$regis;
47
+ return (_tagSelectGroup$regis = tagSelectGroup.registerValue) === null || _tagSelectGroup$regis === void 0 ? void 0 : _tagSelectGroup$regis.call(tagSelectGroup, restProps.value);
48
+ }, [restProps.value]);
49
+ useEffect(function () {
50
+ var _tagSelectGroup$value;
51
+ if ((_tagSelectGroup$value = tagSelectGroup.value) !== null && _tagSelectGroup$value !== void 0 && _tagSelectGroup$value.includes(restProps.value) || restProps.checked || restProps.defaultChecked) {
52
+ setChecked(true);
53
+ } else {
54
+ setChecked(false);
55
+ }
56
+ }, [tagSelectGroup.value, restProps.value]);
57
+ var renderCover = function renderCover() {
58
+ return coverType === 'string' ? /*#__PURE__*/React.createElement("div", {
59
+ className: "".concat(prefixCls, "-cover")
60
+ }, /*#__PURE__*/React.createElement("img", {
61
+ src: cover,
62
+ alt: "tagselect"
63
+ })) : cover;
64
+ };
65
+ return wrapSSR( /*#__PURE__*/React.createElement("label", {
66
+ className: wrapperClassName,
67
+ style: restProps.style
68
+ }, /*#__PURE__*/React.createElement(RcCheckBox, _extends({}, restProps, {
69
+ checked: checked,
70
+ prefixCls: prefixCls,
71
+ onChange: function onChange(e) {
72
+ if (!('checked' in restProps) && !Object.keys(tagSelectGroup).length) {
73
+ setChecked(e.target.checked);
74
+ }
75
+ if (_onChange) {
76
+ _onChange(e);
77
+ }
78
+ if (tagSelectGroup.handleValueChange) {
79
+ tagSelectGroup.handleValueChange(e.target.value);
80
+ }
81
+ }
82
+ })), cover ? renderCover() : /*#__PURE__*/React.createElement("span", null, children)));
83
+ };
84
+ export default Item;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import type { TagSelectValueType } from './Group';
3
+ export type TagSelectContextProps = {
4
+ multiple?: boolean;
5
+ size?: string;
6
+ disabled?: boolean;
7
+ value?: Array<TagSelectValueType>;
8
+ onChange?: (value: Array<TagSelectValueType> | TagSelectValueType) => void;
9
+ registerValue?: (val: TagSelectValueType) => void;
10
+ handleValueChange?: (val: TagSelectValueType) => void;
11
+ };
12
+ declare const TagSelectContext: import("react").Context<TagSelectContextProps>;
13
+ export default TagSelectContext;
@@ -0,0 +1,3 @@
1
+ import { createContext } from 'react';
2
+ var TagSelectContext = /*#__PURE__*/createContext({});
3
+ export default TagSelectContext;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ Group: import("react").FC<import("./Group").TagSelectGroupProps>;
4
+ Item: import("react").FC<import("./Item").TagSelectItemProps>;
5
+ };
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import Group from "./Group";
2
+ import Item from "./Item";
3
+ export default {
4
+ Group: Group,
5
+ Item: Item
6
+ };
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import type { FullToken, GenerateStyle } from 'antd/lib/theme/internal';
3
+ export type TagSelectToken = FullToken<any>;
4
+ export declare const genTagSelectStyle: GenerateStyle<TagSelectToken>;
5
+ declare const _default: (prefixCls: string) => {
6
+ wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
7
+ hashId: string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,98 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ import { genComponentStyleHook } from "../../_util/genComponentStyleHook";
8
+ var genSizeStyle = function genSizeStyle(height, fontSize) {
9
+ return {
10
+ paddingTop: "".concat(height, "px"),
11
+ paddingBottom: "".concat(height, "px"),
12
+ fontSize: fontSize
13
+ };
14
+ };
15
+ var genColoredStyle = function genColoredStyle(borderColor, backgroundColor, color) {
16
+ return {
17
+ borderColor: borderColor,
18
+ backgroundColor: backgroundColor,
19
+ color: color
20
+ };
21
+ };
22
+ var genMultipleStyle = function genMultipleStyle(color, token) {
23
+ return {
24
+ position: 'absolute',
25
+ top: '1px',
26
+ right: '1px',
27
+ borderTop: "12px solid ".concat(color),
28
+ borderLeft: "12px solid transparent",
29
+ borderTopRightRadius: token.borderRadiusSM
30
+ };
31
+ };
32
+ var genImgCoverStyle = function genImgCoverStyle(width, height) {
33
+ return {
34
+ width: width,
35
+ height: height
36
+ };
37
+ };
38
+ export var genTagSelectStyle = function genTagSelectStyle(token) {
39
+ var _$concat, _ref;
40
+ var componentCls = token.componentCls;
41
+ return _ref = {}, _defineProperty(_ref, "".concat(componentCls, "-title"), {
42
+ fontSize: token.fontSize,
43
+ color: token.colorText,
44
+ margin: "".concat(token.marginXXS, "px 0")
45
+ }), _defineProperty(_ref, "".concat(componentCls, "-wrapper"), (_$concat = {
46
+ position: 'relative',
47
+ display: 'inline-block',
48
+ fontSize: token.fontSize,
49
+ color: token.colorTextLabel,
50
+ background: token.colorWhite,
51
+ border: "".concat(token.lineWidth, "px ").concat(token.lineType, " ").concat(token.colorBorder),
52
+ borderRadius: token.borderRadius,
53
+ marginRight: token.marginXS,
54
+ padding: "".concat(token.paddingXXS, "px ").concat(token.paddingContentHorizontal, "px"),
55
+ cursor: 'pointer'
56
+ }, _defineProperty(_$concat, "".concat(componentCls, "-input"), {
57
+ width: 0,
58
+ height: 0,
59
+ opacity: 0,
60
+ pointerEvents: 'none'
61
+ }), _defineProperty(_$concat, '&:last-child', {
62
+ margin: 0
63
+ }), _defineProperty(_$concat, "&:has(".concat(componentCls, "-cover)"), _objectSpread({
64
+ padding: 0
65
+ }, genImgCoverStyle('76px', '40px'))), _$concat)), _defineProperty(_ref, "".concat(componentCls, "-cover"), {
66
+ display: 'inline-block',
67
+ width: '100%',
68
+ height: '100%',
69
+ img: {
70
+ height: 'calc(100% - 2px)',
71
+ width: 'calc(100% - 2px)',
72
+ borderRadius: token.borderRadius,
73
+ marginLeft: '1px',
74
+ marginTop: '1px'
75
+ }
76
+ }), _defineProperty(_ref, "".concat(componentCls, "-large").concat(componentCls, "-img"), _objectSpread(_objectSpread({}, genImgCoverStyle('228px', '120px')), {}, {
77
+ marginRight: '16px'
78
+ })), _defineProperty(_ref, "".concat(componentCls, "-small").concat(componentCls, "-img"), genImgCoverStyle('76px', '32px')), _defineProperty(_ref, "".concat(componentCls, "-large"), genSizeStyle(token.paddingContentVerticalSM, token.fontSize)), _defineProperty(_ref, "".concat(componentCls, "-small"), genSizeStyle(0, token.fontSize)), _defineProperty(_ref, "".concat(componentCls, "-wrapper:not(").concat(componentCls, "-disabled):hover"), {
79
+ color: token.colorPrimaryTextHover
80
+ }), _defineProperty(_ref, "".concat(componentCls, "-checked"), genColoredStyle(token.blue, token.colorPrimaryBg, token.colorPrimaryText)), _defineProperty(_ref, "".concat(componentCls, "-wrapper").concat(componentCls, "-checked:not(").concat(componentCls, "-disabled):focus-within"), {
81
+ boxShadow: "0 1px 3px 0px #000",
82
+ borderColor: "".concat(token.colorPrimary)
83
+ }), _defineProperty(_ref, "".concat(componentCls, "-checked:not(").concat(componentCls, "-disabled)"), {
84
+ '&:hover': _objectSpread(_objectSpread({}, genColoredStyle(token.colorInfoBorder, '#EBF1FF', token.colorInfoTextHover)), {}, _defineProperty({}, "".concat(componentCls, "-inner"), {
85
+ borderTopColor: "".concat(token.colorPrimaryTextHover, " !important")
86
+ }))
87
+ }), _defineProperty(_ref, "".concat(componentCls, "-disabled:not(").concat(componentCls, "-checked)"), _objectSpread(_objectSpread({}, genColoredStyle(token.colorBorder, '#F6F8FE', '#CDD5E3')), {}, {
88
+ cursor: 'not-allowed'
89
+ })), _defineProperty(_ref, "".concat(componentCls, "-disabled").concat(componentCls, "-checked"), _objectSpread({
90
+ cursor: 'not-allowed'
91
+ }, genColoredStyle(token.colorBorder, '#E2E8F3', token.colorTextTertiary))), _defineProperty(_ref, "".concat(componentCls, "-checked").concat(componentCls, "-disabled.multiple"), _defineProperty({}, "".concat(componentCls, "-inner"), genMultipleStyle('#CDD5E3', token))), _defineProperty(_ref, "".concat(componentCls, "-checked:not(").concat(componentCls, "-disabled).multiple"), _defineProperty({}, "".concat(componentCls, "-inner"), genMultipleStyle(token.colorPrimary, token))), _ref;
92
+ };
93
+ export default (function (prefixCls) {
94
+ var useStyle = genComponentStyleHook('TagSelect', function (token) {
95
+ return [genTagSelectStyle(token)];
96
+ });
97
+ return useStyle(prefixCls);
98
+ });
@@ -1,5 +1,6 @@
1
1
  import type { ProAliasToken } from '@ant-design/pro-components';
2
2
  import type { GenerateStyle } from '@oceanbase/design/es/theme';
3
+ import React from 'react';
3
4
  export interface OBToken extends ProAliasToken {
4
5
  /** Wrap component class with `.` prefix */
5
6
  componentCls: string;
@@ -11,4 +12,7 @@ export interface OBToken extends ProAliasToken {
11
12
  antCls: string;
12
13
  zIndexPopup: number;
13
14
  }
14
- export declare function genComponentStyleHook(componentName: string, styleFn: GenerateStyle<OBToken>): (prefixCls: string) => any;
15
+ export declare function genComponentStyleHook(componentName: string, styleFn: GenerateStyle<OBToken>): (prefixCls: string) => {
16
+ wrapSSR: (node: React.ReactElement<any, string | React.JSXElementConstructor<any>>) => React.JSX.Element;
17
+ hashId: string;
18
+ };