@digitalc/dxp-ui 0.0.6-0 → 0.0.6-alpha.2

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 (93) hide show
  1. package/es/assets/iconFont/demo_index.html +535 -6
  2. package/es/assets/iconFont/iconfont.css +98 -6
  3. package/es/assets/iconFont/iconfont.eot +0 -0
  4. package/es/assets/iconFont/iconfont.js +10 -10
  5. package/es/assets/iconFont/iconfont.json +161 -0
  6. package/es/assets/iconFont/iconfont.svg +46 -0
  7. package/es/assets/iconFont/iconfont.ttf +0 -0
  8. package/es/assets/iconFont/iconfont.woff +0 -0
  9. package/es/assets/iconFont/iconfont.woff2 +0 -0
  10. package/es/components/Amount/index.js +0 -1
  11. package/es/components/AppStyleWrapper/index.d.ts +6 -0
  12. package/es/components/AppStyleWrapper/index.js +13 -0
  13. package/es/components/Button/designTokens.d.ts +6 -0
  14. package/es/components/Button/designTokens.js +6 -1
  15. package/es/components/Card/index.d.ts +1 -1
  16. package/es/components/Card/index.js +3 -8
  17. package/es/components/Card/style/index.less +1 -1
  18. package/es/components/Checkbox/style/index.less +0 -5
  19. package/es/components/Col/index.d.ts +7 -0
  20. package/es/components/Col/index.js +21 -0
  21. package/es/components/Drawer/index.d.ts +1 -0
  22. package/es/components/Drawer/index.js +3 -2
  23. package/es/components/Drawer/style/index.less +1 -0
  24. package/es/components/Form/index.js +1 -1
  25. package/es/components/IconButton/index.js +1 -1
  26. package/es/components/Input/index.js +2 -2
  27. package/es/components/Input/style/index.less +0 -3
  28. package/es/components/Input/style/variables.less +0 -4
  29. package/es/components/Modal/index.js +1 -1
  30. package/es/components/Navigation/index.js +1 -1
  31. package/es/components/Row/index.d.ts +7 -0
  32. package/es/components/Row/index.js +68 -0
  33. package/es/components/Selector/ESelector.js +2 -2
  34. package/es/components/Selector/style/index.less +8 -11
  35. package/es/components/SelectorItem/index.js +1 -1
  36. package/es/components/SelectorItem/style/index.less +8 -11
  37. package/es/components/Stepper/index.js +2 -1
  38. package/es/components/StickyFooter/index.js +3 -10
  39. package/es/components/Tabs/index.js +3 -2
  40. package/es/components/Tabs/style/index.less +5 -5
  41. package/es/components/index.d.ts +3 -0
  42. package/es/components/index.js +3 -0
  43. package/es/index.d.ts +1 -1
  44. package/es/index.js +1 -1
  45. package/es/utils/deviceType.d.ts +15 -0
  46. package/es/utils/deviceType.js +46 -0
  47. package/lib/assets/iconFont/demo_index.html +535 -6
  48. package/lib/assets/iconFont/iconfont.css +98 -6
  49. package/lib/assets/iconFont/iconfont.eot +0 -0
  50. package/lib/assets/iconFont/iconfont.js +9 -9
  51. package/lib/assets/iconFont/iconfont.json +161 -0
  52. package/lib/assets/iconFont/iconfont.svg +46 -0
  53. package/lib/assets/iconFont/iconfont.ttf +0 -0
  54. package/lib/assets/iconFont/iconfont.woff +0 -0
  55. package/lib/assets/iconFont/iconfont.woff2 +0 -0
  56. package/lib/components/Amount/index.js +0 -1
  57. package/lib/components/AppStyleWrapper/index.d.ts +6 -0
  58. package/lib/components/AppStyleWrapper/index.js +48 -0
  59. package/lib/components/Button/designTokens.d.ts +6 -0
  60. package/lib/components/Button/designTokens.js +6 -0
  61. package/lib/components/Card/index.d.ts +1 -1
  62. package/lib/components/Card/index.js +2 -2
  63. package/lib/components/Card/style/index.less +1 -1
  64. package/lib/components/Checkbox/style/index.less +0 -5
  65. package/lib/components/Col/index.d.ts +7 -0
  66. package/lib/components/Col/index.js +74 -0
  67. package/lib/components/Drawer/index.d.ts +1 -0
  68. package/lib/components/Drawer/index.js +3 -2
  69. package/lib/components/Drawer/style/index.less +1 -0
  70. package/lib/components/Form/index.js +1 -1
  71. package/lib/components/IconButton/index.js +2 -0
  72. package/lib/components/Input/index.js +1 -4
  73. package/lib/components/Input/style/index.less +0 -3
  74. package/lib/components/Input/style/variables.less +0 -4
  75. package/lib/components/Modal/index.js +2 -1
  76. package/lib/components/Navigation/index.js +1 -1
  77. package/lib/components/Row/index.d.ts +7 -0
  78. package/lib/components/Row/index.js +114 -0
  79. package/lib/components/Selector/ESelector.js +4 -2
  80. package/lib/components/Selector/style/index.less +8 -11
  81. package/lib/components/SelectorItem/index.js +1 -1
  82. package/lib/components/SelectorItem/style/index.less +8 -11
  83. package/lib/components/Stepper/index.js +2 -1
  84. package/lib/components/StickyFooter/index.js +2 -2
  85. package/lib/components/Tabs/index.js +6 -5
  86. package/lib/components/Tabs/style/index.less +5 -5
  87. package/lib/components/index.d.ts +3 -0
  88. package/lib/components/index.js +6 -0
  89. package/lib/index.d.ts +1 -1
  90. package/lib/index.js +1 -0
  91. package/lib/utils/deviceType.d.ts +15 -0
  92. package/lib/utils/deviceType.js +25 -0
  93. package/package.json +2 -2
