react-kui 3.2.1 → 3.3.0

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 (352) hide show
  1. package/ai/kui-components.json +819 -162
  2. package/es/_virtual/_rolldown/runtime.js +2 -3
  3. package/es/affix/index.js +73 -185
  4. package/es/alert/index.js +3 -4
  5. package/es/anchor/anchor-context.js +2 -3
  6. package/es/anchor/anchor-link.js +3 -4
  7. package/es/anchor/anchor.js +195 -398
  8. package/es/auto-complete/index.js +160 -561
  9. package/es/avatar/avatar-group-context.js +2 -3
  10. package/es/avatar/avatar-group.js +32 -124
  11. package/es/avatar/avatar.js +58 -159
  12. package/es/back-top/index.js +66 -201
  13. package/es/badge/index.js +4 -5
  14. package/es/base/teleport.js +22 -54
  15. package/es/base/transition-props.js +2 -3
  16. package/es/base/transition.js +2 -3
  17. package/es/breadcrumb/breadcrumb-context.js +2 -3
  18. package/es/breadcrumb/breadcrumb-item.js +19 -102
  19. package/es/breadcrumb/breadcrumb.js +10 -59
  20. package/es/button/button-group-context.js +2 -3
  21. package/es/button/button-group.js +15 -75
  22. package/es/button/button.js +4 -5
  23. package/es/calendar/index.js +4 -5
  24. package/es/card/index.js +4 -5
  25. package/es/carousel/carousel-context.js +2 -3
  26. package/es/carousel/carousel-item.js +3 -4
  27. package/es/carousel/carousel.js +281 -628
  28. package/es/carousel/drag.js +2 -3
  29. package/es/cascader/index.js +7 -8
  30. package/es/check-card/check-card-group.js +53 -179
  31. package/es/check-card/check-card.js +100 -293
  32. package/es/check-card/context.js +2 -3
  33. package/es/checkbox/checkbox-group-context.js +2 -3
  34. package/es/checkbox/checkbox-group.js +34 -138
  35. package/es/checkbox/checkbox.js +4 -5
  36. package/es/checkbox/index.js +2 -3
  37. package/es/collapse/collapse-panel.js +84 -206
  38. package/es/collapse/collapse.js +38 -170
  39. package/es/color-picker/alpha.js +44 -125
  40. package/es/color-picker/hue.js +39 -108
  41. package/es/color-picker/index.js +7 -6
  42. package/es/color-picker/mode.js +76 -159
  43. package/es/color-picker/paint.js +66 -163
  44. package/es/color-picker/presets.js +12 -44
  45. package/es/components.js +37 -32
  46. package/es/config/config-context.js +2 -3
  47. package/es/config/context.js +2 -3
  48. package/es/config/index.js +3 -4
  49. package/es/config/popup-host.js +3 -4
  50. package/es/config/size-context.js +2 -3
  51. package/es/config/use-config-appearance.js +3 -4
  52. package/es/const/var.js +2 -3
  53. package/es/date-picker/index.js +8 -9
  54. package/es/descriptions/descriptions-item.js +3 -4
  55. package/es/descriptions/descriptions.js +53 -144
  56. package/es/divider/index.js +2 -3
  57. package/es/drawer/index.js +171 -465
  58. package/es/dropdown/dropdown-button.js +25 -128
  59. package/es/dropdown/dropdown-context.js +2 -3
  60. package/es/dropdown/dropdown.js +56 -207
  61. package/es/dropdown/trigger.js +37 -125
  62. package/es/empty/index.js +34 -111
  63. package/es/feature-card/index.js +2 -3
  64. package/es/feedback-panel/index.js +30 -155
  65. package/es/flame-wrap/index.js +3 -4
  66. package/es/flame-wrap/types.js +2 -3
  67. package/es/flex/index.js +2 -3
  68. package/es/form/field-context.js +3 -4
  69. package/es/form/form-context.js +2 -3
  70. package/es/form/form-item.js +4 -5
  71. package/es/form/form.js +108 -279
  72. package/es/form/utils.js +2 -3
  73. package/es/gradient-picker/corners.js +55 -0
  74. package/es/gradient-picker/index.js +191 -0
  75. package/es/gradient-picker/stops.js +219 -0
  76. package/es/gradient-picker/types.js +147 -0
  77. package/es/grid/grid-item.js +25 -116
  78. package/es/grid/grid.js +40 -151
  79. package/es/grid/useBreakpoint.js +3 -4
  80. package/es/icon/index.js +24 -126
  81. package/es/image/group.js +3 -4
  82. package/es/image/image-group-context.js +2 -3
  83. package/es/image/image.js +5 -6
  84. package/es/image/instance.js +2 -3
  85. package/es/image/preview.js +4 -5
  86. package/es/image/utils.js +2 -3
  87. package/es/index.js +5 -4
  88. package/es/input/index.js +2 -3
  89. package/es/input/input-base.js +4 -5
  90. package/es/input/input-box.js +2 -3
  91. package/es/input/input-group.js +4 -5
  92. package/es/input/input.js +3 -4
  93. package/es/input/textarea.js +3 -4
  94. package/es/input-number/drag.js +63 -0
  95. package/es/input-number/index.js +41 -11
  96. package/es/input-otp/index.js +3 -4
  97. package/es/input-tag/index.js +5 -6
  98. package/es/kanban/index.js +31 -168
  99. package/es/layout/index.js +43 -215
  100. package/es/layout/layout-context.js +2 -3
  101. package/es/list-panel/index.js +47 -185
  102. package/es/loading/index.js +2 -3
  103. package/es/loading/loading-bar.js +54 -114
  104. package/es/locale/de.js +2 -3
  105. package/es/locale/el.js +2 -3
  106. package/es/locale/en.js +2 -3
  107. package/es/locale/fr.js +2 -3
  108. package/es/locale/it.js +2 -3
  109. package/es/locale/ja.js +2 -3
  110. package/es/locale/ko.js +2 -3
  111. package/es/locale/ru.js +2 -3
  112. package/es/locale/th.js +2 -3
  113. package/es/locale/uk.js +2 -3
  114. package/es/locale/vi.js +2 -3
  115. package/es/locale/zh-CN.js +2 -3
  116. package/es/locale/zh-TW.js +2 -3
  117. package/es/mentions/index.js +214 -581
  118. package/es/menu/menu-context.js +2 -3
  119. package/es/menu/menu-divider.js +3 -4
  120. package/es/menu/menu-group.js +3 -4
  121. package/es/menu/menu-item.js +2 -3
  122. package/es/menu/menu-keyboard.js +2 -3
  123. package/es/menu/menu.js +184 -442
  124. package/es/menu/recursive-menu.js +3 -4
  125. package/es/menu/sub-menu.js +5 -6
  126. package/es/message/index.js +2 -3
  127. package/es/modal/api.js +2 -3
  128. package/es/modal/modal.js +263 -599
  129. package/es/modal/toast.js +63 -179
  130. package/es/node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js +2 -3
  131. package/es/notice/container.js +2 -3
  132. package/es/notice/content.js +4 -5
  133. package/es/notice/index.js +2 -3
  134. package/es/notice/instance.js +2 -3
  135. package/es/page/index.js +4 -5
  136. package/es/page/responsive.js +2 -3
  137. package/es/page-header/index.js +3 -4
  138. package/es/popconfirm/index.js +24 -70
  139. package/es/poptip/index.js +29 -88
  140. package/es/popup/index.js +8 -6
  141. package/es/popup/layers.js +2 -3
  142. package/es/progress/index.js +95 -229
  143. package/es/qrcode/index.js +3 -4
  144. package/es/radio/radio-button.js +37 -131
  145. package/es/radio/radio-group-context.js +2 -3
  146. package/es/radio/radio-group.js +69 -223
  147. package/es/radio/radio.js +3 -4
  148. package/es/rate/index.js +68 -226
  149. package/es/rate/star.js +38 -129
  150. package/es/result/index.js +35 -127
  151. package/es/ripple/index.js +3 -4
  152. package/es/ripple/types.js +2 -3
  153. package/es/row-col/col.js +59 -149
  154. package/es/row-col/row.js +2 -3
  155. package/es/segmented/index.js +66 -210
  156. package/es/select/option.js +23 -116
  157. package/es/select/select.js +9 -10
  158. package/es/skeleton/skeleton-avatar.js +2 -3
  159. package/es/skeleton/skeleton-button.js +2 -3
  160. package/es/skeleton/skeleton-image.js +28 -108
  161. package/es/skeleton/skeleton-text.js +17 -93
  162. package/es/skeleton/skeleton.js +46 -133
  163. package/es/skeleton/use-skeleton-loading.js +3 -4
  164. package/es/slider/index.js +92 -286
  165. package/es/slider/thumb.js +43 -133
  166. package/es/space/index.js +3 -4
  167. package/es/spin/index.js +2 -3
  168. package/es/splitter/splitter-panel.js +3 -4
  169. package/es/splitter/splitter.js +77 -219
  170. package/es/stat-card/countup.js +46 -141
  171. package/es/stat-card/rollup.js +27 -105
  172. package/es/stat-card/stat-card.js +3 -4
  173. package/es/stat-card/stat-number.js +26 -113
  174. package/es/stat-card/utils/countup.js +2 -3
  175. package/es/stat-card/utils/odometer.js +2 -3
  176. package/es/stat-card/utils/stat-item-key.js +2 -3
  177. package/es/steps/index.js +45 -123
  178. package/es/switch/index.js +4 -5
  179. package/es/table/column-setting.js +43 -139
  180. package/es/table/index.js +8 -9
  181. package/es/table/utils.js +2 -3
  182. package/es/tabs/tab-panel.js +19 -71
  183. package/es/tabs/tabs.js +6 -7
  184. package/es/tag/index.js +4 -5
  185. package/es/time-line/timeline-item.js +3 -4
  186. package/es/time-line/timeline.js +8 -44
  187. package/es/tooltip/index.js +41 -142
  188. package/es/tour/index.js +138 -356
  189. package/es/transfer/index.js +184 -487
  190. package/es/tree/index.js +8 -9
  191. package/es/tree/utils.js +2 -3
  192. package/es/tree-select/index.js +8 -9
  193. package/es/typography/index.js +75 -306
  194. package/es/upload/file-list.js +95 -119
  195. package/es/upload/index.js +8 -9
  196. package/es/upload/picture-sort.js +2 -3
  197. package/es/upload/selector.js +63 -193
  198. package/es/utils/checked.js +2 -3
  199. package/es/utils/color.js +2 -3
  200. package/es/utils/css.js +2 -3
  201. package/es/utils/focus.js +2 -3
  202. package/es/utils/number.js +2 -3
  203. package/es/utils/overlay-order.js +2 -3
  204. package/es/utils/overlay-stack.js +3 -4
  205. package/es/utils/placement.js +16 -4
  206. package/es/utils/popup-arrow.js +45 -0
  207. package/es/utils/popup.js +2 -3
  208. package/es/utils/promise.js +2 -3
  209. package/es/utils/react-node.js +2 -3
  210. package/es/utils/selection-tags.js +2 -3
  211. package/es/utils/share.js +2 -3
  212. package/es/utils/theme.js +2 -3
  213. package/es/utils/transition.js +2 -3
  214. package/es/utils/use-value.js +3 -4
  215. package/es/virtual-list/index.js +49 -187
  216. package/es/virtual-list/range.js +2 -3
  217. package/es/watermark/index.js +149 -289
  218. package/lib/index.cjs +2 -2
  219. package/lib/locale/de.cjs +1 -1
  220. package/lib/locale/el.cjs +1 -1
  221. package/lib/locale/en.cjs +1 -1
  222. package/lib/locale/fr.cjs +1 -1
  223. package/lib/locale/it.cjs +1 -1
  224. package/lib/locale/ja.cjs +1 -1
  225. package/lib/locale/ko.cjs +1 -1
  226. package/lib/locale/ru.cjs +1 -1
  227. package/lib/locale/th.cjs +1 -1
  228. package/lib/locale/uk.cjs +1 -1
  229. package/lib/locale/vi.cjs +1 -1
  230. package/lib/locale/zh-CN.cjs +1 -1
  231. package/lib/locale/zh-TW.cjs +1 -1
  232. package/package.json +24 -24
  233. package/style/base.css +1 -1
  234. package/style/components.css +2 -2
  235. package/style/index.css +2 -2
  236. package/style/theme.css +1 -1
  237. package/types/affix/index.d.cts +1 -1
  238. package/types/affix/index.d.ts +1 -1
  239. package/types/anchor/anchor-link.d.cts +1 -1
  240. package/types/anchor/anchor-link.d.ts +1 -1
  241. package/types/anchor/anchor.d.cts +1 -1
  242. package/types/anchor/anchor.d.ts +1 -1
  243. package/types/back-top/index.d.cts +1 -1
  244. package/types/back-top/index.d.ts +1 -1
  245. package/types/carousel/carousel-item.d.cts +1 -1
  246. package/types/carousel/carousel-item.d.ts +1 -1
  247. package/types/cascader/index.d.cts +1 -1
  248. package/types/cascader/index.d.ts +1 -1
  249. package/types/color-picker/alpha.d.cts +1 -1
  250. package/types/color-picker/alpha.d.ts +1 -1
  251. package/types/color-picker/hue.d.cts +1 -1
  252. package/types/color-picker/hue.d.ts +1 -1
  253. package/types/color-picker/index.d.cts +3 -2
  254. package/types/color-picker/index.d.ts +3 -2
  255. package/types/color-picker/mode.d.cts +1 -1
  256. package/types/color-picker/mode.d.ts +1 -1
  257. package/types/color-picker/paint.d.cts +1 -1
  258. package/types/color-picker/paint.d.ts +1 -1
  259. package/types/color-picker/presets.d.cts +1 -1
  260. package/types/color-picker/presets.d.ts +1 -1
  261. package/types/components.d.cts +3 -0
  262. package/types/components.d.ts +3 -0
  263. package/types/date-picker/index.d.cts +2 -2
  264. package/types/date-picker/index.d.ts +2 -2
  265. package/types/feature-card/index.d.cts +1 -1
  266. package/types/feature-card/index.d.ts +1 -1
  267. package/types/feedback-panel/index.d.cts +1 -1
  268. package/types/feedback-panel/index.d.ts +1 -1
  269. package/types/flame-wrap/index.d.cts +1 -1
  270. package/types/flame-wrap/index.d.ts +1 -1
  271. package/types/form/form-item.d.cts +1 -1
  272. package/types/form/form-item.d.ts +1 -1
  273. package/types/gradient-picker/corners.d.cts +8 -0
  274. package/types/gradient-picker/corners.d.ts +8 -0
  275. package/types/gradient-picker/index.d.cts +25 -0
  276. package/types/gradient-picker/index.d.ts +25 -0
  277. package/types/gradient-picker/stops.d.cts +12 -0
  278. package/types/gradient-picker/stops.d.ts +12 -0
  279. package/types/gradient-picker/types.d.cts +34 -0
  280. package/types/gradient-picker/types.d.ts +34 -0
  281. package/types/grid/grid-item.d.cts +1 -1
  282. package/types/grid/grid-item.d.ts +1 -1
  283. package/types/grid/grid.d.cts +1 -1
  284. package/types/grid/grid.d.ts +1 -1
  285. package/types/image/group.d.cts +1 -1
  286. package/types/image/group.d.ts +1 -1
  287. package/types/input-number/drag.d.cts +9 -0
  288. package/types/input-number/drag.d.ts +9 -0
  289. package/types/input-number/index.d.cts +1 -0
  290. package/types/input-number/index.d.ts +1 -0
  291. package/types/kanban/index.d.cts +1 -1
  292. package/types/kanban/index.d.ts +1 -1
  293. package/types/list-panel/index.d.cts +1 -1
  294. package/types/list-panel/index.d.ts +1 -1
  295. package/types/loading/loading-bar.d.cts +1 -1
  296. package/types/loading/loading-bar.d.ts +1 -1
  297. package/types/modal/toast.d.cts +1 -1
  298. package/types/modal/toast.d.ts +1 -1
  299. package/types/notice/content.d.cts +2 -2
  300. package/types/notice/content.d.ts +2 -2
  301. package/types/page-header/index.d.cts +1 -1
  302. package/types/page-header/index.d.ts +1 -1
  303. package/types/popconfirm/index.d.cts +1 -0
  304. package/types/popconfirm/index.d.ts +1 -0
  305. package/types/poptip/index.d.cts +1 -0
  306. package/types/poptip/index.d.ts +1 -0
  307. package/types/popup/index.d.cts +1 -0
  308. package/types/popup/index.d.ts +1 -0
  309. package/types/result/index.d.cts +1 -1
  310. package/types/result/index.d.ts +1 -1
  311. package/types/ripple/index.d.cts +1 -1
  312. package/types/ripple/index.d.ts +1 -1
  313. package/types/slider/index.d.cts +1 -1
  314. package/types/slider/index.d.ts +1 -1
  315. package/types/splitter/splitter-panel.d.cts +1 -1
  316. package/types/splitter/splitter-panel.d.ts +1 -1
  317. package/types/splitter/splitter.d.cts +1 -1
  318. package/types/splitter/splitter.d.ts +1 -1
  319. package/types/stat-card/countup.d.cts +1 -1
  320. package/types/stat-card/countup.d.ts +1 -1
  321. package/types/stat-card/rollup.d.cts +1 -1
  322. package/types/stat-card/rollup.d.ts +1 -1
  323. package/types/stat-card/stat-card.d.cts +1 -1
  324. package/types/stat-card/stat-card.d.ts +1 -1
  325. package/types/stat-card/stat-number.d.cts +1 -1
  326. package/types/stat-card/stat-number.d.ts +1 -1
  327. package/types/table/column-setting.d.cts +1 -1
  328. package/types/table/column-setting.d.ts +1 -1
  329. package/types/table/index.d.cts +1 -1
  330. package/types/table/index.d.ts +1 -1
  331. package/types/time-line/timeline-item.d.cts +1 -1
  332. package/types/time-line/timeline-item.d.ts +1 -1
  333. package/types/time-line/timeline.d.cts +1 -1
  334. package/types/time-line/timeline.d.ts +1 -1
  335. package/types/tooltip/index.d.cts +1 -0
  336. package/types/tooltip/index.d.ts +1 -0
  337. package/types/transfer/index.d.cts +1 -1
  338. package/types/transfer/index.d.ts +1 -1
  339. package/types/tree-select/index.d.cts +1 -1
  340. package/types/tree-select/index.d.ts +1 -1
  341. package/types/upload/file-list.d.cts +1 -1
  342. package/types/upload/file-list.d.ts +1 -1
  343. package/types/upload/selector.d.cts +1 -1
  344. package/types/upload/selector.d.ts +1 -1
  345. package/types/utils/placement.d.cts +2 -1
  346. package/types/utils/placement.d.ts +2 -1
  347. package/types/utils/popup-arrow.d.cts +5 -0
  348. package/types/utils/popup-arrow.d.ts +5 -0
  349. package/types/utils/selection-tags.d.cts +1 -1
  350. package/types/utils/selection-tags.d.ts +1 -1
  351. package/types/watermark/index.d.cts +1 -1
  352. package/types/watermark/index.d.ts +1 -1
