@rockshin/tao-ui 0.0.40 → 0.0.42
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/README.md +33 -7
- package/THIRD_PARTY_NOTICES.md +34 -0
- package/component-manifest.json +1321 -10
- package/dist/components/affix/affix.css +11 -0
- package/dist/components/affix/affix.d.ts +21 -0
- package/dist/components/affix/affix.js +140 -0
- package/dist/components/app/app-modals.d.ts +2 -0
- package/dist/components/app/app-modals.js +266 -0
- package/dist/components/app/app-notices.d.ts +6 -0
- package/dist/components/app/app-notices.js +334 -0
- package/dist/components/app/app-types.d.ts +154 -0
- package/dist/components/app/app-types.js +0 -0
- package/dist/components/app/app.css +221 -0
- package/dist/components/app/app.d.ts +7 -0
- package/dist/components/app/app.js +69 -0
- package/dist/components/auto-complete/auto-complete.css +35 -0
- package/dist/components/auto-complete/auto-complete.d.ts +47 -0
- package/dist/components/auto-complete/auto-complete.js +106 -0
- package/dist/components/avatar/avatar.css +95 -0
- package/dist/components/avatar/avatar.d.ts +50 -0
- package/dist/components/avatar/avatar.js +159 -0
- package/dist/components/badge/badge.css +165 -0
- package/dist/components/badge/badge.d.ts +48 -0
- package/dist/components/badge/badge.js +412 -0
- package/dist/components/border-beam/border-beam.css +35 -0
- package/dist/components/border-beam/border-beam.d.ts +27 -0
- package/dist/components/border-beam/border-beam.js +215 -0
- package/dist/components/button/button.css +7 -0
- package/dist/components/calendar/calendar.css +176 -0
- package/dist/components/calendar/calendar.d.ts +56 -0
- package/dist/components/calendar/calendar.js +175 -0
- package/dist/components/card/card-tabs.d.ts +43 -0
- package/dist/components/card/card-tabs.js +455 -0
- package/dist/components/card/card.css +401 -0
- package/dist/components/card/card.d.ts +74 -0
- package/dist/components/card/card.js +362 -0
- package/dist/components/carousel/carousel.css +231 -0
- package/dist/components/carousel/carousel.d.ts +35 -0
- package/dist/components/carousel/carousel.js +193 -0
- package/dist/components/cascader/cascader.css +123 -0
- package/dist/components/cascader/cascader.d.ts +58 -0
- package/dist/components/cascader/cascader.js +132 -0
- package/dist/components/checkbox/checkbox.css +7 -0
- package/dist/components/color-picker/color-picker-types.d.ts +78 -0
- package/dist/components/color-picker/color-picker-types.js +0 -0
- package/dist/components/color-picker/color-picker.css +299 -0
- package/dist/components/color-picker/color-picker.d.ts +5 -0
- package/dist/components/color-picker/color-picker.js +974 -0
- package/dist/components/color-picker/color.d.ts +35 -0
- package/dist/components/color-picker/color.js +65 -0
- package/dist/components/date-picker/calendar/calendar-grid.js +4 -11
- package/dist/components/date-picker/calendar/calendar-header.js +76 -69
- package/dist/components/date-picker/calendar/month-grid.js +20 -31
- package/dist/components/date-picker/calendar/time-panel.js +46 -41
- package/dist/components/date-picker/date-picker.css +4 -0
- package/dist/components/date-picker/date-picker.js +4 -4
- package/dist/components/date-picker/range-picker.js +14 -13
- package/dist/components/descriptions/descriptions.css +109 -0
- package/dist/components/descriptions/descriptions.d.ts +49 -0
- package/dist/components/descriptions/descriptions.js +189 -0
- package/dist/components/divider/divider.css +71 -0
- package/dist/components/divider/divider.d.ts +31 -0
- package/dist/components/divider/divider.js +83 -0
- package/dist/components/drawer/drawer.js +199 -184
- package/dist/components/empty/empty.css +35 -0
- package/dist/components/empty/empty.d.ts +25 -0
- package/dist/components/empty/empty.js +278 -0
- package/dist/components/float-button/float-button.css +146 -0
- package/dist/components/float-button/float-button.d.ts +67 -0
- package/dist/components/float-button/float-button.js +347 -0
- package/dist/components/form/form-item.d.ts +1 -1
- package/dist/components/form/form.js +3 -1
- package/dist/components/image/image-icons.d.ts +16 -0
- package/dist/components/image/image-icons.js +63 -0
- package/dist/components/image/image.css +253 -0
- package/dist/components/image/image.d.ts +75 -0
- package/dist/components/image/image.js +818 -0
- package/dist/components/input/input.css +8 -6
- package/dist/components/list/list-pagination.css +127 -0
- package/dist/components/list/list-pagination.d.ts +38 -0
- package/dist/components/list/list-pagination.js +321 -0
- package/dist/components/list/list.css +225 -0
- package/dist/components/list/list.d.ts +77 -0
- package/dist/components/list/list.js +660 -0
- package/dist/components/listy/listy.css +55 -0
- package/dist/components/listy/listy.d.ts +20 -0
- package/dist/components/listy/listy.js +158 -0
- package/dist/components/masonry/masonry.css +13 -0
- package/dist/components/masonry/masonry.d.ts +39 -0
- package/dist/components/masonry/masonry.js +287 -0
- package/dist/components/mentions/mentions.css +172 -0
- package/dist/components/mentions/mentions.d.ts +48 -0
- package/dist/components/mentions/mentions.js +115 -0
- package/dist/components/modal/modal.d.ts +30 -4
- package/dist/components/modal/modal.js +534 -241
- package/dist/components/pagination/pagination.css +10 -0
- package/dist/components/progress/progress.css +187 -0
- package/dist/components/progress/progress.d.ts +66 -0
- package/dist/components/progress/progress.js +567 -0
- package/dist/components/qr-code/qr-code.css +39 -0
- package/dist/components/qr-code/qr-code.d.ts +43 -0
- package/dist/components/qr-code/qr-code.js +286 -0
- package/dist/components/radio/radio.css +7 -0
- package/dist/components/rate/rate.css +97 -0
- package/dist/components/rate/rate.d.ts +17 -0
- package/dist/components/rate/rate.js +172 -0
- package/dist/components/result/result.css +69 -0
- package/dist/components/result/result.d.ts +33 -0
- package/dist/components/result/result.js +320 -0
- package/dist/components/segmented/segmented.css +134 -0
- package/dist/components/segmented/segmented.d.ts +40 -0
- package/dist/components/segmented/segmented.js +169 -0
- package/dist/components/select/mobile-select.d.ts +10 -4
- package/dist/components/select/mobile-select.js +166 -58
- package/dist/components/select/select-tags.js +178 -130
- package/dist/components/select/select-types.d.ts +51 -0
- package/dist/components/select/select.css +70 -10
- package/dist/components/select/select.js +30 -16
- package/dist/components/select/use-select-selection.js +44 -43
- package/dist/components/skeleton/skeleton.css +129 -0
- package/dist/components/skeleton/skeleton.d.ts +78 -0
- package/dist/components/skeleton/skeleton.js +457 -0
- package/dist/components/slider/slider.css +191 -0
- package/dist/components/slider/slider.d.ts +47 -0
- package/dist/components/slider/slider.js +310 -0
- package/dist/components/statistic/statistic.css +34 -0
- package/dist/components/statistic/statistic.d.ts +46 -0
- package/dist/components/statistic/statistic.js +491 -0
- package/dist/components/switch/switch-touch.css +20 -0
- package/dist/components/switch/switch.css +24 -13
- package/dist/components/switch/switch.js +8 -5
- package/dist/components/textarea/textarea.css +1 -1
- package/dist/components/time-picker/time-picker.css +205 -0
- package/dist/components/time-picker/time-picker.d.ts +63 -0
- package/dist/components/time-picker/time-picker.js +356 -0
- package/dist/components/timeline/timeline.css +259 -0
- package/dist/components/timeline/timeline.d.ts +50 -0
- package/dist/components/timeline/timeline.js +140 -0
- package/dist/components/tour/tour.css +151 -0
- package/dist/components/tour/tour.d.ts +45 -0
- package/dist/components/tour/tour.js +575 -0
- package/dist/components/transfer/transfer-list.d.ts +2 -0
- package/dist/components/transfer/transfer-list.js +513 -0
- package/dist/components/transfer/transfer-parts.d.ts +3 -0
- package/dist/components/transfer/transfer-parts.js +163 -0
- package/dist/components/transfer/transfer-types.d.ts +163 -0
- package/dist/components/transfer/transfer-types.js +0 -0
- package/dist/components/transfer/transfer.css +226 -0
- package/dist/components/transfer/transfer.d.ts +13 -0
- package/dist/components/transfer/transfer.js +204 -0
- package/dist/components/tree/tree.css +250 -0
- package/dist/components/tree/tree.d.ts +46 -0
- package/dist/components/tree/tree.js +389 -0
- package/dist/components/tree-select/select-engine.css +231 -0
- package/dist/components/tree-select/select-engine.d.ts +20 -0
- package/dist/components/tree-select/select-engine.js +46 -0
- package/dist/components/tree-select/tree-select.css +25 -0
- package/dist/components/tree-select/tree-select.d.ts +50 -0
- package/dist/components/tree-select/tree-select.js +131 -0
- package/dist/components/upload/upload-types.d.ts +135 -0
- package/dist/components/upload/upload-types.js +0 -0
- package/dist/components/upload/upload.css +177 -0
- package/dist/components/upload/upload.d.ts +12 -0
- package/dist/components/upload/upload.js +455 -0
- package/dist/components/watermark/watermark-context.d.ts +7 -0
- package/dist/components/watermark/watermark-context.js +20 -0
- package/dist/components/watermark/watermark.css +10 -0
- package/dist/components/watermark/watermark.d.ts +38 -0
- package/dist/components/watermark/watermark.js +436 -0
- package/dist/docs/component-docs.d.ts +35 -29
- package/dist/docs/component-docs.js +73 -1
- package/dist/docs/components/affix.doc.d.ts +14 -0
- package/dist/docs/components/affix.doc.js +22 -0
- package/dist/docs/components/app.doc.d.ts +18 -0
- package/dist/docs/components/app.doc.js +42 -0
- package/dist/docs/components/auto-complete.doc.d.ts +18 -0
- package/dist/docs/components/auto-complete.doc.js +49 -0
- package/dist/docs/components/avatar.doc.d.ts +17 -0
- package/dist/docs/components/avatar.doc.js +36 -0
- package/dist/docs/components/badge.doc.d.ts +17 -0
- package/dist/docs/components/badge.doc.js +34 -0
- package/dist/docs/components/border-beam.doc.d.ts +14 -0
- package/dist/docs/components/border-beam.doc.js +22 -0
- package/dist/docs/components/calendar.doc.d.ts +18 -0
- package/dist/docs/components/calendar.doc.js +45 -0
- package/dist/docs/components/card.doc.d.ts +17 -0
- package/dist/docs/components/card.doc.js +39 -0
- package/dist/docs/components/carousel.doc.d.ts +15 -0
- package/dist/docs/components/carousel.doc.js +26 -0
- package/dist/docs/components/cascader.doc.d.ts +18 -0
- package/dist/docs/components/cascader.doc.js +54 -0
- package/dist/docs/components/color-picker.doc.d.ts +18 -0
- package/dist/docs/components/color-picker.doc.js +46 -0
- package/dist/docs/components/descriptions.doc.d.ts +14 -0
- package/dist/docs/components/descriptions.doc.js +26 -0
- package/dist/docs/components/divider.doc.d.ts +17 -0
- package/dist/docs/components/divider.doc.js +34 -0
- package/dist/docs/components/empty.doc.d.ts +18 -0
- package/dist/docs/components/empty.doc.js +40 -0
- package/dist/docs/components/float-button.doc.d.ts +14 -0
- package/dist/docs/components/float-button.doc.js +23 -0
- package/dist/docs/components/form.doc.d.ts +1 -1
- package/dist/docs/components/image.doc.d.ts +15 -0
- package/dist/docs/components/image.doc.js +38 -0
- package/dist/docs/components/list.doc.d.ts +18 -0
- package/dist/docs/components/list.doc.js +43 -0
- package/dist/docs/components/listy.doc.d.ts +18 -0
- package/dist/docs/components/listy.doc.js +40 -0
- package/dist/docs/components/masonry.doc.d.ts +14 -0
- package/dist/docs/components/masonry.doc.js +22 -0
- package/dist/docs/components/mentions.doc.d.ts +18 -0
- package/dist/docs/components/mentions.doc.js +43 -0
- package/dist/docs/components/modal.doc.js +3 -0
- package/dist/docs/components/progress.doc.d.ts +18 -0
- package/dist/docs/components/progress.doc.js +41 -0
- package/dist/docs/components/qr-code.doc.d.ts +18 -0
- package/dist/docs/components/qr-code.doc.js +41 -0
- package/dist/docs/components/rate.doc.d.ts +18 -0
- package/dist/docs/components/rate.doc.js +38 -0
- package/dist/docs/components/result.doc.d.ts +18 -0
- package/dist/docs/components/result.doc.js +42 -0
- package/dist/docs/components/segmented.doc.d.ts +14 -0
- package/dist/docs/components/segmented.doc.js +24 -0
- package/dist/docs/components/skeleton.doc.d.ts +18 -0
- package/dist/docs/components/skeleton.doc.js +42 -0
- package/dist/docs/components/slider.doc.d.ts +18 -0
- package/dist/docs/components/slider.doc.js +41 -0
- package/dist/docs/components/statistic.doc.d.ts +14 -0
- package/dist/docs/components/statistic.doc.js +27 -0
- package/dist/docs/components/time-picker.doc.d.ts +18 -0
- package/dist/docs/components/time-picker.doc.js +45 -0
- package/dist/docs/components/timeline.doc.d.ts +14 -0
- package/dist/docs/components/timeline.doc.js +29 -0
- package/dist/docs/components/tooltip.doc.d.ts +2 -2
- package/dist/docs/components/tour.doc.d.ts +15 -0
- package/dist/docs/components/tour.doc.js +36 -0
- package/dist/docs/components/transfer.doc.d.ts +18 -0
- package/dist/docs/components/transfer.doc.js +48 -0
- package/dist/docs/components/tree-select.doc.d.ts +18 -0
- package/dist/docs/components/tree-select.doc.js +55 -0
- package/dist/docs/components/tree.doc.d.ts +18 -0
- package/dist/docs/components/tree.doc.js +46 -0
- package/dist/docs/components/upload.doc.d.ts +18 -0
- package/dist/docs/components/upload.doc.js +43 -0
- package/dist/docs/components/watermark.doc.d.ts +14 -0
- package/dist/docs/components/watermark.doc.js +22 -0
- package/dist/entries/affix.d.ts +3 -0
- package/dist/entries/affix.js +4 -0
- package/dist/entries/app.d.ts +3 -0
- package/dist/entries/app.js +4 -0
- package/dist/entries/auto-complete.d.ts +4 -0
- package/dist/entries/auto-complete.js +4 -0
- package/dist/entries/avatar.d.ts +3 -0
- package/dist/entries/avatar.js +4 -0
- package/dist/entries/badge.d.ts +3 -0
- package/dist/entries/badge.js +4 -0
- package/dist/entries/border-beam.d.ts +3 -0
- package/dist/entries/border-beam.js +4 -0
- package/dist/entries/calendar.d.ts +3 -0
- package/dist/entries/calendar.js +4 -0
- package/dist/entries/card.d.ts +3 -0
- package/dist/entries/card.js +4 -0
- package/dist/entries/carousel.d.ts +3 -0
- package/dist/entries/carousel.js +4 -0
- package/dist/entries/cascader.d.ts +4 -0
- package/dist/entries/cascader.js +4 -0
- package/dist/entries/color-picker.d.ts +5 -0
- package/dist/entries/color-picker.js +4 -0
- package/dist/entries/descriptions.d.ts +3 -0
- package/dist/entries/descriptions.js +4 -0
- package/dist/entries/divider.d.ts +3 -0
- package/dist/entries/divider.js +4 -0
- package/dist/entries/empty.d.ts +3 -0
- package/dist/entries/empty.js +4 -0
- package/dist/entries/float-button.d.ts +3 -0
- package/dist/entries/float-button.js +4 -0
- package/dist/entries/image.d.ts +3 -0
- package/dist/entries/image.js +4 -0
- package/dist/entries/list.d.ts +3 -0
- package/dist/entries/list.js +4 -0
- package/dist/entries/listy.d.ts +3 -0
- package/dist/entries/listy.js +4 -0
- package/dist/entries/masonry.d.ts +3 -0
- package/dist/entries/masonry.js +4 -0
- package/dist/entries/mentions.d.ts +4 -0
- package/dist/entries/mentions.js +4 -0
- package/dist/entries/progress.d.ts +3 -0
- package/dist/entries/progress.js +4 -0
- package/dist/entries/provider.d.ts +1 -1
- package/dist/entries/provider.js +1 -1
- package/dist/entries/qr-code.d.ts +4 -0
- package/dist/entries/qr-code.js +4 -0
- package/dist/entries/rate.d.ts +3 -0
- package/dist/entries/rate.js +4 -0
- package/dist/entries/result.d.ts +3 -0
- package/dist/entries/result.js +4 -0
- package/dist/entries/segmented.d.ts +3 -0
- package/dist/entries/segmented.js +4 -0
- package/dist/entries/skeleton.d.ts +3 -0
- package/dist/entries/skeleton.js +4 -0
- package/dist/entries/slider.d.ts +3 -0
- package/dist/entries/slider.js +4 -0
- package/dist/entries/statistic.d.ts +3 -0
- package/dist/entries/statistic.js +4 -0
- package/dist/entries/time-picker.d.ts +3 -0
- package/dist/entries/time-picker.js +4 -0
- package/dist/entries/timeline.d.ts +3 -0
- package/dist/entries/timeline.js +4 -0
- package/dist/entries/tour.d.ts +3 -0
- package/dist/entries/tour.js +4 -0
- package/dist/entries/transfer.d.ts +3 -0
- package/dist/entries/transfer.js +4 -0
- package/dist/entries/tree-select.d.ts +4 -0
- package/dist/entries/tree-select.js +4 -0
- package/dist/entries/tree.d.ts +3 -0
- package/dist/entries/tree.js +4 -0
- package/dist/entries/upload.d.ts +4 -0
- package/dist/entries/upload.js +4 -0
- package/dist/entries/util.d.ts +1 -0
- package/dist/entries/util.js +1 -0
- package/dist/entries/watermark.d.ts +3 -0
- package/dist/entries/watermark.js +4 -0
- package/dist/index.d.ts +48 -3
- package/dist/index.js +38 -2
- package/dist/provider/locale.d.ts +59 -0
- package/dist/provider/locale.js +136 -0
- package/dist/provider/tao-provider.d.ts +16 -1
- package/dist/provider/tao-provider.js +104 -87
- package/dist/theme/control.css +10 -0
- package/dist/theme/theme.css +1 -1
- package/dist/utils/breakpoint.d.ts +2 -2
- package/dist/utils/breakpoint.js +3 -1
- package/dist/utils/interop-default.d.ts +2 -0
- package/dist/utils/interop-default.js +4 -0
- package/dist/utils/types.d.ts +7 -0
- package/dist/utils/types.js +0 -0
- package/llms.txt +476 -8
- package/package.json +27 -6
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppInstance, AppProps } from './app-types.js';
|
|
2
|
+
import './app.css';
|
|
3
|
+
export type * from './app-types.js';
|
|
4
|
+
declare function useApp(): AppInstance;
|
|
5
|
+
export declare const App: import("react").ForwardRefExoticComponent<AppProps & import("react").RefAttributes<HTMLElement>> & {
|
|
6
|
+
useApp: typeof useApp;
|
|
7
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, createElement, forwardRef, useContext, useMemo } from "react";
|
|
3
|
+
import { cx } from "../../utils/semantic.js";
|
|
4
|
+
import { useAppModals } from "./app-modals.js";
|
|
5
|
+
import { useAppMessages, useAppNotifications } from "./app-notices.js";
|
|
6
|
+
import "./app.css";
|
|
7
|
+
const AppContext = /*#__PURE__*/ createContext(null);
|
|
8
|
+
const AppConfigContext = /*#__PURE__*/ createContext({});
|
|
9
|
+
const AppRoot = /*#__PURE__*/ forwardRef(function({ message, notification, component = 'div', children, prefixCls, className, rootClassName, style, classNames, styles }, ref) {
|
|
10
|
+
const parent = useContext(AppConfigContext);
|
|
11
|
+
const config = useMemo(()=>({
|
|
12
|
+
message: {
|
|
13
|
+
...parent.message,
|
|
14
|
+
...message
|
|
15
|
+
},
|
|
16
|
+
notification: {
|
|
17
|
+
...parent.notification,
|
|
18
|
+
...notification
|
|
19
|
+
}
|
|
20
|
+
}), [
|
|
21
|
+
parent,
|
|
22
|
+
message,
|
|
23
|
+
notification
|
|
24
|
+
]);
|
|
25
|
+
const [messageApi, messageHolder] = useAppMessages(config.message);
|
|
26
|
+
const [notificationApi, notificationHolder] = useAppNotifications(config.notification);
|
|
27
|
+
const [modal, modalHolder] = useAppModals();
|
|
28
|
+
const value = useMemo(()=>({
|
|
29
|
+
message: messageApi,
|
|
30
|
+
notification: notificationApi,
|
|
31
|
+
modal
|
|
32
|
+
}), [
|
|
33
|
+
messageApi,
|
|
34
|
+
notificationApi,
|
|
35
|
+
modal
|
|
36
|
+
]);
|
|
37
|
+
const content = /*#__PURE__*/ jsxs(Fragment, {
|
|
38
|
+
children: [
|
|
39
|
+
modalHolder,
|
|
40
|
+
messageHolder,
|
|
41
|
+
notificationHolder,
|
|
42
|
+
children
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
return /*#__PURE__*/ jsx(AppContext.Provider, {
|
|
46
|
+
value: value,
|
|
47
|
+
children: /*#__PURE__*/ jsx(AppConfigContext.Provider, {
|
|
48
|
+
value: config,
|
|
49
|
+
children: false === component ? content : /*#__PURE__*/ createElement(component, {
|
|
50
|
+
ref,
|
|
51
|
+
'data-tao-app': '',
|
|
52
|
+
className: cx(prefixCls, classNames?.root, className, rootClassName),
|
|
53
|
+
style: {
|
|
54
|
+
...styles?.root,
|
|
55
|
+
...style
|
|
56
|
+
}
|
|
57
|
+
}, content)
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
function useApp() {
|
|
62
|
+
const api = useContext(AppContext);
|
|
63
|
+
if (!api) throw new Error("App.useApp() must be called below an <App> provider.");
|
|
64
|
+
return api;
|
|
65
|
+
}
|
|
66
|
+
const app_App = Object.assign(AppRoot, {
|
|
67
|
+
useApp: useApp
|
|
68
|
+
});
|
|
69
|
+
export { app_App as App };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[data-tao-auto-complete] {
|
|
2
|
+
cursor: text;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[data-tao-auto-complete] > [class*="-content"] {
|
|
6
|
+
min-height: calc(var(--tao-engine-font-size, var(--tao-font-size-base)) *
|
|
7
|
+
var(--tao-line-height));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
[data-tao-auto-complete][data-tao-custom-input] {
|
|
11
|
+
width: 100%;
|
|
12
|
+
min-width: 0;
|
|
13
|
+
box-shadow: none;
|
|
14
|
+
background: none;
|
|
15
|
+
border: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
position: relative;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
[data-tao-auto-complete][data-tao-custom-input] [class$="-input"] {
|
|
22
|
+
position: relative;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[data-tao-auto-complete][data-tao-custom-input] > [class*="-content"] {
|
|
26
|
+
flex: 1;
|
|
27
|
+
min-width: 0;
|
|
28
|
+
overflow: visible;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[data-tao-auto-complete][data-tao-custom-input] textarea {
|
|
32
|
+
resize: vertical;
|
|
33
|
+
display: block;
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type BaseSelectRef, type SelectProps as RcSelectProps } from '@rc-component/select';
|
|
2
|
+
import type { BaseOptionType, DefaultOptionType, SearchConfig } from '@rc-component/select/es/Select';
|
|
3
|
+
import { type CSSProperties, type ReactElement, type ReactNode, type RefAttributes } from 'react';
|
|
4
|
+
import { type TaoSize, type TaoStatus } from '../../provider/tao-provider.js';
|
|
5
|
+
import { type SelectEngineSemantic, type SelectEngineVariant } from '../tree-select/select-engine.js';
|
|
6
|
+
import '../tree-select/select-engine.css';
|
|
7
|
+
import './auto-complete.css';
|
|
8
|
+
export type AutoCompleteRef = BaseSelectRef;
|
|
9
|
+
export type AutoCompleteOption = DefaultOptionType;
|
|
10
|
+
export type AutoCompleteSemanticPart = 'root' | 'prefix' | 'input' | 'placeholder' | 'content' | 'clear' | 'popup.root' | 'popup.list' | 'popup.listItem';
|
|
11
|
+
export type AutoCompleteSemanticType = {
|
|
12
|
+
classNames?: SelectEngineSemantic<string, 'list' | 'listItem'>;
|
|
13
|
+
styles?: SelectEngineSemantic<CSSProperties, 'list' | 'listItem'>;
|
|
14
|
+
};
|
|
15
|
+
export interface DataSourceItemObject {
|
|
16
|
+
value: string;
|
|
17
|
+
text: string;
|
|
18
|
+
}
|
|
19
|
+
export type DataSourceItemType = DataSourceItemObject | ReactNode;
|
|
20
|
+
export interface AutoCompleteProps<ValueType = string, OptionType extends BaseOptionType = DefaultOptionType> extends Omit<RcSelectProps<ValueType, OptionType>, 'loading' | 'mode' | 'optionLabelProp' | 'labelInValue' | 'styles' | 'classNames' | 'showSearch' | 'optionFilterProp' | 'filterSort' | 'popupRender'> {
|
|
21
|
+
size?: TaoSize | 'middle';
|
|
22
|
+
variant?: SelectEngineVariant;
|
|
23
|
+
status?: TaoStatus;
|
|
24
|
+
bordered?: boolean;
|
|
25
|
+
showArrow?: boolean;
|
|
26
|
+
rootClassName?: string;
|
|
27
|
+
dataSource?: DataSourceItemType[];
|
|
28
|
+
classNames?: AutoCompleteSemanticType['classNames'] | ((info: {
|
|
29
|
+
props: AutoCompleteProps<ValueType, OptionType>;
|
|
30
|
+
}) => AutoCompleteSemanticType['classNames']);
|
|
31
|
+
styles?: AutoCompleteSemanticType['styles'] | ((info: {
|
|
32
|
+
props: AutoCompleteProps<ValueType, OptionType>;
|
|
33
|
+
}) => AutoCompleteSemanticType['styles']);
|
|
34
|
+
showSearch?: boolean | Pick<SearchConfig<OptionType> & {
|
|
35
|
+
searchIcon?: ReactNode;
|
|
36
|
+
}, 'filterOption' | 'onSearch' | 'searchIcon'>;
|
|
37
|
+
dropdownClassName?: string;
|
|
38
|
+
dropdownStyle?: CSSProperties;
|
|
39
|
+
dropdownRender?: (menu: ReactElement) => ReactNode;
|
|
40
|
+
popupRender?: (menu: ReactElement) => ReactNode;
|
|
41
|
+
dropdownMatchSelectWidth?: boolean | number;
|
|
42
|
+
onDropdownVisibleChange?: (visible: boolean) => void;
|
|
43
|
+
onOpenChange?: (open: boolean) => void;
|
|
44
|
+
}
|
|
45
|
+
export declare const AutoComplete: (<ValueType = string, OptionType extends BaseOptionType = DefaultOptionType>(props: AutoCompleteProps<ValueType, OptionType> & RefAttributes<AutoCompleteRef>) => ReactElement) & {
|
|
46
|
+
Option: import("@rc-component/select/es/Option").OptionFC;
|
|
47
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import _rc_component_select from "@rc-component/select";
|
|
3
|
+
import { Children, forwardRef, isValidElement } from "react";
|
|
4
|
+
import { useTaoInternalConfig } from "../../provider/tao-provider.js";
|
|
5
|
+
import { cx } from "../../utils/semantic.js";
|
|
6
|
+
import { SelectEnginePopup, selectAllowClear } from "../tree-select/select-engine.js";
|
|
7
|
+
import "../tree-select/select-engine.css";
|
|
8
|
+
import "./auto-complete.css";
|
|
9
|
+
import { interopDefault } from "../../utils/interop-default.js";
|
|
10
|
+
const RcSelectComponent = /*#__PURE__*/ interopDefault(_rc_component_select);
|
|
11
|
+
function InternalAutoComplete(props, ref) {
|
|
12
|
+
const config = useTaoInternalConfig();
|
|
13
|
+
const { size: sizeProp = config.size, disabled = config.disabled, variant = false === props.bordered ? 'borderless' : config.variant, status, prefixCls = 'tao-select-engine', className, rootClassName, style, classNames, styles, children, dataSource, components, suffix, suffixIcon, allowClear, clearIcon, popupClassName, dropdownClassName, popupStyle, dropdownStyle, popupRender, dropdownRender, onOpenChange, onDropdownVisibleChange, onPopupVisibleChange, popupMatchSelectWidth, dropdownMatchSelectWidth, listHeight = 256, listItemHeight = 32, showSearch = true, notFoundContent = null, bordered: _bordered, showArrow: _showArrow, ...rest } = props;
|
|
14
|
+
const nodes = Children.toArray(children);
|
|
15
|
+
const customInput = 1 === nodes.length && /*#__PURE__*/ isValidElement(nodes[0]) && nodes[0].type !== RcSelectComponent.Option && nodes[0].type !== RcSelectComponent.OptGroup ? nodes[0] : void 0;
|
|
16
|
+
const optionsChildren = customInput ? void 0 : children;
|
|
17
|
+
const legacyOptions = dataSource?.map((item)=>{
|
|
18
|
+
if (/*#__PURE__*/ isValidElement(item)) return item;
|
|
19
|
+
if ('string' == typeof item) return /*#__PURE__*/ jsx(RcSelectComponent.Option, {
|
|
20
|
+
value: item,
|
|
21
|
+
children: item
|
|
22
|
+
}, item);
|
|
23
|
+
if (item && 'object' == typeof item && 'value' in item && 'text' in item) return /*#__PURE__*/ jsx(RcSelectComponent.Option, {
|
|
24
|
+
value: item.value,
|
|
25
|
+
children: item.text
|
|
26
|
+
}, item.value);
|
|
27
|
+
return null;
|
|
28
|
+
});
|
|
29
|
+
const size = 'middle' === sizeProp ? 'medium' : sizeProp;
|
|
30
|
+
const resolvedProps = {
|
|
31
|
+
...props,
|
|
32
|
+
size,
|
|
33
|
+
disabled,
|
|
34
|
+
variant
|
|
35
|
+
};
|
|
36
|
+
const classes = 'function' == typeof classNames ? classNames({
|
|
37
|
+
props: resolvedProps
|
|
38
|
+
}) : classNames;
|
|
39
|
+
const semanticStyles = 'function' == typeof styles ? styles({
|
|
40
|
+
props: resolvedProps
|
|
41
|
+
}) : styles;
|
|
42
|
+
const renderPopup = popupRender ?? dropdownRender;
|
|
43
|
+
return /*#__PURE__*/ jsx(RcSelectComponent, {
|
|
44
|
+
...rest,
|
|
45
|
+
ref: ref,
|
|
46
|
+
prefixCls: prefixCls,
|
|
47
|
+
mode: "combobox",
|
|
48
|
+
"data-tao-auto-complete": "",
|
|
49
|
+
"data-tao-select-engine": customInput ? void 0 : '',
|
|
50
|
+
"data-tao-control": customInput ? void 0 : '',
|
|
51
|
+
"data-tao-custom-input": !!customInput || void 0,
|
|
52
|
+
"data-tao-size": size,
|
|
53
|
+
"data-tao-variant": variant,
|
|
54
|
+
"data-disabled": disabled || void 0,
|
|
55
|
+
"data-tao-error": 'error' === status || void 0,
|
|
56
|
+
"data-tao-warning": 'warning' === status || void 0,
|
|
57
|
+
disabled: disabled,
|
|
58
|
+
className: cx(className, rootClassName, classes?.root),
|
|
59
|
+
style: {
|
|
60
|
+
...semanticStyles?.root,
|
|
61
|
+
...style
|
|
62
|
+
},
|
|
63
|
+
classNames: classes,
|
|
64
|
+
styles: semanticStyles,
|
|
65
|
+
components: customInput ? {
|
|
66
|
+
...components,
|
|
67
|
+
input: customInput
|
|
68
|
+
} : components,
|
|
69
|
+
showSearch: showSearch,
|
|
70
|
+
notFoundContent: notFoundContent,
|
|
71
|
+
listHeight: listHeight,
|
|
72
|
+
listItemHeight: listItemHeight,
|
|
73
|
+
suffix: void 0 !== suffix ? suffix : suffixIcon ?? null,
|
|
74
|
+
allowClear: selectAllowClear(allowClear, clearIcon, config.locale.clear),
|
|
75
|
+
popupMatchSelectWidth: popupMatchSelectWidth ?? dropdownMatchSelectWidth,
|
|
76
|
+
popupClassName: cx(popupClassName ?? dropdownClassName, rootClassName, classes?.popup?.root),
|
|
77
|
+
popupAlign: {
|
|
78
|
+
overflow: {
|
|
79
|
+
adjustX: true,
|
|
80
|
+
adjustY: true,
|
|
81
|
+
shiftX: 8
|
|
82
|
+
},
|
|
83
|
+
...props.popupAlign
|
|
84
|
+
},
|
|
85
|
+
popupStyle: {
|
|
86
|
+
...config.tokenStyle,
|
|
87
|
+
position: 'absolute',
|
|
88
|
+
maxWidth: 'calc(100vw - 16px)',
|
|
89
|
+
zIndex: 'var(--tao-z-index-popup)',
|
|
90
|
+
...dropdownStyle,
|
|
91
|
+
...popupStyle,
|
|
92
|
+
...semanticStyles?.popup?.root
|
|
93
|
+
},
|
|
94
|
+
popupRender: (menu)=>/*#__PURE__*/ jsx(SelectEnginePopup, {
|
|
95
|
+
size: size,
|
|
96
|
+
children: renderPopup ? renderPopup(menu) : menu
|
|
97
|
+
}),
|
|
98
|
+
onPopupVisibleChange: onOpenChange ?? onDropdownVisibleChange ?? onPopupVisibleChange,
|
|
99
|
+
children: optionsChildren ?? legacyOptions
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const AutoCompleteComponent = /*#__PURE__*/ forwardRef(InternalAutoComplete);
|
|
103
|
+
const AutoComplete = Object.assign(AutoCompleteComponent, {
|
|
104
|
+
Option: RcSelectComponent.Option
|
|
105
|
+
});
|
|
106
|
+
export { AutoComplete };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
[data-tao-avatar] {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
width: var(--tao-control-height);
|
|
5
|
+
height: var(--tao-control-height);
|
|
6
|
+
color: var(--tao-color-text-secondary);
|
|
7
|
+
background: var(--tao-color-bg-container-disabled);
|
|
8
|
+
font-family: var(--tao-font-family);
|
|
9
|
+
font-size: var(--tao-font-size);
|
|
10
|
+
vertical-align: middle;
|
|
11
|
+
border-radius: 50%;
|
|
12
|
+
flex: none;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
align-items: center;
|
|
15
|
+
line-height: 1;
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
position: relative;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
[data-tao-avatar][data-tao-shape="square"] {
|
|
22
|
+
border-radius: var(--tao-radius);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[data-tao-avatar][data-tao-size="small"] {
|
|
26
|
+
width: var(--tao-control-height-sm);
|
|
27
|
+
height: var(--tao-control-height-sm);
|
|
28
|
+
font-size: var(--tao-font-size-sm);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[data-tao-avatar][data-tao-size="large"] {
|
|
32
|
+
width: var(--tao-control-height-lg);
|
|
33
|
+
height: var(--tao-control-height-lg);
|
|
34
|
+
font-size: var(--tao-font-size-lg);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[data-tao-avatar] > img {
|
|
38
|
+
object-fit: cover;
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
display: block;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[data-tao-avatar-icon] {
|
|
45
|
+
justify-content: center;
|
|
46
|
+
align-items: center;
|
|
47
|
+
font-size: 1.3em;
|
|
48
|
+
line-height: 0;
|
|
49
|
+
display: inline-flex;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[data-tao-avatar-icon] > svg {
|
|
53
|
+
width: 1em;
|
|
54
|
+
height: 1em;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[data-tao-avatar-content] {
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
transform-origin: center;
|
|
60
|
+
display: inline-block;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[data-tao-avatar-group], [data-tao-avatar-overflow-list] {
|
|
64
|
+
align-items: center;
|
|
65
|
+
display: inline-flex;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[data-tao-avatar-group] > [data-tao-avatar], [data-tao-avatar-overflow] > [data-tao-avatar] {
|
|
69
|
+
border: calc(var(--tao-line-width) * 2) solid var(--tao-color-bg-container);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
[data-tao-avatar-group] > * + * {
|
|
73
|
+
margin-inline-start: calc(var(--tao-margin-xs) * -1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[data-tao-avatar-overflow] {
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
background: none;
|
|
79
|
+
border: 0;
|
|
80
|
+
border-radius: 50%;
|
|
81
|
+
padding: 0;
|
|
82
|
+
display: inline-flex;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
[data-tao-avatar-overflow]:focus-visible {
|
|
86
|
+
box-shadow: 0 0 0 var(--tao-ring-width) var(--tao-control-outline);
|
|
87
|
+
outline: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
[data-tao-avatar-overflow-list] {
|
|
91
|
+
gap: var(--tao-margin-xs);
|
|
92
|
+
flex-wrap: wrap;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type CSSProperties, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type TaoBreakpointMap } from '../../utils/breakpoint.js';
|
|
3
|
+
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
4
|
+
import { type PopoverProps } from '../popover/popover.js';
|
|
5
|
+
import './avatar.css';
|
|
6
|
+
export type AvatarSemanticPart = 'root' | 'image' | 'icon' | 'content';
|
|
7
|
+
export type AvatarSize = 'small' | 'medium' | 'middle' | 'default' | 'large' | number | TaoBreakpointMap<number>;
|
|
8
|
+
export interface AvatarProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'onError'> {
|
|
9
|
+
shape?: 'circle' | 'square';
|
|
10
|
+
size?: AvatarSize;
|
|
11
|
+
gap?: number;
|
|
12
|
+
src?: ReactNode;
|
|
13
|
+
srcSet?: string;
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
prefixCls?: string;
|
|
16
|
+
rootClassName?: string;
|
|
17
|
+
alt?: string;
|
|
18
|
+
crossOrigin?: '' | 'anonymous' | 'use-credentials';
|
|
19
|
+
onError?: () => boolean;
|
|
20
|
+
classNames?: SemanticClassNames<AvatarSemanticPart>;
|
|
21
|
+
styles?: SemanticStyles<AvatarSemanticPart>;
|
|
22
|
+
}
|
|
23
|
+
export type AvatarGroupSemanticPart = 'root' | 'overflow';
|
|
24
|
+
export interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
25
|
+
prefixCls?: string;
|
|
26
|
+
rootClassName?: string;
|
|
27
|
+
size?: AvatarSize;
|
|
28
|
+
shape?: 'circle' | 'square';
|
|
29
|
+
max?: {
|
|
30
|
+
count?: number;
|
|
31
|
+
style?: CSSProperties;
|
|
32
|
+
popover?: Omit<PopoverProps, 'children'>;
|
|
33
|
+
};
|
|
34
|
+
/** @deprecated Use max.count. */
|
|
35
|
+
maxCount?: number;
|
|
36
|
+
/** @deprecated Use max.style. */
|
|
37
|
+
maxStyle?: CSSProperties;
|
|
38
|
+
/** @deprecated Use max.popover.placement. */
|
|
39
|
+
maxPopoverPlacement?: 'top' | 'bottom';
|
|
40
|
+
/** @deprecated Use max.popover.trigger. */
|
|
41
|
+
maxPopoverTrigger?: 'hover' | 'focus' | 'click';
|
|
42
|
+
classNames?: SemanticClassNames<AvatarGroupSemanticPart>;
|
|
43
|
+
styles?: SemanticStyles<AvatarGroupSemanticPart>;
|
|
44
|
+
}
|
|
45
|
+
export interface AvatarGroupRef {
|
|
46
|
+
nativeElement: HTMLDivElement;
|
|
47
|
+
}
|
|
48
|
+
export declare const Avatar: import("react").ForwardRefExoticComponent<AvatarProps & import("react").RefAttributes<HTMLSpanElement>> & {
|
|
49
|
+
Group: import("react").ForwardRefExoticComponent<AvatarGroupProps & import("react").RefAttributes<AvatarGroupRef>>;
|
|
50
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, Fragment, createContext, forwardRef, isValidElement, useContext, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { useTaoConfig } from "../../provider/tao-provider.js";
|
|
4
|
+
import { resolveResponsiveValue, useBreakpoint } from "../../utils/breakpoint.js";
|
|
5
|
+
import { cx } from "../../utils/semantic.js";
|
|
6
|
+
import { Popover } from "../popover/popover.js";
|
|
7
|
+
import "./avatar.css";
|
|
8
|
+
const GroupContext = /*#__PURE__*/ createContext({});
|
|
9
|
+
const AvatarRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
10
|
+
const ctx = useTaoConfig();
|
|
11
|
+
const group = useContext(GroupContext);
|
|
12
|
+
const { shape = group.shape ?? 'circle', size = group.size ?? ctx.size, gap = 4, src, srcSet, icon, prefixCls, rootClassName, alt, crossOrigin, onError, classNames, styles, children, className, style, draggable, ...rest } = props;
|
|
13
|
+
const node = useRef(null);
|
|
14
|
+
const text = useRef(null);
|
|
15
|
+
useImperativeHandle(ref, ()=>node.current);
|
|
16
|
+
const screens = useBreakpoint();
|
|
17
|
+
const dimensions = 'object' == typeof size ? resolveResponsiveValue(size, screens) : size;
|
|
18
|
+
const [failedSource, setFailedSource] = useState();
|
|
19
|
+
const failed = failedSource?.src === src && failedSource?.srcSet === srcSet;
|
|
20
|
+
const hasImage = 'string' == typeof src ? !failed && '' !== src : /*#__PURE__*/ isValidElement(src);
|
|
21
|
+
const hasIcon = null != icon && 'boolean' != typeof icon;
|
|
22
|
+
const [scale, setScale] = useState(1);
|
|
23
|
+
useLayoutEffect(()=>{
|
|
24
|
+
if (hasImage || hasIcon) return;
|
|
25
|
+
const element = node.current;
|
|
26
|
+
const content = text.current;
|
|
27
|
+
if (!element || !content) return;
|
|
28
|
+
const measure = ()=>{
|
|
29
|
+
const width = element.offsetWidth;
|
|
30
|
+
const textWidth = content.offsetWidth;
|
|
31
|
+
setScale(width > 2 * gap && textWidth > 0 ? Math.min(1, (width - 2 * gap) / textWidth) : 1);
|
|
32
|
+
};
|
|
33
|
+
measure();
|
|
34
|
+
const observer = new ResizeObserver(measure);
|
|
35
|
+
observer.observe(element);
|
|
36
|
+
observer.observe(content);
|
|
37
|
+
return ()=>observer.disconnect();
|
|
38
|
+
}, [
|
|
39
|
+
gap,
|
|
40
|
+
hasImage,
|
|
41
|
+
hasIcon
|
|
42
|
+
]);
|
|
43
|
+
const dimensionsStyle = 'number' == typeof dimensions ? {
|
|
44
|
+
width: dimensions,
|
|
45
|
+
height: dimensions,
|
|
46
|
+
fontSize: hasIcon || 'object' == typeof size ? dimensions / 2 : void 0
|
|
47
|
+
} : {};
|
|
48
|
+
return /*#__PURE__*/ jsx("span", {
|
|
49
|
+
...rest,
|
|
50
|
+
ref: node,
|
|
51
|
+
"data-tao-avatar": "",
|
|
52
|
+
"data-tao-shape": shape,
|
|
53
|
+
"data-tao-size": 'string' == typeof dimensions ? 'middle' === dimensions || 'default' === dimensions ? 'medium' : dimensions : void 0,
|
|
54
|
+
"data-tao-image": hasImage || void 0,
|
|
55
|
+
"data-tao-icon": hasIcon || void 0,
|
|
56
|
+
className: cx(prefixCls, classNames?.root, className, rootClassName),
|
|
57
|
+
style: {
|
|
58
|
+
...dimensionsStyle,
|
|
59
|
+
...styles?.root,
|
|
60
|
+
...style
|
|
61
|
+
},
|
|
62
|
+
children: hasImage ? 'string' == typeof src ? /*#__PURE__*/ jsx("img", {
|
|
63
|
+
src: src,
|
|
64
|
+
srcSet: srcSet,
|
|
65
|
+
alt: alt ?? '',
|
|
66
|
+
draggable: draggable,
|
|
67
|
+
crossOrigin: crossOrigin,
|
|
68
|
+
className: classNames?.image,
|
|
69
|
+
style: styles?.image,
|
|
70
|
+
onError: ()=>{
|
|
71
|
+
if (onError?.() !== false) setFailedSource({
|
|
72
|
+
src,
|
|
73
|
+
srcSet
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}) : src : hasIcon ? /*#__PURE__*/ jsx("span", {
|
|
77
|
+
"data-tao-avatar-icon": "",
|
|
78
|
+
className: classNames?.icon,
|
|
79
|
+
style: styles?.icon,
|
|
80
|
+
children: icon
|
|
81
|
+
}) : /*#__PURE__*/ jsx("span", {
|
|
82
|
+
ref: text,
|
|
83
|
+
"data-tao-avatar-content": "",
|
|
84
|
+
className: classNames?.content,
|
|
85
|
+
style: {
|
|
86
|
+
transform: `scale(${scale})`,
|
|
87
|
+
...styles?.content
|
|
88
|
+
},
|
|
89
|
+
children: children
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
AvatarRoot.displayName = 'Avatar';
|
|
94
|
+
function flattenChildren(children) {
|
|
95
|
+
return Children.toArray(children).flatMap((child)=>/*#__PURE__*/ isValidElement(child) && child.type === Fragment ? flattenChildren(child.props.children) : [
|
|
96
|
+
child
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
const AvatarGroup = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
100
|
+
const parent = useContext(GroupContext);
|
|
101
|
+
const { prefixCls, rootClassName, size = parent.size, shape = parent.shape, max, maxCount, maxStyle, maxPopoverPlacement, maxPopoverTrigger, className, style, classNames, styles, children, ...rest } = props;
|
|
102
|
+
const node = useRef(null);
|
|
103
|
+
useImperativeHandle(ref, ()=>({
|
|
104
|
+
nativeElement: node.current
|
|
105
|
+
}));
|
|
106
|
+
const items = flattenChildren(children);
|
|
107
|
+
const count = max?.count || maxCount;
|
|
108
|
+
const hasOverflow = void 0 !== count && count > 0 && count < items.length;
|
|
109
|
+
const visible = hasOverflow ? items.slice(0, count) : items;
|
|
110
|
+
const hidden = hasOverflow ? items.slice(count) : [];
|
|
111
|
+
return /*#__PURE__*/ jsx(GroupContext.Provider, {
|
|
112
|
+
value: {
|
|
113
|
+
size,
|
|
114
|
+
shape
|
|
115
|
+
},
|
|
116
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
117
|
+
...rest,
|
|
118
|
+
ref: node,
|
|
119
|
+
"data-tao-avatar-group": "",
|
|
120
|
+
className: cx(prefixCls && `${prefixCls}-group`, classNames?.root, className, rootClassName),
|
|
121
|
+
style: {
|
|
122
|
+
...styles?.root,
|
|
123
|
+
...style
|
|
124
|
+
},
|
|
125
|
+
children: [
|
|
126
|
+
visible,
|
|
127
|
+
hasOverflow && /*#__PURE__*/ jsx(Popover, {
|
|
128
|
+
content: /*#__PURE__*/ jsx("div", {
|
|
129
|
+
"data-tao-avatar-overflow-list": "",
|
|
130
|
+
children: hidden
|
|
131
|
+
}),
|
|
132
|
+
destroyOnHidden: true,
|
|
133
|
+
...max?.popover,
|
|
134
|
+
placement: max?.popover?.placement ?? maxPopoverPlacement ?? 'top',
|
|
135
|
+
trigger: max?.popover?.trigger ?? maxPopoverTrigger ?? 'hover',
|
|
136
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
137
|
+
type: "button",
|
|
138
|
+
"data-tao-avatar-overflow": "",
|
|
139
|
+
"aria-label": `${hidden.length} more users`,
|
|
140
|
+
className: classNames?.overflow,
|
|
141
|
+
style: styles?.overflow,
|
|
142
|
+
children: /*#__PURE__*/ jsxs(AvatarRoot, {
|
|
143
|
+
style: max?.style ?? maxStyle,
|
|
144
|
+
children: [
|
|
145
|
+
"+",
|
|
146
|
+
hidden.length
|
|
147
|
+
]
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
AvatarGroup.displayName = 'Avatar.Group';
|
|
156
|
+
const Avatar = Object.assign(AvatarRoot, {
|
|
157
|
+
Group: AvatarGroup
|
|
158
|
+
});
|
|
159
|
+
export { Avatar };
|