@rokkit/ui 1.3.3 → 1.3.5
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/components/index.js +63 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -0
- package/dist/markdown-plugin.js +1 -0
- package/dist/types/alert-list.js +7 -0
- package/dist/types/avatar.js +4 -0
- package/dist/types/badge.js +4 -0
- package/dist/types/breadcrumbs.js +4 -0
- package/dist/types/button.js +7 -0
- package/dist/types/card.js +4 -0
- package/dist/types/carousel.js +4 -0
- package/dist/types/chat.js +1 -0
- package/dist/types/code.js +12 -0
- package/dist/types/connector.js +8 -0
- package/dist/types/divider.js +4 -0
- package/dist/types/floating-action.js +12 -0
- package/dist/types/floating-navigation.js +1 -0
- package/dist/types/frame.js +8 -0
- package/dist/types/index.js +93 -0
- package/dist/types/item-content.js +8 -0
- package/dist/types/item-switch.js +10 -0
- package/dist/types/item-toggle.js +12 -0
- package/dist/types/list.js +36 -0
- package/dist/types/lock-mode.js +1 -0
- package/dist/types/menu.js +25 -0
- package/dist/types/message.js +4 -0
- package/dist/types/nav-content.js +4 -0
- package/dist/types/palette.js +54 -0
- package/dist/types/pill.js +4 -0
- package/dist/types/progress-bar.js +4 -0
- package/dist/types/range.js +7 -0
- package/dist/types/rating.js +4 -0
- package/dist/types/responsive-grid.js +4 -0
- package/dist/types/reveal.js +4 -0
- package/dist/types/search-filter.js +7 -0
- package/dist/types/select.js +21 -0
- package/dist/types/shine.js +7 -0
- package/dist/types/stack.js +4 -0
- package/dist/types/status-list.js +7 -0
- package/dist/types/stepper.js +4 -0
- package/dist/types/switch.js +7 -0
- package/dist/types/table.js +23 -0
- package/dist/types/tabs.js +7 -0
- package/dist/types/tilt.js +4 -0
- package/dist/types/timeline.js +14 -0
- package/dist/types/toggle.js +7 -0
- package/dist/types/toolbar.js +20 -0
- package/dist/types/tooltip.js +1 -0
- package/dist/types/tree-table.js +10 -0
- package/dist/types/tree.js +94 -0
- package/dist/types/upload-file-status.js +8 -0
- package/dist/types/upload-progress.js +8 -0
- package/dist/types/upload-target.js +7 -0
- package/dist/utils/palette.js +641 -0
- package/dist/utils/relative-time.js +17 -0
- package/dist/utils/shiki.js +118 -0
- package/package.json +13 -14
- package/src/components/index.ts +0 -63
- package/src/index.ts +0 -73
- package/src/markdown-plugin.ts +0 -12
- package/src/types/alert-list.ts +0 -28
- package/src/types/avatar.ts +0 -41
- package/src/types/badge.ts +0 -37
- package/src/types/breadcrumbs.ts +0 -43
- package/src/types/button.ts +0 -92
- package/src/types/card.ts +0 -38
- package/src/types/carousel.ts +0 -49
- package/src/types/chat.ts +0 -81
- package/src/types/code.ts +0 -147
- package/src/types/connector.ts +0 -22
- package/src/types/divider.ts +0 -20
- package/src/types/floating-action.ts +0 -123
- package/src/types/floating-navigation.ts +0 -80
- package/src/types/frame.ts +0 -29
- package/src/types/index.ts +0 -137
- package/src/types/item-content.ts +0 -26
- package/src/types/item-switch.ts +0 -34
- package/src/types/item-toggle.ts +0 -52
- package/src/types/list.ts +0 -200
- package/src/types/lock-mode.ts +0 -16
- package/src/types/menu.ts +0 -95
- package/src/types/message.ts +0 -54
- package/src/types/nav-content.ts +0 -31
- package/src/types/palette.ts +0 -160
- package/src/types/pill.ts +0 -43
- package/src/types/progress-bar.ts +0 -19
- package/src/types/range.ts +0 -51
- package/src/types/rating.ts +0 -43
- package/src/types/responsive-grid.ts +0 -25
- package/src/types/reveal.ts +0 -49
- package/src/types/search-filter.ts +0 -67
- package/src/types/select.ts +0 -176
- package/src/types/shine.ts +0 -37
- package/src/types/stack.ts +0 -40
- package/src/types/status-list.ts +0 -42
- package/src/types/stepper.ts +0 -74
- package/src/types/switch.ts +0 -68
- package/src/types/table.ts +0 -219
- package/src/types/tabs.ts +0 -103
- package/src/types/tilt.ts +0 -28
- package/src/types/timeline.ts +0 -53
- package/src/types/toggle.ts +0 -81
- package/src/types/toolbar.ts +0 -167
- package/src/types/tooltip.ts +0 -21
- package/src/types/tree-table.ts +0 -103
- package/src/types/tree.ts +0 -302
- package/src/types/upload-file-status.ts +0 -45
- package/src/types/upload-progress.ts +0 -111
- package/src/types/upload-target.ts +0 -71
- package/src/utils/palette.ts +0 -750
- package/src/utils/relative-time.ts +0 -12
- package/src/utils/shiki.ts +0 -137
- /package/{src → dist}/MarkdownRenderer.svelte +0 -0
- /package/{src → dist}/components/AlertList.svelte +0 -0
- /package/{src → dist}/components/Avatar.svelte +0 -0
- /package/{src → dist}/components/Badge.svelte +0 -0
- /package/{src → dist}/components/BreadCrumbs.svelte +0 -0
- /package/{src → dist}/components/Button.svelte +0 -0
- /package/{src → dist}/components/ButtonGroup.svelte +0 -0
- /package/{src → dist}/components/Card.svelte +0 -0
- /package/{src → dist}/components/Carousel.svelte +0 -0
- /package/{src → dist}/components/ChatComposer.svelte +0 -0
- /package/{src → dist}/components/ChatHistory.svelte +0 -0
- /package/{src → dist}/components/ChatMessage.svelte +0 -0
- /package/{src → dist}/components/ChatShell.svelte +0 -0
- /package/{src → dist}/components/ChatTimeline.svelte +0 -0
- /package/{src → dist}/components/Code.svelte +0 -0
- /package/{src → dist}/components/CodeBlock.svelte +0 -0
- /package/{src → dist}/components/CodeGroup.svelte +0 -0
- /package/{src → dist}/components/CommandPalette.svelte +0 -0
- /package/{src → dist}/components/Connector.svelte +0 -0
- /package/{src → dist}/components/Divider.svelte +0 -0
- /package/{src → dist}/components/Dropdown.svelte +0 -0
- /package/{src → dist}/components/FloatingAction.svelte +0 -0
- /package/{src → dist}/components/FloatingNavigation.svelte +0 -0
- /package/{src → dist}/components/Frame.svelte +0 -0
- /package/{src → dist}/components/Grid.svelte +0 -0
- /package/{src → dist}/components/ItemContent.svelte +0 -0
- /package/{src → dist}/components/ItemSwitch.svelte +0 -0
- /package/{src → dist}/components/ItemToggle.svelte +0 -0
- /package/{src → dist}/components/LazyTree.svelte +0 -0
- /package/{src → dist}/components/List.svelte +0 -0
- /package/{src → dist}/components/LockMode.svelte +0 -0
- /package/{src → dist}/components/Menu.svelte +0 -0
- /package/{src → dist}/components/Message.svelte +0 -0
- /package/{src → dist}/components/MultiSelect.svelte +0 -0
- /package/{src → dist}/components/NavContent.svelte +0 -0
- /package/{src → dist}/components/PaletteManager.svelte +0 -0
- /package/{src → dist}/components/Pill.svelte +0 -0
- /package/{src → dist}/components/ProgressBar.svelte +0 -0
- /package/{src → dist}/components/Range.svelte +0 -0
- /package/{src → dist}/components/Rating.svelte +0 -0
- /package/{src → dist}/components/ResponsiveGrid.svelte +0 -0
- /package/{src → dist}/components/Reveal.svelte +0 -0
- /package/{src → dist}/components/SearchFilter.svelte +0 -0
- /package/{src → dist}/components/Select.svelte +0 -0
- /package/{src → dist}/components/Shine.svelte +0 -0
- /package/{src → dist}/components/Stack.svelte +0 -0
- /package/{src → dist}/components/StatusList.svelte +0 -0
- /package/{src → dist}/components/Stepper.svelte +0 -0
- /package/{src → dist}/components/Swatch.svelte +0 -0
- /package/{src → dist}/components/Switch.svelte +0 -0
- /package/{src → dist}/components/Table.svelte +0 -0
- /package/{src → dist}/components/Tabs.svelte +0 -0
- /package/{src → dist}/components/Tilt.svelte +0 -0
- /package/{src → dist}/components/Timeline.svelte +0 -0
- /package/{src → dist}/components/Toggle.svelte +0 -0
- /package/{src → dist}/components/Toolbar.svelte +0 -0
- /package/{src → dist}/components/ToolbarGroup.svelte +0 -0
- /package/{src → dist}/components/Tooltip.svelte +0 -0
- /package/{src → dist}/components/Tree.svelte +0 -0
- /package/{src → dist}/components/TreeTable.svelte +0 -0
- /package/{src → dist}/components/UploadFileStatus.svelte +0 -0
- /package/{src → dist}/components/UploadProgress.svelte +0 -0
- /package/{src → dist}/components/UploadTarget.svelte +0 -0
- /package/{src → dist}/utils/upload.js +0 -0
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** Format an ISO timestamp as a short relative label ("5m ago"), or a clock time when relative=false. */
|
|
2
|
-
export function formatRelativeTime(timestamp: string, relative = true): string {
|
|
3
|
-
const ms = new Date(timestamp).getTime()
|
|
4
|
-
if (Number.isNaN(ms)) return ''
|
|
5
|
-
if (!relative) return new Date(ms).toLocaleTimeString()
|
|
6
|
-
const minutes = Math.round((Date.now() - ms) / 60000)
|
|
7
|
-
if (minutes < 1) return 'just now'
|
|
8
|
-
if (minutes < 60) return `${minutes}m ago`
|
|
9
|
-
const hours = Math.round(minutes / 60)
|
|
10
|
-
if (hours < 24) return `${hours}h ago`
|
|
11
|
-
return `${Math.round(hours / 24)}d ago`
|
|
12
|
-
}
|
package/src/utils/shiki.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shiki syntax highlighting utility
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { createHighlighter, type Highlighter, type BundledLanguage, type BundledTheme } from 'shiki'
|
|
6
|
-
|
|
7
|
-
let highlighter: Highlighter | null = null
|
|
8
|
-
let isInitializing = false
|
|
9
|
-
let initPromise: Promise<Highlighter> | null = null
|
|
10
|
-
|
|
11
|
-
// Supported languages for the application
|
|
12
|
-
const SUPPORTED_LANGUAGES: BundledLanguage[] = [
|
|
13
|
-
'svelte',
|
|
14
|
-
'javascript',
|
|
15
|
-
'typescript',
|
|
16
|
-
'css',
|
|
17
|
-
'html',
|
|
18
|
-
'json',
|
|
19
|
-
'bash',
|
|
20
|
-
'shell',
|
|
21
|
-
'markdown',
|
|
22
|
-
'yaml',
|
|
23
|
-
'sql'
|
|
24
|
-
]
|
|
25
|
-
|
|
26
|
-
// Available themes
|
|
27
|
-
const THEMES: BundledTheme[] = ['github-light', 'github-dark']
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Initialize Shiki highlighter (singleton)
|
|
31
|
-
*/
|
|
32
|
-
function initializeHighlighter(): Promise<Highlighter> {
|
|
33
|
-
if (highlighter) return Promise.resolve(highlighter)
|
|
34
|
-
|
|
35
|
-
if (isInitializing && initPromise) {
|
|
36
|
-
return initPromise
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
isInitializing = true
|
|
40
|
-
|
|
41
|
-
initPromise = createHighlighter({
|
|
42
|
-
themes: THEMES,
|
|
43
|
-
langs: SUPPORTED_LANGUAGES
|
|
44
|
-
})
|
|
45
|
-
.then((hl: Highlighter) => {
|
|
46
|
-
highlighter = hl
|
|
47
|
-
isInitializing = false
|
|
48
|
-
return hl
|
|
49
|
-
})
|
|
50
|
-
.catch((error: Error) => {
|
|
51
|
-
/* v8 ignore next 3 -- createHighlighter failure not reachable in test env (singleton already initialized) */
|
|
52
|
-
isInitializing = false
|
|
53
|
-
initPromise = null
|
|
54
|
-
throw error
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
return initPromise
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface HighlightOptions {
|
|
61
|
-
/** Language for syntax highlighting */
|
|
62
|
-
lang?: BundledLanguage | string
|
|
63
|
-
/** Theme to use (defaults based on user preference) */
|
|
64
|
-
theme?: BundledTheme | 'light' | 'dark'
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Highlight code using Shiki
|
|
69
|
-
*
|
|
70
|
-
* @param code - The code to highlight
|
|
71
|
-
* @param options - Highlighting options
|
|
72
|
-
* @returns The highlighted code as HTML
|
|
73
|
-
*/
|
|
74
|
-
function resolveTheme(themeOption: string | undefined): BundledTheme {
|
|
75
|
-
if (themeOption === 'light') return 'github-light'
|
|
76
|
-
if (themeOption === 'dark' || !themeOption) return 'github-dark'
|
|
77
|
-
return themeOption as BundledTheme
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Map fence languages (used by @rokkit/blocks plugins) to a Shiki-known
|
|
82
|
-
* grammar. The fence is *semantic* (the renderer routes by language name),
|
|
83
|
-
* but the body is plain JSON — highlight it as such instead of falling
|
|
84
|
-
* back to unstyled text.
|
|
85
|
-
*/
|
|
86
|
-
const LANGUAGE_ALIASES: Record<string, BundledLanguage> = {
|
|
87
|
-
plot: 'json',
|
|
88
|
-
table: 'json',
|
|
89
|
-
form: 'json',
|
|
90
|
-
list: 'json',
|
|
91
|
-
stepper: 'json',
|
|
92
|
-
sparkline: 'json',
|
|
93
|
-
chart: 'json'
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function resolveLang(input: string | undefined): BundledLanguage {
|
|
97
|
-
if (!input) return 'text' as BundledLanguage
|
|
98
|
-
return (LANGUAGE_ALIASES[input] ?? input) as BundledLanguage
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function isValidCode(code: unknown): code is string {
|
|
102
|
-
return Boolean(code) && typeof code === 'string'
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export async function highlightCode(code: string, options: HighlightOptions = {}): Promise<string> {
|
|
106
|
-
if (!isValidCode(code)) throw new Error('Invalid code provided for highlighting')
|
|
107
|
-
|
|
108
|
-
const hl = await initializeHighlighter()
|
|
109
|
-
const lang = resolveLang(options.lang as string | undefined)
|
|
110
|
-
const theme = resolveTheme(options.theme)
|
|
111
|
-
const loadedLangs = hl.getLoadedLanguages()
|
|
112
|
-
const effectiveLang = loadedLangs.includes(lang) ? lang : 'text'
|
|
113
|
-
|
|
114
|
-
return hl
|
|
115
|
-
.codeToHtml(code, { lang: effectiveLang, theme })
|
|
116
|
-
.replace(/(<pre[^>]+) style="[^"]*"/, '$1')
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Preload the syntax highlighter for faster initial rendering
|
|
121
|
-
* Errors are silently ignored since preloading is optional
|
|
122
|
-
*/
|
|
123
|
-
export async function preloadHighlighter(): Promise<void> {
|
|
124
|
-
try {
|
|
125
|
-
await initializeHighlighter()
|
|
126
|
-
/* v8 ignore next 3 -- preload catch body unreachable in tests (singleton already initialized) */
|
|
127
|
-
} catch {
|
|
128
|
-
// Preload failures are non-critical - highlighting will still work on demand
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Get list of supported languages
|
|
134
|
-
*/
|
|
135
|
-
export function getSupportedLanguages(): readonly string[] {
|
|
136
|
-
return SUPPORTED_LANGUAGES
|
|
137
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|