@unicom-cloud/ui 0.8.107 → 0.8.108

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 (137) hide show
  1. package/ColorPicker.js +15 -14
  2. package/Constant.js +4 -0
  3. package/Copy.js +4 -3
  4. package/Countdown.js +25 -0
  5. package/Grid.js +8 -10
  6. package/LiquidFill.js +4 -3
  7. package/List.js +7 -6
  8. package/Marquee.js +4 -3
  9. package/PageHeader.js +3 -2
  10. package/QrCode.js +4 -3
  11. package/RowCol.js +8 -0
  12. package/Segmented.js +14 -4
  13. package/Statistic.js +5 -4
  14. package/Tour.js +4 -3
  15. package/Transfer.js +4 -2
  16. package/anchor/Link.js +1 -1
  17. package/avatar/Group.js +1 -1
  18. package/button/index.js +52 -51
  19. package/calendar/Lunar.js +21 -21
  20. package/cascader/base/node.js +22 -20
  21. package/cascader/base/store.js +10 -10
  22. package/cascader/util.js +29 -27
  23. package/color-picker/Mode.js +8 -7
  24. package/color-picker/hooks/useColorPicker.js +56 -55
  25. package/color-picker/index.js +54 -53
  26. package/color-picker/utils.js +58 -57
  27. package/components/common/empty/index.js +2 -2
  28. package/components/common/flex/index.js +64 -55
  29. package/components/common/flex/interface.js +6 -6
  30. package/components/common/hooks/useInterval.js +6 -6
  31. package/components/common/space/index.js +53 -53
  32. package/components/common/utils/dayjs.js +75 -62
  33. package/components/common/utils/toArray.js +7 -5
  34. package/constant/index.js +4 -0
  35. package/copy/index.js +2 -1
  36. package/countdown/index.js +113 -0
  37. package/countdown/interface.js +1 -0
  38. package/countdown/util.js +29 -0
  39. package/descriptions/index.js +26 -26
  40. package/dropdown/Button.js +1 -1
  41. package/flex/index.js +30 -29
  42. package/form/FormItem.js +126 -122
  43. package/grid/Grid.js +40 -41
  44. package/grid/Item.js +37 -37
  45. package/grid/context.js +2 -3
  46. package/grid/index.js +6 -8
  47. package/hooks/useResponsiveState.js +54 -0
  48. package/index.js +614 -610
  49. package/input/InputElement.js +25 -24
  50. package/layout/Sider.js +1 -1
  51. package/liquid-fill/index.js +4 -3
  52. package/list/Item.js +21 -21
  53. package/list/index.js +53 -52
  54. package/marquee/index.js +20 -19
  55. package/marquee-/index.js +4 -3
  56. package/mentions/util.js +9 -8
  57. package/package.json +1 -1
  58. package/page-header/index.js +57 -56
  59. package/pagination/Pagination.js +89 -92
  60. package/qr-code/index.js +4 -3
  61. package/radio/Group.js +1 -1
  62. package/row-col/Col-.js +88 -0
  63. package/row-col/Col.js +159 -0
  64. package/row-col/Row.js +73 -0
  65. package/row-col/context.js +5 -0
  66. package/row-col/index.js +11 -0
  67. package/row-col/interface.js +1 -0
  68. package/segmented/index.js +257 -206
  69. package/select/Select.js +191 -191
  70. package/select/util.js +50 -50
  71. package/space/index.js +15 -13
  72. package/statistic/index.js +56 -55
  73. package/statistic/interface.js +4 -1
  74. package/style.css +1 -1
  75. package/table/hook/useColumns.js +27 -26
  76. package/table/hook/useStickyClassNames.js +9 -8
  77. package/table/hook/useThResizable.js +4 -3
  78. package/table/th-resizable/index.js +11 -10
  79. package/table/thead/index.js +18 -16
  80. package/timeline/Item.js +1 -1
  81. package/tour/index.js +4 -3
  82. package/transfer/index.js +93 -91
  83. package/trigger/index.js +66 -66
  84. package/types/common/flex/index.d.ts +3 -9
  85. package/types/common/flex/interface.d.ts +15 -4
  86. package/types/common/space/index.d.ts +3 -5
  87. package/types/common/space/interface.d.ts +2 -0
  88. package/types/common/utils/dayjs.d.ts +3 -1
  89. package/types/pc/button/interface.d.ts +2 -2
  90. package/types/pc/config-provider/interface.d.ts +16 -11
  91. package/types/pc/constant/index.d.ts +1 -0
  92. package/types/pc/countdown/interface.d.ts +65 -0
  93. package/types/pc/countdown/util.d.ts +7 -0
  94. package/types/pc/flex/index.d.ts +8 -6
  95. package/types/pc/flex/interface.d.ts +3 -10
  96. package/types/pc/form/FormItem.d.ts +1 -1
  97. package/types/pc/form/interface.d.ts +1 -1
  98. package/types/pc/grid/Grid.d.ts +1 -2
  99. package/types/pc/grid/Item.d.ts +1 -2
  100. package/types/pc/grid/context.d.ts +0 -5
  101. package/types/pc/grid/index.d.ts +4 -6
  102. package/types/pc/grid/interface.d.ts +7 -125
  103. package/types/pc/hooks/useResponsiveState.d.ts +3 -0
  104. package/types/pc/index.d.ts +7 -3
  105. package/types/pc/list/interface.d.ts +2 -1
  106. package/types/pc/pagination/PageOption.d.ts +0 -1
  107. package/types/pc/pagination/interface.d.ts +5 -6
  108. package/types/pc/{grid → row-col}/Col-.d.ts +1 -1
  109. package/types/pc/{grid → row-col}/Col.d.ts +1 -2
  110. package/types/pc/{grid → row-col}/Row.d.ts +1 -2
  111. package/types/pc/row-col/context.d.ts +6 -0
  112. package/types/pc/row-col/index.d.ts +7 -0
  113. package/types/pc/row-col/interface.d.ts +112 -0
  114. package/types/pc/segmented/index.d.ts +3 -7
  115. package/types/pc/segmented/interface.d.ts +38 -5
  116. package/types/pc/space/index.d.ts +5 -7
  117. package/types/pc/space/interface.d.ts +3 -10
  118. package/types/pc/statistic/index.d.ts +1 -1
  119. package/types/pc/statistic/interface.d.ts +1 -49
  120. package/types/pc/utils/names.d.ts +121 -113
  121. package/types/pc/utils/responsiveObserve.d.ts +8 -8
  122. package/typography/Ellipsis.js +5 -4
  123. package/typography/Operations.js +4 -3
  124. package/utils/dayjs.js +13 -11
  125. package/utils/index.js +244 -242
  126. package/utils/names.js +15 -10
  127. package/utils/responsiveObserve.js +43 -36
  128. package/version/index.js +1 -1
  129. package/grid/Col-.js +0 -86
  130. package/grid/Col.js +0 -169
  131. package/grid/Row.js +0 -96
  132. package/grid/hook/useResponsiveState.js +0 -35
  133. package/statistic/Countdown.js +0 -56
  134. package/statistic/util.js +0 -33
  135. package/types/pc/grid/hook/useResponsiveState.d.ts +0 -2
  136. package/types/pc/statistic/util.d.ts +0 -1
  137. /package/types/pc/{statistic/Countdown.d.ts → countdown/index.d.ts} +0 -0
