@usefragments/ui 1.3.2 → 1.4.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/README.md +3 -1
- package/dist/assets/ui.css +1261 -849
- package/dist/chart.cjs +60 -24
- package/dist/chart.js +38 -24
- package/dist/codeblock.cjs +14 -6
- package/dist/codeblock.js +14 -6
- package/dist/colorpicker.cjs +56 -9
- package/dist/colorpicker.js +34 -9
- package/dist/components/Badge/Badge.module.scss.cjs +23 -16
- package/dist/components/Badge/Badge.module.scss.js +23 -16
- package/dist/components/Badge/index.cjs +8 -1
- package/dist/components/Badge/index.d.ts +3 -0
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js +8 -1
- package/dist/components/Button/Button.module.scss.cjs +16 -13
- package/dist/components/Button/Button.module.scss.js +16 -13
- package/dist/components/Button/index.d.ts +2 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Chart/index.d.ts +3 -0
- package/dist/components/Chart/index.d.ts.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.module.scss.cjs +21 -21
- package/dist/components/CodeBlock/CodeBlock.module.scss.js +21 -21
- package/dist/components/CodeBlock/index.d.ts.map +1 -1
- package/dist/components/ColorPicker/index.d.ts +4 -0
- package/dist/components/ColorPicker/index.d.ts.map +1 -1
- package/dist/components/Combobox/Combobox.module.scss.cjs +23 -23
- package/dist/components/Combobox/Combobox.module.scss.js +23 -23
- package/dist/components/Command/Command.module.scss.cjs +11 -11
- package/dist/components/Command/Command.module.scss.js +11 -11
- package/dist/components/ConversationList/ConversationList.module.scss.cjs +13 -10
- package/dist/components/ConversationList/ConversationList.module.scss.js +14 -11
- package/dist/components/ConversationList/index.cjs +26 -22
- package/dist/components/ConversationList/index.d.ts +5 -1
- package/dist/components/ConversationList/index.d.ts.map +1 -1
- package/dist/components/ConversationList/index.js +27 -23
- package/dist/components/DataTable/DataTable.module.scss.cjs +35 -35
- package/dist/components/DataTable/DataTable.module.scss.js +35 -35
- package/dist/components/DataTable/index.d.ts +4 -1
- package/dist/components/DataTable/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.d.ts +3 -0
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/Editor/index.d.ts +4 -1
- package/dist/components/Editor/index.d.ts.map +1 -1
- package/dist/components/Listbox/Listbox.module.scss.cjs +8 -8
- package/dist/components/Listbox/Listbox.module.scss.js +8 -8
- package/dist/components/Markdown/Markdown.module.scss.cjs +1 -1
- package/dist/components/Markdown/Markdown.module.scss.js +1 -1
- package/dist/components/Markdown/index.d.ts +16 -0
- package/dist/components/Markdown/index.d.ts.map +1 -1
- package/dist/components/Menu/Menu.module.scss.cjs +14 -14
- package/dist/components/Menu/Menu.module.scss.js +14 -14
- package/dist/components/Message/Message.module.scss.cjs +23 -20
- package/dist/components/Message/Message.module.scss.js +24 -21
- package/dist/components/Message/index.cjs +5 -1
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +5 -1
- package/dist/components/NavigationMenu/NavigationMenu.module.scss.cjs +28 -28
- package/dist/components/NavigationMenu/NavigationMenu.module.scss.js +28 -28
- package/dist/components/Pagination/Pagination.module.scss.cjs +7 -7
- package/dist/components/Pagination/Pagination.module.scss.js +7 -7
- package/dist/components/Prompt/Prompt.module.scss.cjs +52 -22
- package/dist/components/Prompt/Prompt.module.scss.js +52 -22
- package/dist/components/Prompt/index.cjs +197 -2
- package/dist/components/Prompt/index.d.ts +98 -3
- package/dist/components/Prompt/index.d.ts.map +1 -1
- package/dist/components/Prompt/index.js +198 -3
- package/dist/components/Select/Select.module.scss.cjs +29 -17
- package/dist/components/Select/Select.module.scss.js +30 -18
- package/dist/components/Select/index.cjs +45 -8
- package/dist/components/Select/index.d.ts +17 -2
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +45 -8
- package/dist/components/Sidebar/Sidebar.module.scss.cjs +45 -42
- package/dist/components/Sidebar/Sidebar.module.scss.js +45 -42
- package/dist/components/Sidebar/index.cjs +2 -0
- package/dist/components/Sidebar/index.d.ts +6 -1
- package/dist/components/Sidebar/index.d.ts.map +1 -1
- package/dist/components/Sidebar/index.js +2 -0
- package/dist/components/Text/Text.module.scss.cjs +63 -51
- package/dist/components/Text/Text.module.scss.js +63 -51
- package/dist/components/Text/index.d.ts +4 -2
- package/dist/components/Text/index.d.ts.map +1 -1
- package/dist/data-table.cjs +210 -28
- package/dist/data-table.js +189 -29
- package/dist/datepicker.cjs +63 -14
- package/dist/datepicker.js +41 -14
- package/dist/editor.cjs +67 -16
- package/dist/editor.js +45 -16
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/markdown.cjs +63 -19
- package/dist/markdown.js +41 -19
- package/fragments.json +1 -1
- package/package.json +2 -2
- package/src/components/Badge/Badge.contract.json +28 -5
- package/src/components/Badge/Badge.module.scss +21 -0
- package/src/components/Badge/index.tsx +10 -1
- package/src/components/Button/Button.contract.json +9 -3
- package/src/components/Button/Button.module.scss +34 -0
- package/src/components/Button/index.tsx +11 -1
- package/src/components/Chart/Chart.contract.json +7 -0
- package/src/components/Chart/index.tsx +44 -27
- package/src/components/CodeBlock/CodeBlock.contract.json +7 -0
- package/src/components/CodeBlock/CodeBlock.module.scss +7 -2
- package/src/components/CodeBlock/index.tsx +38 -6
- package/src/components/ColorPicker/ColorPicker.contract.json +9 -1
- package/src/components/ColorPicker/index.tsx +42 -12
- package/src/components/Combobox/Combobox.module.scss +4 -13
- package/src/components/ConversationList/ConversationList.contract.json +16 -1
- package/src/components/ConversationList/ConversationList.module.scss +12 -0
- package/src/components/ConversationList/index.tsx +40 -26
- package/src/components/DataTable/DataTable.contract.json +8 -1
- package/src/components/DataTable/DataTable.module.scss +5 -0
- package/src/components/DataTable/index.tsx +282 -51
- package/src/components/DatePicker/DatePicker.contract.json +8 -1
- package/src/components/DatePicker/index.tsx +51 -22
- package/src/components/Editor/Editor.contract.json +19 -1
- package/src/components/Editor/index.tsx +67 -23
- package/src/components/Listbox/Listbox.module.scss +3 -11
- package/src/components/Markdown/Markdown.contract.json +15 -1
- package/src/components/Markdown/Markdown.module.scss +18 -1
- package/src/components/Markdown/index.tsx +58 -24
- package/src/components/Menu/Menu.module.scss +12 -2
- package/src/components/Message/Message.contract.json +3 -0
- package/src/components/Message/Message.module.scss +33 -4
- package/src/components/Message/index.tsx +7 -1
- package/src/components/Pagination/Pagination.contract.json +1 -0
- package/src/components/Pagination/Pagination.module.scss +5 -4
- package/src/components/Prompt/Prompt.contract.json +40 -1
- package/src/components/Prompt/Prompt.module.scss +351 -4
- package/src/components/Prompt/index.tsx +324 -0
- package/src/components/Select/Select.contract.json +11 -1
- package/src/components/Select/Select.module.scss +80 -13
- package/src/components/Select/index.tsx +73 -7
- package/src/components/Sidebar/Sidebar.contract.json +1 -0
- package/src/components/Sidebar/Sidebar.module.scss +10 -0
- package/src/components/Sidebar/index.tsx +7 -0
- package/src/components/Text/Text.contract.json +7 -4
- package/src/components/Text/Text.module.scss +18 -0
- package/src/components/Text/index.tsx +4 -2
- package/src/index.ts +1 -0
- package/src/tokens/_mixins.scss +39 -4
- package/src/tokens/_variables.scss +30 -0
package/dist/data-table.js
CHANGED
|
@@ -5,18 +5,40 @@ import { createElement } from "react";
|
|
|
5
5
|
import styles from "./components/DataTable/DataTable.module.scss.js";
|
|
6
6
|
import { Checkbox } from "./components/Checkbox/index.js";
|
|
7
7
|
import { SortAscIcon, SortDescIcon, SortIcon, ExpandIcon } from "./components/DataTable/DataTable.icons.js";
|
|
8
|
-
import {
|
|
8
|
+
import { DataTableSkeletonRows, useArrowKeyRowNav } from "./components/DataTable/DataTable.support.js";
|
|
9
9
|
let _reactTable = null;
|
|
10
|
-
let
|
|
10
|
+
let _reactTableLoadPromise = null;
|
|
11
11
|
let _reactTableFailed = false;
|
|
12
12
|
function loadReactTable() {
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (!_reactTableLoadPromise) {
|
|
14
|
+
_reactTableLoadPromise = (async () => {
|
|
15
|
+
try {
|
|
16
|
+
_reactTable = await import("@tanstack/react-table");
|
|
17
|
+
} catch {
|
|
18
|
+
_reactTableFailed = true;
|
|
19
|
+
if (process.env.NODE_ENV === "development") {
|
|
20
|
+
console.warn(
|
|
21
|
+
"[@usefragments/ui] DataTable: @tanstack/react-table is not installed. Rendering a static table without sorting, selection, or expansion. Install it with: npm install @tanstack/react-table"
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
})();
|
|
19
26
|
}
|
|
27
|
+
return _reactTableLoadPromise;
|
|
28
|
+
}
|
|
29
|
+
function useReactTableDeps() {
|
|
30
|
+
const [, rerender] = React.useReducer((n) => n + 1, 0);
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
if (_reactTable || _reactTableFailed) return;
|
|
33
|
+
let active = true;
|
|
34
|
+
void loadReactTable().then(() => {
|
|
35
|
+
if (active) rerender();
|
|
36
|
+
});
|
|
37
|
+
return () => {
|
|
38
|
+
active = false;
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
return _reactTable ? "ready" : _reactTableFailed ? "failed" : "pending";
|
|
20
42
|
}
|
|
21
43
|
function getColumnSizeStyle(column) {
|
|
22
44
|
const { size, minSize, maxSize } = column.columnDef;
|
|
@@ -31,6 +53,24 @@ function getColumnSizeStyle(column) {
|
|
|
31
53
|
maxWidth: maxSize ?? resolvedSize
|
|
32
54
|
};
|
|
33
55
|
}
|
|
56
|
+
function computeTableClasses(opts) {
|
|
57
|
+
const densityClass = opts.density === "condensed" ? styles.densityCondensed : opts.density === "regular" ? styles.densityRegular : opts.density === "relaxed" ? styles.densityRelaxed : void 0;
|
|
58
|
+
const rootClasses = [
|
|
59
|
+
styles.table,
|
|
60
|
+
opts.hasExplicitColumnSizing && styles.fixedLayout,
|
|
61
|
+
styles[opts.size],
|
|
62
|
+
densityClass,
|
|
63
|
+
opts.striped && styles.striped,
|
|
64
|
+
opts.className
|
|
65
|
+
].filter(Boolean).join(" ");
|
|
66
|
+
const wrapperClasses = [
|
|
67
|
+
styles.wrapper,
|
|
68
|
+
opts.bordered && styles.bordered,
|
|
69
|
+
opts.wrapperClassName,
|
|
70
|
+
opts.wrapperPropsClassName
|
|
71
|
+
].filter(Boolean).join(" ");
|
|
72
|
+
return { rootClasses, wrapperClasses };
|
|
73
|
+
}
|
|
34
74
|
function isInteractiveTarget(target, currentTarget) {
|
|
35
75
|
if (!(target instanceof Element)) return false;
|
|
36
76
|
const interactiveElement = target.closest(
|
|
@@ -40,7 +80,7 @@ function isInteractiveTarget(target, currentTarget) {
|
|
|
40
80
|
interactiveElement && interactiveElement !== currentTarget && currentTarget.contains(interactiveElement)
|
|
41
81
|
);
|
|
42
82
|
}
|
|
43
|
-
function
|
|
83
|
+
function DataTableLive({
|
|
44
84
|
columns: userColumns,
|
|
45
85
|
data,
|
|
46
86
|
getRowId,
|
|
@@ -74,12 +114,6 @@ function DataTableRoot({
|
|
|
74
114
|
"aria-describedby": ariaDescribedBy,
|
|
75
115
|
...htmlProps
|
|
76
116
|
}) {
|
|
77
|
-
loadReactTable();
|
|
78
|
-
if (_reactTableFailed || !_reactTable) {
|
|
79
|
-
throw new Error(
|
|
80
|
-
"[@usefragments/ui] DataTable: @tanstack/react-table is not installed. Install it with: npm install @tanstack/react-table"
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
117
|
const { flexRender, getCoreRowModel, getExpandedRowModel, getSortedRowModel, useReactTable } = _reactTable;
|
|
84
118
|
const tableRef = React.useRef(null);
|
|
85
119
|
useArrowKeyRowNav(tableRef, !!onRowClick);
|
|
@@ -151,22 +185,17 @@ function DataTableRoot({
|
|
|
151
185
|
enableExpanding: hasSubRows
|
|
152
186
|
});
|
|
153
187
|
const isEmpty = !loading && data.length === 0;
|
|
154
|
-
const densityClass = density === "condensed" ? styles.densityCondensed : density === "regular" ? styles.densityRegular : density === "relaxed" ? styles.densityRelaxed : void 0;
|
|
155
|
-
const rootClasses = [
|
|
156
|
-
styles.table,
|
|
157
|
-
hasExplicitColumnSizing && styles.fixedLayout,
|
|
158
|
-
styles[size],
|
|
159
|
-
densityClass,
|
|
160
|
-
striped && styles.striped,
|
|
161
|
-
className
|
|
162
|
-
].filter(Boolean).join(" ");
|
|
163
188
|
const { className: wrapperPropsClassName, ...restWrapperProps } = wrapperProps ?? {};
|
|
164
|
-
const wrapperClasses =
|
|
165
|
-
|
|
166
|
-
|
|
189
|
+
const { rootClasses, wrapperClasses } = computeTableClasses({
|
|
190
|
+
size,
|
|
191
|
+
density,
|
|
192
|
+
striped,
|
|
193
|
+
bordered,
|
|
194
|
+
hasExplicitColumnSizing,
|
|
195
|
+
className,
|
|
167
196
|
wrapperClassName,
|
|
168
197
|
wrapperPropsClassName
|
|
169
|
-
|
|
198
|
+
});
|
|
170
199
|
if (isEmpty) {
|
|
171
200
|
return /* @__PURE__ */ jsx("div", { ...restWrapperProps, className: wrapperClasses, children: /* @__PURE__ */ jsxs(
|
|
172
201
|
"table",
|
|
@@ -309,6 +338,135 @@ function DataTableRoot({
|
|
|
309
338
|
}
|
|
310
339
|
) });
|
|
311
340
|
}
|
|
341
|
+
function staticColumnSizeStyle(col) {
|
|
342
|
+
const { size, minSize, maxSize } = col;
|
|
343
|
+
if (size === void 0 && minSize === void 0 && maxSize === void 0) return void 0;
|
|
344
|
+
const resolved = size ?? minSize ?? maxSize;
|
|
345
|
+
return { width: resolved, minWidth: minSize ?? resolved, maxWidth: maxSize ?? resolved };
|
|
346
|
+
}
|
|
347
|
+
function staticCellContent(col, row, index) {
|
|
348
|
+
const raw = col.accessorFn ? col.accessorFn(row) : col.accessorKey ? row[col.accessorKey] : void 0;
|
|
349
|
+
if (typeof col.cell === "function") {
|
|
350
|
+
try {
|
|
351
|
+
return col.cell({
|
|
352
|
+
row: { original: row, id: String(index), index, depth: 0 },
|
|
353
|
+
getValue: () => raw,
|
|
354
|
+
column: { id: col.id ?? col.accessorKey ?? "" }
|
|
355
|
+
});
|
|
356
|
+
} catch {
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return typeof raw === "string" || typeof raw === "number" ? raw : null;
|
|
360
|
+
}
|
|
361
|
+
function DataTableStatic({
|
|
362
|
+
pending,
|
|
363
|
+
columns,
|
|
364
|
+
data,
|
|
365
|
+
getRowId,
|
|
366
|
+
emptyMessage = "No data available",
|
|
367
|
+
emptyState,
|
|
368
|
+
loading = false,
|
|
369
|
+
skeletonRows = 6,
|
|
370
|
+
density,
|
|
371
|
+
hideHeader = false,
|
|
372
|
+
size = "md",
|
|
373
|
+
className,
|
|
374
|
+
caption,
|
|
375
|
+
captionHidden = false,
|
|
376
|
+
striped = false,
|
|
377
|
+
bordered = false,
|
|
378
|
+
wrapperClassName,
|
|
379
|
+
wrapperProps,
|
|
380
|
+
"aria-label": ariaLabel,
|
|
381
|
+
"aria-describedby": ariaDescribedBy,
|
|
382
|
+
// Interactive props are inert without the peer — accepted but unused.
|
|
383
|
+
sortable: _sortable,
|
|
384
|
+
sorting: _sorting,
|
|
385
|
+
onSortingChange: _onSortingChange,
|
|
386
|
+
selectable: _selectable,
|
|
387
|
+
showCheckbox: _showCheckbox,
|
|
388
|
+
rowSelection: _rowSelection,
|
|
389
|
+
onRowSelectionChange: _onRowSelectionChange,
|
|
390
|
+
onRowClick: _onRowClick,
|
|
391
|
+
getRowProps: _getRowProps,
|
|
392
|
+
getSubRows: _getSubRows,
|
|
393
|
+
expanded: _expanded,
|
|
394
|
+
onExpandedChange: _onExpandedChange,
|
|
395
|
+
...htmlProps
|
|
396
|
+
}) {
|
|
397
|
+
const hasExplicitColumnSizing = columns.some(
|
|
398
|
+
(column) => column.size !== void 0 || column.minSize !== void 0 || column.maxSize !== void 0
|
|
399
|
+
);
|
|
400
|
+
const { className: wrapperPropsClassName, ...restWrapperProps } = wrapperProps ?? {};
|
|
401
|
+
const { rootClasses, wrapperClasses } = computeTableClasses({
|
|
402
|
+
size,
|
|
403
|
+
density,
|
|
404
|
+
striped,
|
|
405
|
+
bordered,
|
|
406
|
+
hasExplicitColumnSizing,
|
|
407
|
+
className,
|
|
408
|
+
wrapperClassName,
|
|
409
|
+
wrapperPropsClassName
|
|
410
|
+
});
|
|
411
|
+
const showSkeleton = pending || loading;
|
|
412
|
+
const isEmpty = !showSkeleton && data.length === 0;
|
|
413
|
+
const columnCount = Math.max(columns.length, 1);
|
|
414
|
+
return /* @__PURE__ */ jsx("div", { ...restWrapperProps, className: wrapperClasses, children: /* @__PURE__ */ jsxs(
|
|
415
|
+
"table",
|
|
416
|
+
{
|
|
417
|
+
...htmlProps,
|
|
418
|
+
className: rootClasses,
|
|
419
|
+
"aria-label": ariaLabel,
|
|
420
|
+
"aria-describedby": ariaDescribedBy,
|
|
421
|
+
"aria-busy": showSkeleton || void 0,
|
|
422
|
+
children: [
|
|
423
|
+
caption && /* @__PURE__ */ jsx("caption", { className: captionHidden ? styles.captionHidden : styles.caption, children: caption }),
|
|
424
|
+
!hideHeader && !isEmpty && /* @__PURE__ */ jsx("thead", { className: styles.thead, children: /* @__PURE__ */ jsx("tr", { className: styles.headerRow, children: columns.map((col, colIndex) => /* @__PURE__ */ jsx(
|
|
425
|
+
"th",
|
|
426
|
+
{
|
|
427
|
+
className: styles.th,
|
|
428
|
+
style: staticColumnSizeStyle(col),
|
|
429
|
+
scope: "col",
|
|
430
|
+
"data-align": col.align,
|
|
431
|
+
children: /* @__PURE__ */ jsx("div", { className: styles.headerContent, children: typeof col.header === "string" ? col.header : col.id ?? col.accessorKey ?? "" })
|
|
432
|
+
},
|
|
433
|
+
col.id ?? col.accessorKey ?? colIndex
|
|
434
|
+
)) }) }),
|
|
435
|
+
/* @__PURE__ */ jsx("tbody", { className: styles.tbody, children: showSkeleton ? /* @__PURE__ */ jsx(
|
|
436
|
+
DataTableSkeletonRows,
|
|
437
|
+
{
|
|
438
|
+
rowCount: skeletonRows,
|
|
439
|
+
columnCount,
|
|
440
|
+
rowClassName: styles.row,
|
|
441
|
+
cellClassName: styles.td,
|
|
442
|
+
barClassName: styles.skeletonBar
|
|
443
|
+
}
|
|
444
|
+
) : isEmpty ? /* @__PURE__ */ jsx("tr", { className: styles.row, children: /* @__PURE__ */ jsx("td", { className: styles.td, colSpan: columnCount, children: /* @__PURE__ */ jsx("div", { className: styles.emptyState, children: emptyState ?? /* @__PURE__ */ jsx("span", { className: styles.emptyMessage, children: emptyMessage }) }) }) }) : data.map((row, rowIndex) => {
|
|
445
|
+
const rowKey = (getRowId == null ? void 0 : getRowId(row)) ?? rowIndex;
|
|
446
|
+
return /* @__PURE__ */ jsx("tr", { className: styles.row, children: columns.map((col, colIndex) => {
|
|
447
|
+
const content = staticCellContent(col, row, rowIndex);
|
|
448
|
+
return /* @__PURE__ */ jsx(
|
|
449
|
+
"td",
|
|
450
|
+
{
|
|
451
|
+
className: [styles.td, col.truncate && styles.truncate].filter(Boolean).join(" "),
|
|
452
|
+
"data-align": col.align,
|
|
453
|
+
title: typeof content === "string" ? content : void 0,
|
|
454
|
+
style: staticColumnSizeStyle(col),
|
|
455
|
+
children: content
|
|
456
|
+
},
|
|
457
|
+
col.id ?? col.accessorKey ?? colIndex
|
|
458
|
+
);
|
|
459
|
+
}) }, rowKey);
|
|
460
|
+
}) })
|
|
461
|
+
]
|
|
462
|
+
}
|
|
463
|
+
) });
|
|
464
|
+
}
|
|
465
|
+
function DataTableRoot(props) {
|
|
466
|
+
const deps = useReactTableDeps();
|
|
467
|
+
if (deps === "ready") return /* @__PURE__ */ jsx(DataTableLive, { ...props });
|
|
468
|
+
return /* @__PURE__ */ jsx(DataTableStatic, { ...props, pending: deps === "pending" });
|
|
469
|
+
}
|
|
312
470
|
function createColumns(columns) {
|
|
313
471
|
return columns.map((col) => ({
|
|
314
472
|
id: col.key,
|
|
@@ -322,7 +480,9 @@ function createColumns(columns) {
|
|
|
322
480
|
}
|
|
323
481
|
const DataTable = Object.assign(DataTableRoot, {
|
|
324
482
|
Root: DataTableRoot,
|
|
325
|
-
Columns: createColumns
|
|
483
|
+
Columns: createColumns,
|
|
484
|
+
/** Start resolving @tanstack/react-table before first render (optional). */
|
|
485
|
+
preload: loadReactTable
|
|
326
486
|
});
|
|
327
487
|
export {
|
|
328
488
|
DataTable,
|
package/dist/datepicker.cjs
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
3
25
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
26
|
const jsxRuntime = require("react/jsx-runtime");
|
|
5
27
|
const React = require("react");
|
|
@@ -120,20 +142,42 @@ let _DayPicker = null;
|
|
|
120
142
|
let _UI = null;
|
|
121
143
|
let _SelectionState = null;
|
|
122
144
|
let _DayFlag = null;
|
|
123
|
-
let
|
|
145
|
+
let _rdpLoadPromise = null;
|
|
124
146
|
let _rdpFailed = false;
|
|
125
147
|
function loadDayPickerDeps() {
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
148
|
+
if (!_rdpLoadPromise) {
|
|
149
|
+
_rdpLoadPromise = (async () => {
|
|
150
|
+
try {
|
|
151
|
+
const rdp = await import("react-day-picker");
|
|
152
|
+
_DayPicker = rdp.DayPicker;
|
|
153
|
+
_UI = rdp.UI;
|
|
154
|
+
_SelectionState = rdp.SelectionState;
|
|
155
|
+
_DayFlag = rdp.DayFlag;
|
|
156
|
+
} catch {
|
|
157
|
+
_rdpFailed = true;
|
|
158
|
+
if (process.env.NODE_ENV === "development") {
|
|
159
|
+
console.warn(
|
|
160
|
+
"[@usefragments/ui] DatePicker: react-day-picker is not installed. Install it with: npm install react-day-picker"
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
})();
|
|
136
165
|
}
|
|
166
|
+
return _rdpLoadPromise;
|
|
167
|
+
}
|
|
168
|
+
function useDayPickerDeps() {
|
|
169
|
+
const [, rerender] = React__namespace.useReducer((n) => n + 1, 0);
|
|
170
|
+
React__namespace.useEffect(() => {
|
|
171
|
+
if (_DayPicker || _rdpFailed) return;
|
|
172
|
+
let active = true;
|
|
173
|
+
void loadDayPickerDeps().then(() => {
|
|
174
|
+
if (active) rerender();
|
|
175
|
+
});
|
|
176
|
+
return () => {
|
|
177
|
+
active = false;
|
|
178
|
+
};
|
|
179
|
+
}, []);
|
|
180
|
+
return _DayPicker !== null;
|
|
137
181
|
}
|
|
138
182
|
function getCalendarClassNames() {
|
|
139
183
|
const UI = _UI;
|
|
@@ -192,6 +236,9 @@ const DatePickerRoot = React__namespace.forwardRef(function DatePickerRoot2({
|
|
|
192
236
|
name
|
|
193
237
|
}, ref) {
|
|
194
238
|
const size = index.useResolvedControlSize(sizeProp);
|
|
239
|
+
React__namespace.useEffect(() => {
|
|
240
|
+
void loadDayPickerDeps();
|
|
241
|
+
}, []);
|
|
195
242
|
const [internalSelected, setInternalSelected] = React__namespace.useState(selectedProp ?? null);
|
|
196
243
|
const [internalRange, setInternalRange] = React__namespace.useState(
|
|
197
244
|
selectedRangeProp ?? null
|
|
@@ -370,8 +417,8 @@ function DatePickerCalendar({
|
|
|
370
417
|
}),
|
|
371
418
|
[]
|
|
372
419
|
);
|
|
373
|
-
|
|
374
|
-
if (
|
|
420
|
+
const rdpReady = useDayPickerDeps();
|
|
421
|
+
if (!rdpReady || !_DayPicker || !_UI) {
|
|
375
422
|
return null;
|
|
376
423
|
}
|
|
377
424
|
const DayPicker = _DayPicker;
|
|
@@ -446,7 +493,9 @@ const DatePicker = Object.assign(DatePickerRoot, {
|
|
|
446
493
|
Trigger: DatePickerTrigger,
|
|
447
494
|
Content: DatePickerContent,
|
|
448
495
|
Calendar: DatePickerCalendar,
|
|
449
|
-
Preset: DatePickerPreset
|
|
496
|
+
Preset: DatePickerPreset,
|
|
497
|
+
/** Start resolving react-day-picker before first render (optional). */
|
|
498
|
+
preload: loadDayPickerDeps
|
|
450
499
|
});
|
|
451
500
|
exports.DatePicker = DatePicker;
|
|
452
501
|
exports.DatePickerCalendar = DatePickerCalendar;
|
package/dist/datepicker.js
CHANGED
|
@@ -101,20 +101,42 @@ let _DayPicker = null;
|
|
|
101
101
|
let _UI = null;
|
|
102
102
|
let _SelectionState = null;
|
|
103
103
|
let _DayFlag = null;
|
|
104
|
-
let
|
|
104
|
+
let _rdpLoadPromise = null;
|
|
105
105
|
let _rdpFailed = false;
|
|
106
106
|
function loadDayPickerDeps() {
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
if (!_rdpLoadPromise) {
|
|
108
|
+
_rdpLoadPromise = (async () => {
|
|
109
|
+
try {
|
|
110
|
+
const rdp = await import("react-day-picker");
|
|
111
|
+
_DayPicker = rdp.DayPicker;
|
|
112
|
+
_UI = rdp.UI;
|
|
113
|
+
_SelectionState = rdp.SelectionState;
|
|
114
|
+
_DayFlag = rdp.DayFlag;
|
|
115
|
+
} catch {
|
|
116
|
+
_rdpFailed = true;
|
|
117
|
+
if (process.env.NODE_ENV === "development") {
|
|
118
|
+
console.warn(
|
|
119
|
+
"[@usefragments/ui] DatePicker: react-day-picker is not installed. Install it with: npm install react-day-picker"
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
})();
|
|
117
124
|
}
|
|
125
|
+
return _rdpLoadPromise;
|
|
126
|
+
}
|
|
127
|
+
function useDayPickerDeps() {
|
|
128
|
+
const [, rerender] = React.useReducer((n) => n + 1, 0);
|
|
129
|
+
React.useEffect(() => {
|
|
130
|
+
if (_DayPicker || _rdpFailed) return;
|
|
131
|
+
let active = true;
|
|
132
|
+
void loadDayPickerDeps().then(() => {
|
|
133
|
+
if (active) rerender();
|
|
134
|
+
});
|
|
135
|
+
return () => {
|
|
136
|
+
active = false;
|
|
137
|
+
};
|
|
138
|
+
}, []);
|
|
139
|
+
return _DayPicker !== null;
|
|
118
140
|
}
|
|
119
141
|
function getCalendarClassNames() {
|
|
120
142
|
const UI = _UI;
|
|
@@ -173,6 +195,9 @@ const DatePickerRoot = React.forwardRef(function DatePickerRoot2({
|
|
|
173
195
|
name
|
|
174
196
|
}, ref) {
|
|
175
197
|
const size = useResolvedControlSize(sizeProp);
|
|
198
|
+
React.useEffect(() => {
|
|
199
|
+
void loadDayPickerDeps();
|
|
200
|
+
}, []);
|
|
176
201
|
const [internalSelected, setInternalSelected] = React.useState(selectedProp ?? null);
|
|
177
202
|
const [internalRange, setInternalRange] = React.useState(
|
|
178
203
|
selectedRangeProp ?? null
|
|
@@ -351,8 +376,8 @@ function DatePickerCalendar({
|
|
|
351
376
|
}),
|
|
352
377
|
[]
|
|
353
378
|
);
|
|
354
|
-
|
|
355
|
-
if (
|
|
379
|
+
const rdpReady = useDayPickerDeps();
|
|
380
|
+
if (!rdpReady || !_DayPicker || !_UI) {
|
|
356
381
|
return null;
|
|
357
382
|
}
|
|
358
383
|
const DayPicker = _DayPicker;
|
|
@@ -427,7 +452,9 @@ const DatePicker = Object.assign(DatePickerRoot, {
|
|
|
427
452
|
Trigger: DatePickerTrigger,
|
|
428
453
|
Content: DatePickerContent,
|
|
429
454
|
Calendar: DatePickerCalendar,
|
|
430
|
-
Preset: DatePickerPreset
|
|
455
|
+
Preset: DatePickerPreset,
|
|
456
|
+
/** Start resolving react-day-picker before first render (optional). */
|
|
457
|
+
preload: loadDayPickerDeps
|
|
431
458
|
});
|
|
432
459
|
export {
|
|
433
460
|
DatePicker,
|
package/dist/editor.cjs
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
3
25
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
26
|
const jsxRuntime = require("react/jsx-runtime");
|
|
5
27
|
const React = require("react");
|
|
@@ -27,22 +49,46 @@ let _useEditor = null;
|
|
|
27
49
|
let _EditorContent = null;
|
|
28
50
|
let _StarterKit = null;
|
|
29
51
|
let _LinkExtension = null;
|
|
30
|
-
let
|
|
52
|
+
let _tiptapLoadPromise = null;
|
|
31
53
|
let _tiptapFailed = false;
|
|
32
54
|
function loadTipTapDeps() {
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
if (!_tiptapLoadPromise) {
|
|
56
|
+
_tiptapLoadPromise = (async () => {
|
|
57
|
+
try {
|
|
58
|
+
const [tiptapReact, starterKit, linkExt] = await Promise.all([
|
|
59
|
+
import("@tiptap/react"),
|
|
60
|
+
import("@tiptap/starter-kit"),
|
|
61
|
+
import("@tiptap/extension-link")
|
|
62
|
+
]);
|
|
63
|
+
_useEditor = tiptapReact.useEditor;
|
|
64
|
+
_EditorContent = tiptapReact.EditorContent;
|
|
65
|
+
_StarterKit = starterKit.default ?? starterKit.StarterKit ?? starterKit;
|
|
66
|
+
_LinkExtension = linkExt.default ?? linkExt.Link ?? linkExt;
|
|
67
|
+
} catch {
|
|
68
|
+
_tiptapFailed = true;
|
|
69
|
+
if (process.env.NODE_ENV === "development") {
|
|
70
|
+
console.warn(
|
|
71
|
+
"[@usefragments/ui] Editor: TipTap is not installed; falling back to markdown mode. Install it with: npm install @tiptap/react @tiptap/starter-kit @tiptap/extension-link"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
})();
|
|
45
76
|
}
|
|
77
|
+
return _tiptapLoadPromise;
|
|
78
|
+
}
|
|
79
|
+
function useTipTapDeps() {
|
|
80
|
+
const [, rerender] = React__namespace.useReducer((n) => n + 1, 0);
|
|
81
|
+
React__namespace.useEffect(() => {
|
|
82
|
+
if (_useEditor && _EditorContent && _StarterKit || _tiptapFailed) return;
|
|
83
|
+
let active = true;
|
|
84
|
+
void loadTipTapDeps().then(() => {
|
|
85
|
+
if (active) rerender();
|
|
86
|
+
});
|
|
87
|
+
return () => {
|
|
88
|
+
active = false;
|
|
89
|
+
};
|
|
90
|
+
}, []);
|
|
91
|
+
return !_tiptapFailed && !!_useEditor && !!_EditorContent && !!_StarterKit;
|
|
46
92
|
}
|
|
47
93
|
const FORMAT_META = {
|
|
48
94
|
bold: { icon: react.TextB, label: "Bold", shortcut: keyboardShortcuts.KEYBOARD_SHORTCUTS.EDITOR_BOLD.label },
|
|
@@ -185,7 +231,12 @@ function countWords(text) {
|
|
|
185
231
|
if (!trimmed) return 0;
|
|
186
232
|
return trimmed.split(/\s+/).length;
|
|
187
233
|
}
|
|
188
|
-
function EditorRoot({
|
|
234
|
+
function EditorRoot(props) {
|
|
235
|
+
const hasTipTap = useTipTapDeps();
|
|
236
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EditorImpl, { hasTipTap, ...props }, hasTipTap ? "rich" : "markdown");
|
|
237
|
+
}
|
|
238
|
+
function EditorImpl({
|
|
239
|
+
hasTipTap,
|
|
189
240
|
children,
|
|
190
241
|
value: controlledValue,
|
|
191
242
|
defaultValue = "",
|
|
@@ -211,8 +262,6 @@ function EditorRoot({
|
|
|
211
262
|
onValueChange
|
|
212
263
|
);
|
|
213
264
|
const [saveStatus, setSaveStatus] = React__namespace.useState("idle");
|
|
214
|
-
loadTipTapDeps();
|
|
215
|
-
const hasTipTap = !_tiptapFailed && _useEditor && _EditorContent && _StarterKit;
|
|
216
265
|
const mode = hasTipTap ? "rich" : "markdown";
|
|
217
266
|
const tiptapEditor = hasTipTap ? (
|
|
218
267
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -553,6 +602,8 @@ function EditorStatusBar({ showWordCount = true, showCharCount = true, className
|
|
|
553
602
|
] });
|
|
554
603
|
}
|
|
555
604
|
const Editor = Object.assign(EditorRoot, {
|
|
605
|
+
/** Start resolving TipTap before first render (optional). */
|
|
606
|
+
preload: loadTipTapDeps,
|
|
556
607
|
Toolbar: EditorToolbar,
|
|
557
608
|
ToolbarGroup: EditorToolbarGroup,
|
|
558
609
|
ToolbarButton: EditorToolbarButton,
|
package/dist/editor.js
CHANGED
|
@@ -8,22 +8,46 @@ let _useEditor = null;
|
|
|
8
8
|
let _EditorContent = null;
|
|
9
9
|
let _StarterKit = null;
|
|
10
10
|
let _LinkExtension = null;
|
|
11
|
-
let
|
|
11
|
+
let _tiptapLoadPromise = null;
|
|
12
12
|
let _tiptapFailed = false;
|
|
13
13
|
function loadTipTapDeps() {
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
if (!_tiptapLoadPromise) {
|
|
15
|
+
_tiptapLoadPromise = (async () => {
|
|
16
|
+
try {
|
|
17
|
+
const [tiptapReact, starterKit, linkExt] = await Promise.all([
|
|
18
|
+
import("@tiptap/react"),
|
|
19
|
+
import("@tiptap/starter-kit"),
|
|
20
|
+
import("@tiptap/extension-link")
|
|
21
|
+
]);
|
|
22
|
+
_useEditor = tiptapReact.useEditor;
|
|
23
|
+
_EditorContent = tiptapReact.EditorContent;
|
|
24
|
+
_StarterKit = starterKit.default ?? starterKit.StarterKit ?? starterKit;
|
|
25
|
+
_LinkExtension = linkExt.default ?? linkExt.Link ?? linkExt;
|
|
26
|
+
} catch {
|
|
27
|
+
_tiptapFailed = true;
|
|
28
|
+
if (process.env.NODE_ENV === "development") {
|
|
29
|
+
console.warn(
|
|
30
|
+
"[@usefragments/ui] Editor: TipTap is not installed; falling back to markdown mode. Install it with: npm install @tiptap/react @tiptap/starter-kit @tiptap/extension-link"
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})();
|
|
26
35
|
}
|
|
36
|
+
return _tiptapLoadPromise;
|
|
37
|
+
}
|
|
38
|
+
function useTipTapDeps() {
|
|
39
|
+
const [, rerender] = React.useReducer((n) => n + 1, 0);
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
if (_useEditor && _EditorContent && _StarterKit || _tiptapFailed) return;
|
|
42
|
+
let active = true;
|
|
43
|
+
void loadTipTapDeps().then(() => {
|
|
44
|
+
if (active) rerender();
|
|
45
|
+
});
|
|
46
|
+
return () => {
|
|
47
|
+
active = false;
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
return !_tiptapFailed && !!_useEditor && !!_EditorContent && !!_StarterKit;
|
|
27
51
|
}
|
|
28
52
|
const FORMAT_META = {
|
|
29
53
|
bold: { icon: TextB, label: "Bold", shortcut: KEYBOARD_SHORTCUTS.EDITOR_BOLD.label },
|
|
@@ -166,7 +190,12 @@ function countWords(text) {
|
|
|
166
190
|
if (!trimmed) return 0;
|
|
167
191
|
return trimmed.split(/\s+/).length;
|
|
168
192
|
}
|
|
169
|
-
function EditorRoot({
|
|
193
|
+
function EditorRoot(props) {
|
|
194
|
+
const hasTipTap = useTipTapDeps();
|
|
195
|
+
return /* @__PURE__ */ jsx(EditorImpl, { hasTipTap, ...props }, hasTipTap ? "rich" : "markdown");
|
|
196
|
+
}
|
|
197
|
+
function EditorImpl({
|
|
198
|
+
hasTipTap,
|
|
170
199
|
children,
|
|
171
200
|
value: controlledValue,
|
|
172
201
|
defaultValue = "",
|
|
@@ -192,8 +221,6 @@ function EditorRoot({
|
|
|
192
221
|
onValueChange
|
|
193
222
|
);
|
|
194
223
|
const [saveStatus, setSaveStatus] = React.useState("idle");
|
|
195
|
-
loadTipTapDeps();
|
|
196
|
-
const hasTipTap = !_tiptapFailed && _useEditor && _EditorContent && _StarterKit;
|
|
197
224
|
const mode = hasTipTap ? "rich" : "markdown";
|
|
198
225
|
const tiptapEditor = hasTipTap ? (
|
|
199
226
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -534,6 +561,8 @@ function EditorStatusBar({ showWordCount = true, showCharCount = true, className
|
|
|
534
561
|
] });
|
|
535
562
|
}
|
|
536
563
|
const Editor = Object.assign(EditorRoot, {
|
|
564
|
+
/** Start resolving TipTap before first render (optional). */
|
|
565
|
+
preload: loadTipTapDeps,
|
|
537
566
|
Toolbar: EditorToolbar,
|
|
538
567
|
ToolbarGroup: EditorToolbarGroup,
|
|
539
568
|
ToolbarButton: EditorToolbarButton,
|