@og-ui/cli 0.0.1 → 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 +101 -1
- package/lib/registry.js +92 -0
- package/package.json +30 -7
- 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 -9
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "skeleton-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "skeleton (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/skeleton.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,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "skeleton",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Skeleton",
|
|
6
|
+
"description": "Placeholders while content loads.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-skeleton",
|
|
10
|
+
"og-skeleton--text",
|
|
11
|
+
"og-skeleton--circle"
|
|
12
|
+
],
|
|
13
|
+
"group": "Feedback",
|
|
14
|
+
"markup": [
|
|
15
|
+
{
|
|
16
|
+
"label": "Shapes",
|
|
17
|
+
"html": "<div aria-busy=\"true\" style=\"display: flex; gap: 0.75rem; align-items: center; width: 100%; max-width: 22rem\">\n <div class=\"og-skeleton og-skeleton--circle\" style=\"width: 2.5rem; height: 2.5rem\"></div>\n <div style=\"flex: 1; display: grid; gap: 0.5rem\">\n <div class=\"og-skeleton og-skeleton--text\" style=\"width: 70%\"></div>\n <div class=\"og-skeleton og-skeleton--text\" style=\"width: 45%\"></div>\n </div>\n</div>"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"react": "import { Skeleton } from '@og-ui/react';\n\n<Skeleton shape=\"circle\" style={{ width: 40, height: 40 }} />\n<Skeleton shape=\"text\" style={{ width: '70%' }} />",
|
|
21
|
+
"keyboard": [
|
|
22
|
+
"Hidden from screen readers; set aria-busy on the region that is loading."
|
|
23
|
+
],
|
|
24
|
+
"notes": []
|
|
25
|
+
},
|
|
26
|
+
"registryDependencies": [
|
|
27
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
28
|
+
],
|
|
29
|
+
"files": [
|
|
30
|
+
{
|
|
31
|
+
"path": "og-ui/components/skeleton.css",
|
|
32
|
+
"type": "registry:file",
|
|
33
|
+
"target": "og-ui/components/skeleton.css",
|
|
34
|
+
"content": "/*! OG UI skeleton | MIT | https://ui.ogom.in */\n.og-skeleton {\n display: block;\n height: 1rem;\n border-radius: var(--og-radius-sm);\n background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--og-color-text) 6%, transparent), transparent), color-mix(in oklab, var(--og-color-text) 8%, transparent);\n background-size: 200% 100%, auto;\n background-repeat: no-repeat;\n animation: og-skeleton-shimmer 1.4s linear infinite;\n}\n.og-skeleton--text {\n height: 0.75rem;\n border-radius: var(--og-radius-full);\n}\n.og-skeleton--circle {\n width: 2.5rem;\n height: 2.5rem;\n border-radius: var(--og-radius-full);\n}\n\n@keyframes og-skeleton-shimmer {\n from {\n background-position: 150% 0, 0 0;\n }\n to {\n background-position: -50% 0, 0 0;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .og-skeleton {\n animation: none;\n }\n}\n"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "slider-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "slider (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/slider.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,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "slider",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Slider",
|
|
6
|
+
"description": "A native range input whose filled track follows the thumb.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-slider"
|
|
10
|
+
],
|
|
11
|
+
"group": "Forms",
|
|
12
|
+
"markup": [
|
|
13
|
+
{
|
|
14
|
+
"label": "Slider",
|
|
15
|
+
"html": "<label class=\"og-field\" style=\"max-width: 20rem\">\n <span class=\"og-label\">Volume</span>\n <input type=\"range\" class=\"og-slider\" min=\"0\" max=\"100\" value=\"62\" />\n</label>"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"react": "import { Slider } from '@og-ui/react';\n\n<Slider label=\"Volume\" defaultValue={62} />",
|
|
19
|
+
"keyboard": [
|
|
20
|
+
"Arrow keys step by 1; Page Up/Down by 10%; Home and End jump to the ends."
|
|
21
|
+
],
|
|
22
|
+
"notes": [
|
|
23
|
+
"Add aria-valuetext when the number needs a unit (“62 percent”).",
|
|
24
|
+
"og-ui.js keeps the fill in sync while dragging."
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"registryDependencies": [
|
|
28
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
29
|
+
],
|
|
30
|
+
"files": [
|
|
31
|
+
{
|
|
32
|
+
"path": "og-ui/components/slider.css",
|
|
33
|
+
"type": "registry:file",
|
|
34
|
+
"target": "og-ui/components/slider.css",
|
|
35
|
+
"content": "/*! OG UI slider | MIT | https://ui.ogom.in */\n.og-slider {\n --_value: 50%;\n --_track: 0.375rem;\n --_thumb: 1.125rem;\n width: 100%;\n height: var(--_thumb);\n margin: 0;\n background: transparent;\n appearance: none;\n cursor: pointer;\n}\n.og-slider:focus-visible {\n outline: 2px solid var(--og-color-focus-ring);\n outline-offset: 4px;\n border-radius: var(--og-radius-full);\n}\n.og-slider:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.og-slider::-webkit-slider-runnable-track {\n height: var(--_track);\n border-radius: var(--og-radius-full);\n background: linear-gradient(to right, var(--og-color-accent) var(--_value), var(--og-surface-inset-fill) var(--_value));\n box-shadow: var(--og-surface-inset-shadow);\n}\n.og-slider::-moz-range-track {\n height: var(--_track);\n border-radius: var(--og-radius-full);\n background: var(--og-surface-inset-fill);\n box-shadow: var(--og-surface-inset-shadow);\n}\n.og-slider::-moz-range-progress {\n height: var(--_track);\n border-radius: var(--og-radius-full);\n background: var(--og-color-accent);\n}\n.og-slider::-webkit-slider-thumb {\n width: var(--_thumb);\n height: var(--_thumb);\n margin-top: calc((var(--_track) - var(--_thumb)) / 2);\n border: var(--og-border-width) solid var(--og-surface-raised-border);\n border-radius: var(--og-radius-full);\n background: var(--og-surface-raised-bg-solid);\n box-shadow: var(--og-surface-raised-shadow);\n appearance: none;\n}\n.og-slider::-moz-range-thumb {\n width: var(--_thumb);\n height: var(--_thumb);\n border: var(--og-border-width) solid var(--og-surface-raised-border);\n border-radius: var(--og-radius-full);\n background: var(--og-surface-raised-bg-solid);\n box-shadow: var(--og-surface-raised-shadow);\n}\n"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "surface",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Surface",
|
|
6
|
+
"description": "The three materials every theme defines: raised, inset and overlay. Build your own components on them.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-surface",
|
|
10
|
+
"og-surface--inset",
|
|
11
|
+
"og-surface--overlay"
|
|
12
|
+
],
|
|
13
|
+
"group": "Actions & display",
|
|
14
|
+
"markup": [
|
|
15
|
+
{
|
|
16
|
+
"label": "Materials",
|
|
17
|
+
"html": "<div class=\"og-surface\" style=\"padding: 1rem 1.25rem\">Raised</div>\n<div class=\"og-surface og-surface--inset\" style=\"padding: 1rem 1.25rem\">Inset</div>\n<div class=\"og-surface og-surface--overlay\" style=\"padding: 1rem 1.25rem\">Overlay</div>"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"react": "// No wrapper needed: use the classes.\n<div className=\"og-surface og-surface--inset\">…</div>",
|
|
21
|
+
"keyboard": [
|
|
22
|
+
"Presentational only."
|
|
23
|
+
],
|
|
24
|
+
"notes": []
|
|
25
|
+
},
|
|
26
|
+
"registryDependencies": [
|
|
27
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
28
|
+
],
|
|
29
|
+
"files": [
|
|
30
|
+
{
|
|
31
|
+
"path": "og-ui/components/surface.css",
|
|
32
|
+
"type": "registry:file",
|
|
33
|
+
"target": "og-ui/components/surface.css",
|
|
34
|
+
"content": "/*! OG UI surface | MIT | https://ui.ogom.in */\n.og-surface {\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 border-radius: var(--og-radius-lg);\n position: relative;\n isolation: isolate;\n}\n.og-surface::before {\n content: \"\";\n position: absolute;\n inset: 0;\n border-radius: inherit;\n background: var(--og-surface-raised-highlight);\n pointer-events: none;\n z-index: -1;\n}\n.og-surface--inset {\n background: var(--og-surface-inset-fill);\n border: var(--og-border-width) solid var(--og-surface-inset-border);\n box-shadow: var(--og-surface-inset-shadow);\n -webkit-backdrop-filter: var(--og-surface-inset-filter);\n backdrop-filter: var(--og-surface-inset-filter);\n}\n.og-surface--inset::before {\n background: var(--og-surface-inset-highlight);\n}\n.og-surface--overlay {\n background: var(--og-surface-overlay-fill);\n border: var(--og-border-width) solid var(--og-surface-overlay-border);\n box-shadow: var(--og-surface-overlay-shadow);\n -webkit-backdrop-filter: var(--og-surface-overlay-filter);\n backdrop-filter: var(--og-surface-overlay-filter);\n}\n.og-surface--overlay::before {\n background: var(--og-surface-overlay-highlight);\n}\n"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "switch-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "switch (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/switch.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,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "switch",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Switch",
|
|
6
|
+
"description": "An on/off setting that applies at once: a checkbox with role=\"switch\".",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-switch"
|
|
10
|
+
],
|
|
11
|
+
"group": "Forms",
|
|
12
|
+
"markup": [
|
|
13
|
+
{
|
|
14
|
+
"label": "Switch",
|
|
15
|
+
"html": "<label class=\"og-check\"><input type=\"checkbox\" role=\"switch\" class=\"og-switch\" checked /> Notifications</label>\n<label class=\"og-check\"><input type=\"checkbox\" role=\"switch\" class=\"og-switch\" /> Dark sidebar</label>"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"react": "import { Switch } from '@og-ui/react';\n\n<Switch label=\"Notifications\" defaultChecked />",
|
|
19
|
+
"keyboard": [
|
|
20
|
+
"Space toggles. Screen readers announce “switch, on/off”."
|
|
21
|
+
],
|
|
22
|
+
"notes": []
|
|
23
|
+
},
|
|
24
|
+
"registryDependencies": [
|
|
25
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
26
|
+
],
|
|
27
|
+
"files": [
|
|
28
|
+
{
|
|
29
|
+
"path": "og-ui/components/switch.css",
|
|
30
|
+
"type": "registry:file",
|
|
31
|
+
"target": "og-ui/components/switch.css",
|
|
32
|
+
"content": "/*! OG UI switch | MIT | https://ui.ogom.in */\n.og-switch {\n background: var(--og-surface-inset-fill);\n border: var(--og-border-width) solid var(--og-surface-inset-border);\n box-shadow: var(--og-surface-inset-shadow);\n -webkit-backdrop-filter: var(--og-surface-inset-filter);\n backdrop-filter: var(--og-surface-inset-filter);\n --_w: 2.5rem;\n --_h: 1.5rem;\n --_pad: 3px;\n position: relative;\n flex: none;\n width: var(--_w);\n height: var(--_h);\n margin: 0;\n border-radius: var(--og-radius-full);\n appearance: none;\n cursor: inherit;\n transition: background-color var(--og-motion-duration) var(--og-easing);\n}\n.og-switch:focus-visible {\n outline: 2px solid var(--og-color-focus-ring);\n outline-offset: 2px;\n}\n.og-switch::before {\n content: \"\";\n position: absolute;\n top: var(--_pad);\n left: var(--_pad);\n width: calc(var(--_h) - var(--_pad) * 2 - var(--og-border-width) * 2);\n aspect-ratio: 1;\n border-radius: var(--og-radius-full);\n background: var(--og-surface-raised-bg-solid);\n box-shadow: var(--og-surface-raised-shadow);\n transition: transform var(--og-motion-duration) var(--og-easing);\n}\n.og-switch:checked {\n background: var(--og-color-accent);\n border-color: var(--og-color-accent-border);\n box-shadow: none;\n}\n.og-switch:checked::before {\n transform: translateX(calc(var(--_w) - var(--_h)));\n}\n"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "table-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "table (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/table.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,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "table",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Table",
|
|
6
|
+
"description": "Data tables that scroll sideways on small screens; compact density tightens rows.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-table-wrap",
|
|
10
|
+
"og-table",
|
|
11
|
+
"og-table__num",
|
|
12
|
+
"og-table--striped"
|
|
13
|
+
],
|
|
14
|
+
"group": "Navigation & data",
|
|
15
|
+
"markup": [
|
|
16
|
+
{
|
|
17
|
+
"label": "Table",
|
|
18
|
+
"html": "<div class=\"og-table-wrap\" style=\"width: 100%\">\n <table class=\"og-table\">\n <thead><tr><th>Invoice</th><th>Client</th><th>Status</th><th class=\"og-table__num\">Amount</th></tr></thead>\n <tbody>\n <tr><td>#1042</td><td>Acme Ltd</td><td><span class=\"og-badge og-badge--warning\">Pending</span></td><td class=\"og-table__num\">₹4,200</td></tr>\n <tr><td>#1041</td><td>Northwind</td><td><span class=\"og-badge og-badge--success\">Paid</span></td><td class=\"og-table__num\">₹12,800</td></tr>\n <tr><td>#1040</td><td>Globex</td><td><span class=\"og-badge og-badge--danger\">Overdue</span></td><td class=\"og-table__num\">₹2,150</td></tr>\n </tbody>\n </table>\n</div>"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"react": "import { Table } from '@og-ui/react';\n\n<Table>\n <thead><tr><th>Invoice</th><th className=\"og-table__num\">Amount</th></tr></thead>\n <tbody><tr><td>#1042</td><td className=\"og-table__num\">₹4,200</td></tr></tbody>\n</Table>",
|
|
22
|
+
"keyboard": [
|
|
23
|
+
"A plain table: screen readers navigate it with their table commands. Use <th> for headers."
|
|
24
|
+
],
|
|
25
|
+
"notes": []
|
|
26
|
+
},
|
|
27
|
+
"registryDependencies": [
|
|
28
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
29
|
+
],
|
|
30
|
+
"files": [
|
|
31
|
+
{
|
|
32
|
+
"path": "og-ui/components/table.css",
|
|
33
|
+
"type": "registry:file",
|
|
34
|
+
"target": "og-ui/components/table.css",
|
|
35
|
+
"content": "/*! OG UI table | MIT | https://ui.ogom.in */\n.og-table-wrap {\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 width: 100%;\n overflow-x: auto;\n border-radius: var(--og-radius-lg);\n}\n\n.og-table {\n width: 100%;\n border-collapse: collapse;\n color: var(--og-color-text);\n font-family: var(--og-font);\n font-size: 0.875rem;\n}\n.og-table th,\n.og-table td {\n padding: calc(var(--og-gap) * 0.75) var(--og-card-pad);\n text-align: left;\n white-space: nowrap;\n}\n.og-table th {\n color: var(--og-color-text-muted);\n font-size: 0.75rem;\n font-weight: var(--og-font-weight-strong);\n letter-spacing: 0.02em;\n text-transform: uppercase;\n background: color-mix(in oklab, var(--og-color-text) 3%, transparent);\n}\n.og-table tbody tr {\n border-top: 1px solid color-mix(in oklab, var(--og-color-text) 9%, transparent);\n transition: background-color var(--og-motion-duration) var(--og-easing);\n}\n.og-table tbody tr:hover {\n background: color-mix(in oklab, var(--og-color-text) 4%, transparent);\n}\n.og-table__num {\n font-family: var(--og-font-mono);\n font-variant-numeric: tabular-nums;\n text-align: right !important;\n}\n.og-table--striped tbody tr:nth-child(even) {\n background: color-mix(in oklab, var(--og-color-text) 3%, transparent);\n}\n"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "tabs-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "tabs (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/tabs.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,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "tabs",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Tabs",
|
|
6
|
+
"description": "WAI-ARIA tabs with automatic activation and roving focus.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-tabs",
|
|
10
|
+
"og-tabs__list",
|
|
11
|
+
"og-tabs__tab",
|
|
12
|
+
"og-tabs__panel"
|
|
13
|
+
],
|
|
14
|
+
"group": "Navigation & data",
|
|
15
|
+
"markup": [
|
|
16
|
+
{
|
|
17
|
+
"label": "Tabs",
|
|
18
|
+
"html": "<div class=\"og-tabs\" data-og-tabs style=\"width: 100%; max-width: 28rem\">\n <div class=\"og-tabs__list\" role=\"tablist\" aria-label=\"Settings\">\n <button class=\"og-tabs__tab\" role=\"tab\" aria-selected=\"true\" aria-controls=\"tabs-1\" id=\"tabs-1t\">Profile</button>\n <button class=\"og-tabs__tab\" role=\"tab\" aria-selected=\"false\" aria-controls=\"tabs-2\" id=\"tabs-2t\" tabindex=\"-1\">Billing</button>\n <button class=\"og-tabs__tab\" role=\"tab\" aria-selected=\"false\" aria-controls=\"tabs-3\" id=\"tabs-3t\" tabindex=\"-1\">Team</button>\n </div>\n <div class=\"og-tabs__panel\" role=\"tabpanel\" id=\"tabs-1\" aria-labelledby=\"tabs-1t\" tabindex=\"0\">Name, photo and timezone.</div>\n <div class=\"og-tabs__panel\" role=\"tabpanel\" id=\"tabs-2\" aria-labelledby=\"tabs-2t\" tabindex=\"0\" hidden>Plan, payment method and invoices.</div>\n <div class=\"og-tabs__panel\" role=\"tabpanel\" id=\"tabs-3\" aria-labelledby=\"tabs-3t\" tabindex=\"0\" hidden>Invite people and manage roles.</div>\n</div>"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"react": "import { Tabs } from '@og-ui/react';\n\n<Tabs\n label=\"Settings\"\n items={[\n { value: 'profile', label: 'Profile', content: 'Name, photo and timezone.' },\n { value: 'billing', label: 'Billing', content: 'Plan and invoices.' },\n ]}\n onValueChange={(v) => console.log(v)}\n/>",
|
|
22
|
+
"keyboard": [
|
|
23
|
+
"The tab list is one Tab stop (only the selected tab has tabindex=\"0\").",
|
|
24
|
+
"Left/Right move between tabs and select them (Up/Down with aria-orientation=\"vertical\"); they wrap.",
|
|
25
|
+
"Home/End go to the first/last tab.",
|
|
26
|
+
"Tab moves from the tab list into the panel."
|
|
27
|
+
],
|
|
28
|
+
"notes": []
|
|
29
|
+
},
|
|
30
|
+
"registryDependencies": [
|
|
31
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
32
|
+
],
|
|
33
|
+
"files": [
|
|
34
|
+
{
|
|
35
|
+
"path": "og-ui/components/tabs.css",
|
|
36
|
+
"type": "registry:file",
|
|
37
|
+
"target": "og-ui/components/tabs.css",
|
|
38
|
+
"content": "/*! OG UI tabs | MIT | https://ui.ogom.in */\n.og-tabs {\n display: flex;\n flex-direction: column;\n gap: var(--og-gap);\n}\n.og-tabs__list {\n background: var(--og-surface-inset-fill);\n border: var(--og-border-width) solid var(--og-surface-inset-border);\n box-shadow: var(--og-surface-inset-shadow);\n -webkit-backdrop-filter: var(--og-surface-inset-filter);\n backdrop-filter: var(--og-surface-inset-filter);\n display: inline-flex;\n align-self: flex-start;\n gap: 0.25rem;\n max-width: 100%;\n padding: 0.25rem;\n overflow-x: auto;\n border-radius: calc(var(--og-radius-control) + 0.25rem);\n}\n.og-tabs__tab {\n transition-property: transform, background-color, border-color, color, box-shadow;\n transition-duration: var(--og-motion-duration);\n transition-timing-function: var(--og-easing);\n height: calc(var(--og-control-h-md) - 0.5rem);\n padding: 0 calc(var(--og-control-px) * 0.875);\n border: var(--og-border-width) solid transparent;\n border-radius: var(--og-radius-control);\n background: transparent;\n color: var(--og-color-text-muted);\n font: inherit;\n font-family: var(--og-font);\n font-size: 0.875rem;\n font-weight: var(--og-font-weight-strong);\n white-space: nowrap;\n cursor: pointer;\n}\n.og-tabs__tab:focus-visible {\n outline: 2px solid var(--og-color-focus-ring);\n outline-offset: 2px;\n}\n.og-tabs__tab:hover {\n color: var(--og-color-text);\n}\n.og-tabs__tab[aria-selected=true] {\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 color: var(--og-color-text);\n}\n.og-tabs__panel {\n font-family: var(--og-font);\n font-size: 0.875rem;\n line-height: 1.6;\n}\n.og-tabs__panel:focus-visible {\n outline: 2px solid var(--og-color-focus-ring);\n outline-offset: 4px;\n border-radius: var(--og-radius-sm);\n}\n"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|