package/form/FormItem.js CHANGED
@@ -1,43 +1,42 @@
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
- import h from "lodash/isPlainObject";
1
+ import { jsx as i, jsxs as q, Fragment as ie } from "react/jsx-runtime";
2
+ import W, { forwardRef as ae, useContext as F, useState as _, useRef as me, useEffect as de, useMemo as z, createElement as H, cloneElement as K } from "react";
3
+ import ce from "lodash/isArray";
4
+ import pe from "lodash/isFunction";
5
+ import C from "lodash/isPlainObject";
6
6
  import x from "lodash/isUndefined";
7
7
  import "../config-provider/ConfigProvider.js";
8
- import "../grid/index.js";
9
- import fe from "../components/common/hooks/useMergeProps.js";
8
+ import ue from "../components/common/hooks/useMergeProps.js";
9
+ import fe from "../row-col/index.js";
10
10
  import { PqbCSSTransition as be } from "../components/common/utils/PqbCSSTransition.js";
11
- import C from "@unicom-cloud/utils/class-name";
12
- import { omit as ge } from "../components/common/utils/omit.js";
13
- import $ from "./Control.js";
14
- import he from "./FormLabel.js";
15
- import { FormItemContext as K, FormListContext as Ce, FormContext as B } from "./context.js";
16
- import { VALIDATE_STATUS as k } from "./interface.js";
11
+ import S from "@unicom-cloud/utils/class-name";
12
+ import { omit as he } from "../components/common/utils/omit.js";
13
+ import I from "./Control.js";
14
+ import ge from "./FormLabel.js";
15
+ import { FormItemContext as B, FormListContext as Ce, FormContext as G } from "./context.js";
16
+ import { VALIDATE_STATUS as T } from "./interface.js";
17
17
  import { formatValidateMsg as xe } from "./util.js";
