@vendure-io/ui 2.0.0-beta.8 → 2.0.0-rc.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.md +34 -0
- package/package.json +8 -6
- package/src/components/atoms/alert-dialog.tsx +1 -1
- package/src/components/atoms/alert.tsx +1 -1
- package/src/components/atoms/badge.tsx +1 -1
- package/src/components/atoms/button.tsx +2 -2
- package/src/components/atoms/card.tsx +39 -4
- package/src/components/atoms/checkbox.tsx +1 -1
- package/src/components/atoms/combobox.tsx +24 -5
- package/src/components/atoms/command.tsx +16 -5
- package/src/components/atoms/context-menu.tsx +1 -1
- package/src/components/atoms/dialog.tsx +1 -1
- package/src/components/atoms/drawer.tsx +134 -35
- package/src/components/atoms/dropdown-menu.tsx +1 -1
- package/src/components/atoms/field.tsx +2 -2
- package/src/components/atoms/input.tsx +1 -1
- package/src/components/atoms/item.tsx +4 -1
- package/src/components/atoms/menubar.tsx +1 -1
- package/src/components/atoms/native-select.tsx +1 -1
- package/src/components/atoms/navigation-menu.tsx +8 -2
- package/src/components/atoms/progress.tsx +1 -1
- package/src/components/atoms/radio-group.tsx +1 -1
- package/src/components/atoms/scroll-area.tsx +1 -2
- package/src/components/atoms/select.tsx +1 -1
- package/src/components/atoms/sheet.tsx +1 -1
- package/src/components/atoms/sidebar.tsx +6 -4
- package/src/components/atoms/slider.tsx +2 -2
- package/src/components/atoms/switch.tsx +1 -1
- package/src/components/atoms/table.tsx +34 -2
- package/src/components/atoms/tabs.tsx +64 -1
- package/src/components/atoms/textarea.tsx +1 -1
- package/src/components/atoms/toggle-group.tsx +1 -1
- package/src/components/atoms/toggle.tsx +5 -2
- package/src/components/molecules/chip.tsx +7 -2
- package/src/components/molecules/code-block/file-type-icons.tsx +123 -0
- package/src/components/molecules/code-block/process-code.ts +60 -0
- package/src/components/molecules/code-block/transform-command.tsx +177 -0
- package/src/components/molecules/code-block.tsx +29 -575
- package/src/components/molecules/combobox-free-text.tsx +23 -2
- package/src/components/molecules/copyable-text.tsx +14 -1
- package/src/components/molecules/data-table/data-table-bulk-actions.tsx +12 -13
- package/src/components/molecules/data-table/data-table-types.tsx +50 -2
- package/src/components/molecules/data-table/data-table-view-options.tsx +2 -1
- package/src/components/molecules/data-table/data-table.tsx +188 -96
- package/src/components/molecules/date-picker.tsx +3 -1
- package/src/components/molecules/date-range-picker.tsx +3 -1
- package/src/components/molecules/date-time-picker.tsx +3 -1
- package/src/components/molecules/file-dropzone.tsx +15 -5
- package/src/components/molecules/illustrations/empty-database.tsx +8 -5
- package/src/components/molecules/illustrations/error.tsx +19 -17
- package/src/components/molecules/illustrations/expired.tsx +55 -0
- package/src/components/molecules/illustrations/first-run.tsx +3 -1
- package/src/components/molecules/illustrations/no-activity.tsx +35 -14
- package/src/components/molecules/illustrations/no-customers.tsx +66 -0
- package/src/components/molecules/illustrations/no-documents.tsx +4 -3
- package/src/components/molecules/illustrations/no-invoices.tsx +45 -0
- package/src/components/molecules/illustrations/no-notifications.tsx +7 -8
- package/src/components/molecules/illustrations/no-orders.tsx +25 -17
- package/src/components/molecules/illustrations/no-plugins.tsx +21 -31
- package/src/components/molecules/illustrations/no-products.tsx +53 -0
- package/src/components/molecules/illustrations/no-projects.tsx +54 -0
- package/src/components/molecules/illustrations/no-promotions.tsx +49 -0
- package/src/components/molecules/illustrations/no-subscription.tsx +72 -0
- package/src/components/molecules/illustrations/not-found.tsx +17 -15
- package/src/components/molecules/illustrations/offline.tsx +12 -10
- package/src/components/molecules/illustrations/payment-failed.tsx +53 -0
- package/src/components/molecules/illustrations/success.tsx +43 -0
- package/src/components/molecules/inline-code.tsx +26 -0
- package/src/components/molecules/page-header.tsx +7 -3
- package/src/components/molecules/stat-card.tsx +13 -12
- package/src/components/molecules/state-views/empty-state.tsx +12 -1
- package/src/components/molecules/state-views/loading-state.tsx +7 -3
- package/src/lib/highlight.ts +177 -0
- package/src/lib/state-dictionary.ts +18 -5
- package/src/lib/utils.ts +0 -19
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
transformerNotationDiff,
|
|
3
|
+
transformerNotationErrorLevel,
|
|
4
|
+
transformerNotationFocus,
|
|
5
|
+
transformerNotationHighlight,
|
|
6
|
+
transformerNotationWordHighlight,
|
|
7
|
+
} from '@shikijs/transformers';
|
|
8
|
+
import { createHighlighterCore } from 'shiki/core';
|
|
9
|
+
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The design system's Shiki setup: a lazy shared highlighter with the DS themes
|
|
13
|
+
* (github-light / github-dark-default), a fixed grammar set, and the `[!code ...]`
|
|
14
|
+
* notation transformers. Exported so consumers rendering highlighted HTML outside
|
|
15
|
+
* of `CodeBlock` (e.g. custom docs pipelines) reuse the exact same setup instead
|
|
16
|
+
* of duplicating it — and get the lazy per-language chunks instead of the full
|
|
17
|
+
* Shiki bundle.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const languageLoaders = {
|
|
21
|
+
bash: () => import('@shikijs/langs/bash').then((module) => module.default),
|
|
22
|
+
css: () => import('@shikijs/langs/css').then((module) => module.default),
|
|
23
|
+
dotenv: () => import('@shikijs/langs/dotenv').then((module) => module.default),
|
|
24
|
+
graphql: () => import('@shikijs/langs/graphql').then((module) => module.default),
|
|
25
|
+
html: () => import('@shikijs/langs/html').then((module) => module.default),
|
|
26
|
+
ini: () => import('@shikijs/langs/ini').then((module) => module.default),
|
|
27
|
+
javascript: () => import('@shikijs/langs/javascript').then((module) => module.default),
|
|
28
|
+
json: () => import('@shikijs/langs/json').then((module) => module.default),
|
|
29
|
+
jsonc: () => import('@shikijs/langs/jsonc').then((module) => module.default),
|
|
30
|
+
jsx: () => import('@shikijs/langs/jsx').then((module) => module.default),
|
|
31
|
+
markdown: () => import('@shikijs/langs/markdown').then((module) => module.default),
|
|
32
|
+
mdx: () => import('@shikijs/langs/mdx').then((module) => module.default),
|
|
33
|
+
python: () => import('@shikijs/langs/python').then((module) => module.default),
|
|
34
|
+
shellscript: () => import('@shikijs/langs/shellscript').then((module) => module.default),
|
|
35
|
+
sql: () => import('@shikijs/langs/sql').then((module) => module.default),
|
|
36
|
+
tsx: () => import('@shikijs/langs/tsx').then((module) => module.default),
|
|
37
|
+
typescript: () => import('@shikijs/langs/typescript').then((module) => module.default),
|
|
38
|
+
yaml: () => import('@shikijs/langs/yaml').then((module) => module.default),
|
|
39
|
+
} as const;
|
|
40
|
+
|
|
41
|
+
type SupportedLanguage = keyof typeof languageLoaders;
|
|
42
|
+
|
|
43
|
+
const themeLoaders = [
|
|
44
|
+
() => import('@shikijs/themes/github-light').then((module) => module.default),
|
|
45
|
+
() => import('@shikijs/themes/github-dark-default').then((module) => module.default),
|
|
46
|
+
] as const;
|
|
47
|
+
|
|
48
|
+
let highlighterPromise: ReturnType<typeof createHighlighterCore> | null = null;
|
|
49
|
+
|
|
50
|
+
function getHighlighter(): ReturnType<typeof createHighlighterCore> {
|
|
51
|
+
highlighterPromise ??= Promise.all([
|
|
52
|
+
Promise.all(themeLoaders.map((loadTheme) => loadTheme())),
|
|
53
|
+
Promise.all(Object.values(languageLoaders).map((loadLanguage) => loadLanguage())),
|
|
54
|
+
]).then(([themes, languages]) =>
|
|
55
|
+
createHighlighterCore({
|
|
56
|
+
themes,
|
|
57
|
+
langs: languages.flat(),
|
|
58
|
+
engine: createJavaScriptRegexEngine(),
|
|
59
|
+
}),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return highlighterPromise;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const highlightedCodeCache = new Map<string, Promise<string>>();
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Highlight code using Shiki with all transformers.
|
|
69
|
+
* Uses Shiki's native notation for highlighting:
|
|
70
|
+
* - // [!code highlight] - highlight a line (use language-appropriate comment)
|
|
71
|
+
* - // [!code ++] / // [!code --] - diff highlighting
|
|
72
|
+
* - // [!code focus] - focus mode (blur other lines)
|
|
73
|
+
* - // [!code word:myVar] - highlight specific word
|
|
74
|
+
* - // [!code error] / // [!code warning] - error levels
|
|
75
|
+
*/
|
|
76
|
+
async function highlightCode(code: string, language: SupportedLanguage): Promise<string> {
|
|
77
|
+
const cacheKey = `${language}:${code}`;
|
|
78
|
+
const cached = highlightedCodeCache.get(cacheKey);
|
|
79
|
+
if (cached) return cached;
|
|
80
|
+
|
|
81
|
+
const highlighted = getHighlighter().then((highlighter) =>
|
|
82
|
+
highlighter.codeToHtml(code, {
|
|
83
|
+
lang: language,
|
|
84
|
+
themes: {
|
|
85
|
+
light: 'github-light',
|
|
86
|
+
dark: 'github-dark-default',
|
|
87
|
+
},
|
|
88
|
+
// github-light's orange (#e36209, used for GraphQL fields, CSS properties
|
|
89
|
+
// and similar) is 3.5:1 on a white card. #a35200 is 5.6:1 and keeps the hue.
|
|
90
|
+
colorReplacements: { 'github-light': { '#e36209': '#a35200' } },
|
|
91
|
+
transformers: [
|
|
92
|
+
transformerNotationDiff({ matchAlgorithm: 'v3' }),
|
|
93
|
+
transformerNotationHighlight({ matchAlgorithm: 'v3' }),
|
|
94
|
+
transformerNotationWordHighlight({ matchAlgorithm: 'v3' }),
|
|
95
|
+
transformerNotationFocus({ matchAlgorithm: 'v3' }),
|
|
96
|
+
transformerNotationErrorLevel({ matchAlgorithm: 'v3' }),
|
|
97
|
+
],
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
highlightedCodeCache.set(cacheKey, highlighted);
|
|
101
|
+
return highlighted;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Language aliases that map to Shiki's bundled language names
|
|
106
|
+
*/
|
|
107
|
+
const LANGUAGE_ALIASES: Record<string, SupportedLanguage> = {
|
|
108
|
+
env: 'dotenv',
|
|
109
|
+
js: 'javascript',
|
|
110
|
+
ts: 'typescript',
|
|
111
|
+
sh: 'bash',
|
|
112
|
+
shell: 'bash',
|
|
113
|
+
yml: 'yaml',
|
|
114
|
+
py: 'python',
|
|
115
|
+
md: 'markdown',
|
|
116
|
+
plaintext: 'ini',
|
|
117
|
+
text: 'ini',
|
|
118
|
+
chroma: 'ini',
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Normalize language identifier for Shiki/BundledLanguage.
|
|
123
|
+
* Falls back to 'ini' for unsupported languages (minimal highlighting).
|
|
124
|
+
*/
|
|
125
|
+
function normalizeLanguage(lang?: string): SupportedLanguage {
|
|
126
|
+
const normalized = lang?.toLowerCase() || 'ini';
|
|
127
|
+
|
|
128
|
+
// Check for aliases first
|
|
129
|
+
const alias = LANGUAGE_ALIASES[normalized];
|
|
130
|
+
if (alias) {
|
|
131
|
+
return alias;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Check if the language is one of the explicitly bundled grammars.
|
|
135
|
+
if (normalized in languageLoaders) {
|
|
136
|
+
return normalized as SupportedLanguage;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Fallback to 'ini' for unsupported languages (has minimal highlighting)
|
|
140
|
+
return 'ini';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Bundled grammars whose `//` / `#` comment syntax lets the `[!code ...]`
|
|
145
|
+
* notation transformers match. Only languages with a loader above can qualify:
|
|
146
|
+
* anything else falls back to the `ini` grammar, which renders the notation
|
|
147
|
+
* comment as literal text instead of consuming it.
|
|
148
|
+
*/
|
|
149
|
+
const NOTATION_TRANSFORMER_LANGUAGES = new Set<SupportedLanguage>([
|
|
150
|
+
'javascript',
|
|
151
|
+
'typescript',
|
|
152
|
+
'jsx',
|
|
153
|
+
'tsx',
|
|
154
|
+
'python',
|
|
155
|
+
'bash',
|
|
156
|
+
'shellscript',
|
|
157
|
+
'yaml',
|
|
158
|
+
]);
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Whether `[!code ...]` notations in `lang` survive highlighting. Alias-aware:
|
|
162
|
+
* the check runs on the normalized language, so `ts`, `py`, `sh`, … qualify
|
|
163
|
+
* through their canonical grammar. Callers should strip notations when this
|
|
164
|
+
* returns false, or they render as literal text.
|
|
165
|
+
*/
|
|
166
|
+
function supportsNotationComments(lang?: string): boolean {
|
|
167
|
+
return NOTATION_TRANSFORMER_LANGUAGES.has(normalizeLanguage(lang));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
NOTATION_TRANSFORMER_LANGUAGES,
|
|
172
|
+
getHighlighter,
|
|
173
|
+
highlightCode,
|
|
174
|
+
normalizeLanguage,
|
|
175
|
+
supportsNotationComments,
|
|
176
|
+
};
|
|
177
|
+
export type { SupportedLanguage };
|
|
@@ -77,20 +77,33 @@ export function defineStateEntries<S extends string>(entries: Record<S, StateEnt
|
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* The universal map — the only state strings this package ships. Every entry
|
|
80
|
-
* has one
|
|
80
|
+
* has one tone regardless of domain. The rules behind the tones:
|
|
81
81
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
82
|
+
* - A state an actor ended on purpose is `neutral`, not `critical`:
|
|
83
|
+
* `cancelled`, `expired` and `revoked` are outcomes, not failures.
|
|
84
|
+
* `critical` is for failures and refusals (`failed`, `error`, `rejected`).
|
|
85
|
+
* - A dormant state is `neutral` (`disabled`, `inactive`); its live
|
|
86
|
+
* counterpart is `success` (`enabled`, `active`).
|
|
87
|
+
* - `pending` is `progress`: it waits on a step that the system or another
|
|
88
|
+
* party completes, and it will change without the viewer acting. A domain
|
|
89
|
+
* where pending means "waiting for this user" declares its own `warning`
|
|
90
|
+
* entry in its own map.
|
|
91
|
+
*
|
|
92
|
+
* `running` is deliberately absent: it has no single tone (a running job is
|
|
93
|
+
* `progress`, a running service is `success`), so every domain must decide it
|
|
94
|
+
* explicitly in its own map.
|
|
86
95
|
*/
|
|
87
96
|
export const commonStates = defineStateEntries({
|
|
88
97
|
enabled: { tone: 'success', defaultLabel: 'Enabled' },
|
|
89
98
|
disabled: { tone: 'neutral', defaultLabel: 'Disabled' },
|
|
99
|
+
active: { tone: 'success', defaultLabel: 'Active' },
|
|
100
|
+
inactive: { tone: 'neutral', defaultLabel: 'Inactive' },
|
|
101
|
+
pending: { tone: 'progress', defaultLabel: 'Pending' },
|
|
90
102
|
completed: { tone: 'success', defaultLabel: 'Completed' },
|
|
91
103
|
failed: { tone: 'critical', defaultLabel: 'Failed' },
|
|
92
104
|
cancelled: { tone: 'neutral', defaultLabel: 'Cancelled' },
|
|
93
105
|
expired: { tone: 'neutral', defaultLabel: 'Expired' },
|
|
106
|
+
revoked: { tone: 'neutral', defaultLabel: 'Revoked' },
|
|
94
107
|
draft: { tone: 'neutral', defaultLabel: 'Draft' },
|
|
95
108
|
suspended: { tone: 'warning', defaultLabel: 'Suspended' },
|
|
96
109
|
approved: { tone: 'success', defaultLabel: 'Approved' },
|
package/src/lib/utils.ts
CHANGED
|
@@ -4,22 +4,3 @@ import { twMerge } from 'tailwind-merge';
|
|
|
4
4
|
export function cn(...inputs: ClassValue[]): string {
|
|
5
5
|
return twMerge(clsx(inputs));
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
export function slugify(str: string): string {
|
|
9
|
-
return str
|
|
10
|
-
.toLowerCase()
|
|
11
|
-
.trim()
|
|
12
|
-
.replace(/[^\w\s-]/g, '')
|
|
13
|
-
.replace(/[\s_-]+/g, '-')
|
|
14
|
-
.replace(/^-+|-+$/g, '');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function hashString(str: string): number {
|
|
18
|
-
let hash = 0;
|
|
19
|
-
for (let i = 0; i < str.length; i++) {
|
|
20
|
-
const char = str.charCodeAt(i);
|
|
21
|
-
hash = (hash << 5) - hash + char;
|
|
22
|
-
hash |= 0;
|
|
23
|
-
}
|
|
24
|
-
return Math.abs(hash);
|
|
25
|
-
}
|