@unicom-cloud/ui 0.8.101 → 0.8.103

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 (141) hide show
  1. package/Badge.js +7 -54
  2. package/Copy.js +6 -5
  3. package/LiquidFill.js +6 -5
  4. package/List.js +1 -1
  5. package/Marquee.js +6 -5
  6. package/QrCode.js +6 -5
  7. package/Tooltip.js +3 -4
  8. package/Tour.js +6 -5
  9. package/anchor/Anchor.js +12 -12
  10. package/anchor/util.js +10 -10
  11. package/back-top/index.js +7 -7
  12. package/badge/index.js +109 -162
  13. package/card/index.js +63 -43
  14. package/color-picker/InputHex.js +3 -4
  15. package/color-picker/InputRgb.js +7 -8
  16. package/color-picker/Palette.js +3 -4
  17. package/color-picker/Panel.js +3 -4
  18. package/color-picker/colors.js +5 -5
  19. package/color-picker/hooks/useColorPicker.js +3 -4
  20. package/color-picker/utils.js +14 -15
  21. package/components/common/space/index.js +24 -24
  22. package/components/common/utils/PqbCSSTransition.js +1 -1
  23. package/components/common/utils/constant.js +6 -3
  24. package/components/common/utils/reactDOM.js +6 -4
  25. package/components/common/utils/{scrollIntoView.js → scrollIntoViewIfNeeded.js} +1 -1
  26. package/components/common/utils/setPrimaryColor.js +18 -18
  27. package/components/common/utils/setTheme.js +8 -9
  28. package/copy/index.js +4 -3
  29. package/dist/scroll-into-view-if-needed/compute/index.js +126 -0
  30. package/dist/scroll-into-view-if-needed/smooth/index.js +70 -0
  31. package/dist/scroll-into-view-if-needed/src/index.js +19 -19
  32. package/form/FormItem.js +69 -65
  33. package/form/context.js +6 -7
  34. package/grid/Col-.js +86 -0
  35. package/grid/Col.js +156 -73
  36. package/grid/Grid.js +71 -67
  37. package/grid/Row.js +53 -44
  38. package/grid/index.js +13 -13
  39. package/index.js +639 -662
  40. package/input/Textarea.js +1 -1
  41. package/input/autoSizeTextAreaHeight.js +7 -7
  42. package/liquid-fill/index.js +6 -5
  43. package/liquid-fill/interface.js +1 -0
  44. package/list/index.js +1 -1
  45. package/marquee/index.js +141 -223
  46. package/marquee/interface.js +1 -0
  47. package/marquee-/index.js +260 -0
  48. package/marquee-/interface.js +1 -0
  49. package/menu/Item.js +9 -9
  50. package/package.json +1 -1
  51. package/qr-code/index.js +6 -5
  52. package/splitter/SplitBar.js +81 -79
  53. package/splitter/Splitter.js +70 -78
  54. package/splitter/hooks/useResizable.js +9 -18
  55. package/splitter/hooks/useResize.js +10 -10
  56. package/splitter/hooks/useSizes.js +28 -28
  57. package/statistic/index.js +10 -10
  58. package/style.css +1 -1
  59. package/table/Table.js +369 -370
  60. package/table/hook/useThResizable.js +6 -5
  61. package/table/th-resizable/index.js +13 -12
  62. package/time-picker/util.js +8 -8
  63. package/tooltip/index.js +1 -2
  64. package/tour/index.js +6 -5
  65. package/tour/interface.js +1 -0
  66. package/tree/NodeList.js +1 -1
  67. package/types/common/utils/constant.d.ts +1 -0
  68. package/types/common/utils/scrollIntoViewIfNeeded.d.ts +4 -0
  69. package/types/common/utils/tree.d.ts +1 -0
  70. package/types/common/utils/tween.d.ts +1 -0
  71. package/types/pc/anchor/util.d.ts +1 -1
  72. package/types/pc/badge/interface.d.ts +2 -0
  73. package/types/pc/card/interface.d.ts +8 -0
  74. package/types/pc/color-picker/hooks/useColorPicker.d.ts +7 -2
  75. package/types/pc/color-picker/utils.d.ts +6 -1
  76. package/types/pc/config-provider/interface.d.ts +8 -8
  77. package/types/pc/form/FormItem.d.ts +1 -1
  78. package/types/pc/grid/Col-.d.ts +4 -0
  79. package/types/pc/grid/Col.d.ts +3 -2
  80. package/types/pc/grid/Grid.d.ts +2 -2
  81. package/types/pc/grid/Item.d.ts +3 -3
  82. package/types/pc/grid/Row.d.ts +3 -2
  83. package/types/pc/grid/hook/useResponsiveState.d.ts +2 -2
  84. package/types/pc/grid/interface.d.ts +13 -7
  85. package/types/pc/index.d.ts +4 -4
  86. package/types/pc/liquid-fill/index.d.ts +2 -113
  87. package/types/pc/liquid-fill/interface.d.ts +113 -0
  88. package/types/pc/marquee/index.d.ts +3 -60
  89. package/types/pc/marquee/interface.d.ts +95 -0
  90. package/types/pc/marquee-/index.d.ts +8 -0
  91. package/types/pc/marquee-/interface.d.ts +56 -0
  92. package/types/pc/qr-code/index.d.ts +1 -31
  93. package/types/pc/qr-code/interface.d.ts +26 -33
  94. package/types/pc/splitter/SplitBar.d.ts +0 -1
  95. package/types/pc/splitter/hooks/useResizable.d.ts +0 -1
  96. package/types/pc/splitter/hooks/useResize.d.ts +1 -2
  97. package/types/pc/splitter/interface.d.ts +0 -8
  98. package/types/pc/tour/index.d.ts +2 -45
  99. package/types/pc/tour/interface.d.ts +46 -0
  100. package/types/pc/upload/interface.d.ts +1 -0
  101. package/types/pc/utils/constant.d.ts +1 -2
  102. package/types/pc/utils/dayjs.d.ts +2 -1
  103. package/types/pc/utils/index.d.ts +2 -5
  104. package/types/pc/utils/responsiveObserve.d.ts +8 -4
  105. package/types/pc/utils/scrollIntoViewIfNeeded.d.ts +3 -0
  106. package/types/pc/utils/tree.d.ts +2 -1
  107. package/types/pc/utils/tween.d.ts +1 -1
  108. package/typography/Ellipsis.js +6 -5
  109. package/typography/Operations.js +6 -5
  110. package/upload/request.js +12 -13
  111. package/upload/request_.js +2 -3
  112. package/utils/constant.js +5 -5
  113. package/utils/dayjs.js +13 -12
  114. package/utils/index.js +261 -284
  115. package/utils/responsiveObserve.js +32 -25
  116. package/utils/scrollIntoViewIfNeeded.js +12 -0
  117. package/utils/tree.js +11 -9
  118. package/utils/tween.js +5 -5
  119. package/version/index.js +1 -1
  120. package/components/common/utils/convertToDurationBasedOnTimeUnits.js +0 -6
  121. package/dist/compute-scroll-into-view/src/index.js +0 -126
  122. package/dist/tinycolor/chunk/BOzCVdr0.js +0 -182
  123. package/dist/tinycolor/customize/index.js +0 -12
  124. package/dist/tinycolor/src/conversion.js +0 -143
  125. package/dist/tinycolor/src/css-color-names.js +0 -153
  126. package/dist/tinycolor/src/format-input.js +0 -77
  127. package/dist/tinycolor/src/index.js +0 -388
  128. package/dist/tinycolor/src/util.js +0 -32
  129. package/types/common/utils/convertToDurationBasedOnTimeUnits.d.ts +0 -3
  130. package/types/common/utils/scrollIntoView.d.ts +0 -4
  131. package/types/common/utils/tinycolor.d.ts +0 -1
  132. package/types/pc/utils/color.d.ts +0 -1
  133. package/types/pc/utils/computeScrollIntoView.d.ts +0 -1
  134. package/types/pc/utils/convertToDurationBasedOnTimeUnits.d.ts +0 -3
  135. package/types/pc/utils/scrollIntoView.d.ts +0 -3
  136. package/types/pc/utils/tinycolor.d.ts +0 -1
  137. package/utils/color.js +0 -4
  138. package/utils/computeScrollIntoView.js +0 -6
  139. package/utils/convertToDurationBasedOnTimeUnits.js +0 -6
  140. package/utils/scrollIntoView.js +0 -6
  141. package/utils/tinycolor.js +0 -29
