@rockshin/tao-ui 0.0.48 → 0.0.51

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 (147) 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.css +9 -1
  12. package/dist/components/button/button.js +61 -53
  13. package/dist/components/calendar/calendar.js +6 -4
  14. package/dist/components/card/card.js +24 -8
  15. package/dist/components/carousel/carousel.d.ts +1 -1
  16. package/dist/components/carousel/carousel.js +105 -68
  17. package/dist/components/cascader/cascader.js +54 -19
  18. package/dist/components/checkbox/checkbox.css +13 -2
  19. package/dist/components/checkbox/checkbox.d.ts +2 -0
  20. package/dist/components/checkbox/checkbox.js +320 -229
  21. package/dist/components/collapse/collapse-panels.d.ts +1 -1
  22. package/dist/components/collapse/collapse-panels.js +122 -113
  23. package/dist/components/collapse/collapse.js +98 -63
  24. package/dist/components/color-picker/color-picker.js +539 -441
  25. package/dist/components/color-picker/color.js +1 -1
  26. package/dist/components/context-menu/context-menu.d.ts +1 -1
  27. package/dist/components/context-menu/context-menu.js +108 -68
  28. package/dist/components/date-picker/calendar/calendar-grid.js +42 -39
  29. package/dist/components/date-picker/calendar/month-grid.d.ts +8 -1
  30. package/dist/components/date-picker/calendar/month-grid.js +79 -37
  31. package/dist/components/date-picker/calendar/time-panel.d.ts +2 -1
  32. package/dist/components/date-picker/calendar/time-panel.js +94 -89
  33. package/dist/components/date-picker/calendar/year-grid.d.ts +8 -1
  34. package/dist/components/date-picker/calendar/year-grid.js +66 -35
  35. package/dist/components/date-picker/date-picker.css +24 -1
  36. package/dist/components/date-picker/date-picker.js +99 -53
  37. package/dist/components/date-picker/presets.d.ts +2 -1
  38. package/dist/components/date-picker/presets.js +27 -24
  39. package/dist/components/date-picker/range-picker.js +308 -153
  40. package/dist/components/descriptions/descriptions.js +7 -3
  41. package/dist/components/divider/divider.css +1 -1
  42. package/dist/components/divider/divider.js +1 -1
  43. package/dist/components/drawer/drawer.js +201 -369
  44. package/dist/components/dropdown/dropdown.d.ts +1 -1
  45. package/dist/components/dropdown/dropdown.js +183 -279
  46. package/dist/components/empty/empty.js +57 -78
  47. package/dist/components/float-button/float-button.d.ts +1 -0
  48. package/dist/components/float-button/float-button.js +47 -30
  49. package/dist/components/form/field-control.d.ts +4 -2
  50. package/dist/components/form/field-control.js +17 -9
  51. package/dist/components/form/form-context.d.ts +8 -2
  52. package/dist/components/form/form-context.js +2 -1
  53. package/dist/components/form/form-item.js +85 -63
  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/input.css +1 -0
  65. package/dist/components/input/otp.js +236 -217
  66. package/dist/components/input/password.js +2 -1
  67. package/dist/components/input/search.js +8 -7
  68. package/dist/components/list/list-pagination.js +41 -36
  69. package/dist/components/list/list.js +141 -125
  70. package/dist/components/listy/listy.js +175 -106
  71. package/dist/components/masonry/masonry.js +108 -85
  72. package/dist/components/mentions/mentions.js +12 -3
  73. package/dist/components/menu/menu-render.d.ts +9 -3
  74. package/dist/components/menu/menu-render.js +99 -36
  75. package/dist/components/modal/confirm-dialog.js +10 -4
  76. package/dist/components/modal/confirm.js +3 -7
  77. package/dist/components/modal/index.js +9 -3
  78. package/dist/components/modal/modal.js +390 -365
  79. package/dist/components/pagination/pagination.js +105 -96
  80. package/dist/components/popconfirm/popconfirm.d.ts +1 -1
  81. package/dist/components/popconfirm/popconfirm.js +219 -168
  82. package/dist/components/popover/popover.js +330 -243
  83. package/dist/components/progress/progress.css +2 -2
  84. package/dist/components/progress/progress.js +232 -458
  85. package/dist/components/qr-code/qr-code.js +72 -66
  86. package/dist/components/radio/radio.css +15 -4
  87. package/dist/components/radio/radio.d.ts +2 -1
  88. package/dist/components/radio/radio.js +260 -198
  89. package/dist/components/rate/rate.js +173 -113
  90. package/dist/components/scroll-area/scroll-area.js +241 -211
  91. package/dist/components/segmented/segmented.js +73 -41
  92. package/dist/components/select/mobile-select.d.ts +2 -1
  93. package/dist/components/select/mobile-select.js +24 -13
  94. package/dist/components/select/select-searchable-list.d.ts +2 -1
  95. package/dist/components/select/select-searchable-list.js +2 -3
  96. package/dist/components/select/select.css +3 -2
  97. package/dist/components/select/select.js +49 -25
  98. package/dist/components/select/use-select-selection.d.ts +1 -1
  99. package/dist/components/select/use-select-selection.js +7 -4
  100. package/dist/components/skeleton/skeleton.js +56 -48
  101. package/dist/components/slider/slider.js +87 -212
  102. package/dist/components/sonner/sonner.js +109 -93
  103. package/dist/components/spinner/spinner.js +147 -138
  104. package/dist/components/splitter/splitter.js +222 -159
  105. package/dist/components/statistic/statistic.js +7 -6
  106. package/dist/components/steps/steps.js +88 -81
  107. package/dist/components/steps/use-display-steps.js +1 -1
  108. package/dist/components/switch/switch.js +89 -89
  109. package/dist/components/table/table-filter.js +66 -56
  110. package/dist/components/table/table-icons.d.ts +2 -1
  111. package/dist/components/table/table-icons.js +11 -9
  112. package/dist/components/table/table-model.js +1 -1
  113. package/dist/components/table/table.js +107 -83
  114. package/dist/components/table/use-table-data.d.ts +6 -3
  115. package/dist/components/table/use-table-data.js +166 -130
  116. package/dist/components/tabs/tabs.css +1 -1
  117. package/dist/components/tabs/tabs.js +236 -179
  118. package/dist/components/tag/tag.d.ts +2 -2
  119. package/dist/components/tag/tag.js +111 -108
  120. package/dist/components/textarea/textarea.js +22 -17
  121. package/dist/components/time-picker/time-picker.js +5 -3
  122. package/dist/components/timeline/timeline.css +6 -1
  123. package/dist/components/timeline/timeline.js +21 -11
  124. package/dist/components/tooltip/tooltip.d.ts +2 -2
  125. package/dist/components/tooltip/tooltip.js +123 -233
  126. package/dist/components/tour/tour.css +4 -0
  127. package/dist/components/tour/tour.js +400 -331
  128. package/dist/components/transfer/transfer-list.js +31 -12
  129. package/dist/components/transfer/transfer-parts.js +1 -1
  130. package/dist/components/transfer/transfer-types.d.ts +1 -0
  131. package/dist/components/transfer/transfer.css +5 -0
  132. package/dist/components/transfer/transfer.js +29 -14
  133. package/dist/components/tree/tree-keyboard.d.ts +1 -1
  134. package/dist/components/tree/tree-keyboard.js +5 -3
  135. package/dist/components/tree/tree.js +74 -59
  136. package/dist/components/tree-select/select-engine.d.ts +3 -2
  137. package/dist/components/tree-select/select-engine.js +18 -16
  138. package/dist/components/tree-select/tree-select.js +21 -5
  139. package/dist/components/upload/upload.css +8 -0
  140. package/dist/components/upload/upload.js +160 -72
  141. package/dist/components/watermark/watermark.js +36 -29
  142. package/dist/number-input/use-number-input.js +129 -90
  143. package/dist/number-input/validate.js +32 -5
  144. package/dist/provider/merge-locale.js +12 -9
  145. package/dist/provider/tao-provider.d.ts +3 -1
  146. package/dist/provider/tao-provider.js +123 -86
  147. package/package.json +4 -3
