@letterncms/admin 0.0.0-stage → 0.1.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Falko Joseph
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
- "name": "@letterncms/admin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@letterncms/admin",
3
+ "description": "Build a plugin's admin module: the Vite setup and the admin's Tailwind names.",
4
+ "exports": {
5
+ "./theme.css": "./src/styles/theme.css",
6
+ "./vite": "./vite.plugin.mjs"
7
+ },
8
+ "dependencies": {
9
+ "@tailwindcss/vite": "4.3.3",
10
+ "@vitejs/plugin-react": "6.1.2",
11
+ "tailwindcss": "4.3.3"
12
+ },
13
+ "peerDependencies": {
14
+ "vite": "8.3.5"
15
+ },
16
+ "version": "0.1.1",
17
+ "type": "module",
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/letterncms/cms.git"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ }
26
+ }
@@ -0,0 +1,70 @@
1
+ /* The admin's design tokens as Tailwind names, shared with plugin admin modules (import "@letterncms/admin/theme.css").
2
+ Their values live in tokens.css, defined once by the admin theme, so a module never overrides them. */
3
+
4
+ @custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
5
+
6
+ @theme inline {
7
+ --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
8
+ --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
9
+
10
+ --text-2xs: 11px;
11
+ --text-2xs--line-height: 16px;
12
+ --text-xs: 12px;
13
+ --text-xs--line-height: 16px;
14
+ --text-sm: 13px;
15
+ --text-sm--line-height: 20px;
16
+ --text-base: 14px;
17
+ --text-base--line-height: 22px;
18
+ --text-lg: 16px;
19
+ --text-lg--line-height: 24px;
20
+ --text-xl: 20px;
21
+ --text-xl--line-height: 28px;
22
+ --text-2xl: 24px;
23
+ --text-2xl--line-height: 32px;
24
+ --text-3xl: 32px;
25
+ --text-3xl--line-height: 40px;
26
+
27
+ --radius-xs: 4px;
28
+ --radius-sm: 6px;
29
+ --radius-md: 8px;
30
+ --radius-lg: 10px;
31
+ --radius-xl: 14px;
32
+
33
+ --color-bg: var(--cms-bg);
34
+ --color-surface: var(--cms-surface);
35
+ --color-sunken: var(--cms-sunken);
36
+ --color-hover: var(--cms-hover);
37
+ --color-active: var(--cms-active);
38
+ --color-border: var(--cms-border);
39
+ --color-border-strong: var(--cms-border-strong);
40
+ --color-border-float: var(--cms-border-float);
41
+ --color-border-modal: var(--cms-border-modal);
42
+ --color-ink: var(--cms-ink);
43
+ --color-ink-contrast: var(--cms-ink-contrast);
44
+ --color-text: var(--cms-text);
45
+ --color-muted: var(--cms-muted);
46
+ --color-faint: var(--cms-faint);
47
+ --color-signal: var(--cms-signal);
48
+ --color-signal-ink: var(--cms-signal-ink);
49
+ --color-focus: var(--cms-focus);
50
+ --color-success: var(--cms-success);
51
+ --color-warning: var(--cms-warning);
52
+ --color-danger: var(--cms-danger);
53
+ --color-overlay: var(--cms-overlay);
54
+
55
+ --shadow-pop: var(--cms-shadow-pop);
56
+ --shadow-dialog: var(--cms-shadow-dialog);
57
+
58
+ --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
59
+ --ease-spring: cubic-bezier(0.32, 1.25, 0.5, 1);
60
+ }
61
+
62
+ @utility cms-caps {
63
+ font-size: 11px;
64
+ line-height: 16px;
65
+ font-weight: 550;
66
+ letter-spacing: 0.06em;
67
+ text-transform: uppercase;
68
+ color: var(--cms-muted);
69
+ }
70
+
@@ -0,0 +1,117 @@
1
+ // Shared Vite setup for plugin admin modules.
2
+ //
3
+ // // plugins/acme/vite.config.mjs
4
+ // import { cmsAdminModule } from '@letterncms/admin/vite'
5
+ // export default cmsAdminModule({ entry: 'admin/src/index.tsx' })
6
+ //
7
+ // Modules other plugins expose (e.g. "@letterncms/blocks") are listed in `externals`.
8
+ //
9
+ // Module CSS imports utilities into the "plugins" layer:
10
+ // @import "tailwindcss/theme" layer(theme);
11
+ // @import "tailwindcss/utilities" layer(plugins);
12
+ // @import "@letterncms/admin/theme.css";
13
+ //
14
+ // React, the SDK, the UI kit and dnd-kit are NOT bundled: the admin theme provides
15
+ // them through the import map, so every module shares one copy of each.
16
+ import { rmSync } from 'node:fs'
17
+ import { resolve } from 'node:path'
18
+ import react from '@vitejs/plugin-react'
19
+ import tailwindcss from '@tailwindcss/vite'
20
+
21
+ export const SHARED = ['react', 'react/jsx-runtime', 'react-dom', 'react-dom/client', '@tanstack/react-query', '@letterncms/sdk', '@letterncms/ui', '@dnd-kit/core', '@dnd-kit/sortable', '@dnd-kit/utilities']
22
+
23
+ /**
24
+ * Every admin stylesheet — the theme's and each module's — is built on its own, so the
25
+ * cascade cannot rely on Tailwind's ordering inside one file: a module's `lg:grid-cols-7`
26
+ * would lose to the theme's own `.grid-cols-2`. This moves every variant utilities
27
+ * (responsive, hover, dark, group-…) of a file into the shared `variants` layer, which the
28
+ * theme declares last, so variants beat plain utilities whichever file they come from.
29
+ */
30
+ export function layerVariants() {
31
+ return {
32
+ name: 'cms-layer-variants',
33
+ enforce: 'post',
34
+ generateBundle(_, bundle) {
35
+ for (const asset of Object.values(bundle)) {
36
+ if (asset.type === 'asset' && asset.fileName.endsWith('.css')) asset.source = splitVariants(String(asset.source))
37
+ }
38
+ },
39
+ }
40
+ }
41
+
42
+ export function splitVariants(css) {
43
+ return statements(css)
44
+ .map((statement) => {
45
+ const match = /^\s*@layer\s+(utilities|plugins)\s*\{/.exec(statement)
46
+ if (!match) return statement
47
+ const inner = statements(statement.slice(match[0].length, statement.lastIndexOf('}')))
48
+ // A variant is a rule whose class has a prefix (`md\:`, `hover\:`…) or a breakpoint/container query;
49
+ // @supports fallbacks of plain utilities stay with them.
50
+ const variant = (rule) => {
51
+ const text = rule.trimStart()
52
+ if (/^@(media|container)\b/.test(text)) return true
53
+ const inner = text.startsWith('@') ? text.slice(text.indexOf('{') + 1) : text
54
+ return inner.slice(0, inner.indexOf('{')).includes('\\:')
55
+ }
56
+ const base = inner.filter((rule) => !variant(rule)).join('')
57
+ const variants = inner.filter(variant).join('')
58
+ return `@layer ${match[1]}{${base}}` + (variants ? `@layer variants{${variants}}` : '')
59
+ })
60
+ .join('')
61
+ }
62
+
63
+ /** Top-level statements of a stylesheet (rules and at-rules), quotes and escapes respected. */
64
+ function statements(css) {
65
+ const out = []
66
+ let depth = 0
67
+ let start = 0
68
+ let quote = null
69
+ for (let i = 0; i < css.length; i++) {
70
+ const c = css[i]
71
+ if (c === '\\') {
72
+ i++
73
+ } else if (quote) {
74
+ if (c === quote) quote = null
75
+ } else if (c === '"' || c === "'") {
76
+ quote = c
77
+ } else if (c === '{') {
78
+ depth++
79
+ } else if (c === '}') {
80
+ if (--depth === 0) {
81
+ out.push(css.slice(start, i + 1))
82
+ start = i + 1
83
+ }
84
+ } else if (c === ';' && depth === 0) {
85
+ out.push(css.slice(start, i + 1))
86
+ start = i + 1
87
+ }
88
+ }
89
+ if (css.slice(start).trim()) out.push(css.slice(start))
90
+ return out
91
+ }
92
+
93
+ // emptyOutDir stays off because a package can build more into dist/ (blocks has dist/runtime),
94
+ // so last build's chunks are cleared here. Left behind, they would ship in the release.
95
+ const cleanChunks = (outDir) => ({
96
+ name: 'cms-clean-chunks',
97
+ apply: 'build',
98
+ buildStart: () => rmSync(resolve(outDir, 'chunks'), { recursive: true, force: true }),
99
+ })
100
+
101
+ export function cmsAdminModule({ entry, outDir = 'dist', externals = [] }) {
102
+ return {
103
+ plugins: [react(), tailwindcss(), layerVariants(), cleanChunks(outDir)],
104
+ publicDir: false,
105
+ build: {
106
+ outDir,
107
+ emptyOutDir: false,
108
+ target: 'es2023',
109
+ cssCodeSplit: false,
110
+ lib: { entry, formats: ['es'], fileName: () => 'admin.js', cssFileName: 'admin' },
111
+ rollupOptions: {
112
+ external: (id) => SHARED.includes(id) || externals.includes(id),
113
+ output: { chunkFileNames: 'chunks/[name]-[hash].js', assetFileNames: '[name][extname]' },
114
+ },
115
+ },
116
+ }
117
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.