@hsu-react/ui 2.4.4 → 2.4.6

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.
@@ -12,4 +12,14 @@
12
12
  min-height: inherit;
13
13
  }
14
14
  }
15
+
16
+ // Same guard as Input: once the box is an .ant-input-affix-wrapper, `.ant-input` names
17
+ // the one-line <input> inside it, and an app sizing `.ant-input` like a bare input
18
+ // pushes that inner element out of the box and the text onto the bottom border.
19
+ // Full story in components/Input/index.module.scss.
20
+ &:global(.ant-input-affix-wrapper) > :global(.ant-input),
21
+ :global(.ant-input-affix-wrapper) > :global(.ant-input) {
22
+ height: auto;
23
+ min-height: 0px;
24
+ }
15
25
  }
@@ -19,4 +19,14 @@
19
19
  }
20
20
  }
21
21
  }
22
+
23
+ // Same guard as Input: once the box is an .ant-input-affix-wrapper, `.ant-input` names
24
+ // the one-line <input> inside it, and an app sizing `.ant-input` like a bare input
25
+ // pushes that inner element out of the box and the text onto the bottom border.
26
+ // Full story in components/Input/index.module.scss.
27
+ &:global(.ant-input-affix-wrapper) > :global(.ant-input),
28
+ :global(.ant-input-affix-wrapper) > :global(.ant-input) {
29
+ height: auto;
30
+ min-height: 0px;
31
+ }
22
32
  }
@@ -19,4 +19,23 @@
19
19
  min-height: inherit;
20
20
  }
21
21
  }
22
+
23
+ // Keep the inner <input> one line tall, whatever the app says about `.ant-input`.
24
+ //
25
+ // `.ant-input` is two different elements depending on the shape: on a bare antd input
26
+ // it is the bordered box itself, but as soon as there is a clear button, a prefix or a
27
+ // suffix — and this component turns allowClear on by default, so there almost always
28
+ // is one — the box becomes `.ant-input-affix-wrapper` and `.ant-input` moves to the
29
+ // <input> inside it. Apps carry the bare-input habit over and write
30
+ // `.some-form .ant-input { height: 32px }` meaning the box; that height lands on the
31
+ // inner input instead, which is then taller than the ~22px the wrapper's padding
32
+ // leaves it, hangs out of the bottom, and drags the text down onto the border.
33
+ //
34
+ // Three classes, so it outweighs the two-class selectors apps typically write; an app
35
+ // that really means the inner input can still say so with one more level.
36
+ &:global(.ant-input-affix-wrapper) > :global(.ant-input),
37
+ :global(.ant-input-affix-wrapper) > :global(.ant-input) {
38
+ height: auto;
39
+ min-height: 0px;
40
+ }
22
41
  }
@@ -1,4 +1,10 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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); }
5
+ 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; }
6
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
2
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
10
  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; }
@@ -13,6 +19,26 @@ import { toAntdComponents, toAntdTheme } from "../styles/tokens";
13
19
  import { FeedbackHolder } from "../feedback";
14
20
  import { jsx as _jsx } from "react/jsx-runtime";
15
21
  import { jsxs as _jsxs } from "react/jsx-runtime";
