@rockshin/tao-ui 0.0.58 → 0.0.60

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 (111) hide show
  1. package/dist/components/affix/affix.js +38 -4
  2. package/dist/components/app/app-modals.js +11 -6
  3. package/dist/components/app/app-notices.js +105 -47
  4. package/dist/components/auto-complete/auto-complete.js +9 -2
  5. package/dist/components/calendar/calendar.js +22 -18
  6. package/dist/components/carousel/carousel.js +27 -14
  7. package/dist/components/cascader/cascader.js +18 -12
  8. package/dist/components/checkbox/checkbox.d.ts +3 -1
  9. package/dist/components/checkbox/checkbox.js +65 -58
  10. package/dist/components/color-picker/color-picker.css +1 -1
  11. package/dist/components/color-picker/color-picker.js +386 -362
  12. package/dist/components/context-menu/context-menu.d.ts +3 -1
  13. package/dist/components/context-menu/context-menu.js +48 -43
  14. package/dist/components/date-picker/calendar/calendar-grid.d.ts +5 -3
  15. package/dist/components/date-picker/calendar/calendar-grid.js +9 -4
  16. package/dist/components/date-picker/calendar/month-grid.d.ts +2 -1
  17. package/dist/components/date-picker/calendar/month-grid.js +61 -45
  18. package/dist/components/date-picker/calendar/time-panel.d.ts +8 -1
  19. package/dist/components/date-picker/calendar/time-panel.js +93 -88
  20. package/dist/components/date-picker/calendar/year-grid.d.ts +2 -1
  21. package/dist/components/date-picker/calendar/year-grid.js +60 -44
  22. package/dist/components/date-picker/date-picker.css +9 -0
  23. package/dist/components/date-picker/date-picker.js +25 -14
  24. package/dist/components/date-picker/range-picker.d.ts +2 -0
  25. package/dist/components/date-picker/range-picker.js +132 -73
  26. package/dist/components/date-picker/types.js +1 -1
  27. package/dist/components/drawer/drawer.d.ts +1 -1
  28. package/dist/components/drawer/drawer.js +4 -3
  29. package/dist/components/dropdown/dropdown.d.ts +1 -0
  30. package/dist/components/dropdown/dropdown.js +29 -21
  31. package/dist/components/float-button/float-button.js +6 -5
  32. package/dist/components/form/form-item.d.ts +1 -1
  33. package/dist/components/form/form-item.js +160 -120
  34. package/dist/components/form/use-form.js +2 -1
  35. package/dist/components/form-field/form-field-view.d.ts +2 -1
  36. package/dist/components/form-field/form-field-view.js +173 -108
  37. package/dist/components/input/input-shared.js +3 -2
  38. package/dist/components/input/otp.js +114 -110
  39. package/dist/components/input/password.js +55 -61
  40. package/dist/components/input/search.js +8 -4
  41. package/dist/components/input-number/input-number.d.ts +2 -1
  42. package/dist/components/input-number/input-number.js +67 -52
  43. package/dist/components/mentions/mentions.js +4 -2
  44. package/dist/components/menu/menu-render.d.ts +6 -0
  45. package/dist/components/menu/menu-render.js +39 -26
  46. package/dist/components/modal/confirm-dialog.js +22 -10
  47. package/dist/components/modal/modal.js +320 -315
  48. package/dist/components/modal/use-modal.js +1 -1
  49. package/dist/components/pagination/pagination.d.ts +4 -2
  50. package/dist/components/pagination/pagination.js +128 -117
  51. package/dist/components/popover/popover.js +214 -351
  52. package/dist/components/qr-code/qr-code.js +157 -150
  53. package/dist/components/radio/radio.d.ts +3 -1
  54. package/dist/components/radio/radio.js +73 -64
  55. package/dist/components/select/mobile-select.js +7 -4
  56. package/dist/components/select/select-model.js +3 -3
  57. package/dist/components/select/select.js +78 -39
  58. package/dist/components/select/use-select-selection.js +100 -92
  59. package/dist/components/slider/slider.d.ts +2 -2
  60. package/dist/components/slider/slider.js +13 -2
  61. package/dist/components/sonner/sonner.js +2 -2
  62. package/dist/components/splitter/splitter.css +1 -0
  63. package/dist/components/splitter/splitter.js +152 -126
  64. package/dist/components/statistic/statistic.js +38 -31
  65. package/dist/components/switch/switch.js +45 -39
  66. package/dist/components/table/table-filter.d.ts +3 -1
  67. package/dist/components/table/table-filter.js +100 -74
  68. package/dist/components/table/table.js +2 -0
  69. package/dist/components/table/use-table-data.js +2 -2
  70. package/dist/components/tabs/tabs.d.ts +3 -2
  71. package/dist/components/tabs/tabs.js +122 -112
  72. package/dist/components/time-picker/time-picker.js +35 -3
  73. package/dist/components/tooltip/tooltip.d.ts +1 -1
  74. package/dist/components/tooltip/tooltip.js +220 -124
  75. package/dist/components/tree/tree.js +31 -3
  76. package/dist/components/tree-select/tree-select.js +2 -1
  77. package/dist/components/upload/upload.js +67 -40
  78. package/dist/locales/ar-EG.js +2 -0
  79. package/dist/locales/de-DE.js +2 -0
  80. package/dist/locales/en-US.js +2 -0
  81. package/dist/locales/es-ES.js +2 -0
  82. package/dist/locales/fr-FR.js +2 -0
  83. package/dist/locales/hi-IN.js +2 -0
  84. package/dist/locales/id-ID.js +2 -0
  85. package/dist/locales/it-IT.js +2 -0
  86. package/dist/locales/ja-JP.js +2 -0
  87. package/dist/locales/ko-KR.js +2 -0
  88. package/dist/locales/pt-BR.js +2 -0
  89. package/dist/locales/ru-RU.js +2 -0
  90. package/dist/locales/th-TH.js +2 -0
  91. package/dist/locales/tr-TR.js +2 -0
  92. package/dist/locales/types.d.ts +2 -0
  93. package/dist/locales/vi-VN.js +2 -0
  94. package/dist/locales/zh-CN.js +2 -0
  95. package/dist/locales/zh-TW.js +2 -0
  96. package/dist/number-input/format.js +1 -1
  97. package/dist/number-input/use-number-input.d.ts +1 -0
  98. package/dist/number-input/use-number-input.js +170 -321
  99. package/dist/number-input/validate.d.ts +1 -0
  100. package/dist/number-input/validate.js +1 -1
  101. package/dist/provider/tao-provider.d.ts +2 -2
  102. package/dist/provider/tao-provider.js +66 -52
  103. package/dist/theme/control.css +5 -1
  104. package/dist/theme/theme.css +2 -2
  105. package/dist/utils/composed-parent.d.ts +1 -0
  106. package/dist/utils/composed-parent.js +7 -0
  107. package/dist/utils/portal.d.ts +5 -0
  108. package/dist/utils/portal.js +7 -1
  109. package/dist/utils/refs.d.ts +3 -1
  110. package/dist/utils/refs.js +25 -1
  111. package/package.json +1 -1
