impact-ui 4.0.6 → 4.0.7-alpha.2
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/dist/_virtual/index3.js +4 -2
- package/dist/_virtual/index4.js +3 -3
- package/dist/_virtual/index5.js +2 -4
- package/dist/components/Accordion/index.d.ts.map +1 -1
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/BottomSheet/index.d.ts.map +1 -1
- package/dist/components/BottomSheet/index.js +27 -21
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +1 -0
- package/dist/components/Chatbot/Chatbot.types.d.ts +12 -1
- package/dist/components/Chatbot/Chatbot.types.d.ts.map +1 -1
- package/dist/components/Chatbot/chatInput.d.ts.map +1 -1
- package/dist/components/Chatbot/chatInput.js +22 -4
- package/dist/components/Chatbot/chatbotModuleMenu.d.ts +1 -1
- package/dist/components/Chatbot/chatbotModuleMenu.d.ts.map +1 -1
- package/dist/components/Chatbot/chatbotModuleMenu.js +162 -186
- package/dist/components/Chatbot/conversationScreen.d.ts +1 -1
- package/dist/components/Chatbot/conversationScreen.d.ts.map +1 -1
- package/dist/components/Chatbot/conversationScreen.js +7 -3
- package/dist/components/Chatbot/customScreen.d.ts +1 -1
- package/dist/components/Chatbot/customScreen.d.ts.map +1 -1
- package/dist/components/Chatbot/customScreen.js +26 -25
- package/dist/components/Chatbot/index.d.ts.map +1 -1
- package/dist/components/Chatbot/index.js +340 -242
- package/dist/components/Chatbot/newChatComponent.d.ts +1 -1
- package/dist/components/Chatbot/newChatComponent.d.ts.map +1 -1
- package/dist/components/Chatbot/newChatComponent.js +5 -2
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/Chips/index.js +1 -1
- package/dist/components/CommentsPanel/CommentsPanel.impl.d.ts +2 -6
- package/dist/components/CommentsPanel/CommentsPanel.impl.d.ts.map +1 -1
- package/dist/components/CommentsPanel/CommentsPanel.impl.js +7 -2
- package/dist/components/CommentsPanel/CommentsPanel.types.d.ts +2 -2
- package/dist/components/CommentsPanel/CommentsPanel.types.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/DateRangePicker/index.js +1 -1
- package/dist/components/FilterPanel/index.js +1 -1
- package/dist/components/Header/index.js +1 -1
- package/dist/components/HomePage/index.js +1 -1
- package/dist/components/Input/index.js +1 -1
- package/dist/components/KeyboardShortCuts/ShortcutLandingPage.js +1 -1
- package/dist/components/KeyboardShortCuts/ShortcutModal.js +1 -1
- package/dist/components/KeyboardShortCuts/allSetBox.js +1 -1
- package/dist/components/KeyboardShortCuts/index.js +1 -1
- package/dist/components/KeyboardShortCuts/tutorial.js +1 -1
- package/dist/components/Menu/IconMenuItem.d.ts.map +1 -1
- package/dist/components/Menu/IconMenuItem.js +2 -1
- package/dist/components/Menu/MenuHeaderInfo.js +1 -1
- package/dist/components/Menu/NestedMenuItem.js +2 -2
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Menu/nestedMenuItemsFromObject.js +1 -1
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/MonthPicker/index.js +1 -1
- package/dist/components/MonthRangePicker/index.js +1 -1
- package/dist/components/Notification/NotificationBody/NotificationList/NotificationList.js +1 -1
- package/dist/components/Notification/index.js +1 -1
- package/dist/components/Panel/index.js +1 -1
- package/dist/components/Prompt/index.js +1 -1
- package/dist/components/RadioButtonGroup/index.js +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Table/tableFunctions.d.ts.map +1 -1
- package/dist/components/Table/tableFunctions.js +105 -174
- package/dist/components/TableChat/components/TableChatLeftSection/TableChatChannelHeader.js +1 -1
- package/dist/components/TableOld/index.d.ts.map +1 -1
- package/dist/components/TableOld/index.js +2 -1
- package/dist/components/TableOld/tableFunctions.d.ts.map +1 -1
- package/dist/components/TableOld/tableFunctions.js +104 -173
- package/dist/components/TextArea/index.js +1 -1
- package/dist/components/common/HelperText/index.js +1 -1
- package/dist/hooks/useDraggableResizable.d.ts +104 -0
- package/dist/hooks/useDraggableResizable.d.ts.map +1 -0
- package/dist/hooks/useDraggableResizable.js +323 -0
- package/dist/hooks/useMediaQuery.d.ts +9 -0
- package/dist/hooks/useMediaQuery.d.ts.map +1 -0
- package/dist/mcp-component-registry.json +1 -1
- package/dist/node_modules/@mui/system/colorManipulator.js +2 -2
- package/dist/node_modules/react-is/index.js +1 -1
- package/dist/stories/LocaleDictionaryCollapse.d.ts +6 -0
- package/dist/stories/LocaleDictionaryCollapse.d.ts.map +1 -0
- package/dist/utils/assetBase.d.ts +1 -0
- package/dist/utils/assetBase.d.ts.map +1 -1
- package/dist/utils/assetBase.js +4 -7
- package/dist/utils/assetBaseDefault.d.ts +11 -0
- package/dist/utils/assetBaseDefault.d.ts.map +1 -0
- package/dist/utils/assetBaseDefault.js +9 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/onResize.d.ts +24 -0
- package/dist/utils/onResize.d.ts.map +1 -0
- package/dist/utils/onResize.js +28 -0
- package/package.json +4 -5
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { useState, useRef, useCallback, useEffect } from "react";
|
|
2
|
+
const RESIZE_STEP = 8;
|
|
3
|
+
const RESIZE_STEP_LARGE = 32;
|
|
4
|
+
const BOTTOM_VIEWPORT_MARGIN = 24;
|
|
5
|
+
function resolveViewportMargin(input) {
|
|
6
|
+
if (typeof input === "number") {
|
|
7
|
+
return { top: input, right: input, bottom: input, left: input };
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
top: (input == null ? void 0 : input.top) ?? 0,
|
|
11
|
+
right: (input == null ? void 0 : input.right) ?? 0,
|
|
12
|
+
bottom: (input == null ? void 0 : input.bottom) ?? 0,
|
|
13
|
+
left: (input == null ? void 0 : input.left) ?? 0
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function clampNumber(value, min, max) {
|
|
17
|
+
return Math.min(Math.max(value, min), Math.max(min, max));
|
|
18
|
+
}
|
|
19
|
+
function safeCapturePointer(target, pointerId) {
|
|
20
|
+
if (typeof target.setPointerCapture !== "function") return;
|
|
21
|
+
try {
|
|
22
|
+
target.setPointerCapture(pointerId);
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function safeReleasePointer(target, pointerId) {
|
|
27
|
+
if (typeof target.releasePointerCapture !== "function") return;
|
|
28
|
+
try {
|
|
29
|
+
target.releasePointerCapture(pointerId);
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function clampRect(rect, opts) {
|
|
34
|
+
const viewportWidth = typeof window !== "undefined" ? window.innerWidth : Infinity;
|
|
35
|
+
const viewportHeight = typeof window !== "undefined" ? window.innerHeight : Infinity;
|
|
36
|
+
const { margin } = opts;
|
|
37
|
+
const boundsWidth = viewportWidth - margin.left - margin.right;
|
|
38
|
+
const boundsHeight = viewportHeight - margin.top - margin.bottom;
|
|
39
|
+
const width = clampNumber(rect.width, opts.minWidth, Math.min(opts.maxWidth, boundsWidth));
|
|
40
|
+
const height = clampNumber(rect.height, opts.minHeight, Math.min(opts.maxHeight, boundsHeight));
|
|
41
|
+
const x = clampNumber(
|
|
42
|
+
rect.x,
|
|
43
|
+
margin.left,
|
|
44
|
+
Math.max(margin.left, viewportWidth - margin.right - width)
|
|
45
|
+
);
|
|
46
|
+
const y = clampNumber(
|
|
47
|
+
rect.y,
|
|
48
|
+
margin.top,
|
|
49
|
+
Math.max(margin.top, viewportHeight - margin.bottom - height)
|
|
50
|
+
);
|
|
51
|
+
return { x, y, width, height };
|
|
52
|
+
}
|
|
53
|
+
function useDraggableResizable({
|
|
54
|
+
initialRect,
|
|
55
|
+
minWidth = 320,
|
|
56
|
+
minHeight = 320,
|
|
57
|
+
maxWidth = Infinity,
|
|
58
|
+
maxHeight = Infinity,
|
|
59
|
+
viewportMargin,
|
|
60
|
+
disabled = false,
|
|
61
|
+
onChange,
|
|
62
|
+
onDragEnd,
|
|
63
|
+
onResizeEnd
|
|
64
|
+
}) {
|
|
65
|
+
const [rect, setRectState] = useState(initialRect);
|
|
66
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
67
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
68
|
+
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
69
|
+
const rectRef = useRef(rect);
|
|
70
|
+
rectRef.current = rect;
|
|
71
|
+
const savedRectRef = useRef(null);
|
|
72
|
+
const rafRef = useRef(null);
|
|
73
|
+
const pendingRectRef = useRef(null);
|
|
74
|
+
const cleanupRef = useRef(null);
|
|
75
|
+
const margin = resolveViewportMargin(viewportMargin);
|
|
76
|
+
const limits = { minWidth, minHeight, maxWidth, maxHeight, margin };
|
|
77
|
+
const { top: marginTop, right: marginRight, bottom: marginBottom, left: marginLeft } = margin;
|
|
78
|
+
const commitRect = useCallback(
|
|
79
|
+
(next) => {
|
|
80
|
+
const clamped = clampRect(next, limits);
|
|
81
|
+
pendingRectRef.current = clamped;
|
|
82
|
+
if (rafRef.current == null) {
|
|
83
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
84
|
+
rafRef.current = null;
|
|
85
|
+
if (pendingRectRef.current) {
|
|
86
|
+
setRectState(pendingRectRef.current);
|
|
87
|
+
onChange == null ? void 0 : onChange(pendingRectRef.current);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
|
+
[
|
|
94
|
+
minWidth,
|
|
95
|
+
minHeight,
|
|
96
|
+
maxWidth,
|
|
97
|
+
maxHeight,
|
|
98
|
+
marginTop,
|
|
99
|
+
marginRight,
|
|
100
|
+
marginBottom,
|
|
101
|
+
marginLeft,
|
|
102
|
+
onChange
|
|
103
|
+
]
|
|
104
|
+
);
|
|
105
|
+
const setRect = useCallback(
|
|
106
|
+
(updater) => {
|
|
107
|
+
const next = typeof updater === "function" ? updater(rectRef.current) : updater;
|
|
108
|
+
const clamped = clampRect(next, limits);
|
|
109
|
+
rectRef.current = clamped;
|
|
110
|
+
setRectState(clamped);
|
|
111
|
+
onChange == null ? void 0 : onChange(clamped);
|
|
112
|
+
},
|
|
113
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
114
|
+
[
|
|
115
|
+
minWidth,
|
|
116
|
+
minHeight,
|
|
117
|
+
maxWidth,
|
|
118
|
+
maxHeight,
|
|
119
|
+
marginTop,
|
|
120
|
+
marginRight,
|
|
121
|
+
marginBottom,
|
|
122
|
+
marginLeft,
|
|
123
|
+
onChange
|
|
124
|
+
]
|
|
125
|
+
);
|
|
126
|
+
const endInteraction = useCallback(() => {
|
|
127
|
+
document.body.classList.remove("no-select");
|
|
128
|
+
const cleanup = cleanupRef.current;
|
|
129
|
+
cleanupRef.current = null;
|
|
130
|
+
cleanup == null ? void 0 : cleanup();
|
|
131
|
+
if (rafRef.current != null) {
|
|
132
|
+
cancelAnimationFrame(rafRef.current);
|
|
133
|
+
rafRef.current = null;
|
|
134
|
+
}
|
|
135
|
+
if (pendingRectRef.current) {
|
|
136
|
+
setRectState(pendingRectRef.current);
|
|
137
|
+
onChange == null ? void 0 : onChange(pendingRectRef.current);
|
|
138
|
+
}
|
|
139
|
+
}, [onChange]);
|
|
140
|
+
useEffect(
|
|
141
|
+
() => () => {
|
|
142
|
+
var _a;
|
|
143
|
+
document.body.classList.remove("no-select");
|
|
144
|
+
(_a = cleanupRef.current) == null ? void 0 : _a.call(cleanupRef);
|
|
145
|
+
if (rafRef.current != null) cancelAnimationFrame(rafRef.current);
|
|
146
|
+
},
|
|
147
|
+
[]
|
|
148
|
+
);
|
|
149
|
+
const startDrag = useCallback(
|
|
150
|
+
(e) => {
|
|
151
|
+
if (disabled) return;
|
|
152
|
+
const target = e.currentTarget;
|
|
153
|
+
const pointerId = e.pointerId;
|
|
154
|
+
const startX = e.clientX;
|
|
155
|
+
const startY = e.clientY;
|
|
156
|
+
const startRect = rectRef.current;
|
|
157
|
+
safeCapturePointer(target, pointerId);
|
|
158
|
+
document.body.classList.add("no-select");
|
|
159
|
+
setIsDragging(true);
|
|
160
|
+
const onMove = (ev) => {
|
|
161
|
+
const dx = ev.clientX - startX;
|
|
162
|
+
const dy = ev.clientY - startY;
|
|
163
|
+
commitRect({ ...startRect, x: startRect.x - 24 + dx, y: startRect.y - 24 + dy });
|
|
164
|
+
};
|
|
165
|
+
const onUp = () => {
|
|
166
|
+
safeReleasePointer(target, pointerId);
|
|
167
|
+
target.removeEventListener("pointermove", onMove);
|
|
168
|
+
target.removeEventListener("pointerup", onUp);
|
|
169
|
+
target.removeEventListener("pointercancel", onUp);
|
|
170
|
+
setIsDragging(false);
|
|
171
|
+
endInteraction();
|
|
172
|
+
onDragEnd == null ? void 0 : onDragEnd(rectRef.current);
|
|
173
|
+
};
|
|
174
|
+
target.addEventListener("pointermove", onMove);
|
|
175
|
+
target.addEventListener("pointerup", onUp);
|
|
176
|
+
target.addEventListener("pointercancel", onUp);
|
|
177
|
+
cleanupRef.current = onUp;
|
|
178
|
+
},
|
|
179
|
+
[disabled, commitRect, endInteraction, onDragEnd]
|
|
180
|
+
);
|
|
181
|
+
const startResize = useCallback(
|
|
182
|
+
(direction) => (e) => {
|
|
183
|
+
if (disabled) return;
|
|
184
|
+
e.stopPropagation();
|
|
185
|
+
const target = e.currentTarget;
|
|
186
|
+
const pointerId = e.pointerId;
|
|
187
|
+
const startX = e.clientX;
|
|
188
|
+
const startY = e.clientY;
|
|
189
|
+
const startRect = rectRef.current;
|
|
190
|
+
safeCapturePointer(target, pointerId);
|
|
191
|
+
document.body.classList.add("no-select");
|
|
192
|
+
setIsResizing(true);
|
|
193
|
+
const onMove = (ev) => {
|
|
194
|
+
const dx = ev.clientX - startX;
|
|
195
|
+
const dy = ev.clientY - startY;
|
|
196
|
+
let { x, y, width, height } = startRect;
|
|
197
|
+
if (direction.includes("e")) width = startRect.width + dx;
|
|
198
|
+
if (direction.includes("s")) height = startRect.height + dy;
|
|
199
|
+
if (direction.includes("w")) {
|
|
200
|
+
width = startRect.width - dx;
|
|
201
|
+
x = startRect.x + dx;
|
|
202
|
+
}
|
|
203
|
+
if (direction.includes("n")) {
|
|
204
|
+
height = startRect.height - dy;
|
|
205
|
+
y = startRect.y + dy;
|
|
206
|
+
}
|
|
207
|
+
commitRect({ x, y, width, height });
|
|
208
|
+
};
|
|
209
|
+
const onUp = () => {
|
|
210
|
+
safeReleasePointer(target, pointerId);
|
|
211
|
+
target.removeEventListener("pointermove", onMove);
|
|
212
|
+
target.removeEventListener("pointerup", onUp);
|
|
213
|
+
target.removeEventListener("pointercancel", onUp);
|
|
214
|
+
setIsResizing(false);
|
|
215
|
+
endInteraction();
|
|
216
|
+
onResizeEnd == null ? void 0 : onResizeEnd(rectRef.current);
|
|
217
|
+
};
|
|
218
|
+
target.addEventListener("pointermove", onMove);
|
|
219
|
+
target.addEventListener("pointerup", onUp);
|
|
220
|
+
target.addEventListener("pointercancel", onUp);
|
|
221
|
+
cleanupRef.current = onUp;
|
|
222
|
+
},
|
|
223
|
+
[disabled, commitRect, endInteraction, onResizeEnd]
|
|
224
|
+
);
|
|
225
|
+
const handleResizeKeyDown = useCallback(
|
|
226
|
+
(direction) => (e) => {
|
|
227
|
+
if (disabled) return;
|
|
228
|
+
const step = e.shiftKey ? RESIZE_STEP_LARGE : RESIZE_STEP;
|
|
229
|
+
let dx = 0;
|
|
230
|
+
let dy = 0;
|
|
231
|
+
if (e.key === "ArrowLeft") dx = -step;
|
|
232
|
+
else if (e.key === "ArrowRight") dx = step;
|
|
233
|
+
else if (e.key === "ArrowUp") dy = -step;
|
|
234
|
+
else if (e.key === "ArrowDown") dy = step;
|
|
235
|
+
else return;
|
|
236
|
+
e.preventDefault();
|
|
237
|
+
const startRect = rectRef.current;
|
|
238
|
+
let { x, y, width, height } = startRect;
|
|
239
|
+
if (direction.includes("e")) width += dx;
|
|
240
|
+
if (direction.includes("s")) height += dy;
|
|
241
|
+
if (direction.includes("w")) {
|
|
242
|
+
width -= dx;
|
|
243
|
+
x += dx;
|
|
244
|
+
}
|
|
245
|
+
if (direction.includes("n")) {
|
|
246
|
+
height -= dy;
|
|
247
|
+
y += dy;
|
|
248
|
+
}
|
|
249
|
+
setRect({ x, y, width, height });
|
|
250
|
+
onResizeEnd == null ? void 0 : onResizeEnd(rectRef.current);
|
|
251
|
+
},
|
|
252
|
+
[disabled, setRect, onResizeEnd]
|
|
253
|
+
);
|
|
254
|
+
const dragHandleProps = {
|
|
255
|
+
onPointerDown: startDrag,
|
|
256
|
+
onKeyDown: (e) => {
|
|
257
|
+
if (disabled) return;
|
|
258
|
+
const step = e.shiftKey ? RESIZE_STEP_LARGE : RESIZE_STEP;
|
|
259
|
+
let dx = 0;
|
|
260
|
+
let dy = 0;
|
|
261
|
+
if (e.key === "ArrowLeft") dx = -step;
|
|
262
|
+
else if (e.key === "ArrowRight") dx = step;
|
|
263
|
+
else if (e.key === "ArrowUp") dy = -step;
|
|
264
|
+
else if (e.key === "ArrowDown") dy = step;
|
|
265
|
+
else return;
|
|
266
|
+
e.preventDefault();
|
|
267
|
+
setRect((prev) => ({ ...prev, x: prev.x + dx, y: prev.y + dy }));
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
const getResizeHandleProps = useCallback(
|
|
271
|
+
(direction) => ({
|
|
272
|
+
onPointerDown: startResize(direction),
|
|
273
|
+
onKeyDown: handleResizeKeyDown(direction),
|
|
274
|
+
role: "separator",
|
|
275
|
+
tabIndex: 0,
|
|
276
|
+
"aria-orientation": direction === "n" || direction === "s" ? "horizontal" : "vertical"
|
|
277
|
+
}),
|
|
278
|
+
[startResize, handleResizeKeyDown]
|
|
279
|
+
);
|
|
280
|
+
const collapseTo = useCallback(
|
|
281
|
+
(size, options) => {
|
|
282
|
+
savedRectRef.current = rectRef.current;
|
|
283
|
+
setIsCollapsed(true);
|
|
284
|
+
const m = (options == null ? void 0 : options.viewportMargin) === void 0 ? { top: marginTop, right: marginRight, bottom: marginBottom, left: marginLeft } : resolveViewportMargin(options.viewportMargin);
|
|
285
|
+
const viewportWidth = typeof window !== "undefined" ? window.innerWidth : size.width;
|
|
286
|
+
const viewportHeight = typeof window !== "undefined" ? window.innerHeight : size.height;
|
|
287
|
+
const anchor = (options == null ? void 0 : options.anchor) ?? "bottom-right";
|
|
288
|
+
const x = anchor.endsWith("right") ? viewportWidth - size.width - m.right : m.left;
|
|
289
|
+
const y = anchor.startsWith("bottom") ? viewportHeight - size.height - m.bottom : m.top;
|
|
290
|
+
const clamped = clampRect(
|
|
291
|
+
{ x, y, width: size.width, height: size.height },
|
|
292
|
+
{ minWidth: size.width, minHeight: size.height, maxWidth, maxHeight, margin: m }
|
|
293
|
+
);
|
|
294
|
+
rectRef.current = clamped;
|
|
295
|
+
setRectState(clamped);
|
|
296
|
+
onChange == null ? void 0 : onChange(clamped);
|
|
297
|
+
},
|
|
298
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
299
|
+
[maxWidth, maxHeight, marginTop, marginRight, marginBottom, marginLeft, onChange]
|
|
300
|
+
);
|
|
301
|
+
const restore = useCallback(() => {
|
|
302
|
+
if (savedRectRef.current) {
|
|
303
|
+
setRect(savedRectRef.current);
|
|
304
|
+
savedRectRef.current = null;
|
|
305
|
+
}
|
|
306
|
+
setIsCollapsed(false);
|
|
307
|
+
}, [setRect]);
|
|
308
|
+
return {
|
|
309
|
+
rect,
|
|
310
|
+
isDragging,
|
|
311
|
+
isResizing,
|
|
312
|
+
isCollapsed,
|
|
313
|
+
setRect,
|
|
314
|
+
dragHandleProps,
|
|
315
|
+
getResizeHandleProps,
|
|
316
|
+
collapseTo,
|
|
317
|
+
restore
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
export {
|
|
321
|
+
BOTTOM_VIEWPORT_MARGIN,
|
|
322
|
+
useDraggableResizable
|
|
323
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subscribes to a CSS media query via `window.matchMedia` and returns whether it currently
|
|
3
|
+
* matches. Re-renders when the match state changes (e.g. the viewport crosses the threshold).
|
|
4
|
+
*
|
|
5
|
+
* @param query - A valid CSS media query string, e.g. `'(max-width: 768px)'`.
|
|
6
|
+
* @param defaultMatches - Value returned during SSR / before `window` is available. Defaults to `false`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useMediaQuery(query: string, defaultMatches?: boolean): boolean;
|
|
9
|
+
//# sourceMappingURL=useMediaQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useMediaQuery.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,UAAQ,GAAG,OAAO,CA+B5E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __exports as colorManipulator } from "../../../_virtual/colorManipulator.js";
|
|
2
2
|
import require$$0 from "@babel/runtime/helpers/interopRequireDefault";
|
|
3
|
-
import require$$1 from "../../../_virtual/
|
|
4
|
-
import require$$2 from "../../../_virtual/
|
|
3
|
+
import require$$1 from "../../../_virtual/index3.js";
|
|
4
|
+
import require$$2 from "../../../_virtual/index4.js";
|
|
5
5
|
var _interopRequireDefault = require$$0;
|
|
6
6
|
Object.defineProperty(colorManipulator, "__esModule", {
|
|
7
7
|
value: true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as reactIs } from "../../_virtual/
|
|
1
|
+
import { __module as reactIs } from "../../_virtual/index5.js";
|
|
2
2
|
import { __require as requireReactIs_production } from "./cjs/react-is.production.js";
|
|
3
3
|
import { __require as requireReactIs_development } from "./cjs/react-is.development.js";
|
|
4
4
|
if (process.env.NODE_ENV === "production") {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collapsible viewer for the shipped locale JSON files.
|
|
3
|
+
* Used by i18n.mdx so the full dictionaries don't dominate the docs page.
|
|
4
|
+
*/
|
|
5
|
+
export declare function LocaleDictionaryCollapse(): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=LocaleDictionaryCollapse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocaleDictionaryCollapse.d.ts","sourceRoot":"","sources":["../../src/stories/LocaleDictionaryCollapse.tsx"],"names":[],"mappings":"AA0BA;;;GAGG;AACH,wBAAgB,wBAAwB,4CAoBvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetBase.d.ts","sourceRoot":"","sources":["../../src/utils/assetBase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assetBase.d.ts","sourceRoot":"","sources":["../../src/utils/assetBase.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAIxD"}
|
package/dist/utils/assetBase.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return s.replace(/\/+$/, "");
|
|
4
|
-
}
|
|
1
|
+
import { resolveAssetBase } from "./assetBaseDefault.js";
|
|
2
|
+
import { DEFAULT_IMPACT_UI_ASSET_BASE } from "./assetBaseDefault.js";
|
|
5
3
|
function getAssetUrl(relativePath) {
|
|
6
|
-
const base =
|
|
7
|
-
DEFAULT_IMPACT_UI_ASSET_BASE
|
|
8
|
-
);
|
|
4
|
+
const base = resolveAssetBase();
|
|
9
5
|
const path = relativePath.replace(/^\/+/, "");
|
|
10
6
|
return `${base}/${path}`;
|
|
11
7
|
}
|
|
12
8
|
export {
|
|
9
|
+
DEFAULT_IMPACT_UI_ASSET_BASE,
|
|
13
10
|
getAssetUrl
|
|
14
11
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for the asset origin, shared by runtime code (`assetBase.ts`)
|
|
3
|
+
* and the Vite/Vitest/Storybook configs that inject `$impact-ui-asset-base` into SCSS.
|
|
4
|
+
*
|
|
5
|
+
* Must stay free of `import.meta.env` so Node-side config files can import it.
|
|
6
|
+
*/
|
|
7
|
+
/** Default prod asset origin (GCP-backed static files). Override with `VITE_IMPACT_UI_ASSET_BASE`. */
|
|
8
|
+
export declare const DEFAULT_IMPACT_UI_ASSET_BASE = "https://impact-kit.iaproducts.ai/api/v1/files/uploads/impact-ui/prod";
|
|
9
|
+
/** Returns the configured base without trailing slashes, falling back to the prod default. */
|
|
10
|
+
export declare function resolveAssetBase(fromEnv?: string): string;
|
|
11
|
+
//# sourceMappingURL=assetBaseDefault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetBaseDefault.d.ts","sourceRoot":"","sources":["../../src/utils/assetBaseDefault.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,sGAAsG;AACtG,eAAO,MAAM,4BAA4B,yEAC+B,CAAC;AAEzE,8FAA8F;AAC9F,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAIzD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const DEFAULT_IMPACT_UI_ASSET_BASE = "https://impact-kit.iaproducts.ai/api/v1/files/uploads/impact-ui/prod";
|
|
2
|
+
function resolveAssetBase(fromEnv) {
|
|
3
|
+
const base = DEFAULT_IMPACT_UI_ASSET_BASE;
|
|
4
|
+
return base.replace(/\/+$/, "");
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
DEFAULT_IMPACT_UI_ASSET_BASE,
|
|
8
|
+
resolveAssetBase
|
|
9
|
+
};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { getUserAvatarColor, DEFAULT_AVATAR_COLORS } from './avatarColor';
|
|
12
12
|
export { debounce } from './debounce';
|
|
13
|
+
export { getSize, onResize, type ElementSize } from './onResize';
|
|
13
14
|
export { toInnerHTML, type InnerHTML } from './html';
|
|
14
15
|
export { TEXT_FILTER_OPTIONS, NON_TEXT_FILTER_OPTIONS, DATE_FILTER_OPTIONS, convertToOptions, getAllowedColumns, hasDuplicateColumns, isColumnSelectionDuplicate, isViewNameUnique, toSentenceCase, type FilterOption, type ColumnOption, type ColumnDefinition, type FormFilter, type FormValues, type FilterField, type SavedView, } from './helper';
|
|
15
16
|
export { useTextOverflow } from './useTextOverflow';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAG1E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGrD,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAChB,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,GACf,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAG1E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGrD,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAChB,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,GACf,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin ResizeObserver helper for watching an element's size.
|
|
3
|
+
* Prefer this over viewport breakpoints when the thing that changes
|
|
4
|
+
* size is a specific div (e.g. the resizable chatbot panel).
|
|
5
|
+
*/
|
|
6
|
+
export interface ElementSize {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
/** Current width/height of an element. */
|
|
11
|
+
export declare function getSize(el: Element): ElementSize;
|
|
12
|
+
/**
|
|
13
|
+
* Watch an element with ResizeObserver.
|
|
14
|
+
* Fires immediately with the current size, then on every resize.
|
|
15
|
+
* Returns an unsubscribe function.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const stop = onResize(panelEl, ({ width, height }) => {
|
|
19
|
+
* console.log(width, height);
|
|
20
|
+
* });
|
|
21
|
+
* // later: stop();
|
|
22
|
+
*/
|
|
23
|
+
export declare function onResize(el: Element, callback: (size: ElementSize) => void): () => void;
|
|
24
|
+
//# sourceMappingURL=onResize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onResize.d.ts","sourceRoot":"","sources":["../../src/utils/onResize.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,0CAA0C;AAC1C,wBAAgB,OAAO,CAAC,EAAE,EAAE,OAAO,GAAG,WAAW,CAGhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAyBvF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function getSize(el) {
|
|
2
|
+
const { width, height } = el.getBoundingClientRect();
|
|
3
|
+
return { width, height };
|
|
4
|
+
}
|
|
5
|
+
function onResize(el, callback) {
|
|
6
|
+
if (typeof ResizeObserver === "undefined") {
|
|
7
|
+
callback(getSize(el));
|
|
8
|
+
return () => {
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const observer = new ResizeObserver((entries) => {
|
|
12
|
+
const entry = entries[0];
|
|
13
|
+
if (!entry) return;
|
|
14
|
+
const box = entry.borderBoxSize[0];
|
|
15
|
+
callback(
|
|
16
|
+
box ? { width: box.inlineSize, height: box.blockSize } : { width: entry.contentRect.width, height: entry.contentRect.height }
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
observer.observe(el);
|
|
20
|
+
callback(getSize(el));
|
|
21
|
+
return () => {
|
|
22
|
+
observer.disconnect();
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
getSize,
|
|
27
|
+
onResize
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "impact-ui",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7-alpha.2",
|
|
4
4
|
"description": "Impact Analytics UI library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/components/index.js",
|
|
@@ -122,11 +122,10 @@
|
|
|
122
122
|
"@mui/system": "^5.8.1",
|
|
123
123
|
"@mui/types": "^7.1.3",
|
|
124
124
|
"@mui/x-date-pickers": "^5.0.0-alpha.4",
|
|
125
|
-
"@storybook/addon-a11y": "
|
|
125
|
+
"@storybook/addon-a11y": "10.2.15",
|
|
126
126
|
"@storybook/addon-docs": "10.2.15",
|
|
127
|
-
"@storybook/addon-vitest": "
|
|
128
|
-
"@storybook/react-vite": "
|
|
129
|
-
"@storybook/test": "^8.6.15",
|
|
127
|
+
"@storybook/addon-vitest": "10.2.15",
|
|
128
|
+
"@storybook/react-vite": "10.2.15",
|
|
130
129
|
"@testing-library/jest-dom": "^6.2.0",
|
|
131
130
|
"@testing-library/react": "^12.1.2",
|
|
132
131
|
"@testing-library/user-event": "^14.6.1",
|