@@ -0,0 +1,68 @@
1
+ import "antd/es/config-provider/style";
2
+ import _ConfigProvider from "antd/es/config-provider";
3
+ import "antd/es/row/style";
4
+ import _Row from "antd/es/row";
5
+ import "antd/es/col/style";
6
+ import _Col from "antd/es/col";
7
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
8
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
9
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
10
+ var _excluded = ["gutter", "children"];
11
+ import React from 'react';
12
+ import { isWebViewBelow90 } from "../../utils";
13
+ import { cssClasses } from "../../constants";
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ var Row = function Row(_ref) {
16
+ var gutter = _ref.gutter,
17
+ children = _ref.children,
18
+ props = _objectWithoutProperties(_ref, _excluded);
19
+ // 计算实际 gutter 值(仅处理数字和数组类型)
20
+ var _ref2 = function () {
21
+ if (!gutter) return [0, 0];
22
+ if (typeof gutter === 'number') return [gutter, 0];
23
+ if (Array.isArray(gutter)) return [gutter[0] || 0, gutter[1] || 0];
24
+ return [0, 0]; // 响应式 gutter 不处理补偿
25
+ }(),
26
+ _ref3 = _slicedToArray(_ref2, 2),
27
+ horizontalGutter = _ref3[0],
28
+ verticalGutter = _ref3[1];
29
+
30
+ // 为每个 Col 添加 padding 补偿
31
+ var wrappedChildren = React.Children.map(children, function (child) {
32
+ if (! /*#__PURE__*/React.isValidElement(child)) return child;
33
+ return /*#__PURE__*/_jsx(_Col, _objectSpread(_objectSpread({}, child.props), {}, {
34
+ style: _objectSpread({
35
+ paddingLeft: horizontalGutter / 2,
36
+ paddingRight: horizontalGutter / 2,
37
+ paddingBottom: verticalGutter
38
+ }, child.props.style)
39
+ }));
40
+ });
41
+ var prefix = "".concat(cssClasses.PREFIX);
42
+ console.log('isWebViewBelow90()', isWebViewBelow90());
43
+ if (isWebViewBelow90()) {
44
+ return /*#__PURE__*/_jsx(_ConfigProvider, {
45
+ wave: {
46
+ disabled: true
47
+ },
48
+ prefixCls: prefix,
49
+ children: /*#__PURE__*/_jsx(_Row, _objectSpread(_objectSpread({
50
+ gutter: gutter
51
+ }, props), {}, {
52
+ children: wrappedChildren
53
+ }))
54
+ });
55
+ }
56
+ return /*#__PURE__*/_jsx(_ConfigProvider, {
57
+ wave: {
58
+ disabled: true
59
+ },
60
+ prefixCls: prefix,
61
+ children: /*#__PURE__*/_jsx(_Row, _objectSpread(_objectSpread({
62
+ gutter: gutter
63
+ }, props), {}, {
64
+ children: children
65
+ }))
66
+ });
67
+ };
68
+ export default Row;
@@ -98,7 +98,7 @@ var ESelector = function ESelector(props) {
98
98
  token: {},
99
99
  path: ["".concat(prefix, "-warp")]
100
100
  }, function () {
101
- return "\n .".concat(prefix, "-warp {\n gap: ").concat(gap || 16, "px;\n .itemSelect {\n .filterOptions {\n background: ").concat(colorSelectorBackground, ";\n border: ").concat(borderWidthSelectorStandard || 1, "px solid ").concat(colorSelectorBorderStandard, ";\n border-radius: ").concat(borderRadiusSelector, "px;\n padding: ").concat(spacingSelectorPaddingVertical, "px ").concat(spacingSelectorPaddingHorizontal, "px;\n &.active {\n border: ").concat(borderWidthSelectorActive || 1, "px solid ").concat(colorSelectorBorderActive, ";\n border-radius: ").concat(borderRadiusSelector, "px;\n &.activeBg {\n background: ").concat(colorSelectorBackgroundActive, ";\n }\n } \n &.active.showActiveIcon:after {\n background: ").concat(colorSelectorBorderActive, ";\n } \n &.disabled {\n opacity: ").concat(opacitySelectorTextDisabled / 100, ";\n border-color: ").concat(colorSelectorBorderDisabled, ";\n color:").concat(colorSelectorTextDisabled, ";\n }\n }\n }\n ");
101
+ return "\n .".concat(prefix, "-warp {\n > div + div {\n margin-top: ").concat(gap || 16, "px;\n }\n .itemSelect {\n .filterOptions {\n background: ").concat(colorSelectorBackground, ";\n border: ").concat(borderWidthSelectorStandard || 1, "px solid ").concat(colorSelectorBorderStandard, ";\n border-radius: ").concat(borderRadiusSelector, "px;\n padding: ").concat(spacingSelectorPaddingVertical, "px ").concat(spacingSelectorPaddingHorizontal, "px;\n &.active {\n border: ").concat(borderWidthSelectorActive || 1, "px solid ").concat(colorSelectorBorderActive, ";\n border-radius: ").concat(borderRadiusSelector, "px;\n &.activeBg {\n background: ").concat(colorSelectorBackgroundActive, ";\n }\n } \n &.active.showActiveIcon:after {\n background: ").concat(colorSelectorBorderActive, ";\n } \n &.disabled {\n opacity: ").concat(opacitySelectorTextDisabled / 100, ";\n border-color: ").concat(colorSelectorBorderDisabled, ";\n color:").concat(colorSelectorTextDisabled, ";\n }\n }\n }\n ");
102
102
  });