@@ -4,7 +4,7 @@ import { forwardRef, useState } from "react";
4
4
  import { useTaoConfig } from "../../provider/tao-provider.js";
5
5
  import { BaseInput } from "./base-input.js";
6
6
  const password_Password = /*#__PURE__*/ forwardRef(function(t0, ref) {
7
- const $ = c(24);
7
+ const $ = c(22);
8
8
  let disabled;
9
9
  let iconRender;
10
10
  let props;
@@ -40,77 +40,71 @@ const password_Password = /*#__PURE__*/ forwardRef(function(t0, ref) {
40
40
  const resolvedDisabled = disabled ?? ctx.disabled;
41
41
  const t3 = visible ? "text" : "password";
42
42
  let t4;
43
- if ($[8] !== config || $[9] !== ctx || $[10] !== iconRender || $[11] !== resolvedDisabled || $[12] !== visibilityToggle || $[13] !== visible) {
44
- t4 = visibilityToggle && /*#__PURE__*/ jsx("button", {
45
- type: "button",
46
- "data-tao-input-action": "",
47
- "aria-label": visible ? ctx.locale.hidePassword ?? "Hide password" : ctx.locale.showPassword ?? "Show password",
48
- "aria-pressed": visible,
49
- tabIndex: config.tabIndex,
50
- disabled: resolvedDisabled,
51
- onMouseDown: _temp,
52
- onClick: ()=>{
53
- if (void 0 === config.visible) setVisible(!visible);
54
- config.onVisibleChange?.(!visible);
55
- },
56
- children: iconRender ? iconRender(visible) : /*#__PURE__*/ jsxs("svg", {
57
- viewBox: "0 0 24 24",
58
- fill: "none",
59
- stroke: "currentColor",
60
- strokeWidth: "1.8",
61
- "aria-hidden": "true",
62
- children: [
63
- /*#__PURE__*/ jsx("path", {
64
- d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7S2 12 2 12Z"
65
- }),
66
- /*#__PURE__*/ jsx("circle", {
67
- cx: "12",
68
- cy: "12",
69
- r: "3"
70
- }),
71
- !visible && /*#__PURE__*/ jsx("path", {
72
- d: "m3 3 18 18"
43
+ if ($[8] !== config || $[9] !== ctx || $[10] !== iconRender || $[11] !== resolvedDisabled || $[12] !== suffix || $[13] !== visibilityToggle || $[14] !== visible) {
44
+ t4 = visibilityToggle ? /*#__PURE__*/ jsxs(Fragment, {
45
+ children: [
46
+ suffix,
47
+ /*#__PURE__*/ jsx("button", {
48
+ type: "button",
49
+ "data-tao-input-action": "",
50
+ "aria-label": visible ? ctx.locale.hidePassword ?? "Hide password" : ctx.locale.showPassword ?? "Show password",
51
+ "aria-pressed": visible,
52
+ tabIndex: config.tabIndex,
53
+ disabled: resolvedDisabled,
54
+ onMouseDown: _temp,
55
+ onClick: ()=>{
56
+ if (void 0 === config.visible) setVisible(!visible);
57
+ config.onVisibleChange?.(!visible);
58
+ },
59
+ children: iconRender ? iconRender(visible) : /*#__PURE__*/ jsxs("svg", {
60
+ viewBox: "0 0 24 24",
61
+ fill: "none",
62
+ stroke: "currentColor",
63
+ strokeWidth: "1.8",
64
+ "aria-hidden": "true",
65
+ children: [
66
+ /*#__PURE__*/ jsx("path", {
67
+ d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7S2 12 2 12Z"
68
+ }),
69
+ /*#__PURE__*/ jsx("circle", {
70
+ cx: "12",
71
+ cy: "12",
72
+ r: "3"
73
+ }),
74
+ !visible && /*#__PURE__*/ jsx("path", {
75
+ d: "m3 3 18 18"
76
+ })
77
+ ]
73
78
  })
74
- ]
75
- })
76
- });
79
+ })
80
+ ]
81
+ }) : suffix;
77
82
  $[8] = config;
78
83
  $[9] = ctx;
79
84
  $[10] = iconRender;
80
85
  $[11] = resolvedDisabled;
81
- $[12] = visibilityToggle;
82
- $[13] = visible;
83
- $[14] = t4;
84
- } else t4 = $[14];
86
+ $[12] = suffix;
87
+ $[13] = visibilityToggle;
88
+ $[14] = visible;
89
+ $[15] = t4;
90
+ } else t4 = $[15];
85
91
  let t5;
86
- if ($[15] !== suffix || $[16] !== t4) {
87
- t5 = /*#__PURE__*/ jsxs(Fragment, {
88
- children: [
89
- suffix,
90
- t4
91
- ]
92
- });
93
- $[15] = suffix;
94
- $[16] = t4;
95
- $[17] = t5;
96
- } else t5 = $[17];
97
- let t6;
98
- if ($[18] !== props || $[19] !== ref || $[20] !== resolvedDisabled || $[21] !== t3 || $[22] !== t5) {
99
- t6 = /*#__PURE__*/ jsx(BaseInput, {
92
+ if ($[16] !== props || $[17] !== ref || $[18] !== resolvedDisabled || $[19] !== t3 || $[20] !== t4) {
93
+ t5 = /*#__PURE__*/ jsx(BaseInput, {
100
94
  ...props,
101
95
  disabled: resolvedDisabled,
102
96
  ref: ref,
103
97
  type: t3,
104
- suffix: t5
98
+ suffix: t4
105
99
  });
106
- $[18] = props;
107
- $[19] = ref;
108
- $[20] = resolvedDisabled;
109
- $[21] = t3;
110
- $[22] = t5;
111
- $[23] = t6;
112
- } else t6 = $[23];
113
- return t6;
100
+ $[16] = props;
101
+ $[17] = ref;
102
+ $[18] = resolvedDisabled;
103
+ $[19] = t3;
104
+ $[20] = t4;
105
+ $[21] = t5;
106
+ } else t5 = $[21];
107
+ return t5;
114
108
  });
115
109
  function _temp(event) {
116
110
  return event.preventDefault();
@@ -26,17 +26,20 @@ const search_Search = /*#__PURE__*/ forwardRef(function(props, ref) {
26
26
  source: 'input'
27
27
  });
28
28
  };
29
+ const searchLabel = ctx.locale.search ?? 'Search';
30
+ const hasButtonContent = 0 === enterButton || Boolean(enterButton);
31
+ const iconOnly = true === enterButton || !hasButtonContent;
29
32
  const buttonProps = {
30
33
  type: 'button',
31
34
  disabled: submitDisabled,
32
35
  'aria-busy': isLoading || void 0,
33
- 'aria-label': ctx.locale.search ?? 'Search',
36
+ 'aria-label': iconOnly ? searchLabel : void 0,
37
+ title: iconOnly ? void 0 : searchLabel,
34
38
  className: classNames?.button,
35
39
  style: styles?.button,
36
40
  onMouseDown: (event_0)=>event_0.preventDefault(),
37
41
  onClick: search
38
42
  };
39
- const hasButtonContent = 0 === enterButton || Boolean(enterButton);
40
43
  const button = customButton ? /*#__PURE__*/ cloneElement(enterButton, {
41
44
  ...buttonProps,
42
45
  className: cx(enterButton.props.className, classNames?.button),
@@ -44,7 +47,8 @@ const search_Search = /*#__PURE__*/ forwardRef(function(props, ref) {
44
47
  ...enterButton.props.style,
45
48
  ...styles?.button
46
49
  },
47
- 'aria-label': enterButton.props['aria-label'] ?? buttonProps['aria-label'],
50
+ 'aria-label': enterButton.props['aria-label'],
51
+ title: enterButton.props.title ?? searchLabel,
48
52
  ...enterButton.type === Button ? {
49
53
  loading: isLoading,
50
54
  size: props.size ?? enterButton.props.size
@@ -62,7 +66,7 @@ const search_Search = /*#__PURE__*/ forwardRef(function(props, ref) {
62
66
  loading: isLoading,
63
67
  size: props.size,
64
68
  variant: hasButtonContent ? 'primary' : 'secondary',
65
- children: true !== enterButton && hasButtonContent ? enterButton : searchIcon ?? /*#__PURE__*/ jsx(SearchIcon, {})
69
+ children: iconOnly ? searchIcon ?? /*#__PURE__*/ jsx(SearchIcon, {}) : enterButton
66
70
  });
67
71
  return /*#__PURE__*/ jsxs("div", {
68
72
  "data-tao-input-search": "",
@@ -1,4 +1,4 @@
1
- import { type AriaAttributes, type ReactNode, type Ref } from 'react';
1
+ import { type AriaAttributes, type CSSProperties, type ReactNode, type Ref } from 'react';
2
2
  import { type UseNumberInputOptions } from '../../number-input/use-number-input.js';
3
3
  import type { TaoSize, TaoStatus, TaoVariant } from '../../provider/tao-provider.js';
4
4
  import type { SemanticClassNames, SemanticStyles } from '../../utils/semantic.js';
@@ -17,6 +17,7 @@ export interface InputNumberProps extends UseNumberInputOptions, Pick<AriaAttrib
17
17
  id?: string;
18
18
  name?: string;
19
19
  className?: string;
20
+ style?: CSSProperties;
20
21
  classNames?: SemanticClassNames<InputNumberSemanticPart>;
21
22
  styles?: SemanticStyles<InputNumberSemanticPart>;
22
23
  }
@@ -5,7 +5,7 @@ import { useNumberInput } from "../../number-input/use-number-input.js";
5
5
  import { mergeRefs } from "../../utils/refs.js";
6
6
  import { BaseInput } from "../input/base-input.js";
7
7
  const input_number_InputNumber = /*#__PURE__*/ forwardRef(function(t0, forwardedRef) {
8
- const $ = c(49);
8
+ const $ = c(54);
9
9
  let ariaDescribedBy;
10
10
  let ariaErrorMessage;
11
11
  let ariaInvalid;
@@ -23,11 +23,12 @@ const input_number_InputNumber = /*#__PURE__*/ forwardRef(function(t0, forwarded
23
23
  let prefix;
24
24
  let size;
25
25
  let status;
26
+ let style;
26
27
  let styles;
27
28
  let suffix;
28
29
  let variant;
29
30
  if ($[0] !== t0) {
30
- ({ prefix, suffix, size, variant, error, status, disabled, placeholder, id, name, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, className, classNames, styles, ...hookOptions } = t0);
31
+ ({ prefix, suffix, size, variant, error, status, disabled, placeholder, id, name, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, className, style, classNames, styles, ...hookOptions } = t0);
31
32
  $[0] = t0;
32
33
  $[1] = ariaDescribedBy;
33
34
  $[2] = ariaErrorMessage;
@@ -46,9 +47,10 @@ const input_number_InputNumber = /*#__PURE__*/ forwardRef(function(t0, forwarded
46
47
  $[15] = prefix;
47
48
  $[16] = size;
48
49
  $[17] = status;
49
- $[18] = styles;
50
- $[19] = suffix;
51
- $[20] = variant;
50
+ $[18] = style;
51
+ $[19] = styles;
52
+ $[20] = suffix;
53
+ $[21] = variant;
52
54
  } else {
53
55
  ariaDescribedBy = $[1];
54
56
  ariaErrorMessage = $[2];
@@ -67,34 +69,45 @@ const input_number_InputNumber = /*#__PURE__*/ forwardRef(function(t0, forwarded
67
69
  prefix = $[15];
68
70
  size = $[16];
69
71
  status = $[17];
70
- styles = $[18];
71
- suffix = $[19];
72
- variant = $[20];
72
+ style = $[18];
73
+ styles = $[19];
74
+ suffix = $[20];
75
+ variant = $[21];
73
76
  }
74
- const { inputProps } = useNumberInput(hookOptions);
77
+ let t1;
78
+ if ($[22] !== disabled || $[23] !== hookOptions) {
79
+ t1 = {
80
+ ...hookOptions,
81
+ disabled
82
+ };
83
+ $[22] = disabled;
84
+ $[23] = hookOptions;
85
+ $[24] = t1;
86
+ } else t1 = $[24];
87
+ const { inputProps } = useNumberInput(t1);
75
88
  let inputRest;
76
89
  let ref;
77
- if ($[21] !== inputProps) {
90
+ if ($[25] !== inputProps) {
78
91
  ({ ref, ...inputRest } = inputProps);
79
- $[21] = inputProps;
80
- $[22] = inputRest;
81
- $[23] = ref;
92
+ $[25] = inputProps;
93
+ $[26] = inputRest;
94
+ $[27] = ref;
82
95
  } else {
83
- inputRest = $[22];
84
- ref = $[23];
96
+ inputRest = $[26];
97
+ ref = $[27];
85
98
  }
86
- let t1;
87
- if ($[24] !== forwardedRef || $[25] !== ref) {
88
- t1 = mergeRefs(ref, forwardedRef);
89
- $[24] = forwardedRef;
90
- $[25] = ref;
91
- $[26] = t1;
92
- } else t1 = $[26];
93
- const t2 = "error" === status || error ? true : ariaInvalid;
94
- let t3;
95
- if ($[27] !== ariaDescribedBy || $[28] !== ariaErrorMessage || $[29] !== ariaLabel || $[30] !== ariaLabelledBy || $[31] !== ariaRequired || $[32] !== className || $[33] !== classNames || $[34] !== disabled || $[35] !== error || $[36] !== id || $[37] !== inputRest || $[38] !== name || $[39] !== placeholder || $[40] !== prefix || $[41] !== size || $[42] !== status || $[43] !== styles || $[44] !== suffix || $[45] !== t1 || $[46] !== t2 || $[47] !== variant) {
96
- t3 = /*#__PURE__*/ jsx(BaseInput, {
97
- ref: t1,
99
+ let t2;
100
+ if ($[28] !== forwardedRef || $[29] !== ref) {
101
+ t2 = mergeRefs(ref, forwardedRef);
102
+ $[28] = forwardedRef;
103
+ $[29] = ref;
104
+ $[30] = t2;
105
+ } else t2 = $[30];
106
+ const t3 = "error" === status || error ? true : ariaInvalid;
107
+ let t4;
108
+ if ($[31] !== ariaDescribedBy || $[32] !== ariaErrorMessage || $[33] !== ariaLabel || $[34] !== ariaLabelledBy || $[35] !== ariaRequired || $[36] !== className || $[37] !== classNames || $[38] !== disabled || $[39] !== error || $[40] !== id || $[41] !== inputRest || $[42] !== name || $[43] !== placeholder || $[44] !== prefix || $[45] !== size || $[46] !== status || $[47] !== style || $[48] !== styles || $[49] !== suffix || $[50] !== t2 || $[51] !== t3 || $[52] !== variant) {
109
+ t4 = /*#__PURE__*/ jsx(BaseInput, {
110
+ ref: t2,
98
111
  prefix: prefix,
99
112
  suffix: suffix,
100
113
  size: size,
@@ -109,36 +122,38 @@ const input_number_InputNumber = /*#__PURE__*/ forwardRef(function(t0, forwarded
109
122
  "aria-labelledby": ariaLabelledBy,
110
123
  "aria-describedby": ariaDescribedBy,
111
124
  "aria-errormessage": ariaErrorMessage,
112
- "aria-invalid": t2,
125
+ "aria-invalid": t3,
113
126
  "aria-required": ariaRequired,
114
127
  className: className,
128
+ style: style,
115
129
  classNames: classNames,
116
130
  styles: styles,
117
131
  ...inputRest
118
132
  });
119
- $[27] = ariaDescribedBy;
120
- $[28] = ariaErrorMessage;
121
- $[29] = ariaLabel;
122
- $[30] = ariaLabelledBy;
123
- $[31] = ariaRequired;
124
- $[32] = className;
125
- $[33] = classNames;
126
- $[34] = disabled;
127
- $[35] = error;
128
- $[36] = id;
129
- $[37] = inputRest;
130
- $[38] = name;
131
- $[39] = placeholder;
132
- $[40] = prefix;
133
- $[41] = size;
134
- $[42] = status;
135
- $[43] = styles;
136
- $[44] = suffix;
137
- $[45] = t1;
138
- $[46] = t2;
139
- $[47] = variant;
140
- $[48] = t3;
141
- } else t3 = $[48];
142
- return t3;
133
+ $[31] = ariaDescribedBy;
134
+ $[32] = ariaErrorMessage;
135
+ $[33] = ariaLabel;
136
+ $[34] = ariaLabelledBy;
137
+ $[35] = ariaRequired;
138
+ $[36] = className;
139
+ $[37] = classNames;
140
+ $[38] = disabled;
141
+ $[39] = error;
142
+ $[40] = id;
143
+ $[41] = inputRest;
144
+ $[42] = name;
145
+ $[43] = placeholder;
146
+ $[44] = prefix;
147
+ $[45] = size;
148
+ $[46] = status;
149
+ $[47] = style;
150
+ $[48] = styles;
151
+ $[49] = suffix;
152
+ $[50] = t2;
153
+ $[51] = t3;
154
+ $[52] = variant;
155
+ $[53] = t4;
156
+ } else t4 = $[53];
157
+ return t4;
143
158
  });
144
159
  export { input_number_InputNumber as InputNumber };
@@ -9,9 +9,10 @@ import "./mentions.css";
9
9
  import { interopDefault } from "../../utils/interop-default.js";
10
10
  const RcMentionsComponent = /*#__PURE__*/ interopDefault(mentions);
11
11
  function getMentions(value = '', { prefix = '@', split = ' ' } = {}) {
12
- const prefixes = Array.isArray(prefix) ? prefix : [
12
+ const prefixes = (Array.isArray(prefix) ? prefix : [
13
13
  prefix
14
- ];
14
+ ]).filter(Boolean).sort((a, b)=>b.length - a.length);
15
+ if (!prefixes.length) return [];
15
16
  const tokens = ' ' === split ? value.split(/\s+/u) : value.split(split);
16
17
  return tokens.flatMap((text)=>{
17
18
  const match = prefixes.find((candidate)=>text.startsWith(candidate));
@@ -75,6 +76,7 @@ const MentionsComponent = /*#__PURE__*/ forwardRef((props, ref)=>{
75
76
  ref: ref,
76
77
  prefixCls: prefixCls,
77
78
  disabled: disabled,
79
+ "aria-invalid": 'error' === status ? true : props['aria-invalid'],
78
80
  onKeyDownCapture: (event)=>{
79
81
  props.onKeyDownCapture?.(event);
80
82
  if (!event.isPropagationStopped() && 'Enter' === event.key && (event.nativeEvent.isComposing || 229 === event.keyCode)) {
@@ -1,4 +1,5 @@
1
1
  import { type ComponentType, type ReactNode } from 'react';
2
+ import { type TaoDirection, type TaoSize } from '../../provider/tao-provider.js';
2
3
  import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
3
4
  import './menu.css';
4
5
  export type MenuSemanticPart = 'root' | 'content' | 'item' | 'itemIcon' | 'itemLabel' | 'itemExtra' | 'divider' | 'groupLabel' | 'subTrigger' | 'subContent';
@@ -67,6 +68,8 @@ export interface MenuPrimitives {
67
68
  }
68
69
  export interface RenderCtx {
69
70
  P: MenuPrimitives;
71
+ size?: TaoSize;
72
+ direction?: TaoDirection;
70
73
  classNames?: SemanticClassNames<MenuSemanticPart>;
71
74
  styles?: SemanticStyles<MenuSemanticPart>;
72
75
  /** Fire item.onClick + menu.onClick for a plain action item. */
@@ -76,6 +79,7 @@ export interface RenderCtx {
76
79
  multiple: boolean;
77
80
  selectable: boolean;
78
81
  onToggle: (key: string) => void;
82
+ onRadioChange: (key: string) => void;
79
83
  }
80
84
  export declare function renderMenuItems(items: MenuItem[], ctx: RenderCtx): ReactNode;
81
85
  /**
@@ -85,6 +89,8 @@ export declare function renderMenuItems(items: MenuItem[], ctx: RenderCtx): Reac
85
89
  * and ContextMenu.
86
90
  */
87
91
  export declare function useMenuController(menu: MenuProps, P: MenuPrimitives, semantic: {
92
+ size?: TaoSize;
93
+ direction?: TaoDirection;
88
94
  classNames?: SemanticClassNames<MenuSemanticPart>;
89
95
  styles?: SemanticStyles<MenuSemanticPart>;
90
96
  }): {
@@ -227,14 +227,20 @@ function renderMenuItems(items, ctx) {
227
227
  /*#__PURE__*/ jsx(P.Portal, {
228
228
  children: /*#__PURE__*/ jsx(TaoPortalScope, {
229
229
  asChild: true,
230
+ direction: ctx.direction,
230
231
  children: /*#__PURE__*/ jsx(P.SubContent, {
231
232
  "data-tao-menu-content": "",
232
233
  "data-tao-menu-sub-content": "",
234
+ "data-tao-size": ctx.size,
233
235
  className: cx(ctx.classNames?.subContent),
234
236
  style: ctx.styles?.subContent,
235
237
  sideOffset: 2,
236
238
  alignOffset: -4,
237
- children: renderMenuItems(item.children, ctx)
239
+ children: ctx.selectable && !ctx.multiple ? /*#__PURE__*/ jsx(P.RadioGroup, {
240
+ value: ctx.selectedKeys[0],
241
+ onValueChange: ctx.onRadioChange,
242
+ children: renderMenuItems(item.children, ctx)
243
+ }) : renderMenuItems(item.children, ctx)
238
244
  })
239
245
  })
240
246
  })
@@ -245,6 +251,7 @@ function renderMenuItems(items, ctx) {
245
251
  disabled: item.disabled,
246
252
  textValue: textValue,
247
253
  checked: ctx.selectedKeys.includes(item.key),
254
+ onSelect: (event)=>event.preventDefault(),
248
255
  onCheckedChange: ()=>{
249
256
  ctx.onToggle(item.key);
250
257
  ctx.onAction(item);
@@ -315,7 +322,7 @@ function renderMenuItems(items, ctx) {
315
322
  });
316
323
  }
317
324
  function useMenuController(menu, P, semantic) {
318
- const $ = c(37);
325
+ const $ = c(40);
319
326
  const selectable = !!menu.selectable;
320
327
  const multiple = !!menu.multiple;
321
328
  const isSelControlled = "selectedKeys" in menu;
@@ -389,58 +396,64 @@ function useMenuController(menu, P, semantic) {
389
396
  } else t5 = $[15];
390
397
  const onAction = t5;
391
398
  let t6;
392
- if ($[16] !== P || $[17] !== menu.items || $[18] !== multiple || $[19] !== onAction || $[20] !== selectable || $[21] !== selectedKeys || $[22] !== semantic.classNames || $[23] !== semantic.styles || $[24] !== toggleKey) {
399
+ if ($[16] !== P || $[17] !== menu.items || $[18] !== multiple || $[19] !== onAction || $[20] !== radioChange || $[21] !== selectable || $[22] !== selectedKeys || $[23] !== semantic.classNames || $[24] !== semantic.direction || $[25] !== semantic.size || $[26] !== semantic.styles || $[27] !== toggleKey) {
393
400
  const ctx = {
394
401
  P,
402
+ size: semantic.size,
403
+ direction: semantic.direction,
395
404
  classNames: semantic.classNames,
396
405
  styles: semantic.styles,
397
406
  onAction,
398
407
  selectedKeys,
399
408
  multiple,
400
409
  selectable,
401
- onToggle: toggleKey
410
+ onToggle: toggleKey,
411
+ onRadioChange: radioChange
402
412
  };
403
413
  t6 = renderMenuItems(menu.items, ctx);
404
414
  $[16] = P;
405
415
  $[17] = menu.items;
406
416
  $[18] = multiple;
407
417
  $[19] = onAction;
408
- $[20] = selectable;
409
- $[21] = selectedKeys;
410
- $[22] = semantic.classNames;
411
- $[23] = semantic.styles;
412
- $[24] = toggleKey;
413
- $[25] = t6;
414
- } else t6 = $[25];
418
+ $[20] = radioChange;
419
+ $[21] = selectable;
420
+ $[22] = selectedKeys;
421
+ $[23] = semantic.classNames;
422
+ $[24] = semantic.direction;
423
+ $[25] = semantic.size;
424
+ $[26] = semantic.styles;
425
+ $[27] = toggleKey;
426
+ $[28] = t6;
427
+ } else t6 = $[28];
415
428
  const body = t6;
416
429
  let t7;
417
- if ($[26] !== P || $[27] !== body || $[28] !== multiple || $[29] !== radioChange || $[30] !== selectable || $[31] !== selectedKeys) {
430
+ if ($[29] !== P || $[30] !== body || $[31] !== multiple || $[32] !== radioChange || $[33] !== selectable || $[34] !== selectedKeys) {
418
431
  t7 = selectable && !multiple ? /*#__PURE__*/ jsx(P.RadioGroup, {
419
432
  value: selectedKeys[0],
420
433
  onValueChange: radioChange,
421
434
  children: body
422
435
  }) : body;
423
- $[26] = P;
424
- $[27] = body;
425
- $[28] = multiple;
426
- $[29] = radioChange;
427
- $[30] = selectable;
428
- $[31] = selectedKeys;
429
- $[32] = t7;
430
- } else t7 = $[32];
436
+ $[29] = P;
437
+ $[30] = body;
438
+ $[31] = multiple;
439
+ $[32] = radioChange;
440
+ $[33] = selectable;
441
+ $[34] = selectedKeys;
442
+ $[35] = t7;
443
+ } else t7 = $[35];
431
444
  const content = t7;
432
445
  let t8;
433
- if ($[33] !== commitSel || $[34] !== content || $[35] !== selectedKeys) {
446
+ if ($[36] !== commitSel || $[37] !== content || $[38] !== selectedKeys) {
434
447
  t8 = {
435
448
  content,
436
449
  selectedKeys,
437
450
  commitSelection: commitSel
438
451
  };
439
- $[33] = commitSel;
440
- $[34] = content;
441
- $[35] = selectedKeys;
442
- $[36] = t8;
443
- } else t8 = $[36];
452
+ $[36] = commitSel;
453
+ $[37] = content;
454
+ $[38] = selectedKeys;
455
+ $[39] = t8;
456
+ } else t8 = $[39];
444
457
  return t8;
445
458
  }
446
459
  export { menuItemAsChild, renderMenuItems, useMenuController };
@@ -1,18 +1,21 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
- import { useLayoutEffect, useRef, useState } from "react";
3
+ import { useId, useLayoutEffect, useRef, useState } from "react";
4
+ import { useTaoConfig } from "../../provider/tao-provider.js";
4
5
  import { cx } from "../../utils/semantic.js";
5
6
  import { Button } from "../button/button.js";
6
7
  import { StatusIcon } from "../status-icon/status-icon.js";
7
8
  import { Modal } from "./modal.js";
8
- import { useTaoConfig } from "../../provider/tao-provider.js";
9
9
  function isPromise(v) {
10
10
  return !!v && 'function' == typeof v.then;
11
11
  }
12
- function ConfirmDialog({ onMount, open, close, type = 'confirm', icon, title, content, okText, cancelText, okCancel, okButtonProps, cancelButtonProps, onOk, onCancel, afterClose, centered = true, width = 416, maskClosable = false, closable = false, keyboard = true, className, classNames, styles }) {
13
- const { locale } = useTaoConfig();
12
+ function ConfirmDialog({ onMount, open, close, type = 'confirm', icon, title, content, okText, cancelText, okCancel, okButtonProps, cancelButtonProps, onOk, onCancel, afterClose, centered = true, width = 416, maskClosable = false, closable, keyboard = true, className, classNames, styles }) {
13
+ const { locale, disabled } = useTaoConfig();
14
+ const titleId = useId();
15
+ const contentId = useId();
14
16
  const [loading, setLoading] = useState(false);
15
17
  const [cancelLoading, setCancelLoading] = useState(false);
18
+ const okPending = useRef(false);
16
19
  const cancelPending = useRef(false);
17
20
  useLayoutEffect(()=>onMount?.(), [
18
21
  onMount
@@ -21,19 +24,23 @@ function ConfirmDialog({ onMount, open, close, type = 'confirm', icon, title, co
21
24
  const runAndClose = async (handler, withLoading)=>{
22
25
  const result = handler?.();
23
26
  if (isPromise(result)) {
24
- if (withLoading) setLoading(true);
25
- else setCancelLoading(true);
27
+ if (withLoading) {
28
+ okPending.current = true;
29
+ setLoading(true);
30
+ } else setCancelLoading(true);
26
31
  try {
27
32
  await result;
28
33
  close();
29
34
  } catch {} finally{
30
- if (withLoading) setLoading(false);
31
- else setCancelLoading(false);
35
+ if (withLoading) {
36
+ okPending.current = false;
37
+ setLoading(false);
38
+ } else setCancelLoading(false);
32
39
  }
33
40
  } else close();
34
41
  };
35
42
  const handleOk = ()=>{
36
- if (cancelPending.current) return;
43
+ if (cancelPending.current || okPending.current) return;
37
44
  return runAndClose(onOk, true);
38
45
  };
39
46
  const handleCancel = async ()=>{
@@ -55,11 +62,13 @@ function ConfirmDialog({ onMount, open, close, type = 'confirm', icon, title, co
55
62
  return /*#__PURE__*/ jsx(Modal, {
56
63
  open: open,
57
64
  title: null,
65
+ "aria-labelledby": null != title ? titleId : void 0,
66
+ "aria-describedby": null != content ? contentId : void 0,
58
67
  onClose: handleCancel,
59
68
  afterClose: afterClose,
60
69
  width: width,
61
70
  centered: centered,
62
- closable: closable,
71
+ closable: closable ?? (!!(okButtonProps?.disabled ?? disabled) && (!showCancel || !!cancelButtonProps?.disabled)),
63
72
  maskClosable: maskClosable,
64
73
  keyboard: keyboard,
65
74
  classNames: mergedClassNames,
@@ -69,6 +78,7 @@ function ConfirmDialog({ onMount, open, close, type = 'confirm', icon, title, co
69
78
  showCancel && /*#__PURE__*/ jsx(Button, {
70
79
  variant: "secondary",
71
80
  ...cancelButtonProps,
81
+ disabled: cancelButtonProps?.disabled ?? false,
72
82
  loading: cancelLoading || cancelButtonProps?.loading,
73
83
  onClick: (event)=>{
74
84
  cancelButtonProps?.onClick?.(event);
@@ -101,10 +111,12 @@ function ConfirmDialog({ onMount, open, close, type = 'confirm', icon, title, co
101
111
  "data-tao-modal-confirm-main": "",
102
112
  children: [
103
113
  null != title && /*#__PURE__*/ jsx("div", {
114
+ id: titleId,
104
115
  "data-tao-modal-confirm-title": "",
105
116
  children: title
106
117
  }),
107
118
  null != content && /*#__PURE__*/ jsx("div", {
119
+ id: contentId,
108
120
  "data-tao-modal-confirm-content": "",
109
121
  children: content
110
122
  })