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
|
@@ -1,5 +1,5 @@
|
|
|
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
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { createContext } from "react";
|
|
10
|
-
|
|
10
|
+
// components/avatar/avatar-group-context.ts
|
|
11
11
|
var AvatarGroupContext = createContext(null);
|
|
12
|
-
//#endregion
|
|
13
12
|
export { AvatarGroupContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
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
|
|
@@ -7,139 +7,47 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { getChildren } from "../utils/react-node.js";
|
|
10
|
-
import { AvatarGroupContext } from "./avatar-group-context.js";
|
|
11
10
|
import Avatar from "./avatar.js";
|
|
12
|
-
import {
|
|
11
|
+
import { AvatarGroupContext } from "./avatar-group-context.js";
|
|
13
12
|
import clsx from "clsx";
|
|
14
13
|
import "react";
|
|
15
14
|
import { jsx } from "react/jsx-runtime";
|
|
16
|
-
|
|
17
|
-
var AvatarGroup = (
|
|
18
|
-
const
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
$[0] = t0;
|
|
30
|
-
$[1] = children;
|
|
31
|
-
$[2] = maxCount;
|
|
32
|
-
$[3] = rest;
|
|
33
|
-
$[4] = spacing;
|
|
34
|
-
$[5] = style;
|
|
35
|
-
$[6] = t1;
|
|
36
|
-
$[7] = t2;
|
|
37
|
-
$[8] = t3;
|
|
38
|
-
} else {
|
|
39
|
-
children = $[1];
|
|
40
|
-
maxCount = $[2];
|
|
41
|
-
rest = $[3];
|
|
42
|
-
spacing = $[4];
|
|
43
|
-
style = $[5];
|
|
44
|
-
t1 = $[6];
|
|
45
|
-
t2 = $[7];
|
|
46
|
-
t3 = $[8];
|
|
15
|
+
// components/avatar/avatar-group.tsx
|
|
16
|
+
var AvatarGroup = ({ maxCount, spacing, shape = "circle", size = "default", children, className = "", style, ...rest }) => {
|
|
17
|
+
const childList = getChildren(children);
|
|
18
|
+
let childrenToShow = [...childList];
|
|
19
|
+
if (maxCount != null && maxCount >= 0 && maxCount < childList.length) {
|
|
20
|
+
const visibleCount = Math.floor(maxCount);
|
|
21
|
+
childrenToShow = childList.slice(0, visibleCount);
|
|
22
|
+
const restCount = childList.length - visibleCount;
|
|
23
|
+
childrenToShow.push(/* @__PURE__ */ jsx(Avatar, {
|
|
24
|
+
shape,
|
|
25
|
+
size,
|
|
26
|
+
children: `+${restCount}`
|
|
27
|
+
}, "avatar-rest-count"));
|
|
47
28
|
}
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
t5 = /* @__PURE__ */ jsx(Avatar, {
|
|
62
|
-
shape,
|
|
63
|
-
size,
|
|
64
|
-
children: t4
|
|
65
|
-
}, "avatar-rest-count");
|
|
66
|
-
$[14] = shape;
|
|
67
|
-
$[15] = size;
|
|
68
|
-
$[16] = t4;
|
|
69
|
-
$[17] = t5;
|
|
70
|
-
} else t5 = $[17];
|
|
71
|
-
childrenToShow.push(t5);
|
|
72
|
-
}
|
|
73
|
-
$[9] = children;
|
|
74
|
-
$[10] = maxCount;
|
|
75
|
-
$[11] = shape;
|
|
76
|
-
$[12] = size;
|
|
77
|
-
$[13] = childrenToShow;
|
|
78
|
-
} else childrenToShow = $[13];
|
|
79
|
-
let t4;
|
|
80
|
-
if ($[18] !== className) {
|
|
81
|
-
t4 = clsx("k-avatar-group", className);
|
|
82
|
-
$[18] = className;
|
|
83
|
-
$[19] = t4;
|
|
84
|
-
} else t4 = $[19];
|
|
85
|
-
const classes = t4;
|
|
86
|
-
let t5;
|
|
87
|
-
if ($[20] !== size) {
|
|
88
|
-
t5 = typeof size === "number" ? Math.max(0, Math.round(size / 4)) : {
|
|
89
|
-
small: 6,
|
|
90
|
-
default: 8,
|
|
91
|
-
large: 10
|
|
92
|
-
}[size];
|
|
93
|
-
$[20] = size;
|
|
94
|
-
$[21] = t5;
|
|
95
|
-
} else t5 = $[21];
|
|
96
|
-
const t6 = `-${Math.max(0, spacing ?? t5)}px`;
|
|
97
|
-
let t7;
|
|
98
|
-
if ($[22] !== style || $[23] !== t6) {
|
|
99
|
-
t7 = {
|
|
100
|
-
...style,
|
|
101
|
-
"--kui-avatar-group-overlap": t6
|
|
102
|
-
};
|
|
103
|
-
$[22] = style;
|
|
104
|
-
$[23] = t6;
|
|
105
|
-
$[24] = t7;
|
|
106
|
-
} else t7 = $[24];
|
|
107
|
-
const groupStyle = t7;
|
|
108
|
-
let t8;
|
|
109
|
-
if ($[25] !== shape || $[26] !== size) {
|
|
110
|
-
t8 = {
|
|
29
|
+
const classes = clsx("k-avatar-group", className);
|
|
30
|
+
const defaultOverlap = typeof size === "number" ? Math.max(0, Math.round(size / 4)) : {
|
|
31
|
+
small: 6,
|
|
32
|
+
default: 8,
|
|
33
|
+
large: 10
|
|
34
|
+
}[size];
|
|
35
|
+
const overlap = Math.max(0, spacing ?? defaultOverlap);
|
|
36
|
+
const groupStyle = {
|
|
37
|
+
...style,
|
|
38
|
+
"--kui-avatar-group-overlap": `-${overlap}px`
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ jsx(AvatarGroupContext.Provider, {
|
|
41
|
+
value: {
|
|
111
42
|
shape,
|
|
112
43
|
size
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
$[26] = size;
|
|
116
|
-
$[27] = t8;
|
|
117
|
-
} else t8 = $[27];
|
|
118
|
-
let t9;
|
|
119
|
-
if ($[28] !== childrenToShow || $[29] !== classes || $[30] !== groupStyle || $[31] !== rest) {
|
|
120
|
-
t9 = /* @__PURE__ */ jsx("div", {
|
|
44
|
+
},
|
|
45
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
121
46
|
className: classes,
|
|
122
47
|
style: groupStyle,
|
|
123
48
|
...rest,
|
|
124
49
|
children: childrenToShow
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
$[29] = classes;
|
|
128
|
-
$[30] = groupStyle;
|
|
129
|
-
$[31] = rest;
|
|
130
|
-
$[32] = t9;
|
|
131
|
-
} else t9 = $[32];
|
|
132
|
-
let t10;
|
|
133
|
-
if ($[33] !== t8 || $[34] !== t9) {
|
|
134
|
-
t10 = /* @__PURE__ */ jsx(AvatarGroupContext.Provider, {
|
|
135
|
-
value: t8,
|
|
136
|
-
children: t9
|
|
137
|
-
});
|
|
138
|
-
$[33] = t8;
|
|
139
|
-
$[34] = t9;
|
|
140
|
-
$[35] = t10;
|
|
141
|
-
} else t10 = $[35];
|
|
142
|
-
return t10;
|
|
50
|
+
})
|
|
51
|
+
});
|
|
143
52
|
};
|
|
144
|
-
//#endregion
|
|
145
53
|
export { AvatarGroup as default };
|
package/es/avatar/avatar.js
CHANGED
|
@@ -1,150 +1,77 @@
|
|
|
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 { getChildren } from "../utils/react-node.js";
|
|
10
9
|
import { User } from "../node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js";
|
|
11
10
|
import Icon from "../icon/index.js";
|
|
11
|
+
import { getChildren } from "../utils/react-node.js";
|
|
12
12
|
import { AvatarGroupContext } from "./avatar-group-context.js";
|
|
13
|
-
import { c } from "react/compiler-runtime";
|
|
14
13
|
import clsx from "clsx";
|
|
15
|
-
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
14
|
+
import React, { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
16
15
|
import { jsx } from "react/jsx-runtime";
|
|
17
|
-
|
|
18
|
-
var Avatar = (
|
|
19
|
-
const $ = c(39);
|
|
20
|
-
let alt;
|
|
21
|
-
let children;
|
|
22
|
-
let icon;
|
|
23
|
-
let onError;
|
|
24
|
-
let rest;
|
|
25
|
-
let src;
|
|
26
|
-
let style;
|
|
27
|
-
let t1;
|
|
28
|
-
let t2;
|
|
29
|
-
let t3;
|
|
30
|
-
if ($[0] !== t0) {
|
|
31
|
-
({icon, shape: t1, size: t2, src, alt, children, onError, className: t3, style, ...rest} = t0);
|
|
32
|
-
$[0] = t0;
|
|
33
|
-
$[1] = alt;
|
|
34
|
-
$[2] = children;
|
|
35
|
-
$[3] = icon;
|
|
36
|
-
$[4] = onError;
|
|
37
|
-
$[5] = rest;
|
|
38
|
-
$[6] = src;
|
|
39
|
-
$[7] = style;
|
|
40
|
-
$[8] = t1;
|
|
41
|
-
$[9] = t2;
|
|
42
|
-
$[10] = t3;
|
|
43
|
-
} else {
|
|
44
|
-
alt = $[1];
|
|
45
|
-
children = $[2];
|
|
46
|
-
icon = $[3];
|
|
47
|
-
onError = $[4];
|
|
48
|
-
rest = $[5];
|
|
49
|
-
src = $[6];
|
|
50
|
-
style = $[7];
|
|
51
|
-
t1 = $[8];
|
|
52
|
-
t2 = $[9];
|
|
53
|
-
t3 = $[10];
|
|
54
|
-
}
|
|
55
|
-
const shape = t1 === void 0 ? "circle" : t1;
|
|
56
|
-
const size = t2 === void 0 ? "default" : t2;
|
|
57
|
-
const className = t3 === void 0 ? "" : t3;
|
|
16
|
+
// components/avatar/avatar.tsx
|
|
17
|
+
var Avatar = ({ icon, shape = "circle", size = "default", src, alt, children, onError, className = "", style, ...rest }) => {
|
|
58
18
|
const group = useContext(AvatarGroupContext);
|
|
59
19
|
const rootRef = useRef(null);
|
|
60
20
|
const innerRef = useRef(null);
|
|
61
|
-
|
|
62
|
-
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
63
|
-
t4 = {};
|
|
64
|
-
$[11] = t4;
|
|
65
|
-
} else t4 = $[11];
|
|
66
|
-
const [textStyles, setTextStyles] = useState(t4);
|
|
21
|
+
const [textStyles, setTextStyles] = useState({});
|
|
67
22
|
const [failedSrc, setFailedSrc] = useState();
|
|
68
23
|
const imageFailed = !!src && failedSrc === src;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (onError?.(event) !== false) setFailedSrc(src);
|
|
73
|
-
};
|
|
74
|
-
$[12] = onError;
|
|
75
|
-
$[13] = src;
|
|
76
|
-
$[14] = t5;
|
|
77
|
-
} else t5 = $[14];
|
|
78
|
-
const handleImageError = t5;
|
|
24
|
+
const handleImageError = (event) => {
|
|
25
|
+
if (onError?.(event) !== false) setFailedSrc(src);
|
|
26
|
+
};
|
|
79
27
|
const computedSize = group?.size || size;
|
|
80
28
|
const computedShape = group?.shape || shape;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
$[15] = t6;
|
|
94
|
-
} else t6 = $[15];
|
|
95
|
-
const updateSize = t6;
|
|
29
|
+
const updateSize = useCallback(() => {
|
|
30
|
+
if (innerRef.current && rootRef.current) {
|
|
31
|
+
const max = rootRef.current.offsetWidth - 8;
|
|
32
|
+
const innerWidth = innerRef.current.offsetWidth || innerRef.current.scrollWidth;
|
|
33
|
+
if (innerWidth > 0 && innerWidth > max) {
|
|
34
|
+
const scale = Math.min(max / innerWidth, 1);
|
|
35
|
+
setTextStyles({ transform: `scale(${scale}) translateX(-50%)` });
|
|
36
|
+
} else setTextStyles({ transform: "scale(1) translateX(-50%)" });
|
|
37
|
+
}
|
|
38
|
+
}, []);
|
|
96
39
|
const childList = getChildren(children);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (typeof ResizeObserver !== "undefined") {
|
|
103
|
-
observer = new ResizeObserver(() => {
|
|
104
|
-
cancelAnimationFrame(animationFrame);
|
|
105
|
-
animationFrame = window.requestAnimationFrame(updateSize);
|
|
106
|
-
});
|
|
107
|
-
if (rootRef.current) observer.observe(rootRef.current);
|
|
108
|
-
if (innerRef.current) observer.observe(innerRef.current);
|
|
109
|
-
}
|
|
110
|
-
updateSize();
|
|
111
|
-
return () => {
|
|
112
|
-
observer?.disconnect();
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
let observer = null;
|
|
42
|
+
let animationFrame = 0;
|
|
43
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
44
|
+
observer = new ResizeObserver(() => {
|
|
113
45
|
cancelAnimationFrame(animationFrame);
|
|
114
|
-
|
|
46
|
+
animationFrame = window.requestAnimationFrame(updateSize);
|
|
47
|
+
});
|
|
48
|
+
if (rootRef.current) observer.observe(rootRef.current);
|
|
49
|
+
if (innerRef.current) observer.observe(innerRef.current);
|
|
50
|
+
}
|
|
51
|
+
updateSize();
|
|
52
|
+
return () => {
|
|
53
|
+
observer?.disconnect();
|
|
54
|
+
cancelAnimationFrame(animationFrame);
|
|
115
55
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
computedSize,
|
|
123
|
-
imageFailed,
|
|
124
|
-
updateSize
|
|
125
|
-
];
|
|
126
|
-
$[17] = children;
|
|
127
|
-
$[18] = computedSize;
|
|
128
|
-
$[19] = imageFailed;
|
|
129
|
-
$[20] = t8;
|
|
130
|
-
} else t8 = $[20];
|
|
131
|
-
useEffect(t7, t8);
|
|
56
|
+
}, [
|
|
57
|
+
children,
|
|
58
|
+
computedSize,
|
|
59
|
+
imageFailed,
|
|
60
|
+
updateSize
|
|
61
|
+
]);
|
|
132
62
|
const sizeVal = computedSize;
|
|
133
63
|
const shapeVal = computedShape;
|
|
134
|
-
|
|
135
|
-
if (
|
|
136
|
-
rootStyles = {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
$[23] = rootStyles;
|
|
146
|
-
} else rootStyles = $[23];
|
|
147
|
-
const hasIcon = childList.some(_temp);
|
|
64
|
+
const rootStyles = { ...style };
|
|
65
|
+
if (typeof sizeVal === "number") {
|
|
66
|
+
rootStyles.width = `${sizeVal}px`;
|
|
67
|
+
rootStyles.height = `${sizeVal}px`;
|
|
68
|
+
rootStyles.lineHeight = `${sizeVal}px`;
|
|
69
|
+
rootStyles.fontSize = `${sizeVal / 2}px`;
|
|
70
|
+
}
|
|
71
|
+
const hasIcon = childList.some((c) => {
|
|
72
|
+
if (React.isValidElement(c)) return c.type === Icon;
|
|
73
|
+
return false;
|
|
74
|
+
});
|
|
148
75
|
const isText = childList.length === 1 && typeof childList[0] === "string";
|
|
149
76
|
const showImage = !!src && !imageFailed;
|
|
150
77
|
const fallbackIcon = imageFailed && src ? icon || User : icon;
|
|
@@ -156,9 +83,12 @@ var Avatar = (t0) => {
|
|
|
156
83
|
"k-avatar-square": shapeVal === "square",
|
|
157
84
|
"k-avatar-round": shapeVal === "round"
|
|
158
85
|
}, className);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
86
|
+
return /* @__PURE__ */ jsx("div", {
|
|
87
|
+
ref: rootRef,
|
|
88
|
+
className: rootClasses,
|
|
89
|
+
style: rootStyles,
|
|
90
|
+
...rest,
|
|
91
|
+
children: showImage ? /* @__PURE__ */ jsx("img", {
|
|
162
92
|
src,
|
|
163
93
|
alt: alt ?? "",
|
|
164
94
|
onError: handleImageError
|
|
@@ -167,38 +97,7 @@ var Avatar = (t0) => {
|
|
|
167
97
|
className: "k-avatar-string",
|
|
168
98
|
style: textStyles,
|
|
169
99
|
children: childList[0]
|
|
170
|
-
}) : children
|
|
171
|
-
|
|
172
|
-
$[25] = childList;
|
|
173
|
-
$[26] = children;
|
|
174
|
-
$[27] = fallbackIcon;
|
|
175
|
-
$[28] = handleImageError;
|
|
176
|
-
$[29] = isText;
|
|
177
|
-
$[30] = showImage;
|
|
178
|
-
$[31] = src;
|
|
179
|
-
$[32] = textStyles;
|
|
180
|
-
$[33] = t9;
|
|
181
|
-
} else t9 = $[33];
|
|
182
|
-
let t10;
|
|
183
|
-
if ($[34] !== rest || $[35] !== rootClasses || $[36] !== rootStyles || $[37] !== t9) {
|
|
184
|
-
t10 = /* @__PURE__ */ jsx("div", {
|
|
185
|
-
ref: rootRef,
|
|
186
|
-
className: rootClasses,
|
|
187
|
-
style: rootStyles,
|
|
188
|
-
...rest,
|
|
189
|
-
children: t9
|
|
190
|
-
});
|
|
191
|
-
$[34] = rest;
|
|
192
|
-
$[35] = rootClasses;
|
|
193
|
-
$[36] = rootStyles;
|
|
194
|
-
$[37] = t9;
|
|
195
|
-
$[38] = t10;
|
|
196
|
-
} else t10 = $[38];
|
|
197
|
-
return t10;
|
|
100
|
+
}) : children
|
|
101
|
+
});
|
|
198
102
|
};
|
|
199
|
-
function _temp(c) {
|
|
200
|
-
if (React.isValidElement(c)) return c.type === Icon;
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
//#endregion
|
|
204
103
|
export { Avatar as default };
|