react-kui 3.2.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/kui-components.json +819 -162
- package/es/_virtual/_rolldown/runtime.js +2 -3
- package/es/affix/index.js +73 -185
- package/es/alert/index.js +3 -4
- package/es/anchor/anchor-context.js +2 -3
- package/es/anchor/anchor-link.js +3 -4
- package/es/anchor/anchor.js +195 -398
- package/es/auto-complete/index.js +160 -561
- package/es/avatar/avatar-group-context.js +2 -3
- package/es/avatar/avatar-group.js +32 -124
- package/es/avatar/avatar.js +58 -159
- package/es/back-top/index.js +66 -201
- package/es/badge/index.js +4 -5
- package/es/base/teleport.js +22 -54
- package/es/base/transition-props.js +2 -3
- package/es/base/transition.js +2 -3
- package/es/breadcrumb/breadcrumb-context.js +2 -3
- package/es/breadcrumb/breadcrumb-item.js +19 -102
- package/es/breadcrumb/breadcrumb.js +10 -59
- package/es/button/button-group-context.js +2 -3
- package/es/button/button-group.js +15 -75
- package/es/button/button.js +4 -5
- package/es/calendar/index.js +4 -5
- package/es/card/index.js +4 -5
- package/es/carousel/carousel-context.js +2 -3
- package/es/carousel/carousel-item.js +3 -4
- package/es/carousel/carousel.js +281 -628
- package/es/carousel/drag.js +2 -3
- package/es/cascader/index.js +7 -8
- package/es/check-card/check-card-group.js +53 -179
- package/es/check-card/check-card.js +100 -293
- package/es/check-card/context.js +2 -3
- package/es/checkbox/checkbox-group-context.js +2 -3
- package/es/checkbox/checkbox-group.js +34 -138
- package/es/checkbox/checkbox.js +4 -5
- package/es/checkbox/index.js +2 -3
- package/es/collapse/collapse-panel.js +84 -206
- package/es/collapse/collapse.js +38 -170
- package/es/color-picker/alpha.js +44 -125
- package/es/color-picker/hue.js +39 -108
- package/es/color-picker/index.js +7 -6
- package/es/color-picker/mode.js +76 -159
- package/es/color-picker/paint.js +66 -163
- package/es/color-picker/presets.js +12 -44
- package/es/components.js +37 -32
- package/es/config/config-context.js +2 -3
- package/es/config/context.js +2 -3
- package/es/config/index.js +3 -4
- package/es/config/popup-host.js +3 -4
- package/es/config/size-context.js +2 -3
- package/es/config/use-config-appearance.js +3 -4
- package/es/const/var.js +2 -3
- package/es/date-picker/index.js +8 -9
- package/es/descriptions/descriptions-item.js +3 -4
- package/es/descriptions/descriptions.js +53 -144
- package/es/divider/index.js +2 -3
- package/es/drawer/index.js +171 -465
- package/es/dropdown/dropdown-button.js +25 -128
- package/es/dropdown/dropdown-context.js +2 -3
- package/es/dropdown/dropdown.js +56 -207
- package/es/dropdown/trigger.js +37 -125
- package/es/empty/index.js +34 -111
- package/es/feature-card/index.js +2 -3
- package/es/feedback-panel/index.js +30 -155
- package/es/flame-wrap/index.js +3 -4
- package/es/flame-wrap/types.js +2 -3
- package/es/flex/index.js +2 -3
- package/es/form/field-context.js +3 -4
- package/es/form/form-context.js +2 -3
- package/es/form/form-item.js +4 -5
- package/es/form/form.js +108 -279
- package/es/form/utils.js +2 -3
- package/es/gradient-picker/corners.js +55 -0
- package/es/gradient-picker/index.js +191 -0
- package/es/gradient-picker/stops.js +219 -0
- package/es/gradient-picker/types.js +147 -0
- package/es/grid/grid-item.js +25 -116
- package/es/grid/grid.js +40 -151
- package/es/grid/useBreakpoint.js +3 -4
- package/es/icon/index.js +24 -126
- package/es/image/group.js +3 -4
- package/es/image/image-group-context.js +2 -3
- package/es/image/image.js +5 -6
- package/es/image/instance.js +2 -3
- package/es/image/preview.js +4 -5
- package/es/image/utils.js +2 -3
- package/es/index.js +5 -4
- package/es/input/index.js +2 -3
- package/es/input/input-base.js +4 -5
- package/es/input/input-box.js +2 -3
- package/es/input/input-group.js +4 -5
- package/es/input/input.js +3 -4
- package/es/input/textarea.js +3 -4
- package/es/input-number/drag.js +63 -0
- package/es/input-number/index.js +41 -11
- package/es/input-otp/index.js +3 -4
- package/es/input-tag/index.js +5 -6
- package/es/kanban/index.js +31 -168
- package/es/layout/index.js +43 -215
- package/es/layout/layout-context.js +2 -3
- package/es/list-panel/index.js +47 -185
- package/es/loading/index.js +2 -3
- package/es/loading/loading-bar.js +54 -114
- package/es/locale/de.js +2 -3
- package/es/locale/el.js +2 -3
- package/es/locale/en.js +2 -3
- package/es/locale/fr.js +2 -3
- package/es/locale/it.js +2 -3
- package/es/locale/ja.js +2 -3
- package/es/locale/ko.js +2 -3
- package/es/locale/ru.js +2 -3
- package/es/locale/th.js +2 -3
- package/es/locale/uk.js +2 -3
- package/es/locale/vi.js +2 -3
- package/es/locale/zh-CN.js +2 -3
- package/es/locale/zh-TW.js +2 -3
- package/es/mentions/index.js +214 -581
- package/es/menu/menu-context.js +2 -3
- package/es/menu/menu-divider.js +3 -4
- package/es/menu/menu-group.js +3 -4
- package/es/menu/menu-item.js +2 -3
- package/es/menu/menu-keyboard.js +2 -3
- package/es/menu/menu.js +184 -442
- package/es/menu/recursive-menu.js +3 -4
- package/es/menu/sub-menu.js +5 -6
- package/es/message/index.js +2 -3
- package/es/modal/api.js +2 -3
- package/es/modal/modal.js +263 -599
- package/es/modal/toast.js +63 -179
- package/es/node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js +2 -3
- package/es/notice/container.js +2 -3
- package/es/notice/content.js +4 -5
- package/es/notice/index.js +2 -3
- package/es/notice/instance.js +2 -3
- package/es/page/index.js +4 -5
- package/es/page/responsive.js +2 -3
- package/es/page-header/index.js +3 -4
- package/es/popconfirm/index.js +24 -70
- package/es/poptip/index.js +29 -88
- package/es/popup/index.js +8 -6
- package/es/popup/layers.js +2 -3
- package/es/progress/index.js +95 -229
- package/es/qrcode/index.js +3 -4
- package/es/radio/radio-button.js +37 -131
- package/es/radio/radio-group-context.js +2 -3
- package/es/radio/radio-group.js +69 -223
- package/es/radio/radio.js +3 -4
- package/es/rate/index.js +68 -226
- package/es/rate/star.js +38 -129
- package/es/result/index.js +35 -127
- package/es/ripple/index.js +3 -4
- package/es/ripple/types.js +2 -3
- package/es/row-col/col.js +59 -149
- package/es/row-col/row.js +2 -3
- package/es/segmented/index.js +66 -210
- package/es/select/option.js +23 -116
- package/es/select/select.js +9 -10
- package/es/skeleton/skeleton-avatar.js +2 -3
- package/es/skeleton/skeleton-button.js +2 -3
- package/es/skeleton/skeleton-image.js +28 -108
- package/es/skeleton/skeleton-text.js +17 -93
- package/es/skeleton/skeleton.js +46 -133
- package/es/skeleton/use-skeleton-loading.js +3 -4
- package/es/slider/index.js +92 -286
- package/es/slider/thumb.js +43 -133
- package/es/space/index.js +3 -4
- package/es/spin/index.js +2 -3
- package/es/splitter/splitter-panel.js +3 -4
- package/es/splitter/splitter.js +77 -219
- package/es/stat-card/countup.js +46 -141
- package/es/stat-card/rollup.js +27 -105
- package/es/stat-card/stat-card.js +3 -4
- package/es/stat-card/stat-number.js +26 -113
- package/es/stat-card/utils/countup.js +2 -3
- package/es/stat-card/utils/odometer.js +2 -3
- package/es/stat-card/utils/stat-item-key.js +2 -3
- package/es/steps/index.js +45 -123
- package/es/switch/index.js +4 -5
- package/es/table/column-setting.js +43 -139
- package/es/table/index.js +8 -9
- package/es/table/utils.js +2 -3
- package/es/tabs/tab-panel.js +19 -71
- package/es/tabs/tabs.js +6 -7
- package/es/tag/index.js +4 -5
- package/es/time-line/timeline-item.js +3 -4
- package/es/time-line/timeline.js +8 -44
- package/es/tooltip/index.js +41 -142
- package/es/tour/index.js +138 -356
- package/es/transfer/index.js +184 -487
- package/es/tree/index.js +8 -9
- package/es/tree/utils.js +2 -3
- package/es/tree-select/index.js +8 -9
- package/es/typography/index.js +75 -306
- package/es/upload/file-list.js +95 -119
- package/es/upload/index.js +8 -9
- package/es/upload/picture-sort.js +2 -3
- package/es/upload/selector.js +63 -193
- package/es/utils/checked.js +2 -3
- package/es/utils/color.js +2 -3
- package/es/utils/css.js +2 -3
- package/es/utils/focus.js +2 -3
- package/es/utils/number.js +2 -3
- package/es/utils/overlay-order.js +2 -3
- package/es/utils/overlay-stack.js +3 -4
- package/es/utils/placement.js +16 -4
- package/es/utils/popup-arrow.js +45 -0
- package/es/utils/popup.js +2 -3
- package/es/utils/promise.js +2 -3
- package/es/utils/react-node.js +2 -3
- package/es/utils/selection-tags.js +2 -3
- package/es/utils/share.js +2 -3
- package/es/utils/theme.js +2 -3
- package/es/utils/transition.js +2 -3
- package/es/utils/use-value.js +3 -4
- package/es/virtual-list/index.js +49 -187
- package/es/virtual-list/range.js +2 -3
- package/es/watermark/index.js +149 -289
- package/lib/index.cjs +2 -2
- package/lib/locale/de.cjs +1 -1
- package/lib/locale/el.cjs +1 -1
- package/lib/locale/en.cjs +1 -1
- package/lib/locale/fr.cjs +1 -1
- package/lib/locale/it.cjs +1 -1
- package/lib/locale/ja.cjs +1 -1
- package/lib/locale/ko.cjs +1 -1
- package/lib/locale/ru.cjs +1 -1
- package/lib/locale/th.cjs +1 -1
- package/lib/locale/uk.cjs +1 -1
- package/lib/locale/vi.cjs +1 -1
- package/lib/locale/zh-CN.cjs +1 -1
- package/lib/locale/zh-TW.cjs +1 -1
- package/package.json +24 -24
- package/style/base.css +1 -1
- package/style/components.css +2 -2
- package/style/index.css +2 -2
- package/style/theme.css +1 -1
- package/types/affix/index.d.cts +1 -1
- package/types/affix/index.d.ts +1 -1
- package/types/anchor/anchor-link.d.cts +1 -1
- package/types/anchor/anchor-link.d.ts +1 -1
- package/types/anchor/anchor.d.cts +1 -1
- package/types/anchor/anchor.d.ts +1 -1
- package/types/back-top/index.d.cts +1 -1
- package/types/back-top/index.d.ts +1 -1
- package/types/carousel/carousel-item.d.cts +1 -1
- package/types/carousel/carousel-item.d.ts +1 -1
- package/types/cascader/index.d.cts +1 -1
- package/types/cascader/index.d.ts +1 -1
- package/types/color-picker/alpha.d.cts +1 -1
- package/types/color-picker/alpha.d.ts +1 -1
- package/types/color-picker/hue.d.cts +1 -1
- package/types/color-picker/hue.d.ts +1 -1
- package/types/color-picker/index.d.cts +3 -2
- package/types/color-picker/index.d.ts +3 -2
- package/types/color-picker/mode.d.cts +1 -1
- package/types/color-picker/mode.d.ts +1 -1
- package/types/color-picker/paint.d.cts +1 -1
- package/types/color-picker/paint.d.ts +1 -1
- package/types/color-picker/presets.d.cts +1 -1
- package/types/color-picker/presets.d.ts +1 -1
- package/types/components.d.cts +3 -0
- package/types/components.d.ts +3 -0
- package/types/date-picker/index.d.cts +2 -2
- package/types/date-picker/index.d.ts +2 -2
- package/types/feature-card/index.d.cts +1 -1
- package/types/feature-card/index.d.ts +1 -1
- package/types/feedback-panel/index.d.cts +1 -1
- package/types/feedback-panel/index.d.ts +1 -1
- package/types/flame-wrap/index.d.cts +1 -1
- package/types/flame-wrap/index.d.ts +1 -1
- package/types/form/form-item.d.cts +1 -1
- package/types/form/form-item.d.ts +1 -1
- package/types/gradient-picker/corners.d.cts +8 -0
- package/types/gradient-picker/corners.d.ts +8 -0
- package/types/gradient-picker/index.d.cts +25 -0
- package/types/gradient-picker/index.d.ts +25 -0
- package/types/gradient-picker/stops.d.cts +12 -0
- package/types/gradient-picker/stops.d.ts +12 -0
- package/types/gradient-picker/types.d.cts +34 -0
- package/types/gradient-picker/types.d.ts +34 -0
- package/types/grid/grid-item.d.cts +1 -1
- package/types/grid/grid-item.d.ts +1 -1
- package/types/grid/grid.d.cts +1 -1
- package/types/grid/grid.d.ts +1 -1
- package/types/image/group.d.cts +1 -1
- package/types/image/group.d.ts +1 -1
- package/types/input-number/drag.d.cts +9 -0
- package/types/input-number/drag.d.ts +9 -0
- package/types/input-number/index.d.cts +1 -0
- package/types/input-number/index.d.ts +1 -0
- package/types/kanban/index.d.cts +1 -1
- package/types/kanban/index.d.ts +1 -1
- package/types/list-panel/index.d.cts +1 -1
- package/types/list-panel/index.d.ts +1 -1
- package/types/loading/loading-bar.d.cts +1 -1
- package/types/loading/loading-bar.d.ts +1 -1
- package/types/modal/toast.d.cts +1 -1
- package/types/modal/toast.d.ts +1 -1
- package/types/notice/content.d.cts +2 -2
- package/types/notice/content.d.ts +2 -2
- package/types/page-header/index.d.cts +1 -1
- package/types/page-header/index.d.ts +1 -1
- package/types/popconfirm/index.d.cts +1 -0
- package/types/popconfirm/index.d.ts +1 -0
- package/types/poptip/index.d.cts +1 -0
- package/types/poptip/index.d.ts +1 -0
- package/types/popup/index.d.cts +1 -0
- package/types/popup/index.d.ts +1 -0
- package/types/result/index.d.cts +1 -1
- package/types/result/index.d.ts +1 -1
- package/types/ripple/index.d.cts +1 -1
- package/types/ripple/index.d.ts +1 -1
- package/types/slider/index.d.cts +1 -1
- package/types/slider/index.d.ts +1 -1
- package/types/splitter/splitter-panel.d.cts +1 -1
- package/types/splitter/splitter-panel.d.ts +1 -1
- package/types/splitter/splitter.d.cts +1 -1
- package/types/splitter/splitter.d.ts +1 -1
- package/types/stat-card/countup.d.cts +1 -1
- package/types/stat-card/countup.d.ts +1 -1
- package/types/stat-card/rollup.d.cts +1 -1
- package/types/stat-card/rollup.d.ts +1 -1
- package/types/stat-card/stat-card.d.cts +1 -1
- package/types/stat-card/stat-card.d.ts +1 -1
- package/types/stat-card/stat-number.d.cts +1 -1
- package/types/stat-card/stat-number.d.ts +1 -1
- package/types/table/column-setting.d.cts +1 -1
- package/types/table/column-setting.d.ts +1 -1
- package/types/table/index.d.cts +1 -1
- package/types/table/index.d.ts +1 -1
- package/types/time-line/timeline-item.d.cts +1 -1
- package/types/time-line/timeline-item.d.ts +1 -1
- package/types/time-line/timeline.d.cts +1 -1
- package/types/time-line/timeline.d.ts +1 -1
- package/types/tooltip/index.d.cts +1 -0
- package/types/tooltip/index.d.ts +1 -0
- package/types/transfer/index.d.cts +1 -1
- package/types/transfer/index.d.ts +1 -1
- package/types/tree-select/index.d.cts +1 -1
- package/types/tree-select/index.d.ts +1 -1
- package/types/upload/file-list.d.cts +1 -1
- package/types/upload/file-list.d.ts +1 -1
- package/types/upload/selector.d.cts +1 -1
- package/types/upload/selector.d.ts +1 -1
- package/types/utils/placement.d.cts +2 -1
- package/types/utils/placement.d.ts +2 -1
- package/types/utils/popup-arrow.d.cts +5 -0
- package/types/utils/popup-arrow.d.ts +5 -0
- package/types/utils/selection-tags.d.cts +1 -1
- package/types/utils/selection-tags.d.ts +1 -1
- package/types/watermark/index.d.cts +1 -1
- package/types/watermark/index.d.ts +1 -1
package/es/virtual-list/range.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/virtual-list/range.ts
|
|
10
10
|
var normalizeItemHeight = (value) => Number.isFinite(value) && value > 0 ? value : 1;
|
|
11
11
|
var getVirtualRange = ({ count, scrollTop, viewportHeight, itemHeight, overscan }) => {
|
|
12
12
|
const safeCount = Number.isFinite(count) ? Math.max(0, Math.floor(count)) : 0;
|
|
@@ -24,5 +24,4 @@ var getVirtualRange = ({ count, scrollTop, viewportHeight, itemHeight, overscan
|
|
|
24
24
|
total: safeCount * safeHeight
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
//#endregion
|
|
28
27
|
export { getVirtualRange, normalizeItemHeight };
|
package/es/watermark/index.js
CHANGED
|
@@ -1,313 +1,173 @@
|
|
|
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 { c } from "react/compiler-runtime";
|
|
10
9
|
import clsx from "clsx";
|
|
11
10
|
import { useEffect, useRef } from "react";
|
|
12
11
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
13
|
-
|
|
14
|
-
function Watermark(
|
|
15
|
-
const $ = c(46);
|
|
16
|
-
let children;
|
|
17
|
-
let className;
|
|
18
|
-
let font;
|
|
19
|
-
let rest;
|
|
20
|
-
let style;
|
|
21
|
-
let t1;
|
|
22
|
-
let t10;
|
|
23
|
-
let t11;
|
|
24
|
-
let t2;
|
|
25
|
-
let t3;
|
|
26
|
-
let t4;
|
|
27
|
-
let t5;
|
|
28
|
-
let t6;
|
|
29
|
-
let t7;
|
|
30
|
-
let t8;
|
|
31
|
-
let t9;
|
|
32
|
-
if ($[0] !== t0) {
|
|
33
|
-
({content: t1, image: t2, width: t3, height: t4, rotate: t5, zIndex: t6, fullscreen: t7, antiTamper: t8, font, gap: t9, offset: t10, layout: t11, className, style, children, ...rest} = t0);
|
|
34
|
-
$[0] = t0;
|
|
35
|
-
$[1] = children;
|
|
36
|
-
$[2] = className;
|
|
37
|
-
$[3] = font;
|
|
38
|
-
$[4] = rest;
|
|
39
|
-
$[5] = style;
|
|
40
|
-
$[6] = t1;
|
|
41
|
-
$[7] = t10;
|
|
42
|
-
$[8] = t11;
|
|
43
|
-
$[9] = t2;
|
|
44
|
-
$[10] = t3;
|
|
45
|
-
$[11] = t4;
|
|
46
|
-
$[12] = t5;
|
|
47
|
-
$[13] = t6;
|
|
48
|
-
$[14] = t7;
|
|
49
|
-
$[15] = t8;
|
|
50
|
-
$[16] = t9;
|
|
51
|
-
} else {
|
|
52
|
-
children = $[1];
|
|
53
|
-
className = $[2];
|
|
54
|
-
font = $[3];
|
|
55
|
-
rest = $[4];
|
|
56
|
-
style = $[5];
|
|
57
|
-
t1 = $[6];
|
|
58
|
-
t10 = $[7];
|
|
59
|
-
t11 = $[8];
|
|
60
|
-
t2 = $[9];
|
|
61
|
-
t3 = $[10];
|
|
62
|
-
t4 = $[11];
|
|
63
|
-
t5 = $[12];
|
|
64
|
-
t6 = $[13];
|
|
65
|
-
t7 = $[14];
|
|
66
|
-
t8 = $[15];
|
|
67
|
-
t9 = $[16];
|
|
68
|
-
}
|
|
69
|
-
const content = t1 === void 0 ? "" : t1;
|
|
70
|
-
const image = t2 === void 0 ? "" : t2;
|
|
71
|
-
const width = t3 === void 0 ? 240 : t3;
|
|
72
|
-
const height = t4 === void 0 ? 189 : t4;
|
|
73
|
-
const rotate = t5 === void 0 ? -22 : t5;
|
|
74
|
-
const zIndex = t6 === void 0 ? 999 : t6;
|
|
75
|
-
const fullscreen = t7 === void 0 ? false : t7;
|
|
76
|
-
const antiTamper = t8 === void 0 ? true : t8;
|
|
77
|
-
let t12;
|
|
78
|
-
if ($[17] !== t9) {
|
|
79
|
-
t12 = t9 === void 0 ? [40, 40] : t9;
|
|
80
|
-
$[17] = t9;
|
|
81
|
-
$[18] = t12;
|
|
82
|
-
} else t12 = $[18];
|
|
83
|
-
const gap = t12;
|
|
84
|
-
let t13;
|
|
85
|
-
if ($[19] !== t10) {
|
|
86
|
-
t13 = t10 === void 0 ? [20, 20] : t10;
|
|
87
|
-
$[19] = t10;
|
|
88
|
-
$[20] = t13;
|
|
89
|
-
} else t13 = $[20];
|
|
90
|
-
const offset = t13;
|
|
91
|
-
const layout = t11 === void 0 ? "stagger" : t11;
|
|
12
|
+
// components/watermark/index.tsx
|
|
13
|
+
function Watermark({ content = "", image = "", width = 240, height = 189, rotate = -22, zIndex = 999, fullscreen = false, antiTamper = true, font, gap = [40, 40], offset = [20, 20], layout = "stagger", className, style, children, ...rest }) {
|
|
92
14
|
const containerRef = useRef(null);
|
|
93
15
|
const watermarkRef = useRef(null);
|
|
94
16
|
const restoringRef = useRef(false);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
fontFamily: "sans-serif",
|
|
111
|
-
fontStyle: "normal",
|
|
112
|
-
...font
|
|
113
|
-
};
|
|
114
|
-
const lines = (Array.isArray(content) ? content : [content]).map(_temp);
|
|
115
|
-
const heights = lines.map((item_0) => (item_0.fontSize ?? globalFont.fontSize) + 8);
|
|
116
|
-
let y = -heights.reduce(_temp2, 0) / 2;
|
|
117
|
-
context.textAlign = "center";
|
|
118
|
-
context.textBaseline = "middle";
|
|
119
|
-
lines.forEach((item_2, index) => {
|
|
120
|
-
const size = item_2.fontSize ?? globalFont.fontSize;
|
|
121
|
-
context.font = `${item_2.fontStyle ?? globalFont.fontStyle} ${item_2.fontWeight ?? globalFont.fontWeight} ${size}px ${item_2.fontFamily ?? globalFont.fontFamily}`;
|
|
122
|
-
context.fillStyle = item_2.color ?? globalFont.color;
|
|
123
|
-
context.fillText(item_2.text, 0, y + heights[index] / 2);
|
|
124
|
-
y = y + heights[index];
|
|
125
|
-
});
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (typeof document === "undefined") return;
|
|
19
|
+
let disposed = false;
|
|
20
|
+
let parentObserver = null;
|
|
21
|
+
let selfObserver = null;
|
|
22
|
+
const target = fullscreen ? document.body : containerRef.current;
|
|
23
|
+
if (!target) return;
|
|
24
|
+
const drawText = (context) => {
|
|
25
|
+
const globalFont = {
|
|
26
|
+
color: "rgba(128, 128, 128, 0.15)",
|
|
27
|
+
fontSize: 15,
|
|
28
|
+
fontWeight: "normal",
|
|
29
|
+
fontFamily: "sans-serif",
|
|
30
|
+
fontStyle: "normal",
|
|
31
|
+
...font
|
|
126
32
|
};
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const drawCell = (x, y_0, source) => {
|
|
139
|
-
context_0.save();
|
|
140
|
-
context_0.translate(x, y_0);
|
|
141
|
-
context_0.rotate(rotate * Math.PI / 180);
|
|
142
|
-
if (source) context_0.drawImage(source, -width / 2, -height / 2, width, height);
|
|
143
|
-
else drawText(context_0);
|
|
144
|
-
context_0.restore();
|
|
145
|
-
};
|
|
146
|
-
const render = (source_0) => {
|
|
147
|
-
const x_0 = offset[0];
|
|
148
|
-
const y_1 = offset[1];
|
|
149
|
-
drawCell(cellWidth / 2 + x_0, cellHeight / 2 + y_1, source_0);
|
|
150
|
-
if (staggered) {
|
|
151
|
-
drawCell(cellWidth * 1.5 + x_0, cellHeight / 2 + y_1, source_0);
|
|
152
|
-
drawCell(x_0, cellHeight * 1.5 + y_1, source_0);
|
|
153
|
-
drawCell(cellWidth + x_0, cellHeight * 1.5 + y_1, source_0);
|
|
154
|
-
drawCell(cellWidth * 2 + x_0, cellHeight * 1.5 + y_1, source_0);
|
|
155
|
-
}
|
|
156
|
-
resolve(canvas.toDataURL());
|
|
157
|
-
};
|
|
158
|
-
if (!image) return render();
|
|
159
|
-
const source_1 = new Image();
|
|
160
|
-
source_1.crossOrigin = "anonymous";
|
|
161
|
-
source_1.onload = () => render(source_1);
|
|
162
|
-
source_1.onerror = () => render();
|
|
163
|
-
source_1.src = image;
|
|
33
|
+
const lines = (Array.isArray(content) ? content : [content]).map((item) => typeof item === "string" ? { text: item } : item);
|
|
34
|
+
const heights = lines.map((item_0) => (item_0.fontSize ?? globalFont.fontSize) + 8);
|
|
35
|
+
let y = -heights.reduce((sum, item_1) => sum + item_1, 0) / 2;
|
|
36
|
+
context.textAlign = "center";
|
|
37
|
+
context.textBaseline = "middle";
|
|
38
|
+
lines.forEach((item_2, index) => {
|
|
39
|
+
const size = item_2.fontSize ?? globalFont.fontSize;
|
|
40
|
+
context.font = `${item_2.fontStyle ?? globalFont.fontStyle} ${item_2.fontWeight ?? globalFont.fontWeight} ${size}px ${item_2.fontFamily ?? globalFont.fontFamily}`;
|
|
41
|
+
context.fillStyle = item_2.color ?? globalFont.color;
|
|
42
|
+
context.fillText(item_2.text, 0, y + heights[index] / 2);
|
|
43
|
+
y += heights[index];
|
|
164
44
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
root.attachShadow({ mode: "closed" }).appendChild(inner);
|
|
196
|
-
target.appendChild(root);
|
|
197
|
-
watermarkRef.current = root;
|
|
198
|
-
restoringRef.current = false;
|
|
199
|
-
if (!antiTamper) return;
|
|
200
|
-
const restore = () => {
|
|
201
|
-
if (!disposed && !restoringRef.current) {
|
|
202
|
-
restoringRef.current = true;
|
|
203
|
-
install();
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
parentObserver = new MutationObserver((records) => {
|
|
207
|
-
if (records.some((record) => [...record.removedNodes].includes(root))) restore();
|
|
208
|
-
});
|
|
209
|
-
parentObserver.observe(target, { childList: true });
|
|
210
|
-
selfObserver = new MutationObserver(restore);
|
|
211
|
-
selfObserver.observe(root, {
|
|
212
|
-
attributes: true,
|
|
213
|
-
attributeFilter: [
|
|
214
|
-
"style",
|
|
215
|
-
"class",
|
|
216
|
-
"id",
|
|
217
|
-
"hidden"
|
|
218
|
-
]
|
|
219
|
-
});
|
|
45
|
+
};
|
|
46
|
+
const createPattern = () => new Promise((resolve) => {
|
|
47
|
+
const ratio = window.devicePixelRatio || 1;
|
|
48
|
+
const cellWidth = width + gap[0];
|
|
49
|
+
const cellHeight = height + gap[1];
|
|
50
|
+
const staggered = layout === "stagger";
|
|
51
|
+
const canvas = document.createElement("canvas");
|
|
52
|
+
canvas.width = cellWidth * (staggered ? 2 : 1) * ratio;
|
|
53
|
+
canvas.height = cellHeight * (staggered ? 2 : 1) * ratio;
|
|
54
|
+
const context_0 = canvas.getContext("2d");
|
|
55
|
+
if (!context_0) return resolve("");
|
|
56
|
+
context_0.scale(ratio, ratio);
|
|
57
|
+
const drawCell = (x, y_0, source) => {
|
|
58
|
+
context_0.save();
|
|
59
|
+
context_0.translate(x, y_0);
|
|
60
|
+
context_0.rotate(rotate * Math.PI / 180);
|
|
61
|
+
if (source) context_0.drawImage(source, -width / 2, -height / 2, width, height);
|
|
62
|
+
else drawText(context_0);
|
|
63
|
+
context_0.restore();
|
|
64
|
+
};
|
|
65
|
+
const render = (source_0) => {
|
|
66
|
+
const x_0 = offset[0], y_1 = offset[1];
|
|
67
|
+
drawCell(cellWidth / 2 + x_0, cellHeight / 2 + y_1, source_0);
|
|
68
|
+
if (staggered) {
|
|
69
|
+
drawCell(cellWidth * 1.5 + x_0, cellHeight / 2 + y_1, source_0);
|
|
70
|
+
drawCell(x_0, cellHeight * 1.5 + y_1, source_0);
|
|
71
|
+
drawCell(cellWidth + x_0, cellHeight * 1.5 + y_1, source_0);
|
|
72
|
+
drawCell(cellWidth * 2 + x_0, cellHeight * 1.5 + y_1, source_0);
|
|
73
|
+
}
|
|
74
|
+
resolve(canvas.toDataURL());
|
|
220
75
|
};
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
76
|
+
if (!image) return render();
|
|
77
|
+
const source_1 = new Image();
|
|
78
|
+
source_1.crossOrigin = "anonymous";
|
|
79
|
+
source_1.onload = () => render(source_1);
|
|
80
|
+
source_1.onerror = () => render();
|
|
81
|
+
source_1.src = image;
|
|
82
|
+
});
|
|
83
|
+
const install = async () => {
|
|
84
|
+
const pattern = await createPattern();
|
|
85
|
+
if (disposed) return;
|
|
86
|
+
parentObserver?.disconnect();
|
|
87
|
+
selfObserver?.disconnect();
|
|
88
|
+
watermarkRef.current?.remove();
|
|
89
|
+
const root = document.createElement("div");
|
|
90
|
+
root.dataset.wmRoot = "true";
|
|
91
|
+
Object.assign(root.style, {
|
|
92
|
+
position: fullscreen ? "fixed" : "absolute",
|
|
93
|
+
inset: "0",
|
|
94
|
+
width: "100%",
|
|
95
|
+
height: "100%",
|
|
96
|
+
pointerEvents: "none",
|
|
97
|
+
zIndex: String(zIndex),
|
|
98
|
+
margin: "0",
|
|
99
|
+
padding: "0"
|
|
100
|
+
});
|
|
101
|
+
const inner = document.createElement("div");
|
|
102
|
+
const cellWidth_0 = width + gap[0], cellHeight_0 = height + gap[1], staggered_0 = layout === "stagger";
|
|
103
|
+
Object.assign(inner.style, {
|
|
104
|
+
width: "100%",
|
|
105
|
+
height: "100%",
|
|
106
|
+
backgroundImage: `url(${pattern})`,
|
|
107
|
+
backgroundRepeat: "repeat",
|
|
108
|
+
backgroundSize: `${cellWidth_0 * (staggered_0 ? 2 : 1)}px ${cellHeight_0 * (staggered_0 ? 2 : 1)}px`,
|
|
109
|
+
pointerEvents: "none"
|
|
110
|
+
});
|
|
111
|
+
root.attachShadow({ mode: "closed" }).appendChild(inner);
|
|
112
|
+
target.appendChild(root);
|
|
113
|
+
watermarkRef.current = root;
|
|
114
|
+
restoringRef.current = false;
|
|
115
|
+
if (!antiTamper) return;
|
|
116
|
+
const restore = () => {
|
|
117
|
+
if (!disposed && !restoringRef.current) {
|
|
118
|
+
restoringRef.current = true;
|
|
119
|
+
install();
|
|
120
|
+
}
|
|
228
121
|
};
|
|
122
|
+
parentObserver = new MutationObserver((records) => {
|
|
123
|
+
if (records.some((record) => [...record.removedNodes].includes(root))) restore();
|
|
124
|
+
});
|
|
125
|
+
parentObserver.observe(target, { childList: true });
|
|
126
|
+
selfObserver = new MutationObserver(restore);
|
|
127
|
+
selfObserver.observe(root, {
|
|
128
|
+
attributes: true,
|
|
129
|
+
attributeFilter: [
|
|
130
|
+
"style",
|
|
131
|
+
"class",
|
|
132
|
+
"id",
|
|
133
|
+
"hidden"
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
install();
|
|
138
|
+
return () => {
|
|
139
|
+
disposed = true;
|
|
140
|
+
parentObserver?.disconnect();
|
|
141
|
+
selfObserver?.disconnect();
|
|
142
|
+
watermarkRef.current?.remove();
|
|
143
|
+
watermarkRef.current = null;
|
|
229
144
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
$[27] = image;
|
|
251
|
-
$[28] = layout;
|
|
252
|
-
$[29] = offset;
|
|
253
|
-
$[30] = rotate;
|
|
254
|
-
$[31] = width;
|
|
255
|
-
$[32] = zIndex;
|
|
256
|
-
$[33] = t14;
|
|
257
|
-
$[34] = t15;
|
|
258
|
-
} else {
|
|
259
|
-
t14 = $[33];
|
|
260
|
-
t15 = $[34];
|
|
261
|
-
}
|
|
262
|
-
useEffect(t14, t15);
|
|
263
|
-
if (fullscreen) {
|
|
264
|
-
let t16;
|
|
265
|
-
if ($[35] !== children) {
|
|
266
|
-
t16 = /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
267
|
-
$[35] = children;
|
|
268
|
-
$[36] = t16;
|
|
269
|
-
} else t16 = $[36];
|
|
270
|
-
return t16;
|
|
271
|
-
}
|
|
272
|
-
let t16;
|
|
273
|
-
if ($[37] !== className) {
|
|
274
|
-
t16 = clsx("k-watermark-container", className);
|
|
275
|
-
$[37] = className;
|
|
276
|
-
$[38] = t16;
|
|
277
|
-
} else t16 = $[38];
|
|
278
|
-
let t17;
|
|
279
|
-
if ($[39] !== style) {
|
|
280
|
-
t17 = {
|
|
145
|
+
}, [
|
|
146
|
+
content,
|
|
147
|
+
image,
|
|
148
|
+
width,
|
|
149
|
+
height,
|
|
150
|
+
rotate,
|
|
151
|
+
zIndex,
|
|
152
|
+
fullscreen,
|
|
153
|
+
antiTamper,
|
|
154
|
+
font,
|
|
155
|
+
gap,
|
|
156
|
+
offset,
|
|
157
|
+
layout
|
|
158
|
+
]);
|
|
159
|
+
if (fullscreen) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
160
|
+
return /* @__PURE__ */ jsx("div", {
|
|
161
|
+
...rest,
|
|
162
|
+
ref: containerRef,
|
|
163
|
+
className: clsx("k-watermark-container", className),
|
|
164
|
+
style: {
|
|
281
165
|
position: "relative",
|
|
282
166
|
width: "100%",
|
|
283
167
|
height: "100%",
|
|
284
168
|
...style
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
} else t17 = $[40];
|
|
289
|
-
let t18;
|
|
290
|
-
if ($[41] !== children || $[42] !== rest || $[43] !== t16 || $[44] !== t17) {
|
|
291
|
-
t18 = /* @__PURE__ */ jsx("div", {
|
|
292
|
-
...rest,
|
|
293
|
-
ref: containerRef,
|
|
294
|
-
className: t16,
|
|
295
|
-
style: t17,
|
|
296
|
-
children
|
|
297
|
-
});
|
|
298
|
-
$[41] = children;
|
|
299
|
-
$[42] = rest;
|
|
300
|
-
$[43] = t16;
|
|
301
|
-
$[44] = t17;
|
|
302
|
-
$[45] = t18;
|
|
303
|
-
} else t18 = $[45];
|
|
304
|
-
return t18;
|
|
305
|
-
}
|
|
306
|
-
function _temp2(sum, item_1) {
|
|
307
|
-
return sum + item_1;
|
|
308
|
-
}
|
|
309
|
-
function _temp(item) {
|
|
310
|
-
return typeof item === "string" ? { text: item } : item;
|
|
169
|
+
},
|
|
170
|
+
children
|
|
171
|
+
});
|
|
311
172
|
}
|
|
312
|
-
//#endregion
|
|
313
173
|
export { Watermark as default };
|