@iquji-web/web-component 0.1.9 → 0.1.10
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 +2 -0
- package/dist/index.js +31 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -107,6 +107,8 @@ export function Example() {
|
|
|
107
107
|
|
|
108
108
|
`IqujiTour` 沿用 `IqujiOverlayProvider` 和抽屉的浮层范围。每一步以 `target` 返回实际 DOM 元素,组件跟踪挂载、滚动和尺寸变化并避让窗口边缘。目标尚未出现时保留当前说明与退出入口,调用方负责等待目标和业务数据就绪。后开的模态窗口接管交互时,教程暂时隐藏,窗口关闭后恢复当前步骤。
|
|
109
109
|
|
|
110
|
+
普通目标优先在可用方向显示说明卡。目标四周都无法容纳说明卡时,卡片收进视口并隐藏指示箭头,完整保留说明、退出与操作入口;窗口尺寸或说明内容变化后重新计算位置。
|
|
111
|
+
|
|
110
112
|
```tsx
|
|
111
113
|
const name = useRef<HTMLInputElement>(null);
|
|
112
114
|
const [guiding, setGuiding] = useState(true);
|
package/dist/index.js
CHANGED
|
@@ -4109,8 +4109,10 @@ import { Popover } from "@base-ui/react/popover";
|
|
|
4109
4109
|
import { IqujiIcon as IqujiIcon15 } from "@iquji-web/web-icons";
|
|
4110
4110
|
import {
|
|
4111
4111
|
useEffect as useEffect7,
|
|
4112
|
+
useLayoutEffect,
|
|
4112
4113
|
useMemo as useMemo7,
|
|
4113
|
-
useRef as useRef12
|
|
4114
|
+
useRef as useRef12,
|
|
4115
|
+
useState as useState14
|
|
4114
4116
|
} from "react";
|
|
4115
4117
|
|
|
4116
4118
|
// src/tour-target.ts
|
|
@@ -4213,9 +4215,23 @@ function IqujiTour({
|
|
|
4213
4215
|
const topContainer = useIqujiNotificationContainer();
|
|
4214
4216
|
const active = open && (!topContainer || container === topContainer);
|
|
4215
4217
|
const target = useTourTarget(active, step.id, step.target);
|
|
4216
|
-
const card =
|
|
4218
|
+
const [card, setCard] = useState14(null);
|
|
4219
|
+
const [cardSize, setCardSize] = useState14({ width: 0, height: 0 });
|
|
4220
|
+
useLayoutEffect(() => {
|
|
4221
|
+
if (!card)
|
|
4222
|
+
return;
|
|
4223
|
+
const measure = () => {
|
|
4224
|
+
const { width, height } = card.getBoundingClientRect();
|
|
4225
|
+
setCardSize((current) => current.width === width && current.height === height ? current : { width, height });
|
|
4226
|
+
};
|
|
4227
|
+
measure();
|
|
4228
|
+
const resize = new ResizeObserver(measure);
|
|
4229
|
+
resize.observe(card);
|
|
4230
|
+
return () => resize.disconnect();
|
|
4231
|
+
}, [card]);
|
|
4232
|
+
const constrainToViewport = !target.rect || cardSize.width > 0 && cardSize.height > 0 && target.rect.top < cardSize.height + 32 && target.height - target.rect.bottom < cardSize.height + 32 && target.rect.left < cardSize.width + 32 && target.width - target.rect.right < cardSize.width + 32;
|
|
4217
4233
|
const close = () => {
|
|
4218
|
-
if (card
|
|
4234
|
+
if (card?.contains(document.activeElement)) {
|
|
4219
4235
|
const selector = "input, textarea, select, button, a[href], [tabindex]";
|
|
4220
4236
|
const field = target.element?.matches(selector) ? target.element : target.element?.querySelector(selector);
|
|
4221
4237
|
field?.focus({ preventScroll: true });
|
|
@@ -4291,9 +4307,10 @@ function IqujiTour({
|
|
|
4291
4307
|
align: "center",
|
|
4292
4308
|
sideOffset: 16,
|
|
4293
4309
|
collisionPadding: 16,
|
|
4310
|
+
sticky: constrainToViewport,
|
|
4294
4311
|
className: "iquji-tour__positioner",
|
|
4295
4312
|
children: /* @__PURE__ */ jsxs29(Popover.Popup, {
|
|
4296
|
-
ref:
|
|
4313
|
+
ref: setCard,
|
|
4297
4314
|
initialFocus: false,
|
|
4298
4315
|
finalFocus: false,
|
|
4299
4316
|
className: "iquji-tour__card",
|
|
@@ -4340,7 +4357,7 @@ function IqujiTour({
|
|
|
4340
4357
|
})
|
|
4341
4358
|
]
|
|
4342
4359
|
}),
|
|
4343
|
-
hole && /* @__PURE__ */ jsx33(Popover.Arrow, {
|
|
4360
|
+
hole && !constrainToViewport && /* @__PURE__ */ jsx33(Popover.Arrow, {
|
|
4344
4361
|
className: "iquji-tour__arrow"
|
|
4345
4362
|
})
|
|
4346
4363
|
]
|
|
@@ -4354,9 +4371,9 @@ function IqujiTour({
|
|
|
4354
4371
|
// src/workbench.tsx
|
|
4355
4372
|
import {
|
|
4356
4373
|
useId as useId15,
|
|
4357
|
-
useLayoutEffect,
|
|
4374
|
+
useLayoutEffect as useLayoutEffect2,
|
|
4358
4375
|
useRef as useRef13,
|
|
4359
|
-
useState as
|
|
4376
|
+
useState as useState15
|
|
4360
4377
|
} from "react";
|
|
4361
4378
|
import { jsx as jsx34, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
4362
4379
|
var DEFAULT_LEFT_WIDTH = 240;
|
|
@@ -4412,13 +4429,13 @@ function IqujiWorkbenchLayout({
|
|
|
4412
4429
|
const rightRef = useRef13(null);
|
|
4413
4430
|
const previousGeometry = useRef13(null);
|
|
4414
4431
|
const dragRef = useRef13(null);
|
|
4415
|
-
const [resizing, setResizing] =
|
|
4432
|
+
const [resizing, setResizing] = useState15(null);
|
|
4416
4433
|
const leftBounds = widthBounds(leftMinWidth ?? DEFAULT_LEFT_MIN, leftMaxWidth ?? DEFAULT_LEFT_MAX);
|
|
4417
4434
|
const rightBounds = widthBounds(rightMinWidth ?? DEFAULT_RIGHT_MIN, rightMaxWidth ?? DEFAULT_RIGHT_MAX);
|
|
4418
4435
|
const leftDefault = clampWidth(numberOr(defaultLeftWidth, DEFAULT_LEFT_WIDTH), leftBounds.min, leftBounds.max);
|
|
4419
4436
|
const rightDefault = clampWidth(numberOr(defaultRightWidth, DEFAULT_RIGHT_WIDTH), rightBounds.min, rightBounds.max);
|
|
4420
|
-
const [internalLeftWidth, setInternalLeftWidth] =
|
|
4421
|
-
const [internalRightWidth, setInternalRightWidth] =
|
|
4437
|
+
const [internalLeftWidth, setInternalLeftWidth] = useState15(leftDefault);
|
|
4438
|
+
const [internalRightWidth, setInternalRightWidth] = useState15(rightDefault);
|
|
4422
4439
|
const leftValue = clampWidth(numberOr(leftWidth, internalLeftWidth), leftBounds.min, leftBounds.max);
|
|
4423
4440
|
const rightValue = clampWidth(numberOr(rightWidth, internalRightWidth), rightBounds.min, rightBounds.max);
|
|
4424
4441
|
const centerMin = Math.max(1, Math.round(numberOr(centerMinWidth, DEFAULT_CENTER_MIN)));
|
|
@@ -4426,7 +4443,7 @@ function IqujiWorkbenchLayout({
|
|
|
4426
4443
|
const hasRight = right !== undefined && right !== null;
|
|
4427
4444
|
const leftVisible = hasLeft && !leftCollapsed;
|
|
4428
4445
|
const rightVisible = hasRight && !rightCollapsed;
|
|
4429
|
-
|
|
4446
|
+
useLayoutEffect2(() => {
|
|
4430
4447
|
if (!onLayoutChange) {
|
|
4431
4448
|
previousGeometry.current = null;
|
|
4432
4449
|
return;
|
|
@@ -4606,11 +4623,11 @@ function IqujiWorkbenchLayout({
|
|
|
4606
4623
|
});
|
|
4607
4624
|
}
|
|
4608
4625
|
// src/emoji-picker.tsx
|
|
4609
|
-
import { useId as useId16, useMemo as useMemo8, useRef as useRef14, useState as
|
|
4626
|
+
import { useId as useId16, useMemo as useMemo8, useRef as useRef14, useState as useState16 } from "react";
|
|
4610
4627
|
import { jsx as jsx35, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
4611
4628
|
function IqujiEmojiPicker({ value, options, onChange, label, searchLabel, emptyLabel, clearLabel, allLabel, disabled, variant = "primary" }) {
|
|
4612
|
-
const [open, setOpen] =
|
|
4613
|
-
const [category, setCategory] =
|
|
4629
|
+
const [open, setOpen] = useState16(false), [search, setSearch] = useState16("");
|
|
4630
|
+
const [category, setCategory] = useState16(null), [active, setActive] = useState16(0);
|
|
4614
4631
|
const id = useId16(), buttons = useRef14(new Map);
|
|
4615
4632
|
const categories = useMemo8(() => [...new Set(options.flatMap((option) => option.category ? [option.category] : []))], [options]);
|
|
4616
4633
|
const filtered = useMemo8(() => options.filter((option) => (!category || option.category === category) && `${option.label} ${option.keywords ?? ""} ${option.value}`.toLocaleLowerCase().includes(search.trim().toLocaleLowerCase())), [options, search, category]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iquji-web/web-component",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"react": "19.2.4"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@iquji-web/web-icons": "0.1.
|
|
28
|
-
"@iquji-web/web-theme": "0.1.
|
|
27
|
+
"@iquji-web/web-icons": "0.1.10",
|
|
28
|
+
"@iquji-web/web-theme": "0.1.10",
|
|
29
29
|
"@tanstack/react-table": "8.21.3"
|
|
30
30
|
},
|
|
31
31
|
"description": "React 通用交互组件与布局。",
|