22
+ /**
23
+ * Merge the library's per-component tokens with the consumer's, one level deeper than a spread.
24
+ *
25
+ * Spreading the two maps replaces a whole component block: an app that only wants
26
+ * `Button.primaryColor` would silently lose the library's `Button.*Shadow: none` and get antd's
27
+ * stock 2px shadow back under every button — no error, and nothing in the app's own theme to
28
+ * explain it. Merging per component means an app overrides *tokens*, not blocks.
29
+ */
30
+ var mergeComponents = function mergeComponents(base, extra) {
31
+ if (!extra) return base;
32
+ var merged = _objectSpread({}, base);
33
+ for (var _i = 0, _Object$entries = Object.entries(extra); _i < _Object$entries.length; _i++) {
34
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
35
+ name = _Object$entries$_i[0],
36
+ tokens = _Object$entries$_i[1];
37
+ merged[name] = _objectSpread(_objectSpread({}, merged[name]), tokens);
38
+ }
39
+ return merged;
40
+ };
41
+
16
42
  /**
17
43
  * Hsu UI global configuration: permissions, the request implementation, and the design tokens.
18
44
  *
@@ -56,7 +82,7 @@ var ConfigProvider = function ConfigProvider(_ref) {
56
82
  dark: isDark,
57
83
  primaryColor: primaryColor
58
84
  })), theme === null || theme === void 0 ? void 0 : theme.token),
59
- components: _objectSpread(_objectSpread({}, toAntdComponents()), theme === null || theme === void 0 ? void 0 : theme.components)
85
+ components: mergeComponents(toAntdComponents(), theme === null || theme === void 0 ? void 0 : theme.components)
60
86
  });
61
87
  }, [isDark, primaryColor, theme]);
62
88
 
@@ -12,4 +12,14 @@
12
12
  min-height: inherit;
13
13
  }
14
14
  }
15
+
16
+ // Same guard as Input: once the box is an .ant-input-affix-wrapper, `.ant-input` names
17
+ // the one-line <input> inside it, and an app sizing `.ant-input` like a bare input
18
+ // pushes that inner element out of the box and the text onto the bottom border.
19
+ // Full story in components/Input/index.module.scss.
20
+ &:global(.ant-input-affix-wrapper) > :global(.ant-input),
21
+ :global(.ant-input-affix-wrapper) > :global(.ant-input) {
22
+ height: auto;
23
+ min-height: 0px;
24
+ }
15
25
  }
@@ -19,4 +19,14 @@
19
19
  }
20
20
  }
21
21
  }
22
+
23
+ // Same guard as Input: once the box is an .ant-input-affix-wrapper, `.ant-input` names
24
+ // the one-line <input> inside it, and an app sizing `.ant-input` like a bare input
25
+ // pushes that inner element out of the box and the text onto the bottom border.
26
+ // Full story in components/Input/index.module.scss.
27
+ &:global(.ant-input-affix-wrapper) > :global(.ant-input),
28
+ :global(.ant-input-affix-wrapper) > :global(.ant-input) {
29
+ height: auto;
30
+ min-height: 0px;
31
+ }
22
32
  }
@@ -19,4 +19,23 @@
19
19
  min-height: inherit;
20
20
  }
21
21
  }
22
+
23
+ // Keep the inner <input> one line tall, whatever the app says about `.ant-input`.
24
+ //
25
+ // `.ant-input` is two different elements depending on the shape: on a bare antd input
26
+ // it is the bordered box itself, but as soon as there is a clear button, a prefix or a
27
+ // suffix — and this component turns allowClear on by default, so there almost always
28
+ // is one — the box becomes `.ant-input-affix-wrapper` and `.ant-input` moves to the
29
+ // <input> inside it. Apps carry the bare-input habit over and write
30
+ // `.some-form .ant-input { height: 32px }` meaning the box; that height lands on the
31
+ // inner input instead, which is then taller than the ~22px the wrapper's padding
32
+ // leaves it, hangs out of the bottom, and drags the text down onto the border.
33
+ //
34
+ // Three classes, so it outweighs the two-class selectors apps typically write; an app
35
+ // that really means the inner input can still say so with one more level.
36
+ &:global(.ant-input-affix-wrapper) > :global(.ant-input),
37
+ :global(.ant-input-affix-wrapper) > :global(.ant-input) {
38
+ height: auto;
39
+ min-height: 0px;
40
+ }
22
41
  }
@@ -15,6 +15,28 @@ var _jsxRuntime = require("react/jsx-runtime");
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ /**
19
+ * Merge the library's per-component tokens with the consumer's, one level deeper than a spread.
20
+ *
21
+ * Spreading the two maps replaces a whole component block: an app that only wants
22
+ * `Button.primaryColor` would silently lose the library's `Button.*Shadow: none` and get antd's
23
+ * stock 2px shadow back under every button — no error, and nothing in the app's own theme to
24
+ * explain it. Merging per component means an app overrides *tokens*, not blocks.
25
+ */
26
+ const mergeComponents = (base, extra) => {
27
+ if (!extra) return base;
28
+ const merged = {
29
+ ...base
30
+ };
31
+ for (const [name, tokens] of Object.entries(extra)) {
32
+ merged[name] = {
33
+ ...merged[name],
34
+ ...tokens
35
+ };
36
+ }
37
+ return merged;
38
+ };
39
+
18
40
  /**
19
41
  * Hsu UI global configuration: permissions, the request implementation, and the design tokens.
20
42
  *
@@ -57,10 +79,7 @@ const ConfigProvider = ({
57
79
  }),
58
80
  ...theme?.token
59
81
  },
60
- components: {
61
- ...(0, _tokens.toAntdComponents)(),
62
- ...theme?.components
63
- }
82
+ components: mergeComponents((0, _tokens.toAntdComponents)(), theme?.components)
64
83
  }), [isDark, primaryColor, theme]);
65
84
 
66
85
  // Written onto <html> rather than a wrapper element: this provider usually sits at the very top
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsu-react/ui",
3
- "version": "2.4.4",
3
+ "version": "2.4.6",
4
4
  "description": "一套基于 React + Ant Design 的中后台业务组件库",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -12,4 +12,14 @@
12
12
  min-height: inherit;
13
13
  }
14
14
  }
15
+
16
+ // Same guard as Input: once the box is an .ant-input-affix-wrapper, `.ant-input` names
17
+ // the one-line <input> inside it, and an app sizing `.ant-input` like a bare input
18
+ // pushes that inner element out of the box and the text onto the bottom border.
19
+ // Full story in components/Input/index.module.scss.
20
+ &:global(.ant-input-affix-wrapper) > :global(.ant-input),
21
+ :global(.ant-input-affix-wrapper) > :global(.ant-input) {
22
+ height: auto;
23
+ min-height: 0px;
24
+ }
15
25
  }
@@ -19,4 +19,14 @@
19
19
  }
20
20
  }
21
21
  }
22
+
23
+ // Same guard as Input: once the box is an .ant-input-affix-wrapper, `.ant-input` names
24
+ // the one-line <input> inside it, and an app sizing `.ant-input` like a bare input
25
+ // pushes that inner element out of the box and the text onto the bottom border.
26
+ // Full story in components/Input/index.module.scss.
27
+ &:global(.ant-input-affix-wrapper) > :global(.ant-input),
28
+ :global(.ant-input-affix-wrapper) > :global(.ant-input) {
29
+ height: auto;
30
+ min-height: 0px;
31
+ }
22
32
  }
@@ -19,4 +19,23 @@
19
19
  min-height: inherit;
20
20
  }
21
21
  }
22
+
23
+ // Keep the inner <input> one line tall, whatever the app says about `.ant-input`.
24
+ //
25
+ // `.ant-input` is two different elements depending on the shape: on a bare antd input
26
+ // it is the bordered box itself, but as soon as there is a clear button, a prefix or a
27
+ // suffix — and this component turns allowClear on by default, so there almost always
28
+ // is one — the box becomes `.ant-input-affix-wrapper` and `.ant-input` moves to the
29
+ // <input> inside it. Apps carry the bare-input habit over and write
30
+ // `.some-form .ant-input { height: 32px }` meaning the box; that height lands on the
31
+ // inner input instead, which is then taller than the ~22px the wrapper's padding
32
+ // leaves it, hangs out of the bottom, and drags the text down onto the border.
33
+ //
34
+ // Three classes, so it outweighs the two-class selectors apps typically write; an app
35
+ // that really means the inner input can still say so with one more level.
36
+ &:global(.ant-input-affix-wrapper) > :global(.ant-input),
37
+ :global(.ant-input-affix-wrapper) > :global(.ant-input) {
38
+ height: auto;
39
+ min-height: 0px;
40
+ }
22
41
  }
@@ -44,6 +44,28 @@ export interface ConfigProviderProps {
44
44
  children?: React.ReactNode;
45
45
  }
46
46
 
47
+ /**
48
+ * Merge the library's per-component tokens with the consumer's, one level deeper than a spread.
49
+ *
50
+ * Spreading the two maps replaces a whole component block: an app that only wants
51
+ * `Button.primaryColor` would silently lose the library's `Button.*Shadow: none` and get antd's
52
+ * stock 2px shadow back under every button — no error, and nothing in the app's own theme to
53
+ * explain it. Merging per component means an app overrides *tokens*, not blocks.
54
+ */
55
+ const mergeComponents = (
56
+ base: ThemeConfig["components"],
57
+ extra: ThemeConfig["components"]
58
+ ): ThemeConfig["components"] => {
59
+ if (!extra) return base;
60
+
61
+ const merged = { ...base } as Record<string, object | undefined>;
62
+ for (const [name, tokens] of Object.entries(extra)) {
63
+ merged[name] = { ...merged[name], ...tokens };
64
+ }
65
+
66
+ return merged as ThemeConfig["components"];
67
+ };
68
+
47
69
  /**
48
70
  * Hsu UI global configuration: permissions, the request implementation, and the design tokens.
49
71
  *
@@ -82,7 +104,7 @@ const ConfigProvider: React.FC<ConfigProviderProps> = ({
82
104
  algorithm: isDark ? antdTheme.darkAlgorithm : antdTheme.defaultAlgorithm,
83
105
  ...theme,
84
106
  token: { ...toAntdTheme({ dark: isDark, primaryColor }), ...theme?.token },
85
- components: { ...toAntdComponents(), ...theme?.components },
107
+ components: mergeComponents(toAntdComponents(), theme?.components),
86
108
  }),
87
109
  [isDark, primaryColor, theme]
88
110
  );