103
103
  return hashId;
104
104
  };
@@ -125,7 +125,7 @@ var ESelector = function ESelector(props) {
125
125
  children: [/*#__PURE__*/_jsx(Icon, {
126
126
  className: "select-tick",
127
127
  type: "icon-Tick",
128
- size: 32,
128
+ size: 14,
129
129
  color: "#fff"
130
130
  }), hasImg ? /*#__PURE__*/_jsxs("div", {
131
131
  className: "imgStyle",
@@ -44,14 +44,11 @@
44
44
  &.active {
45
45
  &.showActiveIcon {
46
46
  .select-tick {
47
- width: 16px;
48
- height: 16px;
49
47
  display: block;
50
48
  position: absolute;
51
- right: 8px;
52
- bottom: 4px;
53
- z-index: 100;
54
- transform: scale(0.5, 0.5);
49
+ right: 2px;
50
+ bottom: 0;
51
+ z-index: 2;
55
52
  }
56
53
 
57
54
  &:before {
@@ -61,14 +58,14 @@
61
58
  &:after {
62
59
  position: absolute;
63
60
  content: '';
64
- width: 64px;
65
- height: 64px;
61
+ width: 48px;
62
+ height: 48px;
66
63
  overflow: hidden;
67
64
  border-radius: 10000px;
68
- bottom: -32px;
69
- right: -32px;
65
+ bottom: -24px;
66
+ right: -24px;
70
67
  border-radius: 10000px;
71
- z-index: 99;
68
+ z-index: 1;
72
69
  }
73
70
  }
74
71
  }
@@ -59,7 +59,7 @@ var SelectorItem = function SelectorItem(props) {
59
59
  children: [/*#__PURE__*/_jsx(Icon, {
60
60
  className: "select-tick",
61
61
  type: "icon-Tick",
62
- size: 32,
62
+ size: 14,
63
63
  color: "#fff"
64
64
  }), children]
65
65
  });
@@ -23,14 +23,11 @@
23
23
  &.active {
24
24
  &.showActiveIcon {
25
25
  .select-tick {
26
- width: 16px;
27
- height: 16px;
28
26
  display: block;
29
27
  position: absolute;
30
- right: 8px;
31
- bottom: 4px;
32
- z-index: 100;
33
- transform: scale(0.5, 0.5);
28
+ right: 2px;
29
+ bottom: 0;
30
+ z-index: 2;
34
31
  }
35
32
 
36
33
  &:before {
@@ -40,14 +37,14 @@
40
37
  &:after {
41
38
  position: absolute;
42
39
  content: '';
43
- width: 64px;
44
- height: 64px;
40
+ width: 48px;
41
+ height: 48px;
45
42
  overflow: hidden;
46
43
  border-radius: 10000px;
47
- bottom: -32px;
48
- right: -32px;
44
+ bottom: -24px;
45
+ right: -24px;
49
46
  border-radius: 10000px;
50
- z-index: 99;
47
+ z-index: 1;
51
48
  }
52
49
  }
53
50
  }
@@ -84,8 +84,9 @@ var Stepper = function Stepper(_ref) {
84
84
  var _useMemo = useMemo(function () {
85
85
  var _items$current, _items;
86
86
  var hasNextStep = items && current !== undefined && current < items.length - 1;
87
+ var curStep = items && current !== undefined;
87
88
  return {
88
- title: hasNextStep ? ((_items$current = items[current]) === null || _items$current === void 0 ? void 0 : _items$current.title) || '' : '',
89
+ title: curStep ? ((_items$current = items[current]) === null || _items$current === void 0 ? void 0 : _items$current.title) || '' : '',
89
90
  nextStep: hasNextStep ? ((_items = items[current + 1]) === null || _items === void 0 ? void 0 : _items.title) || '' : ''
90
91
  };
91
92
  }, [items, current]),
@@ -86,8 +86,8 @@ var StickyFooter = function StickyFooter(props) {
86
86
  disabled: btnDisabled,
87
87
  children: buttonText
88
88
  })
89
- }), type === 'priceVariant' && !hideAmount && /*#__PURE__*/_jsxs(_Fragment, {
90
- children: [/*#__PURE__*/_jsx(Amount, {
89
+ }), type === 'priceVariant' && /*#__PURE__*/_jsxs(_Fragment, {
90
+ children: [hideAmount ? /*#__PURE__*/_jsx("div", {}) : /*#__PURE__*/_jsx(Amount, {
91
91
  titleType: titleType,
92
92
  priceStrikethrough: priceStrikethrough,
93
93
  priceColor: colorPrice || priceColor,
@@ -101,7 +101,7 @@ var StickyFooter = function StickyFooter(props) {
101
101
  onDropDownClick: onDropDownClick,
102
102
  iconType: iconType,
103
103
  children: price
104
- }), autoBreakPoint === DESKTOP && !hideBtn && /*#__PURE__*/_jsxs(_Space, {
104
+ }), !hideBtn && /*#__PURE__*/_jsxs(_Space, {
105
105
  size: "middle",
106
106
  children: [showCancel, showPrevious, showBackPage, /*#__PURE__*/_jsx(Button, {
107
107
  iconPosition: iconPosition,
@@ -112,13 +112,6 @@ var StickyFooter = function StickyFooter(props) {
112
112
  onClick: onBtnClick,
113
113
  children: buttonText
114
114
  })]
115
- }), autoBreakPoint === MOBILE && /*#__PURE__*/_jsx(Button, {
116
- icon: btnIcon,
117
- disabled: btnDisabled,
118
- loading: btnLoading,
119
- type: "primary",
120
- onClick: onBtnClick,
121
- children: buttonText
122
115
  })]
123
116
  })]
124
117
  }), children]
@@ -22,7 +22,7 @@ var Tabs = function Tabs(props) {
22
22
  type = _props$type === void 0 ? 'default' : _props$type,
23
23
  defaultActiveKey = props.defaultActiveKey,
24
24
  _props$prefixCls = props.prefixCls,
25
- prefixCls = _props$prefixCls === void 0 ? "".concat(BASE_CLASS_PREFIX, "-tabs") : _props$prefixCls,
25
+ prefixCls = _props$prefixCls === void 0 ? "".concat(BASE_CLASS_PREFIX) : _props$prefixCls,
26
26
  _props$className = props.className,
27
27
  className = _props$className === void 0 ? '' : _props$className,
28
28
  _props$isEqualTabs = props.isEqualTabs,
@@ -47,13 +47,14 @@ var Tabs = function Tabs(props) {
47
47
  var iconColor = inverse ? otherDesignToken.colorTabsIconInactiveInverse : otherDesignToken.colorTabsIconInactive; // 选中的subTitle颜色
48
48
  var iconActiveColor = inverse ? otherDesignToken.colorTabsIconActiveInverse : otherDesignToken.colorTabsIconActive; // 选中的subTitle颜色
49
49
 
50
+ var per = "".concat(BASE_CLASS_PREFIX, "-tabs");
50
51
  var useCustomButtonStyle = function useCustomButtonStyle() {
51
52
  var hashId = useStyleRegister({
52
53
  theme: theme,
53
54
  token: {},
54
55
  path: ["".concat(prefixCls)]
55
56
  }, function () {
56
- return "\n .".concat(prefixCls, "-card.").concat(prefixCls, "-fill>.").concat(prefixCls, "-nav .").concat(prefixCls, "-tab {\n border-radius: 32px;\n height:40px;\n }\n .").concat(prefixCls, "-card.").concat(prefixCls, "-fill .").concat(prefixCls, "-nav-list {\n background: ").concat(designFillTokens.colorFillAlter, ";\n border-radius: 32px;\n }\n .").concat(prefixCls, "-tab-active .").concat(prefixCls, "-item-title {\n font-family:").concat(fontFamilySecondaryBold, "-Bold;\n }\n .").concat(prefixCls, "-fill .").concat(prefixCls, "-tab-active .").concat(prefixCls, "-item-title {\n font-family:").concat(fontFamilySecondaryBold, "-Bold;\n font-size: ").concat(fontSizeMobileContentC14, ";\n }\n ");
57
+ return "\n .".concat(per, "-card.").concat(prefixCls, "-fill>.").concat(per, "-nav .").concat(per, "-tab {\n border-radius: 32px;\n height:40px;\n }\n .").concat(per, "-card.").concat(prefixCls, "-fill .").concat(per, "-nav-list {\n background: ").concat(designFillTokens.colorFillAlter, ";\n border-radius: 32px;\n }\n .").concat(per, "-tab-active .").concat(prefixCls, "-item-title {\n font-family:").concat(fontFamilySecondaryBold, "-Bold;\n }\n .").concat(prefixCls, "-fill .").concat(per, "-tab-active .").concat(prefixCls, "-item-title {\n font-family:").concat(fontFamilySecondaryBold, "-Bold;\n font-size: ").concat(fontSizeMobileContentC14, ";\n }\n ");
57
58
  });
58
59
  return hashId;
59
60
  };
@@ -2,7 +2,7 @@
2
2
 
3
3
  @components: tabs;
4
4
 
5
- .@{prefix}-@{components}-equal-tabs {
5
+ .@{prefix}-equal-tabs {
6
6
  .@{prefix}-tabs-nav-list {
7
7
  display: grid !important;
8
8
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
@@ -21,21 +21,21 @@
21
21
  }
22
22
  }
23
23
 
24
- .@{prefix}-@{components}-item {
24
+ .@{prefix}-item {
25
25
  display: flex;
26
26
  align-items: center;
27
27
  flex-direction: column;
28
28
  box-sizing: border-box;
29
29
  }
30
30
 
31
- .@{prefix}-@{components}-tab-btn {
31
+ .@{prefix}-tab-btn {
32
32
  text-align: center;
33
33
 
34
- .@{prefix}-@{components}-tab-icon {
34
+ .@{prefix}-tab-icon {
35
35
  margin: 0 !important;
36
36
  }
37
37
  }
38
38
 
39
- .@{prefix}-@{components}-fill>.@{prefix}-@{components}-nav .@{prefix}-@{components}-tab-focus {
39
+ .@{prefix}-fill>.@{prefix}-nav .@{prefix}-tab-focus {
40
40
  outline: none;
41
41
  }
@@ -63,4 +63,7 @@ export { AlignTypes } from './ListItem';
63
63
  export { default as Selector } from './Selector';
64
64
  export { default as Checkbox } from './Checkbox';
65
65
  export { default as Radio } from './Radio';
66
+ export { default as AppStyleWrapper } from './AppStyleWrapper';
67
+ export { default as Row } from './Row';
68
+ export { default as Col } from './Col';
66
69
  export { default as GlobalTokenProvider } from './GlobalTokenProvider';
@@ -38,4 +38,7 @@ export { AlignTypes } from "./ListItem";
38
38
  export { default as Selector } from "./Selector";
39
39
  export { default as Checkbox } from "./Checkbox";
40
40
  export { default as Radio } from "./Radio";
41
+ export { default as AppStyleWrapper } from "./AppStyleWrapper";
42
+ export { default as Row } from "./Row";
43
+ export { default as Col } from "./Col";
41
44
  export { default as GlobalTokenProvider } from "./GlobalTokenProvider";
package/es/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import './style/themes/index.css';
2
2
  export * from './components';
3
3
  export { default as tokenManager } from './utils/tokenManager';
4
- export { useBreakPoint, useIsMobile, checkIsMobile } from './utils/deviceType';
4
+ export { useBreakPoint, useIsMobile, checkIsMobile, isWebViewBelow90 } from './utils/deviceType';
5
5
  export * from './utils/themeContext';
package/es/index.js CHANGED
@@ -5,7 +5,7 @@ export * from "./components";
5
5
 
6
6
  // 导出工具函数
7
7
  export { default as tokenManager } from "./utils/tokenManager";
8
- export { useBreakPoint, useIsMobile, checkIsMobile } from "./utils/deviceType";
8
+ export { useBreakPoint, useIsMobile, checkIsMobile, isWebViewBelow90 } from "./utils/deviceType";
9
9
 
10
10
  // 这个是多主题的配置目前没用;选择了直接由消费者注入 token 的方式改变样式更灵活
11
11
  export * from "./utils/themeContext";
@@ -12,3 +12,18 @@ export declare const checkIsMobile: () => boolean;
12
12
  */
13
13
  export declare const useIsMobile: () => boolean;
14
14
  export declare const useBreakPoint: () => "desktop" | "mobile" | null;
15
+ /**
16
+ * 获取 WebView 的版本号
17
+ * @returns {number|null} 返回 WebView 的版本号(整数),如果无法解析则返回 null
18
+ */
19
+ export declare const getWebViewVersion: () => number | null;
20
+ /**
21
+ * 检测是否支持某个特性(例如 CSS 属性或 JavaScript API)
22
+ * @returns {boolean} 如果支持返回 true,否则返回 false
23
+ */
24
+ export declare const isGapSupported: () => boolean;
25
+ /**
26
+ * 检测 WebView 版本是否低于 90
27
+ * @returns {boolean} 如果版本低于 90 或无法检测到版本,则返回 true;否则返回 false
28
+ */
29
+ export declare const isWebViewBelow90: () => boolean;
@@ -62,4 +62,50 @@ export var useBreakPoint = function useBreakPoint() {
62
62
  setBreakpoint(autoBreakPoint);
63
63
  }, []);
64
64
  return breakpoint;
65
+ };
66
+
67
+ /**
68
+ * 获取 WebView 的版本号
69
+ * @returns {number|null} 返回 WebView 的版本号(整数),如果无法解析则返回 null
70
+ */
71
+ export var getWebViewVersion = function getWebViewVersion() {
72
+ try {
73
+ var _navigator;
74
+ var userAgent = ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.userAgent) || ''; // 确保 navigator 和 userAgent 存在
75
+
76
+ // 匹配 Chrome/XX 或 WebView/XX(Android WebView 格式)
77
+ var versionMatch = userAgent.match(/(Chrome|WebView)\/(\d+)/);
78
+
79
+ // 如果匹配成功,返回版本号;否则返回 null
80
+ return versionMatch ? parseInt(versionMatch[2], 10) : null;
81
+ } catch (error) {
82
+ console.error('Error while parsing WebView version:', error);
83
+ return null; // 捕获异常并返回 null
84
+ }
85
+ };
86
+ /**
87
+ * 检测是否支持某个特性(例如 CSS 属性或 JavaScript API)
88
+ * @returns {boolean} 如果支持返回 true,否则返回 false
89
+ */
90
+ export var isGapSupported = function isGapSupported() {
91
+ // 示例:检测是否支持 CSS 的 gap 属性
92
+ var testElement = document.createElement('div');
93
+ testElement.style.gap = '1px'; // 尝试设置 gap 属性
94
+
95
+ // 如果浏览器支持 gap 属性,则 style.gap 不会为空
96
+ return testElement.style.gap !== '';
97
+ };
98
+
99
+ /**
100
+ * 检测 WebView 版本是否低于 90
101
+ * @returns {boolean} 如果版本低于 90 或无法检测到版本,则返回 true;否则返回 false
102
+ */
103
+ export var isWebViewBelow90 = function isWebViewBelow90() {
104
+ var version = getWebViewVersion();
105
+ // 如果版本号有效且小于 90,返回 true
106
+ if (version !== null) {
107
+ return version < 90;
108
+ }
109
+ // 如果无法获取版本号,降级到特性检测
110
+ return !isGapSupported();
65
111
  };