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.
- package/ai/kui-components.json +819 -162
- package/es/_virtual/_rolldown/runtime.js +2 -3
- package/es/affix/index.js +73 -185
- package/es/alert/index.js +3 -4
- package/es/anchor/anchor-context.js +2 -3
- package/es/anchor/anchor-link.js +3 -4
- package/es/anchor/anchor.js +195 -398
- package/es/auto-complete/index.js +160 -561
- package/es/avatar/avatar-group-context.js +2 -3
- package/es/avatar/avatar-group.js +32 -124
- package/es/avatar/avatar.js +58 -159
- package/es/back-top/index.js +66 -201
- package/es/badge/index.js +4 -5
- package/es/base/teleport.js +22 -54
- package/es/base/transition-props.js +2 -3
- package/es/base/transition.js +2 -3
- package/es/breadcrumb/breadcrumb-context.js +2 -3
- package/es/breadcrumb/breadcrumb-item.js +19 -102
- package/es/breadcrumb/breadcrumb.js +10 -59
- package/es/button/button-group-context.js +2 -3
- package/es/button/button-group.js +15 -75
- package/es/button/button.js +4 -5
- package/es/calendar/index.js +4 -5
- package/es/card/index.js +4 -5
- package/es/carousel/carousel-context.js +2 -3
- package/es/carousel/carousel-item.js +3 -4
- package/es/carousel/carousel.js +281 -628
- package/es/carousel/drag.js +2 -3
- package/es/cascader/index.js +7 -8
- package/es/check-card/check-card-group.js +53 -179
- package/es/check-card/check-card.js +100 -293
- package/es/check-card/context.js +2 -3
- package/es/checkbox/checkbox-group-context.js +2 -3
- package/es/checkbox/checkbox-group.js +34 -138
- package/es/checkbox/checkbox.js +4 -5
- package/es/checkbox/index.js +2 -3
- package/es/collapse/collapse-panel.js +84 -206
- package/es/collapse/collapse.js +38 -170
- package/es/color-picker/alpha.js +44 -125
- package/es/color-picker/hue.js +39 -108
- package/es/color-picker/index.js +7 -6
- package/es/color-picker/mode.js +76 -159
- package/es/color-picker/paint.js +66 -163
- package/es/color-picker/presets.js +12 -44
- package/es/components.js +37 -32
- package/es/config/config-context.js +2 -3
- package/es/config/context.js +2 -3
- package/es/config/index.js +3 -4
- package/es/config/popup-host.js +3 -4
- package/es/config/size-context.js +2 -3
- package/es/config/use-config-appearance.js +3 -4
- package/es/const/var.js +2 -3
- package/es/date-picker/index.js +8 -9
- package/es/descriptions/descriptions-item.js +3 -4
- package/es/descriptions/descriptions.js +53 -144
- package/es/divider/index.js +2 -3
- package/es/drawer/index.js +171 -465
- package/es/dropdown/dropdown-button.js +25 -128
- package/es/dropdown/dropdown-context.js +2 -3
- package/es/dropdown/dropdown.js +56 -207
- package/es/dropdown/trigger.js +37 -125
- package/es/empty/index.js +34 -111
- package/es/feature-card/index.js +2 -3
- package/es/feedback-panel/index.js +30 -155
- package/es/flame-wrap/index.js +3 -4
- package/es/flame-wrap/types.js +2 -3
- package/es/flex/index.js +2 -3
- package/es/form/field-context.js +3 -4
- package/es/form/form-context.js +2 -3
- package/es/form/form-item.js +4 -5
- package/es/form/form.js +108 -279
- package/es/form/utils.js +2 -3
- package/es/gradient-picker/corners.js +55 -0
- package/es/gradient-picker/index.js +191 -0
- package/es/gradient-picker/stops.js +219 -0
- package/es/gradient-picker/types.js +147 -0
- package/es/grid/grid-item.js +25 -116
- package/es/grid/grid.js +40 -151
- package/es/grid/useBreakpoint.js +3 -4
- package/es/icon/index.js +24 -126
- package/es/image/group.js +3 -4
- package/es/image/image-group-context.js +2 -3
- package/es/image/image.js +5 -6
- package/es/image/instance.js +2 -3
- package/es/image/preview.js +4 -5
- package/es/image/utils.js +2 -3
- package/es/index.js +5 -4
- package/es/input/index.js +2 -3
- package/es/input/input-base.js +4 -5
- package/es/input/input-box.js +2 -3
- package/es/input/input-group.js +4 -5
- package/es/input/input.js +3 -4
- package/es/input/textarea.js +3 -4
- package/es/input-number/drag.js +63 -0
- package/es/input-number/index.js +41 -11
- package/es/input-otp/index.js +3 -4
- package/es/input-tag/index.js +5 -6
- package/es/kanban/index.js +31 -168
- package/es/layout/index.js +43 -215
- package/es/layout/layout-context.js +2 -3
- package/es/list-panel/index.js +47 -185
- package/es/loading/index.js +2 -3
- package/es/loading/loading-bar.js +54 -114
- package/es/locale/de.js +2 -3
- package/es/locale/el.js +2 -3
- package/es/locale/en.js +2 -3
- package/es/locale/fr.js +2 -3
- package/es/locale/it.js +2 -3
- package/es/locale/ja.js +2 -3
- package/es/locale/ko.js +2 -3
- package/es/locale/ru.js +2 -3
- package/es/locale/th.js +2 -3
- package/es/locale/uk.js +2 -3
- package/es/locale/vi.js +2 -3
- package/es/locale/zh-CN.js +2 -3
- package/es/locale/zh-TW.js +2 -3
- package/es/mentions/index.js +214 -581
- package/es/menu/menu-context.js +2 -3
- package/es/menu/menu-divider.js +3 -4
- package/es/menu/menu-group.js +3 -4
- package/es/menu/menu-item.js +2 -3
- package/es/menu/menu-keyboard.js +2 -3
- package/es/menu/menu.js +184 -442
- package/es/menu/recursive-menu.js +3 -4
- package/es/menu/sub-menu.js +5 -6
- package/es/message/index.js +2 -3
- package/es/modal/api.js +2 -3
- package/es/modal/modal.js +263 -599
- package/es/modal/toast.js +63 -179
- package/es/node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js +2 -3
- package/es/notice/container.js +2 -3
- package/es/notice/content.js +4 -5
- package/es/notice/index.js +2 -3
- package/es/notice/instance.js +2 -3
- package/es/page/index.js +4 -5
- package/es/page/responsive.js +2 -3
- package/es/page-header/index.js +3 -4
- package/es/popconfirm/index.js +24 -70
- package/es/poptip/index.js +29 -88
- package/es/popup/index.js +8 -6
- package/es/popup/layers.js +2 -3
- package/es/progress/index.js +95 -229
- package/es/qrcode/index.js +3 -4
- package/es/radio/radio-button.js +37 -131
- package/es/radio/radio-group-context.js +2 -3
- package/es/radio/radio-group.js +69 -223
- package/es/radio/radio.js +3 -4
- package/es/rate/index.js +68 -226
- package/es/rate/star.js +38 -129
- package/es/result/index.js +35 -127
- package/es/ripple/index.js +3 -4
- package/es/ripple/types.js +2 -3
- package/es/row-col/col.js +59 -149
- package/es/row-col/row.js +2 -3
- package/es/segmented/index.js +66 -210
- package/es/select/option.js +23 -116
- package/es/select/select.js +9 -10
- package/es/skeleton/skeleton-avatar.js +2 -3
- package/es/skeleton/skeleton-button.js +2 -3
- package/es/skeleton/skeleton-image.js +28 -108
- package/es/skeleton/skeleton-text.js +17 -93
- package/es/skeleton/skeleton.js +46 -133
- package/es/skeleton/use-skeleton-loading.js +3 -4
- package/es/slider/index.js +92 -286
- package/es/slider/thumb.js +43 -133
- package/es/space/index.js +3 -4
- package/es/spin/index.js +2 -3
- package/es/splitter/splitter-panel.js +3 -4
- package/es/splitter/splitter.js +77 -219
- package/es/stat-card/countup.js +46 -141
- package/es/stat-card/rollup.js +27 -105
- package/es/stat-card/stat-card.js +3 -4
- package/es/stat-card/stat-number.js +26 -113
- package/es/stat-card/utils/countup.js +2 -3
- package/es/stat-card/utils/odometer.js +2 -3
- package/es/stat-card/utils/stat-item-key.js +2 -3
- package/es/steps/index.js +45 -123
- package/es/switch/index.js +4 -5
- package/es/table/column-setting.js +43 -139
- package/es/table/index.js +8 -9
- package/es/table/utils.js +2 -3
- package/es/tabs/tab-panel.js +19 -71
- package/es/tabs/tabs.js +6 -7
- package/es/tag/index.js +4 -5
- package/es/time-line/timeline-item.js +3 -4
- package/es/time-line/timeline.js +8 -44
- package/es/tooltip/index.js +41 -142
- package/es/tour/index.js +138 -356
- package/es/transfer/index.js +184 -487
- package/es/tree/index.js +8 -9
- package/es/tree/utils.js +2 -3
- package/es/tree-select/index.js +8 -9
- package/es/typography/index.js +75 -306
- package/es/upload/file-list.js +95 -119
- package/es/upload/index.js +8 -9
- package/es/upload/picture-sort.js +2 -3
- package/es/upload/selector.js +63 -193
- package/es/utils/checked.js +2 -3
- package/es/utils/color.js +2 -3
- package/es/utils/css.js +2 -3
- package/es/utils/focus.js +2 -3
- package/es/utils/number.js +2 -3
- package/es/utils/overlay-order.js +2 -3
- package/es/utils/overlay-stack.js +3 -4
- package/es/utils/placement.js +16 -4
- package/es/utils/popup-arrow.js +45 -0
- package/es/utils/popup.js +2 -3
- package/es/utils/promise.js +2 -3
- package/es/utils/react-node.js +2 -3
- package/es/utils/selection-tags.js +2 -3
- package/es/utils/share.js +2 -3
- package/es/utils/theme.js +2 -3
- package/es/utils/transition.js +2 -3
- package/es/utils/use-value.js +3 -4
- package/es/virtual-list/index.js +49 -187
- package/es/virtual-list/range.js +2 -3
- package/es/watermark/index.js +149 -289
- package/lib/index.cjs +2 -2
- package/lib/locale/de.cjs +1 -1
- package/lib/locale/el.cjs +1 -1
- package/lib/locale/en.cjs +1 -1
- package/lib/locale/fr.cjs +1 -1
- package/lib/locale/it.cjs +1 -1
- package/lib/locale/ja.cjs +1 -1
- package/lib/locale/ko.cjs +1 -1
- package/lib/locale/ru.cjs +1 -1
- package/lib/locale/th.cjs +1 -1
- package/lib/locale/uk.cjs +1 -1
- package/lib/locale/vi.cjs +1 -1
- package/lib/locale/zh-CN.cjs +1 -1
- package/lib/locale/zh-TW.cjs +1 -1
- package/package.json +24 -24
- package/style/base.css +1 -1
- package/style/components.css +2 -2
- package/style/index.css +2 -2
- package/style/theme.css +1 -1
- package/types/affix/index.d.cts +1 -1
- package/types/affix/index.d.ts +1 -1
- package/types/anchor/anchor-link.d.cts +1 -1
- package/types/anchor/anchor-link.d.ts +1 -1
- package/types/anchor/anchor.d.cts +1 -1
- package/types/anchor/anchor.d.ts +1 -1
- package/types/back-top/index.d.cts +1 -1
- package/types/back-top/index.d.ts +1 -1
- package/types/carousel/carousel-item.d.cts +1 -1
- package/types/carousel/carousel-item.d.ts +1 -1
- package/types/cascader/index.d.cts +1 -1
- package/types/cascader/index.d.ts +1 -1
- package/types/color-picker/alpha.d.cts +1 -1
- package/types/color-picker/alpha.d.ts +1 -1
- package/types/color-picker/hue.d.cts +1 -1
- package/types/color-picker/hue.d.ts +1 -1
- package/types/color-picker/index.d.cts +3 -2
- package/types/color-picker/index.d.ts +3 -2
- package/types/color-picker/mode.d.cts +1 -1
- package/types/color-picker/mode.d.ts +1 -1
- package/types/color-picker/paint.d.cts +1 -1
- package/types/color-picker/paint.d.ts +1 -1
- package/types/color-picker/presets.d.cts +1 -1
- package/types/color-picker/presets.d.ts +1 -1
- package/types/components.d.cts +3 -0
- package/types/components.d.ts +3 -0
- package/types/date-picker/index.d.cts +2 -2
- package/types/date-picker/index.d.ts +2 -2
- package/types/feature-card/index.d.cts +1 -1
- package/types/feature-card/index.d.ts +1 -1
- package/types/feedback-panel/index.d.cts +1 -1
- package/types/feedback-panel/index.d.ts +1 -1
- package/types/flame-wrap/index.d.cts +1 -1
- package/types/flame-wrap/index.d.ts +1 -1
- package/types/form/form-item.d.cts +1 -1
- package/types/form/form-item.d.ts +1 -1
- package/types/gradient-picker/corners.d.cts +8 -0
- package/types/gradient-picker/corners.d.ts +8 -0
- package/types/gradient-picker/index.d.cts +25 -0
- package/types/gradient-picker/index.d.ts +25 -0
- package/types/gradient-picker/stops.d.cts +12 -0
- package/types/gradient-picker/stops.d.ts +12 -0
- package/types/gradient-picker/types.d.cts +34 -0
- package/types/gradient-picker/types.d.ts +34 -0
- package/types/grid/grid-item.d.cts +1 -1
- package/types/grid/grid-item.d.ts +1 -1
- package/types/grid/grid.d.cts +1 -1
- package/types/grid/grid.d.ts +1 -1
- package/types/image/group.d.cts +1 -1
- package/types/image/group.d.ts +1 -1
- package/types/input-number/drag.d.cts +9 -0
- package/types/input-number/drag.d.ts +9 -0
- package/types/input-number/index.d.cts +1 -0
- package/types/input-number/index.d.ts +1 -0
- package/types/kanban/index.d.cts +1 -1
- package/types/kanban/index.d.ts +1 -1
- package/types/list-panel/index.d.cts +1 -1
- package/types/list-panel/index.d.ts +1 -1
- package/types/loading/loading-bar.d.cts +1 -1
- package/types/loading/loading-bar.d.ts +1 -1
- package/types/modal/toast.d.cts +1 -1
- package/types/modal/toast.d.ts +1 -1
- package/types/notice/content.d.cts +2 -2
- package/types/notice/content.d.ts +2 -2
- package/types/page-header/index.d.cts +1 -1
- package/types/page-header/index.d.ts +1 -1
- package/types/popconfirm/index.d.cts +1 -0
- package/types/popconfirm/index.d.ts +1 -0
- package/types/poptip/index.d.cts +1 -0
- package/types/poptip/index.d.ts +1 -0
- package/types/popup/index.d.cts +1 -0
- package/types/popup/index.d.ts +1 -0
- package/types/result/index.d.cts +1 -1
- package/types/result/index.d.ts +1 -1
- package/types/ripple/index.d.cts +1 -1
- package/types/ripple/index.d.ts +1 -1
- package/types/slider/index.d.cts +1 -1
- package/types/slider/index.d.ts +1 -1
- package/types/splitter/splitter-panel.d.cts +1 -1
- package/types/splitter/splitter-panel.d.ts +1 -1
- package/types/splitter/splitter.d.cts +1 -1
- package/types/splitter/splitter.d.ts +1 -1
- package/types/stat-card/countup.d.cts +1 -1
- package/types/stat-card/countup.d.ts +1 -1
- package/types/stat-card/rollup.d.cts +1 -1
- package/types/stat-card/rollup.d.ts +1 -1
- package/types/stat-card/stat-card.d.cts +1 -1
- package/types/stat-card/stat-card.d.ts +1 -1
- package/types/stat-card/stat-number.d.cts +1 -1
- package/types/stat-card/stat-number.d.ts +1 -1
- package/types/table/column-setting.d.cts +1 -1
- package/types/table/column-setting.d.ts +1 -1
- package/types/table/index.d.cts +1 -1
- package/types/table/index.d.ts +1 -1
- package/types/time-line/timeline-item.d.cts +1 -1
- package/types/time-line/timeline-item.d.ts +1 -1
- package/types/time-line/timeline.d.cts +1 -1
- package/types/time-line/timeline.d.ts +1 -1
- package/types/tooltip/index.d.cts +1 -0
- package/types/tooltip/index.d.ts +1 -0
- package/types/transfer/index.d.cts +1 -1
- package/types/transfer/index.d.ts +1 -1
- package/types/tree-select/index.d.cts +1 -1
- package/types/tree-select/index.d.ts +1 -1
- package/types/upload/file-list.d.cts +1 -1
- package/types/upload/file-list.d.ts +1 -1
- package/types/upload/selector.d.cts +1 -1
- package/types/upload/selector.d.ts +1 -1
- package/types/utils/placement.d.cts +2 -1
- package/types/utils/placement.d.ts +2 -1
- package/types/utils/popup-arrow.d.cts +5 -0
- package/types/utils/popup-arrow.d.ts +5 -0
- package/types/utils/selection-tags.d.cts +1 -1
- package/types/utils/selection-tags.d.ts +1 -1
- package/types/watermark/index.d.cts +1 -1
- package/types/watermark/index.d.ts +1 -1
package/es/mentions/index.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
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
|
|
9
|
+
import { useValue } from "../utils/use-value.js";
|
|
10
10
|
import { useFormAppearance } from "../config/use-config-appearance.js";
|
|
11
|
+
import { createFormFieldComponent } from "../form/field-context.js";
|
|
11
12
|
import { CircleX, Loading } from "../node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js";
|
|
12
|
-
import
|
|
13
|
-
import { useValue } from "../utils/use-value.js";
|
|
13
|
+
import Popup from "../popup/index.js";
|
|
14
14
|
import Empty from "../empty/index.js";
|
|
15
|
-
import
|
|
15
|
+
import Icon from "../icon/index.js";
|
|
16
16
|
import textarea_default from "../input/textarea.js";
|
|
17
|
-
import { c } from "react/compiler-runtime";
|
|
18
17
|
import clsx from "clsx";
|
|
19
|
-
import { useEffect, useId, useRef, useState } from "react";
|
|
18
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
20
19
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
-
|
|
20
|
+
// components/mentions/index.tsx
|
|
22
21
|
var caretPosition = (element) => {
|
|
23
22
|
const style = window.getComputedStyle(element);
|
|
24
23
|
const rect = element.getBoundingClientRect();
|
|
@@ -69,601 +68,235 @@ var caretPosition = (element) => {
|
|
|
69
68
|
return markerRect;
|
|
70
69
|
};
|
|
71
70
|
var EMPTY_OPTIONS = [];
|
|
72
|
-
var Mentions = (
|
|
73
|
-
const $ = c(147);
|
|
74
|
-
let className;
|
|
75
|
-
let disabled;
|
|
76
|
-
let emptyText;
|
|
77
|
-
let filterOption;
|
|
78
|
-
let loadingText;
|
|
79
|
-
let onChange;
|
|
80
|
-
let onClear;
|
|
81
|
-
let onSearch;
|
|
82
|
-
let onSelect;
|
|
83
|
-
let readOnly;
|
|
84
|
-
let rest;
|
|
85
|
-
let shapeProp;
|
|
86
|
-
let sizeProp;
|
|
87
|
-
let t1;
|
|
88
|
-
let t2;
|
|
89
|
-
let t3;
|
|
90
|
-
let t4;
|
|
91
|
-
let t5;
|
|
92
|
-
let t6;
|
|
93
|
-
let t7;
|
|
94
|
-
let themeProp;
|
|
95
|
-
let value;
|
|
96
|
-
if ($[0] !== t0) {
|
|
97
|
-
({value, options: t1, triggers: t2, rows: t3, placement: t4, destroyOnClose: t5, size: sizeProp, shape: shapeProp, theme: themeProp, emptyText, loading: t6, loadingText, clearable: t7, filterOption, onChange, onSearch, onSelect, onClear, className, disabled, readOnly, ...rest} = t0);
|
|
98
|
-
$[0] = t0;
|
|
99
|
-
$[1] = className;
|
|
100
|
-
$[2] = disabled;
|
|
101
|
-
$[3] = emptyText;
|
|
102
|
-
$[4] = filterOption;
|
|
103
|
-
$[5] = loadingText;
|
|
104
|
-
$[6] = onChange;
|
|
105
|
-
$[7] = onClear;
|
|
106
|
-
$[8] = onSearch;
|
|
107
|
-
$[9] = onSelect;
|
|
108
|
-
$[10] = readOnly;
|
|
109
|
-
$[11] = rest;
|
|
110
|
-
$[12] = shapeProp;
|
|
111
|
-
$[13] = sizeProp;
|
|
112
|
-
$[14] = t1;
|
|
113
|
-
$[15] = t2;
|
|
114
|
-
$[16] = t3;
|
|
115
|
-
$[17] = t4;
|
|
116
|
-
$[18] = t5;
|
|
117
|
-
$[19] = t6;
|
|
118
|
-
$[20] = t7;
|
|
119
|
-
$[21] = themeProp;
|
|
120
|
-
$[22] = value;
|
|
121
|
-
} else {
|
|
122
|
-
className = $[1];
|
|
123
|
-
disabled = $[2];
|
|
124
|
-
emptyText = $[3];
|
|
125
|
-
filterOption = $[4];
|
|
126
|
-
loadingText = $[5];
|
|
127
|
-
onChange = $[6];
|
|
128
|
-
onClear = $[7];
|
|
129
|
-
onSearch = $[8];
|
|
130
|
-
onSelect = $[9];
|
|
131
|
-
readOnly = $[10];
|
|
132
|
-
rest = $[11];
|
|
133
|
-
shapeProp = $[12];
|
|
134
|
-
sizeProp = $[13];
|
|
135
|
-
t1 = $[14];
|
|
136
|
-
t2 = $[15];
|
|
137
|
-
t3 = $[16];
|
|
138
|
-
t4 = $[17];
|
|
139
|
-
t5 = $[18];
|
|
140
|
-
t6 = $[19];
|
|
141
|
-
t7 = $[20];
|
|
142
|
-
themeProp = $[21];
|
|
143
|
-
value = $[22];
|
|
144
|
-
}
|
|
145
|
-
const options = t1 === void 0 ? EMPTY_OPTIONS : t1;
|
|
146
|
-
let t8;
|
|
147
|
-
if ($[23] !== t2) {
|
|
148
|
-
t8 = t2 === void 0 ? ["@"] : t2;
|
|
149
|
-
$[23] = t2;
|
|
150
|
-
$[24] = t8;
|
|
151
|
-
} else t8 = $[24];
|
|
152
|
-
const triggers = t8;
|
|
153
|
-
const rows = t3 === void 0 ? 1 : t3;
|
|
154
|
-
const placement = t4 === void 0 ? "bottom-left" : t4;
|
|
155
|
-
const destroyOnClose = t5 === void 0 ? true : t5;
|
|
156
|
-
const loading = t6 === void 0 ? false : t6;
|
|
157
|
-
const clearable = t7 === void 0 ? true : t7;
|
|
71
|
+
var Mentions = ({ value, options = EMPTY_OPTIONS, triggers = ["@"], rows = 1, placement = "bottom-left", destroyOnClose = true, size: sizeProp, shape: shapeProp, theme: themeProp, emptyText, loading = false, loadingText, clearable = true, filterOption, onChange, onSearch, onSelect, onClear, className, disabled, readOnly, ...rest }) => {
|
|
158
72
|
const inheritedAppearance = useFormAppearance();
|
|
159
73
|
const size = sizeProp ?? inheritedAppearance.size;
|
|
160
74
|
const shape = shapeProp ?? inheritedAppearance.shape;
|
|
161
75
|
const theme = themeProp ?? inheritedAppearance.theme ?? "fill";
|
|
162
|
-
const [inner, setInner] = useValue(value,
|
|
163
|
-
const
|
|
164
|
-
let t10;
|
|
165
|
-
if ($[25] !== t9) {
|
|
166
|
-
let t11;
|
|
167
|
-
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
168
|
-
t11 = /:/g;
|
|
169
|
-
$[27] = t11;
|
|
170
|
-
} else t11 = $[27];
|
|
171
|
-
t10 = t9.replace(t11, "");
|
|
172
|
-
$[25] = t9;
|
|
173
|
-
$[26] = t10;
|
|
174
|
-
} else t10 = $[26];
|
|
175
|
-
const listboxId = `k-mentions-listbox-${t10}`;
|
|
76
|
+
const [inner, setInner] = useValue(value, (next) => next ?? "");
|
|
77
|
+
const listboxId = `k-mentions-listbox-${useId().replace(/:/g, "")}`;
|
|
176
78
|
const [query, setQuery] = useState(null);
|
|
177
79
|
const [active, setActive] = useState(0);
|
|
178
|
-
|
|
179
|
-
if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
|
|
180
|
-
t11 = [];
|
|
181
|
-
$[28] = t11;
|
|
182
|
-
} else t11 = $[28];
|
|
183
|
-
const [shown, setShown] = useState(t11);
|
|
80
|
+
const [shown, setShown] = useState([]);
|
|
184
81
|
const [popupWidth, setPopupWidth] = useState(260);
|
|
185
82
|
const rootRef = useRef(null);
|
|
186
83
|
const textareaRef = useRef(null);
|
|
187
84
|
const dropdownRef = useRef(null);
|
|
188
85
|
const composing = useRef(false);
|
|
189
86
|
const current = inner;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const enabled = shown.map(_temp5).filter(_temp6);
|
|
218
|
-
if (!enabled.length) return;
|
|
219
|
-
const currentIndex = enabled.indexOf(active);
|
|
220
|
-
setActive(enabled[(Math.max(currentIndex, 0) + offset + enabled.length) % enabled.length]);
|
|
221
|
-
};
|
|
222
|
-
$[34] = active;
|
|
223
|
-
$[35] = shown;
|
|
224
|
-
$[36] = t15;
|
|
225
|
-
} else t15 = $[36];
|
|
226
|
-
const moveActive = t15;
|
|
227
|
-
let t16;
|
|
228
|
-
if ($[37] !== filterOption || $[38] !== normalized || $[39] !== onSearch) {
|
|
229
|
-
t16 = (state) => {
|
|
230
|
-
if (onSearch && !filterOption) return normalized;
|
|
231
|
-
return normalized.filter((option_1) => filterOption ? filterOption(state.text, option_1) : option_1.value.toLocaleLowerCase().includes(state.text.toLocaleLowerCase()));
|
|
232
|
-
};
|
|
233
|
-
$[37] = filterOption;
|
|
234
|
-
$[38] = normalized;
|
|
235
|
-
$[39] = onSearch;
|
|
236
|
-
$[40] = t16;
|
|
237
|
-
} else t16 = $[40];
|
|
238
|
-
const getMatches = t16;
|
|
87
|
+
const normalized = useMemo(() => options.map((item) => typeof item === "string" ? {
|
|
88
|
+
value: item,
|
|
89
|
+
label: item
|
|
90
|
+
} : item), [options]);
|
|
91
|
+
const effectiveTriggers = useMemo(() => triggers.filter(Boolean), [triggers]);
|
|
92
|
+
const firstEnabled = (items) => {
|
|
93
|
+
const index = items.findIndex((option) => !option.disabled);
|
|
94
|
+
return index < 0 ? 0 : index;
|
|
95
|
+
};
|
|
96
|
+
const setMatches = (items_0) => {
|
|
97
|
+
setShown(items_0);
|
|
98
|
+
setActive(firstEnabled(items_0));
|
|
99
|
+
};
|
|
100
|
+
const moveActive = (offset) => {
|
|
101
|
+
const enabled = shown.map((option_0, index_0) => !option_0.disabled ? index_0 : -1).filter((index_1) => index_1 >= 0);
|
|
102
|
+
if (!enabled.length) return;
|
|
103
|
+
const currentIndex = enabled.indexOf(active);
|
|
104
|
+
setActive(enabled[(Math.max(currentIndex, 0) + offset + enabled.length) % enabled.length]);
|
|
105
|
+
};
|
|
106
|
+
const getMatches = useCallback((state) => {
|
|
107
|
+
if (onSearch && !filterOption) return normalized;
|
|
108
|
+
return normalized.filter((option_1) => filterOption ? filterOption(state.text, option_1) : option_1.value.toLocaleLowerCase().includes(state.text.toLocaleLowerCase()));
|
|
109
|
+
}, [
|
|
110
|
+
filterOption,
|
|
111
|
+
normalized,
|
|
112
|
+
onSearch
|
|
113
|
+
]);
|
|
239
114
|
const [previousNormalized, setPreviousNormalized] = useState(normalized);
|
|
240
115
|
if (previousNormalized !== normalized) {
|
|
241
116
|
setPreviousNormalized(normalized);
|
|
242
117
|
if (query) setMatches(getMatches(query));
|
|
243
118
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
x: rect.left,
|
|
252
|
-
y: rect.bottom
|
|
253
|
-
};
|
|
254
|
-
};
|
|
255
|
-
$[41] = t17;
|
|
256
|
-
} else t17 = $[41];
|
|
257
|
-
const getAnchorPosition = t17;
|
|
258
|
-
let t18;
|
|
259
|
-
if ($[42] !== effectiveTriggers || $[43] !== getMatches || $[44] !== onSearch || $[45] !== readOnly) {
|
|
260
|
-
t18 = (text, caret, t19) => {
|
|
261
|
-
const search = t19 === void 0 ? false : t19;
|
|
262
|
-
if (readOnly) {
|
|
263
|
-
setQuery(null);
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
const prefix = text.slice(0, caret);
|
|
267
|
-
let found = null;
|
|
268
|
-
effectiveTriggers.forEach((trigger) => {
|
|
269
|
-
const start = prefix.lastIndexOf(trigger);
|
|
270
|
-
if (start >= 0 && !/\s/.test(prefix.slice(start + trigger.length)) && (!found || start > found.start)) found = {
|
|
271
|
-
start,
|
|
272
|
-
trigger,
|
|
273
|
-
text: prefix.slice(start + trigger.length)
|
|
274
|
-
};
|
|
275
|
-
});
|
|
276
|
-
const nextQuery = found;
|
|
277
|
-
setQuery(nextQuery);
|
|
278
|
-
if (nextQuery) {
|
|
279
|
-
setMatches(onSearch && search && nextQuery.text ? [] : getMatches(nextQuery));
|
|
280
|
-
if (search && nextQuery.text) onSearch?.(nextQuery.text, nextQuery.trigger);
|
|
281
|
-
} else setMatches([]);
|
|
282
|
-
};
|
|
283
|
-
$[42] = effectiveTriggers;
|
|
284
|
-
$[43] = getMatches;
|
|
285
|
-
$[44] = onSearch;
|
|
286
|
-
$[45] = readOnly;
|
|
287
|
-
$[46] = t18;
|
|
288
|
-
} else t18 = $[46];
|
|
289
|
-
const updateQuery = t18;
|
|
290
|
-
let t19;
|
|
291
|
-
let t20;
|
|
292
|
-
if ($[47] !== active || $[48] !== listboxId) {
|
|
293
|
-
t19 = () => {
|
|
294
|
-
dropdownRef.current?.querySelector(`#${listboxId}-option-${active}`)?.scrollIntoView({ block: "nearest" });
|
|
119
|
+
const getAnchorPosition = useCallback(() => {
|
|
120
|
+
if (!textareaRef.current) return null;
|
|
121
|
+
const rect = caretPosition(textareaRef.current);
|
|
122
|
+
setPopupWidth(Math.min(260, rootRef.current?.offsetWidth || 260));
|
|
123
|
+
return {
|
|
124
|
+
x: rect.left,
|
|
125
|
+
y: rect.bottom
|
|
295
126
|
};
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
$[49] = t19;
|
|
300
|
-
$[50] = t20;
|
|
301
|
-
} else {
|
|
302
|
-
t19 = $[49];
|
|
303
|
-
t20 = $[50];
|
|
304
|
-
}
|
|
305
|
-
useEffect(t19, t20);
|
|
306
|
-
let t21;
|
|
307
|
-
if ($[51] !== disabled || $[52] !== onChange || $[53] !== readOnly || $[54] !== setInner) {
|
|
308
|
-
t21 = (next_0) => {
|
|
309
|
-
if (disabled || readOnly) return;
|
|
310
|
-
setInner(next_0);
|
|
311
|
-
onChange?.(next_0);
|
|
312
|
-
};
|
|
313
|
-
$[51] = disabled;
|
|
314
|
-
$[52] = onChange;
|
|
315
|
-
$[53] = readOnly;
|
|
316
|
-
$[54] = setInner;
|
|
317
|
-
$[55] = t21;
|
|
318
|
-
} else t21 = $[55];
|
|
319
|
-
const setValue = t21;
|
|
320
|
-
let t22;
|
|
321
|
-
if ($[56] !== disabled || $[57] !== onClear || $[58] !== readOnly || $[59] !== setValue) {
|
|
322
|
-
t22 = (event) => {
|
|
323
|
-
if (disabled || readOnly) return;
|
|
324
|
-
event.stopPropagation();
|
|
325
|
-
setValue("");
|
|
127
|
+
}, []);
|
|
128
|
+
const updateQuery = (text, caret, search = false) => {
|
|
129
|
+
if (readOnly) {
|
|
326
130
|
setQuery(null);
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
if ($[61] !== current || $[62] !== disabled || $[63] !== onSelect || $[64] !== query || $[65] !== readOnly || $[66] !== setValue) {
|
|
339
|
-
t23 = (option_2) => {
|
|
340
|
-
const textarea = textareaRef.current;
|
|
341
|
-
if (disabled || readOnly || !query || option_2.disabled || !textarea) return;
|
|
342
|
-
const state_0 = query;
|
|
343
|
-
const caret_0 = textarea.selectionStart;
|
|
344
|
-
setValue(`${current.slice(0, state_0.start)}${state_0.trigger}${option_2.value} ${current.slice(caret_0)}`);
|
|
345
|
-
setQuery(null);
|
|
346
|
-
onSelect?.(option_2, state_0.trigger);
|
|
347
|
-
requestAnimationFrame(() => {
|
|
348
|
-
const at = state_0.start + state_0.trigger.length + option_2.value.length + 1;
|
|
349
|
-
textarea.focus();
|
|
350
|
-
textarea.setSelectionRange(at, at);
|
|
351
|
-
});
|
|
352
|
-
};
|
|
353
|
-
$[61] = current;
|
|
354
|
-
$[62] = disabled;
|
|
355
|
-
$[63] = onSelect;
|
|
356
|
-
$[64] = query;
|
|
357
|
-
$[65] = readOnly;
|
|
358
|
-
$[66] = setValue;
|
|
359
|
-
$[67] = t23;
|
|
360
|
-
} else t23 = $[67];
|
|
361
|
-
const choose = t23;
|
|
362
|
-
const t24 = size === "small";
|
|
363
|
-
const t25 = size === "large";
|
|
364
|
-
const t26 = clearable && !!current && !disabled && !readOnly;
|
|
365
|
-
let t27;
|
|
366
|
-
if ($[68] !== className || $[69] !== disabled || $[70] !== readOnly || $[71] !== t24 || $[72] !== t25 || $[73] !== t26) {
|
|
367
|
-
t27 = clsx("k-mentions", className, {
|
|
368
|
-
"k-mentions-sm": t24,
|
|
369
|
-
"k-mentions-lg": t25,
|
|
370
|
-
"k-mentions-disabled": disabled,
|
|
371
|
-
"k-mentions-readonly": readOnly,
|
|
372
|
-
"k-mentions-has-clear": t26
|
|
373
|
-
});
|
|
374
|
-
$[68] = className;
|
|
375
|
-
$[69] = disabled;
|
|
376
|
-
$[70] = readOnly;
|
|
377
|
-
$[71] = t24;
|
|
378
|
-
$[72] = t25;
|
|
379
|
-
$[73] = t26;
|
|
380
|
-
$[74] = t27;
|
|
381
|
-
} else t27 = $[74];
|
|
382
|
-
const t28 = Boolean(query);
|
|
383
|
-
const t29 = query ? listboxId : void 0;
|
|
384
|
-
const t30 = query && shown[active] ? `${listboxId}-option-${active}` : void 0;
|
|
385
|
-
let t31;
|
|
386
|
-
if ($[75] !== setValue || $[76] !== updateQuery) {
|
|
387
|
-
t31 = (text_0) => {
|
|
388
|
-
setValue(text_0);
|
|
389
|
-
if (composing.current) return;
|
|
390
|
-
if (textareaRef.current) updateQuery(text_0, textareaRef.current.selectionStart, true);
|
|
391
|
-
};
|
|
392
|
-
$[75] = setValue;
|
|
393
|
-
$[76] = updateQuery;
|
|
394
|
-
$[77] = t31;
|
|
395
|
-
} else t31 = $[77];
|
|
396
|
-
let t32;
|
|
397
|
-
if ($[78] === Symbol.for("react.memo_cache_sentinel")) {
|
|
398
|
-
t32 = () => {
|
|
399
|
-
composing.current = true;
|
|
400
|
-
};
|
|
401
|
-
$[78] = t32;
|
|
402
|
-
} else t32 = $[78];
|
|
403
|
-
let t33;
|
|
404
|
-
if ($[79] !== updateQuery) {
|
|
405
|
-
t33 = (event_0) => {
|
|
406
|
-
composing.current = false;
|
|
407
|
-
updateQuery(event_0.currentTarget.value, event_0.currentTarget.selectionStart, true);
|
|
408
|
-
};
|
|
409
|
-
$[79] = updateQuery;
|
|
410
|
-
$[80] = t33;
|
|
411
|
-
} else t33 = $[80];
|
|
412
|
-
let t34;
|
|
413
|
-
let t35;
|
|
414
|
-
let t36;
|
|
415
|
-
if ($[81] !== current || $[82] !== updateQuery) {
|
|
416
|
-
t34 = () => textareaRef.current && updateQuery(current, textareaRef.current.selectionStart);
|
|
417
|
-
t35 = () => textareaRef.current && updateQuery(current, textareaRef.current.selectionStart);
|
|
418
|
-
t36 = (event_1) => {
|
|
419
|
-
if ([
|
|
420
|
-
"ArrowLeft",
|
|
421
|
-
"ArrowRight",
|
|
422
|
-
"Home",
|
|
423
|
-
"End"
|
|
424
|
-
].includes(event_1.key) && textareaRef.current) updateQuery(current, textareaRef.current.selectionStart);
|
|
425
|
-
};
|
|
426
|
-
$[81] = current;
|
|
427
|
-
$[82] = updateQuery;
|
|
428
|
-
$[83] = t34;
|
|
429
|
-
$[84] = t35;
|
|
430
|
-
$[85] = t36;
|
|
431
|
-
} else {
|
|
432
|
-
t34 = $[83];
|
|
433
|
-
t35 = $[84];
|
|
434
|
-
t36 = $[85];
|
|
435
|
-
}
|
|
436
|
-
let t37;
|
|
437
|
-
if ($[86] !== active || $[87] !== choose || $[88] !== moveActive || $[89] !== query || $[90] !== shown) {
|
|
438
|
-
t37 = (event_2) => {
|
|
439
|
-
if (!query) return;
|
|
440
|
-
if ((event_2.key === "ArrowDown" || event_2.key === "ArrowUp") && shown.length) {
|
|
441
|
-
moveActive(event_2.key === "ArrowDown" ? 1 : -1);
|
|
442
|
-
event_2.preventDefault();
|
|
443
|
-
} else if (event_2.key === "Enter" && shown.length) {
|
|
444
|
-
choose(shown[active]);
|
|
445
|
-
event_2.preventDefault();
|
|
446
|
-
} else if (event_2.key === "Escape") {
|
|
447
|
-
event_2.preventDefault();
|
|
448
|
-
event_2.stopPropagation();
|
|
449
|
-
setQuery(null);
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
$[86] = active;
|
|
453
|
-
$[87] = choose;
|
|
454
|
-
$[88] = moveActive;
|
|
455
|
-
$[89] = query;
|
|
456
|
-
$[90] = shown;
|
|
457
|
-
$[91] = t37;
|
|
458
|
-
} else t37 = $[91];
|
|
459
|
-
let t38;
|
|
460
|
-
if ($[92] !== current || $[93] !== disabled || $[94] !== readOnly || $[95] !== rest || $[96] !== rows || $[97] !== shape || $[98] !== size || $[99] !== t28 || $[100] !== t29 || $[101] !== t30 || $[102] !== t31 || $[103] !== t33 || $[104] !== t34 || $[105] !== t35 || $[106] !== t36 || $[107] !== t37 || $[108] !== theme) {
|
|
461
|
-
t38 = /* @__PURE__ */ jsx(textarea_default, {
|
|
462
|
-
...rest,
|
|
463
|
-
ref: textareaRef,
|
|
464
|
-
value: current,
|
|
465
|
-
rows,
|
|
466
|
-
size,
|
|
467
|
-
shape,
|
|
468
|
-
theme,
|
|
469
|
-
disabled,
|
|
470
|
-
readOnly,
|
|
471
|
-
"aria-haspopup": "listbox",
|
|
472
|
-
"aria-expanded": t28,
|
|
473
|
-
"aria-controls": t29,
|
|
474
|
-
"aria-activedescendant": t30,
|
|
475
|
-
onChange: t31,
|
|
476
|
-
onCompositionStart: t32,
|
|
477
|
-
onCompositionEnd: t33,
|
|
478
|
-
onClick: t34,
|
|
479
|
-
onSelect: t35,
|
|
480
|
-
onKeyUp: t36,
|
|
481
|
-
onKeyDown: t37
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const prefix = text.slice(0, caret);
|
|
134
|
+
let found = null;
|
|
135
|
+
effectiveTriggers.forEach((trigger) => {
|
|
136
|
+
const start = prefix.lastIndexOf(trigger);
|
|
137
|
+
if (start >= 0 && !/\s/.test(prefix.slice(start + trigger.length)) && (!found || start > found.start)) found = {
|
|
138
|
+
start,
|
|
139
|
+
trigger,
|
|
140
|
+
text: prefix.slice(start + trigger.length)
|
|
141
|
+
};
|
|
482
142
|
});
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
143
|
+
const nextQuery = found;
|
|
144
|
+
setQuery(nextQuery);
|
|
145
|
+
if (nextQuery) {
|
|
146
|
+
setMatches(onSearch && search && nextQuery.text ? [] : getMatches(nextQuery));
|
|
147
|
+
if (search && nextQuery.text) onSearch?.(nextQuery.text, nextQuery.trigger);
|
|
148
|
+
} else setMatches([]);
|
|
149
|
+
};
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
dropdownRef.current?.querySelector(`#${listboxId}-option-${active}`)?.scrollIntoView({ block: "nearest" });
|
|
152
|
+
}, [active, listboxId]);
|
|
153
|
+
const setValue = (next_0) => {
|
|
154
|
+
if (disabled || readOnly) return;
|
|
155
|
+
setInner(next_0);
|
|
156
|
+
onChange?.(next_0);
|
|
157
|
+
};
|
|
158
|
+
const clear = (event) => {
|
|
159
|
+
if (disabled || readOnly) return;
|
|
160
|
+
event.stopPropagation();
|
|
161
|
+
setValue("");
|
|
162
|
+
setQuery(null);
|
|
163
|
+
onClear?.();
|
|
164
|
+
textareaRef.current?.focus();
|
|
165
|
+
};
|
|
166
|
+
const choose = (option_2) => {
|
|
167
|
+
const textarea = textareaRef.current;
|
|
168
|
+
if (disabled || readOnly || !query || option_2.disabled || !textarea) return;
|
|
169
|
+
const state_0 = query;
|
|
170
|
+
const caret_0 = textarea.selectionStart;
|
|
171
|
+
setValue(`${current.slice(0, state_0.start)}${state_0.trigger}${option_2.value} ${current.slice(caret_0)}`);
|
|
172
|
+
setQuery(null);
|
|
173
|
+
onSelect?.(option_2, state_0.trigger);
|
|
174
|
+
requestAnimationFrame(() => {
|
|
175
|
+
const at = state_0.start + state_0.trigger.length + option_2.value.length + 1;
|
|
176
|
+
textarea.focus();
|
|
177
|
+
textarea.setSelectionRange(at, at);
|
|
515
178
|
});
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
179
|
+
};
|
|
180
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
181
|
+
ref: rootRef,
|
|
182
|
+
className: clsx("k-mentions", className, {
|
|
183
|
+
"k-mentions-sm": size === "small",
|
|
184
|
+
"k-mentions-lg": size === "large",
|
|
185
|
+
"k-mentions-disabled": disabled,
|
|
186
|
+
"k-mentions-readonly": readOnly,
|
|
187
|
+
"k-mentions-has-clear": clearable && !!current && !disabled && !readOnly
|
|
188
|
+
}),
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ jsx(textarea_default, {
|
|
191
|
+
...rest,
|
|
192
|
+
ref: textareaRef,
|
|
193
|
+
value: current,
|
|
194
|
+
rows,
|
|
195
|
+
size,
|
|
196
|
+
shape,
|
|
197
|
+
theme,
|
|
198
|
+
disabled,
|
|
199
|
+
readOnly,
|
|
200
|
+
"aria-haspopup": "listbox",
|
|
201
|
+
"aria-expanded": Boolean(query),
|
|
202
|
+
"aria-controls": query ? listboxId : void 0,
|
|
203
|
+
"aria-activedescendant": query && shown[active] ? `${listboxId}-option-${active}` : void 0,
|
|
204
|
+
onChange: (text_0) => {
|
|
205
|
+
setValue(text_0);
|
|
206
|
+
if (composing.current) return;
|
|
207
|
+
if (textareaRef.current) updateQuery(text_0, textareaRef.current.selectionStart, true);
|
|
208
|
+
},
|
|
209
|
+
onCompositionStart: () => {
|
|
210
|
+
composing.current = true;
|
|
211
|
+
},
|
|
212
|
+
onCompositionEnd: (event_0) => {
|
|
213
|
+
composing.current = false;
|
|
214
|
+
updateQuery(event_0.currentTarget.value, event_0.currentTarget.selectionStart, true);
|
|
215
|
+
},
|
|
216
|
+
onClick: () => textareaRef.current && updateQuery(current, textareaRef.current.selectionStart),
|
|
217
|
+
onSelect: () => textareaRef.current && updateQuery(current, textareaRef.current.selectionStart),
|
|
218
|
+
onKeyUp: (event_1) => {
|
|
219
|
+
if ([
|
|
220
|
+
"ArrowLeft",
|
|
221
|
+
"ArrowRight",
|
|
222
|
+
"Home",
|
|
223
|
+
"End"
|
|
224
|
+
].includes(event_1.key) && textareaRef.current) updateQuery(current, textareaRef.current.selectionStart);
|
|
225
|
+
},
|
|
226
|
+
onKeyDown: (event_2) => {
|
|
227
|
+
if (!query) return;
|
|
228
|
+
if ((event_2.key === "ArrowDown" || event_2.key === "ArrowUp") && shown.length) {
|
|
229
|
+
moveActive(event_2.key === "ArrowDown" ? 1 : -1);
|
|
230
|
+
event_2.preventDefault();
|
|
231
|
+
} else if (event_2.key === "Enter" && shown.length) {
|
|
232
|
+
choose(shown[active]);
|
|
233
|
+
event_2.preventDefault();
|
|
234
|
+
} else if (event_2.key === "Escape") {
|
|
235
|
+
event_2.preventDefault();
|
|
236
|
+
event_2.stopPropagation();
|
|
237
|
+
setQuery(null);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
564
240
|
}),
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
className: t27,
|
|
625
|
-
children: [
|
|
626
|
-
t38,
|
|
627
|
-
t39,
|
|
628
|
-
t48
|
|
629
|
-
]
|
|
630
|
-
});
|
|
631
|
-
$[142] = t27;
|
|
632
|
-
$[143] = t38;
|
|
633
|
-
$[144] = t39;
|
|
634
|
-
$[145] = t48;
|
|
635
|
-
$[146] = t49;
|
|
636
|
-
} else t49 = $[146];
|
|
637
|
-
return t49;
|
|
241
|
+
clearable && current && !disabled && !readOnly && /* @__PURE__ */ jsx(Icon, {
|
|
242
|
+
className: "k-mentions-clearable",
|
|
243
|
+
type: CircleX,
|
|
244
|
+
role: "button",
|
|
245
|
+
tabIndex: 0,
|
|
246
|
+
"aria-label": "Clear",
|
|
247
|
+
onPointerDown: (event_3) => event_3.preventDefault(),
|
|
248
|
+
onClick: clear,
|
|
249
|
+
onKeyDown: (event_4) => {
|
|
250
|
+
if (event_4.key === "Enter" || event_4.key === " ") clear(event_4);
|
|
251
|
+
}
|
|
252
|
+
}),
|
|
253
|
+
/* @__PURE__ */ jsx(Popup, {
|
|
254
|
+
raw: true,
|
|
255
|
+
open: !!query,
|
|
256
|
+
target: rootRef,
|
|
257
|
+
trigger: "manual",
|
|
258
|
+
placement,
|
|
259
|
+
prefixCls: "k-mentions-dropdown",
|
|
260
|
+
transitionName: "k-select",
|
|
261
|
+
offset: 4,
|
|
262
|
+
getAnchorPosition,
|
|
263
|
+
style: { minWidth: popupWidth },
|
|
264
|
+
destroyOnClose,
|
|
265
|
+
outsideEvent: "mousedown",
|
|
266
|
+
onOpenChange: (next_1) => {
|
|
267
|
+
if (!next_1) setQuery(null);
|
|
268
|
+
},
|
|
269
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
270
|
+
ref: dropdownRef,
|
|
271
|
+
id: listboxId,
|
|
272
|
+
className: clsx("k-select-dropdown", "k-mentions-dropdown", {
|
|
273
|
+
"k-select-dropdown-sm": size === "small",
|
|
274
|
+
"k-select-dropdown-lg": size === "large"
|
|
275
|
+
}),
|
|
276
|
+
role: "listbox",
|
|
277
|
+
children: loading ? /* @__PURE__ */ jsxs("div", {
|
|
278
|
+
className: "k-select-loading k-mentions-loading",
|
|
279
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
280
|
+
type: Loading,
|
|
281
|
+
spin: true
|
|
282
|
+
}), loadingText && /* @__PURE__ */ jsx("span", { children: loadingText })]
|
|
283
|
+
}) : shown.length ? /* @__PURE__ */ jsx("ul", { children: shown.map((option_3, index_2) => /* @__PURE__ */ jsx("li", {
|
|
284
|
+
id: `${listboxId}-option-${index_2}`,
|
|
285
|
+
role: "option",
|
|
286
|
+
"aria-selected": active === index_2,
|
|
287
|
+
className: clsx("k-select-item", {
|
|
288
|
+
"k-select-item-active": active === index_2,
|
|
289
|
+
"k-select-item-disabled": option_3.disabled
|
|
290
|
+
}),
|
|
291
|
+
onMouseDown: (event_5) => event_5.preventDefault(),
|
|
292
|
+
onMouseEnter: () => !disabled && !readOnly && !option_3.disabled && setActive(index_2),
|
|
293
|
+
onClick: () => choose(option_3),
|
|
294
|
+
children: option_3.label ?? option_3.value
|
|
295
|
+
}, option_3.value)) }) : /* @__PURE__ */ jsx(Empty, { description: emptyText })
|
|
296
|
+
})
|
|
297
|
+
})
|
|
298
|
+
]
|
|
299
|
+
});
|
|
638
300
|
};
|
|
639
301
|
var mentions_default = createFormFieldComponent(Mentions);
|
|
640
|
-
function _temp(next) {
|
|
641
|
-
return next ?? "";
|
|
642
|
-
}
|
|
643
|
-
function _temp2(item) {
|
|
644
|
-
return typeof item === "string" ? {
|
|
645
|
-
value: item,
|
|
646
|
-
label: item
|
|
647
|
-
} : item;
|
|
648
|
-
}
|
|
649
|
-
function _temp3(option) {
|
|
650
|
-
return !option.disabled;
|
|
651
|
-
}
|
|
652
|
-
function _temp4(items) {
|
|
653
|
-
const index = items.findIndex(_temp3);
|
|
654
|
-
return index < 0 ? 0 : index;
|
|
655
|
-
}
|
|
656
|
-
function _temp5(option_0, index_0) {
|
|
657
|
-
return !option_0.disabled ? index_0 : -1;
|
|
658
|
-
}
|
|
659
|
-
function _temp6(index_1) {
|
|
660
|
-
return index_1 >= 0;
|
|
661
|
-
}
|
|
662
|
-
function _temp7(event_3) {
|
|
663
|
-
return event_3.preventDefault();
|
|
664
|
-
}
|
|
665
|
-
function _temp8(event_5) {
|
|
666
|
-
return event_5.preventDefault();
|
|
667
|
-
}
|
|
668
|
-
//#endregion
|
|
669
302
|
export { mentions_default as default };
|