@rockshin/tao-ui 0.0.47 → 0.0.49

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 (144) hide show
  1. package/dist/components/affix/affix.js +20 -16
  2. package/dist/components/alert/alert.js +114 -99
  3. package/dist/components/app/app-modals.js +134 -96
  4. package/dist/components/app/app-notices.js +39 -23
  5. package/dist/components/auto-complete/auto-complete.js +21 -7
  6. package/dist/components/avatar/avatar.js +31 -11
  7. package/dist/components/badge/badge.css +1 -1
  8. package/dist/components/badge/badge.js +72 -257
  9. package/dist/components/border-beam/border-beam.js +21 -17
  10. package/dist/components/breadcrumb/breadcrumb.js +178 -159
  11. package/dist/components/button/button.js +61 -53
  12. package/dist/components/calendar/calendar.js +6 -4
  13. package/dist/components/card/card.js +24 -8
  14. package/dist/components/carousel/carousel.d.ts +1 -1
  15. package/dist/components/carousel/carousel.js +105 -68
  16. package/dist/components/cascader/cascader.js +54 -19
  17. package/dist/components/checkbox/checkbox.css +13 -2
  18. package/dist/components/checkbox/checkbox.d.ts +2 -0
  19. package/dist/components/checkbox/checkbox.js +320 -229
  20. package/dist/components/collapse/collapse-panels.d.ts +1 -1
  21. package/dist/components/collapse/collapse-panels.js +122 -113
  22. package/dist/components/collapse/collapse.js +98 -63
  23. package/dist/components/color-picker/color-picker.js +539 -441
  24. package/dist/components/color-picker/color.js +1 -1
  25. package/dist/components/context-menu/context-menu.d.ts +1 -1
  26. package/dist/components/context-menu/context-menu.js +108 -68
  27. package/dist/components/date-picker/calendar/calendar-grid.js +42 -39
  28. package/dist/components/date-picker/calendar/month-grid.d.ts +8 -1
  29. package/dist/components/date-picker/calendar/month-grid.js +79 -37
  30. package/dist/components/date-picker/calendar/time-panel.d.ts +2 -1
  31. package/dist/components/date-picker/calendar/time-panel.js +94 -89
  32. package/dist/components/date-picker/calendar/year-grid.d.ts +8 -1
  33. package/dist/components/date-picker/calendar/year-grid.js +66 -35
  34. package/dist/components/date-picker/date-picker.css +24 -1
  35. package/dist/components/date-picker/date-picker.js +99 -53
  36. package/dist/components/date-picker/presets.d.ts +2 -1
  37. package/dist/components/date-picker/presets.js +27 -24
  38. package/dist/components/date-picker/range-picker.js +308 -153
  39. package/dist/components/descriptions/descriptions.js +7 -3
  40. package/dist/components/divider/divider.css +1 -1
  41. package/dist/components/divider/divider.js +1 -1
  42. package/dist/components/drawer/drawer.js +201 -369
  43. package/dist/components/dropdown/dropdown.d.ts +1 -1
  44. package/dist/components/dropdown/dropdown.js +183 -279
  45. package/dist/components/empty/empty.js +57 -78
  46. package/dist/components/float-button/float-button.d.ts +1 -0
  47. package/dist/components/float-button/float-button.js +47 -30
  48. package/dist/components/form/field-control.d.ts +4 -2
  49. package/dist/components/form/field-control.js +17 -9
  50. package/dist/components/form/form-context.d.ts +8 -2
  51. package/dist/components/form/form-context.js +2 -1
  52. package/dist/components/form/form-item.js +85 -63
  53. package/dist/components/form/form.css +3 -2
  54. package/dist/components/form/use-form.d.ts +2 -1
  55. package/dist/components/form/use-form.js +2 -1
  56. package/dist/components/form-field/form-field-view.d.ts +3 -1
  57. package/dist/components/form-field/form-field-view.js +194 -141
  58. package/dist/components/form-section/form-section.d.ts +1 -1
  59. package/dist/components/form-section/form-section.js +52 -45
  60. package/dist/components/image/image.js +585 -477
  61. package/dist/components/input/base-input.js +8 -9
  62. package/dist/components/input/input-shared.d.ts +5 -2
  63. package/dist/components/input/input-shared.js +42 -18
  64. package/dist/components/input/otp.js +236 -217
  65. package/dist/components/input/password.js +2 -1
  66. package/dist/components/input/search.js +8 -7
  67. package/dist/components/list/list-pagination.js +41 -36
  68. package/dist/components/list/list.js +141 -125
  69. package/dist/components/listy/listy.js +175 -106
  70. package/dist/components/masonry/masonry.js +108 -85
  71. package/dist/components/mentions/mentions.js +12 -3
  72. package/dist/components/menu/menu-render.d.ts +9 -3
  73. package/dist/components/menu/menu-render.js +99 -36
  74. package/dist/components/modal/confirm-dialog.js +10 -4
  75. package/dist/components/modal/confirm.js +3 -7
  76. package/dist/components/modal/index.js +9 -3
  77. package/dist/components/modal/modal.js +390 -365
  78. package/dist/components/pagination/pagination.js +105 -96
  79. package/dist/components/popconfirm/popconfirm.d.ts +1 -1
  80. package/dist/components/popconfirm/popconfirm.js +219 -168
  81. package/dist/components/popover/popover.js +330 -243
  82. package/dist/components/progress/progress.css +2 -2
  83. package/dist/components/progress/progress.js +232 -458
  84. package/dist/components/qr-code/qr-code.js +72 -66
  85. package/dist/components/radio/radio.css +15 -4
  86. package/dist/components/radio/radio.d.ts +2 -1
  87. package/dist/components/radio/radio.js +260 -198
  88. package/dist/components/rate/rate.js +173 -113
  89. package/dist/components/scroll-area/scroll-area.js +241 -211
  90. package/dist/components/segmented/segmented.js +73 -41
  91. package/dist/components/select/mobile-select.d.ts +2 -1
  92. package/dist/components/select/mobile-select.js +24 -13
  93. package/dist/components/select/select-searchable-list.d.ts +2 -1
  94. package/dist/components/select/select-searchable-list.js +2 -3
  95. package/dist/components/select/select.js +49 -25
  96. package/dist/components/select/use-select-selection.d.ts +1 -1
  97. package/dist/components/select/use-select-selection.js +7 -4
  98. package/dist/components/skeleton/skeleton.js +56 -48
  99. package/dist/components/slider/slider.js +87 -212
  100. package/dist/components/sonner/sonner.js +109 -93
  101. package/dist/components/spinner/spinner.js +147 -138
  102. package/dist/components/splitter/splitter.js +222 -159
  103. package/dist/components/statistic/statistic.js +7 -6
  104. package/dist/components/steps/steps.js +88 -81
  105. package/dist/components/steps/use-display-steps.js +1 -1
  106. package/dist/components/switch/switch.js +89 -89
  107. package/dist/components/table/table-filter.js +66 -56
  108. package/dist/components/table/table-icons.d.ts +2 -1
  109. package/dist/components/table/table-icons.js +11 -9
  110. package/dist/components/table/table-model.js +1 -1
  111. package/dist/components/table/table.js +107 -83
  112. package/dist/components/table/use-table-data.d.ts +6 -3
  113. package/dist/components/table/use-table-data.js +166 -130
  114. package/dist/components/tabs/tabs.css +1 -1
  115. package/dist/components/tabs/tabs.js +236 -179
  116. package/dist/components/tag/tag.d.ts +2 -2
  117. package/dist/components/tag/tag.js +111 -108
  118. package/dist/components/textarea/textarea.js +22 -17
  119. package/dist/components/time-picker/time-picker.js +5 -3
  120. package/dist/components/timeline/timeline.css +6 -1
  121. package/dist/components/timeline/timeline.js +21 -11
  122. package/dist/components/tooltip/tooltip.d.ts +2 -2
  123. package/dist/components/tooltip/tooltip.js +123 -233
  124. package/dist/components/tour/tour.css +4 -0
  125. package/dist/components/tour/tour.js +400 -331
  126. package/dist/components/transfer/transfer-list.js +29 -11
  127. package/dist/components/transfer/transfer-parts.js +1 -1
  128. package/dist/components/transfer/transfer-types.d.ts +1 -0
  129. package/dist/components/transfer/transfer.js +29 -14
  130. package/dist/components/tree/tree-keyboard.d.ts +1 -1
  131. package/dist/components/tree/tree-keyboard.js +5 -3
  132. package/dist/components/tree/tree.js +74 -59
  133. package/dist/components/tree-select/select-engine.d.ts +3 -2
  134. package/dist/components/tree-select/select-engine.js +18 -16
  135. package/dist/components/tree-select/tree-select.js +21 -5
  136. package/dist/components/upload/upload.css +8 -0
  137. package/dist/components/upload/upload.js +160 -72
  138. package/dist/components/watermark/watermark.js +36 -29
  139. package/dist/number-input/use-number-input.js +129 -90
  140. package/dist/number-input/validate.js +32 -5
  141. package/dist/provider/merge-locale.js +12 -9
  142. package/dist/provider/tao-provider.d.ts +3 -1
  143. package/dist/provider/tao-provider.js +123 -86
  144. package/package.json +1 -1