@@ -255,6 +255,22 @@ const CardRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
255
255
  props: mergedProps
256
256
  }) : styles;
257
257
  const hasBody = loading || Children.toArray(children).length > 0;
258
+ const actionItems = Children.toArray(actions);
259
+ let tabExtra = void 0 === tabBarExtraContent ? tabProps.tabBarExtraContent : tabBarExtraContent;
260
+ if (tabExtra && 'object' == typeof tabExtra && Symbol.iterator in tabExtra) {
261
+ const extras = Children.toArray(tabExtra);
262
+ tabExtra = extras.some((node)=>'' !== node) ? {
263
+ right: extras
264
+ } : null;
265
+ }
266
+ const extraMap = null === tabExtra || 'object' != typeof tabExtra || /*#__PURE__*/ isValidElement(tabExtra) ? void 0 : tabExtra;
267
+ const extraNodes = extraMap ? [
268
+ extraMap.left,
269
+ extraMap.right
270
+ ] : [
271
+ tabExtra
272
+ ];
273
+ const hasTabs = tabList && (tabList.length > 0 || extraNodes.some((node_0)=>renderable(node_0) && '' !== node_0));
258
274
  return /*#__PURE__*/ jsxs("div", {
259
275
  ...rest,
260
276
  ref: ref,
@@ -271,7 +287,7 @@ const CardRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
271
287
  ...style
272
288
  },
273
289
  children: [
274
- (renderable(title) || renderable(extra) || tabList) && /*#__PURE__*/ jsxs("div", {
290
+ (renderable(title) || renderable(extra) || hasTabs) && /*#__PURE__*/ jsxs("div", {
275
291
  "data-tao-card-header": "",
276
292
  className: classes?.header,
277
293
  style: {
@@ -296,7 +312,7 @@ const CardRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
296
312
  })
297
313
  ]
298
314
  }),
299
- tabList && /*#__PURE__*/ jsx(CardTabs, {
315
+ hasTabs && /*#__PURE__*/ jsx(CardTabs, {
300
316
  size: 'small' === size ? 'small' : 'large',
301
317
  direction: 'rtl' === rest.dir || 'ltr' === rest.dir ? rest.dir : void 0,
302
318
  ...tabProps,
@@ -305,10 +321,10 @@ const CardRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
305
321
  } : {
306
322
  defaultActiveKey: defaultActiveTabKey ?? tabProps.defaultActiveKey
307
323
  },
308
- tabBarExtraContent: tabBarExtraContent,
309
- items: tabList.map(({ tab, ...item })=>({
310
- label: tab,
311
- ...item
324
+ tabBarExtraContent: tabExtra,
325
+ items: tabList.map(({ tab, label, ...item })=>({
326
+ ...item,
327
+ label: void 0 === label ? tab : label
312
328
  })),
313
329
  onChange: (key)=>{
314
330
  tabProps.onChange?.(key);
@@ -340,11 +356,11 @@ const CardRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
340
356
  children: children
341
357
  }) : children
342
358
  }),
343
- !!actions?.length && /*#__PURE__*/ jsx("ul", {
359
+ actionItems.length > 0 && /*#__PURE__*/ jsx("ul", {
344
360
  "data-tao-card-actions": "",
345
361
  className: classes?.actions,
346
362
  style: slots?.actions,
347
- children: Children.toArray(actions).map((action, index)=>{
363
+ children: actionItems.map((action, index)=>{
348
364
  const key_0 = /*#__PURE__*/ isValidElement(action) ? action.key : `action-${index}`;
349
365
  return /*#__PURE__*/ jsx("li", {
350
366
  children: action
@@ -30,6 +30,6 @@ export interface CarouselRef {
30
30
  next: () => void;
31
31
  prev: () => void;
32
32
  autoPlay: (playType?: 'update' | 'leave' | 'blur') => void;
33
- innerSlider: NonNullable<SlickCarousel['innerSlider']>;
33
+ innerSlider: SlickCarousel['innerSlider'];
34
34
  }
35
35
  export declare const Carousel: import("react").ForwardRefExoticComponent<CarouselProps & import("react").RefAttributes<CarouselRef>>;
@@ -10,7 +10,7 @@ import "./carousel.css";
10
10
  const SlickCarouselComponent = /*#__PURE__*/ interopDefault(react_slick);
11
11
  function useResponsiveSettings(responsive) {
12
12
  const $ = c(3);
13
- const [settings, setSettings] = useState();
13
+ const [settings, setSettings] = useState(responsive?.length ? null : void 0);
14
14
  let t0;
15
15
  let t1;
16
16
  if ($[0] !== responsive) {
@@ -53,12 +53,13 @@ function _temp(a, b) {
53
53
  return a.breakpoint - b.breakpoint;
54
54
  }
55
55
  function Arrow(t0) {
56
- const $ = c(32);
56
+ const $ = c(34);
57
57
  let t1;
58
58
  let t10;
59
59
  let t11;
60
60
  let t12;
61
61
  let t13;
62
+ let t14;
62
63
  let t2;
63
64
  let t3;
64
65
  let t4;
@@ -70,7 +71,8 @@ function Arrow(t0) {
70
71
  if ($[0] !== t0) {
71
72
  const { currentSlide: _current, slideCount: _count, ...props } = t0;
72
73
  t12 = "button";
73
- t13 = props;
74
+ t13 = props.className?.split(" ").includes("slick-disabled");
75
+ t14 = props;
74
76
  t2 = "20";
75
77
  t3 = "20";
76
78
  t4 = "0 0 24 24";
@@ -88,40 +90,42 @@ function Arrow(t0) {
88
90
  $[3] = t11;
89
91
  $[4] = t12;
90
92
  $[5] = t13;
91
- $[6] = t2;
92
- $[7] = t3;
93
- $[8] = t4;
94
- $[9] = t5;
95
- $[10] = t6;
96
- $[11] = t7;
97
- $[12] = t8;
98
- $[13] = t9;
93
+ $[6] = t14;
94
+ $[7] = t2;
95
+ $[8] = t3;
96
+ $[9] = t4;
97
+ $[10] = t5;
98
+ $[11] = t6;
99
+ $[12] = t7;
100
+ $[13] = t8;
101
+ $[14] = t9;
99
102
  } else {
100
103
  t1 = $[1];
101
104
  t10 = $[2];
102
105
  t11 = $[3];
103
106
  t12 = $[4];
104
107
  t13 = $[5];
105
- t2 = $[6];
106
- t3 = $[7];
107
- t4 = $[8];
108
- t5 = $[9];
109
- t6 = $[10];
110
- t7 = $[11];
111
- t8 = $[12];
112
- t9 = $[13];
108
+ t14 = $[6];
109
+ t2 = $[7];
110
+ t3 = $[8];
111
+ t4 = $[9];
112
+ t5 = $[10];
113
+ t6 = $[11];
114
+ t7 = $[12];
115
+ t8 = $[13];
116
+ t9 = $[14];
113
117
  }
114
- let t14;
115
- if ($[14] !== t1) {
116
- t14 = /*#__PURE__*/ jsx("path", {
118
+ let t15;
119
+ if ($[15] !== t1) {
120
+ t15 = /*#__PURE__*/ jsx("path", {
117
121
  d: t1
118
122
  });
119
- $[14] = t1;
120
- $[15] = t14;
121
- } else t14 = $[15];
122
- let t15;
123
- if ($[16] !== t10 || $[17] !== t11 || $[18] !== t14 || $[19] !== t2 || $[20] !== t3 || $[21] !== t4 || $[22] !== t5 || $[23] !== t6 || $[24] !== t7 || $[25] !== t8 || $[26] !== t9) {
124
- t15 = /*#__PURE__*/ jsx("svg", {
123
+ $[15] = t1;
124
+ $[16] = t15;
125
+ } else t15 = $[16];
126
+ let t16;
127
+ if ($[17] !== t10 || $[18] !== t11 || $[19] !== t15 || $[20] !== t2 || $[21] !== t3 || $[22] !== t4 || $[23] !== t5 || $[24] !== t6 || $[25] !== t7 || $[26] !== t8 || $[27] !== t9) {
128
+ t16 = /*#__PURE__*/ jsx("svg", {
125
129
  width: t2,
126
130
  height: t3,
127
131
  viewBox: t4,
@@ -132,41 +136,43 @@ function Arrow(t0) {
132
136
  strokeLinejoin: t9,
133
137
  "aria-hidden": t10,
134
138
  focusable: t11,
135
- children: t14
139
+ children: t15
136
140
  });
137
- $[16] = t10;
138
- $[17] = t11;
139
- $[18] = t14;
140
- $[19] = t2;
141
- $[20] = t3;
142
- $[21] = t4;
143
- $[22] = t5;
144
- $[23] = t6;
145
- $[24] = t7;
146
- $[25] = t8;
147
- $[26] = t9;
148
- $[27] = t15;
149
- } else t15 = $[27];
150
- let t16;
151
- if ($[28] !== t12 || $[29] !== t13 || $[30] !== t15) {
152
- t16 = /*#__PURE__*/ jsx("button", {
141
+ $[17] = t10;
142
+ $[18] = t11;
143
+ $[19] = t15;
144
+ $[20] = t2;
145
+ $[21] = t3;
146
+ $[22] = t4;
147
+ $[23] = t5;
148
+ $[24] = t6;
149
+ $[25] = t7;
150
+ $[26] = t8;
151
+ $[27] = t9;
152
+ $[28] = t16;
153
+ } else t16 = $[28];
154
+ let t17;
155
+ if ($[29] !== t12 || $[30] !== t13 || $[31] !== t14 || $[32] !== t16) {
156
+ t17 = /*#__PURE__*/ jsx("button", {
153
157
  type: t12,
154
- ...t13,
155
- children: t15
158
+ disabled: t13,
159
+ ...t14,
160
+ children: t16
156
161
  });
157
- $[28] = t12;
158
- $[29] = t13;
159
- $[30] = t15;
160
- $[31] = t16;
161
- } else t16 = $[31];
162
- return t16;
162
+ $[29] = t12;
163
+ $[30] = t13;
164
+ $[31] = t14;
165
+ $[32] = t16;
166
+ $[33] = t17;
167
+ } else t17 = $[33];
168
+ return t17;
163
169
  }
164
170
  const carousel_Carousel = /*#__PURE__*/ forwardRef(function(props, ref) {
165
171
  const { locale, tokenStyle } = useTaoInternalConfig();
166
172
  const { responsive, ...baseProps } = props;
167
173
  const responsiveSettings = useResponsiveSettings(responsive);
168
174
  const unslick = 'unslick' === responsiveSettings;
169
- const { dots = true, arrows = false, prevArrow, nextArrow, draggable = false, waitForAnimate = false, dotPosition, dotPlacement, vertical, rootClassName, className, style, id, autoplay = false, autoplaySpeed = 3000, initialSlide = 0, rtl, children, effect = 'scrollx', slickGoTo, prefixCls, classNames, styles, appendDots, ...rest } = {
175
+ const { dots = true, arrows = false, prevArrow, nextArrow, draggable = false, waitForAnimate = false, dotPosition, dotPlacement, vertical, rootClassName, className, style, id, autoplay = false, autoplaySpeed = 3000, initialSlide = 0, rtl, children, effect = 'scrollx', slickGoTo, prefixCls, classNames, styles, appendDots, customPaging, ...rest } = {
170
176
  ...baseProps,
171
177
  ...unslick ? {} : responsiveSettings
172
178
  };
@@ -179,30 +185,57 @@ const carousel_Carousel = /*#__PURE__*/ forwardRef(function(props, ref) {
179
185
  const mergedRootRef = useMemo(()=>mergeRefs(rootRef, directionRef), [
180
186
  directionRef
181
187
  ]);
182
- const count = Children.count(children);
188
+ const childCount = Children.toArray(children).filter((child)=>'string' == typeof child ? Boolean(child.trim()) : Boolean(child)).length;
189
+ const itemsPerSlide = (rest.rows ?? 1) * (rest.slidesPerRow ?? 1);
190
+ const count = Math.ceil(childCount / itemsPerSlide);
191
+ const ready = count > 0 && !unslick && null !== responsiveSettings;
192
+ const previousPosition = useRef(null);
183
193
  useImperativeHandle(ref, ()=>({
184
194
  nativeElement: rootRef.current,
185
- goTo: (slide, dontAnimate = false)=>sliderRef.current.slickGoTo(slide, dontAnimate),
186
- next: ()=>sliderRef.current.slickNext(),
187
- prev: ()=>sliderRef.current.slickPrev(),
188
- autoPlay: (playType)=>sliderRef.current.innerSlider.autoPlay(playType),
195
+ goTo: (slide, dontAnimate = false)=>sliderRef.current?.slickGoTo(slide, dontAnimate),
196
+ next: ()=>sliderRef.current?.slickNext(),
197
+ prev: ()=>sliderRef.current?.slickPrev(),
198
+ autoPlay: (playType)=>sliderRef.current?.innerSlider?.autoPlay(playType),
189
199
  get innerSlider () {
190
- return sliderRef.current.innerSlider;
200
+ return sliderRef.current?.innerSlider;
191
201
  }
192
202
  }), []);
193
203
  useEffect(()=>{
194
- if (count > 0 && !unslick) sliderRef.current.slickGoTo(isRtl ? count - initialSlide - 1 : initialSlide, true);
204
+ const root = rootRef.current;
205
+ if (!root) return;
206
+ const syncSlides = ()=>{
207
+ for (const slide_0 of root.querySelectorAll('.slick-slide[aria-hidden]'))if (slide_0.closest('[data-tao-carousel]') === root) slide_0.toggleAttribute('inert', 'true' === slide_0.getAttribute('aria-hidden'));
208
+ };
209
+ syncSlides();
210
+ const observer = new MutationObserver(syncSlides);
211
+ observer.observe(root, {
212
+ subtree: true,
213
+ childList: true,
214
+ attributes: true,
215
+ attributeFilter: [
216
+ 'aria-hidden'
217
+ ]
218
+ });
219
+ return ()=>observer.disconnect();
220
+ }, []);
221
+ useEffect(()=>{
222
+ const previous = previousPosition.current;
223
+ previousPosition.current = {
224
+ ready,
225
+ isRtl,
226
+ initialSlide,
227
+ slickGoTo
228
+ };
229
+ if (!ready) return;
230
+ if (void 0 !== slickGoTo) {
231
+ if (!previous?.ready || previous.slickGoTo !== slickGoTo) sliderRef.current?.slickGoTo(slickGoTo);
232
+ } else if (!previous?.ready || previous.isRtl !== isRtl || previous.initialSlide !== initialSlide) sliderRef.current?.slickGoTo(isRtl ? count - initialSlide - 1 : initialSlide, true);
195
233
  }, [
196
234
  count,
197
235
  initialSlide,
198
236
  isRtl,
199
- unslick
200
- ]);
201
- useEffect(()=>{
202
- if (void 0 !== slickGoTo && !unslick) sliderRef.current.slickGoTo(slickGoTo);
203
- }, [
204
- slickGoTo,
205
- unslick
237
+ ready,
238
+ slickGoTo
206
239
  ]);
207
240
  return /*#__PURE__*/ jsx("div", {
208
241
  ref: mergedRootRef,
@@ -233,6 +266,10 @@ const carousel_Carousel = /*#__PURE__*/ forwardRef(function(props, ref) {
233
266
  style: styles?.dots,
234
267
  children: items
235
268
  })),
269
+ customPaging: customPaging ?? ((index)=>/*#__PURE__*/ jsx("button", {
270
+ type: "button",
271
+ children: index + 1
272
+ })),
236
273
  arrows: arrows,
237
274
  prevArrow: prevArrow ?? /*#__PURE__*/ jsx(Arrow, {
238
275
  "aria-label": isRtl ? locale.next : locale.previous
@@ -1,6 +1,9 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import cascader, { Panel } from "@rc-component/cascader";
4
+ import { fillFieldNames } from "@rc-component/cascader/es/utils/commonUtil";
5
+ import { toPathOptions } from "@rc-component/cascader/es/utils/treeUtil";
6
+ import isEqual from "@rc-component/util/es/isEqual";
4
7
  import { forwardRef, useMemo, useRef, useState } from "react";
5
8
  import { createPortal } from "react-dom";
6
9
  import { useTaoDirection, useTaoInternalConfig } from "../../provider/tao-provider.js";
@@ -64,6 +67,7 @@ function InternalCascader(props, ref) {
64
67
  const [mobilePresentation, setMobilePresentation] = useState(requestedMobile);
65
68
  if ((!open || void 0 === mobilePresentation) && mobilePresentation !== requestedMobile) setMobilePresentation(requestedMobile);
66
69
  const isMobile = (open ? mobilePresentation : requestedMobile) ?? false;
70
+ const mobileOpen = isMobile && !!open && !disabled;
67
71
  const title = useMobileTitle(mobileTitle, config.locale.select);
68
72
  const triggerRef = useRef(null);
69
73
  const [direction, directionRef] = useTaoDirection(props.direction);
@@ -72,15 +76,21 @@ function InternalCascader(props, ref) {
72
76
  directionRef
73
77
  ]);
74
78
  const [internalValue, setInternalValue] = useState(defaultValue);
75
- const value = void 0 !== valueProp ? valueProp : internalValue;
79
+ const value = 'value' in props ? valueProp : internalValue;
76
80
  const [draft, setDraft] = useState();
77
- const [previousOpen, setPreviousOpen] = useState(open);
78
- if (previousOpen !== open) {
79
- setPreviousOpen(open);
81
+ const draftSource = mobileOpen && multiple ? value ?? null : void 0;
82
+ const [previousDraftSource, setPreviousDraftSource] = useState(draftSource);
83
+ if (!isEqual(previousDraftSource, draftSource)) {
84
+ setPreviousDraftSource(draftSource);
80
85
  setDraft(void 0);
81
86
  }
82
87
  const [mobileContainer, setMobileContainer] = useState(null);
83
88
  const [internalSearch, setInternalSearch] = useState('');
89
+ const [previousMobileOpen, setPreviousMobileOpen] = useState(mobileOpen);
90
+ if (previousMobileOpen !== mobileOpen) {
91
+ setPreviousMobileOpen(mobileOpen);
92
+ if (!mobileOpen) setInternalSearch('');
93
+ }
84
94
  const searchConfig = 'object' == typeof showSearch ? showSearch : {};
85
95
  const searchValue = searchConfig.searchValue ?? searchValueProp ?? internalSearch;
86
96
  const changeSearch = (next)=>{
@@ -88,11 +98,12 @@ function InternalCascader(props, ref) {
88
98
  (searchConfig.onSearch ?? onSearch)?.(next);
89
99
  };
90
100
  const changeOpen = (next_0)=>{
91
- setInternalOpen(next_0);
92
- setDraft(void 0);
93
- if (!next_0 && isMobile) {
94
- if (searchValue) changeSearch('');
95
- triggerRef.current?.focus();
101
+ if (void 0 === openProp) {
102
+ setInternalOpen(next_0);
103
+ if (!next_0 && isMobile) {
104
+ if (searchValue) changeSearch('');
105
+ triggerRef.current?.focus();
106
+ }
96
107
  }
97
108
  (onOpenChange ?? onPopupVisibleChange ?? onDropdownVisibleChange)?.(next_0);
98
109
  };
@@ -101,9 +112,13 @@ function InternalCascader(props, ref) {
101
112
  onChange?.(...args);
102
113
  };
103
114
  const changeValue = (...args_0)=>{
104
- if (isMobile && open && multiple) return void setDraft(args_0);
115
+ if (mobileOpen && multiple) {
116
+ setDraft(args_0[0]);
117
+ if (searchConfig.autoClearSearchValue ?? props.autoClearSearchValue ?? true) setInternalSearch('');
118
+ return;
119
+ }
105
120
  commit(...args_0);
106
- if (isMobile && open) {
121
+ if (mobileOpen) {
107
122
  const selected = args_0[1];
108
123
  const last = selected?.at(-1);
109
124
  const children = last?.[props.fieldNames?.children ?? 'children'];
@@ -115,8 +130,10 @@ function InternalCascader(props, ref) {
115
130
  if (searchValue && ('ArrowLeft' === event.key || 'ArrowRight' === event.key)) return;
116
131
  const keyCode = NAVIGATION_KEYS[event.key];
117
132
  if (!keyCode) return;
118
- event.preventDefault();
119
- triggerRef.current?.nativeElement.querySelector('input')?.dispatchEvent(new KeyboardEvent('keydown', {
133
+ if ('keydown' === event.type) event.preventDefault();
134
+ const trigger = triggerRef.current?.nativeElement;
135
+ const target = props.children ? trigger : trigger?.querySelector('input');
136
+ target?.dispatchEvent(new KeyboardEvent(event.type, {
120
137
  key: event.key,
121
138
  keyCode,
122
139
  which: keyCode,
@@ -131,7 +148,7 @@ function InternalCascader(props, ref) {
131
148
  direction: direction,
132
149
  dir: direction,
133
150
  open: open,
134
- value: (isMobile && open && multiple && draft ? draft[0] : value) ?? [],
151
+ value: (mobileOpen && multiple ? draft ?? value : value) ?? [],
135
152
  onChange: changeValue,
136
153
  showSearch: isMobile && showSearch ? {
137
154
  ...searchConfig,
@@ -208,7 +225,7 @@ function InternalCascader(props, ref) {
208
225
  }
209
226
  }),
210
227
  isMobile && /*#__PURE__*/ jsxs(Drawer, {
211
- open: open && !disabled,
228
+ open: mobileOpen,
212
229
  onClose: ()=>changeOpen(false),
213
230
  placement: "bottom",
214
231
  title: title,
@@ -226,7 +243,22 @@ function InternalCascader(props, ref) {
226
243
  },
227
244
  disabled: disabled,
228
245
  onClick: ()=>{
229
- if (draft) commit(...draft);
246
+ if (draft) {
247
+ const fields = fillFieldNames(props.fieldNames);
248
+ const original = value ?? [];
249
+ const available = draft.flatMap((path)=>{
250
+ const selected_0 = toPathOptions(path, props.options ?? [], fields).map(({ option })=>option);
251
+ const selectable = selected_0.every(Boolean) && !selected_0.at(-1)?.disabled;
252
+ return selectable || original.some((committed)=>isEqual(committed, path)) ? [
253
+ {
254
+ path,
255
+ selected: selected_0
256
+ }
257
+ ] : [];
258
+ });
259
+ const paths = available.map(({ path: path_0 })=>path_0);
260
+ if (!isEqual(paths, original)) commit(paths, available.map(({ selected: selected_1 })=>selected_1));
261
+ }
230
262
  changeOpen(false);
231
263
  },
232
264
  children: config.locale.done
@@ -240,7 +272,8 @@ function InternalCascader(props, ref) {
240
272
  value: searchValue,
241
273
  disabled: disabled,
242
274
  onChange: (event_0)=>changeSearch(event_0.target.value),
243
- onKeyDown: navigateMobile
275
+ onKeyDown: navigateMobile,
276
+ onKeyUp: navigateMobile
244
277
  }),
245
278
  /*#__PURE__*/ jsx("fieldset", {
246
279
  "data-tao-cascader-mobile-container": "",
@@ -248,7 +281,8 @@ function InternalCascader(props, ref) {
248
281
  ref: setMobileContainer,
249
282
  "aria-label": config.locale.select,
250
283
  tabIndex: showSearch ? -1 : 0,
251
- onKeyDown: navigateMobile
284
+ onKeyDown: navigateMobile,
285
+ onKeyUp: navigateMobile
252
286
  })
253
287
  ]
254
288
  })
@@ -259,7 +293,7 @@ function CascaderPanel(props) {
259
293
  const config = useTaoInternalConfig();
260
294
  const { multiple, className, rootClassName, style, prefixCls = 'tao-cascader', disabled = config.disabled, notFoundContent = config.locale.noResults, expandIcon = /*#__PURE__*/ jsx(ExpandIcon, {}), loadingIcon = /*#__PURE__*/ jsx(Spinner, {
261
295
  size: "small"
262
- }), ...rest } = props;
296
+ }), value, ...rest } = props;
263
297
  const [direction, directionRef] = useTaoDirection(props.direction);
264
298
  return /*#__PURE__*/ jsx("div", {
265
299
  ref: directionRef,
@@ -271,6 +305,7 @@ function CascaderPanel(props) {
271
305
  children: /*#__PURE__*/ jsx(Panel, {
272
306
  ...rest,
273
307
  direction: direction,
308
+ value: 'value' in props ? value ?? [] : void 0,
274
309
  prefixCls: prefixCls,
275
310
  checkable: multiple,
276
311
  disabled: disabled,
@@ -1,4 +1,5 @@
1
1
  [data-tao-checkbox-wrapper] {
2
+ --tao-checkbox-size: 16px;
2
3
  align-items: center;
3
4
  gap: var(--tao-padding-xs);
4
5
  cursor: pointer;
@@ -11,6 +12,16 @@
11
12
  display: inline-flex;
12
13
  }
13
14
 
15
+ [data-tao-checkbox-wrapper][data-tao-size="small"] {
16
+ --tao-checkbox-size: 14px;
17
+ font-size: var(--tao-font-size-sm);
18
+ }
19
+
20
+ [data-tao-checkbox-wrapper][data-tao-size="large"] {
21
+ --tao-checkbox-size: 20px;
22
+ font-size: var(--tao-font-size-lg);
23
+ }
24
+
14
25
  [data-tao-checkbox-wrapper][data-tao-disabled] {
15
26
  cursor: not-allowed;
16
27
  opacity: var(--tao-opacity-loading);
@@ -32,11 +43,11 @@
32
43
  }
33
44
 
34
45
  [data-tao-checkbox] {
46
+ width: var(--tao-checkbox-size);
47
+ height: var(--tao-checkbox-size);
35
48
  border: var(--tao-line-width) solid var(--tao-color-border);
36
49
  border-radius: var(--tao-radius-sm);
37
50
  background: var(--tao-color-bg-container);
38
- width: 16px;
39
- height: 16px;
40
51
  transition: background-color var(--tao-motion-duration-fast) var(--tao-motion-ease-out),
41
52
  border-color var(--tao-motion-duration-fast) var(--tao-motion-ease-out),
42
53
  box-shadow var(--tao-motion-duration-fast) var(--tao-motion-ease-out);
@@ -9,6 +9,8 @@ export interface CheckboxProps extends Pick<AriaAttributes, 'aria-label' | 'aria
9
9
  defaultChecked?: boolean;
10
10
  indeterminate?: boolean;
11
11
  disabled?: boolean;
12
+ /** Require a checked value when submitting a native form. */
13
+ required?: boolean;
12
14
  onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
13
15
  value?: string;
14
16
  children?: ReactNode;