react-kui 3.2.0 → 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 +825 -168
- 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 +72 -196
- 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 +25 -15
- package/es/table/utils.js +3 -5
- 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/segmented/index.d.cts +2 -1
- package/types/segmented/index.d.ts +2 -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/tree/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
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 { Transition } from "../base/transition.js";
|
|
10
|
-
import { ChevronRight, CircleMinus, CirclePlus } from "../node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js";
|
|
11
|
-
import Icon from "../icon/index.js";
|
|
12
9
|
import { useValue } from "../utils/use-value.js";
|
|
10
|
+
import { ChevronRight, CircleMinus, CirclePlus } from "../node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js";
|
|
11
|
+
import { getTransitionProps } from "../base/transition-props.js";
|
|
12
|
+
import { Transition } from "../base/transition.js";
|
|
13
13
|
import Button from "../button/button.js";
|
|
14
14
|
import checkbox_default from "../checkbox/index.js";
|
|
15
|
-
import
|
|
16
|
-
import { getTransitionProps } from "../base/transition-props.js";
|
|
15
|
+
import Icon from "../icon/index.js";
|
|
17
16
|
import Spin from "../spin/index.js";
|
|
17
|
+
import VirtualList from "../virtual-list/index.js";
|
|
18
18
|
import { buildTree, updateParentIndeterminate } from "./utils.js";
|
|
19
|
-
import { c } from "react/compiler-runtime";
|
|
20
19
|
import clsx from "clsx";
|
|
21
20
|
import { forwardRef, useCallback, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
22
21
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { c } from "react/compiler-runtime";
|
|
23
23
|
import { TransitionGroup } from "react-transition-group";
|
|
24
|
-
|
|
24
|
+
// components/tree/index.tsx
|
|
25
25
|
var findRaw = (nodes, key) => {
|
|
26
26
|
for (const node of nodes) {
|
|
27
27
|
if (node.key === key) return node;
|
|
@@ -500,5 +500,4 @@ var Tree = forwardRef(function Tree({ data = [], selectedKeys, expandedKeys, che
|
|
|
500
500
|
children: content
|
|
501
501
|
}) : content;
|
|
502
502
|
});
|
|
503
|
-
//#endregion
|
|
504
503
|
export { Tree as default };
|
package/es/tree/utils.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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
|
-
|
|
9
|
+
// components/tree/utils.ts
|
|
10
10
|
var updateParentIndeterminate = (nodes, parentKey) => {
|
|
11
11
|
let parent;
|
|
12
12
|
for (let i = 0; i < nodes.length; i++) if (nodes[i].key === parentKey) {
|
|
@@ -97,5 +97,4 @@ var buildTree = ({ data, expandedKeys = [], selectedKeys = [], checkedKeys = [],
|
|
|
97
97
|
}
|
|
98
98
|
return result;
|
|
99
99
|
};
|
|
100
|
-
//#endregion
|
|
101
100
|
export { buildTree, updateParentIndeterminate };
|
package/es/tree-select/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
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 {
|
|
10
|
-
import
|
|
9
|
+
import { renderSelectionTags } from "../utils/selection-tags.js";
|
|
10
|
+
import { useValue } from "../utils/use-value.js";
|
|
11
11
|
import { resolveTheme, useFormAppearance } from "../config/use-config-appearance.js";
|
|
12
|
+
import { createFormFieldComponent } from "../form/field-context.js";
|
|
12
13
|
import { ChevronDown, CircleX, LoaderCircle } from "../node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js";
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
14
|
+
import Popup from "../popup/index.js";
|
|
15
|
+
import { ConfigContext, DEFAULT_LOCALE } from "../config/config-context.js";
|
|
15
16
|
import Empty from "../empty/index.js";
|
|
16
|
-
import
|
|
17
|
-
import { renderSelectionTags } from "../utils/selection-tags.js";
|
|
17
|
+
import Icon from "../icon/index.js";
|
|
18
18
|
import Tree from "../tree/index.js";
|
|
19
19
|
import clsx from "clsx";
|
|
20
20
|
import { useCallback, useContext, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
21
21
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
-
|
|
22
|
+
// components/tree-select/index.tsx
|
|
23
23
|
var normalize = (value, multiple) => {
|
|
24
24
|
if (value === null || value === void 0 || value === "") return [];
|
|
25
25
|
return (multiple ? Array.isArray(value) ? value : [value] : [Array.isArray(value) ? value[0] : value]).filter((item) => item !== void 0).map(String);
|
|
@@ -319,5 +319,4 @@ function TreeSelect({ placeholder, size: sizeProp, placement = "bottom-left", de
|
|
|
319
319
|
}), overlay] });
|
|
320
320
|
}
|
|
321
321
|
var tree_select_default = createFormFieldComponent(TreeSelect);
|
|
322
|
-
//#endregion
|
|
323
322
|
export { tree_select_default as default };
|
package/es/typography/index.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
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 { useValue } from "../utils/use-value.js";
|
|
9
10
|
import { Check, Copy, Pencil } from "../node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js";
|
|
10
11
|
import Icon from "../icon/index.js";
|
|
11
|
-
import { useValue } from "../utils/use-value.js";
|
|
12
12
|
import Tooltip from "../tooltip/index.js";
|
|
13
|
-
import { c } from "react/compiler-runtime";
|
|
14
13
|
import clsx from "clsx";
|
|
15
14
|
import React, { isValidElement, useEffect, useRef, useState } from "react";
|
|
16
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
-
|
|
16
|
+
// components/typography/index.tsx
|
|
18
17
|
var getReactNodeText = (node) => {
|
|
19
18
|
if (node == null || typeof node === "boolean") return "";
|
|
20
19
|
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
@@ -23,87 +22,9 @@ var getReactNodeText = (node) => {
|
|
|
23
22
|
return "";
|
|
24
23
|
};
|
|
25
24
|
function createTypography(defaultTag, name) {
|
|
26
|
-
const Component = React.forwardRef((
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
let className;
|
|
30
|
-
let code;
|
|
31
|
-
let deleted;
|
|
32
|
-
let disabled;
|
|
33
|
-
let italic;
|
|
34
|
-
let mark;
|
|
35
|
-
let onChange;
|
|
36
|
-
let onCopy;
|
|
37
|
-
let rest;
|
|
38
|
-
let strong;
|
|
39
|
-
let t1;
|
|
40
|
-
let t2;
|
|
41
|
-
let t3;
|
|
42
|
-
let t4;
|
|
43
|
-
let type;
|
|
44
|
-
let underline;
|
|
45
|
-
let value;
|
|
46
|
-
if ($[0] !== t0) {
|
|
47
|
-
({value, tag: t1, type, strong, italic, underline, delete: deleted, mark, code, disabled, copyable: t2, editable: t3, ellipsis: t4, onCopy, onChange, children, className, ...rest} = t0);
|
|
48
|
-
$[0] = t0;
|
|
49
|
-
$[1] = children;
|
|
50
|
-
$[2] = className;
|
|
51
|
-
$[3] = code;
|
|
52
|
-
$[4] = deleted;
|
|
53
|
-
$[5] = disabled;
|
|
54
|
-
$[6] = italic;
|
|
55
|
-
$[7] = mark;
|
|
56
|
-
$[8] = onChange;
|
|
57
|
-
$[9] = onCopy;
|
|
58
|
-
$[10] = rest;
|
|
59
|
-
$[11] = strong;
|
|
60
|
-
$[12] = t1;
|
|
61
|
-
$[13] = t2;
|
|
62
|
-
$[14] = t3;
|
|
63
|
-
$[15] = t4;
|
|
64
|
-
$[16] = type;
|
|
65
|
-
$[17] = underline;
|
|
66
|
-
$[18] = value;
|
|
67
|
-
} else {
|
|
68
|
-
children = $[1];
|
|
69
|
-
className = $[2];
|
|
70
|
-
code = $[3];
|
|
71
|
-
deleted = $[4];
|
|
72
|
-
disabled = $[5];
|
|
73
|
-
italic = $[6];
|
|
74
|
-
mark = $[7];
|
|
75
|
-
onChange = $[8];
|
|
76
|
-
onCopy = $[9];
|
|
77
|
-
rest = $[10];
|
|
78
|
-
strong = $[11];
|
|
79
|
-
t1 = $[12];
|
|
80
|
-
t2 = $[13];
|
|
81
|
-
t3 = $[14];
|
|
82
|
-
t4 = $[15];
|
|
83
|
-
type = $[16];
|
|
84
|
-
underline = $[17];
|
|
85
|
-
value = $[18];
|
|
86
|
-
}
|
|
87
|
-
const tag = t1 === void 0 ? defaultTag : t1;
|
|
88
|
-
const copyable = t2 === void 0 ? false : t2;
|
|
89
|
-
const editable = t3 === void 0 ? false : t3;
|
|
90
|
-
const ellipsis = t4 === void 0 ? false : t4;
|
|
91
|
-
let t5;
|
|
92
|
-
if ($[19] !== children || $[20] !== value) {
|
|
93
|
-
t5 = value ?? (children !== void 0 ? getReactNodeText(children) : "");
|
|
94
|
-
$[19] = children;
|
|
95
|
-
$[20] = value;
|
|
96
|
-
$[21] = t5;
|
|
97
|
-
} else t5 = $[21];
|
|
98
|
-
const initialText = t5;
|
|
99
|
-
let t6;
|
|
100
|
-
if ($[22] !== children || $[23] !== value) {
|
|
101
|
-
t6 = value ?? getReactNodeText(children);
|
|
102
|
-
$[22] = children;
|
|
103
|
-
$[23] = value;
|
|
104
|
-
$[24] = t6;
|
|
105
|
-
} else t6 = $[24];
|
|
106
|
-
const [innerValue, setInnerValue] = useValue(t6, _temp);
|
|
25
|
+
const Component = React.forwardRef(({ value, tag = defaultTag, type, strong, italic, underline, delete: deleted, mark, code, disabled, copyable = false, editable = false, ellipsis = false, onCopy, onChange, children, className, ...rest }, ref) => {
|
|
26
|
+
const initialText = value ?? (children !== void 0 ? getReactNodeText(children) : "");
|
|
27
|
+
const [innerValue, setInnerValue] = useValue(value ?? getReactNodeText(children), (next) => next);
|
|
107
28
|
const [draft, setDraft] = useState(initialText);
|
|
108
29
|
const [editing, setEditing] = useState(false);
|
|
109
30
|
const [copied, setCopied] = useState(false);
|
|
@@ -111,78 +32,28 @@ function createTypography(defaultTag, name) {
|
|
|
111
32
|
const [edited, setEdited] = useState(false);
|
|
112
33
|
const copiedTimer = useRef(void 0);
|
|
113
34
|
const text = innerValue;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
135
|
-
$[27] = draft;
|
|
136
|
-
$[28] = editing;
|
|
137
|
-
$[29] = onChange;
|
|
138
|
-
$[30] = setInnerValue;
|
|
139
|
-
$[31] = t9;
|
|
140
|
-
} else t9 = $[31];
|
|
141
|
-
const finishEdit = t9;
|
|
142
|
-
if (editing) {
|
|
143
|
-
const t10 = ref;
|
|
144
|
-
let t11;
|
|
145
|
-
if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
|
|
146
|
-
t11 = (event) => setDraft(event.target.value);
|
|
147
|
-
$[32] = t11;
|
|
148
|
-
} else t11 = $[32];
|
|
149
|
-
let t12;
|
|
150
|
-
let t13;
|
|
151
|
-
if ($[33] !== finishEdit) {
|
|
152
|
-
t12 = () => {
|
|
153
|
-
finishEdit();
|
|
154
|
-
};
|
|
155
|
-
t13 = (event_0) => {
|
|
156
|
-
if (event_0.key === "Enter") finishEdit();
|
|
157
|
-
};
|
|
158
|
-
$[33] = finishEdit;
|
|
159
|
-
$[34] = t12;
|
|
160
|
-
$[35] = t13;
|
|
161
|
-
} else {
|
|
162
|
-
t12 = $[34];
|
|
163
|
-
t13 = $[35];
|
|
35
|
+
useEffect(() => () => window.clearTimeout(copiedTimer.current), []);
|
|
36
|
+
const finishEdit = () => {
|
|
37
|
+
if (!editing) return;
|
|
38
|
+
setEditing(false);
|
|
39
|
+
setInnerValue(draft);
|
|
40
|
+
setEdited(true);
|
|
41
|
+
onChange?.(draft);
|
|
42
|
+
};
|
|
43
|
+
if (editing) return /* @__PURE__ */ jsx("input", {
|
|
44
|
+
...rest,
|
|
45
|
+
ref,
|
|
46
|
+
className: "k-typography-editor",
|
|
47
|
+
value: draft,
|
|
48
|
+
autoFocus: true,
|
|
49
|
+
onChange: (event) => setDraft(event.target.value),
|
|
50
|
+
onBlur: () => {
|
|
51
|
+
finishEdit();
|
|
52
|
+
},
|
|
53
|
+
onKeyDown: (event_0) => {
|
|
54
|
+
if (event_0.key === "Enter") finishEdit();
|
|
164
55
|
}
|
|
165
|
-
|
|
166
|
-
if ($[36] !== draft || $[37] !== rest || $[38] !== t10 || $[39] !== t12 || $[40] !== t13) {
|
|
167
|
-
t14 = /* @__PURE__ */ jsx("input", {
|
|
168
|
-
...rest,
|
|
169
|
-
ref: t10,
|
|
170
|
-
className: "k-typography-editor",
|
|
171
|
-
value: draft,
|
|
172
|
-
autoFocus: true,
|
|
173
|
-
onChange: t11,
|
|
174
|
-
onBlur: t12,
|
|
175
|
-
onKeyDown: t13
|
|
176
|
-
});
|
|
177
|
-
$[36] = draft;
|
|
178
|
-
$[37] = rest;
|
|
179
|
-
$[38] = t10;
|
|
180
|
-
$[39] = t12;
|
|
181
|
-
$[40] = t13;
|
|
182
|
-
$[41] = t14;
|
|
183
|
-
} else t14 = $[41];
|
|
184
|
-
return t14;
|
|
185
|
-
}
|
|
56
|
+
});
|
|
186
57
|
const options = typeof ellipsis === "object" ? ellipsis : void 0;
|
|
187
58
|
const rows = Math.max(1, Math.floor(typeof ellipsis === "number" ? ellipsis : options?.rows ?? 1));
|
|
188
59
|
const isEllipsis = Boolean(ellipsis) && !expanded;
|
|
@@ -190,27 +61,21 @@ function createTypography(defaultTag, name) {
|
|
|
190
61
|
const copyOptions = typeof copyable === "object" ? copyable : void 0;
|
|
191
62
|
const editableOptions = typeof editable === "object" ? editable : void 0;
|
|
192
63
|
const tooltipTitle = options?.tooltip ? typeof options.tooltip === "string" ? options.tooltip : text : void 0;
|
|
193
|
-
const withTooltip =
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
} else t10 = $[45];
|
|
209
|
-
const copy = t10;
|
|
210
|
-
const t11 = type && `k-typography-${type}`;
|
|
211
|
-
let t12;
|
|
212
|
-
if ($[46] !== className || $[47] !== code || $[48] !== deleted || $[49] !== disabled || $[50] !== ellipsis || $[51] !== italic || $[52] !== mark || $[53] !== strong || $[54] !== t11 || $[55] !== underline) {
|
|
213
|
-
t12 = clsx("k-typography", `k-typography-${name}`, t11, {
|
|
64
|
+
const withTooltip = (node, title) => title ? /* @__PURE__ */ jsx(Tooltip, {
|
|
65
|
+
title,
|
|
66
|
+
children: node
|
|
67
|
+
}) : node;
|
|
68
|
+
const copy = async () => {
|
|
69
|
+
if (disabled) return;
|
|
70
|
+
await navigator.clipboard?.writeText(text);
|
|
71
|
+
setCopied(true);
|
|
72
|
+
onCopy?.(text);
|
|
73
|
+
window.clearTimeout(copiedTimer.current);
|
|
74
|
+
copiedTimer.current = window.setTimeout(() => setCopied(false), 1500);
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ jsxs(Tag, {
|
|
77
|
+
...rest,
|
|
78
|
+
className: clsx("k-typography", `k-typography-${name}`, type && `k-typography-${type}`, {
|
|
214
79
|
"is-strong": strong,
|
|
215
80
|
"is-italic": italic,
|
|
216
81
|
"is-underline": underline,
|
|
@@ -219,125 +84,39 @@ function createTypography(defaultTag, name) {
|
|
|
219
84
|
"is-code": code,
|
|
220
85
|
"is-disabled": disabled,
|
|
221
86
|
"has-ellipsis": ellipsis
|
|
222
|
-
}, className)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
children: t16
|
|
256
|
-
});
|
|
257
|
-
$[62] = t14;
|
|
258
|
-
$[63] = t15;
|
|
259
|
-
$[64] = t16;
|
|
260
|
-
$[65] = t17;
|
|
261
|
-
} else t17 = $[65];
|
|
262
|
-
const t18 = isEllipsis ? tooltipTitle : void 0;
|
|
263
|
-
let t19;
|
|
264
|
-
if ($[66] !== t17 || $[67] !== t18) {
|
|
265
|
-
t19 = withTooltip(t17, t18);
|
|
266
|
-
$[66] = t17;
|
|
267
|
-
$[67] = t18;
|
|
268
|
-
$[68] = t19;
|
|
269
|
-
} else t19 = $[68];
|
|
270
|
-
let t20;
|
|
271
|
-
if ($[69] !== disabled || $[70] !== expanded || $[71] !== options) {
|
|
272
|
-
t20 = options?.expandable && /* @__PURE__ */ jsx("button", {
|
|
273
|
-
className: "k-typography-action k-typography-expand",
|
|
274
|
-
disabled,
|
|
275
|
-
"aria-expanded": expanded,
|
|
276
|
-
onClick: () => setExpanded(!expanded),
|
|
277
|
-
children: expanded ? options.collapseText ?? "Collapse" : options.expandText ?? "More"
|
|
278
|
-
});
|
|
279
|
-
$[69] = disabled;
|
|
280
|
-
$[70] = expanded;
|
|
281
|
-
$[71] = options;
|
|
282
|
-
$[72] = t20;
|
|
283
|
-
} else t20 = $[72];
|
|
284
|
-
let t21;
|
|
285
|
-
if ($[73] !== disabled || $[74] !== editable || $[75] !== editableOptions?.tooltip || $[76] !== text) {
|
|
286
|
-
t21 = editable && withTooltip(/* @__PURE__ */ jsx("button", {
|
|
287
|
-
className: "k-typography-action",
|
|
288
|
-
disabled,
|
|
289
|
-
onClick: () => {
|
|
290
|
-
setDraft(text);
|
|
291
|
-
setEditing(true);
|
|
292
|
-
},
|
|
293
|
-
"aria-label": "Edit",
|
|
294
|
-
children: /* @__PURE__ */ jsx(Icon, { type: Pencil })
|
|
295
|
-
}), editableOptions?.tooltip);
|
|
296
|
-
$[73] = disabled;
|
|
297
|
-
$[74] = editable;
|
|
298
|
-
$[75] = editableOptions?.tooltip;
|
|
299
|
-
$[76] = text;
|
|
300
|
-
$[77] = t21;
|
|
301
|
-
} else t21 = $[77];
|
|
302
|
-
let t22;
|
|
303
|
-
if ($[78] !== copied || $[79] !== copy || $[80] !== copyOptions?.copiedTooltip || $[81] !== copyOptions?.tooltip || $[82] !== copyable || $[83] !== disabled) {
|
|
304
|
-
t22 = copyable && withTooltip(/* @__PURE__ */ jsx("button", {
|
|
305
|
-
className: "k-typography-action",
|
|
306
|
-
disabled,
|
|
307
|
-
onClick: () => void copy(),
|
|
308
|
-
"aria-label": "Copy",
|
|
309
|
-
children: /* @__PURE__ */ jsx(Icon, { type: copied ? Check : Copy })
|
|
310
|
-
}), copied ? copyOptions?.copiedTooltip ?? copyOptions?.tooltip : copyOptions?.tooltip);
|
|
311
|
-
$[78] = copied;
|
|
312
|
-
$[79] = copy;
|
|
313
|
-
$[80] = copyOptions?.copiedTooltip;
|
|
314
|
-
$[81] = copyOptions?.tooltip;
|
|
315
|
-
$[82] = copyable;
|
|
316
|
-
$[83] = disabled;
|
|
317
|
-
$[84] = t22;
|
|
318
|
-
} else t22 = $[84];
|
|
319
|
-
let t23;
|
|
320
|
-
if ($[85] !== Tag || $[86] !== rest || $[87] !== t12 || $[88] !== t19 || $[89] !== t20 || $[90] !== t21 || $[91] !== t22) {
|
|
321
|
-
t23 = /* @__PURE__ */ jsxs(Tag, {
|
|
322
|
-
...rest,
|
|
323
|
-
className: t12,
|
|
324
|
-
children: [
|
|
325
|
-
t19,
|
|
326
|
-
t20,
|
|
327
|
-
t21,
|
|
328
|
-
t22
|
|
329
|
-
]
|
|
330
|
-
});
|
|
331
|
-
$[85] = Tag;
|
|
332
|
-
$[86] = rest;
|
|
333
|
-
$[87] = t12;
|
|
334
|
-
$[88] = t19;
|
|
335
|
-
$[89] = t20;
|
|
336
|
-
$[90] = t21;
|
|
337
|
-
$[91] = t22;
|
|
338
|
-
$[92] = t23;
|
|
339
|
-
} else t23 = $[92];
|
|
340
|
-
return t23;
|
|
87
|
+
}, className),
|
|
88
|
+
children: [
|
|
89
|
+
withTooltip(/* @__PURE__ */ jsx("span", {
|
|
90
|
+
className: clsx("k-typography-content", isEllipsis && "is-ellipsis"),
|
|
91
|
+
style: isEllipsis ? { WebkitLineClamp: rows } : void 0,
|
|
92
|
+
children: value !== void 0 || edited ? innerValue : children ?? innerValue
|
|
93
|
+
}), isEllipsis ? tooltipTitle : void 0),
|
|
94
|
+
options?.expandable && /* @__PURE__ */ jsx("button", {
|
|
95
|
+
className: "k-typography-action k-typography-expand",
|
|
96
|
+
disabled,
|
|
97
|
+
"aria-expanded": expanded,
|
|
98
|
+
onClick: () => setExpanded(!expanded),
|
|
99
|
+
children: expanded ? options.collapseText ?? "Collapse" : options.expandText ?? "More"
|
|
100
|
+
}),
|
|
101
|
+
editable && withTooltip(/* @__PURE__ */ jsx("button", {
|
|
102
|
+
className: "k-typography-action",
|
|
103
|
+
disabled,
|
|
104
|
+
onClick: () => {
|
|
105
|
+
setDraft(text);
|
|
106
|
+
setEditing(true);
|
|
107
|
+
},
|
|
108
|
+
"aria-label": "Edit",
|
|
109
|
+
children: /* @__PURE__ */ jsx(Icon, { type: Pencil })
|
|
110
|
+
}), editableOptions?.tooltip),
|
|
111
|
+
copyable && withTooltip(/* @__PURE__ */ jsx("button", {
|
|
112
|
+
className: "k-typography-action",
|
|
113
|
+
disabled,
|
|
114
|
+
onClick: () => void copy(),
|
|
115
|
+
"aria-label": "Copy",
|
|
116
|
+
children: /* @__PURE__ */ jsx(Icon, { type: copied ? Check : Copy })
|
|
117
|
+
}), copied ? copyOptions?.copiedTooltip ?? copyOptions?.tooltip : copyOptions?.tooltip)
|
|
118
|
+
]
|
|
119
|
+
});
|
|
341
120
|
});
|
|
342
121
|
Component.displayName = name;
|
|
343
122
|
return Component;
|
|
@@ -346,14 +125,4 @@ var TypographyText = createTypography("span", "text");
|
|
|
346
125
|
var TypographyParagraph = createTypography("p", "paragraph");
|
|
347
126
|
var TypographyTitle = createTypography("h2", "title");
|
|
348
127
|
var Typography = createTypography("span", "text");
|
|
349
|
-
function _temp(next) {
|
|
350
|
-
return next;
|
|
351
|
-
}
|
|
352
|
-
function _temp2(node, title) {
|
|
353
|
-
return title ? /* @__PURE__ */ jsx(Tooltip, {
|
|
354
|
-
title,
|
|
355
|
-
children: node
|
|
356
|
-
}) : node;
|
|
357
|
-
}
|
|
358
|
-
//#endregion
|
|
359
128
|
export { TypographyParagraph, TypographyText, TypographyTitle, Typography as default };
|