@vjdesigns/vjdesigns-ui 3.4.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +178 -0
- package/README.md +854 -873
- package/dist/ai/llms-full.txt +759 -584
- package/dist/ai/llms.txt +4 -1
- package/dist/ai/registry.json +481 -27
- package/dist/components/data-display/Accordion/Accordion.cjs.js +1 -1
- package/dist/components/data-display/Accordion/Accordion.mjs +97 -166
- package/dist/components/data-display/Chat/Chat.d.ts +13 -2
- package/dist/components/data-display/Collapsible/Collapsible.cjs.js +1 -0
- package/dist/components/data-display/Collapsible/Collapsible.d.ts +70 -0
- package/dist/components/data-display/Collapsible/Collapsible.mjs +102 -0
- package/dist/components/data-display/Collapsible/Collapsible.module.css.cjs.js +1 -0
- package/dist/components/data-display/Collapsible/Collapsible.module.css.mjs +8 -0
- package/dist/components/data-display/Collapsible/index.d.ts +1 -0
- package/dist/components/feedback/Progress/Progress.cjs.js +1 -1
- package/dist/components/feedback/Progress/Progress.d.ts +32 -2
- package/dist/components/feedback/Progress/Progress.mjs +78 -74
- package/dist/components/feedback/Progress/Progress.module.css.cjs.js +1 -1
- package/dist/components/feedback/Progress/Progress.module.css.mjs +1 -1
- package/dist/components/forms/Radio/Radio.cjs.js +1 -1
- package/dist/components/forms/Radio/Radio.mjs +12 -10
- package/dist/components/forms/ToggleGroup/ToggleGroup.cjs.js +1 -1
- package/dist/components/forms/ToggleGroup/ToggleGroup.d.ts +3 -2
- package/dist/components/forms/ToggleGroup/ToggleGroup.mjs +133 -131
- package/dist/components/navigation/Toolbar/Toolbar.cjs.js +1 -0
- package/dist/components/navigation/Toolbar/Toolbar.d.ts +62 -0
- package/dist/components/navigation/Toolbar/Toolbar.mjs +106 -0
- package/dist/components/navigation/Toolbar/Toolbar.module.css.cjs.js +1 -0
- package/dist/components/navigation/Toolbar/Toolbar.module.css.mjs +11 -0
- package/dist/components/navigation/Toolbar/ToolbarContext.cjs.js +1 -0
- package/dist/components/navigation/Toolbar/ToolbarContext.d.ts +9 -0
- package/dist/components/navigation/Toolbar/ToolbarContext.mjs +4 -0
- package/dist/components/navigation/Toolbar/index.d.ts +1 -0
- package/dist/components/primitives/CopyButton/CopyButton.cjs.js +1 -0
- package/dist/components/primitives/CopyButton/CopyButton.d.ts +39 -0
- package/dist/components/primitives/CopyButton/CopyButton.mjs +49 -0
- package/dist/components/primitives/CopyButton/index.d.ts +1 -0
- package/dist/hooks/useCollapsePresence.cjs.js +1 -0
- package/dist/hooks/useCollapsePresence.d.ts +33 -0
- package/dist/hooks/useCollapsePresence.mjs +83 -0
- package/dist/i18n/en.cjs.js +1 -1
- package/dist/i18n/en.mjs +5 -0
- package/dist/i18n/types.d.ts +8 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +104 -101
- package/dist/locales/ar.cjs.js +1 -1
- package/dist/locales/ar.mjs +5 -0
- package/dist/locales/bn.cjs.js +1 -1
- package/dist/locales/bn.mjs +5 -0
- package/dist/locales/cs.cjs.js +1 -1
- package/dist/locales/cs.mjs +5 -0
- package/dist/locales/da.cjs.js +1 -1
- package/dist/locales/da.mjs +5 -0
- package/dist/locales/de.cjs.js +1 -1
- package/dist/locales/de.mjs +5 -0
- package/dist/locales/el.cjs.js +1 -1
- package/dist/locales/el.mjs +5 -0
- package/dist/locales/es.cjs.js +1 -1
- package/dist/locales/es.mjs +5 -0
- package/dist/locales/fa.cjs.js +1 -1
- package/dist/locales/fa.mjs +5 -0
- package/dist/locales/fi.cjs.js +1 -1
- package/dist/locales/fi.mjs +5 -0
- package/dist/locales/fr.cjs.js +1 -1
- package/dist/locales/fr.mjs +5 -0
- package/dist/locales/he.cjs.js +1 -1
- package/dist/locales/he.mjs +5 -0
- package/dist/locales/hi.cjs.js +1 -1
- package/dist/locales/hi.mjs +5 -0
- package/dist/locales/hu.cjs.js +1 -1
- package/dist/locales/hu.mjs +5 -0
- package/dist/locales/id.cjs.js +1 -1
- package/dist/locales/id.mjs +5 -0
- package/dist/locales/it.cjs.js +1 -1
- package/dist/locales/it.mjs +5 -0
- package/dist/locales/ja.cjs.js +1 -1
- package/dist/locales/ja.mjs +5 -0
- package/dist/locales/ko.cjs.js +1 -1
- package/dist/locales/ko.mjs +5 -0
- package/dist/locales/nb.cjs.js +1 -1
- package/dist/locales/nb.mjs +5 -0
- package/dist/locales/nl.cjs.js +1 -1
- package/dist/locales/nl.mjs +5 -0
- package/dist/locales/pl.cjs.js +1 -1
- package/dist/locales/pl.mjs +5 -0
- package/dist/locales/pt-BR.cjs.js +1 -1
- package/dist/locales/pt-BR.mjs +5 -0
- package/dist/locales/ro.cjs.js +1 -1
- package/dist/locales/ro.mjs +5 -0
- package/dist/locales/ru.cjs.js +1 -1
- package/dist/locales/ru.mjs +5 -0
- package/dist/locales/sv.cjs.js +1 -1
- package/dist/locales/sv.mjs +5 -0
- package/dist/locales/th.cjs.js +1 -1
- package/dist/locales/th.mjs +5 -0
- package/dist/locales/tr.cjs.js +1 -1
- package/dist/locales/tr.mjs +5 -0
- package/dist/locales/uk.cjs.js +1 -1
- package/dist/locales/uk.mjs +5 -0
- package/dist/locales/ur.cjs.js +1 -1
- package/dist/locales/ur.mjs +5 -0
- package/dist/locales/vi.cjs.js +1 -1
- package/dist/locales/vi.mjs +5 -0
- package/dist/locales/zh-Hans.cjs.js +1 -1
- package/dist/locales/zh-Hans.mjs +5 -0
- package/dist/locales/zh-Hant.cjs.js +1 -1
- package/dist/locales/zh-Hant.mjs +5 -0
- package/dist/vjdesigns-ui.css +1 -1
- package/package.json +9 -5
- package/dist/components/feedback/Toast/Toast.storyHelpers.d.ts +0 -21
- package/dist/components/navigation/Sidebar/Sidebar.storyHelpers.d.ts +0 -27
- package/dist/components/overlays/Drawer/Drawer.storyHelpers.d.ts +0 -16
package/dist/ai/registry.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vjdesigns/vjdesigns-ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"summary": "Accessible React 19 component library: WCAG 2.2 AA verified (axe on every story, a contrast check on every color pair), 31 languages with right-to-left support, themeable with any brand color (auto-adjusted to stay accessible), tree-shakable, no runtime dependencies besides React.",
|
|
5
5
|
"install": "npm install @vjdesigns/vjdesigns-ui",
|
|
6
6
|
"stylesheet": "@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css",
|
|
7
7
|
"essentials": [
|
|
8
|
-
"Install: `npm install @vjdesigns/vjdesigns-ui` (peer: react, react-dom
|
|
8
|
+
"Install: `npm install @vjdesigns/vjdesigns-ui` (peer: react, react-dom 19).",
|
|
9
9
|
"Import the stylesheet once: `import \"@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css\";`",
|
|
10
10
|
"Import components from the package root: `import { Button, Field, Input } from \"@vjdesigns/vjdesigns-ui\";`",
|
|
11
11
|
"Theme: wrap the app in `<Theme brand=\"blue\" | \"purple\" | ... | \"#hex\" mode=\"light\" | \"dark\" accent=\"brand\" | \"lime\" | \"#hex\">`.",
|
|
@@ -17,27 +17,27 @@
|
|
|
17
17
|
{
|
|
18
18
|
"id": "setup",
|
|
19
19
|
"title": "Installation",
|
|
20
|
-
"markdown": "Install the package along with React and React DOM
|
|
20
|
+
"markdown": "Install the package along with React and React DOM. The library requires **React 19**, which the components need in order to render:\r\n\r\n```bash\r\nnpm install @vjdesigns/vjdesigns-ui react react-dom\r\n```\r\n\r\nIf your project already uses React, you only need the first package:\r\n\r\n```bash\r\nnpm install @vjdesigns/vjdesigns-ui\r\n```\r\n\r\n### Browser support\r\n\r\nThe components support the current and previous major versions of evergreen browsers, with these minimums:\r\n\r\n| Browser | Minimum version |\r\n| --- | --- |\r\n| Chrome, Edge, and other Chromium browsers | 111 |\r\n| Firefox | 121 |\r\n| Safari (macOS and iOS) | 16.2 |\r\n\r\nThese are set by the CSS the components rely on: `color-mix()`, container queries, `:has()` (which draws some keyboard focus rings), and the `inert` attribute. Internet Explorer and legacy (non-Chromium) Edge aren't supported.\r\n\r\nA few newer features are used only where available, with a fallback elsewhere: `field-sizing` for auto-growing `Textarea` (measured in JavaScript otherwise), the `scrollend` event in `Carousel`, and `hidden=\"until-found\"` for find-in-page in `Accordion` and `Collapsible`.\r\n\r\n### Import the styles\r\n\r\nThe component styles and shared design tokens ship as a separate stylesheet. Import it **once** at your app's entry point, or the components will render unstyled.\r\n\r\n**React:** in `main.tsx` (or `App.tsx`)\r\n\r\n```ts\r\nimport \"@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css\";\r\n```\r\n\r\n**Angular:** add it to the `styles` array in `angular.json`\r\n\r\n```json\r\n\"styles\": [\r\n \"node_modules/@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css\",\r\n \"src/styles.css\"\r\n]\r\n```\r\n\r\n**Vue:** in `main.ts`\r\n\r\n```ts\r\nimport \"@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css\";\r\n```"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"id": "usage",
|
|
24
24
|
"title": "Usage",
|
|
25
|
-
"markdown": "The components are built with React. You can use them directly in a React project. In Angular or Vue, you mount them inside a small wrapper component, as shown below.\n\n### React\n\n```tsx\nimport { useState } from \"react\";\nimport { Button, CheckBox } from \"@vjdesigns/vjdesigns-ui\";\n\nexport function SignupForm() {\n const [accepted, setAccepted] = useState(false);\n\n return (\n <form>\n <CheckBox\n label=\"Accept terms\"\n checked={accepted}\n onCheckedChange={setAccepted}\n />\n <Button\n variant=\"solid\"\n tone=\"primary\"\n size=\"md\"\n disabled={!accepted}\n onClick={() => console.log(\"Submitted\")}\n >\n Submit\n </Button>\n </form>\n );\n}\n```\n\n### Next.js (App Router) and React Server Components\n\nThe library works in Server Components. Interactive components (anything with state, effects, or context: `Button`, `DataGrid`, `Modal`, ...) are marked `\"use client\"`, so you can render them from a Server Component like any client component. Utilities (`cx`, `sortRows`, `createBrandPalette`, `getLocaleDirection`, ...) and the locale catalogs have no directive, so you can call or read them on the server too. Every component also renders on the server for the first paint.\n\nPut the providers in a small client file of your own, and render it from the root layout:\n\n```tsx\n// app/providers.tsx\n\"use client\";\nimport { LocaleProvider, ToastProvider } from \"@vjdesigns/vjdesigns-ui\";\nimport es from \"@vjdesigns/vjdesigns-ui/locales/es\";\nimport type { ReactNode } from \"react\";\n\nexport function Providers({ children }: { children: ReactNode }) {\n return (\n <LocaleProvider locale=\"es\" messages={es}>\n <ToastProvider>{children}</ToastProvider>\n </LocaleProvider>\n );\n}\n```\n\n```tsx\n// app/layout.tsx (a Server Component)\nimport \"@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css\";\nimport { getLocaleDirection } from \"@vjdesigns/vjdesigns-ui\";\nimport { Providers } from \"./providers\";\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"es\" dir={getLocaleDirection(\"es\")}>\n <body>\n <Providers>{children}</Providers>\n </body>\n </html>\n );\n}\n```\n\nTwo rules of Server Components to keep in mind:\n\n- **Functions can't be passed from a Server Component to a client one.** That includes event handlers (`onClick`), DataGrid columns with `cell` or `value` functions, and the locale catalogs themselves (their plural messages are functions, which is why `LocaleProvider` goes in the client providers file above). Render those components from your own `\"use client\"` file.\n- **Compound parts can't be reached with a dot from a Server Component** (`Tabs.List`, `Menu.Item`): Next.js reports \"You cannot dot into a client module\". Use them inside a `\"use client\"` file, or use the named exports where they exist (`CardHeader`, `CardBody`, `NavbarBrand`, ...).\n\n### Angular\n\nMake a standalone wrapper that renders the React component into its host element. The wrapper uses `createElement`, so you don't need to change your JSX or TSX settings.\n\n```ts\n// vj-button.component.ts\nimport {\n AfterViewInit,\n Component,\n ElementRef,\n EventEmitter,\n Input,\n OnChanges,\n OnDestroy,\n Output,\n ViewChild,\n} from \"@angular/core\";\nimport { createElement, type MouseEvent as ReactMouseEvent, type ReactElement } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport {\n Button,\n type ButtonProps,\n type ButtonVariant,\n type Size,\n type Tone,\n} from \"@vjdesigns/vjdesigns-ui\";\n\n// Button has overloaded types (for `href` and `as`). Narrowing it here lets createElement type-check.\nconst ReactButton = Button as (props: ButtonProps) => ReactElement;\n\n@Component({\n selector: \"vj-button\",\n standalone: true,\n template: `<span #host></span>`,\n})\nexport class VjButtonComponent implements AfterViewInit, OnChanges, OnDestroy {\n @ViewChild(\"host\", { static: true }) host!: ElementRef<HTMLElement>;\n\n @Input() label = \"\";\n @Input() variant: ButtonVariant = \"solid\";\n @Input() tone: Tone = \"primary\";\n @Input() size: Size = \"md\";\n @Input() disabled = false;\n @Output() clicked = new EventEmitter<MouseEvent>();\n\n private root?: Root;\n\n ngAfterViewInit() {\n this.root = createRoot(this.host.nativeElement);\n this.render();\n }\n\n ngOnChanges() {\n this.render();\n }\n\n ngOnDestroy() {\n this.root?.unmount();\n }\n\n private render() {\n this.root?.render(\n createElement(\n ReactButton,\n {\n variant: this.variant,\n tone: this.tone,\n size: this.size,\n disabled: this.disabled,\n onClick: (event: ReactMouseEvent) => this.clicked.emit(event.nativeEvent),\n },\n this.label // the button's text is passed as children\n )\n );\n }\n}\n```\n\nImport the wrapper wherever you need it:\n\n```ts\n// app.component.ts\nimport { Component } from \"@angular/core\";\nimport { VjButtonComponent } from \"./vj-button.component\";\n\n@Component({\n selector: \"app-root\",\n standalone: true,\n imports: [VjButtonComponent],\n template: `<vj-button label=\"Submit\" tone=\"primary\" (clicked)=\"onSubmit()\" />`,\n})\nexport class AppComponent {\n onSubmit() {\n console.log(\"Submitted\");\n }\n}\n```\n\n### Vue 3\n\nMake a wrapper component that mounts the React component when it loads and re-renders it whenever its props change.\n\n```vue\n<!-- VjButton.vue -->\n<script setup lang=\"ts\">\nimport { onBeforeUnmount, onMounted, ref, watch } from \"vue\";\nimport { createElement, type MouseEvent as ReactMouseEvent, type ReactElement } from \"react\";\nimport { createRoot, type Root } from \"react-dom/client\";\nimport {\n Button,\n type ButtonProps,\n type ButtonVariant,\n type Size,\n type Tone,\n} from \"@vjdesigns/vjdesigns-ui\";\n\n// Button has overloaded types (for `href` and `as`). Narrowing it here lets createElement type-check.\nconst ReactButton = Button as (props: ButtonProps) => ReactElement;\n\nconst props = withDefaults(\n defineProps<{\n label: string;\n variant?: ButtonVariant;\n tone?: Tone;\n size?: Size;\n disabled?: boolean;\n }>(),\n { variant: \"solid\", tone: \"primary\", size: \"md\", disabled: false }\n);\n\nconst emit = defineEmits<{ click: [event: MouseEvent] }>();\n\nconst host = ref<HTMLElement | null>(null);\nlet root: Root | undefined;\n\nfunction render() {\n root?.render(\n createElement(\n ReactButton,\n {\n variant: props.variant,\n tone: props.tone,\n size: props.size,\n disabled: props.disabled,\n onClick: (event: ReactMouseEvent) => emit(\"click\", event.nativeEvent),\n },\n props.label // the button's text is passed as children\n )\n );\n}\n\nonMounted(() => {\n root = createRoot(host.value!);\n render();\n});\n\nwatch(() => ({ ...props }), render);\n\nonBeforeUnmount(() => root?.unmount());\n</script>\n\n<template>\n <span ref=\"host\" />\n</template>\n```\n\nUse it like any other Vue component:\n\n```vue\n<script setup lang=\"ts\">\nimport VjButton from \"./VjButton.vue\";\n\nconst onSubmit = () => console.log(\"Submitted\");\n</script>\n\n<template>\n <VjButton label=\"Submit\" tone=\"primary\" @click=\"onSubmit\" />\n</template>\n```\n\n> **Tip:** Wrap `CheckBox` and any other component the same way. Pass its props into `createElement`, and send its callbacks back out as Angular outputs or Vue emits. For `CheckBox`, that means sending `onCheckedChange` back out."
|
|
25
|
+
"markdown": "The components are built with React. You can use them directly in a React project. In Angular or Vue, you mount them inside a small wrapper component, as shown below.\r\n\r\n### React\r\n\r\n```tsx\r\nimport { useState } from \"react\";\r\nimport { Button, CheckBox } from \"@vjdesigns/vjdesigns-ui\";\r\n\r\nexport function SignupForm() {\r\n const [accepted, setAccepted] = useState(false);\r\n\r\n return (\r\n <form>\r\n <CheckBox\r\n label=\"Accept terms\"\r\n checked={accepted}\r\n onCheckedChange={setAccepted}\r\n />\r\n <Button\r\n variant=\"solid\"\r\n tone=\"primary\"\r\n size=\"md\"\r\n disabled={!accepted}\r\n onClick={() => console.log(\"Submitted\")}\r\n >\r\n Submit\r\n </Button>\r\n </form>\r\n );\r\n}\r\n```\r\n\r\n### Next.js (App Router) and React Server Components\r\n\r\nThe library works in Server Components. Interactive components (anything with state, effects, or context: `Button`, `DataGrid`, `Modal`, ...) are marked `\"use client\"`, so you can render them from a Server Component like any client component. Utilities (`cx`, `sortRows`, `createBrandPalette`, `getLocaleDirection`, ...) and the locale catalogs have no directive, so you can call or read them on the server too. Every component also renders on the server for the first paint.\r\n\r\nPut the providers in a small client file of your own, and render it from the root layout:\r\n\r\n```tsx\r\n// app/providers.tsx\r\n\"use client\";\r\nimport { LocaleProvider, ToastProvider } from \"@vjdesigns/vjdesigns-ui\";\r\nimport es from \"@vjdesigns/vjdesigns-ui/locales/es\";\r\nimport type { ReactNode } from \"react\";\r\n\r\nexport function Providers({ children }: { children: ReactNode }) {\r\n return (\r\n <LocaleProvider locale=\"es\" messages={es}>\r\n <ToastProvider>{children}</ToastProvider>\r\n </LocaleProvider>\r\n );\r\n}\r\n```\r\n\r\n```tsx\r\n// app/layout.tsx (a Server Component)\r\nimport \"@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css\";\r\nimport { getLocaleDirection } from \"@vjdesigns/vjdesigns-ui\";\r\nimport { Providers } from \"./providers\";\r\n\r\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\r\n return (\r\n <html lang=\"es\" dir={getLocaleDirection(\"es\")}>\r\n <body>\r\n <Providers>{children}</Providers>\r\n </body>\r\n </html>\r\n );\r\n}\r\n```\r\n\r\nTwo rules of Server Components to keep in mind:\r\n\r\n- **Functions can't be passed from a Server Component to a client one.** That includes event handlers (`onClick`), DataGrid columns with `cell` or `value` functions, and the locale catalogs themselves (their plural messages are functions, which is why `LocaleProvider` goes in the client providers file above). Render those components from your own `\"use client\"` file.\r\n- **Compound parts can't be reached with a dot from a Server Component** (`Tabs.List`, `Menu.Item`): Next.js reports \"You cannot dot into a client module\". Use them inside a `\"use client\"` file, or use the named exports where they exist (`CardHeader`, `CardBody`, `NavbarBrand`, ...).\r\n\r\n### Angular\r\n\r\nMake a standalone wrapper that renders the React component into its host element. The wrapper uses `createElement`, so you don't need to change your JSX or TSX settings.\r\n\r\n```ts\r\n// vj-button.component.ts\r\nimport {\r\n AfterViewInit,\r\n Component,\r\n ElementRef,\r\n EventEmitter,\r\n Input,\r\n OnChanges,\r\n OnDestroy,\r\n Output,\r\n ViewChild,\r\n} from \"@angular/core\";\r\nimport { createElement, type MouseEvent as ReactMouseEvent, type ReactElement } from \"react\";\r\nimport { createRoot, Root } from \"react-dom/client\";\r\nimport {\r\n Button,\r\n type ButtonProps,\r\n type ButtonVariant,\r\n type Size,\r\n type Tone,\r\n} from \"@vjdesigns/vjdesigns-ui\";\r\n\r\n// Button has overloaded types (for `href` and `as`). Narrowing it here lets createElement type-check.\r\nconst ReactButton = Button as (props: ButtonProps) => ReactElement;\r\n\r\n@Component({\r\n selector: \"vj-button\",\r\n standalone: true,\r\n template: `<span #host></span>`,\r\n})\r\nexport class VjButtonComponent implements AfterViewInit, OnChanges, OnDestroy {\r\n @ViewChild(\"host\", { static: true }) host!: ElementRef<HTMLElement>;\r\n\r\n @Input() label = \"\";\r\n @Input() variant: ButtonVariant = \"solid\";\r\n @Input() tone: Tone = \"primary\";\r\n @Input() size: Size = \"md\";\r\n @Input() disabled = false;\r\n @Output() clicked = new EventEmitter<MouseEvent>();\r\n\r\n private root?: Root;\r\n\r\n ngAfterViewInit() {\r\n this.root = createRoot(this.host.nativeElement);\r\n this.render();\r\n }\r\n\r\n ngOnChanges() {\r\n this.render();\r\n }\r\n\r\n ngOnDestroy() {\r\n this.root?.unmount();\r\n }\r\n\r\n private render() {\r\n this.root?.render(\r\n createElement(\r\n ReactButton,\r\n {\r\n variant: this.variant,\r\n tone: this.tone,\r\n size: this.size,\r\n disabled: this.disabled,\r\n onClick: (event: ReactMouseEvent) => this.clicked.emit(event.nativeEvent),\r\n },\r\n this.label // the button's text is passed as children\r\n )\r\n );\r\n }\r\n}\r\n```\r\n\r\nImport the wrapper wherever you need it:\r\n\r\n```ts\r\n// app.component.ts\r\nimport { Component } from \"@angular/core\";\r\nimport { VjButtonComponent } from \"./vj-button.component\";\r\n\r\n@Component({\r\n selector: \"app-root\",\r\n standalone: true,\r\n imports: [VjButtonComponent],\r\n template: `<vj-button label=\"Submit\" tone=\"primary\" (clicked)=\"onSubmit()\" />`,\r\n})\r\nexport class AppComponent {\r\n onSubmit() {\r\n console.log(\"Submitted\");\r\n }\r\n}\r\n```\r\n\r\n### Vue 3\r\n\r\nMake a wrapper component that mounts the React component when it loads and re-renders it whenever its props change.\r\n\r\n```vue\r\n<!-- VjButton.vue -->\r\n<script setup lang=\"ts\">\r\nimport { onBeforeUnmount, onMounted, ref, watch } from \"vue\";\r\nimport { createElement, type MouseEvent as ReactMouseEvent, type ReactElement } from \"react\";\r\nimport { createRoot, type Root } from \"react-dom/client\";\r\nimport {\r\n Button,\r\n type ButtonProps,\r\n type ButtonVariant,\r\n type Size,\r\n type Tone,\r\n} from \"@vjdesigns/vjdesigns-ui\";\r\n\r\n// Button has overloaded types (for `href` and `as`). Narrowing it here lets createElement type-check.\r\nconst ReactButton = Button as (props: ButtonProps) => ReactElement;\r\n\r\nconst props = withDefaults(\r\n defineProps<{\r\n label: string;\r\n variant?: ButtonVariant;\r\n tone?: Tone;\r\n size?: Size;\r\n disabled?: boolean;\r\n }>(),\r\n { variant: \"solid\", tone: \"primary\", size: \"md\", disabled: false }\r\n);\r\n\r\nconst emit = defineEmits<{ click: [event: MouseEvent] }>();\r\n\r\nconst host = ref<HTMLElement | null>(null);\r\nlet root: Root | undefined;\r\n\r\nfunction render() {\r\n root?.render(\r\n createElement(\r\n ReactButton,\r\n {\r\n variant: props.variant,\r\n tone: props.tone,\r\n size: props.size,\r\n disabled: props.disabled,\r\n onClick: (event: ReactMouseEvent) => emit(\"click\", event.nativeEvent),\r\n },\r\n props.label // the button's text is passed as children\r\n )\r\n );\r\n}\r\n\r\nonMounted(() => {\r\n root = createRoot(host.value!);\r\n render();\r\n});\r\n\r\nwatch(() => ({ ...props }), render);\r\n\r\nonBeforeUnmount(() => root?.unmount());\r\n</script>\r\n\r\n<template>\r\n <span ref=\"host\" />\r\n</template>\r\n```\r\n\r\nUse it like any other Vue component:\r\n\r\n```vue\r\n<script setup lang=\"ts\">\r\nimport VjButton from \"./VjButton.vue\";\r\n\r\nconst onSubmit = () => console.log(\"Submitted\");\r\n</script>\r\n\r\n<template>\r\n <VjButton label=\"Submit\" tone=\"primary\" @click=\"onSubmit\" />\r\n</template>\r\n```\r\n\r\n> **Tip:** Wrap `CheckBox` and any other component the same way. Pass its props into `createElement`, and send its callbacks back out as Angular outputs or Vue emits. For `CheckBox`, that means sending `onCheckedChange` back out."
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
"id": "theming",
|
|
29
29
|
"title": "Theming",
|
|
30
|
-
"markdown": "Wrap any part of your app in `Theme` to set the color mode, brand palette, and accent for everything inside it:\n\n```tsx\nimport { Theme, Button } from \"@vjdesigns/vjdesigns-ui\";\n\n<Theme mode=\"dark\" brand=\"purple\" fill>\n <Button>Dark, purple button</Button>\n</Theme>\n```\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `mode` | `\"light\" \\| \"dark\"` | inherited | Color mode for everything inside. |\n| `brand` | `\"black\" \\| \"blue\" \\| \"gold\" \\| \"green\" \\| \"purple\"`, a hex color, or `{ light, dark }` | inherited | Brand palette for buttons, links, focus rings and indicators. |\n| `accent` | `\"brand\" | \"lime\"`, a hex color, or `{ light, dark }` | inherited (the brand's own) | The bright highlight on badges, switches, progress bars, sliders, steppers, and active navigation. |\n| `fill` | `boolean` | `false` | Paints the theme's background and text color on the wrapper. |\n\nOutside React (or to theme the whole page), set the attributes on `<html>` instead:\n\n```html\n<html data-theme=\"dark\" data-brand=\"purple\" data-accent=\"lime\">\n```\n\n### Accent color\n\nThe accent is the energetic highlight: badges, switches, progress bars, sliders, steppers, and the active link in the Navbar. By default it follows the brand, as a bright shade of the brand's own color, so it always fits:\n\n| Brand | Default accent |\n| --- | --- |\n| `blue` (default) | sky blue `#76c7ff` |\n| `purple` | lavender `#c0b0ff` |\n| `gold` | amber `#f5ad5f` |\n| `green` | mint `#72d4ad` |\n| `black` | lime `#c8f031` (black has no hue to build on) |\n| a custom hex | generated from that color |\n\nTo choose a different one:\n\n```tsx\n<Theme accent=\"lime\">…</Theme> // the original bright yellow-green (\"volt\", its former name, still works)\n<Theme accent=\"#ff6b00\">…</Theme> // any color\n<Theme accent=\"brand\">…</Theme> // back to the brand's own, inside an area with another accent\n```\n\nAccents always carry dark text. A color too dark for that is lightened (same hue) just enough to meet WCAG AA, with a warning in development. An accent you set also holds inside nested brands. In CSS, `accentCss(\"name\", \"#ff6b00\")` generates a `[data-accent=\"name\"]` rule, like `brandCss` below.\n\n### Custom brand colors\n\nPass any hex color as `brand` and a full palette is generated for both modes:\n\n```tsx\n<Theme brand=\"#e11d48\">…</Theme>\n<Theme brand={{ light: \"#4338ca\", dark: \"#f472b6\" }}>…</Theme>\n```\n\nEvery generated palette meets WCAG 2.2 AA. A single color is used exactly as given in the mode where it has enough contrast (dark colors in light mode, light colors in dark mode), and the other mode gets a matching shade of the same hue. If a color doesn't have enough contrast (for example, a mid-tone that fails in both modes), its lightness is shifted just enough to pass, and a warning is logged in development.\n\nTo define a brand in CSS instead (for the whole page, applied before any JavaScript runs), generate a stylesheet rule with `brandCss`:\n\n```ts\nimport { brandCss } from \"@vjdesigns/vjdesigns-ui\";\n\nbrandCss(\"acme\", \"#e11d48\"); // '[data-brand=\"acme\"] { --brand-light-primary: … }'\n```\n\nAdd the rule to your stylesheet and use `<html data-brand=\"acme\">`. `createBrandPalette(color)` returns the generated colors as an object, if you need them directly.\n\n### Tailwind CSS\n\nA Tailwind CSS v4 preset turns the design tokens into utilities, so your own layouts match the components. Import it after Tailwind in your CSS, and keep importing the library's stylesheet as usual:\n\n```css\n@import \"tailwindcss\";\n@import \"@vjdesigns/vjdesigns-ui/tailwind.css\";\n```\n\n```tsx\n<section className=\"bg-surface text-text rounded-xl shadow-md p-6\">\n <h2 className=\"font-display text-2xl tracking-tight\">Season stats</h2>\n <p className=\"text-text-muted\">Updated after every game.</p>\n <span className=\"bg-accent text-on-accent rounded-control px-3\">New</span>\n</section>\n```\n\nEvery utility points at a token (`bg-primary` is `var(--color-primary)`), so Tailwind classes follow `Theme`, `data-theme`, `data-brand`, and `data-accent` exactly like the components, with no `dark:` variants needed.\n\n| Group | Utilities |\n| --- | --- |\n| Colors | `bg-`, `text-`, `border-`, `ring-`, … with `bg`, `surface` (`-raised`, `-sunken`, `-hover`, `-active`), `overlay`, `text` (`-muted`, `-disabled`, `-inverse`), `border` (`-strong`, `-input`), `focus-ring`, `link-visited`; and for `primary`, `accent`, `success`, `warning`, `danger`, `info`, `neutral`: the solid color, `-hover`, `-active`, `on-…` (text on the solid), `-subtle`, `-subtle-hover`, `-subtle-text`, `-border`. Opacity modifiers work (`bg-primary/50`). |\n| Charts | `bg-chart-1` to `bg-chart-8`, for fills only, in that order. Slots 3 to 5 are under 3:1 on white, so pair them with a legend, labels, or a data table. |\n| Type | `font-display` (headings, buttons, labels, numbers), `font-body`, `font-mono`; `text-xs` to `text-6xl` (plus `text-md`); `font-regular` to `font-black`; `leading-tight`, `-snug`, `-normal`, `-relaxed`; `tracking-tight`, `-normal`, `-wide`, `-caps` |\n| Shape | `rounded-control` (pill controls), `rounded-field` (text fields), `rounded-xs` to `rounded-2xl`, `rounded-pill` |\n| Depth | `shadow-xs` to `shadow-xl`, `blur-sm`, `blur-lg` |\n| Motion | `ease-spring` (enter and press), `ease-standard`, `ease-in`, `ease-out`; `duration-instant`, `-fast`, `-normal`, `-slow` (0ms under reduced motion) |\n| Sizes | `h-control-sm`, `-md`, `-lg` (and `w-`, `min-h-`, …), `size-target` (the 24px minimum pointer target), `max-w-xs` to `max-w-2xl` and `@xs:` to `@2xl:` container queries |\n| Layers | `z-sticky`, `z-overlay`, `z-modal`, `z-popover`, `z-dropdown`, `z-toast`, `z-tooltip` |\n| Dark mode | `dark:` follows `data-theme=\"dark\"`, not the OS setting. |\n\nTailwind's numeric spacing (`p-4` = 1rem) already matches the 4px token scale, and the breakpoints (`sm:` to `2xl:`) are the same as Tailwind's.\n\nSome Tailwind names change meaning with the preset: `rounded-*`, `shadow-*`, `blur-sm`/`-lg`, `ease-in`/`-out`, `font-mono`, `font-medium` to `font-black`, `leading-*`, and the `text-*` sizes take the library's values (for example, `rounded-md` is 12px and `font-black` is 800). So do the containers: `max-w-md` and `@md:` are 48rem, not Tailwind's 28rem. The library's stylesheet already gives some of these names its own values once it's loaded, even without the preset; the preset keeps the utilities and the container queries consistent.\n\nFor text contrast, use the pairs the components use: `text-text` or `text-text-muted` on `bg-bg`, `bg-surface`, and the other surfaces; `text-on-primary` on `bg-primary` (likewise `on-accent`, `on-success`, …); `text-primary-subtle-text` on `bg-primary-subtle` (likewise for each tone). These pairs meet WCAG 2.2 AA in both themes and every brand. Don't use accent or chart colors for text.\n\nThe preset doesn't change the components, and Tailwind's preflight (its CSS reset) doesn't override them, whichever stylesheet loads first."
|
|
30
|
+
"markdown": "Wrap any part of your app in `Theme` to set the color mode, brand palette, and accent for everything inside it:\r\n\r\n```tsx\r\nimport { Theme, Button } from \"@vjdesigns/vjdesigns-ui\";\r\n\r\n<Theme mode=\"dark\" brand=\"purple\" fill>\r\n <Button>Dark, purple button</Button>\r\n</Theme>\r\n```\r\n\r\n| Prop | Type | Default | Description |\r\n| --- | --- | --- | --- |\r\n| `mode` | `\"light\" \\| \"dark\"` | inherited | Color mode for everything inside. |\r\n| `brand` | `\"black\" \\| \"blue\" \\| \"gold\" \\| \"green\" \\| \"purple\"`, a hex color, or `{ light, dark }` | inherited | Brand palette for buttons, links, focus rings and indicators. |\r\n| `accent` | `\"brand\" | \"lime\"`, a hex color, or `{ light, dark }` | inherited (the brand's own) | The bright highlight on badges, switches, progress bars, sliders, steppers, and active navigation. |\r\n| `fill` | `boolean` | `false` | Paints the theme's background and text color on the wrapper. |\r\n\r\nOutside React (or to theme the whole page), set the attributes on `<html>` instead:\r\n\r\n```html\r\n<html data-theme=\"dark\" data-brand=\"purple\" data-accent=\"lime\">\r\n```\r\n\r\n### Accent color\r\n\r\nThe accent is the energetic highlight: badges, switches, progress bars, sliders, steppers, and the active link in the Navbar. By default it follows the brand, as a bright shade of the brand's own color, so it always fits:\r\n\r\n| Brand | Default accent |\r\n| --- | --- |\r\n| `blue` (default) | sky blue `#76c7ff` |\r\n| `purple` | lavender `#c0b0ff` |\r\n| `gold` | amber `#f5ad5f` |\r\n| `green` | mint `#72d4ad` |\r\n| `black` | lime `#c8f031` (black has no hue to build on) |\r\n| a custom hex | generated from that color |\r\n\r\nTo choose a different one:\r\n\r\n```tsx\r\n<Theme accent=\"lime\">…</Theme> // the original bright yellow-green (\"volt\", its former name, still works)\r\n<Theme accent=\"#ff6b00\">…</Theme> // any color\r\n<Theme accent=\"brand\">…</Theme> // back to the brand's own, inside an area with another accent\r\n```\r\n\r\nAccents always carry dark text. A color too dark for that is lightened (same hue) just enough to meet WCAG AA, with a warning in development. An accent you set also holds inside nested brands. In CSS, `accentCss(\"name\", \"#ff6b00\")` generates a `[data-accent=\"name\"]` rule, like `brandCss` below.\r\n\r\n### Custom brand colors\r\n\r\nPass any hex color as `brand` and a full palette is generated for both modes:\r\n\r\n```tsx\r\n<Theme brand=\"#e11d48\">…</Theme>\r\n<Theme brand={{ light: \"#4338ca\", dark: \"#f472b6\" }}>…</Theme>\r\n```\r\n\r\nEvery generated palette meets WCAG 2.2 AA. A single color is used exactly as given in the mode where it has enough contrast (dark colors in light mode, light colors in dark mode), and the other mode gets a matching shade of the same hue. If a color doesn't have enough contrast (for example, a mid-tone that fails in both modes), its lightness is shifted just enough to pass, and a warning is logged in development.\r\n\r\nTo define a brand in CSS instead (for the whole page, applied before any JavaScript runs), generate a stylesheet rule with `brandCss`:\r\n\r\n```ts\r\nimport { brandCss } from \"@vjdesigns/vjdesigns-ui\";\r\n\r\nbrandCss(\"acme\", \"#e11d48\"); // '[data-brand=\"acme\"] { --brand-light-primary: … }'\r\n```\r\n\r\nAdd the rule to your stylesheet and use `<html data-brand=\"acme\">`. `createBrandPalette(color)` returns the generated colors as an object, if you need them directly.\r\n\r\n### Tailwind CSS\r\n\r\nA Tailwind CSS v4 preset turns the design tokens into utilities, so your own layouts match the components. Import it after Tailwind in your CSS, and keep importing the library's stylesheet as usual:\r\n\r\n```css\r\n@import \"tailwindcss\";\r\n@import \"@vjdesigns/vjdesigns-ui/tailwind.css\";\r\n```\r\n\r\n```tsx\r\n<section className=\"bg-surface text-text rounded-xl shadow-md p-6\">\r\n <h2 className=\"font-display text-2xl tracking-tight\">Season stats</h2>\r\n <p className=\"text-text-muted\">Updated after every game.</p>\r\n <span className=\"bg-accent text-on-accent rounded-control px-3\">New</span>\r\n</section>\r\n```\r\n\r\nEvery utility points at a token (`bg-primary` is `var(--color-primary)`), so Tailwind classes follow `Theme`, `data-theme`, `data-brand`, and `data-accent` exactly like the components, with no `dark:` variants needed.\r\n\r\n| Group | Utilities |\r\n| --- | --- |\r\n| Colors | `bg-`, `text-`, `border-`, `ring-`, … with `bg`, `surface` (`-raised`, `-sunken`, `-hover`, `-active`), `overlay`, `text` (`-muted`, `-disabled`, `-inverse`), `border` (`-strong`, `-input`), `focus-ring`, `link-visited`; and for `primary`, `accent`, `success`, `warning`, `danger`, `info`, `neutral`: the solid color, `-hover`, `-active`, `on-…` (text on the solid), `-subtle`, `-subtle-hover`, `-subtle-text`, `-border`. Opacity modifiers work (`bg-primary/50`). |\r\n| Charts | `bg-chart-1` to `bg-chart-8`, for fills only, in that order. Slots 3 to 5 are under 3:1 on white, so pair them with a legend, labels, or a data table. |\r\n| Type | `font-display` (headings, buttons, labels, numbers), `font-body`, `font-mono`; `text-xs` to `text-6xl` (plus `text-md`); `font-regular` to `font-black`; `leading-tight`, `-snug`, `-normal`, `-relaxed`; `tracking-tight`, `-normal`, `-wide`, `-caps` |\r\n| Shape | `rounded-control` (pill controls), `rounded-field` (text fields), `rounded-xs` to `rounded-2xl`, `rounded-pill` |\r\n| Depth | `shadow-xs` to `shadow-xl`, `blur-sm`, `blur-lg` |\r\n| Motion | `ease-spring` (enter and press), `ease-standard`, `ease-in`, `ease-out`; `duration-instant`, `-fast`, `-normal`, `-slow` (0ms under reduced motion) |\r\n| Sizes | `h-control-sm`, `-md`, `-lg` (and `w-`, `min-h-`, …), `size-target` (the 24px minimum pointer target), `max-w-xs` to `max-w-2xl` and `@xs:` to `@2xl:` container queries |\r\n| Layers | `z-sticky`, `z-overlay`, `z-modal`, `z-popover`, `z-dropdown`, `z-toast`, `z-tooltip` |\r\n| Dark mode | `dark:` follows `data-theme=\"dark\"`, not the OS setting. |\r\n\r\nTailwind's numeric spacing (`p-4` = 1rem) already matches the 4px token scale, and the breakpoints (`sm:` to `2xl:`) are the same as Tailwind's.\r\n\r\nSome Tailwind names change meaning with the preset: `rounded-*`, `shadow-*`, `blur-sm`/`-lg`, `ease-in`/`-out`, `font-mono`, `font-medium` to `font-black`, `leading-*`, and the `text-*` sizes take the library's values (for example, `rounded-md` is 12px and `font-black` is 800). So do the containers: `max-w-md` and `@md:` are 48rem, not Tailwind's 28rem. The library's stylesheet already gives some of these names its own values once it's loaded, even without the preset; the preset keeps the utilities and the container queries consistent.\r\n\r\nFor text contrast, use the pairs the components use: `text-text` or `text-text-muted` on `bg-bg`, `bg-surface`, and the other surfaces; `text-on-primary` on `bg-primary` (likewise `on-accent`, `on-success`, …); `text-primary-subtle-text` on `bg-primary-subtle` (likewise for each tone). These pairs meet WCAG 2.2 AA in both themes and every brand. Don't use accent or chart colors for text.\r\n\r\nThe preset doesn't change the components, and Tailwind's preflight (its CSS reset) doesn't override them, whichever stylesheet loads first."
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
"id": "languages",
|
|
34
34
|
"title": "Languages",
|
|
35
|
-
"markdown": "Components have built-in text: button names like \"Close\" and \"Next page\", screen-reader announcements like \"3 results available\", validation messages, and date formats. Wrap your app in `LocaleProvider` to show all of it in another language:\n\n```tsx\nimport { LocaleProvider } from \"@vjdesigns/vjdesigns-ui\";\nimport es from \"@vjdesigns/vjdesigns-ui/locales/es\";\n\n<LocaleProvider locale=\"es\" messages={es}>\n <App />\n</LocaleProvider>\n```\n\n`LocaleProvider` sets:\n\n- **Built-in text** for every component, from `messages`.\n- **Dates and numbers** in the locale's format (`23/10/2026`, `1.234,5`), and plurals that follow the language's rules.\n- **Writing direction**: Arabic, Hebrew, Persian, and Urdu get `dir=\"rtl\"`, and layouts and arrow keys mirror.\n- **`lang`** on its wrapper, so screen readers pronounce the text correctly. Popups (menus, dialogs, tooltips) keep the language of the area that opened them.\n\nEach locale is a separate import, so your app only downloads the languages it uses. Without a `LocaleProvider`, components use English text and the browser's date and number format.\n\nThis library only translates its own built-in text. Text your app passes in, like `<Button>Save</Button>`, is your app's content: translate it with your app's i18n library (react-i18next, FormatJS, and so on).\n\n### What gets translated\n\nThe language is never picked automatically from where the user lives or their browser settings. Your app chooses it by rendering a `LocaleProvider`. For example, with `<LocaleProvider locale=\"de\" messages={de}>`:\n\n| | Translated? |\n| --- | --- |\n| Text your app passes in, like `<Button>Save</Button>` | No: your app translates it |\n| Built-in names, like \"Close\", \"Next page\", \"Clear search\" | Yes: \"Schließen\", \"Nächste Seite\", \"Suche löschen\" |\n| Screen-reader announcements, like \"3 results available\" | Yes: \"3 Ergebnisse verfügbar\" |\n| Validation messages, empty states, file-upload prompts | Yes |\n| Dates and numbers | Yes: \"23.10.2026\", \"4,5\" |\n\nTo follow the user's browser language, pass it yourself: `locale={navigator.language}` together with the matching `messages` (see [Switching language at runtime](#switching-language-at-runtime)).\n\n### Bundled languages\n\n`ar` Arabic · `bn` Bengali · `cs` Czech · `da` Danish · `de` German · `el` Greek · `es` Spanish · `fa` Persian · `fi` Finnish · `fr` French · `he` Hebrew · `hi` Hindi · `hu` Hungarian · `id` Indonesian · `it` Italian · `ja` Japanese · `ko` Korean · `nb` Norwegian Bokmål · `nl` Dutch · `pl` Polish · `pt-BR` Portuguese (Brazil) · `ro` Romanian · `ru` Russian · `sv` Swedish · `th` Thai · `tr` Turkish · `uk` Ukrainian · `ur` Urdu · `vi` Vietnamese · `zh-Hans` Chinese (Simplified) · `zh-Hant` Chinese (Traditional), plus English (the default).\n\nThe translations are machine-generated and haven't been reviewed by native speakers yet. If you find a wrong or awkward phrase, override it (below) and report it so the bundled locale can be fixed. (Working on the library itself? See [Translating built-in text](#translating-built-in-text).)\n\n### Changing a few strings\n\nPass only the strings you want to change. Everything else falls back to the outer provider's language (English at the top):\n\n```tsx\n<LocaleProvider locale=\"en-GB\" messages={{ pagination: { next: \"Onwards\" } }}>\n```\n\nProviders nest, so an inner provider can switch the language for one part of the page. Per-component props such as `clearLabel` or `labels` still win over the provider.\n\n### Other languages\n\nFor a language that isn't bundled, write a complete messages object. TypeScript flags any missing string. Use English as the template:\n\n```ts\nimport { en, plural, type Messages } from \"@vjdesigns/vjdesigns-ui\";\n\nconst p = plural(\"sw\");\nexport const sw: Messages = {\n ...en,\n pagination: { ...en.pagination, next: \"Ukurasa unaofuata\", previous: \"Ukurasa uliopita\" },\n searchInput: {\n ...en.searchInput,\n results: (count) => p(count, { \"=0\": \"Hakuna matokeo\", one: \"Tokeo #\", other: \"Matokeo #\" }),\n },\n // ...\n};\n```\n\n`plural(locale)` picks the right plural form for any language (`#` is the formatted number).\n\n### Switching language at runtime\n\nList the languages your app offers as loaders, so each one is downloaded only when picked:\n\n```tsx\nimport { LocaleProvider, type Messages } from \"@vjdesigns/vjdesigns-ui\";\n\nconst loaders: Record<string, () => Promise<{ default: Messages }>> = {\n es: () => import(\"@vjdesigns/vjdesigns-ui/locales/es\"),\n fr: () => import(\"@vjdesigns/vjdesigns-ui/locales/fr\"),\n ar: () => import(\"@vjdesigns/vjdesigns-ui/locales/ar\"),\n};\n\nfunction App({ lang }: { lang: string }) {\n const [messages, setMessages] = useState<Messages>();\n useEffect(() => {\n const load = loaders[lang];\n if (load) load().then((mod) => setMessages(mod.default));\n else setMessages(undefined); // English\n }, [lang]);\n // Until a language loads, the previous one (or English) shows.\n return <LocaleProvider locale={lang} messages={messages}>…</LocaleProvider>;\n}\n```\n\nFor server rendering, also set `<html lang=\"…\" dir=\"…\">` on the page. `getLocaleDirection(locale)` returns `\"ltr\"` or `\"rtl\"`."
|
|
35
|
+
"markdown": "Components have built-in text: button names like \"Close\" and \"Next page\", screen-reader announcements like \"3 results available\", validation messages, and date formats. Wrap your app in `LocaleProvider` to show all of it in another language:\r\n\r\n```tsx\r\nimport { LocaleProvider } from \"@vjdesigns/vjdesigns-ui\";\r\nimport es from \"@vjdesigns/vjdesigns-ui/locales/es\";\r\n\r\n<LocaleProvider locale=\"es\" messages={es}>\r\n <App />\r\n</LocaleProvider>\r\n```\r\n\r\n`LocaleProvider` sets:\r\n\r\n- **Built-in text** for every component, from `messages`.\r\n- **Dates and numbers** in the locale's format (`23/10/2026`, `1.234,5`), and plurals that follow the language's rules.\r\n- **Writing direction**: Arabic, Hebrew, Persian, and Urdu get `dir=\"rtl\"`, and layouts and arrow keys mirror.\r\n- **`lang`** on its wrapper, so screen readers pronounce the text correctly. Popups (menus, dialogs, tooltips) keep the language of the area that opened them.\r\n\r\nEach locale is a separate import, so your app only downloads the languages it uses. Without a `LocaleProvider`, components use English text and the browser's date and number format.\r\n\r\nThis library only translates its own built-in text. Text your app passes in, like `<Button>Save</Button>`, is your app's content: translate it with your app's i18n library (react-i18next, FormatJS, and so on).\r\n\r\n### What gets translated\r\n\r\nThe language is never picked automatically from where the user lives or their browser settings. Your app chooses it by rendering a `LocaleProvider`. For example, with `<LocaleProvider locale=\"de\" messages={de}>`:\r\n\r\n| | Translated? |\r\n| --- | --- |\r\n| Text your app passes in, like `<Button>Save</Button>` | No: your app translates it |\r\n| Built-in names, like \"Close\", \"Next page\", \"Clear search\" | Yes: \"Schließen\", \"Nächste Seite\", \"Suche löschen\" |\r\n| Screen-reader announcements, like \"3 results available\" | Yes: \"3 Ergebnisse verfügbar\" |\r\n| Validation messages, empty states, file-upload prompts | Yes |\r\n| Dates and numbers | Yes: \"23.10.2026\", \"4,5\" |\r\n\r\nTo follow the user's browser language, pass it yourself: `locale={navigator.language}` together with the matching `messages` (see [Switching language at runtime](#switching-language-at-runtime)).\r\n\r\n### Bundled languages\r\n\r\n`ar` Arabic · `bn` Bengali · `cs` Czech · `da` Danish · `de` German · `el` Greek · `es` Spanish · `fa` Persian · `fi` Finnish · `fr` French · `he` Hebrew · `hi` Hindi · `hu` Hungarian · `id` Indonesian · `it` Italian · `ja` Japanese · `ko` Korean · `nb` Norwegian Bokmål · `nl` Dutch · `pl` Polish · `pt-BR` Portuguese (Brazil) · `ro` Romanian · `ru` Russian · `sv` Swedish · `th` Thai · `tr` Turkish · `uk` Ukrainian · `ur` Urdu · `vi` Vietnamese · `zh-Hans` Chinese (Simplified) · `zh-Hant` Chinese (Traditional), plus English (the default).\r\n\r\nThe translations are machine-generated and haven't been reviewed by native speakers yet. If you find a wrong or awkward phrase, override it (below) and report it so the bundled locale can be fixed. (Working on the library itself? See [Translating built-in text](#translating-built-in-text).)\r\n\r\n### Changing a few strings\r\n\r\nPass only the strings you want to change. Everything else falls back to the outer provider's language (English at the top):\r\n\r\n```tsx\r\n<LocaleProvider locale=\"en-GB\" messages={{ pagination: { next: \"Onwards\" } }}>\r\n```\r\n\r\nProviders nest, so an inner provider can switch the language for one part of the page. Per-component props such as `clearLabel` or `labels` still win over the provider.\r\n\r\n### Other languages\r\n\r\nFor a language that isn't bundled, write a complete messages object. TypeScript flags any missing string. Use English as the template:\r\n\r\n```ts\r\nimport { en, plural, type Messages } from \"@vjdesigns/vjdesigns-ui\";\r\n\r\nconst p = plural(\"sw\");\r\nexport const sw: Messages = {\r\n ...en,\r\n pagination: { ...en.pagination, next: \"Ukurasa unaofuata\", previous: \"Ukurasa uliopita\" },\r\n searchInput: {\r\n ...en.searchInput,\r\n results: (count) => p(count, { \"=0\": \"Hakuna matokeo\", one: \"Tokeo #\", other: \"Matokeo #\" }),\r\n },\r\n // ...\r\n};\r\n```\r\n\r\n`plural(locale)` picks the right plural form for any language (`#` is the formatted number).\r\n\r\n### Switching language at runtime\r\n\r\nList the languages your app offers as loaders, so each one is downloaded only when picked:\r\n\r\n```tsx\r\nimport { LocaleProvider, type Messages } from \"@vjdesigns/vjdesigns-ui\";\r\n\r\nconst loaders: Record<string, () => Promise<{ default: Messages }>> = {\r\n es: () => import(\"@vjdesigns/vjdesigns-ui/locales/es\"),\r\n fr: () => import(\"@vjdesigns/vjdesigns-ui/locales/fr\"),\r\n ar: () => import(\"@vjdesigns/vjdesigns-ui/locales/ar\"),\r\n};\r\n\r\nfunction App({ lang }: { lang: string }) {\r\n const [messages, setMessages] = useState<Messages>();\r\n useEffect(() => {\r\n const load = loaders[lang];\r\n if (load) load().then((mod) => setMessages(mod.default));\r\n else setMessages(undefined); // English\r\n }, [lang]);\r\n // Until a language loads, the previous one (or English) shows.\r\n return <LocaleProvider locale={lang} messages={messages}>…</LocaleProvider>;\r\n}\r\n```\r\n\r\nFor server rendering, also set `<html lang=\"…\" dir=\"…\">` on the page. `getLocaleDirection(locale)` returns `\"ltr\"` or `\"rtl\"`."
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"id": "validation",
|
|
39
39
|
"title": "Form validation",
|
|
40
|
-
"markdown": "> **Front-end validation is not security.** It helps people fill in a form correctly, but anyone can turn off JavaScript or send requests straight to your server. Always validate again on the server. The format checks below (`isEmail`, `isIP`, …) are plain functions you can reuse there.\n\n`useFormValidation` checks a form when it's submitted, using the browser's own rules on each input (`required`, `type=\"email\"`, `minLength`, `pattern`, `min` / `max`) plus any rules you add. Messages follow the current language.\n\n```tsx\nimport {\n useFormValidation, rules, ErrorSummary, Field, Input, PasswordInput, Button,\n} from \"@vjdesigns/vjdesigns-ui\";\n\nfunction SignUp() {\n const form = useFormValidation({\n rules: {\n confirm: rules.matches(\"password\", \"The passwords don't match.\"),\n serverIp: rules.ip(), // IPv4 or IPv6\n },\n // Runs only when everything is valid. Return the server's errors to show them on their fields.\n onValid: async (values) => {\n const response = await api.signUp(values);\n return response.errors; // e.g. { username: \"That username is taken.\" }\n },\n });\n\n return (\n <form {...form.formProps}>\n <ErrorSummary ref={form.summaryRef} errors={form.errorList} />\n <Field label=\"Email\" required error={form.errors.email}>\n <Input name=\"email\" type=\"email\" />\n </Field>\n <Field label=\"Password\" required error={form.errors.password}>\n <PasswordInput name=\"password\" minLength={12} />\n </Field>\n <Field label=\"Confirm password\" required error={form.errors.confirm}>\n <PasswordInput name=\"confirm\" />\n </Field>\n <Field label=\"Server IP\" error={form.errors.serverIp}>\n <Input name=\"serverIp\" />\n </Field>\n <Button type=\"submit\" loading={form.isSubmitting}>Create account</Button>\n </form>\n );\n}\n```\n\nHow it behaves:\n\n- **On submit**, every field is checked. If anything is wrong, the `ErrorSummary` at the top lists the problems and takes focus, so screen readers announce it. Each item links to its field. Without a summary, focus goes to the first invalid field.\n- **Errors are keyed by the field's `name`.** Pass `form.errors.<name>` to each `Field`'s `error`.\n- **After a failed submit**, an error disappears as soon as the field is fixed (while typing), and a field is fully re-checked when you leave it. It doesn't nag while you're still typing.\n- **Server errors** (returned from `onValid`, or set with `form.setErrors({...})`) show on their fields and stay until that field is edited.\n- **Emails** must have a real domain (`name@example.com`). The browser's own check also accepts `name@localhost`.\n\n### Rules and format checks\n\n| Rule | Checks |\n| --- | --- |\n| `rules.required()` | Not empty (for controls without a native `required`) |\n| `rules.email()` | An email address in the usual format, with a top-level domain |\n| `rules.ip()` / `rules.ip({ version: 4 })` / `rules.ip({ version: 6 })` | An IPv4 or IPv6 address |\n| `rules.minLength(n)` / `rules.maxLength(n)` | Length in characters |\n| `rules.pattern(/regex/, \"message\")` | The whole value matches |\n| `rules.matches(\"otherField\")` | Equals another field (confirm password) |\n| your own `(value, { values }) => message` | Anything else |\n\nEach rule takes an optional custom message. The checks behind them are exported for use anywhere, including your server:\n\n- `isEmail(value)`\n- `isIPv4(value)`: four numbers 0–255, no leading zeros\n- `isIPv6(value)`: including `::` shorthand and IPv4 tails like `::ffff:192.168.0.1`\n- `isIP(value, version?)`"
|
|
40
|
+
"markdown": "> **Front-end validation is not security.** It helps people fill in a form correctly, but anyone can turn off JavaScript or send requests straight to your server. Always validate again on the server. The format checks below (`isEmail`, `isIP`, …) are plain functions you can reuse there.\r\n\r\n`useFormValidation` checks a form when it's submitted, using the browser's own rules on each input (`required`, `type=\"email\"`, `minLength`, `pattern`, `min` / `max`) plus any rules you add. Messages follow the current language.\r\n\r\n```tsx\r\nimport {\r\n useFormValidation, rules, ErrorSummary, Field, Input, PasswordInput, Button,\r\n} from \"@vjdesigns/vjdesigns-ui\";\r\n\r\nfunction SignUp() {\r\n const form = useFormValidation({\r\n rules: {\r\n confirm: rules.matches(\"password\", \"The passwords don't match.\"),\r\n serverIp: rules.ip(), // IPv4 or IPv6\r\n },\r\n // Runs only when everything is valid. Return the server's errors to show them on their fields.\r\n onValid: async (values) => {\r\n const response = await api.signUp(values);\r\n return response.errors; // e.g. { username: \"That username is taken.\" }\r\n },\r\n });\r\n\r\n return (\r\n <form {...form.formProps}>\r\n <ErrorSummary ref={form.summaryRef} errors={form.errorList} />\r\n <Field label=\"Email\" required error={form.errors.email}>\r\n <Input name=\"email\" type=\"email\" />\r\n </Field>\r\n <Field label=\"Password\" required error={form.errors.password}>\r\n <PasswordInput name=\"password\" minLength={12} />\r\n </Field>\r\n <Field label=\"Confirm password\" required error={form.errors.confirm}>\r\n <PasswordInput name=\"confirm\" />\r\n </Field>\r\n <Field label=\"Server IP\" error={form.errors.serverIp}>\r\n <Input name=\"serverIp\" />\r\n </Field>\r\n <Button type=\"submit\" loading={form.isSubmitting}>Create account</Button>\r\n </form>\r\n );\r\n}\r\n```\r\n\r\nHow it behaves:\r\n\r\n- **On submit**, every field is checked. If anything is wrong, the `ErrorSummary` at the top lists the problems and takes focus, so screen readers announce it. Each item links to its field. Without a summary, focus goes to the first invalid field.\r\n- **Errors are keyed by the field's `name`.** Pass `form.errors.<name>` to each `Field`'s `error`.\r\n- **After a failed submit**, an error disappears as soon as the field is fixed (while typing), and a field is fully re-checked when you leave it. It doesn't nag while you're still typing.\r\n- **Server errors** (returned from `onValid`, or set with `form.setErrors({...})`) show on their fields and stay until that field is edited.\r\n- **Emails** must have a real domain (`name@example.com`). The browser's own check also accepts `name@localhost`.\r\n\r\n### Rules and format checks\r\n\r\n| Rule | Checks |\r\n| --- | --- |\r\n| `rules.required()` | Not empty (for controls without a native `required`) |\r\n| `rules.email()` | An email address in the usual format, with a top-level domain |\r\n| `rules.ip()` / `rules.ip({ version: 4 })` / `rules.ip({ version: 6 })` | An IPv4 or IPv6 address |\r\n| `rules.minLength(n)` / `rules.maxLength(n)` | Length in characters |\r\n| `rules.pattern(/regex/, \"message\")` | The whole value matches |\r\n| `rules.matches(\"otherField\")` | Equals another field (confirm password) |\r\n| your own `(value, { values }) => message` | Anything else |\r\n\r\nEach rule takes an optional custom message. The checks behind them are exported for use anywhere, including your server:\r\n\r\n- `isEmail(value)`\r\n- `isIPv4(value)`: four numbers 0–255, no leading zeros\r\n- `isIPv6(value)`: including `::` shorthand and IPv4 tails like `::ffff:192.168.0.1`\r\n- `isIP(value, version?)`"
|
|
41
41
|
}
|
|
42
42
|
],
|
|
43
43
|
"components": [
|
|
@@ -1283,7 +1283,7 @@
|
|
|
1283
1283
|
"category": "data-display",
|
|
1284
1284
|
"folder": "Chat",
|
|
1285
1285
|
"import": "import { Chat } from \"@vjdesigns/vjdesigns-ui\";",
|
|
1286
|
-
"description": "A chat interface for an AI assistant (or a person), with no backend of its\nown: `onSend` connects it to any API and can stream the reply. Includes a\nscrolling conversation that follows new messages, an auto-growing message\nbox (Enter sends, Shift+Enter adds a line), Stop and Retry, copy buttons,\nsuggested prompts, and screen reader announcements of each reply.\n\n```tsx\n<Chat\n style={{ blockSize: 560 }}\n onSend={async function* (text, { messages, signal }) {\n const res = await fetch(\"/api/chat\", {\n method: \"POST\",\n body: JSON.stringify({ messages }),\n signal,\n });\n yield* readTextStream(res);\n }}\n/>\n```",
|
|
1286
|
+
"description": "A chat interface for an AI assistant (or a person), with no backend of its\r\nown: `onSend` connects it to any API and can stream the reply. Includes a\r\nscrolling conversation that follows new messages, an auto-growing message\r\nbox (Enter sends, Shift+Enter adds a line), Stop and Retry, copy buttons,\r\nsuggested prompts, and screen reader announcements of each reply.\r\n\r\n```tsx\r\n<Chat\r\n style={{ blockSize: 560 }}\r\n onSend={async function* (text, { messages, signal }) {\r\n const res = await fetch(\"/api/chat\", {\r\n method: \"POST\",\r\n body: JSON.stringify({ messages }),\r\n signal,\r\n });\r\n yield* readTextStream(res);\r\n }}\r\n/>\r\n```",
|
|
1287
1287
|
"nativeElement": "section",
|
|
1288
1288
|
"props": [
|
|
1289
1289
|
{
|
|
@@ -1308,7 +1308,7 @@
|
|
|
1308
1308
|
"name": "onSend",
|
|
1309
1309
|
"type": "( text: string, context: ChatSendContext, ) => ChatSendResult | Promise<ChatSendResult>",
|
|
1310
1310
|
"required": false,
|
|
1311
|
-
"description": "Connects the Chat to your backend. Called with the user's text when they\nsend a message (or retry). Return the reply as a string, stream it as an\n`AsyncIterable<string>`, or return nothing and add it yourself through\ncontrolled `messages`. Throwing (or rejecting) turns the reply into an\nerror with a Retry button."
|
|
1311
|
+
"description": "Connects the Chat to your backend. Called with the user's text when they\r\nsend a message (or retry). Return the reply as a string, stream it as an\r\n`AsyncIterable<string>`, or return nothing and add it yourself through\r\ncontrolled `messages`. Throwing (or rejecting) turns the reply into an\r\nerror with a Retry button."
|
|
1312
1312
|
},
|
|
1313
1313
|
{
|
|
1314
1314
|
"name": "onStop",
|
|
@@ -1356,7 +1356,7 @@
|
|
|
1356
1356
|
"name": "renderContent",
|
|
1357
1357
|
"type": "(message: ChatMessage) => ReactNode",
|
|
1358
1358
|
"required": false,
|
|
1359
|
-
"description": "Renders a message's content, e.g. through your Markdown renderer.\nDefaults to plain text with line breaks kept
|
|
1359
|
+
"description": "Renders a message's content, e.g. through your Markdown renderer.\r\nDefaults to plain text with line breaks kept, which is always safe.\r\n\r\n**Security:** treat every message as untrusted, including the model's\r\nreplies (a prompt injection can make a model write anything). When you\r\nrender it yourself:\r\n- Render to React elements, not an HTML string. Don't pass content to\r\n `dangerouslySetInnerHTML`, and don't enable raw HTML in your Markdown\r\n renderer. If you must render HTML, sanitize it first (e.g. DOMPurify).\r\n- Allow only `http:`, `https:`, and `mailto:` link URLs (no\r\n `javascript:` or `data:`), and give external links\r\n `rel=\"noopener noreferrer\"`.\r\n- Don't load remote images from message content automatically: an image\r\n URL can leak data from the conversation to another server."
|
|
1360
1360
|
},
|
|
1361
1361
|
{
|
|
1362
1362
|
"name": "assistantName",
|
|
@@ -1471,15 +1471,15 @@
|
|
|
1471
1471
|
},
|
|
1472
1472
|
{
|
|
1473
1473
|
"name": "Custom Rendering",
|
|
1474
|
-
"description": "`renderContent` renders messages your way, e.g. through a Markdown\nrenderer. This one turns `**bold**` into `<strong>` and keeps paragraphs.\
|
|
1474
|
+
"description": "`renderContent` renders messages your way, e.g. through a Markdown\r\nrenderer. This one turns `**bold**` into `<strong>` and keeps paragraphs,\r\nbuilding React elements rather than an HTML string, so nothing in a\r\nmessage can run as code.\r\n\r\nTreat model replies as untrusted, like user input: never render them\r\nwith `dangerouslySetInnerHTML` or a Markdown renderer's raw-HTML mode\r\n(sanitize with a library such as DOMPurify if you must), allow only\r\n`http:`, `https:`, and `mailto:` links, and don't auto-load remote images\r\nfrom replies, since an image URL can leak conversation data."
|
|
1475
1475
|
},
|
|
1476
1476
|
{
|
|
1477
1477
|
"name": "Controlled",
|
|
1478
|
-
"description": "Controlled: the parent owns the messages, so it can save, clear, or seed\nthem. Here, `onSend` returns nothing and the parent adds the reply itself\n(the way a WebSocket or a human agent would)."
|
|
1478
|
+
"description": "Controlled: the parent owns the messages, so it can save, clear, or seed\r\nthem. Here, `onSend` returns nothing and the parent adds the reply itself\r\n(the way a WebSocket or a human agent would)."
|
|
1479
1479
|
},
|
|
1480
1480
|
{
|
|
1481
1481
|
"name": "Connecting ABackend",
|
|
1482
|
-
"description": "How to connect a real backend: stream server-sent events from your API\nroute with `readEventStream`, passing `signal` so Stop cancels the request.\n\n```tsx\nimport { Chat, readEventStream } from \"@vjdesigns/vjdesigns-ui\";\n\n<Chat\n onSend={async function* (_text, { messages, signal }) {\n const res = await fetch(\"/api/chat\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n messages: messages.map(({ role, content }) => ({ role, content })),\n }),\n signal,\n });\n if (!res.ok) throw new Error(`Chat request failed: ${res.status}`);\n for await (const data of readEventStream(res)) {\n if (data === \"[DONE]\") break;\n yield JSON.parse(data).text ?? \"\";\n }\n }}\n/>\n```\n\nKeep API keys on your server: the browser should call your own route,\nwhich calls the model provider. This story fakes the server with an\nin-memory event stream."
|
|
1482
|
+
"description": "How to connect a real backend: stream server-sent events from your API\r\nroute with `readEventStream`, passing `signal` so Stop cancels the request.\r\n\r\n```tsx\r\nimport { Chat, readEventStream } from \"@vjdesigns/vjdesigns-ui\";\r\n\r\n<Chat\r\n onSend={async function* (_text, { messages, signal }) {\r\n const res = await fetch(\"/api/chat\", {\r\n method: \"POST\",\r\n headers: { \"Content-Type\": \"application/json\" },\r\n body: JSON.stringify({\r\n messages: messages.map(({ role, content }) => ({ role, content })),\r\n }),\r\n signal,\r\n });\r\n if (!res.ok) throw new Error(`Chat request failed: ${res.status}`);\r\n for await (const data of readEventStream(res)) {\r\n if (data === \"[DONE]\") break;\r\n yield JSON.parse(data).text ?? \"\";\r\n }\r\n }}\r\n/>\r\n```\r\n\r\nKeep API keys on your server: the browser should call your own route,\r\nwhich calls the model provider. This story fakes the server with an\r\nin-memory event stream."
|
|
1483
1483
|
},
|
|
1484
1484
|
{
|
|
1485
1485
|
"name": "Right To Left",
|
|
@@ -2059,6 +2059,184 @@
|
|
|
2059
2059
|
}
|
|
2060
2060
|
]
|
|
2061
2061
|
},
|
|
2062
|
+
{
|
|
2063
|
+
"name": "Collapsible",
|
|
2064
|
+
"category": "data-display",
|
|
2065
|
+
"folder": "Collapsible",
|
|
2066
|
+
"import": "import { Collapsible } from \"@vjdesigns/vjdesigns-ui\";",
|
|
2067
|
+
"description": "A show/hide section (WAI-ARIA disclosure). See `CollapsibleRoot`.",
|
|
2068
|
+
"nativeElement": "div",
|
|
2069
|
+
"props": [
|
|
2070
|
+
{
|
|
2071
|
+
"name": "open",
|
|
2072
|
+
"type": "boolean",
|
|
2073
|
+
"required": false,
|
|
2074
|
+
"description": "Controlled open state."
|
|
2075
|
+
},
|
|
2076
|
+
{
|
|
2077
|
+
"name": "defaultOpen",
|
|
2078
|
+
"type": "boolean",
|
|
2079
|
+
"required": false,
|
|
2080
|
+
"default": "false",
|
|
2081
|
+
"description": "Initial open state when uncontrolled."
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
"name": "onOpenChange",
|
|
2085
|
+
"type": "(open: boolean) => void",
|
|
2086
|
+
"required": false,
|
|
2087
|
+
"description": "Called with the next open state when the trigger is pressed (or find-in-page reveals the content)."
|
|
2088
|
+
},
|
|
2089
|
+
{
|
|
2090
|
+
"name": "disabled",
|
|
2091
|
+
"type": "boolean",
|
|
2092
|
+
"required": false,
|
|
2093
|
+
"default": "false",
|
|
2094
|
+
"description": "Disables the trigger, so the section stays in its current state."
|
|
2095
|
+
},
|
|
2096
|
+
{
|
|
2097
|
+
"name": "children",
|
|
2098
|
+
"type": "ReactNode",
|
|
2099
|
+
"required": false,
|
|
2100
|
+
"description": "A `Collapsible.Trigger` and a `Collapsible.Content`, anywhere inside."
|
|
2101
|
+
}
|
|
2102
|
+
],
|
|
2103
|
+
"subcomponents": [
|
|
2104
|
+
{
|
|
2105
|
+
"name": "Collapsible.Trigger",
|
|
2106
|
+
"exportedAs": "CollapsibleTrigger",
|
|
2107
|
+
"description": "The button that opens and closes the content. Renders a `Button`\r\n(`variant=\"ghost\"`, `tone=\"neutral\"` by default) with a turning chevron,\r\nor your own element with `asChild`.",
|
|
2108
|
+
"nativeElement": "button",
|
|
2109
|
+
"props": [
|
|
2110
|
+
{
|
|
2111
|
+
"name": "variant",
|
|
2112
|
+
"type": "ButtonVariant",
|
|
2113
|
+
"required": false,
|
|
2114
|
+
"default": "\"solid\"",
|
|
2115
|
+
"description": "Visual style. Inherits from a surrounding `ButtonGroup`."
|
|
2116
|
+
},
|
|
2117
|
+
{
|
|
2118
|
+
"name": "tone",
|
|
2119
|
+
"type": "Tone",
|
|
2120
|
+
"required": false,
|
|
2121
|
+
"default": "\"primary\"",
|
|
2122
|
+
"description": "Semantic color. Inherits from a surrounding `ButtonGroup`."
|
|
2123
|
+
},
|
|
2124
|
+
{
|
|
2125
|
+
"name": "size",
|
|
2126
|
+
"type": "Size",
|
|
2127
|
+
"required": false,
|
|
2128
|
+
"default": "\"md\"",
|
|
2129
|
+
"description": "Control height, padding, and type size. Inherits from a surrounding `ButtonGroup`."
|
|
2130
|
+
},
|
|
2131
|
+
{
|
|
2132
|
+
"name": "radius",
|
|
2133
|
+
"type": "Radius",
|
|
2134
|
+
"required": false,
|
|
2135
|
+
"default": "\"pill\"",
|
|
2136
|
+
"description": "Corner rounding. When omitted, uses `--control-radius` (pill)."
|
|
2137
|
+
},
|
|
2138
|
+
{
|
|
2139
|
+
"name": "disabled",
|
|
2140
|
+
"type": "boolean",
|
|
2141
|
+
"required": false,
|
|
2142
|
+
"default": "false",
|
|
2143
|
+
"description": "Disables the control. Buttons use the native `disabled` attribute; links drop `href` and get `aria-disabled`."
|
|
2144
|
+
},
|
|
2145
|
+
{
|
|
2146
|
+
"name": "asChild",
|
|
2147
|
+
"type": "boolean",
|
|
2148
|
+
"required": false,
|
|
2149
|
+
"default": "false",
|
|
2150
|
+
"description": "Render your own element instead of a `Button`, passing it the trigger's\r\nARIA attributes, `onClick`, and `ref`. It must be a single element that\r\nrenders a `<button>` (or a component that forwards these props to one)."
|
|
2151
|
+
},
|
|
2152
|
+
{
|
|
2153
|
+
"name": "indicator",
|
|
2154
|
+
"type": "boolean",
|
|
2155
|
+
"required": false,
|
|
2156
|
+
"default": "true",
|
|
2157
|
+
"description": "Show a chevron after the label that turns when open. Ignored with `asChild`."
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
"name": "children",
|
|
2161
|
+
"type": "ReactNode",
|
|
2162
|
+
"required": false,
|
|
2163
|
+
"description": "The visible label, or your element with `asChild`."
|
|
2164
|
+
}
|
|
2165
|
+
]
|
|
2166
|
+
},
|
|
2167
|
+
{
|
|
2168
|
+
"name": "Collapsible.Content",
|
|
2169
|
+
"exportedAs": "CollapsibleContent",
|
|
2170
|
+
"description": "The content the trigger controls. Animates its height open and closed\r\n(instantly under `prefers-reduced-motion`), then gets the `hidden`\r\nattribute. Adds no padding, so it fits any layout.",
|
|
2171
|
+
"nativeElement": "div",
|
|
2172
|
+
"props": [
|
|
2173
|
+
{
|
|
2174
|
+
"name": "forceMount",
|
|
2175
|
+
"type": "boolean",
|
|
2176
|
+
"required": false,
|
|
2177
|
+
"default": "false",
|
|
2178
|
+
"description": "Keep the children mounted while closed (still hidden), e.g. to keep form state."
|
|
2179
|
+
},
|
|
2180
|
+
{
|
|
2181
|
+
"name": "hiddenUntilFound",
|
|
2182
|
+
"type": "boolean",
|
|
2183
|
+
"required": false,
|
|
2184
|
+
"default": "false",
|
|
2185
|
+
"description": "Use `hidden=\"until-found\"` where supported, so the browser's\r\nfind-in-page can search the closed content and opens it on a match.\r\nKeeps the children mounted."
|
|
2186
|
+
},
|
|
2187
|
+
{
|
|
2188
|
+
"name": "children",
|
|
2189
|
+
"type": "ReactNode",
|
|
2190
|
+
"required": false,
|
|
2191
|
+
"description": "The content to show and hide."
|
|
2192
|
+
}
|
|
2193
|
+
]
|
|
2194
|
+
}
|
|
2195
|
+
],
|
|
2196
|
+
"storybook": "Data Display/Collapsible",
|
|
2197
|
+
"stories": [
|
|
2198
|
+
{
|
|
2199
|
+
"name": "Playground",
|
|
2200
|
+
"description": ""
|
|
2201
|
+
},
|
|
2202
|
+
{
|
|
2203
|
+
"name": "Behavior",
|
|
2204
|
+
"description": "The trigger reports its state with `aria-expanded`; closed content is hidden."
|
|
2205
|
+
},
|
|
2206
|
+
{
|
|
2207
|
+
"name": "Default Open",
|
|
2208
|
+
"description": ""
|
|
2209
|
+
},
|
|
2210
|
+
{
|
|
2211
|
+
"name": "Disabled",
|
|
2212
|
+
"description": "A disabled collapsible keeps its state; the trigger can't be pressed."
|
|
2213
|
+
},
|
|
2214
|
+
{
|
|
2215
|
+
"name": "Show More",
|
|
2216
|
+
"description": "The trigger and content can be anywhere inside the root: here a \"Show all\" button below a list."
|
|
2217
|
+
},
|
|
2218
|
+
{
|
|
2219
|
+
"name": "Controlled",
|
|
2220
|
+
"description": "Controlled with `open` and `onOpenChange`, e.g. to open it from elsewhere."
|
|
2221
|
+
},
|
|
2222
|
+
{
|
|
2223
|
+
"name": "Custom Trigger",
|
|
2224
|
+
"description": "`asChild` uses your own element as the trigger; it gets the ARIA wiring and click handling."
|
|
2225
|
+
},
|
|
2226
|
+
{
|
|
2227
|
+
"name": "Hidden Until Found",
|
|
2228
|
+
"description": "`hiddenUntilFound` lets the browser's find-in-page (Ctrl+F) search the closed content and open it."
|
|
2229
|
+
},
|
|
2230
|
+
{
|
|
2231
|
+
"name": "Long Content",
|
|
2232
|
+
"description": "Long content animates open and closed just the same."
|
|
2233
|
+
},
|
|
2234
|
+
{
|
|
2235
|
+
"name": "Both Themes",
|
|
2236
|
+
"description": "Both themes side by side."
|
|
2237
|
+
}
|
|
2238
|
+
]
|
|
2239
|
+
},
|
|
2062
2240
|
{
|
|
2063
2241
|
"name": "Countdown",
|
|
2064
2242
|
"category": "data-display",
|
|
@@ -4952,6 +5130,12 @@
|
|
|
4952
5130
|
"required": false,
|
|
4953
5131
|
"description": "Semantic color of the fill. Color never carries meaning alone: pair\r\n`danger`/`warning` with a `label` and `showValue` (or `valueText`)."
|
|
4954
5132
|
},
|
|
5133
|
+
{
|
|
5134
|
+
"name": "toneSteps",
|
|
5135
|
+
"type": "readonly ProgressToneStep[]",
|
|
5136
|
+
"required": false,
|
|
5137
|
+
"description": "Change the fill color with the value. Bands are percentages of the range,\r\nchecked in order; the first whose `upTo` is at or above the current\r\npercentage wins, and a step without `upTo` catches the rest. `tone` is\r\nused while indeterminate or when no step matches. Example:\r\n`[{ upTo: 40, tone: \"danger\" }, { upTo: 75, tone: \"warning\" }, { tone: \"success\" }]`.\r\nColor never carries meaning alone: also show the value or describe the\r\nstate in `label` / `valueText`."
|
|
5138
|
+
},
|
|
4955
5139
|
{
|
|
4956
5140
|
"name": "label",
|
|
4957
5141
|
"type": "ReactNode",
|
|
@@ -5193,6 +5377,12 @@
|
|
|
5193
5377
|
"required": false,
|
|
5194
5378
|
"description": "Semantic color of the fill. Color never carries meaning alone: pair\r\n`danger`/`warning` with a `label` and `showValue` (or `valueText`)."
|
|
5195
5379
|
},
|
|
5380
|
+
{
|
|
5381
|
+
"name": "toneSteps",
|
|
5382
|
+
"type": "readonly ProgressToneStep[]",
|
|
5383
|
+
"required": false,
|
|
5384
|
+
"description": "Change the fill color with the value. Bands are percentages of the range,\r\nchecked in order; the first whose `upTo` is at or above the current\r\npercentage wins, and a step without `upTo` catches the rest. `tone` is\r\nused while indeterminate or when no step matches. Example:\r\n`[{ upTo: 40, tone: \"danger\" }, { upTo: 75, tone: \"warning\" }, { tone: \"success\" }]`.\r\nColor never carries meaning alone: also show the value or describe the\r\nstate in `label` / `valueText`."
|
|
5385
|
+
},
|
|
5196
5386
|
{
|
|
5197
5387
|
"name": "label",
|
|
5198
5388
|
"type": "ReactNode",
|
|
@@ -5273,6 +5463,10 @@
|
|
|
5273
5463
|
"name": "Tones",
|
|
5274
5464
|
"description": ""
|
|
5275
5465
|
},
|
|
5466
|
+
{
|
|
5467
|
+
"name": "Tone steps (color by value)",
|
|
5468
|
+
"description": ""
|
|
5469
|
+
},
|
|
5276
5470
|
{
|
|
5277
5471
|
"name": "Sizes",
|
|
5278
5472
|
"description": ""
|
|
@@ -7135,7 +7329,7 @@
|
|
|
7135
7329
|
},
|
|
7136
7330
|
{
|
|
7137
7331
|
"name": "Basic Single",
|
|
7138
|
-
"description": "Type to filter, ArrowDown to highlight, Enter to choose. The input shows the\nchosen label. Escape closes the list; a second Escape undoes typed text,\ngoing back to the chosen label (the selection is kept)."
|
|
7332
|
+
"description": "Type to filter, ArrowDown to highlight, Enter to choose. The input shows the\r\nchosen label. Escape closes the list; a second Escape undoes typed text,\r\ngoing back to the chosen label (the selection is kept)."
|
|
7139
7333
|
},
|
|
7140
7334
|
{
|
|
7141
7335
|
"name": "Results Announcement",
|
|
@@ -7143,7 +7337,7 @@
|
|
|
7143
7337
|
},
|
|
7144
7338
|
{
|
|
7145
7339
|
"name": "Multiple",
|
|
7146
|
-
"description": "`multiple`: selections become removable chips before the input. Enter\ntoggles the highlighted option and keeps the list open; Backspace on an\nempty input removes the last chip."
|
|
7340
|
+
"description": "`multiple`: selections become removable chips before the input. Enter\r\ntoggles the highlighted option and keeps the list open; Backspace on an\r\nempty input removes the last chip."
|
|
7147
7341
|
},
|
|
7148
7342
|
{
|
|
7149
7343
|
"name": "With Groups",
|
|
@@ -7163,7 +7357,7 @@
|
|
|
7163
7357
|
},
|
|
7164
7358
|
{
|
|
7165
7359
|
"name": "Async",
|
|
7166
|
-
"description": "Server-side filtering: `filter={false}` shows `options` as given, `loading`\nshows a spinner row, and `emptyMessage` a status row when nothing matches."
|
|
7360
|
+
"description": "Server-side filtering: `filter={false}` shows `options` as given, `loading`\r\nshows a spinner row, and `emptyMessage` a status row when nothing matches."
|
|
7167
7361
|
},
|
|
7168
7362
|
{
|
|
7169
7363
|
"name": "Creatable",
|
|
@@ -7191,7 +7385,7 @@
|
|
|
7191
7385
|
},
|
|
7192
7386
|
{
|
|
7193
7387
|
"name": "In Modal",
|
|
7194
|
-
"description": "Inside a Modal the list is a child layer: Escape closes only the list.\nWith the chosen label unchanged, the next Escape reaches the Modal and\ncloses it (the selection isn't silently cleared)."
|
|
7388
|
+
"description": "Inside a Modal the list is a child layer: Escape closes only the list.\r\nWith the chosen label unchanged, the next Escape reaches the Modal and\r\ncloses it (the selection isn't silently cleared)."
|
|
7195
7389
|
},
|
|
7196
7390
|
{
|
|
7197
7391
|
"name": "Assign Players To Team",
|
|
@@ -7207,11 +7401,11 @@
|
|
|
7207
7401
|
},
|
|
7208
7402
|
{
|
|
7209
7403
|
"name": "Form submit, reset, and custom values",
|
|
7210
|
-
"description": "Form behavior: Enter submits what is shown (cleared text submits no team),\na form reset restores the default, and re-entering a custom tag that's\nalready chosen doesn't remove it."
|
|
7404
|
+
"description": "Form behavior: Enter submits what is shown (cleared text submits no team),\r\na form reset restores the default, and re-entering a custom tag that's\r\nalready chosen doesn't remove it."
|
|
7211
7405
|
},
|
|
7212
7406
|
{
|
|
7213
7407
|
"name": "Long list (10,000 options)",
|
|
7214
|
-
"description": "10,000 options. Only the options in view are in the page (plus the\nhighlighted one), so opening, scrolling, and typing stay instant. Each\noption carries its position in the full list (`aria-setsize`,\n`aria-posinset`), so screen readers still hear \"10,000 of 10,000\".\nLists with groups always render in full."
|
|
7408
|
+
"description": "10,000 options. Only the options in view are in the page (plus the\r\nhighlighted one), so opening, scrolling, and typing stay instant. Each\r\noption carries its position in the full list (`aria-setsize`,\r\n`aria-posinset`), so screen readers still hear \"10,000 of 10,000\".\r\nLists with groups always render in full."
|
|
7215
7409
|
}
|
|
7216
7410
|
]
|
|
7217
7411
|
},
|
|
@@ -7988,7 +8182,7 @@
|
|
|
7988
8182
|
},
|
|
7989
8183
|
{
|
|
7990
8184
|
"name": "Min And Max",
|
|
7991
|
-
"description": "`min` and `max` limit the calendar by date, and the time list on the\nboundary dates only: on Oct 22 the list starts at 6:00 PM; on other days\nit's the whole day."
|
|
8185
|
+
"description": "`min` and `max` limit the calendar by date, and the time list on the\r\nboundary dates only: on Oct 22 the list starts at 6:00 PM; on other days\r\nit's the whole day."
|
|
7992
8186
|
},
|
|
7993
8187
|
{
|
|
7994
8188
|
"name": "Controlled",
|
|
@@ -12069,7 +12263,7 @@
|
|
|
12069
12263
|
},
|
|
12070
12264
|
{
|
|
12071
12265
|
"name": "Validation",
|
|
12072
|
-
"description": "Text it can't read, or a time outside `min` / `max`, is flagged inline\nand announced politely; the value becomes null. `onInvalidInput` lets you\nshow your own `Field` error instead (with `invalidMessage={null}`)."
|
|
12266
|
+
"description": "Text it can't read, or a time outside `min` / `max`, is flagged inline\r\nand announced politely; the value becomes null. `onInvalidInput` lets you\r\nshow your own `Field` error instead (with `invalidMessage={null}`)."
|
|
12073
12267
|
},
|
|
12074
12268
|
{
|
|
12075
12269
|
"name": "Typed Formats",
|
|
@@ -12341,8 +12535,8 @@
|
|
|
12341
12535
|
"name": "rovingFocus",
|
|
12342
12536
|
"type": "boolean",
|
|
12343
12537
|
"required": false,
|
|
12344
|
-
"default": "true",
|
|
12345
|
-
"description": "Toolbar-style roving tabindex: the group is one Tab stop, and Arrow keys,\r\nHome, and End move focus between items (wrapping). Turn off to make every\r\nitem its own Tab stop."
|
|
12538
|
+
"default": "true (false inside a Toolbar)",
|
|
12539
|
+
"description": "Toolbar-style roving tabindex: the group is one Tab stop, and Arrow keys,\r\nHome, and End move focus between items (wrapping). Turn off to make every\r\nitem its own Tab stop. Inside a `Toolbar` it defaults to off, so the\r\nitems join the toolbar's own arrow keys."
|
|
12346
12540
|
},
|
|
12347
12541
|
{
|
|
12348
12542
|
"name": "role",
|
|
@@ -14666,11 +14860,11 @@
|
|
|
14666
14860
|
"stories": [
|
|
14667
14861
|
{
|
|
14668
14862
|
"name": "Playground",
|
|
14669
|
-
"description": "Right-click the area (or long-press it on a touch screen). With the area\nfocused, Shift+F10 or the Menu key opens the menu on the first item."
|
|
14863
|
+
"description": "Right-click the area (or long-press it on a touch screen). With the area\r\nfocused, Shift+F10 or the Menu key opens the menu on the first item."
|
|
14670
14864
|
},
|
|
14671
14865
|
{
|
|
14672
14866
|
"name": "Keyboard",
|
|
14673
|
-
"description": "Keyboard: Shift+F10 (or the Menu key) opens the menu next to the focused\nelement and focuses the first item. Escape closes it and focus goes back."
|
|
14867
|
+
"description": "Keyboard: Shift+F10 (or the Menu key) opens the menu next to the focused\r\nelement and focuses the first item. Escape closes it and focus goes back."
|
|
14674
14868
|
},
|
|
14675
14869
|
{
|
|
14676
14870
|
"name": "Long Press",
|
|
@@ -17072,6 +17266,118 @@
|
|
|
17072
17266
|
}
|
|
17073
17267
|
]
|
|
17074
17268
|
},
|
|
17269
|
+
{
|
|
17270
|
+
"name": "Toolbar",
|
|
17271
|
+
"category": "navigation",
|
|
17272
|
+
"folder": "Toolbar",
|
|
17273
|
+
"import": "import { Toolbar } from \"@vjdesigns/vjdesigns-ui\";",
|
|
17274
|
+
"description": "A row (or column) of controls that is one Tab stop, with arrow keys between controls.",
|
|
17275
|
+
"nativeElement": "div",
|
|
17276
|
+
"props": [
|
|
17277
|
+
{
|
|
17278
|
+
"name": "orientation",
|
|
17279
|
+
"type": "Orientation",
|
|
17280
|
+
"required": false,
|
|
17281
|
+
"default": "\"horizontal\"",
|
|
17282
|
+
"description": "Direction of the controls. Also picks the arrow keys: Left/Right when\r\nhorizontal (following the reading direction), Up/Down when vertical."
|
|
17283
|
+
},
|
|
17284
|
+
{
|
|
17285
|
+
"name": "variant",
|
|
17286
|
+
"type": "ToolbarVariant",
|
|
17287
|
+
"required": false,
|
|
17288
|
+
"default": "\"surface\"",
|
|
17289
|
+
"description": "`surface`: a rounded, bordered bar. `plain`: no container styling."
|
|
17290
|
+
},
|
|
17291
|
+
{
|
|
17292
|
+
"name": "loop",
|
|
17293
|
+
"type": "boolean",
|
|
17294
|
+
"required": false,
|
|
17295
|
+
"default": "true",
|
|
17296
|
+
"description": "Arrow keys wrap from the last control to the first, and back."
|
|
17297
|
+
},
|
|
17298
|
+
{
|
|
17299
|
+
"name": "wrap",
|
|
17300
|
+
"type": "boolean",
|
|
17301
|
+
"required": false,
|
|
17302
|
+
"default": "false",
|
|
17303
|
+
"description": "Let controls wrap onto more lines when there isn't room (horizontal only)."
|
|
17304
|
+
},
|
|
17305
|
+
{
|
|
17306
|
+
"name": "children",
|
|
17307
|
+
"type": "ReactNode",
|
|
17308
|
+
"required": false,
|
|
17309
|
+
"description": "The controls: buttons, toggle groups, links, menus, inputs, `Toolbar.Separator`, and `Toolbar.Group`."
|
|
17310
|
+
}
|
|
17311
|
+
],
|
|
17312
|
+
"subcomponents": [
|
|
17313
|
+
{
|
|
17314
|
+
"name": "Toolbar.Separator",
|
|
17315
|
+
"exportedAs": "ToolbarSeparator",
|
|
17316
|
+
"description": "A line between groups of controls, drawn across the toolbar's direction\r\n(`role=\"separator\"`). It isn't focusable, and arrow keys skip it.",
|
|
17317
|
+
"props": [
|
|
17318
|
+
{
|
|
17319
|
+
"name": "className",
|
|
17320
|
+
"type": "string",
|
|
17321
|
+
"required": false,
|
|
17322
|
+
"description": "Additional class for the separator."
|
|
17323
|
+
}
|
|
17324
|
+
]
|
|
17325
|
+
},
|
|
17326
|
+
{
|
|
17327
|
+
"name": "Toolbar.Group",
|
|
17328
|
+
"exportedAs": "ToolbarGroup",
|
|
17329
|
+
"description": "Keeps related controls together (`role=\"group\"`), so a wrapping toolbar\r\nmoves them to the next line as one. Its controls stay in the toolbar's\r\narrow-key order.",
|
|
17330
|
+
"nativeElement": "div",
|
|
17331
|
+
"props": [
|
|
17332
|
+
{
|
|
17333
|
+
"name": "children",
|
|
17334
|
+
"type": "ReactNode",
|
|
17335
|
+
"required": false,
|
|
17336
|
+
"description": "Related controls. Name the group with `aria-label` (e.g. \"Alignment\") if the controls don't make it obvious."
|
|
17337
|
+
}
|
|
17338
|
+
]
|
|
17339
|
+
}
|
|
17340
|
+
],
|
|
17341
|
+
"storybook": "Navigation/Toolbar",
|
|
17342
|
+
"stories": [
|
|
17343
|
+
{
|
|
17344
|
+
"name": "Playground",
|
|
17345
|
+
"description": ""
|
|
17346
|
+
},
|
|
17347
|
+
{
|
|
17348
|
+
"name": "Keyboard Navigation",
|
|
17349
|
+
"description": "One Tab stop; arrow keys, Home, and End move between every control, toggle groups included."
|
|
17350
|
+
},
|
|
17351
|
+
{
|
|
17352
|
+
"name": "All Variants",
|
|
17353
|
+
"description": "`surface` draws a rounded bar; `plain` adds no container styling."
|
|
17354
|
+
},
|
|
17355
|
+
{
|
|
17356
|
+
"name": "Vertical",
|
|
17357
|
+
"description": "Up and Down move between controls; the separator runs across."
|
|
17358
|
+
},
|
|
17359
|
+
{
|
|
17360
|
+
"name": "Disabled And No Loop",
|
|
17361
|
+
"description": "Disabled controls are skipped by the arrow keys, and `loop={false}` stops at the ends."
|
|
17362
|
+
},
|
|
17363
|
+
{
|
|
17364
|
+
"name": "With Input And Menu",
|
|
17365
|
+
"description": "A text field keeps its arrow keys, Home, and End for editing; Tab leaves\r\nthe toolbar. A menu trigger is just another control."
|
|
17366
|
+
},
|
|
17367
|
+
{
|
|
17368
|
+
"name": "With Composite Widget",
|
|
17369
|
+
"description": "Widgets with arrow keys of their own (here a `SegmentedControl`, a radio\r\ngroup) keep them, and stay a separate Tab stop."
|
|
17370
|
+
},
|
|
17371
|
+
{
|
|
17372
|
+
"name": "Right To Left",
|
|
17373
|
+
"description": "In right-to-left layouts, Left and Right follow the reading direction."
|
|
17374
|
+
},
|
|
17375
|
+
{
|
|
17376
|
+
"name": "Wrapping",
|
|
17377
|
+
"description": "With `wrap`, controls move to a new line when there isn't room; a `Toolbar.Group` wraps as one."
|
|
17378
|
+
}
|
|
17379
|
+
]
|
|
17380
|
+
},
|
|
17075
17381
|
{
|
|
17076
17382
|
"name": "CommandPalette",
|
|
17077
17383
|
"category": "overlays",
|
|
@@ -18180,11 +18486,11 @@
|
|
|
18180
18486
|
"stories": [
|
|
18181
18487
|
{
|
|
18182
18488
|
"name": "Playground",
|
|
18183
|
-
"description": "Rest the pointer on the name. The card opens after `openDelay`, stays\nopen while the pointer is on the link or the card, and closes\n`closeDelay` after it leaves both."
|
|
18489
|
+
"description": "Rest the pointer on the name. The card opens after `openDelay`, stays\r\nopen while the pointer is on the link or the card, and closes\r\n`closeDelay` after it leaves both."
|
|
18184
18490
|
},
|
|
18185
18491
|
{
|
|
18186
18492
|
"name": "Keyboard",
|
|
18187
|
-
"description": "Keyboard: Tab to the link opens the card. Tab again moves into its links;\nTab past the last one continues to what follows the trigger and closes\nthe card. Escape closes it and returns focus to the link."
|
|
18493
|
+
"description": "Keyboard: Tab to the link opens the card. Tab again moves into its links;\r\nTab past the last one continues to what follows the trigger and closes\r\nthe card. Escape closes it and returns focus to the link."
|
|
18188
18494
|
},
|
|
18189
18495
|
{
|
|
18190
18496
|
"name": "Click Closes",
|
|
@@ -19472,6 +19778,154 @@
|
|
|
19472
19778
|
"storybook": "Primitives/Button",
|
|
19473
19779
|
"stories": []
|
|
19474
19780
|
},
|
|
19781
|
+
{
|
|
19782
|
+
"name": "CopyButton",
|
|
19783
|
+
"category": "primitives",
|
|
19784
|
+
"folder": "CopyButton",
|
|
19785
|
+
"import": "import { CopyButton } from \"@vjdesigns/vjdesigns-ui\";",
|
|
19786
|
+
"description": "A button that copies text to the clipboard and confirms it: the icon turns\r\ninto a check and the label into \"Copied\", and the result is announced to\r\nscreen readers through a polite live region (a label change on a focused\r\nbutton isn't reliably read). Falls back to a legacy copy method where the\r\nClipboard API is blocked, and shows an error state if both fail.\r\n\r\nTakes `Button`'s style props (`variant`, `tone`, `size`, `radius`) and any\r\nnative `<button>` attribute. An `onClick` that calls `preventDefault()`\r\ncancels the copy.",
|
|
19787
|
+
"nativeElement": "button",
|
|
19788
|
+
"props": [
|
|
19789
|
+
{
|
|
19790
|
+
"name": "variant",
|
|
19791
|
+
"type": "ButtonVariant",
|
|
19792
|
+
"required": false,
|
|
19793
|
+
"default": "\"solid\"",
|
|
19794
|
+
"description": "Visual style. Inherits from a surrounding `ButtonGroup`."
|
|
19795
|
+
},
|
|
19796
|
+
{
|
|
19797
|
+
"name": "tone",
|
|
19798
|
+
"type": "Tone",
|
|
19799
|
+
"required": false,
|
|
19800
|
+
"default": "\"primary\"",
|
|
19801
|
+
"description": "Semantic color. Inherits from a surrounding `ButtonGroup`."
|
|
19802
|
+
},
|
|
19803
|
+
{
|
|
19804
|
+
"name": "size",
|
|
19805
|
+
"type": "Size",
|
|
19806
|
+
"required": false,
|
|
19807
|
+
"default": "\"md\"",
|
|
19808
|
+
"description": "Control height, padding, and type size. Inherits from a surrounding `ButtonGroup`."
|
|
19809
|
+
},
|
|
19810
|
+
{
|
|
19811
|
+
"name": "radius",
|
|
19812
|
+
"type": "Radius",
|
|
19813
|
+
"required": false,
|
|
19814
|
+
"default": "\"pill\"",
|
|
19815
|
+
"description": "Corner rounding. When omitted, uses `--control-radius` (pill)."
|
|
19816
|
+
},
|
|
19817
|
+
{
|
|
19818
|
+
"name": "disabled",
|
|
19819
|
+
"type": "boolean",
|
|
19820
|
+
"required": false,
|
|
19821
|
+
"default": "false",
|
|
19822
|
+
"description": "Disables the control. Buttons use the native `disabled` attribute; links drop `href` and get `aria-disabled`."
|
|
19823
|
+
},
|
|
19824
|
+
{
|
|
19825
|
+
"name": "value",
|
|
19826
|
+
"type": "string | (() => string)",
|
|
19827
|
+
"required": true,
|
|
19828
|
+
"description": "The text to copy, or a function that returns it when clicked (for values\r\nthat change, such as the current URL)."
|
|
19829
|
+
},
|
|
19830
|
+
{
|
|
19831
|
+
"name": "iconOnly",
|
|
19832
|
+
"type": "boolean",
|
|
19833
|
+
"required": false,
|
|
19834
|
+
"default": "false",
|
|
19835
|
+
"description": "Show only the icon. The accessible name is `aria-label` if you pass\r\none (e.g. \"Copy invite link\"), otherwise the translated \"Copy\"."
|
|
19836
|
+
},
|
|
19837
|
+
{
|
|
19838
|
+
"name": "children",
|
|
19839
|
+
"type": "ReactNode",
|
|
19840
|
+
"required": false,
|
|
19841
|
+
"default": "\"Copy\" (translated)",
|
|
19842
|
+
"description": "Visible label while idle."
|
|
19843
|
+
},
|
|
19844
|
+
{
|
|
19845
|
+
"name": "copiedLabel",
|
|
19846
|
+
"type": "string",
|
|
19847
|
+
"required": false,
|
|
19848
|
+
"default": "\"Copied\" (translated)",
|
|
19849
|
+
"description": "Label shown and announced after a successful copy."
|
|
19850
|
+
},
|
|
19851
|
+
{
|
|
19852
|
+
"name": "copyErrorLabel",
|
|
19853
|
+
"type": "string",
|
|
19854
|
+
"required": false,
|
|
19855
|
+
"default": "\"Couldn't copy\" (translated)",
|
|
19856
|
+
"description": "Label shown and announced when copying fails."
|
|
19857
|
+
},
|
|
19858
|
+
{
|
|
19859
|
+
"name": "timeout",
|
|
19860
|
+
"type": "number",
|
|
19861
|
+
"required": false,
|
|
19862
|
+
"default": "2000",
|
|
19863
|
+
"description": "How long the copied or error state shows, in milliseconds."
|
|
19864
|
+
},
|
|
19865
|
+
{
|
|
19866
|
+
"name": "onCopyStatusChange",
|
|
19867
|
+
"type": "(status: CopyStatus) => void",
|
|
19868
|
+
"required": false,
|
|
19869
|
+
"description": "Called with each copy result, then with `\"idle\"` when it resets."
|
|
19870
|
+
}
|
|
19871
|
+
],
|
|
19872
|
+
"subcomponents": [],
|
|
19873
|
+
"storybook": "Primitives/CopyButton",
|
|
19874
|
+
"stories": [
|
|
19875
|
+
{
|
|
19876
|
+
"name": "Playground",
|
|
19877
|
+
"description": ""
|
|
19878
|
+
},
|
|
19879
|
+
{
|
|
19880
|
+
"name": "Behavior",
|
|
19881
|
+
"description": "Copying shows \"Copied\", announces it, reports the status, and resets after `timeout`."
|
|
19882
|
+
},
|
|
19883
|
+
{
|
|
19884
|
+
"name": "Error State",
|
|
19885
|
+
"description": "When copying fails, the button says so (and announces it) instead of pretending it worked."
|
|
19886
|
+
},
|
|
19887
|
+
{
|
|
19888
|
+
"name": "Icon Only",
|
|
19889
|
+
"description": "Icon only: the accessible name is `aria-label` (or \"Copy\"); the icon turns into a check."
|
|
19890
|
+
},
|
|
19891
|
+
{
|
|
19892
|
+
"name": "Cancelable",
|
|
19893
|
+
"description": "An `onClick` that calls `preventDefault()` cancels the copy."
|
|
19894
|
+
},
|
|
19895
|
+
{
|
|
19896
|
+
"name": "All Variants",
|
|
19897
|
+
"description": ""
|
|
19898
|
+
},
|
|
19899
|
+
{
|
|
19900
|
+
"name": "All Tones",
|
|
19901
|
+
"description": ""
|
|
19902
|
+
},
|
|
19903
|
+
{
|
|
19904
|
+
"name": "All Sizes",
|
|
19905
|
+
"description": ""
|
|
19906
|
+
},
|
|
19907
|
+
{
|
|
19908
|
+
"name": "Disabled",
|
|
19909
|
+
"description": ""
|
|
19910
|
+
},
|
|
19911
|
+
{
|
|
19912
|
+
"name": "In AField",
|
|
19913
|
+
"description": "Inside a read-only field, as the field's end element."
|
|
19914
|
+
},
|
|
19915
|
+
{
|
|
19916
|
+
"name": "Computed Value",
|
|
19917
|
+
"description": "`value` can be a function, read when clicked, for values that change."
|
|
19918
|
+
},
|
|
19919
|
+
{
|
|
19920
|
+
"name": "Custom Labels",
|
|
19921
|
+
"description": "Custom labels, for example in another language or for a specific action."
|
|
19922
|
+
},
|
|
19923
|
+
{
|
|
19924
|
+
"name": "Both Themes",
|
|
19925
|
+
"description": "Both themes side by side."
|
|
19926
|
+
}
|
|
19927
|
+
]
|
|
19928
|
+
},
|
|
19475
19929
|
{
|
|
19476
19930
|
"name": "Display",
|
|
19477
19931
|
"category": "primitives",
|