18
18
  import ye from "../config-provider/context.js";
19
- import ve from "../grid/Row.js";
20
- import G from "../grid/Col.js";
21
- const we = ({
22
- prefixCls: f,
23
- help: b,
19
+ import J from "../row-col/Col.js";
20
+ const ve = ({
21
+ prefixCls: b,
22
+ help: h,
24
23
  errors: e,
25
- warnings: I
24
+ warnings: N
26
25
  }) => {
27
- const g = e.map((p, d) => {
28
- if (p)
29
- return /* @__PURE__ */ i("div", { role: "alert", children: p.message }, d);
30
- }), c = [];
31
- I.map((p, d) => {
32
- c.push(
33
- /* @__PURE__ */ i("div", { role: "alert", className: `${f}-message-help-warning`, children: p }, d)
26
+ const g = e.map((u, d) => {
27
+ if (u)
28
+ return /* @__PURE__ */ i("div", { role: "alert", children: u.message }, d);
29
+ }), p = [];
30
+ N.map((u, d) => {
31
+ p.push(
32
+ /* @__PURE__ */ i("div", { role: "alert", className: `${b}-message-help-warning`, children: u }, d)
34
33
  );
35
34
  });
36
- const y = !x(b) || !!c.length, u = y || !!g.length;
37
- return u && /* @__PURE__ */ i(
35
+ const y = !x(h) || !!p.length, f = y || !!g.length;
36
+ return f && /* @__PURE__ */ i(
38
37
  be,
39
38
  {
40
- in: u,
39
+ in: f,
41
40
  appear: !0,
42
41
  classNames: "formblink",
43
42
  timeout: 300,
@@ -45,109 +44,96 @@ const we = ({
45
44
  children: /* @__PURE__ */ i(
46
45
  "div",
47
46
  {
48
- className: C(`${f}-message`, {
49
- [`${f}-message-help`]: y
47
+ className: S(`${b}-message`, {
48
+ [`${b}-message-help`]: y
50
49
  }),
51
- children: x(b) ? /* @__PURE__ */ E(ae, { children: [
50
+ children: x(h) ? /* @__PURE__ */ q(ie, { children: [
52
51
  g.length > 0 && g,
53
- c.length > 0 && c
54
- ] }) : b
52
+ p.length > 0 && p
53
+ ] }) : h
55
54
  }
56
55
  )
57
56
  }
58
57
  );
59
- }, Fe = {
58
+ }, we = {
60
59
  trigger: "onChange",
61
60
  triggerPropName: "value"
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 = {}) => {
64
- if (N.current)
61
+ }, $e = (b, h) => {
62
+ const e = ue(b, we), { getPrefixCls: N, prefixCls: g } = F(ye), p = F(B), y = F(Ce), [f, u] = _(null), [d, A] = _(null), r = F(G), c = r.prefixCls || N?.("form"), l = `${c}-item`, D = e.layout || r.layout, Q = e.labelAlign || r.labelAlign, P = me(!1), L = !e.labelCol && !r.labelCol, M = !e.wrapperCol && !r.wrapperCol, X = (n, o = {}) => {
63
+ if (P.current)
65
64
  return;
66
- const { errors: m, warnings: s } = t || {};
67
- p((o) => {
68
- const a = { ...o || {} };
65
+ const { errors: m, warnings: s } = o || {};
66
+ u((t) => {
67
+ const a = { ...t || {} };
69
68
  return m ? a[n] = m : delete a[n], a;
70
- }), T((o) => {
71
- const a = { ...o || {} };
69
+ }), A((t) => {
70
+ const a = { ...t || {} };
72
71
  return s && s.length ? a[n] = s : delete a[n], a;
73
72
  });
74
- }, X = h(e.noStyle) && e.noStyle.showErrorTip && c.updateFormItem ? c.updateFormItem : Q;
75
- ce(() => (N.current = !1, () => {
76
- N.current = !0, p(null), T(null);
73
+ }, Y = C(e.noStyle) && e.noStyle.showErrorTip && p.updateFormItem ? p.updateFormItem : X;
74
+ de(() => (P.current = !1, () => {
75
+ P.current = !0, u(null), A(null);
77
76
  }), []);
78
- const Y = {
77
+ const Z = {
79
78
  ...r,
80
79
  validateMessages: r.validateMessages && xe(r.validateMessages, {
81
80
  label: e.label
82
81
  }),
83
- prefixCls: l,
84
- updateFormItem: X,
82
+ prefixCls: c,
83
+ updateFormItem: Y,
85
84
  disabled: "disabled" in e ? e.disabled : r.disabled
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 = _(() => {
89
- if (v)
90
- return v;
91
- if (j.length)
92
- return k.error;
93
- if (S.length)
94
- return k.warning;
95
- }, [u, d, v]), V = _(() => !x(e.help) || S.length > 0, [e.help, d]), le = C(
96
- `${l}-item`,
97
- {
98
- [`${l}-item-error`]: V || !v && w === k.error,
99
- [`${l}-item-status-${w}`]: w,
100
- [`${l}-item-has-help`]: V,
101
- [`${l}-item-hidden`]: re,
102
- [`${l}-item-has-feedback`]: w && e.hasFeedback
103
- },
104
- `${l}-layout-${q}`,
105
- Z
106
- ), O = () => {
107
- const { field: n, children: t } = e, m = "disabled" in e ? e.disabled : r.disabled;
108
- if (ue(t)) {
109
- const { key: s, ...o } = e ?? {};
110
- return /* @__PURE__ */ z(
111
- $,
85
+ }, { label: v, extra: j, className: ee, style: re, validateStatus: w, hidden: oe, ...te } = e, V = f ? Object.values(f) : [], k = d ? Object.values(d).reduce((n, o) => n.concat(o), []) : [], $ = z(() => {
86
+ if (w)
87
+ return w;
88
+ if (V.length)
89
+ return T.error;
90
+ if (k.length)
91
+ return T.warning;
92
+ }, [f, d, w]), O = z(() => !x(e.help) || k.length > 0, [e.help, d]), R = () => {
93
+ const { field: n, children: o } = e, m = "disabled" in e ? e.disabled : r.disabled;
94
+ if (pe(o)) {
95
+ const { key: s, ...t } = e ?? {};
96
+ return /* @__PURE__ */ H(
97
+ I,
112
98
  {
113
99
  disabled: m,
114
- ...o,
100
+ ...t,
115
101
  key: n || s,
116
102
  _key: n || s
117
103
  },
118
- (...a) => t(
104
+ (...a) => o(
119
105
  ...a
120
106
  )
121
107
  );
122
108
  }
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;
109
+ if (ce(o)) {
110
+ const s = W.Children.map(o, (t, a) => {
111
+ const U = C(t) && t.key || a, ne = C(t) && "disabled" in t.props, se = !x(m) && !ne ? { key: U, disabled: m } : { key: U };
112
+ return C(t) ? K(t, se) : t;
127
113
  });
128
- return /* @__PURE__ */ i($, { ...e, field: void 0, children: s });
114
+ return /* @__PURE__ */ i(I, { ...e, field: void 0, children: s });
129
115
  }
130
- if (U.Children.count(t) == 1) {
116
+ if (W.Children.count(o) == 1) {
131
117
  if (n) {
132
118
  const s = y?.getItemKey?.(n) || n;
133
- return /* @__PURE__ */ z($, { disabled: m, ...e, key: s, _key: s }, t);
119
+ return /* @__PURE__ */ H(I, { disabled: m, ...e, key: s, _key: s }, o);
134
120
  }
135
- if (h(t)) {
136
- if (t.type?.isFormControl)
137
- return 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 });
121
+ if (C(o)) {
122
+ if (o.type?.isFormControl)
123
+ return o;
124
+ const t = !("disabled" in o.props) && !x(m) ? { disabled: m } : null;
125
+ return /* @__PURE__ */ i(I, { ...e, field: void 0, children: t ? K(o, t) : o });
140
126
  }
141
127
  }
142
- return t;
143
- }, ne = K, P = {
128
+ return o;
129
+ }, le = B, E = {
144
130
  ...r
145
131
  };
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,
132
+ return e.noStyle || (E.wrapperCol = void 0, E.labelCol = void 0), /* @__PURE__ */ i(G.Provider, { value: E, children: /* @__PURE__ */ i(le.Provider, { value: Z, children: e.noStyle ? R() : /* @__PURE__ */ q(
133
+ fe,
148
134
  {
149
- ref: b,
150
- ...ge(te, [
135
+ ref: h,
136
+ ...he(te, [
151
137
  "tooltip",
152
138
  "children",
153
139
  "prefixCls",
@@ -177,29 +163,43 @@ const we = ({
177
163
  "requiredSymbol",
178
164
  "isFormList"
179
165
  ]),
180
- className: le,
181
- div: q !== "horizontal",
182
- style: ee,
166
+ className: S(
167
+ l,
168
+ {
169
+ [`${l}-error`]: O || !w && $ === T.error,
170
+ [`${l}-status-${$}`]: $,
171
+ [`${l}-has-help`]: O,
172
+ [`${l}-hidden`]: oe,
173
+ [`${l}-has-feedback`]: $ && e.hasFeedback
174
+ },
175
+ `${c}-layout-${D}`,
176
+ v ? `${l}-has-label` : `${l}-no-label`,
177
+ ee
178
+ ),
179
+ div: D !== "horizontal",
180
+ style: re,
183
181
  children: [
184
- L ? /* @__PURE__ */ i(
185
- G,
182
+ !!v && /* @__PURE__ */ i(
183
+ J,
186
184
  {
187
- className: C(
188
- oe,
185
+ className: S(
186
+ `${l}-label`,
187
+ `${c}-label-item`,
189
188
  e.labelCol?.className,
190
189
  r.labelCol?.className,
191
190
  {
192
- [`${l}-label-item-flex`]: A
191
+ [`${c}-label-item-left`]: Q === "left",
192
+ [`${c}-label-item-flex`]: L
193
193
  }
194
194
  ),
195
- flex: A ? 0 : void 0,
195
+ flex: L ? 0 : void 0,
196
196
  ...e.labelCol || r.labelCol,
197
197
  children: /* @__PURE__ */ i(
198
- he,
198
+ ge,
199
199
  {
200
200
  tooltip: e.tooltip,
201
201
  htmlFor: e.field && r?.getFormElementId?.(e.field),
202
- label: L,
202
+ label: v,
203
203
  prefix: g,
204
204
  requiredSymbol: "requiredSymbol" in e ? e.requiredSymbol : r.requiredSymbol,
205
205
  required: e.required,
@@ -208,35 +208,39 @@ const we = ({
208
208
  }
209
209
  )
210
210
  }
211
- ) : null,
212
- /* @__PURE__ */ E(
213
- G,
211
+ ),
212
+ /* @__PURE__ */ q(
213
+ J,
214
214
  {
215
- className: C(`${l}-item-wrapper`, {
216
- [`${l}-item-wrapper-flex`]: D
217
- }),
218
- flex: D ? 1 : void 0,
215
+ className: S(
216
+ `${l}-wrapper`,
217
+ {
218
+ [`${l}-wrapper-flex`]: M
219
+ },
220
+ v ? `${l}-wrapper-has-label` : `${l}-wrapper-no-label`
221
+ ),
222
+ flex: M ? 1 : void 0,
219
223
  ...e.wrapperCol || r.wrapperCol,
220
224
  children: [
221
- O(),
225
+ R(),
222
226
  /* @__PURE__ */ i(
223
- we,
227
+ ve,
224
228
  {
225
- prefixCls: l,
229
+ prefixCls: c,
226
230
  help: e.help,
227
- errors: j,
228
- warnings: S
231
+ errors: V,
232
+ warnings: k
229
233
  }
230
234
  ),
231
- M && /* @__PURE__ */ i("div", { className: `${l}-extra`, children: M })
235
+ j && /* @__PURE__ */ i("div", { className: `${c}-extra`, children: j })
232
236
  ]
233
237
  }
234
238
  )
235
239
  ]
236
240
  }
237
241
  ) }) });
238
- }, Ie = me($e);
239
- Ie.displayName = "FormItem";
242
+ }, Fe = ae($e);
243
+ Fe.displayName = "FormItem";
240
244
  export {
241
- Ie as default
245
+ Fe as default
242
246
  };
package/grid/Grid.js CHANGED
@@ -1,74 +1,73 @@
1
1
  import { jsx as x } from "react/jsx-runtime";
2
- import _ from "lodash/isArray";
3
- import c from "lodash/isNil";
4
- import { forwardRef as A, useContext as M } from "react";
2
+ import O from "lodash/isArray";
3
+ import f from "lodash/isNil";
4
+ import { forwardRef as _, useContext as A } from "react";
5
5
  import "../config-provider/ConfigProvider.js";
6
- import O from "../components/common/hooks/useMergeProps.js";
7
- import k from "@unicom-cloud/utils/class-name";
6
+ import { COLS as g } from "../constant/index.js";
7
+ import L from "../components/common/hooks/useMergeProps.js";
8
+ import { useResponsiveState as c } from "../hooks/useResponsiveState.js";
9
+ import M from "@unicom-cloud/utils/class-name";
8
10
  import "../components/common/utils/is.js";
9
- import { GridContext as q } from "./context.js";
10
- import { useResponsiveState as f } from "./hook/useResponsiveState.js";
11
- import z from "../config-provider/context.js";
12
- import { isNumber as G, isPlainObject as B } from "@unicom-cloud/utils/is";
11
+ import { GridContext as k } from "./context.js";
12
+ import q from "../config-provider/context.js";
13
+ import { isString as z, isNumber as d, isPlainObject as B } from "@unicom-cloud/utils/is";
13
14
  const D = {
14
- cols: 24,
15
+ cols: g,
15
16
  gap: 0
16
17
  };
17
- function E(C, u) {
18
- const { getPrefixCls: g, componentConfig: N, rtl: $ } = M(z), y = O(
19
- C,
18
+ function E(u, C) {
19
+ const { getPrefixCls: N, componentConfig: P, rtl: y } = A(q), G = N?.("grid"), $ = L(
20
+ u,
20
21
  D,
21
- N?.Grid
22
+ P?.Grid
22
23
  ), {
23
- children: w,
24
- className: P,
25
- style: v,
24
+ style: w,
25
+ className: v,
26
+ children: S,
26
27
  cols: R,
27
- gap: e,
28
+ gap: r,
28
29
  colGap: l,
29
30
  rowGap: m
30
- } = y;
31
- let t = m, s = l;
32
- const b = c(e), h = c(m), j = c(l);
33
- b || (_(e) ? (t = e[0], s = e[1] ?? e[0]) : t = s = e), h || (t = m), j || (s = l);
34
- const o = f(R, 24), a = f(t, 0), n = f(s, 0), r = {};
35
- if (a && (r.rowGap = a), n && (r.columnGap = n), G(o))
36
- r.gridTemplateColumns = `repeat(${o}, minmax(0px, 1fr))`;
37
- else if (o && B(o) && "type" in o) {
38
- const T = o.type;
39
- let i = o.max ?? "1fr";
40
- G(i) && (i = `${i}px`);
31
+ } = $;
32
+ let i = m, t = l;
33
+ const T = f(r), b = f(m), h = f(l);
34
+ T || (O(r) ? (i = r[0], t = r[1] ?? r[0]) : i = t = r), b || (i = m), h || (t = l);
35
+ const o = c(R, g), a = c(i, 0), n = c(t, 0), e = {};
36
+ if (a && (e.rowGap = a), n && (e.columnGap = n), z(o))
37
+ e.gridTemplateColumns = o;
38
+ else if (d(o))
39
+ e.gridTemplateColumns = `repeat(${o}, minmax(0px, 1fr))`;
40
+ else if (B(o) && "type" in o) {
41
+ const j = o.type;
42
+ let s = o.max ?? "1fr";
43
+ d(s) && (s = `${s}px`);
41
44
  let p = o.min ?? "0px";
42
- G(p) && (p = `${p}px`), r.gridTemplateColumns = `repeat(${T}, minmax(${p}, ${i}))`;
45
+ d(p) && (p = `${p}px`), e.gridTemplateColumns = `repeat(${j}, minmax(${p}, ${s}))`;
43
46
  }
44
- const d = g?.("grid"), S = {
45
- [`${d}`]: !0,
46
- [`${d}-rtl`]: $
47
- };
48
47
  return /* @__PURE__ */ x(
49
48
  "div",
50
49
  {
51
- ref: u,
52
- className: k(S, P),
50
+ ref: C,
51
+ className: M(G, y && `${G}-rtl`, v),
53
52
  style: {
54
- ...r,
55
- ...v
53
+ ...e,
54
+ ...w
56
55
  },
57
56
  children: /* @__PURE__ */ x(
58
- q.Provider,
57
+ k.Provider,
59
58
  {
60
59
  value: {
61
60
  cols: o,
62
61
  rowGap: a,
63
62
  colGap: n
64
63
  },
65
- children: w
64
+ children: S
66
65
  }
67
66
  )
68
67
  }
69
68
  );
70
69
  }
71
- const F = A(E);
70
+ const F = _(E);
72
71
  F.displayName = "Grid";
73
72
  export {
74
73
  F as default
package/grid/Item.js CHANGED
@@ -1,55 +1,55 @@
1
- import { jsx as R } from "react/jsx-runtime";
2
- import { forwardRef as w, useContext as p } from "react";
1
+ import { jsx as S } from "react/jsx-runtime";
2
+ import { forwardRef as v, useContext as i } from "react";
3
3
  import "../config-provider/ConfigProvider.js";
4
- import O from "../components/common/hooks/useMergeProps.js";
4
+ import R from "../components/common/hooks/useMergeProps.js";
5
+ import { useResponsiveState as a } from "../hooks/useResponsiveState.js";
5
6
  import b from "@unicom-cloud/utils/class-name";
6
7
  import "../components/common/utils/is.js";
7
8
  import { GridContext as h } from "./context.js";
8
- import { useResponsiveState as a } from "./hook/useResponsiveState.js";
9
9
  import { resolveItemData as j } from "./util.js";
10
- import D from "../config-provider/context.js";
11
- import { isNumber as e } from "@unicom-cloud/utils/is";
12
- const E = {
13
- offset: 0,
14
- span: 1
15
- };
16
- function F(f, c) {
17
- const { getPrefixCls: l, componentConfig: d, rtl: C } = p(D), g = O(
18
- f,
19
- E,
20
- d?.["Grid.Item"]
10
+ import w from "../config-provider/context.js";
11
+ import { isNumber as t } from "@unicom-cloud/utils/is";
12
+ function D(c, l) {
13
+ const { getPrefixCls: d, componentConfig: u, rtl: C } = i(w), n = d?.("grid-item"), x = R(
14
+ c,
15
+ {
16
+ offset: 0,
17
+ span: 1
18
+ },
19
+ u?.GridItem
21
20
  ), {
22
- children: u,
23
- className: x,
24
21
  style: $,
25
- offset: N,
26
- span: n
27
- } = g, G = p(h), { colGap: r, cols: m } = G, I = a(N, 0), S = a(n, 1), { span: t, offset: o } = e(m) ? j(m, {
28
- span: S,
29
- offset: I
30
- }) : {}, i = l?.("grid-item"), y = {
31
- [`${i}`]: !0,
32
- [`${i}-rtl`]: C
33
- }, v = b(y, x), s = {};
34
- if (e(t) && (s.gridColumnStart = `span ${t}`, e(r) && e(o) && o > 0)) {
35
- const P = `(100% - ${r * (t - 1)}px) / ${t}`;
36
- s.marginLeft = `calc(${P} * ${o} + ${r * o}px)`;
22
+ className: g,
23
+ children: N,
24
+ offset: P,
25
+ span: m,
26
+ order: p
27
+ } = x, { colGap: e, cols: f } = i(h), G = a(P, 0), y = a(m, 1), { span: s, offset: r } = t(f) ? j(f, {
28
+ span: y,
29
+ offset: G
30
+ }) : {}, o = {};
31
+ if (t(p) && (o.order = p), t(s)) {
32
+ if (o.gridColumnStart = `span ${s}`, t(e) && t(r) && r > 0) {
33
+ const I = `(100% - ${e * (s - 1)}px) / ${s}`;
34
+ o.marginLeft = `calc(${I} * ${r} + ${e * r}px)`;
35
+ }
36
+ o.gridColumnEnd = `span ${m}`;
37
37
  }
38
- return s.gridColumnEnd = `span ${n}`, /* @__PURE__ */ R(
38
+ return /* @__PURE__ */ S(
39
39
  "div",
40
40
  {
41
- ref: c,
42
- className: v,
41
+ ref: l,
43
42
  style: {
44
- ...s,
43
+ ...o,
45
44
  ...$
46
45
  },
47
- children: u
46
+ className: b(n, C && `${n}-rtl`, g),
47
+ children: N
48
48
  }
49
49
  );
50
50
  }
51
- const L = w(F), M = L;
52
- M.displayName = "Grid.Item";
51
+ const E = v(D);
52
+ E.displayName = "Grid.Item";
53
53
  export {
54
- M as default
54
+ E as default
55
55
  };
package/grid/context.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { createContext as t } from "react";
2
- const e = t({}), n = t({});
2
+ const e = t({});
3
3
  export {
4
- n as GridContext,
5
- e as RowContext
4
+ e as GridContext
6
5
  };
package/grid/index.js CHANGED
@@ -1,16 +1,14 @@
1
- import r from "./Col.js";
1
+ import r from "../row-col/index.js";
2
2
  import m from "./Grid.js";
3
3
  import i from "./Item.js";
4
- import t from "./Row.js";
4
+ import t from "../row-col/Col.js";
5
5
  const o = m;
6
- o.Col = r;
7
- o.Row = t;
8
6
  o.Item = i;
7
+ o.Row = r;
8
+ o.Col = t;
9
9
  export {
10
- r as Col,
11
- r as GridCol,
10
+ t as GridCol,
12
11
  i as GridItem,
13
- t as GridRow,
14
- t as Row,
12
+ r as GridRow,
15
13
  o as default
16
14
  };
@@ -0,0 +1,54 @@
1
+ import { useRef as p, useState as m, useEffect as b, useMemo as R } from "react";
2
+ import "../components/common/utils/is.js";
3
+ import { responsiveArray as c, responsiveObserve as u } from "../utils/responsiveObserve.js";
4
+ import { isPlainObject as k, isNil as f } from "@unicom-cloud/utils/is";
5
+ function v(r) {
6
+ return k(r) ? c.some((s, o, t) => {
7
+ const n = r[s];
8
+ return !f(n);
9
+ }) : !1;
10
+ }
11
+ function O(r = !0) {
12
+ const e = p(), [s, o] = m(() => {
13
+ let t = {
14
+ // xs: true,
15
+ // sm: true,
16
+ // md: true,
17
+ // lg: true,
18
+ // xl: true,
19
+ // xxl: true,
20
+ // xxxl: true,
21
+ };
22
+ return r && (t = Object.fromEntries(
23
+ c.map((n, i, S) => [n, !0])
24
+ )), t;
25
+ });
26
+ return b(() => {
27
+ if (r)
28
+ return e.current = u.subscribe((t) => {
29
+ o(t);
30
+ }), () => {
31
+ e.current && u.unsubscribe(e.current);
32
+ };
33
+ }, []), s;
34
+ }
35
+ function A(r, e = 0) {
36
+ const s = v(r), o = O(s);
37
+ return R(() => {
38
+ if (f(r))
39
+ return e;
40
+ if (!s) return r;
41
+ let n = e;
42
+ for (const i of c)
43
+ if (o[i] && r[i] !== void 0) {
44
+ n = r[i];
45
+ break;
46
+ }
47
+ return n;
48
+ }, [e, s, o, r]);
49
+ }
50
+ export {
51
+ v as isResponsiveValue,
52
+ O as useResponsive,
53
+ A as useResponsiveState
54
+ };