package/form/FormItem.js CHANGED
@@ -1,22 +1,24 @@
1
- import { jsx as i, jsxs as E, Fragment as ie } from "react/jsx-runtime";
2
- import V, { forwardRef as ae, useContext as F, useState as O, useRef as me, useEffect as de, useMemo as U, createElement as _, cloneElement as z } from "react";
3
- import ce from "lodash/isArray";
4
- import pe from "lodash/isFunction";
1
+ import { jsx as i, jsxs as E, Fragment as ae } from "react/jsx-runtime";
2
+ import U, { forwardRef as me, useContext as F, useState as W, useRef as de, useEffect as ce, useMemo as _, createElement as z, cloneElement as H } from "react";
3
+ import pe from "lodash/isArray";
4
+ import ue from "lodash/isFunction";
5
5
  import h from "lodash/isPlainObject";
6
- import y from "lodash/isUndefined";
6
+ import x from "lodash/isUndefined";
7
7
  import "../config-provider/ConfigProvider.js";
8
- import K from "../grid/index.js";
9
- import ue from "../components/common/hooks/useMergeProps.js";
10
- import { PqbCSSTransition as fe } from "../components/common/utils/PqbCSSTransition.js";
8
+ import "../grid/index.js";
9
+ import fe from "../components/common/hooks/useMergeProps.js";
10
+ import { PqbCSSTransition as be } from "../components/common/utils/PqbCSSTransition.js";
11
11
  import C from "@unicom-cloud/utils/class-name";
