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
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* react-kui v3.3.0
|
|
3
|
+
* Copyright 2017-present, kui-react.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Homepage: https://react.k-ui.cn
|
|
6
|
+
* Author: Qiu / https://chuchur.com
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { clamp } from "../utils/share.js";
|
|
10
|
+
import { useEffect, useRef, useState } from "react";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
// components/gradient-picker/stops.tsx
|
|
13
|
+
var round = (value) => Math.round(value * 100) / 100;
|
|
14
|
+
var touchStart = (event) => ({
|
|
15
|
+
clientX: event.touches[0].clientX,
|
|
16
|
+
clientY: event.touches[0].clientY,
|
|
17
|
+
currentTarget: event.currentTarget,
|
|
18
|
+
preventDefault: () => event.preventDefault(),
|
|
19
|
+
stopPropagation: () => event.stopPropagation()
|
|
20
|
+
});
|
|
21
|
+
function Stops({ disabled = false, stops, selected = 0, onAdd, onMove, onRemove, onSelect, onActivate }) {
|
|
22
|
+
const laneRef = useRef(null);
|
|
23
|
+
const [removingIndex, setRemovingIndex] = useState(-1);
|
|
24
|
+
const removingRef = useRef(-1);
|
|
25
|
+
const dragRef = useRef({
|
|
26
|
+
dragging: false,
|
|
27
|
+
moved: false,
|
|
28
|
+
index: -1,
|
|
29
|
+
element: null,
|
|
30
|
+
startX: 0,
|
|
31
|
+
startY: 0,
|
|
32
|
+
min: 0,
|
|
33
|
+
max: 100
|
|
34
|
+
});
|
|
35
|
+
const cleanupRef = useRef(() => void 0);
|
|
36
|
+
const handlersRef = useRef({
|
|
37
|
+
onMove,
|
|
38
|
+
onRemove,
|
|
39
|
+
onActivate,
|
|
40
|
+
stopsLength: stops.length
|
|
41
|
+
});
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
handlersRef.current = {
|
|
44
|
+
onMove,
|
|
45
|
+
onRemove,
|
|
46
|
+
onActivate,
|
|
47
|
+
stopsLength: stops.length
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
const markRemoving = (index) => {
|
|
51
|
+
removingRef.current = index;
|
|
52
|
+
setRemovingIndex(index);
|
|
53
|
+
};
|
|
54
|
+
const stopDrag = () => {
|
|
55
|
+
dragRef.current.dragging = false;
|
|
56
|
+
dragRef.current.moved = false;
|
|
57
|
+
dragRef.current.element = null;
|
|
58
|
+
cleanupRef.current();
|
|
59
|
+
cleanupRef.current = () => void 0;
|
|
60
|
+
markRemoving(-1);
|
|
61
|
+
};
|
|
62
|
+
useEffect(() => () => cleanupRef.current(), []);
|
|
63
|
+
const [disabledState, setDisabledState] = useState(disabled);
|
|
64
|
+
if (disabledState !== disabled) {
|
|
65
|
+
setDisabledState(disabled);
|
|
66
|
+
if (disabled) setRemovingIndex(-1);
|
|
67
|
+
}
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!disabled) return;
|
|
70
|
+
dragRef.current.dragging = false;
|
|
71
|
+
dragRef.current.element = null;
|
|
72
|
+
removingRef.current = -1;
|
|
73
|
+
cleanupRef.current();
|
|
74
|
+
cleanupRef.current = () => void 0;
|
|
75
|
+
}, [disabled]);
|
|
76
|
+
const offsetAt = (clientX) => {
|
|
77
|
+
const rect = laneRef.current?.getBoundingClientRect();
|
|
78
|
+
if (!rect || !rect.width) return 0;
|
|
79
|
+
return round(clamp((clientX - rect.left) / rect.width * 100, 0, 100));
|
|
80
|
+
};
|
|
81
|
+
const beginDrag = (index_0, event, min, max, element) => {
|
|
82
|
+
cleanupRef.current();
|
|
83
|
+
dragRef.current = {
|
|
84
|
+
dragging: true,
|
|
85
|
+
moved: false,
|
|
86
|
+
index: index_0,
|
|
87
|
+
element,
|
|
88
|
+
startX: event.clientX,
|
|
89
|
+
startY: event.clientY,
|
|
90
|
+
min,
|
|
91
|
+
max
|
|
92
|
+
};
|
|
93
|
+
const move = (event_0) => {
|
|
94
|
+
const drag = dragRef.current;
|
|
95
|
+
if (!drag.dragging) return;
|
|
96
|
+
if (Math.abs(event_0.clientX - drag.startX) > 2 || Math.abs(event_0.clientY - drag.startY) > 2) drag.moved = true;
|
|
97
|
+
const offset = round(clamp(offsetAt(event_0.clientX), drag.min, drag.max));
|
|
98
|
+
handlersRef.current.onMove?.(drag.index, offset);
|
|
99
|
+
markRemoving(event_0.clientY - drag.startY > 24 && handlersRef.current.stopsLength > 2 ? drag.index : -1);
|
|
100
|
+
};
|
|
101
|
+
const touchMove = (event_1) => {
|
|
102
|
+
if (event_1.cancelable) event_1.preventDefault();
|
|
103
|
+
if (event_1.touches[0]) move(event_1.touches[0]);
|
|
104
|
+
};
|
|
105
|
+
const up = () => {
|
|
106
|
+
const { index: dragged, element: marker, moved } = dragRef.current;
|
|
107
|
+
const removing = removingRef.current >= 0;
|
|
108
|
+
const activating = !removing && !moved && marker !== null;
|
|
109
|
+
stopDrag();
|
|
110
|
+
if (removing) handlersRef.current.onRemove?.(dragged);
|
|
111
|
+
else if (activating) handlersRef.current.onActivate?.(dragged, marker);
|
|
112
|
+
};
|
|
113
|
+
cleanupRef.current = () => {
|
|
114
|
+
document.removeEventListener("mousemove", move);
|
|
115
|
+
document.removeEventListener("mouseup", up);
|
|
116
|
+
document.removeEventListener("touchmove", touchMove);
|
|
117
|
+
document.removeEventListener("touchend", up);
|
|
118
|
+
document.removeEventListener("touchcancel", stopDrag);
|
|
119
|
+
};
|
|
120
|
+
document.addEventListener("mousemove", move);
|
|
121
|
+
document.addEventListener("mouseup", up);
|
|
122
|
+
document.addEventListener("touchmove", touchMove, { passive: false });
|
|
123
|
+
document.addEventListener("touchend", up);
|
|
124
|
+
document.addEventListener("touchcancel", stopDrag);
|
|
125
|
+
};
|
|
126
|
+
const startLaneDrag = (event_2) => {
|
|
127
|
+
if (disabled) return;
|
|
128
|
+
event_2.preventDefault();
|
|
129
|
+
const offset_0 = offsetAt(event_2.clientX);
|
|
130
|
+
const near = stops.findIndex((stop) => Math.abs(stop.offset - offset_0) <= 2);
|
|
131
|
+
let index_1 = near;
|
|
132
|
+
if (near >= 0) onSelect?.(near);
|
|
133
|
+
else {
|
|
134
|
+
index_1 = stops.filter((stop_0) => stop_0.offset < offset_0).length;
|
|
135
|
+
onAdd?.(offset_0);
|
|
136
|
+
onSelect?.(index_1);
|
|
137
|
+
}
|
|
138
|
+
const previous = stops[index_1 - 1];
|
|
139
|
+
const next = near >= 0 ? stops[index_1 + 1] : stops[index_1];
|
|
140
|
+
const low = previous ? previous.offset + .1 : 0;
|
|
141
|
+
const high = next ? next.offset - .1 : 100;
|
|
142
|
+
const current = near >= 0 ? stops[index_1].offset : offset_0;
|
|
143
|
+
beginDrag(index_1, event_2, Math.min(low, current), Math.max(high, current), null);
|
|
144
|
+
};
|
|
145
|
+
const startStopDrag = (event_3, index_2) => {
|
|
146
|
+
if (disabled) return;
|
|
147
|
+
event_3.preventDefault();
|
|
148
|
+
event_3.stopPropagation();
|
|
149
|
+
onSelect?.(index_2);
|
|
150
|
+
const previous_0 = stops[index_2 - 1];
|
|
151
|
+
const next_0 = stops[index_2 + 1];
|
|
152
|
+
const low_0 = previous_0 ? previous_0.offset + .1 : 0;
|
|
153
|
+
const high_0 = next_0 ? next_0.offset - .1 : 100;
|
|
154
|
+
const current_0 = stops[index_2].offset;
|
|
155
|
+
const element_0 = event_3.currentTarget;
|
|
156
|
+
beginDrag(index_2, event_3, Math.min(low_0, current_0), Math.max(high_0, current_0), element_0);
|
|
157
|
+
};
|
|
158
|
+
const onKeydown = (event_4, index_3) => {
|
|
159
|
+
if (disabled) return;
|
|
160
|
+
const stop_1 = stops[index_3];
|
|
161
|
+
const previous_1 = stops[index_3 - 1];
|
|
162
|
+
const next_1 = stops[index_3 + 1];
|
|
163
|
+
const low_1 = previous_1 ? previous_1.offset + .1 : 0;
|
|
164
|
+
const high_1 = next_1 ? next_1.offset - .1 : 100;
|
|
165
|
+
const current_1 = stop_1.offset;
|
|
166
|
+
const lower = Math.min(low_1, current_1);
|
|
167
|
+
const upper = Math.max(high_1, current_1);
|
|
168
|
+
const step = event_4.shiftKey ? 10 : 1;
|
|
169
|
+
if (event_4.key === "ArrowLeft" || event_4.key === "ArrowRight") {
|
|
170
|
+
event_4.preventDefault();
|
|
171
|
+
const offset_1 = stop_1.offset + (event_4.key === "ArrowRight" ? step : -step);
|
|
172
|
+
onMove?.(index_3, round(clamp(offset_1, lower, upper)));
|
|
173
|
+
} else if (event_4.key === "Home" || event_4.key === "End") {
|
|
174
|
+
event_4.preventDefault();
|
|
175
|
+
onMove?.(index_3, round(event_4.key === "Home" ? lower : upper));
|
|
176
|
+
} else if ((event_4.key === "Delete" || event_4.key === "Backspace") && stops.length > 2) {
|
|
177
|
+
event_4.preventDefault();
|
|
178
|
+
onRemove?.(index_3);
|
|
179
|
+
} else if (event_4.key === "Enter" || event_4.key === " ") {
|
|
180
|
+
event_4.preventDefault();
|
|
181
|
+
onSelect?.(index_3);
|
|
182
|
+
onActivate?.(index_3, event_4.currentTarget);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
return /* @__PURE__ */ jsx("div", {
|
|
186
|
+
className: "k-gradient-picker-stops",
|
|
187
|
+
ref: laneRef,
|
|
188
|
+
onMouseDown: startLaneDrag,
|
|
189
|
+
onTouchStart: (event_5) => {
|
|
190
|
+
if (event_5.touches.length === 1) startLaneDrag(touchStart(event_5));
|
|
191
|
+
},
|
|
192
|
+
children: stops.map((stop_2, index_4) => /* @__PURE__ */ jsx("span", {
|
|
193
|
+
className: [
|
|
194
|
+
"k-gradient-picker-stop",
|
|
195
|
+
index_4 === selected && "k-gradient-picker-stop-active",
|
|
196
|
+
index_4 === removingIndex && "k-gradient-picker-stop-removing"
|
|
197
|
+
].filter(Boolean).join(" "),
|
|
198
|
+
style: { left: `${stop_2.offset}%` },
|
|
199
|
+
role: "slider",
|
|
200
|
+
tabIndex: disabled ? -1 : 0,
|
|
201
|
+
"aria-label": `Color stop ${index_4 + 1}`,
|
|
202
|
+
"aria-haspopup": "dialog",
|
|
203
|
+
"aria-valuemin": 0,
|
|
204
|
+
"aria-valuemax": 100,
|
|
205
|
+
"aria-valuenow": stop_2.offset,
|
|
206
|
+
"aria-disabled": disabled || void 0,
|
|
207
|
+
onMouseDown: (event_6) => startStopDrag(event_6, index_4),
|
|
208
|
+
onTouchStart: (event_7) => {
|
|
209
|
+
if (event_7.touches.length === 1) startStopDrag(touchStart(event_7), index_4);
|
|
210
|
+
},
|
|
211
|
+
onKeyDown: (event_8) => onKeydown(event_8, index_4),
|
|
212
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
213
|
+
className: "k-gradient-picker-stop-color",
|
|
214
|
+
style: { backgroundColor: stop_2.color }
|
|
215
|
+
})
|
|
216
|
+
}, index_4))
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
export { Stops as default };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* react-kui v3.3.0
|
|
3
|
+
* Copyright 2017-present, kui-react.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Homepage: https://react.k-ui.cn
|
|
6
|
+
* Author: Qiu / https://chuchur.com
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import Color from "color";
|
|
10
|
+
// components/gradient-picker/types.ts
|
|
11
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, Number.isFinite(value) ? value : min));
|
|
12
|
+
var round = (value) => Math.round(value * 100) / 100;
|
|
13
|
+
var clampOffset = (value) => round(clamp(value, 0, 100));
|
|
14
|
+
function createLinearGradient() {
|
|
15
|
+
return [{
|
|
16
|
+
color: "#ff0000",
|
|
17
|
+
offset: 0
|
|
18
|
+
}, {
|
|
19
|
+
color: "#0000ff",
|
|
20
|
+
offset: 100
|
|
21
|
+
}];
|
|
22
|
+
}
|
|
23
|
+
function createCornerGradient() {
|
|
24
|
+
return [
|
|
25
|
+
"#ff0000",
|
|
26
|
+
"#ffff00",
|
|
27
|
+
"#00ff00",
|
|
28
|
+
"#0000ff"
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
function formatColor(color) {
|
|
32
|
+
const instance = Color(color);
|
|
33
|
+
return (instance.alpha() < 1 ? instance.hexa() : instance.hex()).toLowerCase();
|
|
34
|
+
}
|
|
35
|
+
function mixGradientColor(from, to, ratio) {
|
|
36
|
+
const start = Color(from);
|
|
37
|
+
const end = Color(to);
|
|
38
|
+
const weight = clamp(ratio, 0, 1);
|
|
39
|
+
const alpha = start.alpha() + (end.alpha() - start.alpha()) * weight;
|
|
40
|
+
const channel = (a, b) => alpha === 0 ? 0 : Math.round((a * start.alpha() * (1 - weight) + b * end.alpha() * weight) / alpha);
|
|
41
|
+
return formatColor(Color({
|
|
42
|
+
r: channel(start.red(), end.red()),
|
|
43
|
+
g: channel(start.green(), end.green()),
|
|
44
|
+
b: channel(start.blue(), end.blue()),
|
|
45
|
+
alpha: Math.round(alpha * 1e3) / 1e3
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
function normalizeStops(stops) {
|
|
49
|
+
const list = (stops ?? []).filter((stop) => stop && typeof stop.color === "string").map((stop) => ({
|
|
50
|
+
color: formatColor(stop.color),
|
|
51
|
+
offset: clampOffset(stop.offset)
|
|
52
|
+
})).sort((a, b) => a.offset - b.offset);
|
|
53
|
+
if (list.length === 0) return createLinearGradient();
|
|
54
|
+
if (list.length === 1) {
|
|
55
|
+
const only = list[0];
|
|
56
|
+
return only.offset <= 50 ? [only, {
|
|
57
|
+
color: "#000000",
|
|
58
|
+
offset: 100
|
|
59
|
+
}] : [{
|
|
60
|
+
color: "#000000",
|
|
61
|
+
offset: 0
|
|
62
|
+
}, only];
|
|
63
|
+
}
|
|
64
|
+
return list;
|
|
65
|
+
}
|
|
66
|
+
var isColorList = (value) => value.every((item) => typeof item === "string");
|
|
67
|
+
var isStopList = (value) => value.some((item) => typeof item === "object" && item !== null);
|
|
68
|
+
/**
|
|
69
|
+
* Fill in a complete value of `type`. A value of the other shape is converted the way the panel
|
|
70
|
+
* switches: stops → corner takes the two end colors for the left and right edges; corner → stops
|
|
71
|
+
* runs the diagonal (top-left to bottom-right).
|
|
72
|
+
*/
|
|
73
|
+
function normalizeGradient(value, type = "linear") {
|
|
74
|
+
const list = Array.isArray(value) ? value : [];
|
|
75
|
+
if (type === "corner") {
|
|
76
|
+
if (list.length && isColorList(list)) {
|
|
77
|
+
const fallback = createCornerGradient();
|
|
78
|
+
const colors = list.slice(0, 4).map((color) => formatColor(color));
|
|
79
|
+
while (colors.length < 4) colors.push(fallback[colors.length]);
|
|
80
|
+
return colors;
|
|
81
|
+
}
|
|
82
|
+
if (list.length) {
|
|
83
|
+
const stops = normalizeStops(list);
|
|
84
|
+
const first = stops[0].color;
|
|
85
|
+
const last = stops[stops.length - 1].color;
|
|
86
|
+
return [
|
|
87
|
+
first,
|
|
88
|
+
last,
|
|
89
|
+
first,
|
|
90
|
+
last
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
return createCornerGradient();
|
|
94
|
+
}
|
|
95
|
+
if (list.length && isStopList(list)) return normalizeStops(list);
|
|
96
|
+
if (list.length) {
|
|
97
|
+
const colors = list;
|
|
98
|
+
return [{
|
|
99
|
+
color: formatColor(colors[0]),
|
|
100
|
+
offset: 0
|
|
101
|
+
}, {
|
|
102
|
+
color: formatColor(colors[colors.length - 1]),
|
|
103
|
+
offset: 100
|
|
104
|
+
}];
|
|
105
|
+
}
|
|
106
|
+
return createLinearGradient();
|
|
107
|
+
}
|
|
108
|
+
function gradientColorAtOffset(value, offset) {
|
|
109
|
+
const stops = value;
|
|
110
|
+
if (!stops.length) return "#000000";
|
|
111
|
+
const target = clampOffset(offset);
|
|
112
|
+
if (target <= stops[0].offset) return stops[0].color;
|
|
113
|
+
const last = stops[stops.length - 1];
|
|
114
|
+
if (target >= last.offset) return last.color;
|
|
115
|
+
for (let index = 1; index < stops.length; index++) {
|
|
116
|
+
const previous = stops[index - 1];
|
|
117
|
+
const next = stops[index];
|
|
118
|
+
if (target <= next.offset) {
|
|
119
|
+
const span = next.offset - previous.offset;
|
|
120
|
+
return mixGradientColor(previous.color, next.color, span === 0 ? 0 : (target - previous.offset) / span);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return last.color;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* CSS for the component's own preview and for demos: stops render left to right; the four-corner
|
|
127
|
+
* value has no single native CSS gradient, so the default is a layered approximation. Consumers who
|
|
128
|
+
* need another function (radial, conic, direction) build it from the value instead.
|
|
129
|
+
*/
|
|
130
|
+
function formatGradient(value) {
|
|
131
|
+
if (Array.isArray(value) && value.length && isColorList(value)) {
|
|
132
|
+
const [topLeft, topRight, bottomLeft, bottomRight] = value;
|
|
133
|
+
const fade = (color) => {
|
|
134
|
+
const instance = Color(color);
|
|
135
|
+
return `rgba(${Math.round(instance.red())}, ${Math.round(instance.green())}, ${Math.round(instance.blue())}, 0)`;
|
|
136
|
+
};
|
|
137
|
+
return [
|
|
138
|
+
`radial-gradient(at 0% 0%, ${topLeft} 0%, ${fade(topLeft)} 70%)`,
|
|
139
|
+
`radial-gradient(at 100% 0%, ${topRight} 0%, ${fade(topRight)} 70%)`,
|
|
140
|
+
`radial-gradient(at 0% 100%, ${bottomLeft} 0%, ${fade(bottomLeft)} 70%)`,
|
|
141
|
+
`radial-gradient(at 100% 100%, ${bottomRight} 0%, ${fade(bottomRight)} 70%)`,
|
|
142
|
+
`linear-gradient(135deg, ${topLeft} 0%, ${bottomRight} 100%)`
|
|
143
|
+
].join(", ");
|
|
144
|
+
}
|
|
145
|
+
return `linear-gradient(90deg, ${[...value].sort((a, b) => a.offset - b.offset).map((stop) => `${stop.color} ${round(stop.offset)}%`).join(", ")})`;
|
|
146
|
+
}
|
|
147
|
+
export { createCornerGradient, createLinearGradient, formatColor, formatGradient, gradientColorAtOffset, mixGradientColor, normalizeGradient };
|
package/es/grid/grid-item.js
CHANGED
|
@@ -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,124 +7,33 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { GridContext } from "./useBreakpoint.js";
|
|
10
|
-
import { c } from "react/compiler-runtime";
|
|
11
10
|
import clsx from "clsx";
|
|
12
11
|
import { useContext } from "react";
|
|
13
12
|
import { jsx } from "react/jsx-runtime";
|
|
14
|
-
|
|
15
|
-
function GridItem(
|
|
16
|
-
const $ = c(36);
|
|
17
|
-
let children;
|
|
18
|
-
let className;
|
|
19
|
-
let columnStart;
|
|
20
|
-
let rest;
|
|
21
|
-
let rowStart;
|
|
22
|
-
let style;
|
|
23
|
-
let t1;
|
|
24
|
-
let t2;
|
|
25
|
-
let t3;
|
|
26
|
-
if ($[0] !== t0) {
|
|
27
|
-
({span: t1, rowSpan: t2, columnStart, rowStart, suffix: t3, className, style, children, ...rest} = t0);
|
|
28
|
-
$[0] = t0;
|
|
29
|
-
$[1] = children;
|
|
30
|
-
$[2] = className;
|
|
31
|
-
$[3] = columnStart;
|
|
32
|
-
$[4] = rest;
|
|
33
|
-
$[5] = rowStart;
|
|
34
|
-
$[6] = style;
|
|
35
|
-
$[7] = t1;
|
|
36
|
-
$[8] = t2;
|
|
37
|
-
$[9] = t3;
|
|
38
|
-
} else {
|
|
39
|
-
children = $[1];
|
|
40
|
-
className = $[2];
|
|
41
|
-
columnStart = $[3];
|
|
42
|
-
rest = $[4];
|
|
43
|
-
rowStart = $[5];
|
|
44
|
-
style = $[6];
|
|
45
|
-
t1 = $[7];
|
|
46
|
-
t2 = $[8];
|
|
47
|
-
t3 = $[9];
|
|
48
|
-
}
|
|
49
|
-
const span = t1 === void 0 ? 1 : t1;
|
|
50
|
-
const rowSpan = t2 === void 0 ? 1 : t2;
|
|
51
|
-
const suffix = t3 === void 0 ? false : t3;
|
|
13
|
+
// components/grid/grid-item.tsx
|
|
14
|
+
function GridItem({ span = 1, rowSpan = 1, columnStart, rowStart, suffix = false, className, style, children, ...rest }) {
|
|
52
15
|
const context = useContext(GridContext);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} else t6 = $[18];
|
|
76
|
-
const currentColumnStart = t6;
|
|
77
|
-
let t7;
|
|
78
|
-
if ($[19] !== context || $[20] !== rowStart) {
|
|
79
|
-
t7 = context?.resolveResponsive(rowStart, 0) ?? 0;
|
|
80
|
-
$[19] = context;
|
|
81
|
-
$[20] = rowStart;
|
|
82
|
-
$[21] = t7;
|
|
83
|
-
} else t7 = $[21];
|
|
84
|
-
const currentRowStart = t7;
|
|
85
|
-
let itemStyle;
|
|
86
|
-
if ($[22] !== currentColumnStart || $[23] !== currentRowSpan || $[24] !== currentRowStart || $[25] !== currentSpan || $[26] !== style || $[27] !== suffix) {
|
|
87
|
-
itemStyle = {};
|
|
88
|
-
if (currentSpan === 0) itemStyle.display = "none";
|
|
89
|
-
else {
|
|
90
|
-
const safeSpan = Math.max(1, Math.floor(currentSpan));
|
|
91
|
-
const safeRowSpan = Math.max(1, Math.floor(currentRowSpan));
|
|
92
|
-
if (suffix) itemStyle.gridColumn = `${-safeSpan - 1} / -1`;
|
|
93
|
-
else if (currentColumnStart > 0) itemStyle.gridColumn = `${Math.floor(currentColumnStart)} / span ${safeSpan}`;
|
|
94
|
-
else if (safeSpan !== 1) itemStyle.gridColumn = `span ${safeSpan}`;
|
|
95
|
-
if (currentRowStart > 0) itemStyle.gridRow = `${Math.floor(currentRowStart)} / span ${safeRowSpan}`;
|
|
96
|
-
else if (safeRowSpan !== 1) itemStyle.gridRow = `span ${safeRowSpan}`;
|
|
97
|
-
}
|
|
98
|
-
Object.assign(itemStyle, style);
|
|
99
|
-
$[22] = currentColumnStart;
|
|
100
|
-
$[23] = currentRowSpan;
|
|
101
|
-
$[24] = currentRowStart;
|
|
102
|
-
$[25] = currentSpan;
|
|
103
|
-
$[26] = style;
|
|
104
|
-
$[27] = suffix;
|
|
105
|
-
$[28] = itemStyle;
|
|
106
|
-
} else itemStyle = $[28];
|
|
107
|
-
let t8;
|
|
108
|
-
if ($[29] !== className) {
|
|
109
|
-
t8 = clsx("k-grid-item", className);
|
|
110
|
-
$[29] = className;
|
|
111
|
-
$[30] = t8;
|
|
112
|
-
} else t8 = $[30];
|
|
113
|
-
let t9;
|
|
114
|
-
if ($[31] !== children || $[32] !== itemStyle || $[33] !== rest || $[34] !== t8) {
|
|
115
|
-
t9 = /* @__PURE__ */ jsx("div", {
|
|
116
|
-
...rest,
|
|
117
|
-
className: t8,
|
|
118
|
-
style: itemStyle,
|
|
119
|
-
children
|
|
120
|
-
});
|
|
121
|
-
$[31] = children;
|
|
122
|
-
$[32] = itemStyle;
|
|
123
|
-
$[33] = rest;
|
|
124
|
-
$[34] = t8;
|
|
125
|
-
$[35] = t9;
|
|
126
|
-
} else t9 = $[35];
|
|
127
|
-
return t9;
|
|
16
|
+
const currentSpan = context?.resolveResponsive(span, 1) ?? 1;
|
|
17
|
+
const currentRowSpan = context?.resolveResponsive(rowSpan, 1) ?? 1;
|
|
18
|
+
const currentColumnStart = context?.resolveResponsive(columnStart, 0) ?? 0;
|
|
19
|
+
const currentRowStart = context?.resolveResponsive(rowStart, 0) ?? 0;
|
|
20
|
+
const itemStyle = {};
|
|
21
|
+
if (currentSpan === 0) itemStyle.display = "none";
|
|
22
|
+
else {
|
|
23
|
+
const safeSpan = Math.max(1, Math.floor(currentSpan));
|
|
24
|
+
const safeRowSpan = Math.max(1, Math.floor(currentRowSpan));
|
|
25
|
+
if (suffix) itemStyle.gridColumn = `${-safeSpan - 1} / -1`;
|
|
26
|
+
else if (currentColumnStart > 0) itemStyle.gridColumn = `${Math.floor(currentColumnStart)} / span ${safeSpan}`;
|
|
27
|
+
else if (safeSpan !== 1) itemStyle.gridColumn = `span ${safeSpan}`;
|
|
28
|
+
if (currentRowStart > 0) itemStyle.gridRow = `${Math.floor(currentRowStart)} / span ${safeRowSpan}`;
|
|
29
|
+
else if (safeRowSpan !== 1) itemStyle.gridRow = `span ${safeRowSpan}`;
|
|
30
|
+
}
|
|
31
|
+
Object.assign(itemStyle, style);
|
|
32
|
+
return /* @__PURE__ */ jsx("div", {
|
|
33
|
+
...rest,
|
|
34
|
+
className: clsx("k-grid-item", className),
|
|
35
|
+
style: itemStyle,
|
|
36
|
+
children
|
|
37
|
+
});
|
|
128
38
|
}
|
|
129
|
-
//#endregion
|
|
130
39
|
export { GridItem as default };
|