nuvox 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -21,11 +21,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  DEFAULT_COLOR_PRESETS: () => DEFAULT_PRESETS,
24
+ DRAG_START_THRESHOLD_PX: () => DRAG_START_THRESHOLD_PX,
25
+ LABELED_SKIP_SECONDS: () => LABELED_SKIP_SECONDS,
24
26
  LANGUAGE_LABELS: () => LANGUAGE_LABELS,
27
+ PLAYBACK_RATES: () => PLAYBACK_RATES,
25
28
  REQUIRED_TOKEN_PATHS: () => REQUIRED_TOKEN_PATHS,
29
+ SKIP_SECONDS: () => SKIP_SECONDS,
26
30
  TOKEN_CATEGORIES: () => TOKEN_CATEGORIES,
27
31
  amber: () => amber,
32
+ aspectRatioFromDims: () => aspectRatioFromDims,
28
33
  brutalism: () => brutalism,
34
+ computeColumnDropIndex: () => computeColumnDropIndex,
35
+ computeDropColumn: () => computeDropColumn,
36
+ computeDropIndex: () => computeDropIndex,
37
+ computeJustifiedRows: () => computeJustifiedRows,
29
38
  copper: () => copper,
30
39
  createHistory: () => createHistory,
31
40
  cyberpunk: () => cyberpunk,