12
- import { omit as be } from "../components/common/utils/omit.js";
12
+ import { omit as ge } from "../components/common/utils/omit.js";
13
13
  import $ from "./Control.js";
14
- import ge from "./FormLabel.js";
15
- import { FormItemContext as H, FormListContext as he, FormContext as W } from "./context.js";
14
+ import he from "./FormLabel.js";
15
+ import { FormItemContext as K, FormListContext as Ce, FormContext as B } from "./context.js";
16
16
  import { VALIDATE_STATUS as k } from "./interface.js";
17
- import { formatValidateMsg as Ce } from "./util.js";
17
+ import { formatValidateMsg as xe } from "./util.js";
18
18
  import ye from "../config-provider/context.js";
19
- const xe = K.Row, G = K.Col, ve = ({
19
+ import ve from "../grid/Row.js";
20
+ import G from "../grid/Col.js";
21
+ const we = ({
20
22
  prefixCls: f,
21
23
  help: b,
22
24
  errors: e,
@@ -31,9 +33,9 @@ const xe = K.Row, G = K.Col, ve = ({
31
33
  /* @__PURE__ */ i("div", { role: "alert", className: `${f}-message-help-warning`, children: p }, d)
32
34
  );
33
35
  });
34
- const x = !y(b) || !!c.length, u = x || !!g.length;
36
+ const y = !x(b) || !!c.length, u = y || !!g.length;
35
37
  return u && /* @__PURE__ */ i(
36
- fe,
38
+ be,
37
39
  {
38
40
  in: u,
39
41
  appear: !0,
@@ -44,9 +46,9 @@ const xe = K.Row, G = K.Col, ve = ({
44
46
  "div",
45
47
  {
46
48
  className: C(`${f}-message`, {
47
- [`${f}-message-help`]: x
49
+ [`${f}-message-help`]: y
48
50
  }),
49
- children: y(b) ? /* @__PURE__ */ E(ie, { children: [
51
+ children: x(b) ? /* @__PURE__ */ E(ae, { children: [
50
52
  g.length > 0 && g,
51
53
  c.length > 0 && c
52
54
  ] }) : b
@@ -54,11 +56,11 @@ const xe = K.Row, G = K.Col, ve = ({
54
56
  )
55
57
  }
56
58
  );
57
- }, we = {
59
+ }, Fe = {
58
60
  trigger: "onChange",
59
61
  triggerPropName: "value"
60
- }, Fe = (f, b) => {
61
- const e = ue(f, we), { getPrefixCls: I, prefixCls: g } = F(ye), c = F(H), x = F(he), [u, p] = O(null), [d, T] = O(null), r = F(W), l = r.prefixCls || I?.("form"), q = e.layout || r.layout, B = e.labelAlign || r.labelAlign, N = me(!1), J = (n, t = {}) => {
62
+ }, $e = (f, b) => {
63
+ const e = fe(f, Fe), { getPrefixCls: I, prefixCls: g } = F(ye), c = F(K), y = F(Ce), [u, p] = W(null), [d, T] = W(null), r = F(B), l = r.prefixCls || I?.("form"), q = e.layout || r.layout, J = e.labelAlign || r.labelAlign, N = de(!1), A = !e.labelCol && !r.labelCol, D = !e.wrapperCol && !r.wrapperCol, Q = (n, t = {}) => {
62
64
  if (N.current)
63
65
  return;
64
66
  const { errors: m, warnings: s } = t || {};
@@ -69,43 +71,43 @@ const xe = K.Row, G = K.Col, ve = ({
69
71
  const a = { ...o || {} };
70
72
  return s && s.length ? a[n] = s : delete a[n], a;
71
73
  });
72
- }, Q = h(e.noStyle) && e.noStyle.showErrorTip && c.updateFormItem ? c.updateFormItem : J;
73
- de(() => (N.current = !1, () => {
74
+ }, X = h(e.noStyle) && e.noStyle.showErrorTip && c.updateFormItem ? c.updateFormItem : Q;
75
+ ce(() => (N.current = !1, () => {
74
76
  N.current = !0, p(null), T(null);
75
77
  }), []);
76
- const X = {
78
+ const Y = {
77
79
  ...r,
78
- validateMessages: r.validateMessages && Ce(r.validateMessages, {
80
+ validateMessages: r.validateMessages && xe(r.validateMessages, {
79
81
  label: e.label
80
82
  }),
81
83
  prefixCls: l,
82
- updateFormItem: Q,
84
+ updateFormItem: X,
83
85
  disabled: "disabled" in e ? e.disabled : r.disabled
84
- }, { label: A, extra: D, className: Y, style: Z, validateStatus: v, hidden: ee, ...re } = e, te = C(`${l}-label-item`, {
85
- [`${l}-label-item-left`]: B === "left"
86
- }), L = u ? Object.values(u) : [], S = d ? Object.values(d).reduce((n, t) => n.concat(t), []) : [], w = U(() => {
86
+ }, { label: L, extra: M, className: Z, style: ee, validateStatus: v, hidden: re, ...te } = e, oe = C(`${l}-label-item`, {
87
+ [`${l}-label-item-left`]: J === "left"
88
+ }), j = u ? Object.values(u) : [], S = d ? Object.values(d).reduce((n, t) => n.concat(t), []) : [], w = _(() => {
87
89
  if (v)
88
90
  return v;
89
- if (L.length)
91
+ if (j.length)
90
92
  return k.error;
91
93
  if (S.length)
92
94
  return k.warning;
93
- }, [u, d, v]), M = U(() => !y(e.help) || S.length > 0, [e.help, d]), oe = C(
95
+ }, [u, d, v]), V = _(() => !x(e.help) || S.length > 0, [e.help, d]), le = C(
94
96
  `${l}-item`,
95
97
  {
96
- [`${l}-item-error`]: M || !v && w === k.error,
98
+ [`${l}-item-error`]: V || !v && w === k.error,
97
99
  [`${l}-item-status-${w}`]: w,
98
- [`${l}-item-has-help`]: M,
99
- [`${l}-item-hidden`]: ee,
100
+ [`${l}-item-has-help`]: V,
101
+ [`${l}-item-hidden`]: re,
100
102
  [`${l}-item-has-feedback`]: w && e.hasFeedback
101
103
  },
102
104
  `${l}-layout-${q}`,
103
- Y
104
- ), j = () => {
105
+ Z
106
+ ), O = () => {
105
107
  const { field: n, children: t } = e, m = "disabled" in e ? e.disabled : r.disabled;
106
- if (pe(t)) {
108
+ if (ue(t)) {
107
109
  const { key: s, ...o } = e ?? {};
108
- return /* @__PURE__ */ _(
110
+ return /* @__PURE__ */ z(
109
111
  $,
110
112
  {
111
113
  disabled: m,
@@ -118,34 +120,34 @@ const xe = K.Row, G = K.Col, ve = ({
118
120
  )
119
121
  );
120
122
  }
121
- if (ce(t)) {
122
- const s = V.Children.map(t, (o, a) => {
123
- const R = h(o) && o.key || a, ne = h(o) && "disabled" in o.props, se = !y(m) && !ne ? { key: R, disabled: m } : { key: R };
124
- return h(o) ? z(o, se) : o;
123
+ if (pe(t)) {
124
+ const s = U.Children.map(t, (o, a) => {
125
+ const R = h(o) && o.key || a, se = h(o) && "disabled" in o.props, ie = !x(m) && !se ? { key: R, disabled: m } : { key: R };
126
+ return h(o) ? H(o, ie) : o;
125
127
  });
126
128
  return /* @__PURE__ */ i($, { ...e, field: void 0, children: s });
127
129
  }
128
- if (V.Children.count(t) == 1) {
130
+ if (U.Children.count(t) == 1) {
129
131
  if (n) {
130
- const s = x?.getItemKey?.(n) || n;
131
- return /* @__PURE__ */ _($, { disabled: m, ...e, key: s, _key: s }, t);
132
+ const s = y?.getItemKey?.(n) || n;
133
+ return /* @__PURE__ */ z($, { disabled: m, ...e, key: s, _key: s }, t);
132
134
  }
133
135
  if (h(t)) {
134
136
  if (t.type?.isFormControl)
135
137
  return t;
136
- const o = !("disabled" in t.props) && !y(m) ? { disabled: m } : null;
137
- return /* @__PURE__ */ i($, { ...e, field: void 0, children: o ? z(t, o) : t });
138
+ const o = !("disabled" in t.props) && !x(m) ? { disabled: m } : null;
139
+ return /* @__PURE__ */ i($, { ...e, field: void 0, children: o ? H(t, o) : t });
138
140
  }
139
141
  }
140
142
  return t;
141
- }, le = H, P = {
143
+ }, ne = K, P = {
142
144
  ...r
143
145
  };
144
- return e.noStyle || (P.wrapperCol = void 0, P.labelCol = void 0), /* @__PURE__ */ i(W.Provider, { value: P, children: /* @__PURE__ */ i(le.Provider, { value: X, children: e.noStyle ? j() : /* @__PURE__ */ E(
145
- xe,
146
+ return e.noStyle || (P.wrapperCol = void 0, P.labelCol = void 0), /* @__PURE__ */ i(B.Provider, { value: P, children: /* @__PURE__ */ i(ne.Provider, { value: Y, children: e.noStyle ? O() : /* @__PURE__ */ E(
147
+ ve,
146
148
  {
147
149
  ref: b,
148
- ...be(re, [
150
+ ...ge(te, [
149
151
  "tooltip",
150
152
  "children",
151
153
  "prefixCls",
@@ -175,28 +177,29 @@ const xe = K.Row, G = K.Col, ve = ({
175
177
  "requiredSymbol",
176
178
  "isFormList"
177
179
  ]),
178
- className: oe,
180
+ className: le,
179
181
  div: q !== "horizontal",
180
- style: Z,
182
+ style: ee,
181
183
  children: [
182
- A ? /* @__PURE__ */ i(
184
+ L ? /* @__PURE__ */ i(
183
185
  G,
184
186
  {
185
187
  ...e.labelCol || r.labelCol,
186
188
  className: C(
187
- te,
189
+ oe,
188
190
  e.labelCol?.className,
189
191
  r.labelCol?.className,
190
192
  {
191
- [`${l}-label-item-flex`]: !e.labelCol && !r.labelCol
193
+ [`${l}-label-item-flex`]: A
192
194
  }
193
195
  ),
196
+ flex: A ? 0 : void 0,
194
197
  children: /* @__PURE__ */ i(
195
- ge,
198
+ he,
196
199
  {
197
200
  tooltip: e.tooltip,
198
201
  htmlFor: e.field && r?.getFormElementId?.(e.field),
199
- label: A,
202
+ label: L,
200
203
  prefix: g,
201
204
  requiredSymbol: "requiredSymbol" in e ? e.requiredSymbol : r.requiredSymbol,
202
205
  required: e.required,
@@ -210,29 +213,30 @@ const xe = K.Row, G = K.Col, ve = ({
210
213
  G,
211
214
  {
212
215
  className: C(`${l}-item-wrapper`, {
213
- [`${l}-item-wrapper-flex`]: !e.wrapperCol && !r.wrapperCol
216
+ [`${l}-item-wrapper-flex`]: D
214
217
  }),
218
+ flex: D ? 1 : void 0,
215
219
  ...e.wrapperCol || r.wrapperCol,
216
220
  children: [
217
- j(),
221
+ O(),
218
222
  /* @__PURE__ */ i(
219
- ve,
223
+ we,
220
224
  {
221
225
  prefixCls: l,
222
226
  help: e.help,
223
- errors: L,
227
+ errors: j,
224
228
  warnings: S
225
229
  }
226
230
  ),
227
- D && /* @__PURE__ */ i("div", { className: `${l}-extra`, children: D })
231
+ M && /* @__PURE__ */ i("div", { className: `${l}-extra`, children: M })
228
232
  ]
229
233
  }
230
234
  )
231
235
  ]
232
236
  }
233
237
  ) }) });
234
- }, $e = ae(Fe);
235
- $e.displayName = "FormItem";
238
+ }, Ie = me($e);
239
+ Ie.displayName = "FormItem";
236
240
  export {
237
- $e as default
241
+ Ie as default
238
242
  };
package/form/context.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { createContext as t } from "react";
2
- import "@unicom-cloud/utils/constant/ui";
3
2
  import { NOOP as e } from "../components/common/utils/constant.js";
4
- const i = t({
3
+ const o = t({
5
4
  layout: "horizontal",
6
5
  labelCol: { span: 5, offset: 0 },
7
6
  labelAlign: "right",
@@ -35,10 +34,10 @@ const i = t({
35
34
  innerGetStoreStatus: e
36
35
  })
37
36
  }
38
- }), s = t({}), a = t({}), n = t({});
37
+ }), i = t({}), s = t({}), a = t({});
39
38
  export {
40
- i as FormContext,
41
- s as FormItemContext,
42
- n as FormListContext,
43
- a as FormProviderContext
39
+ o as FormContext,
40
+ i as FormItemContext,
41
+ a as FormListContext,
42
+ s as FormProviderContext
44
43
  };
package/grid/Col-.js ADDED
@@ -0,0 +1,86 @@
1
+ import { jsx as E } from "react/jsx-runtime";
2
+ import F from "lodash/isNumber";
3
+ import H from "lodash/isPlainObject";
4
+ import { forwardRef as T, useContext as R, useMemo as q } from "react";
5
+ import "../config-provider/ConfigProvider.js";
6
+ import D from "../components/common/hooks/useMergeProps.js";
7
+ import I from "@unicom-cloud/utils/class-name";
8
+ import { RowContext as J } from "./context.js";
9
+ import K from "../config-provider/context.js";
10
+ const Q = {
11
+ span: 24
12
+ };
13
+ function S(i) {
14
+ return typeof i == "string" && /\d+[px|%|em|rem|]{1}/.test(i) ? `0 0 ${i}` : i;
15
+ }
16
+ function U(i, v) {
17
+ const { getPrefixCls: w, componentConfig: A, rtl: G } = R(K), L = D(
18
+ i,
19
+ Q,
20
+ A?.["Grid.Col"]
21
+ ), { gutter: p, div: l } = R(J), {
22
+ className: M,
23
+ style: N,
24
+ children: O,
25
+ span: V,
26
+ offset: d,
27
+ order: a,
28
+ pull: u,
29
+ push: c,
30
+ xs: m,
31
+ sm: g,
32
+ md: x,
33
+ lg: y,
34
+ xl: h,
35
+ xxl: P,
36
+ xxxl: b,
37
+ flex: f,
38
+ ...k
39
+ } = L;
40
+ function z(r, o) {
41
+ const j = { xs: m, sm: g, md: x, lg: y, xl: h, xxl: P, xxxl: b };
42
+ return Object.keys(j).forEach((s) => {
43
+ const t = j[s];
44
+ F(t) ? t >= 0 && (o[`${r}-${s}-${t}`] = !0) : H(t) && (o[`${r}-${s}-${t.span}`] = t.span, o[`${r}-${s}-offset-${t.offset}`] = t.offset, o[`${r}-${s}-order-${t.order}`] = t.order, o[`${r}-${s}-pull-${t.pull}`] = t.pull, o[`${r}-${s}-push-${t.push}`] = t.push);
45
+ }), o;
46
+ }
47
+ const n = w?.("col");
48
+ let $ = {
49
+ [`${n}`]: !l,
50
+ [`${n}-order-${a}`]: a,
51
+ [`${n}-${V}`]: !l && !m && !g && !x && !y && !h && !P && !b,
52
+ [`${n}-offset-${d}`]: d,
53
+ [`${n}-pull-${u}`]: u,
54
+ [`${n}-push-${c}`]: c,
55
+ [`${n}-rtl`]: G
56
+ };
57
+ $ = z(n, $);
58
+ const B = I(f ? n : $, M), e = {};
59
+ if (Array.isArray(p) && !l) {
60
+ const r = p[0] && p[0] / 2 || 0, o = p[1] && p[1] / 2 || 0;
61
+ r && (e.paddingLeft = r, e.paddingRight = r), o && (e.paddingTop = o, e.paddingBottom = o);
62
+ }
63
+ const C = q(
64
+ () => S(f) ? { flex: S(f) } : {},
65
+ [f]
66
+ );
67
+ return /* @__PURE__ */ E(
68
+ "div",
69
+ {
70
+ ref: v,
71
+ ...k,
72
+ style: {
73
+ ...N,
74
+ ...e,
75
+ ...C
76
+ },
77
+ className: B,
78
+ children: O
79
+ }
80
+ );
81
+ }
82
+ const W = T(U);
83
+ W.displayName = "Col";
84
+ export {
85
+ W as default
86
+ };
package/grid/Col.js CHANGED
@@ -1,86 +1,169 @@
1
- import { jsx as E } from "react/jsx-runtime";
2
- import F from "lodash/isNumber";
3
- import H from "lodash/isPlainObject";
4
- import { forwardRef as T, useContext as R, useMemo as q } from "react";
1
+ import { jsx as W } from "react/jsx-runtime";
2
+ import X from "lodash/isNil";
3
+ import M from "lodash/isNumber";
4
+ import B from "lodash/isPlainObject";
5
+ import { forwardRef as Y, useContext as F, useState as Z, useMemo as b, useEffect as _ } from "react";
5
6
  import "../config-provider/ConfigProvider.js";
6
- import D from "../components/common/hooks/useMergeProps.js";
7
- import I from "@unicom-cloud/utils/class-name";
8
- import { RowContext as J } from "./context.js";
9
- import K from "../config-provider/context.js";
10
- const Q = {
7
+ import ee from "../components/common/hooks/useMergeProps.js";
8
+ import te from "@unicom-cloud/utils/class-name";
9
+ import { responsiveArray as y, responsiveObserve as z } from "../utils/responsiveObserve.js";
10
+ import { RowContext as re } from "./context.js";
11
+ import se from "../config-provider/context.js";
12
+ const oe = {
11
13
  span: 24
14
+ // 默认占据24列
12
15
  };
13
- function S(i) {
14
- return typeof i == "string" && /\d+[px|%|em|rem|]{1}/.test(i) ? `0 0 ${i}` : i;
16
+ function ne(i) {
17
+ return typeof i == "string" && /\d+[px|%|em|rem|]{1}/.test(i) ? { flex: `0 0 ${i}` } : { flex: i };
15
18
  }
16
- function U(i, v) {
17
- const { getPrefixCls: w, componentConfig: A, rtl: C } = R(K), G = D(
19
+ const ie = (i, E) => {
20
+ const { getPrefixCls: G, componentConfig: I, rtl: d } = F(se), T = ee(
18
21
  i,
19
- Q,
20
- A?.["Grid.Col"]
21
- ), { gutter: p, div: l } = R(J), {
22
- className: L,
23
- style: M,
24
- children: N,
25
- span: O,
26
- offset: d,
27
- order: a,
28
- pull: u,
29
- push: c,
30
- xs: m,
31
- sm: g,
32
- md: x,
33
- lg: y,
34
- xl: h,
35
- xxl: P,
36
- xxxl: b,
37
- flex: f,
38
- ...V
39
- } = G;
40
- function k(r, o) {
41
- const j = { xs: m, sm: g, md: x, lg: y, xl: h, xxl: P, xxxl: b };
42
- return Object.keys(j).forEach((s) => {
43
- const t = j[s];
44
- F(t) ? t >= 0 && (o[`${r}-${s}-${t}`] = !0) : H(t) && (o[`${r}-${s}-${t.span}`] = t.span, o[`${r}-${s}-offset-${t.offset}`] = t.offset, o[`${r}-${s}-order-${t.order}`] = t.order, o[`${r}-${s}-pull-${t.pull}`] = t.pull, o[`${r}-${s}-push-${t.push}`] = t.push);
45
- }), o;
46
- }
47
- const n = w?.("col");
48
- let $ = {
49
- [`${n}`]: !l,
50
- [`${n}-order-${a}`]: a,
51
- [`${n}-${O}`]: !l && !m && !g && !x && !y && !h && !P && !b,
52
- [`${n}-offset-${d}`]: d,
53
- [`${n}-pull-${u}`]: u,
54
- [`${n}-push-${c}`]: c,
55
- [`${n}-rtl`]: C
56
- };
57
- $ = k(n, $);
58
- const z = I(f ? n : $, L), e = {};
59
- if (Array.isArray(p) && !l) {
60
- const r = p[0] && p[0] / 2 || 0, o = p[1] && p[1] / 2 || 0;
61
- r && (e.paddingLeft = r, e.paddingRight = r), o && (e.paddingTop = o, e.paddingBottom = o);
62
- }
63
- const B = q(
64
- () => S(f) ? { flex: S(f) } : {},
65
- [f]
66
- );
67
- return /* @__PURE__ */ E(
22
+ oe,
23
+ I?.["Grid.Col"]
24
+ ), { gutter: C, div: o } = F(re), {
25
+ className: V,
26
+ style: q,
27
+ children: D,
28
+ span: g = 24,
29
+ offset: c,
30
+ order: u,
31
+ pull: m,
32
+ push: $,
33
+ xs: v,
34
+ sm: P,
35
+ md: k,
36
+ lg: R,
37
+ xl: S,
38
+ xxl: w,
39
+ xxxl: O,
40
+ flex: j,
41
+ ...H
42
+ } = T, f = !X(j), s = G?.("col"), [A, J] = Z({
43
+ xs: !1,
44
+ sm: !1,
45
+ md: !1,
46
+ lg: !1,
47
+ xl: !1,
48
+ xxl: !1,
49
+ xxxl: !1
50
+ }), l = b(() => ({ xs: v, sm: P, md: k, lg: R, xl: S, xxl: w, xxxl: O }), [R, k, P, S, v, w, O]), K = b(() => {
51
+ if (f)
52
+ return;
53
+ const e = {
54
+ [`${s}`]: !o,
55
+ [`${s}-order-${u}`]: u,
56
+ [`${s}-${g}`]: !o && Object.values(l).every((r) => !r),
57
+ [`${s}-offset-${c}`]: c,
58
+ [`${s}-pull-${m}`]: m,
59
+ [`${s}-push-${$}`]: $,
60
+ [`${s}-rtl`]: d
61
+ };
62
+ for (const r in l) {
63
+ const t = l[r];
64
+ M(t) ? t >= 0 && (e[`${s}-${r}-${t}`] = !0) : B(t) && (e[`${s}-${r}-${t.span}`] = t.span, e[`${s}-${r}-offset-${t.offset}`] = t.offset, e[`${s}-${r}-order-${t.order}`] = t.order, e[`${s}-${r}-pull-${t.pull}`] = t.pull, e[`${s}-${r}-push-${t.push}`] = t.push);
65
+ }
66
+ return e;
67
+ }, [
68
+ f,
69
+ s,
70
+ o,
71
+ u,
72
+ g,
73
+ l,
74
+ c,
75
+ m,
76
+ $,
77
+ d
78
+ ]), x = (e) => `${100 / 24 * e}%`, Q = b(() => {
79
+ if (o || f)
80
+ return;
81
+ const e = {
82
+ span: g,
83
+ offset: c,
84
+ order: u,
85
+ pull: m,
86
+ push: $
87
+ }, r = y.find((a) => A[a]);
88
+ if (r) {
89
+ const a = y.indexOf(r);
90
+ for (let p = a; p < y.length; p++) {
91
+ const h = y[p], n = l[h];
92
+ if (n !== void 0) {
93
+ if (B(n)) {
94
+ Object.assign(e, n);
95
+ break;
96
+ }
97
+ if (M(n)) {
98
+ Object.assign(e, { span: n });
99
+ break;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ const t = {}, L = x(e.span);
105
+ t.width = L, t.flex = `0 0 ${L}`;
106
+ const N = (a, p, h) => {
107
+ if (d) {
108
+ const n = {
109
+ left: "right",
110
+ right: "left",
111
+ marginLeft: "marginRight",
112
+ marginRight: "marginLeft"
113
+ };
114
+ a[n[p]] = h;
115
+ } else
116
+ a[p] = h;
117
+ };
118
+ return e.offset && N(
119
+ t,
120
+ "marginLeft",
121
+ x(e.offset)
122
+ ), e.order && (t.order = e.order), e.pull && N(t, "right", x(e.pull)), e.push && N(t, "left", x(e.push)), t;
123
+ }, [
124
+ o,
125
+ f,
126
+ g,
127
+ c,
128
+ u,
129
+ m,
130
+ $,
131
+ A,
132
+ l,
133
+ d
134
+ ]), U = b(() => {
135
+ if (o)
136
+ return;
137
+ const e = {};
138
+ if (Array.isArray(C)) {
139
+ const [r, t] = C;
140
+ r && (e.paddingLeft = r / 2, e.paddingRight = r / 2), t && (e.paddingTop = t / 2, e.paddingBottom = t / 2);
141
+ }
142
+ return e;
143
+ }, [C, o]);
144
+ return _(() => {
145
+ const e = z.subscribe((r) => {
146
+ J(r);
147
+ });
148
+ return () => {
149
+ z.unsubscribe(e);
150
+ };
151
+ }, []), /* @__PURE__ */ W(
68
152
  "div",
69
153
  {
70
- ref: v,
71
- ...V,
154
+ ref: E,
155
+ ...H,
72
156
  style: {
73
- ...M,
74
- ...e,
75
- ...B
157
+ ...f ? ne(j) : Q,
158
+ ...U,
159
+ ...q
76
160
  },
77
- className: z,
78
- children: N
161
+ className: te(f ? s : K, V),
162
+ children: D
79
163
  }
80
164
  );
81
- }
82
- const W = T(U);
83
- W.displayName = "Col";
165
+ }, fe = Y(ie);
166
+ fe.displayName = "Col";
84
167
  export {
85
- W as default
168
+ fe as default
86
169
  };