@birdycom/omniaui 0.11.0 → 0.11.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 +21 -21
- package/README.md +21 -21
- package/bin/lib/add.mjs +126 -126
- package/bin/lib/catalog.mjs +169 -169
- package/bin/lib/project.mjs +90 -90
- package/bin/omniaui.mjs +69 -69
- package/dist/code-block.css +25 -25
- package/dist/components-extra.css +916 -914
- package/dist/components.css +6559 -6469
- package/dist/components.min.css +1 -1
- package/dist/data-table.d.ts +9 -9
- package/dist/data-table.js +505 -505
- package/dist/docs-ui.css +267 -265
- package/dist/oc-theme.css +69 -69
- package/dist/parts/app-accordion-accent.css +60 -60
- package/dist/parts/app-alpha-tabs.css +68 -68
- package/dist/parts/app-busy-overlay.css +25 -25
- package/dist/parts/app-column-menu.css +85 -85
- package/dist/parts/app-confirm-dialog.css +70 -70
- package/dist/parts/app-cookie-consent.css +63 -63
- package/dist/parts/app-data-table.css +174 -174
- package/dist/parts/app-greeting.css +47 -47
- package/dist/parts/app-list-toolbar.css +81 -81
- package/dist/parts/app-page-header.css +54 -54
- package/dist/parts/app-severity-card.css +91 -91
- package/dist/parts/app-sidebar-dark.css +15 -15
- package/dist/parts/app-sortable-row.css +52 -52
- package/dist/parts/app-stat-card.css +68 -68
- package/dist/parts/app-table-actions.css +71 -71
- package/dist/parts/app-table-compact.css +54 -54
- package/dist/parts/app-top-progress.css +68 -68
- package/dist/parts/app-tree.css +104 -104
- package/dist/parts/app-upgrade-banner.css +90 -90
- package/dist/parts/app-version-banner.css +80 -80
- package/dist/parts/data-chart-line.css +167 -167
- package/dist/parts/forms-affix-input.css +75 -75
- package/dist/parts/forms-barcode-input.css +75 -75
- package/dist/parts/forms-chip-filter.css +91 -91
- package/dist/parts/forms-color-select.css +97 -89
- package/dist/parts/forms-decimal-input.css +51 -51
- package/dist/parts/forms-filter-counts.css +94 -94
- package/dist/parts/forms-language-select.css +89 -76
- package/dist/parts/forms-number-input.css +98 -95
- package/dist/parts/forms-password-requirements.css +55 -55
- package/dist/parts/forms-phone-input.css +85 -85
- package/dist/parts/forms-time-input.css +74 -74
- package/dist/parts/forms-toggle-field.css +69 -69
- package/dist/parts/media-art.css +21 -21
- package/dist/parts/media-attachment.css +160 -160
- package/dist/parts/media-browser-frame.css +73 -73
- package/dist/parts/media-card.css +83 -83
- package/dist/parts/media-chat-composer.css +90 -90
- package/dist/parts/media-doc-viewer.css +151 -151
- package/dist/parts/media-emoji-picker.css +88 -88
- package/dist/parts/media-entity-card.css +52 -52
- package/dist/parts/media-flip-card.css +78 -78
- package/dist/parts/media-image-zoom.css +68 -68
- package/dist/parts/media-lightbox.css +131 -131
- package/dist/parts/media-message-thread.css +136 -136
- package/dist/parts/media-message.css +160 -160
- package/dist/parts/media-row.css +78 -78
- package/dist/parts/media-stack-card.css +82 -82
- package/dist/parts/media-terminal-log.css +76 -76
- package/dist/parts/media-thumb.css +71 -71
- package/dist/parts/site-fact-list.css +25 -25
- package/dist/parts/site-link-arrow.css +34 -34
- package/dist/parts/site-marquee.css +34 -34
- package/dist/parts/site-next-teaser.css +75 -75
- package/dist/parts/site-price-card.css +91 -75
- package/dist/parts/site-product-mark.css +66 -66
- package/dist/parts/site-project-card.css +111 -111
- package/dist/parts/site-prose.css +124 -124
- package/dist/parts/site-stack-list.css +48 -48
- package/dist/parts/site-timeline.css +54 -54
- package/dist/showcase.css +404 -404
- package/package.json +69 -69
- package/snippets/accordion-accent.html +24 -24
- package/snippets/accordion.html +11 -11
- package/snippets/affix-input.html +30 -30
- package/snippets/alert-dialog.html +22 -22
- package/snippets/alert.html +5 -5
- package/snippets/alpha-tabs.html +37 -37
- package/snippets/aspect-ratio.html +15 -15
- package/snippets/attachment.html +43 -43
- package/snippets/avatar.html +6 -6
- package/snippets/back-link.html +5 -5
- package/snippets/badge.html +5 -5
- package/snippets/barcode-input.html +18 -18
- package/snippets/breadcrumb.html +6 -6
- package/snippets/browser-frame.html +18 -18
- package/snippets/busy-overlay.html +31 -31
- package/snippets/button-group.html +21 -21
- package/snippets/button.html +8 -8
- package/snippets/calendar.html +43 -43
- package/snippets/card.html +17 -17
- package/snippets/carousel.html +21 -21
- package/snippets/chart-line.html +46 -46
- package/snippets/chart.html +27 -27
- package/snippets/chat-composer.html +21 -21
- package/snippets/checkbox.html +5 -5
- package/snippets/checklist.html +23 -23
- package/snippets/chip-filter.html +14 -14
- package/snippets/code-window.html +20 -20
- package/snippets/collapsible.html +19 -19
- package/snippets/color-field.html +13 -13
- package/snippets/color-select.html +18 -18
- package/snippets/column-menu.html +38 -38
- package/snippets/combobox.html +19 -19
- package/snippets/command.html +24 -24
- package/snippets/confirm-dialog.html +32 -32
- package/snippets/context-menu.html +25 -25
- package/snippets/cookie-consent.html +70 -70
- package/snippets/copy-field.html +19 -19
- package/snippets/counter.html +2 -2
- package/snippets/data-table.html +151 -151
- package/snippets/date-picker.html +32 -32
- package/snippets/decimal-input.html +20 -20
- package/snippets/definition-list.html +20 -20
- package/snippets/demo-panel.html +18 -18
- package/snippets/doc-viewer.html +58 -58
- package/snippets/drawer.html +30 -30
- package/snippets/dropdown-menu.html +27 -27
- package/snippets/dropdown.html +9 -9
- package/snippets/dropzone.html +13 -13
- package/snippets/emoji-picker.html +51 -51
- package/snippets/empty-state.html +17 -17
- package/snippets/entity-card.html +26 -26
- package/snippets/expandable-table.html +26 -26
- package/snippets/fact-list.html +14 -14
- package/snippets/filter-counts.html +30 -30
- package/snippets/flip-card.html +22 -22
- package/snippets/form-field.html +6 -6
- package/snippets/greeting.html +22 -22
- package/snippets/heading.html +14 -14
- package/snippets/hover-card.html +18 -18
- package/snippets/image-zoom.html +30 -30
- package/snippets/input-group.html +10 -10
- package/snippets/input.html +5 -5
- package/snippets/item.html +26 -26
- package/snippets/kbd.html +13 -13
- package/snippets/label.html +9 -9
- package/snippets/language-select.html +26 -26
- package/snippets/launcher-card.html +14 -14
- package/snippets/lightbox.html +50 -50
- package/snippets/link-arrow.html +10 -10
- package/snippets/list-toolbar.html +33 -33
- package/snippets/marquee.html +15 -15
- package/snippets/media-card.html +28 -28
- package/snippets/media-row.html +21 -21
- package/snippets/media-thumb.html +12 -12
- package/snippets/menubar.html +30 -30
- package/snippets/message-thread.html +123 -123
- package/snippets/message.html +51 -51
- package/snippets/modal.html +15 -15
- package/snippets/native-select.html +15 -15
- package/snippets/navmenu.html +23 -23
- package/snippets/next-teaser.html +15 -15
- package/snippets/number-input.html +27 -27
- package/snippets/otp-input.html +9 -9
- package/snippets/page-header.html +24 -24
- package/snippets/pagination.html +6 -6
- package/snippets/password-input.html +24 -24
- package/snippets/password-requirements.html +30 -30
- package/snippets/phone-input.html +22 -22
- package/snippets/popover.html +15 -15
- package/snippets/price-card.html +34 -34
- package/snippets/product-mark.html +13 -13
- package/snippets/progress.html +4 -4
- package/snippets/project-card.html +23 -23
- package/snippets/prose.html +54 -54
- package/snippets/radio.html +17 -17
- package/snippets/recovery-codes.html +20 -20
- package/snippets/resizable.html +16 -16
- package/snippets/scroll-area.html +20 -20
- package/snippets/search.html +8 -8
- package/snippets/segmented.html +11 -11
- package/snippets/select.html +7 -7
- package/snippets/separator.html +15 -15
- package/snippets/severity-card.html +35 -35
- package/snippets/sheet.html +32 -32
- package/snippets/sidebar-docs.html +24 -24
- package/snippets/sidebar.html +55 -55
- package/snippets/site-footer.html +6 -6
- package/snippets/site-header.html +26 -26
- package/snippets/skeleton.html +4 -4
- package/snippets/slider.html +17 -17
- package/snippets/sortable-row.html +31 -31
- package/snippets/spinner.html +14 -14
- package/snippets/stack-card.html +17 -17
- package/snippets/stack-list.html +16 -16
- package/snippets/stat-card.html +24 -24
- package/snippets/stepper.html +13 -13
- package/snippets/switch.html +6 -6
- package/snippets/table-actions.html +39 -39
- package/snippets/table-compact.html +24 -24
- package/snippets/table.html +29 -29
- package/snippets/tabs.html +9 -9
- package/snippets/tag-input.html +60 -17
- package/snippets/terminal-log.html +23 -23
- package/snippets/textarea.html +3 -3
- package/snippets/theme-switch.html +6 -6
- package/snippets/time-input.html +26 -26
- package/snippets/timeline.html +28 -28
- package/snippets/toast-stack.html +10 -10
- package/snippets/toast.html +36 -36
- package/snippets/toc.html +13 -13
- package/snippets/toggle-field.html +20 -20
- package/snippets/toggle.html +22 -22
- package/snippets/tooltip.html +4 -4
- package/snippets/top-progress.html +12 -12
- package/snippets/tree.html +38 -38
- package/snippets/upgrade-banner.html +28 -28
- package/snippets/user.html +15 -15
- package/snippets/version-banner.html +15 -15
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Serge Cools (Birdycom)
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Serge Cools (Birdycom)
|
|
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/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# @birdycom/omniaui
|
|
2
|
-
|
|
3
|
-
CSS-first components for OmniaCSS. Native HTML does the behaviour — **no JavaScript required**:
|
|
4
|
-
|
|
5
|
-
| Component | Markup |
|
|
6
|
-
|-----------|--------|
|
|
7
|
-
| Modal | `<dialog class="oc-modal">` + `command="show-modal" commandfor="id"` |
|
|
8
|
-
| Dropdown | `<div popover class="oc-dropdown-menu">` + `popovertarget` (anchor positioned) |
|
|
9
|
-
| Accordion | `<details class="oc-accordion-item" name="group">` |
|
|
10
|
-
| Tabs | `.oc-tabset` with radio inputs (`:has()`) |
|
|
11
|
-
| Theme switch | `.oc-theme-switch` (system / light / dark, `light-dark()` tokens) |
|
|
12
|
-
| Counter | `.oc-counter` (`@property`, optional start on scroll) |
|
|
13
|
-
|
|
14
|
-
Plus buttons, cards, badges, alerts, forms, avatar, progress, breadcrumb, pagination, skeleton, tooltip and the Code-block.
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install @birdycom/omniaui # import "@birdycom/omniaui"
|
|
18
|
-
npx omniacss add component modal # copy a snippet into your project
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
MIT
|
|
1
|
+
# @birdycom/omniaui
|
|
2
|
+
|
|
3
|
+
CSS-first components for OmniaCSS. Native HTML does the behaviour — **no JavaScript required**:
|
|
4
|
+
|
|
5
|
+
| Component | Markup |
|
|
6
|
+
|-----------|--------|
|
|
7
|
+
| Modal | `<dialog class="oc-modal">` + `command="show-modal" commandfor="id"` |
|
|
8
|
+
| Dropdown | `<div popover class="oc-dropdown-menu">` + `popovertarget` (anchor positioned) |
|
|
9
|
+
| Accordion | `<details class="oc-accordion-item" name="group">` |
|
|
10
|
+
| Tabs | `.oc-tabset` with radio inputs (`:has()`) |
|
|
11
|
+
| Theme switch | `.oc-theme-switch` (system / light / dark, `light-dark()` tokens) |
|
|
12
|
+
| Counter | `.oc-counter` (`@property`, optional start on scroll) |
|
|
13
|
+
|
|
14
|
+
Plus buttons, cards, badges, alerts, forms, avatar, progress, breadcrumb, pagination, skeleton, tooltip and the Code-block.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @birdycom/omniaui # import "@birdycom/omniaui"
|
|
18
|
+
npx omniacss add component modal # copy a snippet into your project
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
MIT
|
package/bin/lib/add.mjs
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
// File: packages/ui/bin/lib/add.mjs
|
|
2
|
-
// The "add" and "list" commands of the omniaui CLI: copy components/blocks into a project (you own the code).
|
|
3
|
-
// Map: copyFiles -> importLine -> cmdAdd -> cmdList
|
|
4
|
-
|
|
5
|
-
import fs from "node:fs/promises";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import { catalog, closure, findEntries, INSTALL_HINT, proBlockNames } from "./catalog.mjs";
|
|
8
|
-
import { cwd, defaultDir, ensureContentGlob, exists, pascal, posix, readJson, requireFromProject, resolveFramework } from "./project.mjs";
|
|
9
|
-
|
|
10
|
-
/** Copied Blade files call each other as <x-oc.name>, matching the folder they land in. */
|
|
11
|
-
const rewriteBlade = (text) => text.replace(/(<\/?)x-oc::/g, "$1x-oc.");
|
|
12
|
-
|
|
13
|
-
async function copyFiles(root, files, targetDir, fw, flags) {
|
|
14
|
-
let copied = 0;
|
|
15
|
-
for (const file of files) {
|
|
16
|
-
// vue/react sources live in src/; keep their folder layout below it so relative imports stay valid
|
|
17
|
-
const rel = fw === "blade" ? file : file.replace(/^src\//, "");
|
|
18
|
-
const target = path.resolve(cwd, targetDir, rel);
|
|
19
|
-
const shown = posix(path.relative(cwd, target));
|
|
20
|
-
if (!flags.force && (await exists(target))) { console.log(` skip ${shown} (exists, use --force)`); continue; }
|
|
21
|
-
if (!flags["dry-run"]) {
|
|
22
|
-
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
23
|
-
if (fw === "blade") await fs.writeFile(target, rewriteBlade(await fs.readFile(path.join(root, file), "utf8")));
|
|
24
|
-
else await fs.copyFile(path.join(root, file), target);
|
|
25
|
-
}
|
|
26
|
-
console.log(` ${flags["dry-run"] ? "would copy" : "copied "} ${shown}`);
|
|
27
|
-
copied++;
|
|
28
|
-
}
|
|
29
|
-
return copied;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** css flavour: copy the one HTML snippet straight into the target folder (no sub-folders). */
|
|
33
|
-
async function copySnippet(entry, dir, flags) {
|
|
34
|
-
const target = path.resolve(cwd, dir, path.basename(entry.files[0]));
|
|
35
|
-
const shown = posix(path.relative(cwd, target));
|
|
36
|
-
if (!flags.force && (await exists(target))) { console.log(` skip ${shown} (exists, use --force)`); return 0; }
|
|
37
|
-
if (!flags["dry-run"]) {
|
|
38
|
-
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
39
|
-
await fs.copyFile(path.join(entry.root, entry.files[0]), target);
|
|
40
|
-
}
|
|
41
|
-
console.log(` ${flags["dry-run"] ? "would copy" : "copied "} ${shown}`);
|
|
42
|
-
return 1;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** The line a user pastes to use the npm package (or Blade tag) instead of copying code. */
|
|
46
|
-
async function importLine(fw, root, entry) {
|
|
47
|
-
if (fw === "vue") {
|
|
48
|
-
const names = (await readJson(path.join(root, "manifest.json"))).items
|
|
49
|
-
.filter((i) => i.kind === entry.kind && i.snippet && path.basename(i.snippet, ".html") === entry.name).map((i) => i.name);
|
|
50
|
-
return `import { ${names.join(", ")} } from "@birdycom/omniaui-vue";`;
|
|
51
|
-
}
|
|
52
|
-
if (fw === "react") {
|
|
53
|
-
const names = [];
|
|
54
|
-
for (const file of entry.files) {
|
|
55
|
-
for (const m of (await fs.readFile(path.join(root, file), "utf8")).matchAll(/export\s+(?:const|function|class)\s+([A-Z]\w*)/g)) names.push(m[1]);
|
|
56
|
-
}
|
|
57
|
-
return `import { ${[...new Set(names)].join(", ")} } from "@birdycom/omniaui-react";`;
|
|
58
|
-
}
|
|
59
|
-
if (fw === "blade") return `<x-oc::${entry.kind === "block" ? "block." : ""}${entry.name} />`;
|
|
60
|
-
return entry.kind === "block" ? `@birdycom/omniaui-blocks/blocks/${entry.name}.html` : `@birdycom/omniaui/snippets/${entry.name}.html`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export async function cmdAdd(args, flags) {
|
|
64
|
-
const names = [...args];
|
|
65
|
-
let kind = flags.kind;
|
|
66
|
-
let legacyKind; // `omniaui add block <name>` keeps working
|
|
67
|
-
if (["block", "component", "blocks", "components"].includes(names[0]) && names.length > 1) legacyKind = kind = names.shift().replace(/s$/, "");
|
|
68
|
-
if (kind && !["component", "block"].includes(kind)) throw new Error(`Unknown kind "${kind}". Use component or block.`);
|
|
69
|
-
if (!names.length && !flags.all) throw new Error("Usage: omniaui add <name...> [-f css|vue|react|blade] [--kind component|block] [--dir dir] [--force] [--dry-run] [--import]");
|
|
70
|
-
|
|
71
|
-
const fw = await resolveFramework(flags);
|
|
72
|
-
const cat = await catalog(fw);
|
|
73
|
-
const selected = [];
|
|
74
|
-
if (flags.all) selected.push(...cat.entries.filter((e) => e.kind === (kind || "component")));
|
|
75
|
-
for (const input of names) {
|
|
76
|
-
const hits = findEntries(cat.entries, input, kind);
|
|
77
|
-
if (!hits.length && (await proBlockNames()).includes(input.replace(/^block-/, ""))) {
|
|
78
|
-
throw new Error(fw === "css"
|
|
79
|
-
? `"${input}" is an OmniaUI Pro block. Install @birdycom/omniaui-pro (licensed) to add it.`
|
|
80
|
-
: `"${input}" is an OmniaUI Pro block: use it from @birdycom/omniaui-pro-${fw === "blade" ? "laravel" : fw} (licensed) instead of copying.`);
|
|
81
|
-
}
|
|
82
|
-
if (!hits.length) throw new Error(`Unknown ${kind || "component or block"} "${input}" for ${fw}. Run "omniaui list -f ${fw}" to see the options.`);
|
|
83
|
-
if (hits.length > 1) throw new Error(`"${input}" exists as component and block. Pass --kind component or --kind block.`);
|
|
84
|
-
selected.push(hits[0]);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (flags.import) {
|
|
88
|
-
for (const entry of selected) console.log(await importLine(fw, cat.root, entry));
|
|
89
|
-
if (fw === "vue" || fw === "react") {
|
|
90
|
-
try { requireFromProject.resolve(`@birdycom/omniaui-${fw}/package.json`); } catch { console.log(`Package not installed in this project. Install it with: ${INSTALL_HINT[fw]}`); }
|
|
91
|
-
}
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const dir = flags.dir || flags.to || (await defaultDir(fw, legacyKind));
|
|
96
|
-
console.log(`${fw} → ${dir}${flags["dry-run"] ? " (dry run)" : ""}`);
|
|
97
|
-
let total = 0;
|
|
98
|
-
for (const entry of selected) {
|
|
99
|
-
console.log(`${entry.kind} "${entry.name}"`);
|
|
100
|
-
if (fw === "css") total += await copySnippet(entry, dir, flags);
|
|
101
|
-
else total += await copyFiles(cat.root, await closure(fw, cat.root, entry, cat.entries), dir, fw, flags);
|
|
102
|
-
}
|
|
103
|
-
if (flags["dry-run"]) { console.log(`\n${total} file(s) would be copied.`); return; }
|
|
104
|
-
const hasBlock = selected.some((e) => e.kind === "block");
|
|
105
|
-
const glob = { css: "**/*.html", vue: "**/*.vue", react: "**/*.tsx", blade: "**/*.blade.php" }[fw];
|
|
106
|
-
await ensureContentGlob(`${posix(path.normalize(dir)).replace(/\/$/, "")}/${glob}`, hasBlock);
|
|
107
|
-
const hasPro = selected.some((e) => e.pro);
|
|
108
|
-
console.log(`\n${total} file(s) copied. Styles come from @birdycom/omniaui${hasBlock ? " and @birdycom/omniaui-blocks" : ""}${hasPro ? " and @birdycom/omniaui-pro" : ""} ("omniacss build" includes them).`);
|
|
109
|
-
if (fw === "vue" || fw === "react") console.log(`These files need ${fw} in your project (${fw === "vue" ? "3.4+" : "18+"}).`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export async function cmdList(what, flags = {}) {
|
|
113
|
-
const fw = await resolveFramework(flags);
|
|
114
|
-
const kinds = flags.kind ? [flags.kind] : what ? [what.replace(/s$/, "")] : ["component", "block"];
|
|
115
|
-
const cat = await catalog(fw);
|
|
116
|
-
console.log(`framework: ${fw}`);
|
|
117
|
-
for (const kind of kinds) {
|
|
118
|
-
console.log(`\n${kind}s`);
|
|
119
|
-
for (const e of cat.entries.filter((x) => x.kind === kind)) {
|
|
120
|
-
const label = fw === "vue" ? `Oc${kind === "block" ? "Block" : ""}${pascal(e.name)}`
|
|
121
|
-
: fw === "react" ? path.basename(e.files[0], ".tsx")
|
|
122
|
-
: fw === "blade" ? `<x-oc::${kind === "block" ? "block." : ""}${e.name}>` : "";
|
|
123
|
-
console.log(` ${e.name.padEnd(18)} ${label.padEnd(fw === "css" ? 0 : 30)}${e.description || ""}`.trimEnd());
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
1
|
+
// File: packages/ui/bin/lib/add.mjs
|
|
2
|
+
// The "add" and "list" commands of the omniaui CLI: copy components/blocks into a project (you own the code).
|
|
3
|
+
// Map: copyFiles -> importLine -> cmdAdd -> cmdList
|
|
4
|
+
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { catalog, closure, findEntries, INSTALL_HINT, proBlockNames } from "./catalog.mjs";
|
|
8
|
+
import { cwd, defaultDir, ensureContentGlob, exists, pascal, posix, readJson, requireFromProject, resolveFramework } from "./project.mjs";
|
|
9
|
+
|
|
10
|
+
/** Copied Blade files call each other as <x-oc.name>, matching the folder they land in. */
|
|
11
|
+
const rewriteBlade = (text) => text.replace(/(<\/?)x-oc::/g, "$1x-oc.");
|
|
12
|
+
|
|
13
|
+
async function copyFiles(root, files, targetDir, fw, flags) {
|
|
14
|
+
let copied = 0;
|
|
15
|
+
for (const file of files) {
|
|
16
|
+
// vue/react sources live in src/; keep their folder layout below it so relative imports stay valid
|
|
17
|
+
const rel = fw === "blade" ? file : file.replace(/^src\//, "");
|
|
18
|
+
const target = path.resolve(cwd, targetDir, rel);
|
|
19
|
+
const shown = posix(path.relative(cwd, target));
|
|
20
|
+
if (!flags.force && (await exists(target))) { console.log(` skip ${shown} (exists, use --force)`); continue; }
|
|
21
|
+
if (!flags["dry-run"]) {
|
|
22
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
23
|
+
if (fw === "blade") await fs.writeFile(target, rewriteBlade(await fs.readFile(path.join(root, file), "utf8")));
|
|
24
|
+
else await fs.copyFile(path.join(root, file), target);
|
|
25
|
+
}
|
|
26
|
+
console.log(` ${flags["dry-run"] ? "would copy" : "copied "} ${shown}`);
|
|
27
|
+
copied++;
|
|
28
|
+
}
|
|
29
|
+
return copied;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** css flavour: copy the one HTML snippet straight into the target folder (no sub-folders). */
|
|
33
|
+
async function copySnippet(entry, dir, flags) {
|
|
34
|
+
const target = path.resolve(cwd, dir, path.basename(entry.files[0]));
|
|
35
|
+
const shown = posix(path.relative(cwd, target));
|
|
36
|
+
if (!flags.force && (await exists(target))) { console.log(` skip ${shown} (exists, use --force)`); return 0; }
|
|
37
|
+
if (!flags["dry-run"]) {
|
|
38
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
39
|
+
await fs.copyFile(path.join(entry.root, entry.files[0]), target);
|
|
40
|
+
}
|
|
41
|
+
console.log(` ${flags["dry-run"] ? "would copy" : "copied "} ${shown}`);
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The line a user pastes to use the npm package (or Blade tag) instead of copying code. */
|
|
46
|
+
async function importLine(fw, root, entry) {
|
|
47
|
+
if (fw === "vue") {
|
|
48
|
+
const names = (await readJson(path.join(root, "manifest.json"))).items
|
|
49
|
+
.filter((i) => i.kind === entry.kind && i.snippet && path.basename(i.snippet, ".html") === entry.name).map((i) => i.name);
|
|
50
|
+
return `import { ${names.join(", ")} } from "@birdycom/omniaui-vue";`;
|
|
51
|
+
}
|
|
52
|
+
if (fw === "react") {
|
|
53
|
+
const names = [];
|
|
54
|
+
for (const file of entry.files) {
|
|
55
|
+
for (const m of (await fs.readFile(path.join(root, file), "utf8")).matchAll(/export\s+(?:const|function|class)\s+([A-Z]\w*)/g)) names.push(m[1]);
|
|
56
|
+
}
|
|
57
|
+
return `import { ${[...new Set(names)].join(", ")} } from "@birdycom/omniaui-react";`;
|
|
58
|
+
}
|
|
59
|
+
if (fw === "blade") return `<x-oc::${entry.kind === "block" ? "block." : ""}${entry.name} />`;
|
|
60
|
+
return entry.kind === "block" ? `@birdycom/omniaui-blocks/blocks/${entry.name}.html` : `@birdycom/omniaui/snippets/${entry.name}.html`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function cmdAdd(args, flags) {
|
|
64
|
+
const names = [...args];
|
|
65
|
+
let kind = flags.kind;
|
|
66
|
+
let legacyKind; // `omniaui add block <name>` keeps working
|
|
67
|
+
if (["block", "component", "blocks", "components"].includes(names[0]) && names.length > 1) legacyKind = kind = names.shift().replace(/s$/, "");
|
|
68
|
+
if (kind && !["component", "block"].includes(kind)) throw new Error(`Unknown kind "${kind}". Use component or block.`);
|
|
69
|
+
if (!names.length && !flags.all) throw new Error("Usage: omniaui add <name...> [-f css|vue|react|blade] [--kind component|block] [--dir dir] [--force] [--dry-run] [--import]");
|
|
70
|
+
|
|
71
|
+
const fw = await resolveFramework(flags);
|
|
72
|
+
const cat = await catalog(fw);
|
|
73
|
+
const selected = [];
|
|
74
|
+
if (flags.all) selected.push(...cat.entries.filter((e) => e.kind === (kind || "component")));
|
|
75
|
+
for (const input of names) {
|
|
76
|
+
const hits = findEntries(cat.entries, input, kind);
|
|
77
|
+
if (!hits.length && (await proBlockNames()).includes(input.replace(/^block-/, ""))) {
|
|
78
|
+
throw new Error(fw === "css"
|
|
79
|
+
? `"${input}" is an OmniaUI Pro block. Install @birdycom/omniaui-pro (licensed) to add it.`
|
|
80
|
+
: `"${input}" is an OmniaUI Pro block: use it from @birdycom/omniaui-pro-${fw === "blade" ? "laravel" : fw} (licensed) instead of copying.`);
|
|
81
|
+
}
|
|
82
|
+
if (!hits.length) throw new Error(`Unknown ${kind || "component or block"} "${input}" for ${fw}. Run "omniaui list -f ${fw}" to see the options.`);
|
|
83
|
+
if (hits.length > 1) throw new Error(`"${input}" exists as component and block. Pass --kind component or --kind block.`);
|
|
84
|
+
selected.push(hits[0]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (flags.import) {
|
|
88
|
+
for (const entry of selected) console.log(await importLine(fw, cat.root, entry));
|
|
89
|
+
if (fw === "vue" || fw === "react") {
|
|
90
|
+
try { requireFromProject.resolve(`@birdycom/omniaui-${fw}/package.json`); } catch { console.log(`Package not installed in this project. Install it with: ${INSTALL_HINT[fw]}`); }
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const dir = flags.dir || flags.to || (await defaultDir(fw, legacyKind));
|
|
96
|
+
console.log(`${fw} → ${dir}${flags["dry-run"] ? " (dry run)" : ""}`);
|
|
97
|
+
let total = 0;
|
|
98
|
+
for (const entry of selected) {
|
|
99
|
+
console.log(`${entry.kind} "${entry.name}"`);
|
|
100
|
+
if (fw === "css") total += await copySnippet(entry, dir, flags);
|
|
101
|
+
else total += await copyFiles(cat.root, await closure(fw, cat.root, entry, cat.entries), dir, fw, flags);
|
|
102
|
+
}
|
|
103
|
+
if (flags["dry-run"]) { console.log(`\n${total} file(s) would be copied.`); return; }
|
|
104
|
+
const hasBlock = selected.some((e) => e.kind === "block");
|
|
105
|
+
const glob = { css: "**/*.html", vue: "**/*.vue", react: "**/*.tsx", blade: "**/*.blade.php" }[fw];
|
|
106
|
+
await ensureContentGlob(`${posix(path.normalize(dir)).replace(/\/$/, "")}/${glob}`, hasBlock);
|
|
107
|
+
const hasPro = selected.some((e) => e.pro);
|
|
108
|
+
console.log(`\n${total} file(s) copied. Styles come from @birdycom/omniaui${hasBlock ? " and @birdycom/omniaui-blocks" : ""}${hasPro ? " and @birdycom/omniaui-pro" : ""} ("omniacss build" includes them).`);
|
|
109
|
+
if (fw === "vue" || fw === "react") console.log(`These files need ${fw} in your project (${fw === "vue" ? "3.4+" : "18+"}).`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function cmdList(what, flags = {}) {
|
|
113
|
+
const fw = await resolveFramework(flags);
|
|
114
|
+
const kinds = flags.kind ? [flags.kind] : what ? [what.replace(/s$/, "")] : ["component", "block"];
|
|
115
|
+
const cat = await catalog(fw);
|
|
116
|
+
console.log(`framework: ${fw}`);
|
|
117
|
+
for (const kind of kinds) {
|
|
118
|
+
console.log(`\n${kind}s`);
|
|
119
|
+
for (const e of cat.entries.filter((x) => x.kind === kind)) {
|
|
120
|
+
const label = fw === "vue" ? `Oc${kind === "block" ? "Block" : ""}${pascal(e.name)}`
|
|
121
|
+
: fw === "react" ? path.basename(e.files[0], ".tsx")
|
|
122
|
+
: fw === "blade" ? `<x-oc::${kind === "block" ? "block." : ""}${e.name}>` : "";
|
|
123
|
+
console.log(` ${e.name.padEnd(18)} ${label.padEnd(fw === "css" ? 0 : 30)}${e.description || ""}`.trimEnd());
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|