@@ -34,15 +43,23 @@ __export(src_exports, {
34
43
  defineTheme: () => defineTheme,
35
44
  emerald: () => emerald,
36
45
  execRichTextCommand: () => execRichTextCommand,
46
+ findCardLocation: () => findCardLocation,
37
47
  findMissingTokenPaths: () => findMissingTokenPaths,
48
+ formatMediaTime: () => formatMediaTime,
49
+ formatZoomPercent: () => formatZoomPercent,
38
50
  getAccent: () => getAccent,
39
51
  getActiveCommands: () => getActiveCommands,
52
+ getAdjacentColumnId: () => getAdjacentColumnId,
53
+ getColumnKeyboardMoveTarget: () => getColumnKeyboardMoveTarget,
54
+ getKeyboardMoveTarget: () => getKeyboardMoveTarget,
55
+ getMediaKeyAction: () => getMediaKeyAction,
40
56
  getNextSortDirection: () => getNextSortDirection,
41
57
  getSelectAllState: () => getSelectAllState,
42
58
  getTheme: () => getTheme,
43
59
  glass: () => glass,
44
60
  gradient: () => gradient,
45
61
  graphite: () => graphite,
62
+ hasLabeledSkipIcon: () => hasLabeledSkipIcon,
46
63
  indigo: () => indigo,
47
64
  light: () => light,
48
65
  listAccents: () => listAccents,
@@ -50,12 +67,18 @@ __export(src_exports, {
50
67
  magenta: () => magenta,
51
68
  material: () => material,
52
69
  minimalism: () => minimalism,
70
+ moveCard: () => moveCard,
71
+ moveColumn: () => moveColumn,
53
72
  neobrutalism: () => neobrutalism,
54
73
  nuvoxHighlight: () => nuvoxHighlight,
55
74
  pushHistory: () => pushHistory,
56
75
  redoHistory: () => redoHistory,
57
76
  registerAccent: () => registerAccent,
58
77
  registerTheme: () => registerTheme,
78
+ removeCard: () => removeCard,
79
+ removeColumn: () => removeColumn,
80
+ resolveMediaTransport: () => resolveMediaTransport,
81
+ resolveSkipSeconds: () => resolveSkipSeconds,
59
82
  rose: () => rose,
60
83
  sanitizeHtml: () => sanitizeHtml,
61
84
  skeuomorphism: () => skeuomorphism,
@@ -222,7 +245,7 @@ var light = defineTheme({
222
245
  "2xl": "0 28px 56px rgba(0,0,0,0.16)",
223
246
  inner: "inset 0 1px 2px rgba(0,0,0,0.05)"
224
247
  },
225
- elevation: { dropdown: 1e3, popover: 1100, modal: 1200, toast: 1300, tooltip: 1400 },
248
+ elevation: { dropdown: 1050, popover: 1060, modal: 1e3, toast: 1200, tooltip: 1100 },
226
249
  motion: {
227
250
  durationFast: "120ms",
228
251
  durationNormal: "200ms",
@@ -295,7 +318,7 @@ var dark = defineTheme({
295
318
  "2xl": "0 28px 56px rgba(0,0,0,0.65)",
296
319
  inner: "inset 0 1px 2px rgba(0,0,0,0.4)"
297
320
  },
298
- elevation: { dropdown: 1e3, popover: 1100, modal: 1200, toast: 1300, tooltip: 1400 },
321
+ elevation: { dropdown: 1050, popover: 1060, modal: 1e3, toast: 1200, tooltip: 1100 },
299
322
  motion: {
300
323
  durationFast: "120ms",
301
324
  durationNormal: "200ms",
@@ -379,7 +402,7 @@ var glass = defineTheme({
379
402
  "2xl": "0 32px 80px rgba(0,0,0,0.18)",
380
403
  inner: "inset 0 1px 0 rgba(255,255,255,0.4)"
381
404
  },
382
- elevation: { dropdown: 1e3, popover: 1100, modal: 1200, toast: 1300, tooltip: 1400 },
405
+ elevation: { dropdown: 1050, popover: 1060, modal: 1e3, toast: 1200, tooltip: 1100 },
383
406
  motion: {
384
407
  // Slightly slower/softer than light/dark — matches "everything floats".
385
408
  durationFast: "160ms",
@@ -900,6 +923,106 @@ function getSelectAllState(totalCount, selectedCount) {
900
923
  return "some";
901
924
  }
902
925
 
926
+ // src/core/kanban.ts
927
+ var DRAG_START_THRESHOLD_PX = 4;
928
+ function findCardLocation(value, cardId) {
929
+ for (const column of value.columns) {
930
+ const index = column.cardIds.indexOf(cardId);
931
+ if (index !== -1) return { columnId: column.id, index };
932
+ }
933
+ return null;
934
+ }
935
+ function removeCard(value, cardId) {
936
+ const location = findCardLocation(value, cardId);
937
+ if (!location) return value;
938
+ return {
939
+ columns: value.columns.map(
940
+ (column) => column.id === location.columnId ? { ...column, cardIds: column.cardIds.filter((id) => id !== cardId) } : column
941
+ )
942
+ };
943
+ }
944
+ function moveCard(value, target) {
945
+ const location = findCardLocation(value, target.cardId);
946
+ const destExists = value.columns.some((column) => column.id === target.toColumnId);
947
+ if (!location || !destExists) return value;
948
+ const withoutCard = value.columns.map(
949
+ (column) => column.cardIds.includes(target.cardId) ? { ...column, cardIds: column.cardIds.filter((id) => id !== target.cardId) } : column
950
+ );
951
+ return {
952
+ columns: withoutCard.map((column) => {
953
+ if (column.id !== target.toColumnId) return column;
954
+ const clampedIndex = Math.max(0, Math.min(target.toIndex, column.cardIds.length));
955
+ const cardIds = [...column.cardIds];
956
+ cardIds.splice(clampedIndex, 0, target.cardId);
957
+ return { ...column, cardIds };
958
+ })
959
+ };
960
+ }
961
+ function getAdjacentColumnId(value, columnId, direction) {
962
+ const index = value.columns.findIndex((column) => column.id === columnId);
963
+ if (index === -1) return null;
964
+ return value.columns[index + direction]?.id ?? null;
965
+ }
966
+ function getKeyboardMoveTarget(value, cardId, direction) {
967
+ const location = findCardLocation(value, cardId);
968
+ if (!location) return null;
969
+ const column = value.columns.find((c) => c.id === location.columnId);
970
+ if (!column) return null;
971
+ if (direction === "up" || direction === "down") {
972
+ const toIndex2 = direction === "up" ? location.index - 1 : location.index + 1;
973
+ if (toIndex2 < 0 || toIndex2 > column.cardIds.length - 1) return null;
974
+ return { cardId, toColumnId: location.columnId, toIndex: toIndex2 };
975
+ }
976
+ const adjacentColumnId = getAdjacentColumnId(value, location.columnId, direction === "prev" ? -1 : 1);
977
+ if (!adjacentColumnId) return null;
978
+ const destColumn = value.columns.find((c) => c.id === adjacentColumnId);
979
+ if (!destColumn) return null;
980
+ const toIndex = Math.min(location.index, destColumn.cardIds.length);
981
+ return { cardId, toColumnId: adjacentColumnId, toIndex };
982
+ }
983
+ function computeDropIndex(pointerY, cardRects) {
984
+ for (let i = 0; i < cardRects.length; i++) {
985
+ const midpoint = (cardRects[i].top + cardRects[i].bottom) / 2;
986
+ if (pointerY < midpoint) return i;
987
+ }
988
+ return cardRects.length;
989
+ }
990
+ function computeDropColumn(pointerX, pointerY, columns) {
991
+ for (const column of columns) {
992
+ if (pointerX >= column.left && pointerX <= column.right && pointerY >= column.top && pointerY <= column.bottom) {
993
+ return column.id;
994
+ }
995
+ }
996
+ return null;
997
+ }
998
+ function moveColumn(value, target) {
999
+ const fromIndex = value.columns.findIndex((c) => c.id === target.columnId);
1000
+ if (fromIndex === -1) return value;
1001
+ const columns = [...value.columns];
1002
+ const [moved] = columns.splice(fromIndex, 1);
1003
+ const clampedIndex = Math.max(0, Math.min(target.toIndex, columns.length));
1004
+ columns.splice(clampedIndex, 0, moved);
1005
+ return { columns };
1006
+ }
1007
+ function removeColumn(value, columnId) {
1008
+ if (!value.columns.some((c) => c.id === columnId)) return value;
1009
+ return { columns: value.columns.filter((c) => c.id !== columnId) };
1010
+ }
1011
+ function getColumnKeyboardMoveTarget(value, columnId, direction) {
1012
+ const fromIndex = value.columns.findIndex((c) => c.id === columnId);
1013
+ if (fromIndex === -1) return null;
1014
+ const toIndex = direction === "prev" ? fromIndex - 1 : fromIndex + 1;
1015
+ if (toIndex < 0 || toIndex > value.columns.length - 1) return null;
1016
+ return { columnId, toIndex };
1017
+ }
1018
+ function computeColumnDropIndex(pointerX, columnRects) {
1019
+ for (let i = 0; i < columnRects.length; i++) {
1020
+ const midpoint = (columnRects[i].left + columnRects[i].right) / 2;
1021
+ if (pointerX < midpoint) return i;
1022
+ }
1023
+ return columnRects.length;
1024
+ }
1025
+
903
1026
  // src/core/code-highlight.ts
904
1027
  function tokenizeFlat(source, grammar) {
905
1028
  const tokens = [];
@@ -1601,14 +1724,121 @@ function redoHistory(history, currentValue) {
1601
1724
  value
1602
1725
  };
1603
1726
  }
1727
+
1728
+ // src/core/gallery.ts
1729
+ function aspectRatioFromDims(width, height) {
1730
+ if (!width || !height || width <= 0 || height <= 0) return 1;
1731
+ return width / height;
1732
+ }
1733
+ function computeJustifiedRows(aspectRatios, containerWidth, targetRowHeight, gap) {
1734
+ if (aspectRatios.length === 0 || containerWidth <= 0 || targetRowHeight <= 0) return [];
1735
+ const rows = [];
1736
+ let rowIndices = [];
1737
+ let rowNaturalWidths = [];
1738
+ let rowWidthSum = 0;
1739
+ function flushRow(scale) {
1740
+ if (rowIndices.length === 0) return;
1741
+ const gapsWidth = gap * (rowIndices.length - 1);
1742
+ const availableWidth = containerWidth - gapsWidth;
1743
+ const naturalTotal = rowWidthSum;
1744
+ const scaleFactor = scale ? availableWidth / naturalTotal : 1;
1745
+ rows.push({
1746
+ indices: rowIndices,
1747
+ height: targetRowHeight * scaleFactor,
1748
+ widths: rowNaturalWidths.map((w) => w * scaleFactor)
1749
+ });
1750
+ rowIndices = [];
1751
+ rowNaturalWidths = [];
1752
+ rowWidthSum = 0;
1753
+ }
1754
+ for (let i = 0; i < aspectRatios.length; i++) {
1755
+ const naturalWidth = aspectRatios[i] * targetRowHeight;
1756
+ const gapsWidth = gap * rowIndices.length;
1757
+ if (rowIndices.length > 0 && rowWidthSum + naturalWidth + gapsWidth > containerWidth) {
1758
+ flushRow(true);
1759
+ }
1760
+ rowIndices.push(i);
1761
+ rowNaturalWidths.push(naturalWidth);
1762
+ rowWidthSum += naturalWidth;
1763
+ }
1764
+ const finalGapsWidth = gap * (rowIndices.length - 1);
1765
+ const overflows = rowWidthSum + finalGapsWidth > containerWidth;
1766
+ flushRow(overflows);
1767
+ return rows;
1768
+ }
1769
+
1770
+ // src/core/media.ts
1771
+ var PLAYBACK_RATES = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
1772
+ function formatMediaTime(seconds) {
1773
+ if (!Number.isFinite(seconds) || seconds < 0) return "0:00";
1774
+ const total = Math.floor(seconds);
1775
+ const h = Math.floor(total / 3600);
1776
+ const m = Math.floor(total % 3600 / 60);
1777
+ const s = total % 60;
1778
+ const paddedS = String(s).padStart(2, "0");
1779
+ if (h > 0) return `${h}:${String(m).padStart(2, "0")}:${paddedS}`;
1780
+ return `${m}:${paddedS}`;
1781
+ }
1782
+ var SKIP_SECONDS = 10;
1783
+ var LABELED_SKIP_SECONDS = [5, 10, 15, 30];
1784
+ function hasLabeledSkipIcon(seconds) {
1785
+ return LABELED_SKIP_SECONDS.includes(seconds);
1786
+ }
1787
+ function resolveSkipSeconds(skipSeconds) {
1788
+ if (skipSeconds === void 0) return SKIP_SECONDS;
1789
+ if (!Number.isFinite(skipSeconds) || skipSeconds <= 0) return SKIP_SECONDS;
1790
+ return skipSeconds;
1791
+ }
1792
+ function resolveMediaTransport(props) {
1793
+ const showNext = props.onNext !== void 0;
1794
+ const showPrevious = props.onPrevious !== void 0;
1795
+ return {
1796
+ skipSeconds: resolveSkipSeconds(props.skipSeconds),
1797
+ showNext,
1798
+ showPrevious,
1799
+ nextDisabled: showNext && (props.hasNext ?? true) === false,
1800
+ previousDisabled: showPrevious && (props.hasPrevious ?? true) === false
1801
+ };
1802
+ }
1803
+ function getMediaKeyAction(key) {
1804
+ switch (key) {
1805
+ case " ":
1806
+ case "Spacebar":
1807
+ return "toggle-play";
1808
+ case "ArrowLeft":
1809
+ return "seek-back";
1810
+ case "ArrowRight":
1811
+ return "seek-forward";
1812
+ case "ArrowUp":
1813
+ return "volume-up";
1814
+ case "ArrowDown":
1815
+ return "volume-down";
1816
+ default:
1817
+ return null;
1818
+ }
1819
+ }
1820
+
1821
+ // src/core/pdf-viewer.ts
1822
+ function formatZoomPercent(scale) {
1823
+ return scale === "auto" ? "Fit" : `${Math.round(scale * 100)}%`;
1824
+ }
1604
1825
  // Annotate the CommonJS export names for ESM import in node:
1605
1826
  0 && (module.exports = {
1606
1827
  DEFAULT_COLOR_PRESETS,
1828
+ DRAG_START_THRESHOLD_PX,
1829
+ LABELED_SKIP_SECONDS,
1607
1830
  LANGUAGE_LABELS,
1831
+ PLAYBACK_RATES,
1608
1832
  REQUIRED_TOKEN_PATHS,
1833
+ SKIP_SECONDS,
1609
1834
  TOKEN_CATEGORIES,
1610
1835
  amber,
1836
+ aspectRatioFromDims,
1611
1837
  brutalism,
1838
+ computeColumnDropIndex,
1839
+ computeDropColumn,
1840
+ computeDropIndex,
1841
+ computeJustifiedRows,
1612
1842
  copper,
1613
1843
  createHistory,
1614
1844
  cyberpunk,
@@ -1617,15 +1847,23 @@ function redoHistory(history, currentValue) {
1617
1847
  defineTheme,
1618
1848
  emerald,
1619
1849
  execRichTextCommand,
1850
+ findCardLocation,
1620
1851
  findMissingTokenPaths,
1852
+ formatMediaTime,
1853
+ formatZoomPercent,
1621
1854
  getAccent,
1622
1855
  getActiveCommands,
1856
+ getAdjacentColumnId,
1857
+ getColumnKeyboardMoveTarget,
1858
+ getKeyboardMoveTarget,
1859
+ getMediaKeyAction,
1623
1860
  getNextSortDirection,
1624
1861
  getSelectAllState,
1625
1862
  getTheme,
1626
1863
  glass,
1627
1864
  gradient,
1628
1865
  graphite,
1866
+ hasLabeledSkipIcon,
1629
1867
  indigo,
1630
1868
  light,
1631
1869
  listAccents,
@@ -1633,12 +1871,18 @@ function redoHistory(history, currentValue) {
1633
1871
  magenta,
1634
1872
  material,
1635
1873
  minimalism,
1874
+ moveCard,
1875
+ moveColumn,
1636
1876
  neobrutalism,
1637
1877
  nuvoxHighlight,
1638
1878
  pushHistory,
1639
1879
  redoHistory,
1640
1880
  registerAccent,
1641
1881
  registerTheme,
1882
+ removeCard,
1883
+ removeColumn,
1884
+ resolveMediaTransport,
1885
+ resolveSkipSeconds,
1642
1886
  rose,
1643
1887
  sanitizeHtml,
1644
1888
  skeuomorphism,