sqlite-hub 2.1.0 → 2.2.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.
@@ -1586,6 +1586,23 @@ function renderDeleteDocumentForm(modal) {
1586
1586
  ].join('');
1587
1587
  }
1588
1588
 
1589
+ function renderCreateDocumentFolderForm(modal) {
1590
+ return [
1591
+ '<form class="space-y-5" data-form="create-document-folder"><label class="block space-y-2">',
1592
+ '<span class="text-[10px] font-mono uppercase tracking-[0.22em] text-on-surface-variant/60">Folder Name</span>',
1593
+ '<input class="control-input w-full border border-outline-variant/20 bg-surface-container-lowest text-sm text-on-surface outline-none transition-colors placeholder:text-on-surface-variant/35 focus:border-primary-container" name="name" type="text" autocomplete="off" maxlength="80" value="',
1594
+ escapeHtml(modal.name ?? ''),
1595
+ '" autofocus />',
1596
+ '</label>',
1597
+ renderError(modal.error),
1598
+ '<div class="flex items-center justify-between gap-3 pt-2">',
1599
+ '<button class="standard-button" data-action="close-modal" type="button">Cancel</button>',
1600
+ '<button class="signature-button" type="submit">',
1601
+ modal.submitting ? 'Creating...' : 'Create Folder',
1602
+ '</button></div></form>',
1603
+ ].join('');
1604
+ }
1605
+
1589
1606
  export function renderDeleteApiTokenForm(modal) {
1590
1607
  return [
1591
1608
  '<form class="space-y-5" data-form="delete-api-token-confirm"><div class="space-y-3">',
@@ -1720,13 +1737,136 @@ function renderDocumentInsertNoteForm(modal) {
1720
1737
  <div class="flex items-center justify-between gap-3 pt-2">
1721
1738
  <button class="standard-button" data-action="close-modal" type="button">Cancel</button>
1722
1739
  <button class="signature-button" type="submit" ${disabledAttribute}>
1723
- ${modal.submitting ? 'Inserting...' : 'Insert Note'}
1740
+ ${modal.submitting ? 'Inserting...' : 'Insert Query Note'}
1724
1741
  </button>
1725
1742
  </div>
1726
1743
  </form>
1727
1744
  `;
1728
1745
  }
1729
1746
 
1747
+ function renderDocumentTableDefinitionSelect(modal) {
1748
+ const tables = (modal.tables ?? []).filter(table => !table.isShadow && table.tableKind !== 'shadow');
1749
+
1750
+ if (modal.loading) {
1751
+ return '<div class="border border-outline-variant/10 bg-surface-container-lowest px-4 py-3 text-sm text-on-surface-variant/65">Loading tables...</div>';
1752
+ }
1753
+
1754
+ if (!tables.length) {
1755
+ return '<div class="border border-outline-variant/10 bg-surface-container-lowest px-4 py-3 text-sm text-on-surface-variant/65">No regular or virtual tables are available for this database.</div>';
1756
+ }
1757
+
1758
+ return `
1759
+ <label class="block space-y-2">
1760
+ <span class="text-[10px] font-mono uppercase tracking-[0.22em] text-on-surface-variant/60">
1761
+ Table
1762
+ </span>
1763
+ <select
1764
+ class="control-select w-full border border-outline-variant/20 bg-surface-container-lowest text-sm text-on-surface outline-none transition-colors focus:border-primary-container"
1765
+ data-bind="document-table-definition-select"
1766
+ name="tableName"
1767
+ >
1768
+ ${tables
1769
+ .map(table => {
1770
+ const label = table.isVirtual || table.tableKind === 'virtual'
1771
+ ? `${table.name} (virtual)`
1772
+ : table.name;
1773
+
1774
+ return `
1775
+ <option
1776
+ value="${escapeHtml(table.name)}"
1777
+ ${String(table.name) === String(modal.selectedTableName) ? 'selected' : ''}
1778
+ >
1779
+ ${escapeHtml(label)}
1780
+ </option>
1781
+ `;
1782
+ })
1783
+ .join('')}
1784
+ </select>
1785
+ </label>
1786
+ `;
1787
+ }
1788
+
1789
+ function renderDocumentTableDefinitionCheckbox({ label, option, checked, disabled }) {
1790
+ return `
1791
+ <label class="standard-checkbox ${disabled ? 'is-disabled' : ''}">
1792
+ <input
1793
+ data-bind="document-table-definition-option"
1794
+ data-option="${escapeHtml(option)}"
1795
+ name="${escapeHtml(option)}"
1796
+ type="checkbox"
1797
+ ${checked ? 'checked' : ''}
1798
+ ${disabled ? 'disabled' : ''}
1799
+ />
1800
+ <span>${escapeHtml(label)}</span>
1801
+ </label>
1802
+ `;
1803
+ }
1804
+
1805
+ function renderDocumentInsertTableDefinitionForm(modal) {
1806
+ const hasTables = Boolean((modal.tables ?? []).length);
1807
+ const optionDisabled = modal.loading || modal.submitting || !hasTables;
1808
+ const hasSelection = Boolean(modal.markdownTable || modal.sqlDefinition || modal.sampleData);
1809
+ const disabledAttribute = optionDisabled || !hasSelection ? 'disabled aria-disabled="true"' : '';
1810
+
1811
+ return `
1812
+ <form class="space-y-5" data-form="document-insert-table-definition">
1813
+ ${renderDocumentTableDefinitionSelect(modal)}
1814
+ <div class="grid gap-2">
1815
+ ${renderDocumentTableDefinitionCheckbox({
1816
+ label: 'Markdown Table',
1817
+ option: 'markdownTable',
1818
+ checked: Boolean(modal.markdownTable),
1819
+ disabled: optionDisabled,
1820
+ })}
1821
+ ${renderDocumentTableDefinitionCheckbox({
1822
+ label: 'SQL Definition',
1823
+ option: 'sqlDefinition',
1824
+ checked: Boolean(modal.sqlDefinition),
1825
+ disabled: optionDisabled,
1826
+ })}
1827
+ ${renderDocumentTableDefinitionCheckbox({
1828
+ label: 'Sample Data',
1829
+ option: 'sampleData',
1830
+ checked: Boolean(modal.sampleData),
1831
+ disabled: optionDisabled,
1832
+ })}
1833
+ </div>
1834
+ ${
1835
+ modal.sampleData
1836
+ ? `
1837
+ <label class="block space-y-2">
1838
+ <span class="text-[10px] font-mono uppercase tracking-[0.22em] text-on-surface-variant/60">
1839
+ Sample Rows
1840
+ </span>
1841
+ <select
1842
+ class="control-select w-full border border-outline-variant/20 bg-surface-container-lowest text-sm text-on-surface outline-none transition-colors focus:border-primary-container"
1843
+ data-bind="document-table-definition-row-count"
1844
+ name="sampleRowCount"
1845
+ ${optionDisabled ? 'disabled' : ''}
1846
+ >
1847
+ ${[3, 5, 10]
1848
+ .map(count => `
1849
+ <option value="${count}" ${Number(modal.sampleRowCount ?? 5) === count ? 'selected' : ''}>
1850
+ ${count}
1851
+ </option>
1852
+ `)
1853
+ .join('')}
1854
+ </select>
1855
+ </label>
1856
+ `
1857
+ : ''
1858
+ }
1859
+ ${renderError(modal.error)}
1860
+ <div class="flex items-center justify-between gap-3 pt-2">
1861
+ <button class="standard-button" data-action="close-modal" type="button">Cancel</button>
1862
+ <button class="signature-button" type="submit" ${disabledAttribute}>
1863
+ ${modal.submitting ? 'Inserting...' : 'Insert Table Definition'}
1864
+ </button>
1865
+ </div>
1866
+ </form>
1867
+ `;
1868
+ }
1869
+
1730
1870
  function renderQueryExportPreview(lines = []) {
1731
1871
  return lines.map(line => `<span class="block whitespace-pre">${escapeHtml(line)}</span>`).join('');
1732
1872
  }
@@ -2255,6 +2395,11 @@ export function renderModal(state) {
2255
2395
  title: 'Delete Document',
2256
2396
  body: renderDeleteDocumentForm(modal),
2257
2397
  },
2398
+ 'create-document-folder': {
2399
+ eyebrow: 'Documents // New folder',
2400
+ title: 'New Folder',
2401
+ body: renderCreateDocumentFolderForm(modal),
2402
+ },
2258
2403
  'delete-api-token': {
2259
2404
  eyebrow: 'Settings // Confirm token deletion',
2260
2405
  title: 'Delete API Token',
@@ -2267,9 +2412,14 @@ export function renderModal(state) {
2267
2412
  },
2268
2413
  'document-insert-note': {
2269
2414
  eyebrow: 'Documents // Saved query notes',
2270
- title: 'Insert Note',
2415
+ title: 'Insert Query Note',
2271
2416
  body: renderDocumentInsertNoteForm(modal),
2272
2417
  },
2418
+ 'document-insert-table-definition': {
2419
+ eyebrow: 'Documents // Table definition',
2420
+ title: 'Insert Table Definition',
2421
+ body: renderDocumentInsertTableDefinitionForm(modal),
2422
+ },
2273
2423
  'query-export': {
2274
2424
  eyebrow: 'SQL Editor // Export query result',
2275
2425
  title: 'Export Query',