@hypoth-ui/react 0.1.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/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/chunk-5A7SNEOH.js +1991 -0
- package/dist/client-8T-8F3H4.d.ts +1885 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +87 -0
- package/dist/index.d.ts +3068 -0
- package/dist/index.js +6804 -0
- package/package.json +68 -0
|
@@ -0,0 +1,1991 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
// src/components/button.tsx
|
|
9
|
+
import {
|
|
10
|
+
createElement,
|
|
11
|
+
forwardRef,
|
|
12
|
+
useCallback,
|
|
13
|
+
useEffect,
|
|
14
|
+
useRef
|
|
15
|
+
} from "react";
|
|
16
|
+
|
|
17
|
+
// src/primitives/responsive.ts
|
|
18
|
+
var BREAKPOINT_ORDER = [
|
|
19
|
+
"base",
|
|
20
|
+
"sm",
|
|
21
|
+
"md",
|
|
22
|
+
"lg",
|
|
23
|
+
"xl",
|
|
24
|
+
"2xl"
|
|
25
|
+
];
|
|
26
|
+
function isResponsiveObject(value) {
|
|
27
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && BREAKPOINT_ORDER.some((bp) => bp in value);
|
|
28
|
+
}
|
|
29
|
+
function resolveResponsiveValue(value, defaultValue) {
|
|
30
|
+
if (!isResponsiveObject(value)) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
for (const bp of BREAKPOINT_ORDER) {
|
|
34
|
+
if (bp in value && value[bp] !== void 0) {
|
|
35
|
+
return value[bp];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return defaultValue;
|
|
39
|
+
}
|
|
40
|
+
function generateResponsiveDataAttr(value) {
|
|
41
|
+
if (!isResponsiveObject(value)) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
const parts = [];
|
|
45
|
+
for (const bp of BREAKPOINT_ORDER) {
|
|
46
|
+
if (bp in value && value[bp] !== void 0) {
|
|
47
|
+
if (bp === "base") {
|
|
48
|
+
parts.push(value[bp]);
|
|
49
|
+
} else {
|
|
50
|
+
parts.push(`${bp}:${value[bp]}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return parts.join(" ");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/components/button.tsx
|
|
58
|
+
var Button = forwardRef((props, forwardedRef) => {
|
|
59
|
+
const {
|
|
60
|
+
variant = "primary",
|
|
61
|
+
size = "md",
|
|
62
|
+
disabled = false,
|
|
63
|
+
loading = false,
|
|
64
|
+
type = "button",
|
|
65
|
+
onClick,
|
|
66
|
+
children,
|
|
67
|
+
className,
|
|
68
|
+
...rest
|
|
69
|
+
} = props;
|
|
70
|
+
const internalRef = useRef(null);
|
|
71
|
+
const onClickRef = useRef(onClick);
|
|
72
|
+
const loadingRef = useRef(loading);
|
|
73
|
+
onClickRef.current = onClick;
|
|
74
|
+
loadingRef.current = loading;
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (typeof forwardedRef === "function") {
|
|
77
|
+
forwardedRef(internalRef.current);
|
|
78
|
+
} else if (forwardedRef) {
|
|
79
|
+
forwardedRef.current = internalRef.current;
|
|
80
|
+
}
|
|
81
|
+
}, [forwardedRef]);
|
|
82
|
+
const handleClick = useCallback((event) => {
|
|
83
|
+
if (loadingRef.current) {
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
event.stopPropagation();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
onClickRef.current?.(event);
|
|
89
|
+
}, []);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const element = internalRef.current;
|
|
92
|
+
if (!element) return;
|
|
93
|
+
element.addEventListener("click", handleClick);
|
|
94
|
+
return () => element.removeEventListener("click", handleClick);
|
|
95
|
+
}, [handleClick]);
|
|
96
|
+
const resolvedSize = resolveResponsiveValue(size, "md");
|
|
97
|
+
const isResponsive = isResponsiveObject(size);
|
|
98
|
+
const responsiveSizeAttr = isResponsive ? generateResponsiveDataAttr(size) : void 0;
|
|
99
|
+
return createElement(
|
|
100
|
+
"ds-button",
|
|
101
|
+
{
|
|
102
|
+
ref: internalRef,
|
|
103
|
+
variant,
|
|
104
|
+
size: resolvedSize,
|
|
105
|
+
disabled: disabled || void 0,
|
|
106
|
+
loading: loading || void 0,
|
|
107
|
+
type,
|
|
108
|
+
class: className,
|
|
109
|
+
// Add responsive data attribute for CSS targeting
|
|
110
|
+
"data-size-responsive": responsiveSizeAttr,
|
|
111
|
+
...rest
|
|
112
|
+
},
|
|
113
|
+
children
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
Button.displayName = "Button";
|
|
117
|
+
|
|
118
|
+
// src/components/input.tsx
|
|
119
|
+
import {
|
|
120
|
+
createElement as createElement2,
|
|
121
|
+
forwardRef as forwardRef2,
|
|
122
|
+
useCallback as useCallback2,
|
|
123
|
+
useEffect as useEffect2,
|
|
124
|
+
useRef as useRef2
|
|
125
|
+
} from "react";
|
|
126
|
+
var Input = forwardRef2((props, forwardedRef) => {
|
|
127
|
+
const {
|
|
128
|
+
type = "text",
|
|
129
|
+
size = "md",
|
|
130
|
+
name,
|
|
131
|
+
value,
|
|
132
|
+
placeholder,
|
|
133
|
+
disabled = false,
|
|
134
|
+
readOnly = false,
|
|
135
|
+
required = false,
|
|
136
|
+
error = false,
|
|
137
|
+
minLength,
|
|
138
|
+
maxLength,
|
|
139
|
+
pattern,
|
|
140
|
+
onChange,
|
|
141
|
+
onValueChange,
|
|
142
|
+
className,
|
|
143
|
+
...rest
|
|
144
|
+
} = props;
|
|
145
|
+
const internalRef = useRef2(null);
|
|
146
|
+
const onChangeRef = useRef2(onChange);
|
|
147
|
+
const onValueChangeRef = useRef2(onValueChange);
|
|
148
|
+
onChangeRef.current = onChange;
|
|
149
|
+
onValueChangeRef.current = onValueChange;
|
|
150
|
+
useEffect2(() => {
|
|
151
|
+
if (typeof forwardedRef === "function") {
|
|
152
|
+
forwardedRef(internalRef.current);
|
|
153
|
+
} else if (forwardedRef) {
|
|
154
|
+
forwardedRef.current = internalRef.current;
|
|
155
|
+
}
|
|
156
|
+
}, [forwardedRef]);
|
|
157
|
+
const handleInputEvent = useCallback2((event) => {
|
|
158
|
+
const customEvent = event;
|
|
159
|
+
onValueChangeRef.current?.(customEvent.detail.value, event);
|
|
160
|
+
}, []);
|
|
161
|
+
const handleChangeEvent = useCallback2((event) => {
|
|
162
|
+
const customEvent = event;
|
|
163
|
+
onChangeRef.current?.(customEvent.detail.value, event);
|
|
164
|
+
}, []);
|
|
165
|
+
useEffect2(() => {
|
|
166
|
+
const element = internalRef.current;
|
|
167
|
+
if (!element) return;
|
|
168
|
+
element.addEventListener("input", handleInputEvent);
|
|
169
|
+
element.addEventListener("change", handleChangeEvent);
|
|
170
|
+
return () => {
|
|
171
|
+
element.removeEventListener("input", handleInputEvent);
|
|
172
|
+
element.removeEventListener("change", handleChangeEvent);
|
|
173
|
+
};
|
|
174
|
+
}, [handleInputEvent, handleChangeEvent]);
|
|
175
|
+
const resolvedSize = resolveResponsiveValue(size, "md");
|
|
176
|
+
const isResponsive = isResponsiveObject(size);
|
|
177
|
+
const responsiveSizeAttr = isResponsive ? generateResponsiveDataAttr(size) : void 0;
|
|
178
|
+
return createElement2("ds-input", {
|
|
179
|
+
ref: internalRef,
|
|
180
|
+
type,
|
|
181
|
+
size: resolvedSize,
|
|
182
|
+
name,
|
|
183
|
+
value,
|
|
184
|
+
placeholder,
|
|
185
|
+
disabled: disabled || void 0,
|
|
186
|
+
readonly: readOnly || void 0,
|
|
187
|
+
required: required || void 0,
|
|
188
|
+
error: error || void 0,
|
|
189
|
+
minlength: minLength,
|
|
190
|
+
maxlength: maxLength,
|
|
191
|
+
pattern,
|
|
192
|
+
class: className,
|
|
193
|
+
// Add responsive data attribute for CSS targeting
|
|
194
|
+
"data-size-responsive": responsiveSizeAttr,
|
|
195
|
+
...rest
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
Input.displayName = "Input";
|
|
199
|
+
|
|
200
|
+
// src/utils/merge-props.ts
|
|
201
|
+
function composeEventHandlers(parentHandler, childHandler) {
|
|
202
|
+
return (event) => {
|
|
203
|
+
childHandler?.(event);
|
|
204
|
+
if (!("defaultPrevented" in event) || !event.defaultPrevented) {
|
|
205
|
+
parentHandler?.(event);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function mergeClassNames(...classNames) {
|
|
210
|
+
return classNames.filter(Boolean).join(" ");
|
|
211
|
+
}
|
|
212
|
+
function mergeStyles(parentStyle, childStyle) {
|
|
213
|
+
if (!parentStyle && !childStyle) return void 0;
|
|
214
|
+
if (!parentStyle) return childStyle;
|
|
215
|
+
if (!childStyle) return parentStyle;
|
|
216
|
+
return { ...parentStyle, ...childStyle };
|
|
217
|
+
}
|
|
218
|
+
function isEventHandler(propName) {
|
|
219
|
+
return /^on[A-Z]/.test(propName);
|
|
220
|
+
}
|
|
221
|
+
function mergeProps(slotProps, childProps) {
|
|
222
|
+
const result = { ...slotProps };
|
|
223
|
+
for (const key in childProps) {
|
|
224
|
+
const slotValue = slotProps[key];
|
|
225
|
+
const childValue = childProps[key];
|
|
226
|
+
if (key === "className") {
|
|
227
|
+
result[key] = mergeClassNames(
|
|
228
|
+
slotValue,
|
|
229
|
+
childValue
|
|
230
|
+
);
|
|
231
|
+
} else if (key === "style") {
|
|
232
|
+
result[key] = mergeStyles(
|
|
233
|
+
slotValue,
|
|
234
|
+
childValue
|
|
235
|
+
);
|
|
236
|
+
} else if (isEventHandler(key) && typeof slotValue === "function" && typeof childValue === "function") {
|
|
237
|
+
result[key] = composeEventHandlers(
|
|
238
|
+
slotValue,
|
|
239
|
+
childValue
|
|
240
|
+
);
|
|
241
|
+
} else if (childValue !== void 0) {
|
|
242
|
+
result[key] = childValue;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/primitives/slot.tsx
|
|
249
|
+
import {
|
|
250
|
+
Children,
|
|
251
|
+
cloneElement,
|
|
252
|
+
forwardRef as forwardRef3,
|
|
253
|
+
isValidElement,
|
|
254
|
+
useEffect as useEffect3,
|
|
255
|
+
useRef as useRef3
|
|
256
|
+
} from "react";
|
|
257
|
+
function mergeRefs(...refs) {
|
|
258
|
+
return (instance) => {
|
|
259
|
+
for (const ref of refs) {
|
|
260
|
+
if (typeof ref === "function") {
|
|
261
|
+
ref(instance);
|
|
262
|
+
} else if (ref && typeof ref === "object") {
|
|
263
|
+
ref.current = instance;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
var Slot = forwardRef3(
|
|
269
|
+
({ children, ...slotProps }, forwardedRef) => {
|
|
270
|
+
const childrenArray = Children.toArray(children);
|
|
271
|
+
const internalRef = useRef3(null);
|
|
272
|
+
const validChildren = childrenArray.filter(
|
|
273
|
+
(child2) => child2 !== null && child2 !== void 0 && typeof child2 !== "boolean"
|
|
274
|
+
);
|
|
275
|
+
if (validChildren.length === 0) {
|
|
276
|
+
throw new Error("Slot expects a single React element child");
|
|
277
|
+
}
|
|
278
|
+
if (validChildren.length > 1) {
|
|
279
|
+
throw new Error("Slot expects a single React element child, received multiple children");
|
|
280
|
+
}
|
|
281
|
+
const child = validChildren[0];
|
|
282
|
+
if (!isValidElement(child)) {
|
|
283
|
+
throw new Error(`Slot expects a single React element child, received ${typeof child}`);
|
|
284
|
+
}
|
|
285
|
+
const isCustomComponent = typeof child.type === "function" || typeof child.type === "object";
|
|
286
|
+
useEffect3(() => {
|
|
287
|
+
if (process.env.NODE_ENV !== "production" && isCustomComponent && internalRef.current === null) {
|
|
288
|
+
const componentName = typeof child.type === "function" ? child.type.displayName || child.type.name || "Component" : "Component";
|
|
289
|
+
console.warn(
|
|
290
|
+
`[Slot] The child component "${componentName}" doesn't forward refs. When using asChild, ensure the child component is wrapped with React.forwardRef() and forwards the ref to its underlying DOM element. This is required for proper focus management and accessibility.`
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
}, [isCustomComponent, child.type]);
|
|
294
|
+
const childRef = child.ref;
|
|
295
|
+
const mergedProps = mergeProps(
|
|
296
|
+
slotProps,
|
|
297
|
+
child.props
|
|
298
|
+
);
|
|
299
|
+
return cloneElement(child, {
|
|
300
|
+
...mergedProps,
|
|
301
|
+
ref: mergeRefs(forwardedRef, childRef, internalRef)
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
Slot.displayName = "Slot";
|
|
306
|
+
|
|
307
|
+
// src/components/link.tsx
|
|
308
|
+
import { createElement as createElement3, forwardRef as forwardRef4, useCallback as useCallback3, useEffect as useEffect4, useRef as useRef4 } from "react";
|
|
309
|
+
var Link = forwardRef4((props, forwardedRef) => {
|
|
310
|
+
const {
|
|
311
|
+
href,
|
|
312
|
+
external = false,
|
|
313
|
+
variant = "default",
|
|
314
|
+
onNavigate,
|
|
315
|
+
asChild = false,
|
|
316
|
+
children,
|
|
317
|
+
className,
|
|
318
|
+
...rest
|
|
319
|
+
} = props;
|
|
320
|
+
const internalRef = useRef4(null);
|
|
321
|
+
const onNavigateRef = useRef4(onNavigate);
|
|
322
|
+
onNavigateRef.current = onNavigate;
|
|
323
|
+
useEffect4(() => {
|
|
324
|
+
if (typeof forwardedRef === "function") {
|
|
325
|
+
forwardedRef(internalRef.current);
|
|
326
|
+
} else if (forwardedRef) {
|
|
327
|
+
forwardedRef.current = internalRef.current;
|
|
328
|
+
}
|
|
329
|
+
}, [forwardedRef]);
|
|
330
|
+
const handleNavigate = useCallback3((event) => {
|
|
331
|
+
onNavigateRef.current?.(event);
|
|
332
|
+
}, []);
|
|
333
|
+
useEffect4(() => {
|
|
334
|
+
const element = internalRef.current;
|
|
335
|
+
if (!element) return;
|
|
336
|
+
element.addEventListener("ds:navigate", handleNavigate);
|
|
337
|
+
return () => element.removeEventListener("ds:navigate", handleNavigate);
|
|
338
|
+
}, [handleNavigate]);
|
|
339
|
+
if (asChild) {
|
|
340
|
+
const linkClasses = mergeClassNames(
|
|
341
|
+
"ds-link",
|
|
342
|
+
`ds-link--${variant}`,
|
|
343
|
+
external && "ds-link--external",
|
|
344
|
+
className
|
|
345
|
+
);
|
|
346
|
+
return createElement3(
|
|
347
|
+
Slot,
|
|
348
|
+
{
|
|
349
|
+
ref: internalRef,
|
|
350
|
+
className: linkClasses,
|
|
351
|
+
...rest
|
|
352
|
+
},
|
|
353
|
+
children
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
return createElement3(
|
|
357
|
+
"ds-link",
|
|
358
|
+
{
|
|
359
|
+
ref: internalRef,
|
|
360
|
+
href,
|
|
361
|
+
external: external || void 0,
|
|
362
|
+
variant,
|
|
363
|
+
class: className,
|
|
364
|
+
...rest
|
|
365
|
+
},
|
|
366
|
+
children
|
|
367
|
+
);
|
|
368
|
+
});
|
|
369
|
+
Link.displayName = "Link";
|
|
370
|
+
|
|
371
|
+
// src/components/icon.tsx
|
|
372
|
+
import { createElement as createElement4, forwardRef as forwardRef5, useEffect as useEffect5, useRef as useRef5 } from "react";
|
|
373
|
+
var Icon = forwardRef5((props, forwardedRef) => {
|
|
374
|
+
const { name, size = "md", label, color, className, ...rest } = props;
|
|
375
|
+
const internalRef = useRef5(null);
|
|
376
|
+
useEffect5(() => {
|
|
377
|
+
if (typeof forwardedRef === "function") {
|
|
378
|
+
forwardedRef(internalRef.current);
|
|
379
|
+
} else if (forwardedRef) {
|
|
380
|
+
forwardedRef.current = internalRef.current;
|
|
381
|
+
}
|
|
382
|
+
}, [forwardedRef]);
|
|
383
|
+
const resolvedSize = resolveResponsiveValue(size, "md");
|
|
384
|
+
const isResponsive = isResponsiveObject(size);
|
|
385
|
+
const responsiveSizeAttr = isResponsive ? generateResponsiveDataAttr(size) : void 0;
|
|
386
|
+
return createElement4("ds-icon", {
|
|
387
|
+
ref: internalRef,
|
|
388
|
+
name,
|
|
389
|
+
size: resolvedSize,
|
|
390
|
+
label: label || void 0,
|
|
391
|
+
color: color || void 0,
|
|
392
|
+
class: className,
|
|
393
|
+
// Add responsive data attribute for CSS targeting
|
|
394
|
+
"data-size-responsive": responsiveSizeAttr,
|
|
395
|
+
...rest
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
Icon.displayName = "Icon";
|
|
399
|
+
|
|
400
|
+
// src/components/spinner.tsx
|
|
401
|
+
import { createElement as createElement5, forwardRef as forwardRef6, useEffect as useEffect6, useRef as useRef6 } from "react";
|
|
402
|
+
var Spinner = forwardRef6((props, forwardedRef) => {
|
|
403
|
+
const { size = "md", label = "Loading", className, ...rest } = props;
|
|
404
|
+
const internalRef = useRef6(null);
|
|
405
|
+
useEffect6(() => {
|
|
406
|
+
if (typeof forwardedRef === "function") {
|
|
407
|
+
forwardedRef(internalRef.current);
|
|
408
|
+
} else if (forwardedRef) {
|
|
409
|
+
forwardedRef.current = internalRef.current;
|
|
410
|
+
}
|
|
411
|
+
}, [forwardedRef]);
|
|
412
|
+
const resolvedSize = resolveResponsiveValue(size, "md");
|
|
413
|
+
const isResponsive = isResponsiveObject(size);
|
|
414
|
+
const responsiveSizeAttr = isResponsive ? generateResponsiveDataAttr(size) : void 0;
|
|
415
|
+
return createElement5("ds-spinner", {
|
|
416
|
+
ref: internalRef,
|
|
417
|
+
size: resolvedSize,
|
|
418
|
+
label,
|
|
419
|
+
class: className,
|
|
420
|
+
// Add responsive data attribute for CSS targeting
|
|
421
|
+
"data-size-responsive": responsiveSizeAttr,
|
|
422
|
+
...rest
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
Spinner.displayName = "Spinner";
|
|
426
|
+
|
|
427
|
+
// src/components/visually-hidden.tsx
|
|
428
|
+
import { createElement as createElement6, forwardRef as forwardRef7, useEffect as useEffect7, useRef as useRef7 } from "react";
|
|
429
|
+
var VisuallyHidden = forwardRef7(
|
|
430
|
+
(props, forwardedRef) => {
|
|
431
|
+
const { focusable = false, children, className, ...rest } = props;
|
|
432
|
+
const internalRef = useRef7(null);
|
|
433
|
+
useEffect7(() => {
|
|
434
|
+
if (typeof forwardedRef === "function") {
|
|
435
|
+
forwardedRef(internalRef.current);
|
|
436
|
+
} else if (forwardedRef) {
|
|
437
|
+
forwardedRef.current = internalRef.current;
|
|
438
|
+
}
|
|
439
|
+
}, [forwardedRef]);
|
|
440
|
+
return createElement6(
|
|
441
|
+
"ds-visually-hidden",
|
|
442
|
+
{
|
|
443
|
+
ref: internalRef,
|
|
444
|
+
focusable: focusable || void 0,
|
|
445
|
+
class: className,
|
|
446
|
+
...rest
|
|
447
|
+
},
|
|
448
|
+
children
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
);
|
|
452
|
+
VisuallyHidden.displayName = "VisuallyHidden";
|
|
453
|
+
|
|
454
|
+
// src/components/text.tsx
|
|
455
|
+
import { createElement as createElement7, forwardRef as forwardRef8 } from "react";
|
|
456
|
+
function buildTextClasses(props) {
|
|
457
|
+
const classes = [];
|
|
458
|
+
if (props.size) {
|
|
459
|
+
classes.push(`ds-text-${props.size}`);
|
|
460
|
+
}
|
|
461
|
+
if (props.weight) {
|
|
462
|
+
classes.push(`ds-font-${props.weight}`);
|
|
463
|
+
}
|
|
464
|
+
if (props.variant && props.variant !== "default") {
|
|
465
|
+
classes.push(`ds-text-${props.variant}`);
|
|
466
|
+
}
|
|
467
|
+
if (props.truncate) {
|
|
468
|
+
classes.push("ds-truncate");
|
|
469
|
+
}
|
|
470
|
+
return classes;
|
|
471
|
+
}
|
|
472
|
+
var Text = forwardRef8((props, ref) => {
|
|
473
|
+
const {
|
|
474
|
+
asChild = false,
|
|
475
|
+
size = "md",
|
|
476
|
+
weight = "normal",
|
|
477
|
+
variant = "default",
|
|
478
|
+
truncate = false,
|
|
479
|
+
className,
|
|
480
|
+
children,
|
|
481
|
+
...rest
|
|
482
|
+
} = props;
|
|
483
|
+
const textClasses = buildTextClasses({ size, weight, variant, truncate });
|
|
484
|
+
const allClasses = mergeClassNames(...textClasses, className);
|
|
485
|
+
const Component = asChild ? Slot : "span";
|
|
486
|
+
return createElement7(
|
|
487
|
+
Component,
|
|
488
|
+
{
|
|
489
|
+
ref,
|
|
490
|
+
className: allClasses || void 0,
|
|
491
|
+
...rest
|
|
492
|
+
},
|
|
493
|
+
children
|
|
494
|
+
);
|
|
495
|
+
});
|
|
496
|
+
Text.displayName = "Text";
|
|
497
|
+
|
|
498
|
+
// src/primitives/box.tsx
|
|
499
|
+
import { createElement as createElement8, forwardRef as forwardRef9 } from "react";
|
|
500
|
+
function buildSpacingClasses(props) {
|
|
501
|
+
const classes = [];
|
|
502
|
+
if (props.p !== void 0) classes.push(`ds-p-${props.p}`);
|
|
503
|
+
if (props.px !== void 0) classes.push(`ds-px-${props.px}`);
|
|
504
|
+
if (props.py !== void 0) classes.push(`ds-py-${props.py}`);
|
|
505
|
+
if (props.pt !== void 0) classes.push(`ds-pt-${props.pt}`);
|
|
506
|
+
if (props.pr !== void 0) classes.push(`ds-pr-${props.pr}`);
|
|
507
|
+
if (props.pb !== void 0) classes.push(`ds-pb-${props.pb}`);
|
|
508
|
+
if (props.pl !== void 0) classes.push(`ds-pl-${props.pl}`);
|
|
509
|
+
if (props.m !== void 0) classes.push(`ds-m-${props.m}`);
|
|
510
|
+
if (props.mx !== void 0) classes.push(`ds-mx-${props.mx}`);
|
|
511
|
+
if (props.my !== void 0) classes.push(`ds-my-${props.my}`);
|
|
512
|
+
if (props.mt !== void 0) classes.push(`ds-mt-${props.mt}`);
|
|
513
|
+
if (props.mr !== void 0) classes.push(`ds-mr-${props.mr}`);
|
|
514
|
+
if (props.mb !== void 0) classes.push(`ds-mb-${props.mb}`);
|
|
515
|
+
if (props.ml !== void 0) classes.push(`ds-ml-${props.ml}`);
|
|
516
|
+
if (props.gap !== void 0) classes.push(`ds-gap-${props.gap}`);
|
|
517
|
+
return classes;
|
|
518
|
+
}
|
|
519
|
+
function buildLayoutClasses(props) {
|
|
520
|
+
const classes = [];
|
|
521
|
+
if (props.display) {
|
|
522
|
+
classes.push(`ds-d-${props.display}`);
|
|
523
|
+
}
|
|
524
|
+
if (props.flexDirection) {
|
|
525
|
+
const dirMap = {
|
|
526
|
+
row: "ds-flex-row",
|
|
527
|
+
"row-reverse": "ds-flex-row-reverse",
|
|
528
|
+
column: "ds-flex-col",
|
|
529
|
+
"column-reverse": "ds-flex-col-reverse"
|
|
530
|
+
};
|
|
531
|
+
classes.push(dirMap[props.flexDirection]);
|
|
532
|
+
}
|
|
533
|
+
if (props.alignItems) {
|
|
534
|
+
classes.push(`ds-items-${props.alignItems}`);
|
|
535
|
+
}
|
|
536
|
+
if (props.justifyContent) {
|
|
537
|
+
classes.push(`ds-justify-${props.justifyContent}`);
|
|
538
|
+
}
|
|
539
|
+
if (props.flexWrap) {
|
|
540
|
+
const wrapMap = {
|
|
541
|
+
wrap: "ds-flex-wrap",
|
|
542
|
+
nowrap: "ds-flex-nowrap",
|
|
543
|
+
"wrap-reverse": "ds-flex-wrap-reverse"
|
|
544
|
+
};
|
|
545
|
+
classes.push(wrapMap[props.flexWrap]);
|
|
546
|
+
}
|
|
547
|
+
if (props.flexGrow !== void 0) {
|
|
548
|
+
classes.push(props.flexGrow === 1 ? "ds-grow" : "ds-grow-0");
|
|
549
|
+
}
|
|
550
|
+
if (props.flexShrink !== void 0) {
|
|
551
|
+
classes.push(props.flexShrink === 0 ? "ds-shrink-0" : "ds-shrink");
|
|
552
|
+
}
|
|
553
|
+
return classes;
|
|
554
|
+
}
|
|
555
|
+
var Box = forwardRef9((props, ref) => {
|
|
556
|
+
const {
|
|
557
|
+
asChild = false,
|
|
558
|
+
p,
|
|
559
|
+
px,
|
|
560
|
+
py,
|
|
561
|
+
pt,
|
|
562
|
+
pr,
|
|
563
|
+
pb,
|
|
564
|
+
pl,
|
|
565
|
+
m,
|
|
566
|
+
mx,
|
|
567
|
+
my,
|
|
568
|
+
mt,
|
|
569
|
+
mr,
|
|
570
|
+
mb,
|
|
571
|
+
ml,
|
|
572
|
+
gap,
|
|
573
|
+
display,
|
|
574
|
+
flexDirection,
|
|
575
|
+
alignItems,
|
|
576
|
+
justifyContent,
|
|
577
|
+
flexWrap,
|
|
578
|
+
flexGrow,
|
|
579
|
+
flexShrink,
|
|
580
|
+
className,
|
|
581
|
+
style,
|
|
582
|
+
children,
|
|
583
|
+
...rest
|
|
584
|
+
} = props;
|
|
585
|
+
const spacingClasses = buildSpacingClasses(props);
|
|
586
|
+
const layoutClasses = buildLayoutClasses(props);
|
|
587
|
+
const allClasses = mergeClassNames(...spacingClasses, ...layoutClasses, className);
|
|
588
|
+
const Component = asChild ? Slot : "div";
|
|
589
|
+
return createElement8(
|
|
590
|
+
Component,
|
|
591
|
+
{
|
|
592
|
+
ref,
|
|
593
|
+
className: allClasses || void 0,
|
|
594
|
+
style,
|
|
595
|
+
...rest
|
|
596
|
+
},
|
|
597
|
+
children
|
|
598
|
+
);
|
|
599
|
+
});
|
|
600
|
+
Box.displayName = "Box";
|
|
601
|
+
|
|
602
|
+
// src/primitives/portal.tsx
|
|
603
|
+
import { useEffect as useEffect8, useState } from "react";
|
|
604
|
+
import { createPortal } from "react-dom";
|
|
605
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
606
|
+
function getContainer(container, containerSelector) {
|
|
607
|
+
if (typeof document === "undefined") return null;
|
|
608
|
+
if (container) return container;
|
|
609
|
+
if (containerSelector) {
|
|
610
|
+
return document.querySelector(containerSelector);
|
|
611
|
+
}
|
|
612
|
+
return document.body;
|
|
613
|
+
}
|
|
614
|
+
function Portal({
|
|
615
|
+
children,
|
|
616
|
+
container,
|
|
617
|
+
containerSelector,
|
|
618
|
+
disabled = false
|
|
619
|
+
}) {
|
|
620
|
+
const [mounted, setMounted] = useState(false);
|
|
621
|
+
useEffect8(() => {
|
|
622
|
+
setMounted(true);
|
|
623
|
+
return () => setMounted(false);
|
|
624
|
+
}, []);
|
|
625
|
+
if (disabled || !mounted) {
|
|
626
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
627
|
+
}
|
|
628
|
+
const portalContainer = getContainer(container, containerSelector);
|
|
629
|
+
if (!portalContainer) {
|
|
630
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
631
|
+
}
|
|
632
|
+
return createPortal(children, portalContainer);
|
|
633
|
+
}
|
|
634
|
+
Portal.displayName = "Portal";
|
|
635
|
+
|
|
636
|
+
// src/primitives/focus-scope.tsx
|
|
637
|
+
import { createFocusScope } from "@hypoth-ui/primitives-dom";
|
|
638
|
+
import {
|
|
639
|
+
createElement as createElement9,
|
|
640
|
+
forwardRef as forwardRef10,
|
|
641
|
+
useEffect as useEffect9,
|
|
642
|
+
useImperativeHandle,
|
|
643
|
+
useRef as useRef8
|
|
644
|
+
} from "react";
|
|
645
|
+
var FocusScope = forwardRef10(
|
|
646
|
+
({
|
|
647
|
+
children,
|
|
648
|
+
trap = true,
|
|
649
|
+
restoreFocus = true,
|
|
650
|
+
autoFocus = true,
|
|
651
|
+
initialFocus,
|
|
652
|
+
returnFocus,
|
|
653
|
+
onFocusOutside,
|
|
654
|
+
active = true,
|
|
655
|
+
className,
|
|
656
|
+
as: Component = "div"
|
|
657
|
+
}, ref) => {
|
|
658
|
+
const containerRef = useRef8(null);
|
|
659
|
+
const scopeRef = useRef8(null);
|
|
660
|
+
useImperativeHandle(ref, () => ({
|
|
661
|
+
focusFirst: () => scopeRef.current?.focusFirst(),
|
|
662
|
+
focusLast: () => scopeRef.current?.focusLast(),
|
|
663
|
+
getFocusableElements: () => scopeRef.current?.getFocusableElements() ?? []
|
|
664
|
+
}));
|
|
665
|
+
useEffect9(() => {
|
|
666
|
+
const container = containerRef.current;
|
|
667
|
+
if (!container) return;
|
|
668
|
+
const options = {
|
|
669
|
+
trap,
|
|
670
|
+
restoreFocus,
|
|
671
|
+
autoFocus,
|
|
672
|
+
initialFocus: initialFocus?.current ?? null,
|
|
673
|
+
returnFocus: returnFocus?.current ?? null,
|
|
674
|
+
onFocusOutside
|
|
675
|
+
};
|
|
676
|
+
scopeRef.current = createFocusScope(container, options);
|
|
677
|
+
if (active) {
|
|
678
|
+
scopeRef.current.activate();
|
|
679
|
+
}
|
|
680
|
+
return () => {
|
|
681
|
+
scopeRef.current?.deactivate();
|
|
682
|
+
scopeRef.current = null;
|
|
683
|
+
};
|
|
684
|
+
}, [trap, restoreFocus, autoFocus, initialFocus, returnFocus, onFocusOutside, active]);
|
|
685
|
+
useEffect9(() => {
|
|
686
|
+
if (!scopeRef.current) return;
|
|
687
|
+
if (active) {
|
|
688
|
+
scopeRef.current.activate();
|
|
689
|
+
} else {
|
|
690
|
+
scopeRef.current.deactivate();
|
|
691
|
+
}
|
|
692
|
+
}, [active]);
|
|
693
|
+
return createElement9(Component, { ref: containerRef, className }, children);
|
|
694
|
+
}
|
|
695
|
+
);
|
|
696
|
+
FocusScope.displayName = "FocusScope";
|
|
697
|
+
|
|
698
|
+
// src/primitives/client-only.tsx
|
|
699
|
+
import { useEffect as useEffect10, useState as useState2 } from "react";
|
|
700
|
+
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
701
|
+
function ClientOnly({ children, fallback = null }) {
|
|
702
|
+
const [mounted, setMounted] = useState2(false);
|
|
703
|
+
useEffect10(() => {
|
|
704
|
+
setMounted(true);
|
|
705
|
+
}, []);
|
|
706
|
+
if (!mounted) {
|
|
707
|
+
return /* @__PURE__ */ jsx2(Fragment2, { children: fallback });
|
|
708
|
+
}
|
|
709
|
+
return /* @__PURE__ */ jsx2(Fragment2, { children });
|
|
710
|
+
}
|
|
711
|
+
ClientOnly.displayName = "ClientOnly";
|
|
712
|
+
function useIsClient() {
|
|
713
|
+
const [isClient, setIsClient] = useState2(false);
|
|
714
|
+
useEffect10(() => {
|
|
715
|
+
setIsClient(true);
|
|
716
|
+
}, []);
|
|
717
|
+
return isClient;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
// src/components/alert/index.tsx
|
|
721
|
+
import { forwardRef as forwardRef11, useCallback as useCallback4 } from "react";
|
|
722
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
723
|
+
var VARIANT_ICONS = {
|
|
724
|
+
info: /* @__PURE__ */ jsx3("svg", { className: "ds-alert__icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx3(
|
|
725
|
+
"path",
|
|
726
|
+
{
|
|
727
|
+
fillRule: "evenodd",
|
|
728
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
729
|
+
clipRule: "evenodd"
|
|
730
|
+
}
|
|
731
|
+
) }),
|
|
732
|
+
success: /* @__PURE__ */ jsx3("svg", { className: "ds-alert__icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx3(
|
|
733
|
+
"path",
|
|
734
|
+
{
|
|
735
|
+
fillRule: "evenodd",
|
|
736
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
737
|
+
clipRule: "evenodd"
|
|
738
|
+
}
|
|
739
|
+
) }),
|
|
740
|
+
warning: /* @__PURE__ */ jsx3("svg", { className: "ds-alert__icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx3(
|
|
741
|
+
"path",
|
|
742
|
+
{
|
|
743
|
+
fillRule: "evenodd",
|
|
744
|
+
d: "M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z",
|
|
745
|
+
clipRule: "evenodd"
|
|
746
|
+
}
|
|
747
|
+
) }),
|
|
748
|
+
error: /* @__PURE__ */ jsx3("svg", { className: "ds-alert__icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx3(
|
|
749
|
+
"path",
|
|
750
|
+
{
|
|
751
|
+
fillRule: "evenodd",
|
|
752
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z",
|
|
753
|
+
clipRule: "evenodd"
|
|
754
|
+
}
|
|
755
|
+
) })
|
|
756
|
+
};
|
|
757
|
+
var CLOSE_ICON = /* @__PURE__ */ jsx3("svg", { className: "ds-alert__close-icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx3("path", { d: "M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" }) });
|
|
758
|
+
function getRole(variant) {
|
|
759
|
+
return variant === "error" || variant === "warning" ? "alert" : "status";
|
|
760
|
+
}
|
|
761
|
+
var Alert = forwardRef11(
|
|
762
|
+
({
|
|
763
|
+
variant = "info",
|
|
764
|
+
title,
|
|
765
|
+
closable = false,
|
|
766
|
+
hideIcon = false,
|
|
767
|
+
icon,
|
|
768
|
+
action,
|
|
769
|
+
onClose,
|
|
770
|
+
children,
|
|
771
|
+
className,
|
|
772
|
+
...restProps
|
|
773
|
+
}, ref) => {
|
|
774
|
+
const role = getRole(variant);
|
|
775
|
+
const handleClose = useCallback4(() => {
|
|
776
|
+
onClose?.();
|
|
777
|
+
}, [onClose]);
|
|
778
|
+
const handleKeyDown = useCallback4(
|
|
779
|
+
(event) => {
|
|
780
|
+
if (event.key === "Escape" && closable) {
|
|
781
|
+
handleClose();
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
[closable, handleClose]
|
|
785
|
+
);
|
|
786
|
+
const alertClassName = ["ds-alert", className].filter(Boolean).join(" ");
|
|
787
|
+
return /* @__PURE__ */ jsxs(
|
|
788
|
+
"div",
|
|
789
|
+
{
|
|
790
|
+
ref,
|
|
791
|
+
className: alertClassName,
|
|
792
|
+
role,
|
|
793
|
+
"aria-live": role === "alert" ? "assertive" : "polite",
|
|
794
|
+
"data-variant": variant,
|
|
795
|
+
"data-closable": closable || void 0,
|
|
796
|
+
onKeyDown: handleKeyDown,
|
|
797
|
+
...restProps,
|
|
798
|
+
children: [
|
|
799
|
+
!hideIcon && (icon || VARIANT_ICONS[variant]),
|
|
800
|
+
/* @__PURE__ */ jsxs("div", { className: "ds-alert__content", children: [
|
|
801
|
+
title && /* @__PURE__ */ jsx3("p", { className: "ds-alert__title", children: title }),
|
|
802
|
+
/* @__PURE__ */ jsx3("div", { className: "ds-alert__description", children }),
|
|
803
|
+
action && /* @__PURE__ */ jsx3("div", { className: "ds-alert__action", children: action })
|
|
804
|
+
] }),
|
|
805
|
+
closable && /* @__PURE__ */ jsx3(
|
|
806
|
+
"button",
|
|
807
|
+
{
|
|
808
|
+
className: "ds-alert__close",
|
|
809
|
+
type: "button",
|
|
810
|
+
"aria-label": "Dismiss alert",
|
|
811
|
+
onClick: handleClose,
|
|
812
|
+
children: CLOSE_ICON
|
|
813
|
+
}
|
|
814
|
+
)
|
|
815
|
+
]
|
|
816
|
+
}
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
);
|
|
820
|
+
Alert.displayName = "Alert";
|
|
821
|
+
|
|
822
|
+
// src/components/toast/use-toast.ts
|
|
823
|
+
import { useCallback as useCallback7, useContext } from "react";
|
|
824
|
+
|
|
825
|
+
// src/components/toast/provider.tsx
|
|
826
|
+
import { createContext, useCallback as useCallback6, useMemo, useState as useState4 } from "react";
|
|
827
|
+
|
|
828
|
+
// src/components/toast/toast.tsx
|
|
829
|
+
import { useCallback as useCallback5, useState as useState3 } from "react";
|
|
830
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
831
|
+
var VARIANT_ICONS2 = {
|
|
832
|
+
info: /* @__PURE__ */ jsx4("svg", { className: "ds-toast__icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx4(
|
|
833
|
+
"path",
|
|
834
|
+
{
|
|
835
|
+
fillRule: "evenodd",
|
|
836
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
837
|
+
clipRule: "evenodd"
|
|
838
|
+
}
|
|
839
|
+
) }),
|
|
840
|
+
success: /* @__PURE__ */ jsx4("svg", { className: "ds-toast__icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx4(
|
|
841
|
+
"path",
|
|
842
|
+
{
|
|
843
|
+
fillRule: "evenodd",
|
|
844
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
845
|
+
clipRule: "evenodd"
|
|
846
|
+
}
|
|
847
|
+
) }),
|
|
848
|
+
warning: /* @__PURE__ */ jsx4("svg", { className: "ds-toast__icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx4(
|
|
849
|
+
"path",
|
|
850
|
+
{
|
|
851
|
+
fillRule: "evenodd",
|
|
852
|
+
d: "M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z",
|
|
853
|
+
clipRule: "evenodd"
|
|
854
|
+
}
|
|
855
|
+
) }),
|
|
856
|
+
error: /* @__PURE__ */ jsx4("svg", { className: "ds-toast__icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx4(
|
|
857
|
+
"path",
|
|
858
|
+
{
|
|
859
|
+
fillRule: "evenodd",
|
|
860
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z",
|
|
861
|
+
clipRule: "evenodd"
|
|
862
|
+
}
|
|
863
|
+
) })
|
|
864
|
+
};
|
|
865
|
+
var CLOSE_ICON2 = /* @__PURE__ */ jsx4("svg", { className: "ds-toast__close-icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx4("path", { d: "M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" }) });
|
|
866
|
+
function ToastItem({ toast, onDismiss, onPause, onResume }) {
|
|
867
|
+
const [isPaused, setIsPaused] = useState3(false);
|
|
868
|
+
const handleMouseEnter = useCallback5(() => {
|
|
869
|
+
setIsPaused(true);
|
|
870
|
+
onPause();
|
|
871
|
+
}, [onPause]);
|
|
872
|
+
const handleMouseLeave = useCallback5(() => {
|
|
873
|
+
setIsPaused(false);
|
|
874
|
+
onResume();
|
|
875
|
+
}, [onResume]);
|
|
876
|
+
const handleActionClick = useCallback5(() => {
|
|
877
|
+
toast.action?.onClick();
|
|
878
|
+
onDismiss();
|
|
879
|
+
}, [toast.action, onDismiss]);
|
|
880
|
+
const variant = toast.variant ?? "info";
|
|
881
|
+
return /* @__PURE__ */ jsxs2(
|
|
882
|
+
"output",
|
|
883
|
+
{
|
|
884
|
+
className: "ds-toast",
|
|
885
|
+
"aria-live": "polite",
|
|
886
|
+
"aria-atomic": "true",
|
|
887
|
+
"data-variant": variant,
|
|
888
|
+
"data-state": toast.state,
|
|
889
|
+
onMouseEnter: handleMouseEnter,
|
|
890
|
+
onMouseLeave: handleMouseLeave,
|
|
891
|
+
children: [
|
|
892
|
+
VARIANT_ICONS2[variant],
|
|
893
|
+
/* @__PURE__ */ jsxs2("div", { className: "ds-toast__content", children: [
|
|
894
|
+
/* @__PURE__ */ jsx4("p", { className: "ds-toast__title", children: toast.title }),
|
|
895
|
+
toast.description && /* @__PURE__ */ jsx4("p", { className: "ds-toast__description", children: toast.description }),
|
|
896
|
+
toast.action && /* @__PURE__ */ jsx4("div", { className: "ds-toast__action", children: /* @__PURE__ */ jsx4(
|
|
897
|
+
"button",
|
|
898
|
+
{
|
|
899
|
+
type: "button",
|
|
900
|
+
className: "ds-button ds-button--sm ds-button--ghost",
|
|
901
|
+
onClick: handleActionClick,
|
|
902
|
+
children: toast.action.label
|
|
903
|
+
}
|
|
904
|
+
) })
|
|
905
|
+
] }),
|
|
906
|
+
/* @__PURE__ */ jsx4(
|
|
907
|
+
"button",
|
|
908
|
+
{
|
|
909
|
+
className: "ds-toast__close",
|
|
910
|
+
type: "button",
|
|
911
|
+
"aria-label": "Dismiss notification",
|
|
912
|
+
onClick: onDismiss,
|
|
913
|
+
children: CLOSE_ICON2
|
|
914
|
+
}
|
|
915
|
+
),
|
|
916
|
+
toast.duration && toast.duration > 0 && /* @__PURE__ */ jsx4("div", { className: "ds-toast__progress", children: /* @__PURE__ */ jsx4(
|
|
917
|
+
"div",
|
|
918
|
+
{
|
|
919
|
+
className: "ds-toast__progress-bar",
|
|
920
|
+
style: {
|
|
921
|
+
animation: `ds-toast-progress ${toast.duration}ms linear forwards`,
|
|
922
|
+
animationPlayState: isPaused ? "paused" : "running"
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
) })
|
|
926
|
+
]
|
|
927
|
+
}
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
ToastItem.displayName = "ToastItem";
|
|
931
|
+
|
|
932
|
+
// src/components/toast/provider.tsx
|
|
933
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
934
|
+
var ToastContext = createContext(null);
|
|
935
|
+
var toastIdCounter = 0;
|
|
936
|
+
function generateId() {
|
|
937
|
+
return `toast-${++toastIdCounter}-${Date.now()}`;
|
|
938
|
+
}
|
|
939
|
+
function ToastProvider({
|
|
940
|
+
position = "top-right",
|
|
941
|
+
max = 5,
|
|
942
|
+
duration: defaultDuration = 5e3,
|
|
943
|
+
children
|
|
944
|
+
}) {
|
|
945
|
+
const [toasts, setToasts] = useState4([]);
|
|
946
|
+
const timersRef = useMemo(() => /* @__PURE__ */ new Map(), []);
|
|
947
|
+
const show = useCallback6(
|
|
948
|
+
(options) => {
|
|
949
|
+
const id = generateId();
|
|
950
|
+
const duration = options.duration ?? defaultDuration;
|
|
951
|
+
const newToast = {
|
|
952
|
+
id,
|
|
953
|
+
title: options.title,
|
|
954
|
+
description: options.description,
|
|
955
|
+
variant: options.variant ?? "info",
|
|
956
|
+
duration,
|
|
957
|
+
action: options.action,
|
|
958
|
+
state: "entering",
|
|
959
|
+
createdAt: Date.now()
|
|
960
|
+
};
|
|
961
|
+
setToasts((prev) => {
|
|
962
|
+
const updated = [newToast, ...prev];
|
|
963
|
+
if (updated.length > max) {
|
|
964
|
+
const toRemove = updated.slice(max);
|
|
965
|
+
for (const t of toRemove) {
|
|
966
|
+
if (timersRef.has(t.id)) {
|
|
967
|
+
clearTimeout(timersRef.get(t.id));
|
|
968
|
+
timersRef.delete(t.id);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
return updated.slice(0, max);
|
|
972
|
+
}
|
|
973
|
+
return updated;
|
|
974
|
+
});
|
|
975
|
+
setTimeout(() => {
|
|
976
|
+
setToasts(
|
|
977
|
+
(prev) => prev.map((t) => t.id === id ? { ...t, state: "visible" } : t)
|
|
978
|
+
);
|
|
979
|
+
}, 200);
|
|
980
|
+
if (duration > 0) {
|
|
981
|
+
const timerId = setTimeout(() => {
|
|
982
|
+
dismiss(id);
|
|
983
|
+
}, duration);
|
|
984
|
+
timersRef.set(id, timerId);
|
|
985
|
+
}
|
|
986
|
+
return id;
|
|
987
|
+
},
|
|
988
|
+
[defaultDuration, max, timersRef]
|
|
989
|
+
);
|
|
990
|
+
const dismiss = useCallback6(
|
|
991
|
+
(id) => {
|
|
992
|
+
if (timersRef.has(id)) {
|
|
993
|
+
clearTimeout(timersRef.get(id));
|
|
994
|
+
timersRef.delete(id);
|
|
995
|
+
}
|
|
996
|
+
setToasts(
|
|
997
|
+
(prev) => prev.map(
|
|
998
|
+
(t) => t.id === id && t.state !== "exiting" && t.state !== "dismissed" ? { ...t, state: "exiting" } : t
|
|
999
|
+
)
|
|
1000
|
+
);
|
|
1001
|
+
setTimeout(() => {
|
|
1002
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
1003
|
+
}, 150);
|
|
1004
|
+
},
|
|
1005
|
+
[timersRef]
|
|
1006
|
+
);
|
|
1007
|
+
const dismissAll = useCallback6(() => {
|
|
1008
|
+
for (const toast of toasts) {
|
|
1009
|
+
dismiss(toast.id);
|
|
1010
|
+
}
|
|
1011
|
+
}, [toasts, dismiss]);
|
|
1012
|
+
const pause = useCallback6(
|
|
1013
|
+
(id) => {
|
|
1014
|
+
if (timersRef.has(id)) {
|
|
1015
|
+
clearTimeout(timersRef.get(id));
|
|
1016
|
+
timersRef.delete(id);
|
|
1017
|
+
}
|
|
1018
|
+
},
|
|
1019
|
+
[timersRef]
|
|
1020
|
+
);
|
|
1021
|
+
const resume = useCallback6(
|
|
1022
|
+
(id) => {
|
|
1023
|
+
const toast = toasts.find((t) => t.id === id);
|
|
1024
|
+
if (toast?.duration && toast.duration > 0 && toast.state === "visible") {
|
|
1025
|
+
const elapsed = Date.now() - toast.createdAt;
|
|
1026
|
+
const remaining = Math.max(toast.duration - elapsed, 1e3);
|
|
1027
|
+
const timerId = setTimeout(() => {
|
|
1028
|
+
dismiss(id);
|
|
1029
|
+
}, remaining);
|
|
1030
|
+
timersRef.set(id, timerId);
|
|
1031
|
+
}
|
|
1032
|
+
},
|
|
1033
|
+
[toasts, dismiss, timersRef]
|
|
1034
|
+
);
|
|
1035
|
+
const contextValue = useMemo(
|
|
1036
|
+
() => ({ show, dismiss, dismissAll, pause, resume }),
|
|
1037
|
+
[show, dismiss, dismissAll, pause, resume]
|
|
1038
|
+
);
|
|
1039
|
+
return /* @__PURE__ */ jsxs3(ToastContext.Provider, { value: contextValue, children: [
|
|
1040
|
+
children,
|
|
1041
|
+
/* @__PURE__ */ jsx5(Portal, { children: /* @__PURE__ */ jsx5(
|
|
1042
|
+
"section",
|
|
1043
|
+
{
|
|
1044
|
+
className: "ds-toast-viewport",
|
|
1045
|
+
"data-position": position,
|
|
1046
|
+
"aria-label": "Notifications",
|
|
1047
|
+
"aria-live": "polite",
|
|
1048
|
+
children: toasts.map((toast) => /* @__PURE__ */ jsx5(
|
|
1049
|
+
ToastItem,
|
|
1050
|
+
{
|
|
1051
|
+
toast,
|
|
1052
|
+
onDismiss: () => dismiss(toast.id),
|
|
1053
|
+
onPause: () => pause(toast.id),
|
|
1054
|
+
onResume: () => resume(toast.id)
|
|
1055
|
+
},
|
|
1056
|
+
toast.id
|
|
1057
|
+
))
|
|
1058
|
+
}
|
|
1059
|
+
) })
|
|
1060
|
+
] });
|
|
1061
|
+
}
|
|
1062
|
+
ToastProvider.displayName = "Toast.Provider";
|
|
1063
|
+
|
|
1064
|
+
// src/components/toast/use-toast.ts
|
|
1065
|
+
function useToast() {
|
|
1066
|
+
const context = useContext(ToastContext);
|
|
1067
|
+
if (!context) {
|
|
1068
|
+
throw new Error("useToast must be used within a Toast.Provider");
|
|
1069
|
+
}
|
|
1070
|
+
const toast = useCallback7(
|
|
1071
|
+
(options) => {
|
|
1072
|
+
return context.show(options);
|
|
1073
|
+
},
|
|
1074
|
+
[context]
|
|
1075
|
+
);
|
|
1076
|
+
const dismiss = useCallback7(
|
|
1077
|
+
(id) => {
|
|
1078
|
+
context.dismiss(id);
|
|
1079
|
+
},
|
|
1080
|
+
[context]
|
|
1081
|
+
);
|
|
1082
|
+
const dismissAll = useCallback7(() => {
|
|
1083
|
+
context.dismissAll();
|
|
1084
|
+
}, [context]);
|
|
1085
|
+
return { toast, dismiss, dismissAll };
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
// src/components/toast/index.tsx
|
|
1089
|
+
var Toast = {
|
|
1090
|
+
Provider: ToastProvider
|
|
1091
|
+
};
|
|
1092
|
+
|
|
1093
|
+
// src/components/progress/index.tsx
|
|
1094
|
+
import { createElement as createElement10, forwardRef as forwardRef12 } from "react";
|
|
1095
|
+
import "@hypoth-ui/wc";
|
|
1096
|
+
var Progress = forwardRef12(function Progress2({
|
|
1097
|
+
value,
|
|
1098
|
+
max = 100,
|
|
1099
|
+
variant = "linear",
|
|
1100
|
+
size = "md",
|
|
1101
|
+
label,
|
|
1102
|
+
showValue = false,
|
|
1103
|
+
className,
|
|
1104
|
+
...props
|
|
1105
|
+
}, ref) {
|
|
1106
|
+
const resolvedSize = resolveResponsiveValue(size, "md");
|
|
1107
|
+
const isResponsive = isResponsiveObject(size);
|
|
1108
|
+
const responsiveSizeAttr = isResponsive ? generateResponsiveDataAttr(size) : void 0;
|
|
1109
|
+
return createElement10("ds-progress", {
|
|
1110
|
+
ref,
|
|
1111
|
+
value,
|
|
1112
|
+
max,
|
|
1113
|
+
variant,
|
|
1114
|
+
size: resolvedSize,
|
|
1115
|
+
label,
|
|
1116
|
+
"show-value": showValue || void 0,
|
|
1117
|
+
class: className,
|
|
1118
|
+
// Add responsive data attribute for CSS targeting
|
|
1119
|
+
"data-size-responsive": responsiveSizeAttr,
|
|
1120
|
+
...props
|
|
1121
|
+
});
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1124
|
+
// src/components/avatar/avatar-group.tsx
|
|
1125
|
+
import { createElement as createElement11, forwardRef as forwardRef13 } from "react";
|
|
1126
|
+
import "@hypoth-ui/wc";
|
|
1127
|
+
var AvatarGroup = forwardRef13(function AvatarGroup2({ max = 5, size = "md", children, className, ...props }, ref) {
|
|
1128
|
+
const resolvedSize = resolveResponsiveValue(size, "md");
|
|
1129
|
+
const isResponsive = isResponsiveObject(size);
|
|
1130
|
+
const responsiveSizeAttr = isResponsive ? generateResponsiveDataAttr(size) : void 0;
|
|
1131
|
+
return createElement11(
|
|
1132
|
+
"ds-avatar-group",
|
|
1133
|
+
{
|
|
1134
|
+
ref,
|
|
1135
|
+
max,
|
|
1136
|
+
size: resolvedSize,
|
|
1137
|
+
class: className,
|
|
1138
|
+
// Add responsive data attribute for CSS targeting
|
|
1139
|
+
"data-size-responsive": responsiveSizeAttr,
|
|
1140
|
+
...props
|
|
1141
|
+
},
|
|
1142
|
+
children
|
|
1143
|
+
);
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
// src/components/avatar/avatar.tsx
|
|
1147
|
+
import { createElement as createElement12, forwardRef as forwardRef14 } from "react";
|
|
1148
|
+
import "@hypoth-ui/wc";
|
|
1149
|
+
var Avatar = forwardRef14(function Avatar2({
|
|
1150
|
+
src,
|
|
1151
|
+
alt,
|
|
1152
|
+
name,
|
|
1153
|
+
size = "md",
|
|
1154
|
+
shape = "circle",
|
|
1155
|
+
status,
|
|
1156
|
+
showStatus = false,
|
|
1157
|
+
className,
|
|
1158
|
+
...props
|
|
1159
|
+
}, ref) {
|
|
1160
|
+
const resolvedSize = resolveResponsiveValue(size, "md");
|
|
1161
|
+
const isResponsive = isResponsiveObject(size);
|
|
1162
|
+
const responsiveSizeAttr = isResponsive ? generateResponsiveDataAttr(size) : void 0;
|
|
1163
|
+
return createElement12("ds-avatar", {
|
|
1164
|
+
ref,
|
|
1165
|
+
src,
|
|
1166
|
+
alt,
|
|
1167
|
+
name,
|
|
1168
|
+
size: resolvedSize,
|
|
1169
|
+
shape,
|
|
1170
|
+
status,
|
|
1171
|
+
"show-status": showStatus || void 0,
|
|
1172
|
+
class: className,
|
|
1173
|
+
// Add responsive data attribute for CSS targeting
|
|
1174
|
+
"data-size-responsive": responsiveSizeAttr,
|
|
1175
|
+
...props
|
|
1176
|
+
});
|
|
1177
|
+
});
|
|
1178
|
+
|
|
1179
|
+
// src/components/avatar/index.tsx
|
|
1180
|
+
var Avatar3 = Object.assign(Avatar, {
|
|
1181
|
+
Group: AvatarGroup
|
|
1182
|
+
});
|
|
1183
|
+
|
|
1184
|
+
// src/components/table/body.tsx
|
|
1185
|
+
import { createElement as createElement13, forwardRef as forwardRef15 } from "react";
|
|
1186
|
+
import "@hypoth-ui/wc";
|
|
1187
|
+
var TableBody = forwardRef15(function TableBody2({ children, className, ...props }, ref) {
|
|
1188
|
+
return createElement13("ds-table-body", { ref, class: className, ...props }, children);
|
|
1189
|
+
});
|
|
1190
|
+
|
|
1191
|
+
// src/components/table/cell.tsx
|
|
1192
|
+
import { createElement as createElement14, forwardRef as forwardRef16 } from "react";
|
|
1193
|
+
import "@hypoth-ui/wc";
|
|
1194
|
+
var TableCell = forwardRef16(function TableCell2({ align = "left", colSpan = 1, rowSpan = 1, children, className, ...props }, ref) {
|
|
1195
|
+
return createElement14(
|
|
1196
|
+
"ds-table-cell",
|
|
1197
|
+
{ ref, align, colspan: colSpan, rowspan: rowSpan, class: className, ...props },
|
|
1198
|
+
children
|
|
1199
|
+
);
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
// src/components/table/head.tsx
|
|
1203
|
+
import {
|
|
1204
|
+
createElement as createElement15,
|
|
1205
|
+
forwardRef as forwardRef17,
|
|
1206
|
+
useEffect as useEffect11,
|
|
1207
|
+
useRef as useRef9
|
|
1208
|
+
} from "react";
|
|
1209
|
+
import "@hypoth-ui/wc";
|
|
1210
|
+
var TableHead = forwardRef17(function TableHead2({
|
|
1211
|
+
column,
|
|
1212
|
+
align = "left",
|
|
1213
|
+
sortable = false,
|
|
1214
|
+
sortDirection = "none",
|
|
1215
|
+
width,
|
|
1216
|
+
onSort,
|
|
1217
|
+
children,
|
|
1218
|
+
className,
|
|
1219
|
+
...props
|
|
1220
|
+
}, forwardedRef) {
|
|
1221
|
+
const internalRef = useRef9(null);
|
|
1222
|
+
useEffect11(() => {
|
|
1223
|
+
if (typeof forwardedRef === "function") {
|
|
1224
|
+
forwardedRef(internalRef.current);
|
|
1225
|
+
} else if (forwardedRef) {
|
|
1226
|
+
forwardedRef.current = internalRef.current;
|
|
1227
|
+
}
|
|
1228
|
+
}, [forwardedRef]);
|
|
1229
|
+
useEffect11(() => {
|
|
1230
|
+
const element = internalRef.current;
|
|
1231
|
+
if (!element) return;
|
|
1232
|
+
const handleSort = (e) => {
|
|
1233
|
+
const event = e;
|
|
1234
|
+
onSort?.(event.detail.column, event.detail.direction);
|
|
1235
|
+
};
|
|
1236
|
+
element.addEventListener("ds:sort", handleSort);
|
|
1237
|
+
return () => element.removeEventListener("ds:sort", handleSort);
|
|
1238
|
+
}, [onSort]);
|
|
1239
|
+
return createElement15(
|
|
1240
|
+
"ds-table-head",
|
|
1241
|
+
{
|
|
1242
|
+
ref: internalRef,
|
|
1243
|
+
column,
|
|
1244
|
+
align,
|
|
1245
|
+
sortable: sortable || void 0,
|
|
1246
|
+
"sort-direction": sortDirection,
|
|
1247
|
+
width,
|
|
1248
|
+
class: className,
|
|
1249
|
+
...props
|
|
1250
|
+
},
|
|
1251
|
+
children
|
|
1252
|
+
);
|
|
1253
|
+
});
|
|
1254
|
+
|
|
1255
|
+
// src/components/table/header.tsx
|
|
1256
|
+
import { createElement as createElement16, forwardRef as forwardRef18 } from "react";
|
|
1257
|
+
import "@hypoth-ui/wc";
|
|
1258
|
+
var TableHeader = forwardRef18(function TableHeader2({ children, className, ...props }, ref) {
|
|
1259
|
+
return createElement16("ds-table-header", { ref, class: className, ...props }, children);
|
|
1260
|
+
});
|
|
1261
|
+
|
|
1262
|
+
// src/components/table/row.tsx
|
|
1263
|
+
import { createElement as createElement17, forwardRef as forwardRef19 } from "react";
|
|
1264
|
+
import "@hypoth-ui/wc";
|
|
1265
|
+
var TableRow = forwardRef19(function TableRow2({ rowId, selected = false, children, className, ...props }, ref) {
|
|
1266
|
+
return createElement17(
|
|
1267
|
+
"ds-table-row",
|
|
1268
|
+
{ ref, "row-id": rowId, selected: selected || void 0, class: className, ...props },
|
|
1269
|
+
children
|
|
1270
|
+
);
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1273
|
+
// src/components/table/root.tsx
|
|
1274
|
+
import { createElement as createElement18, forwardRef as forwardRef20 } from "react";
|
|
1275
|
+
import "@hypoth-ui/wc";
|
|
1276
|
+
var TableRoot = forwardRef20(function TableRoot2({
|
|
1277
|
+
size = "default",
|
|
1278
|
+
striped = false,
|
|
1279
|
+
borderless = false,
|
|
1280
|
+
fixed = false,
|
|
1281
|
+
stickyHeader = false,
|
|
1282
|
+
caption,
|
|
1283
|
+
children,
|
|
1284
|
+
className,
|
|
1285
|
+
...props
|
|
1286
|
+
}, ref) {
|
|
1287
|
+
return createElement18(
|
|
1288
|
+
"ds-table",
|
|
1289
|
+
{
|
|
1290
|
+
ref,
|
|
1291
|
+
size,
|
|
1292
|
+
striped: striped || void 0,
|
|
1293
|
+
borderless: borderless || void 0,
|
|
1294
|
+
fixed: fixed || void 0,
|
|
1295
|
+
"sticky-header": stickyHeader || void 0,
|
|
1296
|
+
caption,
|
|
1297
|
+
class: className,
|
|
1298
|
+
...props
|
|
1299
|
+
},
|
|
1300
|
+
children
|
|
1301
|
+
);
|
|
1302
|
+
});
|
|
1303
|
+
|
|
1304
|
+
// src/components/table/index.tsx
|
|
1305
|
+
var Table = Object.assign(TableRoot, {
|
|
1306
|
+
Header: TableHeader,
|
|
1307
|
+
Body: TableBody,
|
|
1308
|
+
Row: TableRow,
|
|
1309
|
+
Head: TableHead,
|
|
1310
|
+
Cell: TableCell
|
|
1311
|
+
});
|
|
1312
|
+
|
|
1313
|
+
// src/components/skeleton/index.tsx
|
|
1314
|
+
import { createElement as createElement19, forwardRef as forwardRef21 } from "react";
|
|
1315
|
+
import "@hypoth-ui/wc";
|
|
1316
|
+
var Skeleton = forwardRef21(function Skeleton2({
|
|
1317
|
+
variant = "text",
|
|
1318
|
+
size,
|
|
1319
|
+
width,
|
|
1320
|
+
customWidth,
|
|
1321
|
+
customHeight,
|
|
1322
|
+
animation = "wave",
|
|
1323
|
+
label = "Loading...",
|
|
1324
|
+
className,
|
|
1325
|
+
...props
|
|
1326
|
+
}, ref) {
|
|
1327
|
+
const resolvedSize = size ? resolveResponsiveValue(size, "md") : void 0;
|
|
1328
|
+
const isResponsive = size ? isResponsiveObject(size) : false;
|
|
1329
|
+
const responsiveSizeAttr = isResponsive && size ? generateResponsiveDataAttr(size) : void 0;
|
|
1330
|
+
return createElement19("ds-skeleton", {
|
|
1331
|
+
ref,
|
|
1332
|
+
variant,
|
|
1333
|
+
size: resolvedSize,
|
|
1334
|
+
width,
|
|
1335
|
+
"custom-width": customWidth,
|
|
1336
|
+
"custom-height": customHeight,
|
|
1337
|
+
animation,
|
|
1338
|
+
label,
|
|
1339
|
+
class: className,
|
|
1340
|
+
// Add responsive data attribute for CSS targeting
|
|
1341
|
+
"data-size-responsive": responsiveSizeAttr,
|
|
1342
|
+
...props
|
|
1343
|
+
});
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
// src/components/badge/index.tsx
|
|
1347
|
+
import { createElement as createElement20, forwardRef as forwardRef22 } from "react";
|
|
1348
|
+
import "@hypoth-ui/wc";
|
|
1349
|
+
var Badge = forwardRef22(function Badge2({
|
|
1350
|
+
content,
|
|
1351
|
+
max,
|
|
1352
|
+
variant = "primary",
|
|
1353
|
+
size = "md",
|
|
1354
|
+
outline = false,
|
|
1355
|
+
dot = false,
|
|
1356
|
+
position = "top-right",
|
|
1357
|
+
pulse = false,
|
|
1358
|
+
className,
|
|
1359
|
+
...props
|
|
1360
|
+
}, ref) {
|
|
1361
|
+
const resolvedSize = resolveResponsiveValue(size, "md");
|
|
1362
|
+
const isResponsive = isResponsiveObject(size);
|
|
1363
|
+
const responsiveSizeAttr = isResponsive ? generateResponsiveDataAttr(size) : void 0;
|
|
1364
|
+
return createElement20("ds-badge", {
|
|
1365
|
+
ref,
|
|
1366
|
+
content: content?.toString() ?? "",
|
|
1367
|
+
max,
|
|
1368
|
+
variant,
|
|
1369
|
+
size: resolvedSize,
|
|
1370
|
+
outline: outline || void 0,
|
|
1371
|
+
dot: dot || void 0,
|
|
1372
|
+
position,
|
|
1373
|
+
pulse: pulse || void 0,
|
|
1374
|
+
class: className,
|
|
1375
|
+
// Add responsive data attribute for CSS targeting
|
|
1376
|
+
"data-size-responsive": responsiveSizeAttr,
|
|
1377
|
+
...props
|
|
1378
|
+
});
|
|
1379
|
+
});
|
|
1380
|
+
|
|
1381
|
+
// src/components/tag/index.tsx
|
|
1382
|
+
import {
|
|
1383
|
+
createElement as createElement21,
|
|
1384
|
+
forwardRef as forwardRef23,
|
|
1385
|
+
useEffect as useEffect12,
|
|
1386
|
+
useRef as useRef10
|
|
1387
|
+
} from "react";
|
|
1388
|
+
import "@hypoth-ui/wc";
|
|
1389
|
+
var Tag = forwardRef23(function Tag2({
|
|
1390
|
+
variant = "neutral",
|
|
1391
|
+
size = "md",
|
|
1392
|
+
solid = false,
|
|
1393
|
+
removable = false,
|
|
1394
|
+
clickable = false,
|
|
1395
|
+
disabled = false,
|
|
1396
|
+
value,
|
|
1397
|
+
onRemove,
|
|
1398
|
+
children,
|
|
1399
|
+
className,
|
|
1400
|
+
...props
|
|
1401
|
+
}, forwardedRef) {
|
|
1402
|
+
const internalRef = useRef10(null);
|
|
1403
|
+
useEffect12(() => {
|
|
1404
|
+
if (typeof forwardedRef === "function") {
|
|
1405
|
+
forwardedRef(internalRef.current);
|
|
1406
|
+
} else if (forwardedRef) {
|
|
1407
|
+
forwardedRef.current = internalRef.current;
|
|
1408
|
+
}
|
|
1409
|
+
}, [forwardedRef]);
|
|
1410
|
+
useEffect12(() => {
|
|
1411
|
+
const element = internalRef.current;
|
|
1412
|
+
if (!element) return;
|
|
1413
|
+
const handleRemove = (e) => {
|
|
1414
|
+
const event = e;
|
|
1415
|
+
onRemove?.(event.detail.value);
|
|
1416
|
+
};
|
|
1417
|
+
element.addEventListener("ds:remove", handleRemove);
|
|
1418
|
+
return () => element.removeEventListener("ds:remove", handleRemove);
|
|
1419
|
+
}, [onRemove]);
|
|
1420
|
+
const resolvedSize = resolveResponsiveValue(size, "md");
|
|
1421
|
+
const isResponsive = isResponsiveObject(size);
|
|
1422
|
+
const responsiveSizeAttr = isResponsive ? generateResponsiveDataAttr(size) : void 0;
|
|
1423
|
+
return createElement21(
|
|
1424
|
+
"ds-tag",
|
|
1425
|
+
{
|
|
1426
|
+
ref: internalRef,
|
|
1427
|
+
variant,
|
|
1428
|
+
size: resolvedSize,
|
|
1429
|
+
solid: solid || void 0,
|
|
1430
|
+
removable: removable || void 0,
|
|
1431
|
+
clickable: clickable || void 0,
|
|
1432
|
+
disabled: disabled || void 0,
|
|
1433
|
+
value,
|
|
1434
|
+
class: className,
|
|
1435
|
+
// Add responsive data attribute for CSS targeting
|
|
1436
|
+
"data-size-responsive": responsiveSizeAttr,
|
|
1437
|
+
...props
|
|
1438
|
+
},
|
|
1439
|
+
children
|
|
1440
|
+
);
|
|
1441
|
+
});
|
|
1442
|
+
|
|
1443
|
+
// src/components/tree/tree-item.tsx
|
|
1444
|
+
import {
|
|
1445
|
+
createElement as createElement22,
|
|
1446
|
+
forwardRef as forwardRef24,
|
|
1447
|
+
useEffect as useEffect13,
|
|
1448
|
+
useRef as useRef11
|
|
1449
|
+
} from "react";
|
|
1450
|
+
import "@hypoth-ui/wc";
|
|
1451
|
+
var TreeItem = forwardRef24(function TreeItem2({
|
|
1452
|
+
itemId,
|
|
1453
|
+
expanded = false,
|
|
1454
|
+
selected = false,
|
|
1455
|
+
disabled = false,
|
|
1456
|
+
onExpand,
|
|
1457
|
+
onItemSelect,
|
|
1458
|
+
onActivate,
|
|
1459
|
+
children,
|
|
1460
|
+
className,
|
|
1461
|
+
...props
|
|
1462
|
+
}, forwardedRef) {
|
|
1463
|
+
const internalRef = useRef11(null);
|
|
1464
|
+
useEffect13(() => {
|
|
1465
|
+
if (typeof forwardedRef === "function") {
|
|
1466
|
+
forwardedRef(internalRef.current);
|
|
1467
|
+
} else if (forwardedRef) {
|
|
1468
|
+
forwardedRef.current = internalRef.current;
|
|
1469
|
+
}
|
|
1470
|
+
}, [forwardedRef]);
|
|
1471
|
+
useEffect13(() => {
|
|
1472
|
+
const element = internalRef.current;
|
|
1473
|
+
if (!element) return;
|
|
1474
|
+
const handleExpand = (e) => {
|
|
1475
|
+
const event = e;
|
|
1476
|
+
onExpand?.(event.detail.itemId, event.detail.expanded);
|
|
1477
|
+
};
|
|
1478
|
+
const handleSelect = (e) => {
|
|
1479
|
+
const event = e;
|
|
1480
|
+
onItemSelect?.(event.detail.itemId, event.detail.selected);
|
|
1481
|
+
};
|
|
1482
|
+
const handleActivate = (e) => {
|
|
1483
|
+
const event = e;
|
|
1484
|
+
onActivate?.(event.detail.itemId);
|
|
1485
|
+
};
|
|
1486
|
+
element.addEventListener("ds:expand", handleExpand);
|
|
1487
|
+
element.addEventListener("ds:select", handleSelect);
|
|
1488
|
+
element.addEventListener("ds:activate", handleActivate);
|
|
1489
|
+
return () => {
|
|
1490
|
+
element.removeEventListener("ds:expand", handleExpand);
|
|
1491
|
+
element.removeEventListener("ds:select", handleSelect);
|
|
1492
|
+
element.removeEventListener("ds:activate", handleActivate);
|
|
1493
|
+
};
|
|
1494
|
+
}, [onExpand, onItemSelect, onActivate]);
|
|
1495
|
+
return createElement22(
|
|
1496
|
+
"ds-tree-item",
|
|
1497
|
+
{
|
|
1498
|
+
ref: internalRef,
|
|
1499
|
+
"item-id": itemId,
|
|
1500
|
+
expanded: expanded || void 0,
|
|
1501
|
+
selected: selected || void 0,
|
|
1502
|
+
disabled: disabled || void 0,
|
|
1503
|
+
class: className,
|
|
1504
|
+
...props
|
|
1505
|
+
},
|
|
1506
|
+
children
|
|
1507
|
+
);
|
|
1508
|
+
});
|
|
1509
|
+
|
|
1510
|
+
// src/components/tree/tree.tsx
|
|
1511
|
+
import {
|
|
1512
|
+
createElement as createElement23,
|
|
1513
|
+
forwardRef as forwardRef25,
|
|
1514
|
+
useEffect as useEffect14,
|
|
1515
|
+
useRef as useRef12
|
|
1516
|
+
} from "react";
|
|
1517
|
+
import "@hypoth-ui/wc";
|
|
1518
|
+
var TreeRoot = forwardRef25(function TreeRoot2({
|
|
1519
|
+
selectionMode = "single",
|
|
1520
|
+
size = "default",
|
|
1521
|
+
lines = false,
|
|
1522
|
+
label = "Tree",
|
|
1523
|
+
loading = false,
|
|
1524
|
+
loadingText = "Loading...",
|
|
1525
|
+
loadingNodes,
|
|
1526
|
+
onSelectionChange,
|
|
1527
|
+
children,
|
|
1528
|
+
className,
|
|
1529
|
+
...props
|
|
1530
|
+
}, forwardedRef) {
|
|
1531
|
+
const internalRef = useRef12(null);
|
|
1532
|
+
useEffect14(() => {
|
|
1533
|
+
if (typeof forwardedRef === "function") {
|
|
1534
|
+
forwardedRef(internalRef.current);
|
|
1535
|
+
} else if (forwardedRef) {
|
|
1536
|
+
forwardedRef.current = internalRef.current;
|
|
1537
|
+
}
|
|
1538
|
+
}, [forwardedRef]);
|
|
1539
|
+
useEffect14(() => {
|
|
1540
|
+
const element = internalRef.current;
|
|
1541
|
+
if (!element) return;
|
|
1542
|
+
const handleSelectionChange = (e) => {
|
|
1543
|
+
const event = e;
|
|
1544
|
+
onSelectionChange?.(event.detail.selectedItems);
|
|
1545
|
+
};
|
|
1546
|
+
element.addEventListener("ds:selection-change", handleSelectionChange);
|
|
1547
|
+
return () => element.removeEventListener("ds:selection-change", handleSelectionChange);
|
|
1548
|
+
}, [onSelectionChange]);
|
|
1549
|
+
useEffect14(() => {
|
|
1550
|
+
const element = internalRef.current;
|
|
1551
|
+
if (element && loadingNodes !== void 0) {
|
|
1552
|
+
element.loadingNodes = loadingNodes;
|
|
1553
|
+
}
|
|
1554
|
+
}, [loadingNodes]);
|
|
1555
|
+
return createElement23(
|
|
1556
|
+
"ds-tree",
|
|
1557
|
+
{
|
|
1558
|
+
ref: internalRef,
|
|
1559
|
+
"selection-mode": selectionMode,
|
|
1560
|
+
size,
|
|
1561
|
+
lines: lines || void 0,
|
|
1562
|
+
label,
|
|
1563
|
+
loading: loading || void 0,
|
|
1564
|
+
"loading-text": loadingText,
|
|
1565
|
+
class: className,
|
|
1566
|
+
...props
|
|
1567
|
+
},
|
|
1568
|
+
children
|
|
1569
|
+
);
|
|
1570
|
+
});
|
|
1571
|
+
|
|
1572
|
+
// src/components/tree/index.tsx
|
|
1573
|
+
var Tree = Object.assign(TreeRoot, {
|
|
1574
|
+
Item: TreeItem
|
|
1575
|
+
});
|
|
1576
|
+
|
|
1577
|
+
// src/components/list/list-item.tsx
|
|
1578
|
+
import {
|
|
1579
|
+
createElement as createElement24,
|
|
1580
|
+
forwardRef as forwardRef26,
|
|
1581
|
+
useEffect as useEffect15,
|
|
1582
|
+
useRef as useRef13
|
|
1583
|
+
} from "react";
|
|
1584
|
+
import "@hypoth-ui/wc";
|
|
1585
|
+
var ListItem = forwardRef26(function ListItem2({
|
|
1586
|
+
itemId,
|
|
1587
|
+
selected = false,
|
|
1588
|
+
disabled = false,
|
|
1589
|
+
value,
|
|
1590
|
+
onItemSelect,
|
|
1591
|
+
onActivate,
|
|
1592
|
+
children,
|
|
1593
|
+
className,
|
|
1594
|
+
...props
|
|
1595
|
+
}, forwardedRef) {
|
|
1596
|
+
const internalRef = useRef13(null);
|
|
1597
|
+
useEffect15(() => {
|
|
1598
|
+
if (typeof forwardedRef === "function") {
|
|
1599
|
+
forwardedRef(internalRef.current);
|
|
1600
|
+
} else if (forwardedRef) {
|
|
1601
|
+
forwardedRef.current = internalRef.current;
|
|
1602
|
+
}
|
|
1603
|
+
}, [forwardedRef]);
|
|
1604
|
+
useEffect15(() => {
|
|
1605
|
+
const element = internalRef.current;
|
|
1606
|
+
if (!element) return;
|
|
1607
|
+
const handleSelect = (e) => {
|
|
1608
|
+
const event = e;
|
|
1609
|
+
onItemSelect?.(event.detail.itemId, event.detail.value, event.detail.selected);
|
|
1610
|
+
};
|
|
1611
|
+
const handleActivate = (e) => {
|
|
1612
|
+
const event = e;
|
|
1613
|
+
onActivate?.(event.detail.itemId, event.detail.value);
|
|
1614
|
+
};
|
|
1615
|
+
element.addEventListener("ds:select", handleSelect);
|
|
1616
|
+
element.addEventListener("ds:activate", handleActivate);
|
|
1617
|
+
return () => {
|
|
1618
|
+
element.removeEventListener("ds:select", handleSelect);
|
|
1619
|
+
element.removeEventListener("ds:activate", handleActivate);
|
|
1620
|
+
};
|
|
1621
|
+
}, [onItemSelect, onActivate]);
|
|
1622
|
+
return createElement24(
|
|
1623
|
+
"ds-list-item",
|
|
1624
|
+
{
|
|
1625
|
+
ref: internalRef,
|
|
1626
|
+
"item-id": itemId,
|
|
1627
|
+
selected: selected || void 0,
|
|
1628
|
+
disabled: disabled || void 0,
|
|
1629
|
+
value,
|
|
1630
|
+
class: className,
|
|
1631
|
+
...props
|
|
1632
|
+
},
|
|
1633
|
+
children
|
|
1634
|
+
);
|
|
1635
|
+
});
|
|
1636
|
+
|
|
1637
|
+
// src/components/list/list.tsx
|
|
1638
|
+
import {
|
|
1639
|
+
createElement as createElement25,
|
|
1640
|
+
forwardRef as forwardRef27,
|
|
1641
|
+
useEffect as useEffect16,
|
|
1642
|
+
useRef as useRef14
|
|
1643
|
+
} from "react";
|
|
1644
|
+
import "@hypoth-ui/wc";
|
|
1645
|
+
var ListRoot = forwardRef27(function ListRoot2({
|
|
1646
|
+
selectionMode = "single",
|
|
1647
|
+
orientation = "vertical",
|
|
1648
|
+
size = "default",
|
|
1649
|
+
bordered = false,
|
|
1650
|
+
label = "List",
|
|
1651
|
+
onSelectionChange,
|
|
1652
|
+
children,
|
|
1653
|
+
className,
|
|
1654
|
+
...props
|
|
1655
|
+
}, forwardedRef) {
|
|
1656
|
+
const internalRef = useRef14(null);
|
|
1657
|
+
useEffect16(() => {
|
|
1658
|
+
if (typeof forwardedRef === "function") {
|
|
1659
|
+
forwardedRef(internalRef.current);
|
|
1660
|
+
} else if (forwardedRef) {
|
|
1661
|
+
forwardedRef.current = internalRef.current;
|
|
1662
|
+
}
|
|
1663
|
+
}, [forwardedRef]);
|
|
1664
|
+
useEffect16(() => {
|
|
1665
|
+
const element = internalRef.current;
|
|
1666
|
+
if (!element) return;
|
|
1667
|
+
const handleSelectionChange = (e) => {
|
|
1668
|
+
const event = e;
|
|
1669
|
+
onSelectionChange?.(event.detail.selectedItems);
|
|
1670
|
+
};
|
|
1671
|
+
element.addEventListener("ds:selection-change", handleSelectionChange);
|
|
1672
|
+
return () => element.removeEventListener("ds:selection-change", handleSelectionChange);
|
|
1673
|
+
}, [onSelectionChange]);
|
|
1674
|
+
return createElement25(
|
|
1675
|
+
"ds-list",
|
|
1676
|
+
{
|
|
1677
|
+
ref: internalRef,
|
|
1678
|
+
"selection-mode": selectionMode,
|
|
1679
|
+
orientation,
|
|
1680
|
+
size,
|
|
1681
|
+
bordered: bordered || void 0,
|
|
1682
|
+
label,
|
|
1683
|
+
class: className,
|
|
1684
|
+
...props
|
|
1685
|
+
},
|
|
1686
|
+
children
|
|
1687
|
+
);
|
|
1688
|
+
});
|
|
1689
|
+
|
|
1690
|
+
// src/components/list/index.tsx
|
|
1691
|
+
var List = Object.assign(ListRoot, {
|
|
1692
|
+
Item: ListItem
|
|
1693
|
+
});
|
|
1694
|
+
|
|
1695
|
+
// src/components/calendar/index.tsx
|
|
1696
|
+
import { createElement as createElement26, forwardRef as forwardRef28, useEffect as useEffect17, useRef as useRef15 } from "react";
|
|
1697
|
+
import "@hypoth-ui/wc";
|
|
1698
|
+
var Calendar = forwardRef28(function Calendar2({
|
|
1699
|
+
value,
|
|
1700
|
+
min,
|
|
1701
|
+
max,
|
|
1702
|
+
disabledDates = [],
|
|
1703
|
+
locale = "en-US",
|
|
1704
|
+
size = "default",
|
|
1705
|
+
firstDayOfWeek = 0,
|
|
1706
|
+
onChange,
|
|
1707
|
+
onMonthChange,
|
|
1708
|
+
className,
|
|
1709
|
+
...props
|
|
1710
|
+
}, forwardedRef) {
|
|
1711
|
+
const internalRef = useRef15(null);
|
|
1712
|
+
useEffect17(() => {
|
|
1713
|
+
if (typeof forwardedRef === "function") {
|
|
1714
|
+
forwardedRef(internalRef.current);
|
|
1715
|
+
} else if (forwardedRef) {
|
|
1716
|
+
forwardedRef.current = internalRef.current;
|
|
1717
|
+
}
|
|
1718
|
+
}, [forwardedRef]);
|
|
1719
|
+
useEffect17(() => {
|
|
1720
|
+
const element = internalRef.current;
|
|
1721
|
+
if (!element) return;
|
|
1722
|
+
const handleChange = (e) => {
|
|
1723
|
+
const event = e;
|
|
1724
|
+
onChange?.(event.detail.value, new Date(event.detail.date));
|
|
1725
|
+
};
|
|
1726
|
+
const handleMonthChange = (e) => {
|
|
1727
|
+
const event = e;
|
|
1728
|
+
onMonthChange?.(event.detail.month, event.detail.year);
|
|
1729
|
+
};
|
|
1730
|
+
element.addEventListener("ds:change", handleChange);
|
|
1731
|
+
element.addEventListener("ds:month-change", handleMonthChange);
|
|
1732
|
+
return () => {
|
|
1733
|
+
element.removeEventListener("ds:change", handleChange);
|
|
1734
|
+
element.removeEventListener("ds:month-change", handleMonthChange);
|
|
1735
|
+
};
|
|
1736
|
+
}, [onChange, onMonthChange]);
|
|
1737
|
+
return createElement26("ds-calendar", {
|
|
1738
|
+
ref: internalRef,
|
|
1739
|
+
value,
|
|
1740
|
+
min,
|
|
1741
|
+
max,
|
|
1742
|
+
"disabled-dates": disabledDates.join(","),
|
|
1743
|
+
locale,
|
|
1744
|
+
size,
|
|
1745
|
+
"first-day-of-week": firstDayOfWeek,
|
|
1746
|
+
class: className,
|
|
1747
|
+
...props
|
|
1748
|
+
});
|
|
1749
|
+
});
|
|
1750
|
+
|
|
1751
|
+
// src/components/data-table/index.tsx
|
|
1752
|
+
import { createElement as createElement27, forwardRef as forwardRef29, useEffect as useEffect18, useRef as useRef16 } from "react";
|
|
1753
|
+
var DataTable = forwardRef29(function DataTable2({
|
|
1754
|
+
virtualized = false,
|
|
1755
|
+
rowHeight = 48,
|
|
1756
|
+
overscan = 5,
|
|
1757
|
+
totalRows = 0,
|
|
1758
|
+
page = 1,
|
|
1759
|
+
pageSize = 10,
|
|
1760
|
+
pageSizes = "10,25,50,100",
|
|
1761
|
+
selectable = false,
|
|
1762
|
+
selectionMode = "multiple",
|
|
1763
|
+
loading = false,
|
|
1764
|
+
sortColumn,
|
|
1765
|
+
sortDirection = "none",
|
|
1766
|
+
filter,
|
|
1767
|
+
emptyMessage = "No data available",
|
|
1768
|
+
onSort,
|
|
1769
|
+
onPageChange,
|
|
1770
|
+
onPageSizeChange,
|
|
1771
|
+
onSelectionChange,
|
|
1772
|
+
children,
|
|
1773
|
+
className
|
|
1774
|
+
}, forwardedRef) {
|
|
1775
|
+
const internalRef = useRef16(null);
|
|
1776
|
+
useEffect18(() => {
|
|
1777
|
+
if (typeof forwardedRef === "function") {
|
|
1778
|
+
forwardedRef(internalRef.current);
|
|
1779
|
+
} else if (forwardedRef) {
|
|
1780
|
+
forwardedRef.current = internalRef.current;
|
|
1781
|
+
}
|
|
1782
|
+
}, [forwardedRef]);
|
|
1783
|
+
useEffect18(() => {
|
|
1784
|
+
const element = internalRef.current;
|
|
1785
|
+
if (!element) return;
|
|
1786
|
+
const handleSort = (e) => {
|
|
1787
|
+
const event = e;
|
|
1788
|
+
onSort?.(event.detail);
|
|
1789
|
+
};
|
|
1790
|
+
const handlePageChange = (e) => {
|
|
1791
|
+
const event = e;
|
|
1792
|
+
onPageChange?.(event.detail);
|
|
1793
|
+
};
|
|
1794
|
+
const handlePageSizeChange = (e) => {
|
|
1795
|
+
const event = e;
|
|
1796
|
+
onPageSizeChange?.(event.detail);
|
|
1797
|
+
};
|
|
1798
|
+
const handleSelectionChange = (e) => {
|
|
1799
|
+
const event = e;
|
|
1800
|
+
onSelectionChange?.(event.detail);
|
|
1801
|
+
};
|
|
1802
|
+
element.addEventListener("ds:sort", handleSort);
|
|
1803
|
+
element.addEventListener("ds:page-change", handlePageChange);
|
|
1804
|
+
element.addEventListener("ds:page-size-change", handlePageSizeChange);
|
|
1805
|
+
element.addEventListener("ds:selection-change", handleSelectionChange);
|
|
1806
|
+
return () => {
|
|
1807
|
+
element.removeEventListener("ds:sort", handleSort);
|
|
1808
|
+
element.removeEventListener("ds:page-change", handlePageChange);
|
|
1809
|
+
element.removeEventListener("ds:page-size-change", handlePageSizeChange);
|
|
1810
|
+
element.removeEventListener("ds:selection-change", handleSelectionChange);
|
|
1811
|
+
};
|
|
1812
|
+
}, [onSort, onPageChange, onPageSizeChange, onSelectionChange]);
|
|
1813
|
+
return createElement27(
|
|
1814
|
+
"ds-data-table",
|
|
1815
|
+
{
|
|
1816
|
+
ref: internalRef,
|
|
1817
|
+
virtualized: virtualized || void 0,
|
|
1818
|
+
"row-height": rowHeight,
|
|
1819
|
+
overscan,
|
|
1820
|
+
"total-rows": totalRows,
|
|
1821
|
+
page,
|
|
1822
|
+
"page-size": pageSize,
|
|
1823
|
+
"page-sizes": pageSizes,
|
|
1824
|
+
selectable: selectable || void 0,
|
|
1825
|
+
"selection-mode": selectionMode,
|
|
1826
|
+
loading: loading || void 0,
|
|
1827
|
+
"sort-column": sortColumn,
|
|
1828
|
+
"sort-direction": sortDirection,
|
|
1829
|
+
filter,
|
|
1830
|
+
"empty-message": emptyMessage,
|
|
1831
|
+
class: className
|
|
1832
|
+
},
|
|
1833
|
+
children
|
|
1834
|
+
);
|
|
1835
|
+
});
|
|
1836
|
+
DataTable.displayName = "DataTable";
|
|
1837
|
+
|
|
1838
|
+
// src/utils/events.ts
|
|
1839
|
+
function createEventHandler(handler) {
|
|
1840
|
+
if (!handler) return void 0;
|
|
1841
|
+
return (event) => {
|
|
1842
|
+
const syntheticEvent = {
|
|
1843
|
+
...event,
|
|
1844
|
+
nativeEvent: event,
|
|
1845
|
+
currentTarget: event.currentTarget,
|
|
1846
|
+
target: event.target,
|
|
1847
|
+
bubbles: event.bubbles,
|
|
1848
|
+
cancelable: event.cancelable,
|
|
1849
|
+
defaultPrevented: event.defaultPrevented,
|
|
1850
|
+
eventPhase: event.eventPhase,
|
|
1851
|
+
isTrusted: event.isTrusted,
|
|
1852
|
+
preventDefault: () => event.preventDefault(),
|
|
1853
|
+
stopPropagation: () => event.stopPropagation(),
|
|
1854
|
+
persist: () => {
|
|
1855
|
+
},
|
|
1856
|
+
isDefaultPrevented: () => event.defaultPrevented,
|
|
1857
|
+
isPropagationStopped: () => false,
|
|
1858
|
+
type: event.type,
|
|
1859
|
+
timeStamp: event.timeStamp
|
|
1860
|
+
};
|
|
1861
|
+
handler(syntheticEvent);
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
function attachEventListeners(element, events) {
|
|
1865
|
+
const cleanup = [];
|
|
1866
|
+
for (const [eventName, handler] of Object.entries(events)) {
|
|
1867
|
+
if (handler) {
|
|
1868
|
+
element.addEventListener(eventName, handler);
|
|
1869
|
+
cleanup.push(() => element.removeEventListener(eventName, handler));
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
return () => {
|
|
1873
|
+
for (const fn of cleanup) {
|
|
1874
|
+
fn();
|
|
1875
|
+
}
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
// src/utils/create-component.ts
|
|
1880
|
+
import {
|
|
1881
|
+
forwardRef as forwardRef30,
|
|
1882
|
+
useEffect as useEffect19,
|
|
1883
|
+
useRef as useRef17
|
|
1884
|
+
} from "react";
|
|
1885
|
+
function createComponent(config) {
|
|
1886
|
+
const { tagName, properties = [], events = {}, defaults = {} } = config;
|
|
1887
|
+
const Component = forwardRef30((incomingProps, forwardedRef) => {
|
|
1888
|
+
const props = { ...defaults, ...incomingProps };
|
|
1889
|
+
const internalRef = useRef17(null);
|
|
1890
|
+
const mergedRef = (element) => {
|
|
1891
|
+
internalRef.current = element;
|
|
1892
|
+
if (typeof forwardedRef === "function") {
|
|
1893
|
+
forwardedRef(element);
|
|
1894
|
+
} else if (forwardedRef) {
|
|
1895
|
+
forwardedRef.current = element;
|
|
1896
|
+
}
|
|
1897
|
+
};
|
|
1898
|
+
useEffect19(() => {
|
|
1899
|
+
const element = internalRef.current;
|
|
1900
|
+
if (!element) return;
|
|
1901
|
+
for (const prop of properties) {
|
|
1902
|
+
const value = props[prop];
|
|
1903
|
+
if (value !== void 0) {
|
|
1904
|
+
element[prop] = value;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
}, [props]);
|
|
1908
|
+
useEffect19(() => {
|
|
1909
|
+
const element = internalRef.current;
|
|
1910
|
+
if (!element) return;
|
|
1911
|
+
const listeners = [];
|
|
1912
|
+
for (const [reactProp, domEvent] of Object.entries(events)) {
|
|
1913
|
+
const handler = props[reactProp];
|
|
1914
|
+
if (handler) {
|
|
1915
|
+
element.addEventListener(domEvent, handler);
|
|
1916
|
+
listeners.push(() => element.removeEventListener(domEvent, handler));
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
return () => {
|
|
1920
|
+
for (const cleanup of listeners) {
|
|
1921
|
+
cleanup();
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
}, [props]);
|
|
1925
|
+
const elementProps = {};
|
|
1926
|
+
const restProps = {};
|
|
1927
|
+
for (const [key, value] of Object.entries(props)) {
|
|
1928
|
+
if (properties.includes(key) || key in events) {
|
|
1929
|
+
} else if (key === "children" || key === "className" || key === "style") {
|
|
1930
|
+
elementProps[key] = value;
|
|
1931
|
+
} else {
|
|
1932
|
+
restProps[key] = value;
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
const React = __require("react");
|
|
1936
|
+
return React.createElement(
|
|
1937
|
+
tagName,
|
|
1938
|
+
{ ref: mergedRef, ...elementProps, ...restProps },
|
|
1939
|
+
props.children
|
|
1940
|
+
);
|
|
1941
|
+
});
|
|
1942
|
+
Component.displayName = `React(${tagName})`;
|
|
1943
|
+
return Component;
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
export {
|
|
1947
|
+
isResponsiveObject,
|
|
1948
|
+
resolveResponsiveValue,
|
|
1949
|
+
generateResponsiveDataAttr,
|
|
1950
|
+
Button,
|
|
1951
|
+
Input,
|
|
1952
|
+
composeEventHandlers,
|
|
1953
|
+
mergeClassNames,
|
|
1954
|
+
mergeStyles,
|
|
1955
|
+
mergeProps,
|
|
1956
|
+
Slot,
|
|
1957
|
+
Link,
|
|
1958
|
+
Icon,
|
|
1959
|
+
Spinner,
|
|
1960
|
+
VisuallyHidden,
|
|
1961
|
+
Text,
|
|
1962
|
+
Box,
|
|
1963
|
+
Portal,
|
|
1964
|
+
FocusScope,
|
|
1965
|
+
ClientOnly,
|
|
1966
|
+
useIsClient,
|
|
1967
|
+
Alert,
|
|
1968
|
+
useToast,
|
|
1969
|
+
Toast,
|
|
1970
|
+
Progress,
|
|
1971
|
+
AvatarGroup,
|
|
1972
|
+
Avatar3 as Avatar,
|
|
1973
|
+
TableBody,
|
|
1974
|
+
TableCell,
|
|
1975
|
+
TableHead,
|
|
1976
|
+
TableHeader,
|
|
1977
|
+
TableRow,
|
|
1978
|
+
Table,
|
|
1979
|
+
Skeleton,
|
|
1980
|
+
Badge,
|
|
1981
|
+
Tag,
|
|
1982
|
+
TreeItem,
|
|
1983
|
+
Tree,
|
|
1984
|
+
ListItem,
|
|
1985
|
+
List,
|
|
1986
|
+
Calendar,
|
|
1987
|
+
DataTable,
|
|
1988
|
+
createEventHandler,
|
|
1989
|
+
attachEventListeners,
|
|
1990
|
+
createComponent
|
|
1991
|
+
};
|