@@ -1,156 +1,66 @@
1
1
  /*!
2
- * react-kui v3.2.1
2
+ * react-kui v3.3.0
3
3
  * Copyright 2017-present, kui-react.
4
4
  * All rights reserved.
5
5
  * Homepage: https://react.k-ui.cn
6
6
  * Author: Qiu / https://chuchur.com
7
7
  */
8
8
 
9
- import { SURFACE_THEMES, resolvePaintedTheme, useFormAppearance } from "../config/use-config-appearance.js";
10
9
  import { useValue } from "../utils/use-value.js";
11
- import Button from "../button/button.js";
10
+ import { SURFACE_THEMES, resolvePaintedTheme, useFormAppearance } from "../config/use-config-appearance.js";
12
11
  import { createFormFieldComponent } from "../form/field-context.js";
12
+ import Button from "../button/button.js";
13
13
  import { RadioGroupContext } from "./radio-group-context.js";
14
- import { c } from "react/compiler-runtime";
15
14
  import React, { useContext } from "react";
16
15
  import { jsx } from "react/jsx-runtime";
17
- //#region components/radio/radio-button.tsx
18
- var RadioButton = React.forwardRef((t0, ref) => {
19
- const $ = c(41);
20
- let checked;
21
- let children;
22
- let icon;
23
- let label;
24
- let onChange;
25
- let onClick;
26
- let rest;
27
- let shapeProp;
28
- let sizeProp;
29
- let t1;
30
- let t2;
31
- let themeProp;
32
- let value;
33
- if ($[0] !== t0) {
34
- ({label, value, theme: themeProp, disabled: t1, readOnly: t2, checked, icon, size: sizeProp, shape: shapeProp, onChange, onClick, children, ...rest} = t0);
35
- $[0] = t0;
36
- $[1] = checked;
37
- $[2] = children;
38
- $[3] = icon;
39
- $[4] = label;
40
- $[5] = onChange;
41
- $[6] = onClick;
42
- $[7] = rest;
43
- $[8] = shapeProp;
44
- $[9] = sizeProp;
45
- $[10] = t1;
46
- $[11] = t2;
47
- $[12] = themeProp;
48
- $[13] = value;
49
- } else {
50
- checked = $[1];
51
- children = $[2];
52
- icon = $[3];
53
- label = $[4];
54
- onChange = $[5];
55
- onClick = $[6];
56
- rest = $[7];
57
- shapeProp = $[8];
58
- sizeProp = $[9];
59
- t1 = $[10];
60
- t2 = $[11];
61
- themeProp = $[12];
62
- value = $[13];
63
- }
64
- const disabled = t1 === void 0 ? false : t1;
65
- const readOnly = t2 === void 0 ? false : t2;
16
+ // components/radio/radio-button.tsx
17
+ var RadioButton = React.forwardRef(({ label, value, theme: themeProp, disabled = false, readOnly = false, checked, icon, size: sizeProp, shape: shapeProp, onChange, onClick, children, ...rest }, ref) => {
66
18
  const inheritedAppearance = useFormAppearance();
67
19
  const theme = themeProp ?? inheritedAppearance.theme;
68
20
  const size = sizeProp ?? inheritedAppearance.size;
69
21
  const shape = shapeProp ?? inheritedAppearance.shape;
70
22
  const group = useContext(RadioGroupContext);
71
23
  const isGroup = !!group;
72
- const [localChecked, setLocalChecked] = useValue(checked, _temp);
24
+ const [localChecked, setLocalChecked] = useValue(checked, (next) => next ?? false);
73
25
  const groupChecked = isGroup ? group.value === value : false;
74
26
  const isChecked = isGroup ? groupChecked : localChecked;
75
27
  const currentDisabled = disabled || isGroup && group.disabled;
76
28
  const currentReadOnly = readOnly || Boolean(isGroup && group.readOnly);
77
- const t3 = themeProp ?? group?.theme ?? theme;
78
- let t4;
79
- if ($[14] !== t3) {
80
- t4 = resolvePaintedTheme(t3, SURFACE_THEMES);
81
- $[14] = t3;
82
- $[15] = t4;
83
- } else t4 = $[15];
84
- const currentTheme = t4;
29
+ const currentTheme = resolvePaintedTheme(themeProp ?? group?.theme ?? theme, SURFACE_THEMES);
85
30
  const currentSize = sizeProp ?? group?.size ?? size;
86
31
  const currentShape = shapeProp ?? group?.shape ?? shape;
87
32
  const labelText = label ?? children ?? String(value ?? "");
88
- let t5;
89
- if ($[16] !== currentDisabled || $[17] !== currentReadOnly || $[18] !== group || $[19] !== isChecked || $[20] !== isGroup || $[21] !== label || $[22] !== onChange || $[23] !== onClick || $[24] !== setLocalChecked || $[25] !== value) {
90
- t5 = (e) => {
91
- onClick?.(e);
92
- if (e.defaultPrevented) return;
93
- if (currentDisabled || currentReadOnly || isChecked) return;
94
- if (!isGroup) setLocalChecked(true);
95
- const eventObj = {
96
- checked: true,
97
- value,
98
- label: label ?? String(value ?? "")
99
- };
100
- onChange?.(eventObj);
101
- group?.onChange?.(eventObj);
102
- e.preventDefault();
33
+ const handleClick = (e) => {
34
+ onClick?.(e);
35
+ if (e.defaultPrevented) return;
36
+ if (currentDisabled || currentReadOnly || isChecked) return;
37
+ const nextChecked = true;
38
+ if (!isGroup) setLocalChecked(nextChecked);
39
+ const eventObj = {
40
+ checked: nextChecked,
41
+ value,
42
+ label: label ?? String(value ?? "")
103
43
  };
104
- $[16] = currentDisabled;
105
- $[17] = currentReadOnly;
106
- $[18] = group;
107
- $[19] = isChecked;
108
- $[20] = isGroup;
109
- $[21] = label;
110
- $[22] = onChange;
111
- $[23] = onClick;
112
- $[24] = setLocalChecked;
113
- $[25] = value;
114
- $[26] = t5;
115
- } else t5 = $[26];
116
- const handleClick = t5;
117
- const t6 = isChecked ? "primary" : "default";
118
- const t7 = currentReadOnly || void 0;
119
- const t8 = isChecked ? 0 : -1;
120
- let t9;
121
- if ($[27] !== currentDisabled || $[28] !== currentShape || $[29] !== currentSize || $[30] !== currentTheme || $[31] !== handleClick || $[32] !== icon || $[33] !== isChecked || $[34] !== labelText || $[35] !== ref || $[36] !== rest || $[37] !== t6 || $[38] !== t7 || $[39] !== t8) {
122
- t9 = /* @__PURE__ */ jsx(Button, {
123
- ...rest,
124
- ref,
125
- disabled: currentDisabled,
126
- size: currentSize,
127
- icon,
128
- theme: currentTheme,
129
- shape: currentShape,
130
- type: t6,
131
- onClick: handleClick,
132
- role: "radio",
133
- "aria-checked": isChecked,
134
- "aria-readonly": t7,
135
- tabIndex: t8,
136
- children: labelText
137
- });
138
- $[27] = currentDisabled;
139
- $[28] = currentShape;
140
- $[29] = currentSize;
141
- $[30] = currentTheme;
142
- $[31] = handleClick;
143
- $[32] = icon;
144
- $[33] = isChecked;
145
- $[34] = labelText;
146
- $[35] = ref;
147
- $[36] = rest;
148
- $[37] = t6;
149
- $[38] = t7;
150
- $[39] = t8;
151
- $[40] = t9;
152
- } else t9 = $[40];
153
- return t9;
44
+ onChange?.(eventObj);
45
+ group?.onChange?.(eventObj);
46
+ e.preventDefault();
47
+ };
48
+ return /* @__PURE__ */ jsx(Button, {
49
+ ...rest,
50
+ ref,
51
+ disabled: currentDisabled,
52
+ size: currentSize,
53
+ icon,
54
+ theme: currentTheme,
55
+ shape: currentShape,
56
+ type: isChecked ? "primary" : "default",
57
+ onClick: handleClick,
58
+ role: "radio",
59
+ "aria-checked": isChecked,
60
+ "aria-readonly": currentReadOnly || void 0,
61
+ tabIndex: isChecked ? 0 : -1,
62
+ children: labelText
63
+ });
154
64
  });
155
65
  RadioButton.displayName = "RadioButton";
156
66
  var radio_button_default = createFormFieldComponent(RadioButton, {
@@ -158,8 +68,4 @@ var radio_button_default = createFormFieldComponent(RadioButton, {
158
68
  getFieldValue: (value) => value === true || value === 1 || value === "1",
159
69
  getChangeValue: (event) => event.checked
160
70
  });
161
- function _temp(next) {
162
- return next ?? false;
163
- }
164
- //#endregion
165
71
  export { radio_button_default as default };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * react-kui v3.2.1
2
+ * react-kui v3.3.0
3
3
  * Copyright 2017-present, kui-react.
4
4
  * All rights reserved.
5
5
  * Homepage: https://react.k-ui.cn
@@ -7,7 +7,6 @@
7
7
  */
8
8
 
9
9
  import { createContext } from "react";
10
- //#region components/radio/radio-group-context.ts
10
+ // components/radio/radio-group-context.ts
11
11
  var RadioGroupContext = createContext(null);
12
- //#endregion
13
12
  export { RadioGroupContext };
@@ -1,177 +1,70 @@
1
1
  /*!
2
- * react-kui v3.2.1
2
+ * react-kui v3.3.0
3
3
  * Copyright 2017-present, kui-react.
4
4
  * All rights reserved.
5
5
  * Homepage: https://react.k-ui.cn
6
6
  * Author: Qiu / https://chuchur.com
7
7
  */
8
8
 
9
- import { useFormAppearance } from "../config/use-config-appearance.js";
10
9
  import { useValue } from "../utils/use-value.js";
10
+ import { useFormAppearance } from "../config/use-config-appearance.js";
11
11
  import { createFormFieldComponent } from "../form/field-context.js";
12
- import { RadioGroupContext } from "./radio-group-context.js";
13
12
  import radio_default from "./radio.js";
14
13
  import radio_button_default from "./radio-button.js";
15
- import { c } from "react/compiler-runtime";
14
+ import { RadioGroupContext } from "./radio-group-context.js";
16
15
  import clsx from "clsx";
17
- import React, { useId, useRef } from "react";
16
+ import React, { useId, useMemo, useRef } from "react";
18
17
  import { jsx } from "react/jsx-runtime";
19
- //#region components/radio/radio-group.tsx
20
- var RadioGroup = (t0) => {
21
- const $ = c(65);
22
- let children;
23
- let onChange;
24
- let onKeyDown;
25
- let options;
26
- let rest;
27
- let shapeProp;
28
- let sizeProp;
29
- let t1;
30
- let t2;
31
- let t3;
32
- let t4;
33
- let themeProp;
34
- let type;
35
- let value;
36
- if ($[0] !== t0) {
37
- ({value, disabled: t1, readOnly: t2, direction: t3, size: sizeProp, theme: themeProp, shape: shapeProp, options, type, onChange, children, className: t4, onKeyDown, ...rest} = t0);
38
- $[0] = t0;
39
- $[1] = children;
40
- $[2] = onChange;
41
- $[3] = onKeyDown;
42
- $[4] = options;
43
- $[5] = rest;
44
- $[6] = shapeProp;
45
- $[7] = sizeProp;
46
- $[8] = t1;
47
- $[9] = t2;
48
- $[10] = t3;
49
- $[11] = t4;
50
- $[12] = themeProp;
51
- $[13] = type;
52
- $[14] = value;
53
- } else {
54
- children = $[1];
55
- onChange = $[2];
56
- onKeyDown = $[3];
57
- options = $[4];
58
- rest = $[5];
59
- shapeProp = $[6];
60
- sizeProp = $[7];
61
- t1 = $[8];
62
- t2 = $[9];
63
- t3 = $[10];
64
- t4 = $[11];
65
- themeProp = $[12];
66
- type = $[13];
67
- value = $[14];
68
- }
69
- const disabled = t1 === void 0 ? false : t1;
70
- const readOnly = t2 === void 0 ? false : t2;
71
- const direction = t3 === void 0 ? "horizontal" : t3;
72
- const className = t4 === void 0 ? "" : t4;
18
+ // components/radio/radio-group.tsx
19
+ var RadioGroup = ({ value, disabled = false, readOnly = false, direction = "horizontal", size: sizeProp, theme: themeProp, shape: shapeProp, options, type, onChange, children, className = "", onKeyDown, ...rest }) => {
73
20
  const inheritedAppearance = useFormAppearance();
74
21
  const size = sizeProp ?? inheritedAppearance.size;
75
22
  const theme = themeProp ?? inheritedAppearance.theme;
76
23
  const shape = shapeProp ?? inheritedAppearance.shape;
77
24
  const rootRef = useRef(null);
78
- const t5 = useId();
79
- let t6;
80
- if ($[15] !== t5) {
81
- let t7;
82
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
83
- t7 = /:/g;
84
- $[17] = t7;
85
- } else t7 = $[17];
86
- t6 = t5.replace(t7, "");
87
- $[15] = t5;
88
- $[16] = t6;
89
- } else t6 = $[16];
90
- const name = `k-radio-group-${t6}`;
91
- const [innerValue, setInnerValue] = useValue(value, _temp);
25
+ const name = `k-radio-group-${useId().replace(/:/g, "")}`;
26
+ const [innerValue, setInnerValue] = useValue(value, (next) => next ?? "");
92
27
  const currentValue = innerValue;
93
28
  const isVertical = direction === "vertical";
94
29
  const isButton = type === "button";
95
- let t7;
96
- if ($[18] !== onChange || $[19] !== readOnly || $[20] !== setInnerValue) {
97
- t7 = (event) => {
98
- if (readOnly || event.value === void 0) return;
99
- const nextValue = event.value;
100
- setInnerValue(nextValue);
101
- onChange?.(nextValue);
102
- };
103
- $[18] = onChange;
104
- $[19] = readOnly;
105
- $[20] = setInnerValue;
106
- $[21] = t7;
107
- } else t7 = $[21];
108
- const handleRadioChange = t7;
109
- const t8 = shape === "circle";
110
- const t9 = theme === "fill" && isButton;
111
- let t10;
112
- if ($[22] !== className || $[23] !== isButton || $[24] !== isVertical || $[25] !== t8 || $[26] !== t9) {
113
- t10 = clsx("k-radio-group", {
114
- "k-radio-button-group": isButton,
115
- "k-radio-group-circle": t8,
116
- "k-radio-group-fill": t9,
117
- "k-radio-group-vertical": isVertical
118
- }, className);
119
- $[22] = className;
120
- $[23] = isButton;
121
- $[24] = isVertical;
122
- $[25] = t8;
123
- $[26] = t9;
124
- $[27] = t10;
125
- } else t10 = $[27];
126
- const classes = t10;
30
+ const handleRadioChange = (event) => {
31
+ if (readOnly || event.value === void 0) return;
32
+ const nextValue = event.value;
33
+ setInnerValue(nextValue);
34
+ onChange?.(nextValue);
35
+ };
36
+ const classes = clsx("k-radio-group", {
37
+ "k-radio-button-group": isButton,
38
+ "k-radio-group-circle": shape === "circle",
39
+ "k-radio-group-fill": theme === "fill" && isButton,
40
+ "k-radio-group-vertical": isVertical
41
+ }, className);
127
42
  const Component = isButton ? radio_button_default : radio_default;
128
- let t11;
129
- bb0: {
130
- if (options && options.length > 0) {
131
- let t12;
132
- if ($[28] !== Component || $[29] !== disabled || $[30] !== options || $[31] !== readOnly || $[32] !== shape || $[33] !== size) {
133
- let t13;
134
- if ($[35] !== Component || $[36] !== disabled || $[37] !== readOnly || $[38] !== shape || $[39] !== size) {
135
- t13 = (option) => /* @__PURE__ */ jsx(Component, {
136
- label: option.label,
137
- value: option.value,
138
- disabled: disabled || option.disabled,
139
- readOnly,
140
- icon: option.icon,
141
- size,
142
- shape
143
- }, option.label ?? option.value);
144
- $[35] = Component;
145
- $[36] = disabled;
146
- $[37] = readOnly;
147
- $[38] = shape;
148
- $[39] = size;
149
- $[40] = t13;
150
- } else t13 = $[40];
151
- t12 = options.map(t13);
152
- $[28] = Component;
153
- $[29] = disabled;
154
- $[30] = options;
155
- $[31] = readOnly;
156
- $[32] = shape;
157
- $[33] = size;
158
- $[34] = t12;
159
- } else t12 = $[34];
160
- t11 = t12;
161
- break bb0;
162
- }
163
- let t12;
164
- if ($[41] !== children) {
165
- t12 = React.Children.map(children, _temp2);
166
- $[41] = children;
167
- $[42] = t12;
168
- } else t12 = $[42];
169
- t11 = t12;
170
- }
171
- const content = t11;
172
- let t12;
173
- if ($[43] !== currentValue || $[44] !== disabled || $[45] !== handleRadioChange || $[46] !== name || $[47] !== readOnly || $[48] !== shape || $[49] !== size || $[50] !== theme) {
174
- t12 = {
43
+ const content = useMemo(() => {
44
+ if (options && options.length > 0) return options.map((option) => /* @__PURE__ */ jsx(Component, {
45
+ label: option.label,
46
+ value: option.value,
47
+ disabled: disabled || option.disabled,
48
+ readOnly,
49
+ icon: option.icon,
50
+ size,
51
+ shape
52
+ }, option.label ?? option.value));
53
+ return React.Children.map(children, (child) => {
54
+ if (React.isValidElement(child)) return child;
55
+ return child;
56
+ });
57
+ }, [
58
+ options,
59
+ children,
60
+ disabled,
61
+ readOnly,
62
+ size,
63
+ shape,
64
+ Component
65
+ ]);
66
+ return /* @__PURE__ */ jsx(RadioGroupContext.Provider, {
67
+ value: {
175
68
  name,
176
69
  value: currentValue,
177
70
  disabled,
@@ -180,82 +73,35 @@ var RadioGroup = (t0) => {
180
73
  size,
181
74
  shape,
182
75
  onChange: handleRadioChange
183
- };
184
- $[43] = currentValue;
185
- $[44] = disabled;
186
- $[45] = handleRadioChange;
187
- $[46] = name;
188
- $[47] = readOnly;
189
- $[48] = shape;
190
- $[49] = size;
191
- $[50] = theme;
192
- $[51] = t12;
193
- } else t12 = $[51];
194
- const t13 = disabled || void 0;
195
- const t14 = readOnly || void 0;
196
- let t15;
197
- if ($[52] !== isButton || $[53] !== onKeyDown) {
198
- t15 = (event_0) => {
199
- onKeyDown?.(event_0);
200
- if (event_0.defaultPrevented) return;
201
- if (!isButton || ![
202
- "ArrowRight",
203
- "ArrowDown",
204
- "ArrowLeft",
205
- "ArrowUp"
206
- ].includes(event_0.key)) return;
207
- const buttons = [...rootRef.current?.querySelectorAll("[role=\"radio\"]:not([disabled])") ?? []];
208
- if (!buttons.length) return;
209
- event_0.preventDefault();
210
- const index = buttons.indexOf(event_0.target);
211
- const offset = event_0.key === "ArrowRight" || event_0.key === "ArrowDown" ? 1 : -1;
212
- const next_0 = buttons[(Math.max(index, 0) + offset + buttons.length) % buttons.length];
213
- next_0?.focus();
214
- next_0?.click();
215
- };
216
- $[52] = isButton;
217
- $[53] = onKeyDown;
218
- $[54] = t15;
219
- } else t15 = $[54];
220
- let t16;
221
- if ($[55] !== classes || $[56] !== content || $[57] !== rest || $[58] !== t13 || $[59] !== t14 || $[60] !== t15) {
222
- t16 = /* @__PURE__ */ jsx("div", {
76
+ },
77
+ children: /* @__PURE__ */ jsx("div", {
223
78
  ...rest,
224
79
  className: classes,
225
80
  ref: rootRef,
226
81
  role: "radiogroup",
227
- "aria-disabled": t13,
228
- "aria-readonly": t14,
229
- onKeyDown: t15,
82
+ "aria-disabled": disabled || void 0,
83
+ "aria-readonly": readOnly || void 0,
84
+ onKeyDown: (event_0) => {
85
+ onKeyDown?.(event_0);
86
+ if (event_0.defaultPrevented) return;
87
+ if (!isButton || ![
88
+ "ArrowRight",
89
+ "ArrowDown",
90
+ "ArrowLeft",
91
+ "ArrowUp"
92
+ ].includes(event_0.key)) return;
93
+ const buttons = [...rootRef.current?.querySelectorAll("[role=\"radio\"]:not([disabled])") ?? []];
94
+ if (!buttons.length) return;
95
+ event_0.preventDefault();
96
+ const index = buttons.indexOf(event_0.target);
97
+ const offset = event_0.key === "ArrowRight" || event_0.key === "ArrowDown" ? 1 : -1;
98
+ const next_0 = buttons[(Math.max(index, 0) + offset + buttons.length) % buttons.length];
99
+ next_0?.focus();
100
+ next_0?.click();
101
+ },
230
102
  children: content
231
- });
232
- $[55] = classes;
233
- $[56] = content;
234
- $[57] = rest;
235
- $[58] = t13;
236
- $[59] = t14;
237
- $[60] = t15;
238
- $[61] = t16;
239
- } else t16 = $[61];
240
- let t17;
241
- if ($[62] !== t12 || $[63] !== t16) {
242
- t17 = /* @__PURE__ */ jsx(RadioGroupContext.Provider, {
243
- value: t12,
244
- children: t16
245
- });
246
- $[62] = t12;
247
- $[63] = t16;
248
- $[64] = t17;
249
- } else t17 = $[64];
250
- return t17;
103
+ })
104
+ });
251
105
  };
252
106
  var radio_group_default = createFormFieldComponent(RadioGroup);
253
- function _temp(next) {
254
- return next ?? "";
255
- }
256
- function _temp2(child) {
257
- if (React.isValidElement(child)) return child;
258
- return child;
259
- }
260
- //#endregion
261
107
  export { radio_group_default as default };
package/es/radio/radio.js CHANGED
@@ -1,19 +1,19 @@
1
1
  /*!
2
- * react-kui v3.2.1
2
+ * react-kui v3.3.0
3
3
  * Copyright 2017-present, kui-react.
4
4
  * All rights reserved.
5
5
  * Homepage: https://react.k-ui.cn
6
6
  * Author: Qiu / https://chuchur.com
7
7
  */
8
8
 
9
- import { resolvePaintedTheme, useFormAppearance } from "../config/use-config-appearance.js";
10
9
  import { useValue } from "../utils/use-value.js";
10
+ import { resolvePaintedTheme, useFormAppearance } from "../config/use-config-appearance.js";
11
11
  import { createFormFieldComponent } from "../form/field-context.js";
12
12
  import { RadioGroupContext } from "./radio-group-context.js";
13
13
  import clsx from "clsx";
14
14
  import React, { useContext } from "react";
15
15
  import { jsx, jsxs } from "react/jsx-runtime";
16
- //#region components/radio/radio.tsx
16
+ // components/radio/radio.tsx
17
17
  var PAINTED_THEMES = ["fill", "outline"];
18
18
  var Radio = React.forwardRef(({ checked, value, label, theme: themeProp, size: sizeProp, onChange, children, className = "", id, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, disabled = false, readOnly = false, onClick, ...rest }, ref) => {
19
19
  const inheritedAppearance = useFormAppearance();
@@ -96,5 +96,4 @@ var radio_default = createFormFieldComponent(Radio, {
96
96
  getFieldValue: (value) => value === true || value === 1 || value === "1",
97
97
  getChangeValue: (event) => event.checked
98
98
  });
99
- //#endregion
100
99
  export { radio_default as default };