@og-ui/cli 0.0.0-stage → 0.1.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 +21 -0
- package/bin/ogui.js +102 -0
- package/lib/registry.js +92 -0
- package/package.json +32 -3
- package/registry/accordion-react.json +33 -0
- package/registry/accordion.json +36 -0
- package/registry/alert-react.json +33 -0
- package/registry/alert.json +41 -0
- package/registry/avatar-react.json +33 -0
- package/registry/avatar.json +48 -0
- package/registry/badge-react.json +33 -0
- package/registry/badge.json +52 -0
- package/registry/button-react.json +33 -0
- package/registry/button.json +51 -0
- package/registry/card-react.json +33 -0
- package/registry/card.json +51 -0
- package/registry/checkbox-react.json +33 -0
- package/registry/checkbox.json +46 -0
- package/registry/dialog-react.json +33 -0
- package/registry/dialog.json +53 -0
- package/registry/index.json +1155 -0
- package/registry/input-react.json +33 -0
- package/registry/input.json +45 -0
- package/registry/menu-react.json +33 -0
- package/registry/menu.json +11 -0
- package/registry/og-ui.json +21 -0
- package/registry/pagination-react.json +33 -0
- package/registry/pagination.json +37 -0
- package/registry/popover-react.json +33 -0
- package/registry/popover.json +46 -0
- package/registry/progress-react.json +33 -0
- package/registry/progress.json +35 -0
- package/registry/select-react.json +33 -0
- package/registry/select.json +35 -0
- package/registry/skeleton-react.json +33 -0
- package/registry/skeleton.json +37 -0
- package/registry/slider-react.json +33 -0
- package/registry/slider.json +38 -0
- package/registry/surface.json +37 -0
- package/registry/switch-react.json +33 -0
- package/registry/switch.json +35 -0
- package/registry/table-react.json +33 -0
- package/registry/table.json +38 -0
- package/registry/tabs-react.json +33 -0
- package/registry/tabs.json +41 -0
- package/registry/theme-aurora.json +135 -0
- package/registry/theme-brutal.json +135 -0
- package/registry/theme-clay.json +135 -0
- package/registry/theme-clean.json +135 -0
- package/registry/theme-glass.json +135 -0
- package/registry/theme-liquid-glass.json +135 -0
- package/registry/theme-neumorphism.json +135 -0
- package/registry/theme-provider-react.json +33 -0
- package/registry/toast-react.json +33 -0
- package/registry/toast.json +46 -0
- package/registry/tooltip.json +37 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Omkar
|
|
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/bin/ogui.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ogui: copy OG UI themes and components into a project, shadcn-style.
|
|
3
|
+
// Reads the registry bundled with this package (built from packages/core, tokens and react).
|
|
4
|
+
// The same JSON hosted at https://ui.ogom.in/r/<name>.json also works with `npx shadcn add`.
|
|
5
|
+
import { createInstaller, loadItem, readIndex } from '../lib/registry.js';
|
|
6
|
+
|
|
7
|
+
const [, , command, ...rest] = process.argv;
|
|
8
|
+
|
|
9
|
+
const valueFlags = ['--dir', '--react-dir', '--theme'];
|
|
10
|
+
const flags = new Set(rest.filter((a) => a.startsWith('--') && !valueFlags.includes(a)));
|
|
11
|
+
const valueOf = (name, fallback) => {
|
|
12
|
+
const i = rest.indexOf(name);
|
|
13
|
+
return i >= 0 && rest[i + 1] ? rest[i + 1] : fallback;
|
|
14
|
+
};
|
|
15
|
+
const valueArgs = new Set(valueFlags.map((n) => valueOf(n)).filter(Boolean));
|
|
16
|
+
const names = rest.filter((a) => !a.startsWith('--') && !valueArgs.has(a));
|
|
17
|
+
|
|
18
|
+
const installer = createInstaller({
|
|
19
|
+
cssDir: valueOf('--dir', 'og-ui'),
|
|
20
|
+
reactDir: valueOf('--react-dir', 'components/og'),
|
|
21
|
+
overwrite: flags.has('--overwrite'),
|
|
22
|
+
log: console.log,
|
|
23
|
+
});
|
|
24
|
+
const { install } = installer;
|
|
25
|
+
|
|
26
|
+
function help() {
|
|
27
|
+
console.log(`ogui: OG UI command line (https://ui.ogom.in)
|
|
28
|
+
|
|
29
|
+
Usage
|
|
30
|
+
ogui init [--theme <name>] Write the default theme, base styles and og-ui/index.css
|
|
31
|
+
ogui add <component...> [--react] Copy component CSS (and React source with --react)
|
|
32
|
+
ogui add --all [--react] Copy every component
|
|
33
|
+
ogui theme <name> Add a theme; switch with data-og-theme="<name>" on <html>
|
|
34
|
+
ogui list List components and themes
|
|
35
|
+
|
|
36
|
+
Options
|
|
37
|
+
--dir <path> Where CSS goes (default og-ui)
|
|
38
|
+
--react-dir <path> Where React files go (default components/og)
|
|
39
|
+
--overwrite Replace files you have changed
|
|
40
|
+
|
|
41
|
+
Then import og-ui/index.css once in your app.`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function finish() {
|
|
45
|
+
installer.writeIndex();
|
|
46
|
+
if (installer.npmDeps.size) console.log(`\nThe React files need: npm i ${[...installer.npmDeps].join(' ')}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const isComponent = (i) => i.type === 'registry:component' && !i.name.endsWith('-react');
|
|
50
|
+
const isTheme = (i) => i.name.startsWith('theme-') && !i.name.endsWith('-react');
|
|
51
|
+
|
|
52
|
+
switch (command) {
|
|
53
|
+
case 'init': {
|
|
54
|
+
install('og-ui');
|
|
55
|
+
const theme = valueOf('--theme');
|
|
56
|
+
if (theme && theme !== 'clean') {
|
|
57
|
+
if (!install(`theme-${theme}`)) process.exit(1);
|
|
58
|
+
console.log(`\nSet <html data-og-theme="${theme}"> to use it.`);
|
|
59
|
+
}
|
|
60
|
+
finish();
|
|
61
|
+
console.log('\nImport og-ui/index.css once, e.g. in your root layout or main.js.');
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case 'add': {
|
|
65
|
+
const wanted = flags.has('--all') ? readIndex().filter(isComponent).map((i) => i.name) : names;
|
|
66
|
+
if (!wanted.length) {
|
|
67
|
+
console.error('Name at least one component, e.g. `ogui add button dialog`. Run `ogui list` to see them.');
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
let ok = true;
|
|
71
|
+
for (const name of wanted) {
|
|
72
|
+
// CSS-only components (surface) still install with --react.
|
|
73
|
+
const item = flags.has('--react') && loadItem(`${name}-react`) ? `${name}-react` : name;
|
|
74
|
+
ok = install(item) && ok;
|
|
75
|
+
}
|
|
76
|
+
finish();
|
|
77
|
+
if (!ok) process.exit(1);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case 'theme': {
|
|
81
|
+
const name = names[0];
|
|
82
|
+
if (!name || !loadItem(`theme-${name}`)) {
|
|
83
|
+
console.error(`Pick a theme: ${readIndex().filter(isTheme).map((i) => i.name.slice(6)).join(', ')}`);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
install(`theme-${name}`);
|
|
87
|
+
finish();
|
|
88
|
+
console.log(`\nSwitch to it with <html data-og-theme="${name}">.`);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 'list': {
|
|
92
|
+
const all = readIndex();
|
|
93
|
+
const react = new Set(all.filter((i) => i.name.endsWith('-react')).map((i) => i.name.slice(0, -6)));
|
|
94
|
+
console.log('Components (* has a React version):');
|
|
95
|
+
for (const i of all.filter(isComponent)) console.log(` ${i.name}${react.has(i.name) ? ' *' : ''}`);
|
|
96
|
+
console.log('Themes:');
|
|
97
|
+
for (const i of all.filter(isTheme)) console.log(` ${i.name.slice(6)}`);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
default:
|
|
101
|
+
help();
|
|
102
|
+
}
|
package/lib/registry.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Reads the bundled registry and writes its files into a project. Used by `ogui` and @og-ui/mcp.
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
export const registryDir = join(dirname(fileURLToPath(import.meta.url)), '..', 'registry');
|
|
7
|
+
|
|
8
|
+
export const readIndex = () => JSON.parse(readFileSync(join(registryDir, 'index.json'), 'utf8')).items;
|
|
9
|
+
|
|
10
|
+
export function loadItem(name) {
|
|
11
|
+
if (!/^[a-z0-9-]+$/.test(name)) return null;
|
|
12
|
+
const path = join(registryDir, `${name}.json`);
|
|
13
|
+
return existsSync(path) ? JSON.parse(readFileSync(path, 'utf8')) : null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Registry dependencies are URLs (for shadcn); here they resolve to the bundled item.
|
|
17
|
+
const nameOf = (dep) => dep.split('/').pop().replace(/\.json$/, '');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {{ cwd?: string, cssDir?: string, reactDir?: string, overwrite?: boolean, log?: (line: string) => void }} opts
|
|
21
|
+
*/
|
|
22
|
+
export function createInstaller({ cwd = process.cwd(), cssDir = 'og-ui', reactDir = 'components/og', overwrite = false, log = () => {} } = {}) {
|
|
23
|
+
const root = resolve(cwd);
|
|
24
|
+
const css = resolve(root, cssDir);
|
|
25
|
+
const done = new Set();
|
|
26
|
+
const npmDeps = new Set();
|
|
27
|
+
const written = [];
|
|
28
|
+
const kept = [];
|
|
29
|
+
|
|
30
|
+
/** Map a registry target onto the project's folders, never outside the project. */
|
|
31
|
+
function targetPath(target) {
|
|
32
|
+
const path = target.startsWith('og-ui/')
|
|
33
|
+
? join(css, target.slice('og-ui/'.length))
|
|
34
|
+
: target.startsWith('components/og/')
|
|
35
|
+
? resolve(root, reactDir, target.slice('components/og/'.length))
|
|
36
|
+
: resolve(root, target);
|
|
37
|
+
if (path !== root && !path.startsWith(root + sep)) throw new Error(`Refusing to write outside the project: ${target}`);
|
|
38
|
+
return path;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function install(name) {
|
|
42
|
+
if (done.has(name)) return true;
|
|
43
|
+
const item = loadItem(name);
|
|
44
|
+
if (!item) {
|
|
45
|
+
log(` ✗ ${name}: not in the registry (run \`ogui list\`)`);
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
done.add(name);
|
|
49
|
+
for (const dep of item.registryDependencies ?? []) install(nameOf(dep));
|
|
50
|
+
for (const dep of item.dependencies ?? []) npmDeps.add(dep);
|
|
51
|
+
for (const f of item.files) {
|
|
52
|
+
const path = targetPath(f.target);
|
|
53
|
+
const shown = relative(root, path) || path;
|
|
54
|
+
if (existsSync(path)) {
|
|
55
|
+
if (readFileSync(path, 'utf8') === f.content) continue;
|
|
56
|
+
if (!overwrite) {
|
|
57
|
+
kept.push(shown);
|
|
58
|
+
log(` ! ${shown} exists and differs; kept yours (use --overwrite to replace)`);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
63
|
+
writeFileSync(path, f.content);
|
|
64
|
+
written.push(shown);
|
|
65
|
+
log(` ✓ ${shown}`);
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** og-ui/index.css imports everything installed, in cascade order. */
|
|
71
|
+
function writeIndex() {
|
|
72
|
+
if (!existsSync(css)) return;
|
|
73
|
+
const list = (sub) =>
|
|
74
|
+
existsSync(join(css, sub))
|
|
75
|
+
? readdirSync(join(css, sub))
|
|
76
|
+
.filter((f) => f.endsWith('.css'))
|
|
77
|
+
.sort()
|
|
78
|
+
.map((f) => `${sub}/${f}`)
|
|
79
|
+
: [];
|
|
80
|
+
const files = [
|
|
81
|
+
...['theme.css'].filter((f) => existsSync(join(css, f))),
|
|
82
|
+
...list('themes'), // scoped themes after the default so data-og-theme wins
|
|
83
|
+
...['base.css'].filter((f) => existsSync(join(css, f))),
|
|
84
|
+
...list('components'),
|
|
85
|
+
];
|
|
86
|
+
const text = `/* Generated by ogui. Import this file once. */\n${files.map((f) => `@import './${f}';`).join('\n')}\n`;
|
|
87
|
+
writeFileSync(join(css, 'index.css'), text);
|
|
88
|
+
log(` ✓ ${relative(root, join(css, 'index.css'))} (${files.length} imports)`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return { install, writeIndex, npmDeps, written, kept };
|
|
92
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@og-ui/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The ogui command: add OG UI components and themes to your project.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Omkar",
|
|
7
|
+
"homepage": "https://ui.ogom.in",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"bin": {
|
|
10
|
+
"ogui": "./bin/ogui.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"lib",
|
|
15
|
+
"registry"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
"./lib/registry.js": "./lib/registry.js"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@og-ui/core": "0.1.0",
|
|
28
|
+
"@og-ui/react": "0.1.0",
|
|
29
|
+
"@og-ui/tokens": "0.1.0"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "node --check bin/ogui.js && node scripts/build-registry.mjs",
|
|
33
|
+
"test": "node --test test/"
|
|
34
|
+
}
|
|
6
35
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "accordion-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "accordion (React)",
|
|
6
|
+
"description": "React component(s) from @og-ui/react's navigation.tsx, copied into your project.",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"@og-ui/core"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"https://ui.ogom.in/r/accordion.json"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"path": "components/og/navigation.tsx",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "components/og/navigation.tsx",
|
|
18
|
+
"content": "import {\n createContext,\n forwardRef,\n Fragment,\n useContext,\n useEffect,\n useId,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n type ReactNode,\n} from 'react';\nimport { cx, pageList, useOgUI } from './util.js';\n\n// ---------------------------------------------------------------------------\n// Tabs\n\nexport interface TabItem {\n value: string;\n label: ReactNode;\n content: ReactNode;\n disabled?: boolean;\n}\n\nexport interface TabsProps extends Omit<ComponentPropsWithoutRef<'div'>, 'defaultValue' | 'onChange'> {\n /** Accessible name of the tab list. */\n label: string;\n items: TabItem[];\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n}\n\n/**\n * WAI-ARIA tabs with automatic activation. og-ui.js handles clicks and arrow keys/Home/End\n * and reports the change, so React state follows the DOM rather than fighting it.\n */\nexport function Tabs({ label, items, value, defaultValue, onValueChange, className, ...props }: TabsProps) {\n useOgUI();\n const root = useRef<HTMLDivElement>(null);\n const base = useId();\n const [internal, setInternal] = useState(defaultValue ?? items[0]?.value);\n const current = value ?? internal;\n const change = useRef(onValueChange);\n change.current = onValueChange;\n\n useEffect(() => {\n const el = root.current;\n const onChange = (e: Event) => {\n const next = (e as CustomEvent<{ tab: HTMLElement }>).detail.tab.dataset.value;\n if (next === undefined) return;\n setInternal(next);\n change.current?.(next);\n };\n el?.addEventListener('og-tab-change', onChange);\n return () => el?.removeEventListener('og-tab-change', onChange);\n }, []);\n\n return (\n <div ref={root} className={cx('og-tabs', className)} data-og-tabs=\"\" {...props}>\n <div className=\"og-tabs__list\" role=\"tablist\" aria-label={label}>\n {items.map((item, i) => {\n const selected = item.value === current;\n return (\n <button\n key={item.value}\n type=\"button\"\n role=\"tab\"\n id={`${base}-t${i}`}\n aria-controls={`${base}-p${i}`}\n aria-selected={selected}\n tabIndex={selected ? 0 : -1}\n disabled={item.disabled}\n data-value={item.value}\n className=\"og-tabs__tab\"\n >\n {item.label}\n </button>\n );\n })}\n </div>\n {items.map((item, i) => (\n <div\n key={item.value}\n role=\"tabpanel\"\n id={`${base}-p${i}`}\n aria-labelledby={`${base}-t${i}`}\n tabIndex={0}\n hidden={item.value !== current}\n className=\"og-tabs__panel\"\n >\n {item.content}\n </div>\n ))}\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Accordion (native <details>: keyboard and screen readers work without JS)\n\nconst GroupName = createContext<string | undefined>(undefined);\n\nexport interface AccordionProps extends ComponentPropsWithoutRef<'div'> {\n /** Only one item open at a time (shared <details name>). */\n single?: boolean;\n}\n\nexport const Accordion = forwardRef<HTMLDivElement, AccordionProps>(function Accordion(\n { single, className, ...props },\n ref,\n) {\n const name = useId();\n return (\n <GroupName.Provider value={single ? name : undefined}>\n <div ref={ref} className={cx('og-accordion', className)} {...props} />\n </GroupName.Provider>\n );\n});\n\nexport interface AccordionItemProps extends Omit<ComponentPropsWithoutRef<'details'>, 'title'> {\n title: ReactNode;\n}\n\nexport const AccordionItem = forwardRef<HTMLDetailsElement, AccordionItemProps>(function AccordionItem(\n { title, children, ...props },\n ref,\n) {\n const name = useContext(GroupName);\n return (\n <details ref={ref} name={name} {...props}>\n <summary>{title}</summary>\n <div className=\"og-accordion__content\">{children}</div>\n </details>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Pagination\n\nexport interface PaginationProps extends Omit<ComponentPropsWithoutRef<'nav'>, 'onChange'> {\n page: number;\n pageCount: number;\n /** Render links. Without it, items are buttons that call onPageChange. */\n getHref?: (page: number) => string;\n onPageChange?: (page: number) => void;\n /** Pages shown either side of the current one. */\n siblings?: number;\n}\n\nexport const Pagination = forwardRef<HTMLElement, PaginationProps>(function Pagination(\n { page, pageCount, getHref, onPageChange, siblings = 1, className, 'aria-label': label = 'Pagination', ...props },\n ref,\n) {\n useOgUI();\n const item = (to: number, content: ReactNode, extra: { label?: string; current?: boolean } = {}) => {\n const disabled = to < 1 || to > pageCount;\n const common = {\n className: 'og-pagination__item',\n 'aria-label': extra.label,\n 'aria-current': extra.current ? ('page' as const) : undefined,\n 'aria-disabled': disabled || undefined,\n };\n return getHref ? (\n // Disabled links keep an href so they stay focusable; og-ui.js stops them activating.\n <a {...common} href={getHref(Math.min(Math.max(to, 1), pageCount))} onClick={() => !disabled && onPageChange?.(to)}>\n {content}\n </a>\n ) : (\n <button {...common} type=\"button\" onClick={() => !disabled && onPageChange?.(to)}>\n {content}\n </button>\n );\n };\n\n return (\n <nav ref={ref} aria-label={label} className={cx('og-pagination', className)} {...props}>\n {item(page - 1, '‹', { label: 'Previous page' })}\n {pageList(page, pageCount, siblings).map((p, i) =>\n p === 'gap' ? (\n <span key={`gap${i}`} className=\"og-pagination__gap\" aria-hidden=\"true\">\n …\n </span>\n ) : (\n <Fragment key={p}>{item(p, p, { current: p === page })}</Fragment>\n ),\n )}\n {item(page + 1, '›', { label: 'Next page' })}\n </nav>\n );\n});\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "components/og/util.ts",
|
|
22
|
+
"type": "registry:file",
|
|
23
|
+
"target": "components/og/util.ts",
|
|
24
|
+
"content": "import { useEffect } from 'react';\nimport { initOgUI } from '@og-ui/core/og-ui.js';\n\n/** Join class names, skipping falsy ones. */\nexport const cx = (...parts: (string | false | null | undefined)[]) => parts.filter(Boolean).join(' ');\n\n/**\n * Start og-ui.js (keyboard for menus and tabs, slider fill, popover placement, toasts).\n * Safe to call from every component: it only wires the document once, and only in the browser.\n */\nexport function useOgUI() {\n useEffect(() => initOgUI(), []);\n}\n\n/** Pages to show, with gaps: 1 … 4 5 [6] 7 8 … 20 */\nexport function pageList(page: number, count: number, siblings = 1): (number | 'gap')[] {\n const out: (number | 'gap')[] = [1];\n const from = Math.max(2, page - siblings);\n const to = Math.min(count - 1, page + siblings);\n if (from > 2) out.push('gap');\n for (let p = from; p <= to; p++) out.push(p);\n if (to < count - 1) out.push('gap');\n if (count > 1) out.push(count);\n return out;\n}\n"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "components/og/og-ui.d.ts",
|
|
28
|
+
"type": "registry:file",
|
|
29
|
+
"target": "components/og/og-ui.d.ts",
|
|
30
|
+
"content": "declare module '@og-ui/core/og-ui.js' {\n export function initOgUI(root?: Document | Element): void;\n export function ogToast(\n title: string,\n options?: {\n description?: string;\n variant?: 'success' | 'warning' | 'danger' | 'accent';\n duration?: number;\n },\n ): () => void;\n}\n"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "accordion",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Accordion",
|
|
6
|
+
"description": "Native <details>: works without JavaScript. The same name keeps one item open.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-accordion",
|
|
10
|
+
"og-accordion__content"
|
|
11
|
+
],
|
|
12
|
+
"group": "Navigation & data",
|
|
13
|
+
"markup": [
|
|
14
|
+
{
|
|
15
|
+
"label": "One open at a time",
|
|
16
|
+
"html": "<div class=\"og-accordion\" style=\"width: 100%; max-width: 28rem\">\n <details name=\"accordion\" open><summary>What is OG UI?</summary><div class=\"og-accordion__content\">One component library with seven design themes.</div></details>\n <details name=\"accordion\"><summary>Does it need React?</summary><div class=\"og-accordion__content\">No. It’s CSS classes plus a 3 KB script; React wrappers are optional.</div></details>\n <details name=\"accordion\"><summary>Is it accessible?</summary><div class=\"og-accordion__content\">Every theme is contrast-checked and every component keyboard-tested.</div></details>\n</div>"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"react": "import { Accordion, AccordionItem } from '@og-ui/react';\n\n<Accordion single>\n <AccordionItem title=\"What is OG UI?\" open>One library, seven themes.</AccordionItem>\n <AccordionItem title=\"Does it need React?\">No.</AccordionItem>\n</Accordion>",
|
|
20
|
+
"keyboard": [
|
|
21
|
+
"Tab moves between headers; Enter or Space opens and closes."
|
|
22
|
+
],
|
|
23
|
+
"notes": []
|
|
24
|
+
},
|
|
25
|
+
"registryDependencies": [
|
|
26
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
27
|
+
],
|
|
28
|
+
"files": [
|
|
29
|
+
{
|
|
30
|
+
"path": "og-ui/components/accordion.css",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"target": "og-ui/components/accordion.css",
|
|
33
|
+
"content": "/*! OG UI accordion | MIT | https://ui.ogom.in */\n.og-accordion {\n background: var(--og-surface-raised-fill);\n border: var(--og-border-width) solid var(--og-surface-raised-border);\n box-shadow: var(--og-surface-raised-shadow);\n -webkit-backdrop-filter: var(--og-surface-raised-filter);\n backdrop-filter: var(--og-surface-raised-filter);\n overflow: hidden;\n border-radius: var(--og-radius-lg);\n color: var(--og-color-text);\n font-family: var(--og-font);\n}\n.og-accordion details + details {\n border-top: 1px solid color-mix(in oklab, var(--og-color-text) 10%, transparent);\n}\n.og-accordion summary {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 1rem;\n padding: 0.875rem var(--og-card-pad);\n font-size: 0.9375rem;\n font-weight: var(--og-font-weight-strong);\n list-style: none;\n cursor: pointer;\n}\n.og-accordion summary::-webkit-details-marker {\n display: none;\n}\n.og-accordion summary::after {\n content: \"\";\n display: inline-block;\n width: 1rem;\n height: 1rem;\n background: currentColor;\n -webkit-mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\") center/contain no-repeat;\n mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\") center/contain no-repeat;\n flex: none;\n color: var(--og-color-text-muted);\n transition: transform var(--og-motion-duration) var(--og-easing);\n}\n.og-accordion summary:hover {\n background: color-mix(in oklab, var(--og-color-text) 4%, transparent);\n}\n.og-accordion summary:focus-visible {\n outline: 2px solid var(--og-color-focus-ring);\n outline-offset: -2px;\n}\n.og-accordion details[open] > summary::after {\n transform: rotate(180deg);\n}\n.og-accordion details::details-content {\n height: 0;\n overflow: clip;\n transition: height var(--og-motion-duration) var(--og-easing), content-visibility var(--og-motion-duration) allow-discrete;\n}\n.og-accordion details[open]::details-content {\n height: auto;\n}\n.og-accordion__content {\n padding: 0 var(--og-card-pad) var(--og-card-pad);\n color: var(--og-color-text-muted);\n font-size: 0.875rem;\n line-height: 1.6;\n}\n\n:root {\n interpolate-size: allow-keywords;\n}\n"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "alert-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "alert (React)",
|
|
6
|
+
"description": "React component(s) from @og-ui/react's components.tsx, copied into your project.",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"@og-ui/core"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"https://ui.ogom.in/r/alert.json"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"path": "components/og/components.tsx",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "components/og/components.tsx",
|
|
18
|
+
"content": "import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { cx, useOgUI } from './util.js';\n\ntype Palette = 1 | 2 | 3 | 4 | 5 | 6;\ntype Status = 'accent' | 'success' | 'warning' | 'danger';\n\n// ---------------------------------------------------------------------------\n// Button\n\nexport interface ButtonProps extends ComponentPropsWithoutRef<'button'> {\n variant?: 'primary' | 'ghost' | 'danger';\n size?: 'sm' | 'lg';\n /** Square icon button. Give it an aria-label. */\n icon?: boolean;\n block?: boolean;\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n { variant, size, icon, block, className, type = 'button', ...props },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n className={cx(\n 'og-button',\n variant && `og-button--${variant}`,\n size && `og-button--${size}`,\n icon && 'og-button--icon',\n block && 'og-button--block',\n className,\n )}\n {...props}\n />\n );\n});\n\n// ---------------------------------------------------------------------------\n// Card\n\nexport interface CardProps extends Omit<ComponentPropsWithoutRef<'article'>, 'title'> {\n title?: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n /** Palette tint 1–6. */\n tint?: Palette;\n}\n\nexport const Card = forwardRef<HTMLElement, CardProps>(function Card(\n { title, description, footer, tint, className, children, ...props },\n ref,\n) {\n return (\n <article ref={ref} className={cx('og-card', tint && `og-card--tint-${tint}`, className)} {...props}>\n {(title || description) && (\n <header className=\"og-card__header\">\n {title && <h3 className=\"og-card__title\">{title}</h3>}\n {description && <p className=\"og-card__description\">{description}</p>}\n </header>\n )}\n {children !== undefined && <div className=\"og-card__body\">{children}</div>}\n {footer && <footer className=\"og-card__footer\">{footer}</footer>}\n </article>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Form controls\n\n/** Wraps a control in og-field with a label and hint when they are given. */\nfunction Field({ label, hint, children }: { label?: ReactNode; hint?: ReactNode; children: ReactNode }) {\n if (!label && !hint) return <>{children}</>;\n return (\n <label className=\"og-field\">\n {label && <span className=\"og-label\">{label}</span>}\n {children}\n {hint && <span className=\"og-hint\">{hint}</span>}\n </label>\n );\n}\n\nexport interface InputProps extends ComponentPropsWithoutRef<'input'> {\n label?: ReactNode;\n hint?: ReactNode;\n invalid?: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n { label, hint, invalid, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <input\n ref={ref}\n className={cx('og-input', className)}\n aria-invalid={invalid || props['aria-invalid']}\n {...props}\n />\n </Field>\n );\n});\n\nexport interface SelectProps extends ComponentPropsWithoutRef<'select'> {\n label?: ReactNode;\n hint?: ReactNode;\n}\n\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n { label, hint, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <span className={cx('og-select', className)}>\n <select ref={ref} {...props} />\n </span>\n </Field>\n );\n});\n\nexport interface CheckboxProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n /** Shows the dash state. Sets the DOM property, which has no HTML attribute. */\n indeterminate?: boolean;\n}\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n { label, indeterminate, className, ...props },\n ref,\n) {\n const setRef = (el: HTMLInputElement | null) => {\n if (el) el.indeterminate = !!indeterminate;\n if (typeof ref === 'function') ref(el);\n else if (ref) ref.current = el;\n };\n return (\n <label className=\"og-check\">\n <input ref={setRef} type=\"checkbox\" className={cx('og-checkbox', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SwitchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'role'> {\n label?: ReactNode;\n}\n\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\n { label, className, ...props },\n ref,\n) {\n return (\n <label className=\"og-check\">\n <input ref={ref} type=\"checkbox\" role=\"switch\" className={cx('og-switch', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SliderProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n}\n\nexport const Slider = forwardRef<HTMLInputElement, SliderProps>(function Slider(\n { label, className, style, min = 0, max = 100, ...props },\n ref,\n) {\n useOgUI();\n // og-ui.js keeps the fill in sync while dragging; this covers the first render and\n // controlled value changes that don't come from the user.\n const value = Number(props.value ?? props.defaultValue ?? (Number(min) + Number(max)) / 2);\n const span = Number(max) - Number(min);\n const pct = span ? ((value - Number(min)) / span) * 100 : 0;\n return (\n <Field label={label}>\n <input\n ref={ref}\n type=\"range\"\n min={min}\n max={max}\n className={cx('og-slider', className)}\n style={{ '--_value': `${pct}%`, ...style } as CSSProperties}\n {...props}\n />\n </Field>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Display\n\nexport interface BadgeProps extends ComponentPropsWithoutRef<'span'> {\n variant?: Status | Palette;\n /** Filled. Documented for variant=\"accent\". */\n solid?: boolean;\n}\n\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n { variant, solid, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-badge', variant && `og-badge--${variant}`, solid && 'og-badge--solid', className)}\n {...props}\n />\n );\n});\n\nexport interface AvatarProps extends Omit<ComponentPropsWithoutRef<'span'>, 'color'> {\n /** Full name: used for the initials and the accessible name. */\n name: string;\n src?: string;\n color?: Palette;\n size?: 'sm' | 'lg';\n}\n\nconst initials = (name: string) =>\n name\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map((w) => w[0]?.toUpperCase())\n .join('');\n\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n { name, src, color, size, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-avatar', color && `og-avatar--${color}`, size && `og-avatar--${size}`, className)}\n role={src ? undefined : 'img'}\n aria-label={src ? undefined : name}\n {...props}\n >\n {src ? <img src={src} alt={name} /> : initials(name)}\n </span>\n );\n});\n\nexport interface AlertProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title'> {\n variant?: Status;\n title?: ReactNode;\n}\n\n/** role=\"status\" by default; pass role=\"alert\" only for urgent errors. */\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(\n { variant, title, className, children, role = 'status', ...props },\n ref,\n) {\n return (\n <div ref={ref} role={role} className={cx('og-alert', variant && `og-alert--${variant}`, className)} {...props}>\n {title && <p className=\"og-alert__title\">{title}</p>}\n {children && <p className=\"og-alert__description\">{children}</p>}\n </div>\n );\n});\n\n/** Leave out value for an indeterminate bar. Give it an aria-label. */\nexport const Progress = forwardRef<HTMLProgressElement, ComponentPropsWithoutRef<'progress'>>(function Progress(\n { className, max = 100, ...props },\n ref,\n) {\n return <progress ref={ref} max={max} className={cx('og-progress', className)} {...props} />;\n});\n\nexport interface SkeletonProps extends ComponentPropsWithoutRef<'div'> {\n shape?: 'text' | 'circle';\n}\n\nexport const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>(function Skeleton(\n { shape, className, ...props },\n ref,\n) {\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={cx('og-skeleton', shape && `og-skeleton--${shape}`, className)}\n {...props}\n />\n );\n});\n\n/** The wrapper scrolls sideways on small screens. Use className=\"og-table__num\" on number cells. */\nexport const Table = forwardRef<HTMLTableElement, ComponentPropsWithoutRef<'table'>>(function Table(\n { className, ...props },\n ref,\n) {\n return (\n <div className=\"og-table-wrap\">\n <table ref={ref} className={cx('og-table', className)} {...props} />\n </div>\n );\n});\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "components/og/util.ts",
|
|
22
|
+
"type": "registry:file",
|
|
23
|
+
"target": "components/og/util.ts",
|
|
24
|
+
"content": "import { useEffect } from 'react';\nimport { initOgUI } from '@og-ui/core/og-ui.js';\n\n/** Join class names, skipping falsy ones. */\nexport const cx = (...parts: (string | false | null | undefined)[]) => parts.filter(Boolean).join(' ');\n\n/**\n * Start og-ui.js (keyboard for menus and tabs, slider fill, popover placement, toasts).\n * Safe to call from every component: it only wires the document once, and only in the browser.\n */\nexport function useOgUI() {\n useEffect(() => initOgUI(), []);\n}\n\n/** Pages to show, with gaps: 1 … 4 5 [6] 7 8 … 20 */\nexport function pageList(page: number, count: number, siblings = 1): (number | 'gap')[] {\n const out: (number | 'gap')[] = [1];\n const from = Math.max(2, page - siblings);\n const to = Math.min(count - 1, page + siblings);\n if (from > 2) out.push('gap');\n for (let p = from; p <= to; p++) out.push(p);\n if (to < count - 1) out.push('gap');\n if (count > 1) out.push(count);\n return out;\n}\n"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "components/og/og-ui.d.ts",
|
|
28
|
+
"type": "registry:file",
|
|
29
|
+
"target": "components/og/og-ui.d.ts",
|
|
30
|
+
"content": "declare module '@og-ui/core/og-ui.js' {\n export function initOgUI(root?: Document | Element): void;\n export function ogToast(\n title: string,\n options?: {\n description?: string;\n variant?: 'success' | 'warning' | 'danger' | 'accent';\n duration?: number;\n },\n ): () => void;\n}\n"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "alert",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Alert",
|
|
6
|
+
"description": "Inline messages in four tones.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-alert",
|
|
10
|
+
"og-alert__title",
|
|
11
|
+
"og-alert__description",
|
|
12
|
+
"og-alert--accent",
|
|
13
|
+
"og-alert--success",
|
|
14
|
+
"og-alert--warning",
|
|
15
|
+
"og-alert--danger"
|
|
16
|
+
],
|
|
17
|
+
"group": "Feedback",
|
|
18
|
+
"markup": [
|
|
19
|
+
{
|
|
20
|
+
"label": "Tones",
|
|
21
|
+
"html": "<div class=\"og-alert og-alert--success\" role=\"status\"><p class=\"og-alert__title\">Payment received</p><p class=\"og-alert__description\">₹4,200 from Acme Ltd landed in your account.</p></div>\n<div class=\"og-alert og-alert--warning\" role=\"status\"><p class=\"og-alert__title\">Card expires soon</p><p class=\"og-alert__description\">Update it before 1 January.</p></div>\n<div class=\"og-alert og-alert--danger\" role=\"alert\"><p class=\"og-alert__title\">Sync failed</p><p class=\"og-alert__description\">We’ll retry in 5 minutes.</p></div>"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"react": "import { Alert } from '@og-ui/react';\n\n<Alert variant=\"warning\" title=\"Card expires soon\">Update it before 1 January.</Alert>",
|
|
25
|
+
"keyboard": [
|
|
26
|
+
"Not focusable. role=\"status\" is announced politely; use role=\"alert\" only for urgent errors."
|
|
27
|
+
],
|
|
28
|
+
"notes": []
|
|
29
|
+
},
|
|
30
|
+
"registryDependencies": [
|
|
31
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
32
|
+
],
|
|
33
|
+
"files": [
|
|
34
|
+
{
|
|
35
|
+
"path": "og-ui/components/alert.css",
|
|
36
|
+
"type": "registry:file",
|
|
37
|
+
"target": "og-ui/components/alert.css",
|
|
38
|
+
"content": "/*! OG UI alert | MIT | https://ui.ogom.in */\n.og-alert {\n --_c: var(--og-color-text-muted);\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n padding: 0.875rem 1rem 0.875rem 1.25rem;\n overflow: hidden;\n border: var(--og-border-width) solid color-mix(in oklab, var(--_c) 35%, transparent);\n border-radius: var(--og-radius-md);\n background: color-mix(in oklab, var(--_c) 10%, var(--og-surface-raised-fill));\n color: var(--og-color-text);\n font-family: var(--og-font);\n font-size: 0.875rem;\n}\n.og-alert::before {\n content: \"\";\n position: absolute;\n inset: 0 auto 0 0;\n width: 4px;\n background: var(--_c);\n}\n.og-alert__title {\n margin: 0;\n font-weight: var(--og-font-weight-strong);\n}\n.og-alert__description {\n margin: 0;\n color: var(--og-color-text-muted);\n line-height: 1.5;\n}\n.og-alert--accent {\n --_c: var(--og-color-accent);\n}\n.og-alert--success {\n --_c: var(--og-color-success);\n}\n.og-alert--warning {\n --_c: var(--og-color-warning);\n}\n.og-alert--danger {\n --_c: var(--og-color-danger);\n}\n"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "avatar-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "avatar (React)",
|
|
6
|
+
"description": "React component(s) from @og-ui/react's components.tsx, copied into your project.",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"@og-ui/core"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"https://ui.ogom.in/r/avatar.json"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"path": "components/og/components.tsx",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "components/og/components.tsx",
|
|
18
|
+
"content": "import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { cx, useOgUI } from './util.js';\n\ntype Palette = 1 | 2 | 3 | 4 | 5 | 6;\ntype Status = 'accent' | 'success' | 'warning' | 'danger';\n\n// ---------------------------------------------------------------------------\n// Button\n\nexport interface ButtonProps extends ComponentPropsWithoutRef<'button'> {\n variant?: 'primary' | 'ghost' | 'danger';\n size?: 'sm' | 'lg';\n /** Square icon button. Give it an aria-label. */\n icon?: boolean;\n block?: boolean;\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n { variant, size, icon, block, className, type = 'button', ...props },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n className={cx(\n 'og-button',\n variant && `og-button--${variant}`,\n size && `og-button--${size}`,\n icon && 'og-button--icon',\n block && 'og-button--block',\n className,\n )}\n {...props}\n />\n );\n});\n\n// ---------------------------------------------------------------------------\n// Card\n\nexport interface CardProps extends Omit<ComponentPropsWithoutRef<'article'>, 'title'> {\n title?: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n /** Palette tint 1–6. */\n tint?: Palette;\n}\n\nexport const Card = forwardRef<HTMLElement, CardProps>(function Card(\n { title, description, footer, tint, className, children, ...props },\n ref,\n) {\n return (\n <article ref={ref} className={cx('og-card', tint && `og-card--tint-${tint}`, className)} {...props}>\n {(title || description) && (\n <header className=\"og-card__header\">\n {title && <h3 className=\"og-card__title\">{title}</h3>}\n {description && <p className=\"og-card__description\">{description}</p>}\n </header>\n )}\n {children !== undefined && <div className=\"og-card__body\">{children}</div>}\n {footer && <footer className=\"og-card__footer\">{footer}</footer>}\n </article>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Form controls\n\n/** Wraps a control in og-field with a label and hint when they are given. */\nfunction Field({ label, hint, children }: { label?: ReactNode; hint?: ReactNode; children: ReactNode }) {\n if (!label && !hint) return <>{children}</>;\n return (\n <label className=\"og-field\">\n {label && <span className=\"og-label\">{label}</span>}\n {children}\n {hint && <span className=\"og-hint\">{hint}</span>}\n </label>\n );\n}\n\nexport interface InputProps extends ComponentPropsWithoutRef<'input'> {\n label?: ReactNode;\n hint?: ReactNode;\n invalid?: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n { label, hint, invalid, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <input\n ref={ref}\n className={cx('og-input', className)}\n aria-invalid={invalid || props['aria-invalid']}\n {...props}\n />\n </Field>\n );\n});\n\nexport interface SelectProps extends ComponentPropsWithoutRef<'select'> {\n label?: ReactNode;\n hint?: ReactNode;\n}\n\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n { label, hint, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <span className={cx('og-select', className)}>\n <select ref={ref} {...props} />\n </span>\n </Field>\n );\n});\n\nexport interface CheckboxProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n /** Shows the dash state. Sets the DOM property, which has no HTML attribute. */\n indeterminate?: boolean;\n}\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n { label, indeterminate, className, ...props },\n ref,\n) {\n const setRef = (el: HTMLInputElement | null) => {\n if (el) el.indeterminate = !!indeterminate;\n if (typeof ref === 'function') ref(el);\n else if (ref) ref.current = el;\n };\n return (\n <label className=\"og-check\">\n <input ref={setRef} type=\"checkbox\" className={cx('og-checkbox', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SwitchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'role'> {\n label?: ReactNode;\n}\n\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\n { label, className, ...props },\n ref,\n) {\n return (\n <label className=\"og-check\">\n <input ref={ref} type=\"checkbox\" role=\"switch\" className={cx('og-switch', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SliderProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n}\n\nexport const Slider = forwardRef<HTMLInputElement, SliderProps>(function Slider(\n { label, className, style, min = 0, max = 100, ...props },\n ref,\n) {\n useOgUI();\n // og-ui.js keeps the fill in sync while dragging; this covers the first render and\n // controlled value changes that don't come from the user.\n const value = Number(props.value ?? props.defaultValue ?? (Number(min) + Number(max)) / 2);\n const span = Number(max) - Number(min);\n const pct = span ? ((value - Number(min)) / span) * 100 : 0;\n return (\n <Field label={label}>\n <input\n ref={ref}\n type=\"range\"\n min={min}\n max={max}\n className={cx('og-slider', className)}\n style={{ '--_value': `${pct}%`, ...style } as CSSProperties}\n {...props}\n />\n </Field>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Display\n\nexport interface BadgeProps extends ComponentPropsWithoutRef<'span'> {\n variant?: Status | Palette;\n /** Filled. Documented for variant=\"accent\". */\n solid?: boolean;\n}\n\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n { variant, solid, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-badge', variant && `og-badge--${variant}`, solid && 'og-badge--solid', className)}\n {...props}\n />\n );\n});\n\nexport interface AvatarProps extends Omit<ComponentPropsWithoutRef<'span'>, 'color'> {\n /** Full name: used for the initials and the accessible name. */\n name: string;\n src?: string;\n color?: Palette;\n size?: 'sm' | 'lg';\n}\n\nconst initials = (name: string) =>\n name\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map((w) => w[0]?.toUpperCase())\n .join('');\n\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n { name, src, color, size, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-avatar', color && `og-avatar--${color}`, size && `og-avatar--${size}`, className)}\n role={src ? undefined : 'img'}\n aria-label={src ? undefined : name}\n {...props}\n >\n {src ? <img src={src} alt={name} /> : initials(name)}\n </span>\n );\n});\n\nexport interface AlertProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title'> {\n variant?: Status;\n title?: ReactNode;\n}\n\n/** role=\"status\" by default; pass role=\"alert\" only for urgent errors. */\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(\n { variant, title, className, children, role = 'status', ...props },\n ref,\n) {\n return (\n <div ref={ref} role={role} className={cx('og-alert', variant && `og-alert--${variant}`, className)} {...props}>\n {title && <p className=\"og-alert__title\">{title}</p>}\n {children && <p className=\"og-alert__description\">{children}</p>}\n </div>\n );\n});\n\n/** Leave out value for an indeterminate bar. Give it an aria-label. */\nexport const Progress = forwardRef<HTMLProgressElement, ComponentPropsWithoutRef<'progress'>>(function Progress(\n { className, max = 100, ...props },\n ref,\n) {\n return <progress ref={ref} max={max} className={cx('og-progress', className)} {...props} />;\n});\n\nexport interface SkeletonProps extends ComponentPropsWithoutRef<'div'> {\n shape?: 'text' | 'circle';\n}\n\nexport const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>(function Skeleton(\n { shape, className, ...props },\n ref,\n) {\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={cx('og-skeleton', shape && `og-skeleton--${shape}`, className)}\n {...props}\n />\n );\n});\n\n/** The wrapper scrolls sideways on small screens. Use className=\"og-table__num\" on number cells. */\nexport const Table = forwardRef<HTMLTableElement, ComponentPropsWithoutRef<'table'>>(function Table(\n { className, ...props },\n ref,\n) {\n return (\n <div className=\"og-table-wrap\">\n <table ref={ref} className={cx('og-table', className)} {...props} />\n </div>\n );\n});\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "components/og/util.ts",
|
|
22
|
+
"type": "registry:file",
|
|
23
|
+
"target": "components/og/util.ts",
|
|
24
|
+
"content": "import { useEffect } from 'react';\nimport { initOgUI } from '@og-ui/core/og-ui.js';\n\n/** Join class names, skipping falsy ones. */\nexport const cx = (...parts: (string | false | null | undefined)[]) => parts.filter(Boolean).join(' ');\n\n/**\n * Start og-ui.js (keyboard for menus and tabs, slider fill, popover placement, toasts).\n * Safe to call from every component: it only wires the document once, and only in the browser.\n */\nexport function useOgUI() {\n useEffect(() => initOgUI(), []);\n}\n\n/** Pages to show, with gaps: 1 … 4 5 [6] 7 8 … 20 */\nexport function pageList(page: number, count: number, siblings = 1): (number | 'gap')[] {\n const out: (number | 'gap')[] = [1];\n const from = Math.max(2, page - siblings);\n const to = Math.min(count - 1, page + siblings);\n if (from > 2) out.push('gap');\n for (let p = from; p <= to; p++) out.push(p);\n if (to < count - 1) out.push('gap');\n if (count > 1) out.push(count);\n return out;\n}\n"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "components/og/og-ui.d.ts",
|
|
28
|
+
"type": "registry:file",
|
|
29
|
+
"target": "components/og/og-ui.d.ts",
|
|
30
|
+
"content": "declare module '@og-ui/core/og-ui.js' {\n export function initOgUI(root?: Document | Element): void;\n export function ogToast(\n title: string,\n options?: {\n description?: string;\n variant?: 'success' | 'warning' | 'danger' | 'accent';\n duration?: number;\n },\n ): () => void;\n}\n"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "avatar",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Avatar",
|
|
6
|
+
"description": "A photo or initials in a palette colour, in three sizes, and a stacked group.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-avatar",
|
|
10
|
+
"og-avatar--1",
|
|
11
|
+
"og-avatar--2",
|
|
12
|
+
"og-avatar--3",
|
|
13
|
+
"og-avatar--4",
|
|
14
|
+
"og-avatar--5",
|
|
15
|
+
"og-avatar--6",
|
|
16
|
+
"og-avatar--sm",
|
|
17
|
+
"og-avatar--lg",
|
|
18
|
+
"og-avatar-group"
|
|
19
|
+
],
|
|
20
|
+
"group": "Actions & display",
|
|
21
|
+
"markup": [
|
|
22
|
+
{
|
|
23
|
+
"label": "Initials and sizes",
|
|
24
|
+
"html": "<span class=\"og-avatar og-avatar--sm og-avatar--1\" role=\"img\" aria-label=\"Asha Rao\">AR</span>\n<span class=\"og-avatar og-avatar--2\" role=\"img\" aria-label=\"Omkar Lande\">OL</span>\n<span class=\"og-avatar og-avatar--lg og-avatar--3\" role=\"img\" aria-label=\"Dev Mehta\">DM</span>"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"label": "Group",
|
|
28
|
+
"html": "<div class=\"og-avatar-group\">\n <span class=\"og-avatar og-avatar--4\" role=\"img\" aria-label=\"Kiran Shah\">KS</span>\n <span class=\"og-avatar og-avatar--5\" role=\"img\" aria-label=\"Lena Park\">LP</span>\n <span class=\"og-avatar og-avatar--6\" role=\"img\" aria-label=\"Sam Ito\">SI</span>\n</div>"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"react": "import { Avatar } from '@og-ui/react';\n\n<Avatar name=\"Omkar Lande\" color={2} />\n<Avatar name=\"Asha Rao\" src=\"/asha.jpg\" size=\"lg\" />",
|
|
32
|
+
"keyboard": [
|
|
33
|
+
"Not focusable. Initials avatars carry role=\"img\" and the full name as aria-label; photos use alt."
|
|
34
|
+
],
|
|
35
|
+
"notes": []
|
|
36
|
+
},
|
|
37
|
+
"registryDependencies": [
|
|
38
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
39
|
+
],
|
|
40
|
+
"files": [
|
|
41
|
+
{
|
|
42
|
+
"path": "og-ui/components/avatar.css",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"target": "og-ui/components/avatar.css",
|
|
45
|
+
"content": "/*! OG UI avatar | MIT | https://ui.ogom.in */\n.og-avatar {\n --_s: 2.25rem;\n --_c: var(--og-palette-1);\n display: inline-grid;\n place-items: center;\n flex: none;\n width: var(--_s);\n height: var(--_s);\n overflow: hidden;\n border: var(--og-border-width) solid var(--og-surface-raised-border);\n border-radius: var(--og-radius-full);\n background: color-mix(in oklab, var(--_c) 22%, var(--og-surface-raised-fill));\n color: color-mix(in oklab, var(--_c) 50%, var(--og-color-text));\n font-family: var(--og-font);\n font-size: calc(var(--_s) * 0.38);\n font-weight: var(--og-font-weight-strong);\n line-height: 1;\n user-select: none;\n}\n.og-avatar img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n.og-avatar--1 {\n --_c: var(--og-palette-1);\n}\n.og-avatar--2 {\n --_c: var(--og-palette-2);\n}\n.og-avatar--3 {\n --_c: var(--og-palette-3);\n}\n.og-avatar--4 {\n --_c: var(--og-palette-4);\n}\n.og-avatar--5 {\n --_c: var(--og-palette-5);\n}\n.og-avatar--6 {\n --_c: var(--og-palette-6);\n}\n.og-avatar--sm {\n --_s: 1.75rem;\n}\n.og-avatar--lg {\n --_s: 3rem;\n}\n\n.og-avatar-group {\n display: inline-flex;\n}\n.og-avatar-group .og-avatar + .og-avatar {\n margin-left: calc(var(--_s, 2.25rem) * -0.18);\n box-shadow: 0 0 0 2px var(--og-color-bg);\n}\n"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "badge-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "badge (React)",
|
|
6
|
+
"description": "React component(s) from @og-ui/react's components.tsx, copied into your project.",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"@og-ui/core"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"https://ui.ogom.in/r/badge.json"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"path": "components/og/components.tsx",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "components/og/components.tsx",
|
|
18
|
+
"content": "import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { cx, useOgUI } from './util.js';\n\ntype Palette = 1 | 2 | 3 | 4 | 5 | 6;\ntype Status = 'accent' | 'success' | 'warning' | 'danger';\n\n// ---------------------------------------------------------------------------\n// Button\n\nexport interface ButtonProps extends ComponentPropsWithoutRef<'button'> {\n variant?: 'primary' | 'ghost' | 'danger';\n size?: 'sm' | 'lg';\n /** Square icon button. Give it an aria-label. */\n icon?: boolean;\n block?: boolean;\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n { variant, size, icon, block, className, type = 'button', ...props },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n className={cx(\n 'og-button',\n variant && `og-button--${variant}`,\n size && `og-button--${size}`,\n icon && 'og-button--icon',\n block && 'og-button--block',\n className,\n )}\n {...props}\n />\n );\n});\n\n// ---------------------------------------------------------------------------\n// Card\n\nexport interface CardProps extends Omit<ComponentPropsWithoutRef<'article'>, 'title'> {\n title?: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n /** Palette tint 1–6. */\n tint?: Palette;\n}\n\nexport const Card = forwardRef<HTMLElement, CardProps>(function Card(\n { title, description, footer, tint, className, children, ...props },\n ref,\n) {\n return (\n <article ref={ref} className={cx('og-card', tint && `og-card--tint-${tint}`, className)} {...props}>\n {(title || description) && (\n <header className=\"og-card__header\">\n {title && <h3 className=\"og-card__title\">{title}</h3>}\n {description && <p className=\"og-card__description\">{description}</p>}\n </header>\n )}\n {children !== undefined && <div className=\"og-card__body\">{children}</div>}\n {footer && <footer className=\"og-card__footer\">{footer}</footer>}\n </article>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Form controls\n\n/** Wraps a control in og-field with a label and hint when they are given. */\nfunction Field({ label, hint, children }: { label?: ReactNode; hint?: ReactNode; children: ReactNode }) {\n if (!label && !hint) return <>{children}</>;\n return (\n <label className=\"og-field\">\n {label && <span className=\"og-label\">{label}</span>}\n {children}\n {hint && <span className=\"og-hint\">{hint}</span>}\n </label>\n );\n}\n\nexport interface InputProps extends ComponentPropsWithoutRef<'input'> {\n label?: ReactNode;\n hint?: ReactNode;\n invalid?: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n { label, hint, invalid, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <input\n ref={ref}\n className={cx('og-input', className)}\n aria-invalid={invalid || props['aria-invalid']}\n {...props}\n />\n </Field>\n );\n});\n\nexport interface SelectProps extends ComponentPropsWithoutRef<'select'> {\n label?: ReactNode;\n hint?: ReactNode;\n}\n\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n { label, hint, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <span className={cx('og-select', className)}>\n <select ref={ref} {...props} />\n </span>\n </Field>\n );\n});\n\nexport interface CheckboxProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n /** Shows the dash state. Sets the DOM property, which has no HTML attribute. */\n indeterminate?: boolean;\n}\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n { label, indeterminate, className, ...props },\n ref,\n) {\n const setRef = (el: HTMLInputElement | null) => {\n if (el) el.indeterminate = !!indeterminate;\n if (typeof ref === 'function') ref(el);\n else if (ref) ref.current = el;\n };\n return (\n <label className=\"og-check\">\n <input ref={setRef} type=\"checkbox\" className={cx('og-checkbox', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SwitchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'role'> {\n label?: ReactNode;\n}\n\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\n { label, className, ...props },\n ref,\n) {\n return (\n <label className=\"og-check\">\n <input ref={ref} type=\"checkbox\" role=\"switch\" className={cx('og-switch', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SliderProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n}\n\nexport const Slider = forwardRef<HTMLInputElement, SliderProps>(function Slider(\n { label, className, style, min = 0, max = 100, ...props },\n ref,\n) {\n useOgUI();\n // og-ui.js keeps the fill in sync while dragging; this covers the first render and\n // controlled value changes that don't come from the user.\n const value = Number(props.value ?? props.defaultValue ?? (Number(min) + Number(max)) / 2);\n const span = Number(max) - Number(min);\n const pct = span ? ((value - Number(min)) / span) * 100 : 0;\n return (\n <Field label={label}>\n <input\n ref={ref}\n type=\"range\"\n min={min}\n max={max}\n className={cx('og-slider', className)}\n style={{ '--_value': `${pct}%`, ...style } as CSSProperties}\n {...props}\n />\n </Field>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Display\n\nexport interface BadgeProps extends ComponentPropsWithoutRef<'span'> {\n variant?: Status | Palette;\n /** Filled. Documented for variant=\"accent\". */\n solid?: boolean;\n}\n\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n { variant, solid, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-badge', variant && `og-badge--${variant}`, solid && 'og-badge--solid', className)}\n {...props}\n />\n );\n});\n\nexport interface AvatarProps extends Omit<ComponentPropsWithoutRef<'span'>, 'color'> {\n /** Full name: used for the initials and the accessible name. */\n name: string;\n src?: string;\n color?: Palette;\n size?: 'sm' | 'lg';\n}\n\nconst initials = (name: string) =>\n name\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map((w) => w[0]?.toUpperCase())\n .join('');\n\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n { name, src, color, size, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-avatar', color && `og-avatar--${color}`, size && `og-avatar--${size}`, className)}\n role={src ? undefined : 'img'}\n aria-label={src ? undefined : name}\n {...props}\n >\n {src ? <img src={src} alt={name} /> : initials(name)}\n </span>\n );\n});\n\nexport interface AlertProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title'> {\n variant?: Status;\n title?: ReactNode;\n}\n\n/** role=\"status\" by default; pass role=\"alert\" only for urgent errors. */\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(\n { variant, title, className, children, role = 'status', ...props },\n ref,\n) {\n return (\n <div ref={ref} role={role} className={cx('og-alert', variant && `og-alert--${variant}`, className)} {...props}>\n {title && <p className=\"og-alert__title\">{title}</p>}\n {children && <p className=\"og-alert__description\">{children}</p>}\n </div>\n );\n});\n\n/** Leave out value for an indeterminate bar. Give it an aria-label. */\nexport const Progress = forwardRef<HTMLProgressElement, ComponentPropsWithoutRef<'progress'>>(function Progress(\n { className, max = 100, ...props },\n ref,\n) {\n return <progress ref={ref} max={max} className={cx('og-progress', className)} {...props} />;\n});\n\nexport interface SkeletonProps extends ComponentPropsWithoutRef<'div'> {\n shape?: 'text' | 'circle';\n}\n\nexport const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>(function Skeleton(\n { shape, className, ...props },\n ref,\n) {\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={cx('og-skeleton', shape && `og-skeleton--${shape}`, className)}\n {...props}\n />\n );\n});\n\n/** The wrapper scrolls sideways on small screens. Use className=\"og-table__num\" on number cells. */\nexport const Table = forwardRef<HTMLTableElement, ComponentPropsWithoutRef<'table'>>(function Table(\n { className, ...props },\n ref,\n) {\n return (\n <div className=\"og-table-wrap\">\n <table ref={ref} className={cx('og-table', className)} {...props} />\n </div>\n );\n});\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "components/og/util.ts",
|
|
22
|
+
"type": "registry:file",
|
|
23
|
+
"target": "components/og/util.ts",
|
|
24
|
+
"content": "import { useEffect } from 'react';\nimport { initOgUI } from '@og-ui/core/og-ui.js';\n\n/** Join class names, skipping falsy ones. */\nexport const cx = (...parts: (string | false | null | undefined)[]) => parts.filter(Boolean).join(' ');\n\n/**\n * Start og-ui.js (keyboard for menus and tabs, slider fill, popover placement, toasts).\n * Safe to call from every component: it only wires the document once, and only in the browser.\n */\nexport function useOgUI() {\n useEffect(() => initOgUI(), []);\n}\n\n/** Pages to show, with gaps: 1 … 4 5 [6] 7 8 … 20 */\nexport function pageList(page: number, count: number, siblings = 1): (number | 'gap')[] {\n const out: (number | 'gap')[] = [1];\n const from = Math.max(2, page - siblings);\n const to = Math.min(count - 1, page + siblings);\n if (from > 2) out.push('gap');\n for (let p = from; p <= to; p++) out.push(p);\n if (to < count - 1) out.push('gap');\n if (count > 1) out.push(count);\n return out;\n}\n"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "components/og/og-ui.d.ts",
|
|
28
|
+
"type": "registry:file",
|
|
29
|
+
"target": "components/og/og-ui.d.ts",
|
|
30
|
+
"content": "declare module '@og-ui/core/og-ui.js' {\n export function initOgUI(root?: Document | Element): void;\n export function ogToast(\n title: string,\n options?: {\n description?: string;\n variant?: 'success' | 'warning' | 'danger' | 'accent';\n duration?: number;\n },\n ): () => void;\n}\n"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|