@@ -1,18 +1,30 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { createElement, useEffect, useLayoutEffect, useRef, useState } from "react";
2
+ import { createContext, createElement, useContext, useLayoutEffect, useRef, useState } from "react";
3
3
  import { c } from "react-compiler-runtime";
4
+ import { useLayoutEffect as util_useLayoutEffect } from "@rc-component/util";
4
5
  import { useTaoConfig } from "../../provider/tao-provider.js";
5
6
  import { cx } from "../../utils/semantic.js";
6
7
  import { Button } from "../button/button.js";
7
8
  import { Modal } from "../modal/modal.js";
8
9
  import { StatusIcon } from "../status-icon/status-icon.js";
9
10
  import { resolveAppSemantic } from "./app-notices.js";
10
- function AppConfirm({ config, open, mount, close, remove }) {
11
+ const ActionContext = /*#__PURE__*/ createContext({
12
+ ok: null,
13
+ cancel: null
14
+ });
15
+ function OkBtn() {
16
+ return useContext(ActionContext).ok;
17
+ }
18
+ function CancelBtn() {
19
+ return useContext(ActionContext).cancel;
20
+ }
21
+ function AppConfirm({ config, open, markOpen, close, remove }) {
11
22
  const { locale } = useTaoConfig();
12
23
  const [pending, setPending] = useState(null);
13
24
  const busy = useRef(false);
14
- useLayoutEffect(mount, [
15
- mount
25
+ useLayoutEffect(()=>markOpen(open), [
26
+ markOpen,
27
+ open
16
28
  ]);
17
29
  const run = async (action)=>{
18
30
  if (busy.current) return;
@@ -32,30 +44,30 @@ function AppConfirm({ config, open, mount, close, remove }) {
32
44
  } else if (!callback?.length) finish();
33
45
  };
34
46
  const variant = 'default' === config.okType || 'dashed' === config.okType ? 'secondary' : 'link' === config.okType ? 'bare' : config.okType ?? 'primary';
35
- const OkBtn = ()=>/*#__PURE__*/ jsx(Button, {
36
- variant: variant,
37
- ...config.okButtonProps,
38
- "data-tao-modal-action": "ok",
39
- loading: 'ok' === pending || config.confirmLoading || config.okButtonProps?.loading,
40
- disabled: 'cancel' === pending || config.okButtonProps?.disabled,
41
- onClick: (event)=>{
42
- config.okButtonProps?.onClick?.(event);
43
- if (!event.defaultPrevented) run('ok');
44
- },
45
- children: config.okText ?? locale.ok
46
- });
47
- const CancelBtn = ()=>/*#__PURE__*/ jsx(Button, {
48
- variant: "secondary",
49
- ...config.cancelButtonProps,
50
- "data-tao-modal-action": "cancel",
51
- loading: 'cancel' === pending || config.cancelButtonProps?.loading,
52
- disabled: 'ok' === pending || config.cancelButtonProps?.disabled,
53
- onClick: (event_0)=>{
54
- config.cancelButtonProps?.onClick?.(event_0);
55
- if (!event_0.defaultPrevented) run('cancel');
56
- },
57
- children: config.cancelText ?? locale.cancel ?? 'Cancel'
58
- });
47
+ const okButton = /*#__PURE__*/ jsx(Button, {
48
+ variant: variant,
49
+ ...config.okButtonProps,
50
+ "data-tao-modal-action": "ok",
51
+ loading: 'ok' === pending || config.confirmLoading || config.okButtonProps?.loading,
52
+ disabled: 'cancel' === pending || config.okButtonProps?.disabled,
53
+ onClick: (event)=>{
54
+ config.okButtonProps?.onClick?.(event);
55
+ if (!event.defaultPrevented) run('ok');
56
+ },
57
+ children: config.okText ?? locale.ok
58
+ });
59
+ const cancelButton = /*#__PURE__*/ jsx(Button, {
60
+ variant: "secondary",
61
+ ...config.cancelButtonProps,
62
+ "data-tao-modal-action": "cancel",
63
+ loading: 'cancel' === pending || config.cancelButtonProps?.loading,
64
+ disabled: 'ok' === pending || config.cancelButtonProps?.disabled,
65
+ onClick: (event_0)=>{
66
+ config.cancelButtonProps?.onClick?.(event_0);
67
+ if (!event_0.defaultPrevented) run('cancel');
68
+ },
69
+ children: config.cancelText ?? locale.cancel ?? 'Cancel'
70
+ });
59
71
  const defaultFooter = /*#__PURE__*/ jsxs(Fragment, {
60
72
  children: [
61
73
  (config.okCancel ?? 'confirm' === config.type) && /*#__PURE__*/ jsx(CancelBtn, {}),
@@ -63,8 +75,8 @@ function AppConfirm({ config, open, mount, close, remove }) {
63
75
  ]
64
76
  });
65
77
  const footer = 'function' == typeof config.footer ? config.footer(defaultFooter, {
66
- OkBtn,
67
- CancelBtn
78
+ OkBtn: OkBtn,
79
+ CancelBtn: CancelBtn
68
80
  }) : void 0 === config.footer ? defaultFooter : config.footer;
69
81
  const type = 'confirm' === config.type || 'warn' === config.type ? 'warning' : config.type ?? 'warning';
70
82
  const classes = resolveAppSemantic(config.classNames, config);
@@ -72,61 +84,67 @@ function AppConfirm({ config, open, mount, close, remove }) {
72
84
  const icon = void 0 === config.icon ? /*#__PURE__*/ jsx(StatusIcon, {
73
85
  type: type
74
86
  }) : config.icon;
75
- return /*#__PURE__*/ jsx(Modal, {
76
- ...config,
77
- open: open,
78
- title: config.title,
79
- width: config.width ?? 416,
80
- centered: config.centered ?? false,
81
- closable: config.closable ? {
82
- 'aria-label': locale.close,
83
- ...'object' == typeof config.closable ? config.closable : {}
84
- } : false,
85
- maskClosable: config.maskClosable ?? false,
86
- onClose: ()=>{
87
- run('cancel');
88
- },
89
- onOk: ()=>{
90
- run('ok');
87
+ return /*#__PURE__*/ jsx(ActionContext.Provider, {
88
+ value: {
89
+ ok: okButton,
90
+ cancel: cancelButton
91
91
  },
92
- afterClose: remove,
93
- focusTriggerAfterClose: config.focusTriggerAfterClose ?? true,
94
- autoFocusButton: void 0 === config.autoFocusButton ? 'ok' : config.autoFocusButton,
95
- footer: footer,
96
- classNames: {
97
- ...classes,
98
- root: cx(classes?.root, config.className, config.rootClassName, config.prefixCls),
99
- wrapper: cx(classes?.wrapper, config.wrapClassName)
100
- },
101
- styles: {
102
- ...styles,
103
- root: {
104
- ...styles?.root,
105
- ...config.style,
106
- direction: config.direction
92
+ children: /*#__PURE__*/ jsx(Modal, {
93
+ ...config,
94
+ open: open,
95
+ title: config.title,
96
+ width: config.width ?? 416,
97
+ centered: config.centered ?? false,
98
+ closable: config.closable ? {
99
+ 'aria-label': locale.close,
100
+ ...'object' == typeof config.closable ? config.closable : {}
101
+ } : false,
102
+ maskClosable: config.maskClosable ?? false,
103
+ onClose: ()=>{
104
+ run('cancel');
107
105
  },
108
- body: {
109
- ...config.bodyStyle,
110
- ...styles?.body
106
+ onOk: ()=>{
107
+ run('ok');
111
108
  },
112
- mask: {
113
- ...config.maskStyle,
114
- ...styles?.mask
115
- }
116
- },
117
- children: /*#__PURE__*/ jsxs("div", {
118
- "data-tao-app-modal-body": "",
119
- children: [
120
- null != icon && /*#__PURE__*/ jsx("span", {
121
- "data-tao-modal-confirm-icon": "",
122
- "data-tao-status": type,
123
- children: icon
124
- }),
125
- /*#__PURE__*/ jsx("div", {
126
- "data-tao-app-modal-content": "",
127
- children: config.content
128
- })
129
- ]
109
+ afterClose: remove,
110
+ focusTriggerAfterClose: config.focusTriggerAfterClose ?? true,
111
+ autoFocusButton: void 0 === config.autoFocusButton ? 'ok' : config.autoFocusButton,
112
+ footer: footer,
113
+ classNames: {
114
+ ...classes,
115
+ root: cx(classes?.root, config.className, config.rootClassName, config.prefixCls),
116
+ wrapper: cx(classes?.wrapper, config.wrapClassName)
117
+ },
118
+ styles: {
119
+ ...styles,
120
+ root: {
121
+ ...styles?.root,
122
+ ...config.style,
123
+ direction: config.direction
124
+ },
125
+ body: {
126
+ ...config.bodyStyle,
127
+ ...styles?.body
128
+ },
129
+ mask: {
130
+ ...config.maskStyle,
131
+ ...styles?.mask
132
+ }
133
+ },
134
+ children: /*#__PURE__*/ jsxs("div", {
135
+ "data-tao-app-modal-body": "",
136
+ children: [
137
+ null != icon && /*#__PURE__*/ jsx("span", {
138
+ "data-tao-modal-confirm-icon": "",
139
+ "data-tao-status": type,
140
+ children: icon
141
+ }),
142
+ /*#__PURE__*/ jsx("div", {
143
+ "data-tao-app-modal-content": "",
144
+ children: config.content
145
+ })
146
+ ]
147
+ })
130
148
  })
131
149
  });
132
150
  }
@@ -145,13 +163,18 @@ function useAppModals() {
145
163
  } else t1 = $[1];
146
164
  const resolvers = useRef(t1);
147
165
  const sequence = useRef(0);
166
+ const disposed = useRef(false);
148
167
  let t2;
149
168
  let t3;
150
169
  if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
151
- t2 = ()=>()=>{
170
+ t2 = ()=>{
171
+ disposed.current = false;
172
+ return ()=>{
173
+ disposed.current = true;
152
174
  for (const resolve of resolvers.current)resolve(false);
153
175
  resolvers.current.clear();
154
176
  };
177
+ };
155
178
  t3 = [];
156
179
  $[2] = t2;
157
180
  $[3] = t3;
@@ -159,10 +182,18 @@ function useAppModals() {
159
182
  t2 = $[2];
160
183
  t3 = $[3];
161
184
  }
162
- useEffect(t2, t3);
185
+ util_useLayoutEffect(t2, t3);
163
186
  let t4;
164
187
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
165
188
  t4 = (initial, type)=>{
189
+ if (disposed.current) {
190
+ const result = Promise.resolve(false);
191
+ return {
192
+ destroy: _temp,
193
+ update: _temp2,
194
+ then: result.then.bind(result)
195
+ };
196
+ }
166
197
  sequence.current = sequence.current + 1;
167
198
  const key = sequence.current;
168
199
  let config = {
@@ -170,7 +201,8 @@ function useAppModals() {
170
201
  ...initial,
171
202
  type
172
203
  };
173
- let mounted = false;
204
+ let open = config.open ?? true;
205
+ let committedOpen = false;
174
206
  let closed = false;
175
207
  let removed = false;
176
208
  let resolve_0;
@@ -185,11 +217,11 @@ function useAppModals() {
185
217
  config.afterClose?.();
186
218
  };
187
219
  const close = (confirmed)=>{
188
- if (closed) return;
220
+ if (closed || disposed.current) return;
189
221
  closed = true;
190
222
  resolve_0(confirmed);
191
223
  resolvers.current.delete(resolve_0);
192
- if (mounted) setDialogs((previous_0)=>previous_0.map((dialog_0)=>dialog_0.key === key ? {
224
+ if (committedOpen) setDialogs((previous_0)=>previous_0.map((dialog_0)=>dialog_0.key === key ? {
193
225
  ...dialog_0,
194
226
  open: false
195
227
  } : dialog_0));
@@ -200,9 +232,9 @@ function useAppModals() {
200
232
  {
201
233
  key,
202
234
  config,
203
- open: config.open ?? true,
204
- mount: ()=>{
205
- mounted = true;
235
+ open,
236
+ markOpen: (value)=>{
237
+ committedOpen = value;
206
238
  },
207
239
  close,
208
240
  remove
@@ -211,15 +243,19 @@ function useAppModals() {
211
243
  return {
212
244
  destroy: ()=>close(false),
213
245
  update: (update)=>{
214
- if (closed) return;
246
+ if (closed || disposed.current) return;
215
247
  config = "function" == typeof update ? update(config) : {
216
248
  ...config,
217
249
  ...update
218
250
  };
219
- if (false === config.open) close(false);
220
- else setDialogs((previous_2)=>previous_2.map((dialog_1)=>dialog_1.key === key ? {
251
+ const closeRequested = "function" == typeof update ? open && false === config.open : false === update.open;
252
+ if (closeRequested) return void close(false);
253
+ const nextOpen = config.open ?? open;
254
+ open = nextOpen;
255
+ setDialogs((previous_2)=>previous_2.map((dialog_1)=>dialog_1.key === key ? {
221
256
  ...dialog_1,
222
- config
257
+ config,
258
+ open: nextOpen
223
259
  } : dialog_1));
224
260
  },
225
261
  then: promise.then.bind(promise)
@@ -242,7 +278,7 @@ function useAppModals() {
242
278
  const api = t5;
243
279
  let t6;
244
280
  if ($[6] !== dialogs) {
245
- t6 = dialogs.map(_temp);
281
+ t6 = dialogs.map(_temp3);
246
282
  $[6] = dialogs;
247
283
  $[7] = t6;
248
284
  } else t6 = $[7];
@@ -257,10 +293,12 @@ function useAppModals() {
257
293
  } else t7 = $[9];
258
294
  return t7;
259
295
  }
260
- function _temp(dialog_2) {
296
+ function _temp3(dialog_2) {
261
297
  return /*#__PURE__*/ createElement(AppConfirm, {
262
298
  ...dialog_2,
263
299
  key: dialog_2.key
264
300
  });
265
301
  }
302
+ function _temp2() {}
303
+ function _temp() {}
266
304
  export { useAppModals };
@@ -1,7 +1,8 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { useNotification } from "@rc-component/notification";
4
- import { useEffect, useMemo, useRef } from "react";
4
+ import { useLayoutEffect } from "@rc-component/util";
5
+ import { useMemo, useRef } from "react";
5
6
  import { TaoPortalScope, useTaoConfig, useTaoInternalConfig } from "../../provider/tao-provider.js";
6
7
  import { cx } from "../../utils/semantic.js";
7
8
  import { Spinner } from "../spinner/spinner.js";
@@ -159,42 +160,57 @@ function useNoticeHolder(kind, config) {
159
160
  } else t14 = $[32];
160
161
  return t14;
161
162
  }
163
+ function messageResult(promise, close) {
164
+ return Object.assign(close, {
165
+ then: promise.then.bind(promise)
166
+ });
167
+ }
162
168
  function useAppMessages(config = {}) {
163
169
  const [notices, holder] = useNoticeHolder('message', config);
164
170
  const active = useRef(new Map());
165
171
  const sequence = useRef(0);
172
+ const disposed = useRef(false);
166
173
  const latest = useRef(config);
167
174
  latest.current = config;
168
- useEffect(()=>()=>{
175
+ useLayoutEffect(()=>{
176
+ disposed.current = false;
177
+ return ()=>{
178
+ disposed.current = true;
169
179
  for (const life of active.current.values())for (const resolve of life.resolve)resolve();
170
180
  active.current.clear();
171
- }, []);
181
+ };
182
+ }, []);
172
183
  const api = useMemo(()=>{
173
- const finish = (key)=>{
174
- const life_0 = active.current.get(key);
175
- if (!life_0) return;
184
+ const finish = (key, life_0)=>{
185
+ if (active.current.get(key) !== life_0) return;
176
186
  active.current.delete(key);
177
- life_0.onClose?.();
178
- for (const resolve_0 of life_0.resolve)resolve_0();
187
+ try {
188
+ life_0.onClose?.();
189
+ } finally{
190
+ for (const resolve of life_0.resolve)resolve();
191
+ }
179
192
  };
180
- const close = (key_0)=>{
193
+ const close = (key_0, life_1 = active.current.get(key_0))=>{
194
+ if (!life_1 || active.current.get(key_0) !== life_1) return;
181
195
  notices.close(key_0);
182
- finish(key_0);
196
+ finish(key_0, life_1);
183
197
  };
184
198
  const open = (args)=>{
199
+ if (disposed.current) return messageResult(Promise.resolve(true), ()=>{});
185
200
  const defaults = latest.current;
186
201
  const key_1 = args.key ?? `tao-app-message-${sequence.current++}`;
187
- const resolvers = active.current.get(key_1)?.resolve ?? [];
188
- const promise = new Promise((resolve_1)=>resolvers.push(()=>resolve_1(true)));
189
- active.current.set(key_1, {
190
- onClose: args.onClose,
191
- resolve: resolvers
192
- });
193
- if (defaults.maxCount && active.current.size > defaults.maxCount) close(active.current.keys().next().value);
194
202
  const merged = {
195
203
  ...defaults,
196
204
  ...args
197
205
  };
206
+ const classNames = noticeClasses(resolveAppSemantic(defaults.classNames, merged), resolveAppSemantic(args.classNames, merged));
207
+ const styles = noticeStyles(resolveAppSemantic(defaults.styles, merged), resolveAppSemantic(args.styles, merged));
208
+ const life_2 = active.current.get(key_1) ?? {
209
+ resolve: []
210
+ };
211
+ life_2.onClose = args.onClose;
212
+ const promise = new Promise((resolve_0)=>life_2.resolve.push(()=>resolve_0(true)));
213
+ active.current.set(key_1, life_2);
198
214
  notices.open({
199
215
  ...args,
200
216
  key: key_1,
@@ -205,13 +221,13 @@ function useAppMessages(config = {}) {
205
221
  closable: false,
206
222
  placement: 'top',
207
223
  icon: iconFor(args.type, args.icon),
208
- classNames: noticeClasses(resolveAppSemantic(defaults.classNames, merged), resolveAppSemantic(args.classNames, merged)),
209
- styles: noticeStyles(resolveAppSemantic(defaults.styles, merged), resolveAppSemantic(args.styles, merged)),
210
- onClose: ()=>finish(key_1)
211
- });
212
- return Object.assign(()=>close(key_1), {
213
- then: promise.then.bind(promise)
224
+ classNames,
225
+ styles,
226
+ onClose: ()=>finish(key_1, life_2)
214
227
  });
228
+ const maxCount = defaults.maxCount ?? 0;
229
+ while(maxCount > 0 && active.current.size > maxCount)close(active.current.keys().next().value);
230
+ return messageResult(promise, ()=>close(key_1, life_2));
215
231
  };
216
232
  const typed = (type)=>(content, duration, onClose)=>{
217
233
  const args_0 = content && 'object' == typeof content && 'content' in content ? content : {
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import _rc_component_select from "@rc-component/select";
3
- import { Children, forwardRef, isValidElement, useMemo } from "react";
3
+ import { Children, cloneElement, forwardRef, isValidElement, useMemo } from "react";
4
4
  import { useTaoDirection, useTaoInternalConfig } from "../../provider/tao-provider.js";
5
5
  import { mergeRefs } from "../../utils/refs.js";
6
6
  import { cx } from "../../utils/semantic.js";
@@ -11,10 +11,20 @@ import { interopDefault } from "../../utils/interop-default.js";
11
11
  const RcSelectComponent = /*#__PURE__*/ interopDefault(_rc_component_select);
12
12
  function InternalAutoComplete(props, ref) {
13
13
  const config = useTaoInternalConfig();
14
- const { size: sizeProp = config.size, disabled = config.disabled, variant = false === props.bordered ? 'borderless' : config.variant, status, prefixCls = 'tao-select-engine', className, rootClassName, style, classNames, styles, children, dataSource, components, suffix, suffixIcon, allowClear, clearIcon, popupClassName, dropdownClassName, popupStyle, dropdownStyle, popupRender, dropdownRender, onOpenChange, onDropdownVisibleChange, onPopupVisibleChange, popupMatchSelectWidth, dropdownMatchSelectWidth, listHeight = 256, listItemHeight = 32, showSearch = true, notFoundContent = null, bordered: _bordered, showArrow: _showArrow, ...rest } = props;
14
+ const { size: sizeProp = config.size, disabled = config.disabled, variant = false === props.bordered ? 'borderless' : config.variant, status, prefixCls = 'tao-select-engine', className, rootClassName, style, classNames, styles, children, dataSource, components, suffix, suffixIcon, allowClear, clearIcon, popupClassName, dropdownClassName, popupStyle, dropdownStyle, popupRender, dropdownRender, onOpenChange, onDropdownVisibleChange, onPopupVisibleChange, popupMatchSelectWidth, dropdownMatchSelectWidth, listHeight = 256, listItemHeight = 32, showSearch = true, notFoundContent, value, bordered: _bordered, showArrow: _showArrow, ...rest } = props;
15
15
  const nodes = Children.toArray(children);
16
16
  const customInput = 1 === nodes.length && /*#__PURE__*/ isValidElement(nodes[0]) && nodes[0].type !== RcSelectComponent.Option && nodes[0].type !== RcSelectComponent.OptGroup ? nodes[0] : void 0;
17
17
  const optionsChildren = customInput ? void 0 : children;
18
+ const input = customInput ?? components?.input;
19
+ const mergedComponents = disabled && /*#__PURE__*/ isValidElement(input) ? {
20
+ ...components,
21
+ input: /*#__PURE__*/ cloneElement(input, {
22
+ disabled: true
23
+ })
24
+ } : customInput ? {
25
+ ...components,
26
+ input: customInput
27
+ } : components;
18
28
  const legacyOptions = dataSource?.map((item)=>{
19
29
  if (/*#__PURE__*/ isValidElement(item)) return item;
20
30
  if ('string' == typeof item) return /*#__PURE__*/ jsx(RcSelectComponent.Option, {
@@ -63,6 +73,11 @@ function InternalAutoComplete(props, ref) {
63
73
  "data-tao-error": 'error' === status || void 0,
64
74
  "data-tao-warning": 'warning' === status || void 0,
65
75
  disabled: disabled,
76
+ onInputKeyDown: (event)=>{
77
+ props.onInputKeyDown?.(event);
78
+ if ('Enter' === event.key && (event.nativeEvent.isComposing || 229 === event.keyCode)) event.stopPropagation();
79
+ },
80
+ value: 'value' in props ? value ?? null : void 0,
66
81
  className: cx(className, rootClassName, classes?.root),
67
82
  style: {
68
83
  ...semanticStyles?.root,
@@ -70,12 +85,11 @@ function InternalAutoComplete(props, ref) {
70
85
  },
71
86
  classNames: classes,
72
87
  styles: semanticStyles,
73
- components: customInput ? {
74
- ...components,
75
- input: customInput
76
- } : components,
88
+ components: mergedComponents,
77
89
  showSearch: showSearch,
78
- notFoundContent: notFoundContent,
90
+ notFoundContent: void 0 === notFoundContent ? renderPopup ? /*#__PURE__*/ jsx("span", {
91
+ hidden: true
92
+ }) : null : notFoundContent,
79
93
  listHeight: listHeight,
80
94
  listItemHeight: listItemHeight,
81
95
  suffix: void 0 !== suffix ? suffix : suffixIcon ?? null,
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Children, Fragment, createContext, forwardRef, isValidElement, useContext, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
2
+ import { Children, Fragment, cloneElement, createContext, forwardRef, isValidElement, useContext, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
3
3
  import { useTaoConfig } from "../../provider/tao-provider.js";
4
4
  import { resolveResponsiveValue, useBreakpoint } from "../../utils/breakpoint.js";
5
5
  import { cx } from "../../utils/semantic.js";
@@ -16,8 +16,12 @@ const AvatarRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
16
16
  const screens = useBreakpoint();
17
17
  const dimensions = 'object' == typeof size ? resolveResponsiveValue(size, screens) : size;
18
18
  const [failedSource, setFailedSource] = useState();
19
- const failed = failedSource?.src === src && failedSource?.srcSet === srcSet;
20
- const hasImage = 'string' == typeof src ? !failed && '' !== src : /*#__PURE__*/ isValidElement(src);
19
+ const failed = failedSource?.src === src && failedSource?.srcSet === srcSet && failedSource?.crossOrigin === crossOrigin;
20
+ if (failedSource && !failed) setFailedSource(void 0);
21
+ const customImage = /*#__PURE__*/ isValidElement(src) ? src : null;
22
+ const imageSrc = 'string' == typeof src && '' !== src ? src : void 0;
23
+ const hasNativeImage = !customImage && !failed && (!!imageSrc || !!srcSet);
24
+ const hasImage = hasNativeImage || null !== customImage;
21
25
  const hasIcon = null != icon && 'boolean' != typeof icon;
22
26
  const [scale, setScale] = useState(1);
23
27
  useLayoutEffect(()=>{
@@ -59,8 +63,8 @@ const AvatarRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
59
63
  ...styles?.root,
60
64
  ...style
61
65
  },
62
- children: hasImage ? 'string' == typeof src ? /*#__PURE__*/ jsx("img", {
63
- src: src,
66
+ children: hasNativeImage ? /*#__PURE__*/ jsx("img", {
67
+ src: imageSrc,
64
68
  srcSet: srcSet,
65
69
  alt: alt ?? '',
66
70
  draggable: draggable,
@@ -70,10 +74,11 @@ const AvatarRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
70
74
  onError: ()=>{
71
75
  if (onError?.() !== false) setFailedSource({
72
76
  src,
73
- srcSet
77
+ srcSet,
78
+ crossOrigin
74
79
  });
75
80
  }
76
- }) : src : hasIcon ? /*#__PURE__*/ jsx("span", {
81
+ }) : customImage ? customImage : hasIcon ? /*#__PURE__*/ jsx("span", {
77
82
  "data-tao-avatar-icon": "",
78
83
  className: classNames?.icon,
79
84
  style: styles?.icon,
@@ -91,10 +96,22 @@ const AvatarRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
91
96
  });
92
97
  });
93
98
  AvatarRoot.displayName = 'Avatar';
94
- function flattenChildren(children) {
95
- return Children.toArray(children).flatMap((child)=>/*#__PURE__*/ isValidElement(child) && child.type === Fragment ? flattenChildren(child.props.children) : [
99
+ function flattenChildren(children, fragmentKeys = []) {
100
+ return Children.toArray(children).flatMap((child)=>{
101
+ if (!/*#__PURE__*/ isValidElement(child)) return [
96
102
  child
97
- ]);
103
+ ];
104
+ const keyPath = [
105
+ ...fragmentKeys,
106
+ child.key
107
+ ];
108
+ if (child.type === Fragment) return flattenChildren(child.props.children, keyPath);
109
+ return [
110
+ fragmentKeys.length ? /*#__PURE__*/ cloneElement(child, {
111
+ key: JSON.stringify(keyPath)
112
+ }) : child
113
+ ];
114
+ });
98
115
  }
99
116
  const AvatarGroup = /*#__PURE__*/ forwardRef((props, ref)=>{
100
117
  const parent = useContext(GroupContext);
@@ -133,7 +150,10 @@ const AvatarGroup = /*#__PURE__*/ forwardRef((props, ref)=>{
133
150
  destroyOnHidden: true,
134
151
  ...max?.popover,
135
152
  placement: max?.popover?.placement ?? maxPopoverPlacement ?? 'top',
136
- trigger: max?.popover?.trigger ?? maxPopoverTrigger ?? 'hover',
153
+ trigger: max?.popover?.trigger ?? maxPopoverTrigger ?? [
154
+ 'hover',
155
+ 'focus'
156
+ ],
137
157
  children: /*#__PURE__*/ jsx("button", {
138
158
  type: "button",
139
159
  "data-tao-avatar-overflow": "",
@@ -94,7 +94,7 @@
94
94
  inset: 0;
95
95
  }
96
96
 
97
- [data-tao-badge-indicator][data-tao-status="processing"][data-tao-dot], [data-tao-ribbon] {
97
+ [data-tao-badge]:not([data-tao-wrapper]) > [data-tao-badge-indicator][data-tao-status="processing"][data-tao-dot], [data-tao-ribbon] {
98
98
  position: relative;
99
99
  }
100
100