@hsu-react/ui 2.4.5 → 2.4.7

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.
@@ -1,8 +1,12 @@
1
1
  .antdInput {
2
2
  width: 100%;
3
- height: 100%;
4
- // When the parent has no set height (height:100% resolves to auto), ensure a minimum height so the input is not squashed;
5
- // the inner .ant-input-wrapper / .ant-input inherit this value via min-height: inherit.
3
+ // The control height is a floor, not `height: 100%` — see the long note in
4
+ // `Select/index.module.scss`. Same failure: under a flex item stretched by a taller
5
+ // sibling, `height: 100%` inflates the input to the item's whole content box.
6
+ //
7
+ // The inner `height: 100%` rules below stay: when this root *is* stretched (as a flex
8
+ // child, or because the app asked for it), they propagate that height inward. They
9
+ // resolve to `auto` otherwise and fall back to `min-height: inherit`.
6
10
  min-height: var(--vita-control-height);
7
11
 
8
12
  :global(.ant-input-clear-icon) {
@@ -4,7 +4,10 @@
4
4
  --tree-switcher-gap: 0px;
5
5
 
6
6
  width: 100%;
7
- height: 100%;
7
+ // Control height as a floor, not `height: 100%` — same reason as `Select` (see the
8
+ // note there). TreeSelect had no `min-height` at all because `height: 100%` was doing
9
+ // that job by accident; dropping one without adding the other would collapse it.
10
+ min-height: var(--vita-control-height);
8
11
 
9
12
  // CF style: outlined input control that follows appearance switching.
10
13
  //
@@ -5,9 +5,24 @@
5
5
  align-items: center;
6
6
 
7
7
  width: 100%;
8
- height: 100%;
9
- // When the parent has no explicit height (height:100% resolves to auto), guarantee a min height
10
- // consistent with Input and other form controls, so it is neither squashed nor mis-sized in search rows.
8
+ // The control height is a floor, not `height: 100%`.
9
+ //
10
+ // `height: 100%` looks harmless because it resolves to `auto` under an auto-height
11
+ // parent — but the moment the parent has a *definite* height the control inflates to
12
+ // fill it, and the most common way a parent acquires one is by accident: a flex item
13
+ // stretched by a taller sibling. A card holding `<label> <Select> <hint>` where the
14
+ // hint wraps to two lines is enough — the Select swells to the card's whole content
15
+ // box (measured: 102px for a 32px control) and covers the label and the hint.
16
+ //
17
+ // This bit hsu-ui itself: `ChainGraph/SearchSelect` has to park the Select in a
18
+ // fixed 32px box, "preventing the Select root's height:100% from resolving against
19
+ // the graph and being stretched to the full graph height". Consumers hit it too and
20
+ // reach for the same wrapper, which is a workaround for a default that is wrong.
21
+ //
22
+ // Filling a deliberately sized parent still works without the declaration: as a flex
23
+ // child the default `align-self: stretch` fills the cross axis, and the inner
24
+ // `height: 100%` rules below then resolve against a genuinely definite height.
25
+ // A block parent that really wants a taller control can still say `height: 100%`.
11
26
  min-height: var(--vita-control-height);
12
27
  padding: 0px 11px;
13
28
 
@@ -118,7 +133,16 @@
118
133
  align-items: center;
119
134
 
120
135
  width: 100%;
121
- height: 100%;
136
+ // 撑满外壳用 align-self,不用 height: 100%。
137
+ //
138
+ // 外壳 `.select` 的高度是 `min-height` 撑出来的、`height` 仍是 auto,
139
+ // 百分比高度对着 auto 解析不出东西 —— 这一层会缩回内容高(实测 22px,
140
+ // 而外壳是 32px),上下各多出 5px 点不动的死区:看着是个 32px 的下拉框,
141
+ // 边缘一圈却没有反应。
142
+ //
143
+ // 外壳是 flex 且 align-items: center,所以这里要显式 stretch;
144
+ // 前后缀图标不受影响,它们该保持居中
145
+ align-self: stretch;
122
146
  margin: 0px !important;
123
147
 
124
148
  border-radius: inherit;
@@ -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
 
@@ -1,8 +1,12 @@
1
1
  .antdInput {
2
2
  width: 100%;
3
- height: 100%;
4
- // When the parent has no set height (height:100% resolves to auto), ensure a minimum height so the input is not squashed;
5
- // the inner .ant-input-wrapper / .ant-input inherit this value via min-height: inherit.
3
+ // The control height is a floor, not `height: 100%` — see the long note in
4
+ // `Select/index.module.scss`. Same failure: under a flex item stretched by a taller
5
+ // sibling, `height: 100%` inflates the input to the item's whole content box.
6
+ //
7
+ // The inner `height: 100%` rules below stay: when this root *is* stretched (as a flex
8
+ // child, or because the app asked for it), they propagate that height inward. They
9
+ // resolve to `auto` otherwise and fall back to `min-height: inherit`.
6
10
  min-height: var(--vita-control-height);
7
11
 
8
12
  :global(.ant-input-clear-icon) {
@@ -4,7 +4,10 @@
4
4
  --tree-switcher-gap: 0px;
5
5
 
6
6
  width: 100%;
7
- height: 100%;
7
+ // Control height as a floor, not `height: 100%` — same reason as `Select` (see the
8
+ // note there). TreeSelect had no `min-height` at all because `height: 100%` was doing
9
+ // that job by accident; dropping one without adding the other would collapse it.
10
+ min-height: var(--vita-control-height);
8
11
 
9
12
  // CF style: outlined input control that follows appearance switching.
10
13
  //
@@ -5,9 +5,24 @@
5
5
  align-items: center;
6
6
 
7
7
  width: 100%;
8
- height: 100%;
9
- // When the parent has no explicit height (height:100% resolves to auto), guarantee a min height
10
- // consistent with Input and other form controls, so it is neither squashed nor mis-sized in search rows.
8
+ // The control height is a floor, not `height: 100%`.
9
+ //
10
+ // `height: 100%` looks harmless because it resolves to `auto` under an auto-height
11
+ // parent — but the moment the parent has a *definite* height the control inflates to
12
+ // fill it, and the most common way a parent acquires one is by accident: a flex item
13
+ // stretched by a taller sibling. A card holding `<label> <Select> <hint>` where the
14
+ // hint wraps to two lines is enough — the Select swells to the card's whole content
15
+ // box (measured: 102px for a 32px control) and covers the label and the hint.
16
+ //
17
+ // This bit hsu-ui itself: `ChainGraph/SearchSelect` has to park the Select in a
18
+ // fixed 32px box, "preventing the Select root's height:100% from resolving against
19
+ // the graph and being stretched to the full graph height". Consumers hit it too and
20
+ // reach for the same wrapper, which is a workaround for a default that is wrong.
21
+ //
22
+ // Filling a deliberately sized parent still works without the declaration: as a flex
23
+ // child the default `align-self: stretch` fills the cross axis, and the inner
24
+ // `height: 100%` rules below then resolve against a genuinely definite height.
25
+ // A block parent that really wants a taller control can still say `height: 100%`.
11
26
  min-height: var(--vita-control-height);
12
27
  padding: 0px 11px;
13
28
 
@@ -118,7 +133,16 @@
118
133
  align-items: center;
119
134
 
120
135
  width: 100%;
121
- height: 100%;
136
+ // 撑满外壳用 align-self,不用 height: 100%。
137
+ //
138
+ // 外壳 `.select` 的高度是 `min-height` 撑出来的、`height` 仍是 auto,
139
+ // 百分比高度对着 auto 解析不出东西 —— 这一层会缩回内容高(实测 22px,
140
+ // 而外壳是 32px),上下各多出 5px 点不动的死区:看着是个 32px 的下拉框,
141
+ // 边缘一圈却没有反应。
142
+ //
143
+ // 外壳是 flex 且 align-items: center,所以这里要显式 stretch;
144
+ // 前后缀图标不受影响,它们该保持居中
145
+ align-self: stretch;
122
146
  margin: 0px !important;
123
147
 
124
148
  border-radius: inherit;
@@ -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.5",
3
+ "version": "2.4.7",
4
4
  "description": "一套基于 React + Ant Design 的中后台业务组件库",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,8 +1,12 @@
1
1
  .antdInput {
2
2
  width: 100%;
3
- height: 100%;
4
- // When the parent has no set height (height:100% resolves to auto), ensure a minimum height so the input is not squashed;
5
- // the inner .ant-input-wrapper / .ant-input inherit this value via min-height: inherit.
3
+ // The control height is a floor, not `height: 100%` — see the long note in
4
+ // `Select/index.module.scss`. Same failure: under a flex item stretched by a taller
5
+ // sibling, `height: 100%` inflates the input to the item's whole content box.
6
+ //
7
+ // The inner `height: 100%` rules below stay: when this root *is* stretched (as a flex
8
+ // child, or because the app asked for it), they propagate that height inward. They
9
+ // resolve to `auto` otherwise and fall back to `min-height: inherit`.
6
10
  min-height: var(--vita-control-height);
7
11
 
8
12
  :global(.ant-input-clear-icon) {
@@ -4,7 +4,10 @@
4
4
  --tree-switcher-gap: 0px;
5
5
 
6
6
  width: 100%;
7
- height: 100%;
7
+ // Control height as a floor, not `height: 100%` — same reason as `Select` (see the
8
+ // note there). TreeSelect had no `min-height` at all because `height: 100%` was doing
9
+ // that job by accident; dropping one without adding the other would collapse it.
10
+ min-height: var(--vita-control-height);
8
11
 
9
12
  // CF style: outlined input control that follows appearance switching.
10
13
  //
@@ -5,9 +5,24 @@
5
5
  align-items: center;
6
6
 
7
7
  width: 100%;
8
- height: 100%;
9
- // When the parent has no explicit height (height:100% resolves to auto), guarantee a min height
10
- // consistent with Input and other form controls, so it is neither squashed nor mis-sized in search rows.
8
+ // The control height is a floor, not `height: 100%`.
9
+ //
10
+ // `height: 100%` looks harmless because it resolves to `auto` under an auto-height
11
+ // parent — but the moment the parent has a *definite* height the control inflates to
12
+ // fill it, and the most common way a parent acquires one is by accident: a flex item
13
+ // stretched by a taller sibling. A card holding `<label> <Select> <hint>` where the
14
+ // hint wraps to two lines is enough — the Select swells to the card's whole content
15
+ // box (measured: 102px for a 32px control) and covers the label and the hint.
16
+ //
17
+ // This bit hsu-ui itself: `ChainGraph/SearchSelect` has to park the Select in a
18
+ // fixed 32px box, "preventing the Select root's height:100% from resolving against
19
+ // the graph and being stretched to the full graph height". Consumers hit it too and
20
+ // reach for the same wrapper, which is a workaround for a default that is wrong.
21
+ //
22
+ // Filling a deliberately sized parent still works without the declaration: as a flex
23
+ // child the default `align-self: stretch` fills the cross axis, and the inner
24
+ // `height: 100%` rules below then resolve against a genuinely definite height.
25
+ // A block parent that really wants a taller control can still say `height: 100%`.
11
26
  min-height: var(--vita-control-height);
12
27
  padding: 0px 11px;
13
28
 
@@ -118,7 +133,16 @@
118
133
  align-items: center;
119
134
 
120
135
  width: 100%;
121
- height: 100%;
136
+ // 撑满外壳用 align-self,不用 height: 100%。
137
+ //
138
+ // 外壳 `.select` 的高度是 `min-height` 撑出来的、`height` 仍是 auto,
139
+ // 百分比高度对着 auto 解析不出东西 —— 这一层会缩回内容高(实测 22px,
140
+ // 而外壳是 32px),上下各多出 5px 点不动的死区:看着是个 32px 的下拉框,
141
+ // 边缘一圈却没有反应。
142
+ //
143
+ // 外壳是 flex 且 align-items: center,所以这里要显式 stretch;
144
+ // 前后缀图标不受影响,它们该保持居中
145
+ align-self: stretch;
122
146
  margin: 0px !important;
123
147
 
124
148
  border-radius: inherit;
@@ -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
  );