@uibot/registry 0.19.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component-replacement.d.ts +10 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2117 -12
- package/dist/materialize-templates.d.ts +28 -0
- package/dist/materialize.d.ts +63 -0
- package/dist/resources.d.ts +5 -0
- package/dist/resources.js +2108 -3
- package/dist/shadcn/r/admin-apps.json +1 -1
- package/dist/shadcn/r/admin-chats.json +1 -1
- package/dist/shadcn/r/admin-settings-account.json +1 -1
- package/dist/shadcn/r/admin-settings-appearance.json +1 -1
- package/dist/shadcn/r/admin-settings-display.json +1 -1
- package/dist/shadcn/r/admin-settings-notifications.json +1 -1
- package/dist/shadcn/r/admin-settings-profile.json +1 -1
- package/dist/shadcn/r/admin-settings.json +1 -1
- package/dist/shadcn/r/admin-shell.json +16 -3
- package/dist/shadcn/r/admin-tasks.json +1 -1
- package/dist/shadcn/r/admin-users.json +1 -1
- package/dist/shadcn/r/agent-run-console.json +64 -0
- package/dist/shadcn/r/auth-minimal.json +59 -0
- package/dist/shadcn/r/billing-overview.json +66 -0
- package/dist/shadcn/r/billing-usage-ledger.json +66 -0
- package/dist/shadcn/r/charts.json +44 -17
- package/dist/shadcn/r/chat-workspace.json +1 -1
- package/dist/shadcn/r/collection-cell-editor.json +1 -1
- package/dist/shadcn/r/collection-kanban.json +134 -0
- package/dist/shadcn/r/collection-panel-drawer.json +1 -1
- package/dist/shadcn/r/collection-record-menu.json +1 -1
- package/dist/shadcn/r/collection-shared.json +1 -1
- package/dist/shadcn/r/commerce-workspace.json +1 -1
- package/dist/shadcn/r/console-billing.json +1 -1
- package/dist/shadcn/r/console-page.json +14 -14
- package/dist/shadcn/r/console-shell.json +2 -2
- package/dist/shadcn/r/creation-html-generation.json +2 -2
- package/dist/shadcn/r/creation-reference-generation.json +2 -2
- package/dist/shadcn/r/creation-revision-export.json +2 -2
- package/dist/shadcn/r/creation-shared.json +2 -2
- package/dist/shadcn/r/creation-variant-compare.json +3 -3
- package/dist/shadcn/r/creation-workspace.json +3 -3
- package/dist/shadcn/r/crm-workspace.json +1 -1
- package/dist/shadcn/r/dashboard-01.json +78 -0
- package/dist/shadcn/r/dashboard.json +113 -3
- package/dist/shadcn/r/data-crud-gallery.json +66 -0
- package/dist/shadcn/r/data-crud-kanban.json +66 -0
- package/dist/shadcn/r/data-crud-master-detail.json +66 -0
- package/dist/shadcn/r/data-crud-table.json +66 -0
- package/dist/shadcn/r/data-table.json +120 -10
- package/dist/shadcn/r/data.json +9 -2
- package/dist/shadcn/r/document-assistant.json +1 -1
- package/dist/shadcn/r/document-workspace.json +1 -1
- package/dist/shadcn/r/drilldown-menu.json +1 -1
- package/dist/shadcn/r/education-workspace.json +1 -1
- package/dist/shadcn/r/feedback.json +15 -2
- package/dist/shadcn/r/form.json +1 -1
- package/dist/shadcn/r/launch-site.json +72 -0
- package/dist/shadcn/r/layout.json +57 -22
- package/dist/shadcn/r/nav.json +38 -10
- package/dist/shadcn/r/onboarding-checklist.json +63 -0
- package/dist/shadcn/r/onboarding-wizard.json +66 -0
- package/dist/shadcn/r/prompt-eval-workbench.json +65 -0
- package/dist/shadcn/r/record-master-detail.json +132 -0
- package/dist/shadcn/r/shadcn-admin.json +1 -1
- package/dist/shadcn/r/sidebar-primitives.json +1 -1
- package/dist/shadcn/r/workspace.json +9 -2
- package/dist/shadcn/registry.json +229 -27
- package/dist/solution-regions.d.ts +12 -2
- package/dist/spec-blueprint.d.ts +11 -0
- package/dist/spec-patch.d.ts +10 -0
- package/dist/variant-swap.d.ts +22 -0
- package/package.json +2 -2
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
{
|
|
15
15
|
"path": "lib/uibot/templates/admin-settings.uibot.yaml",
|
|
16
16
|
"target": "lib/uibot/templates/admin-settings.uibot.yaml",
|
|
17
|
-
"content": "version: \"2.0\"\npages:\n - id: settings-profile\n path: /settings/profile\n title: Settings · Profile\n state:\n direction: ltr\n font: Inter\n loading: false\n theme: light\n currentPath: /settings/profile\n saving: false\n uiError: null\n saved: false\n form:\n username: shadcn\n email: m@example.com\n bio: I own a computer.\n urls:\n - https://shadcn.com\n preferences: []\n blocks:\n - type: PageLayout\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 1\n text: Settings\n - type: Paragraph\n props:\n text: Manage your account settings and set e-mail preferences.\n muted: true\n size: sm\n - type: Divider\n - type: Box\n props:\n className: \"!flex-col gap-10 lg:!flex-row\"\n children:\n - type: Box\n props:\n className: w-full shrink-0 lg:!flex-col lg:w-48 [&>a]:shrink-0 [&>a]:px-3\n [&>a]:py-2 [&>a]:rounded-md lg:[&>a]:px-0 lg:[&>a]:py-0\n direction: row\n wrap: true\n gap: md\n children:\n - type: Link\n props:\n label: Profile\n href: /settings/profile\n variant: default\n className: bg-muted font-medium lg:bg-transparent\n - type: Link\n props:\n label: Account\n href: /settings/account\n variant: muted\n - type: Link\n props:\n label: Appearance\n href: /settings/appearance\n variant: muted\n - type: Link\n props:\n label: Notifications\n href: /settings/notifications\n variant: muted\n - type: Link\n props:\n label: Display\n href: /settings/display\n variant: muted\n - type: Box\n props:\n className: max-w-2xl flex-1\n gap: lg\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 2\n text: Profile\n - type: Paragraph\n props:\n text: This is how others will see you on the site.\n muted: true\n size: sm\n - type: Divider\n - type: Form\n props:\n label: Profile settings\n pending:\n _or:\n - _state: saving\n - _state: loading\n idempotent: true\n children:\n - type: Field\n props:\n name: username\n label: Username\n description: This is your public display name.\n required: true\n value:\n _bindState: form.username\n - type: Field\n props:\n name: email\n label: Email\n kind: email\n required: true\n value:\n _bindState: form.email\n - type: Field\n props:\n name: bio\n label: Bio\n kind: textarea\n description: Describe your role and what you work on.\n value:\n _bindState: form.bio\n - type: Field\n props:\n name: urls\n label: URLs\n kind: urls\n description: Add links to your website, blog, or social media profiles.\n value:\n _bindState: form.urls\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - type: Paragraph\n props:\n text:\n _state: uiError.message\n muted: true\n visible:\n _state: uiError\n - type: Form.Submit\n props:\n label: Update profile\n disabled:\n _state: saving\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n onSubmit:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: save-preferences\n connectionId: preferences-db\n payload:\n operation:\n _if:\n - _state: preferences.0.id\n - UpdateOne\n - InsertOne\n filter:\n id:\n _state: preferences.0.id\n data:\n section: profile\n values:\n _event: values\n idempotencyKey:\n _event: value\n expectedVersion:\n _state: preferences.0.version\n loadingPath: saving\n errorPath: uiError\n onSuccess:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: profile\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - action: SetState\n params:\n path: saved\n value:\n _not:\n _state: uiError\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - type: Paragraph\n props:\n text: Settings saved.\n muted: true\n visible:\n _state: saved\n events:\n onThemeChange:\n - action: SetState\n params:\n path: theme\n value:\n _event: value\n props:\n headerLinks:\n - label: Settings · Profile\n href: /settings/profile\n appearance: admin\n routes:\n - label: Settings · Profile\n href: /settings/profile\n theme:\n _state: theme\n direction:\n _state: direction\n font:\n _state: font\n lifecycle:\n onMount:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: profile\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - id: settings-account\n path: /settings/account\n title: Settings · Account\n state:\n direction: ltr\n font: Inter\n loading: false\n theme: light\n currentPath: /settings/account\n saving: false\n uiError: null\n saved: false\n form:\n name: shadcn\n birthday: \"\"\n language: English\n preferences: []\n blocks:\n - type: PageLayout\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 1\n text: Settings\n - type: Paragraph\n props:\n text: Manage your account settings and set e-mail preferences.\n muted: true\n size: sm\n - type: Divider\n - type: Box\n props:\n className: \"!flex-col gap-10 lg:!flex-row\"\n children:\n - type: Box\n props:\n className: w-full shrink-0 !flex-row flex-wrap gap-1 lg:!flex-col lg:w-48\n [&>a]:shrink-0 [&>a]:px-3 [&>a]:py-2 [&>a]:rounded-md\n lg:[&>a]:px-0 lg:[&>a]:py-0\n children:\n - type: Link\n props:\n label: Profile\n href: /settings/profile\n variant: muted\n - type: Link\n props:\n label: Account\n href: /settings/account\n variant: default\n className: bg-muted font-medium lg:bg-transparent\n - type: Link\n props:\n label: Appearance\n href: /settings/appearance\n variant: muted\n - type: Link\n props:\n label: Notifications\n href: /settings/notifications\n variant: muted\n - type: Link\n props:\n label: Display\n href: /settings/display\n variant: muted\n - type: Box\n props:\n className: max-w-2xl flex-1\n gap: lg\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 2\n text: Account\n - type: Paragraph\n props:\n text: Update your account settings. Set your preferred language and timezone.\n muted: true\n size: sm\n - type: Divider\n - type: Form\n props:\n label: Account settings\n pending:\n _or:\n - _state: saving\n - _state: loading\n idempotent: true\n children:\n - type: Field\n props:\n name: name\n label: Name\n description: This is the name that will be displayed on your profile.\n required: true\n value:\n _bindState: form.name\n - type: Field\n props:\n name: birthday\n label: Date of birth\n kind: date\n description: Your date of birth is used to calculate your age.\n value:\n _bindState: form.birthday\n - type: Field\n props:\n name: language\n label: Language\n kind: combobox\n options:\n - value: English\n label: English\n - value: Chinese\n label: Chinese\n - value: French\n label: French\n - value: German\n label: German\n - value: Japanese\n label: Japanese\n value:\n _bindState: form.language\n - type: Paragraph\n props:\n text:\n _state: uiError.message\n muted: true\n visible:\n _state: uiError\n - type: Form.Submit\n props:\n label: Update account\n disabled:\n _state: saving\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n onSubmit:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: save-preferences\n connectionId: preferences-db\n payload:\n operation:\n _if:\n - _state: preferences.0.id\n - UpdateOne\n - InsertOne\n filter:\n id:\n _state: preferences.0.id\n data:\n section: account\n values:\n _event: values\n idempotencyKey:\n _event: value\n expectedVersion:\n _state: preferences.0.version\n loadingPath: saving\n errorPath: uiError\n onSuccess:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: account\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - action: SetState\n params:\n path: saved\n value:\n _not:\n _state: uiError\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - type: Paragraph\n props:\n text: Settings saved.\n muted: true\n visible:\n _state: saved\n events:\n onThemeChange:\n - action: SetState\n params:\n path: theme\n value:\n _event: value\n props:\n headerLinks:\n - label: Settings · Account\n href: /settings/account\n appearance: admin\n routes:\n - label: Settings · Account\n href: /settings/account\n theme:\n _state: theme\n direction:\n _state: direction\n font:\n _state: font\n lifecycle:\n onMount:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: account\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - id: settings-appearance\n path: /settings/appearance\n title: Settings · Appearance\n state:\n direction: ltr\n font: Inter\n loading: false\n theme: light\n currentPath: /settings/appearance\n saving: false\n uiError: null\n saved: false\n form:\n font: Inter\n theme: light\n direction: ltr\n preferences: []\n blocks:\n - type: PageLayout\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 1\n text: Settings\n - type: Paragraph\n props:\n text: Manage your account settings and set e-mail preferences.\n muted: true\n size: sm\n - type: Divider\n - type: Box\n props:\n className: \"!flex-col gap-10 lg:!flex-row\"\n children:\n - type: Box\n props:\n className: w-full shrink-0 !flex-row flex-wrap gap-1 lg:!flex-col lg:w-48\n [&>a]:shrink-0 [&>a]:px-3 [&>a]:py-2 [&>a]:rounded-md\n lg:[&>a]:px-0 lg:[&>a]:py-0\n children:\n - type: Link\n props:\n label: Profile\n href: /settings/profile\n variant: muted\n - type: Link\n props:\n label: Account\n href: /settings/account\n variant: muted\n - type: Link\n props:\n label: Appearance\n href: /settings/appearance\n variant: default\n className: bg-muted font-medium lg:bg-transparent\n - type: Link\n props:\n label: Notifications\n href: /settings/notifications\n variant: muted\n - type: Link\n props:\n label: Display\n href: /settings/display\n variant: muted\n - type: Box\n props:\n className: max-w-2xl flex-1\n gap: lg\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 2\n text: Appearance\n - type: Paragraph\n props:\n text: Customize the appearance of the app. Automatically switch between day and\n night themes.\n muted: true\n size: sm\n - type: Divider\n - type: Form\n props:\n label: Appearance settings\n pending:\n _or:\n - _state: saving\n - _state: loading\n idempotent: true\n children:\n - type: Field\n props:\n name: font\n label: Font\n kind: select\n options:\n - value: Inter\n label: Inter\n - value: System\n label: System\n - value: Manrope\n label: Manrope\n value:\n _bindState: form.font\n - type: Field\n props:\n name: theme\n label: Theme\n kind: radio\n options:\n - value: light\n label: Light\n - value: dark\n label: Dark\n - value: system\n label: System\n value:\n _bindState: form.theme\n - type: Field\n props:\n name: direction\n label: Direction\n kind: select\n options:\n - value: ltr\n label: Ltr\n - value: rtl\n label: Rtl\n value:\n _bindState: form.direction\n - type: Paragraph\n props:\n text:\n _state: uiError.message\n muted: true\n visible:\n _state: uiError\n - type: Form.Submit\n props:\n label: Update appearance\n disabled:\n _state: saving\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n onSubmit:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: save-preferences\n connectionId: preferences-db\n payload:\n operation:\n _if:\n - _state: preferences.0.id\n - UpdateOne\n - InsertOne\n filter:\n id:\n _state: preferences.0.id\n data:\n section: appearance\n values:\n _event: values\n idempotencyKey:\n _event: value\n expectedVersion:\n _state: preferences.0.version\n loadingPath: saving\n errorPath: uiError\n onSuccess:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: appearance\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - action: SetState\n params:\n path: saved\n value:\n _not:\n _state: uiError\n - action: SetState\n params:\n path: theme\n value:\n _state: form.theme\n - action: SetState\n params:\n path: direction\n value:\n _state: form.direction\n - action: SetState\n params:\n path: font\n value:\n _state: form.font\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - type: Paragraph\n props:\n text: Settings saved.\n muted: true\n visible:\n _state: saved\n events:\n onThemeChange:\n - action: SetState\n params:\n path: theme\n value:\n _event: value\n props:\n headerLinks:\n - label: Settings · Appearance\n href: /settings/appearance\n appearance: admin\n routes:\n - label: Settings · Appearance\n href: /settings/appearance\n theme:\n _state: theme\n direction:\n _state: direction\n font:\n _state: font\n lifecycle:\n onMount:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: appearance\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - id: settings-notifications\n path: /settings/notifications\n title: Settings · Notifications\n state:\n direction: ltr\n font: Inter\n loading: false\n theme: light\n currentPath: /settings/notifications\n saving: false\n uiError: null\n saved: false\n form:\n notify: all\n communication: false\n marketing: false\n social: true\n security: true\n preferences: []\n blocks:\n - type: PageLayout\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 1\n text: Settings\n - type: Paragraph\n props:\n text: Manage your account settings and set e-mail preferences.\n muted: true\n size: sm\n - type: Divider\n - type: Box\n props:\n className: \"!flex-col gap-10 lg:!flex-row\"\n children:\n - type: Box\n props:\n className: w-full shrink-0 !flex-row flex-wrap gap-1 lg:!flex-col lg:w-48\n [&>a]:shrink-0 [&>a]:px-3 [&>a]:py-2 [&>a]:rounded-md\n lg:[&>a]:px-0 lg:[&>a]:py-0\n children:\n - type: Link\n props:\n label: Profile\n href: /settings/profile\n variant: muted\n - type: Link\n props:\n label: Account\n href: /settings/account\n variant: muted\n - type: Link\n props:\n label: Appearance\n href: /settings/appearance\n variant: muted\n - type: Link\n props:\n label: Notifications\n href: /settings/notifications\n variant: default\n className: bg-muted font-medium lg:bg-transparent\n - type: Link\n props:\n label: Display\n href: /settings/display\n variant: muted\n - type: Box\n props:\n className: max-w-2xl flex-1\n gap: lg\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 2\n text: Notifications\n - type: Paragraph\n props:\n text: Configure how you receive notifications.\n muted: true\n size: sm\n - type: Divider\n - type: Form\n props:\n label: Notifications settings\n pending:\n _or:\n - _state: saving\n - _state: loading\n idempotent: true\n children:\n - type: Field\n props:\n name: notify\n label: Notify me about...\n kind: radio\n options:\n - label: All new messages\n value: all\n - label: Direct messages and mentions\n value: mentions\n - label: Nothing\n value: none\n value:\n _bindState: form.notify\n - type: Field\n props:\n name: communication\n kind: switch\n label: Communication emails\n description: Receive emails about your account activity.\n value:\n _bindState: form.communication\n - type: Field\n props:\n name: marketing\n kind: switch\n label: Marketing emails\n description: Receive emails about new products and features.\n value:\n _bindState: form.marketing\n - type: Field\n props:\n name: social\n kind: switch\n label: Social emails\n description: Receive emails for friend requests and follows.\n value:\n _bindState: form.social\n - type: Field\n props:\n name: security\n kind: switch\n label: Security emails\n description: Receive emails about your account security.\n value:\n _bindState: form.security\n - type: Paragraph\n props:\n text:\n _state: uiError.message\n muted: true\n visible:\n _state: uiError\n - type: Form.Submit\n props:\n label: Update notifications\n disabled:\n _state: saving\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n onSubmit:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: save-preferences\n connectionId: preferences-db\n payload:\n operation:\n _if:\n - _state: preferences.0.id\n - UpdateOne\n - InsertOne\n filter:\n id:\n _state: preferences.0.id\n data:\n section: notifications\n values:\n _event: values\n idempotencyKey:\n _event: value\n expectedVersion:\n _state: preferences.0.version\n loadingPath: saving\n errorPath: uiError\n onSuccess:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: notifications\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - action: SetState\n params:\n path: saved\n value:\n _not:\n _state: uiError\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - type: Paragraph\n props:\n text: Settings saved.\n muted: true\n visible:\n _state: saved\n events:\n onThemeChange:\n - action: SetState\n params:\n path: theme\n value:\n _event: value\n props:\n headerLinks:\n - label: Settings · Notifications\n href: /settings/notifications\n appearance: admin\n routes:\n - label: Settings · Notifications\n href: /settings/notifications\n theme:\n _state: theme\n direction:\n _state: direction\n font:\n _state: font\n lifecycle:\n onMount:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: notifications\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - id: settings-display\n path: /settings/display\n title: Settings · Display\n state:\n direction: ltr\n font: Inter\n loading: false\n theme: light\n currentPath: /settings/display\n saving: false\n uiError: null\n saved: false\n form:\n recents: true\n home: true\n applications: true\n desktop: true\n downloads: true\n documents: true\n preferences: []\n blocks:\n - type: PageLayout\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 1\n text: Settings\n - type: Paragraph\n props:\n text: Manage your account settings and set e-mail preferences.\n muted: true\n size: sm\n - type: Divider\n - type: Box\n props:\n className: \"!flex-col gap-10 lg:!flex-row\"\n children:\n - type: Box\n props:\n className: w-full shrink-0 !flex-row flex-wrap gap-1 lg:!flex-col lg:w-48\n [&>a]:shrink-0 [&>a]:px-3 [&>a]:py-2 [&>a]:rounded-md\n lg:[&>a]:px-0 lg:[&>a]:py-0\n children:\n - type: Link\n props:\n label: Profile\n href: /settings/profile\n variant: muted\n - type: Link\n props:\n label: Account\n href: /settings/account\n variant: muted\n - type: Link\n props:\n label: Appearance\n href: /settings/appearance\n variant: muted\n - type: Link\n props:\n label: Notifications\n href: /settings/notifications\n variant: muted\n - type: Link\n props:\n label: Display\n href: /settings/display\n variant: default\n className: bg-muted font-medium lg:bg-transparent\n - type: Box\n props:\n className: max-w-2xl flex-1\n gap: lg\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 2\n text: Display\n - type: Paragraph\n props:\n text: Turn items on or off to control what’s displayed in the app.\n muted: true\n size: sm\n - type: Divider\n - type: Form\n props:\n label: Display settings\n pending:\n _or:\n - _state: saving\n - _state: loading\n idempotent: true\n children:\n - type: Paragraph\n props:\n text: Select the items you want to display in the sidebar.\n muted: true\n - type: Field\n props:\n name: recents\n label: Recents\n kind: checkbox\n value:\n _bindState: form.recents\n - type: Field\n props:\n name: home\n label: Home\n kind: checkbox\n value:\n _bindState: form.home\n - type: Field\n props:\n name: applications\n label: Applications\n kind: checkbox\n value:\n _bindState: form.applications\n - type: Field\n props:\n name: desktop\n label: Desktop\n kind: checkbox\n value:\n _bindState: form.desktop\n - type: Field\n props:\n name: downloads\n label: Downloads\n kind: checkbox\n value:\n _bindState: form.downloads\n - type: Field\n props:\n name: documents\n label: Documents\n kind: checkbox\n value:\n _bindState: form.documents\n - type: Paragraph\n props:\n text:\n _state: uiError.message\n muted: true\n visible:\n _state: uiError\n - type: Form.Submit\n props:\n label: Update display\n disabled:\n _state: saving\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n onSubmit:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: save-preferences\n connectionId: preferences-db\n payload:\n operation:\n _if:\n - _state: preferences.0.id\n - UpdateOne\n - InsertOne\n filter:\n id:\n _state: preferences.0.id\n data:\n section: display\n values:\n _event: values\n idempotencyKey:\n _event: value\n expectedVersion:\n _state: preferences.0.version\n loadingPath: saving\n errorPath: uiError\n onSuccess:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: display\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - action: SetState\n params:\n path: saved\n value:\n _not:\n _state: uiError\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - type: Paragraph\n props:\n text: Settings saved.\n muted: true\n visible:\n _state: saved\n events:\n onThemeChange:\n - action: SetState\n params:\n path: theme\n value:\n _event: value\n props:\n headerLinks:\n - label: Settings · Display\n href: /settings/display\n appearance: admin\n routes:\n - label: Settings · Display\n href: /settings/display\n theme:\n _state: theme\n direction:\n _state: direction\n font:\n _state: font\n lifecycle:\n onMount:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: display\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\nconnections:\n - id: preferences-db\n type: NowAPI.Collection\n",
|
|
17
|
+
"content": "version: \"2.0\"\npages:\n - id: settings-profile\n path: /settings/profile\n title: Settings · Profile\n state:\n direction: ltr\n font: Inter\n loading: false\n theme: light\n currentPath: /settings/profile\n saving: false\n uiError: null\n saved: false\n form:\n username: shadcn\n email: m@example.com\n bio: I own a computer.\n urls:\n - https://shadcn.com\n preferences: []\n blocks:\n - type: PageLayout\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 1\n text: Settings\n - type: Paragraph\n props:\n text: Manage your account settings and set e-mail preferences.\n muted: true\n size: sm\n - type: Divider\n - type: Box\n props:\n className: \"!flex-col gap-10 lg:!flex-row\"\n children:\n - type: Box\n props:\n className: w-full shrink-0 lg:!flex-col lg:w-48 [&>a]:shrink-0 [&>a]:px-3\n [&>a]:py-2 [&>a]:rounded-md lg:[&>a]:px-0 lg:[&>a]:py-0\n direction: row\n wrap: true\n gap: md\n children:\n - type: Link\n props:\n label: Profile\n href: /settings/profile\n variant: default\n className: bg-muted font-medium lg:bg-transparent\n - type: Link\n props:\n label: Account\n href: /settings/account\n variant: muted\n - type: Link\n props:\n label: Appearance\n href: /settings/appearance\n variant: muted\n - type: Link\n props:\n label: Notifications\n href: /settings/notifications\n variant: muted\n - type: Link\n props:\n label: Display\n href: /settings/display\n variant: muted\n - type: Box\n props:\n className: max-w-2xl flex-1\n gap: lg\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 2\n text: Profile\n - type: Paragraph\n props:\n text: This is how others will see you on the site.\n muted: true\n size: sm\n - type: Divider\n - type: Form\n props:\n label: Profile settings\n pending:\n _or:\n - _state: saving\n - _state: loading\n idempotent: true\n children:\n - type: Field\n props:\n name: username\n label: Username\n description: This is your public display name.\n required: true\n value:\n _bindState: form.username\n - type: Field\n props:\n name: email\n label: Email\n kind: email\n required: true\n value:\n _bindState: form.email\n - type: Field\n props:\n name: bio\n label: Bio\n kind: textarea\n description: Describe your role and what you work on.\n value:\n _bindState: form.bio\n - type: Field\n props:\n name: urls\n label: URLs\n kind: urls\n description: Add links to your website, blog, or social media profiles.\n value:\n _bindState: form.urls\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - type: Paragraph\n props:\n text:\n _state: uiError.message\n muted: true\n visible:\n _state: uiError\n - type: Form.Submit\n props:\n label: Update profile\n disabled:\n _state: saving\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n onSubmit:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: save-preferences\n connectionId: preferences-db\n payload:\n _if:\n - _eq:\n - _if:\n - _state: preferences.0.id\n - UpdateOne\n - InsertOne\n - InsertOne\n - operation: InsertOne\n data:\n section: profile\n values:\n _event: values\n - operation: UpdateOne\n data:\n section: profile\n values:\n _event: values\n filter:\n id:\n _state: preferences.0.id\n version:\n _state: preferences.0.version\n loadingPath: saving\n errorPath: uiError\n onSuccess:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: profile\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - action: SetState\n params:\n path: saved\n value:\n _not:\n _state: uiError\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - type: Paragraph\n props:\n text: Settings saved.\n muted: true\n visible:\n _state: saved\n events:\n onThemeChange:\n - action: SetState\n params:\n path: theme\n value:\n _event: value\n props:\n headerLinks:\n - label: Settings · Profile\n href: /settings/profile\n appearance: admin\n routes:\n - label: Settings · Profile\n href: /settings/profile\n theme:\n _state: theme\n direction:\n _state: direction\n font:\n _state: font\n lifecycle:\n onMount:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: profile\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - id: settings-account\n path: /settings/account\n title: Settings · Account\n state:\n direction: ltr\n font: Inter\n loading: false\n theme: light\n currentPath: /settings/account\n saving: false\n uiError: null\n saved: false\n form:\n name: shadcn\n birthday: \"\"\n language: English\n preferences: []\n blocks:\n - type: PageLayout\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 1\n text: Settings\n - type: Paragraph\n props:\n text: Manage your account settings and set e-mail preferences.\n muted: true\n size: sm\n - type: Divider\n - type: Box\n props:\n className: \"!flex-col gap-10 lg:!flex-row\"\n children:\n - type: Box\n props:\n className: w-full shrink-0 !flex-row flex-wrap gap-1 lg:!flex-col lg:w-48\n [&>a]:shrink-0 [&>a]:px-3 [&>a]:py-2 [&>a]:rounded-md\n lg:[&>a]:px-0 lg:[&>a]:py-0\n children:\n - type: Link\n props:\n label: Profile\n href: /settings/profile\n variant: muted\n - type: Link\n props:\n label: Account\n href: /settings/account\n variant: default\n className: bg-muted font-medium lg:bg-transparent\n - type: Link\n props:\n label: Appearance\n href: /settings/appearance\n variant: muted\n - type: Link\n props:\n label: Notifications\n href: /settings/notifications\n variant: muted\n - type: Link\n props:\n label: Display\n href: /settings/display\n variant: muted\n - type: Box\n props:\n className: max-w-2xl flex-1\n gap: lg\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 2\n text: Account\n - type: Paragraph\n props:\n text: Update your account settings. Set your preferred language and timezone.\n muted: true\n size: sm\n - type: Divider\n - type: Form\n props:\n label: Account settings\n pending:\n _or:\n - _state: saving\n - _state: loading\n idempotent: true\n children:\n - type: Field\n props:\n name: name\n label: Name\n description: This is the name that will be displayed on your profile.\n required: true\n value:\n _bindState: form.name\n - type: Field\n props:\n name: birthday\n label: Date of birth\n kind: date\n description: Your date of birth is used to calculate your age.\n value:\n _bindState: form.birthday\n - type: Field\n props:\n name: language\n label: Language\n kind: combobox\n options:\n - value: English\n label: English\n - value: Chinese\n label: Chinese\n - value: French\n label: French\n - value: German\n label: German\n - value: Japanese\n label: Japanese\n value:\n _bindState: form.language\n - type: Paragraph\n props:\n text:\n _state: uiError.message\n muted: true\n visible:\n _state: uiError\n - type: Form.Submit\n props:\n label: Update account\n disabled:\n _state: saving\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n onSubmit:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: save-preferences\n connectionId: preferences-db\n payload:\n _if:\n - _eq:\n - _if:\n - _state: preferences.0.id\n - UpdateOne\n - InsertOne\n - InsertOne\n - operation: InsertOne\n data:\n section: account\n values:\n _event: values\n - operation: UpdateOne\n data:\n section: account\n values:\n _event: values\n filter:\n id:\n _state: preferences.0.id\n version:\n _state: preferences.0.version\n loadingPath: saving\n errorPath: uiError\n onSuccess:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: account\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - action: SetState\n params:\n path: saved\n value:\n _not:\n _state: uiError\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - type: Paragraph\n props:\n text: Settings saved.\n muted: true\n visible:\n _state: saved\n events:\n onThemeChange:\n - action: SetState\n params:\n path: theme\n value:\n _event: value\n props:\n headerLinks:\n - label: Settings · Account\n href: /settings/account\n appearance: admin\n routes:\n - label: Settings · Account\n href: /settings/account\n theme:\n _state: theme\n direction:\n _state: direction\n font:\n _state: font\n lifecycle:\n onMount:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: account\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - id: settings-appearance\n path: /settings/appearance\n title: Settings · Appearance\n state:\n direction: ltr\n font: Inter\n loading: false\n theme: light\n currentPath: /settings/appearance\n saving: false\n uiError: null\n saved: false\n form:\n font: Inter\n theme: light\n direction: ltr\n preferences: []\n blocks:\n - type: PageLayout\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 1\n text: Settings\n - type: Paragraph\n props:\n text: Manage your account settings and set e-mail preferences.\n muted: true\n size: sm\n - type: Divider\n - type: Box\n props:\n className: \"!flex-col gap-10 lg:!flex-row\"\n children:\n - type: Box\n props:\n className: w-full shrink-0 !flex-row flex-wrap gap-1 lg:!flex-col lg:w-48\n [&>a]:shrink-0 [&>a]:px-3 [&>a]:py-2 [&>a]:rounded-md\n lg:[&>a]:px-0 lg:[&>a]:py-0\n children:\n - type: Link\n props:\n label: Profile\n href: /settings/profile\n variant: muted\n - type: Link\n props:\n label: Account\n href: /settings/account\n variant: muted\n - type: Link\n props:\n label: Appearance\n href: /settings/appearance\n variant: default\n className: bg-muted font-medium lg:bg-transparent\n - type: Link\n props:\n label: Notifications\n href: /settings/notifications\n variant: muted\n - type: Link\n props:\n label: Display\n href: /settings/display\n variant: muted\n - type: Box\n props:\n className: max-w-2xl flex-1\n gap: lg\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 2\n text: Appearance\n - type: Paragraph\n props:\n text: Customize the appearance of the app. Automatically switch between day and\n night themes.\n muted: true\n size: sm\n - type: Divider\n - type: Form\n props:\n label: Appearance settings\n pending:\n _or:\n - _state: saving\n - _state: loading\n idempotent: true\n children:\n - type: Field\n props:\n name: font\n label: Font\n kind: select\n options:\n - value: Inter\n label: Inter\n - value: System\n label: System\n - value: Manrope\n label: Manrope\n value:\n _bindState: form.font\n - type: Field\n props:\n name: theme\n label: Theme\n kind: radio\n options:\n - value: light\n label: Light\n - value: dark\n label: Dark\n - value: system\n label: System\n value:\n _bindState: form.theme\n - type: Field\n props:\n name: direction\n label: Direction\n kind: select\n options:\n - value: ltr\n label: Ltr\n - value: rtl\n label: Rtl\n value:\n _bindState: form.direction\n - type: Paragraph\n props:\n text:\n _state: uiError.message\n muted: true\n visible:\n _state: uiError\n - type: Form.Submit\n props:\n label: Update appearance\n disabled:\n _state: saving\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n onSubmit:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: save-preferences\n connectionId: preferences-db\n payload:\n _if:\n - _eq:\n - _if:\n - _state: preferences.0.id\n - UpdateOne\n - InsertOne\n - InsertOne\n - operation: InsertOne\n data:\n section: appearance\n values:\n _event: values\n - operation: UpdateOne\n data:\n section: appearance\n values:\n _event: values\n filter:\n id:\n _state: preferences.0.id\n version:\n _state: preferences.0.version\n loadingPath: saving\n errorPath: uiError\n onSuccess:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: appearance\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - action: SetState\n params:\n path: saved\n value:\n _not:\n _state: uiError\n - action: SetState\n params:\n path: theme\n value:\n _state: form.theme\n - action: SetState\n params:\n path: direction\n value:\n _state: form.direction\n - action: SetState\n params:\n path: font\n value:\n _state: form.font\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - type: Paragraph\n props:\n text: Settings saved.\n muted: true\n visible:\n _state: saved\n events:\n onThemeChange:\n - action: SetState\n params:\n path: theme\n value:\n _event: value\n props:\n headerLinks:\n - label: Settings · Appearance\n href: /settings/appearance\n appearance: admin\n routes:\n - label: Settings · Appearance\n href: /settings/appearance\n theme:\n _state: theme\n direction:\n _state: direction\n font:\n _state: font\n lifecycle:\n onMount:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: appearance\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - id: settings-notifications\n path: /settings/notifications\n title: Settings · Notifications\n state:\n direction: ltr\n font: Inter\n loading: false\n theme: light\n currentPath: /settings/notifications\n saving: false\n uiError: null\n saved: false\n form:\n notify: all\n communication: false\n marketing: false\n social: true\n security: true\n preferences: []\n blocks:\n - type: PageLayout\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 1\n text: Settings\n - type: Paragraph\n props:\n text: Manage your account settings and set e-mail preferences.\n muted: true\n size: sm\n - type: Divider\n - type: Box\n props:\n className: \"!flex-col gap-10 lg:!flex-row\"\n children:\n - type: Box\n props:\n className: w-full shrink-0 !flex-row flex-wrap gap-1 lg:!flex-col lg:w-48\n [&>a]:shrink-0 [&>a]:px-3 [&>a]:py-2 [&>a]:rounded-md\n lg:[&>a]:px-0 lg:[&>a]:py-0\n children:\n - type: Link\n props:\n label: Profile\n href: /settings/profile\n variant: muted\n - type: Link\n props:\n label: Account\n href: /settings/account\n variant: muted\n - type: Link\n props:\n label: Appearance\n href: /settings/appearance\n variant: muted\n - type: Link\n props:\n label: Notifications\n href: /settings/notifications\n variant: default\n className: bg-muted font-medium lg:bg-transparent\n - type: Link\n props:\n label: Display\n href: /settings/display\n variant: muted\n - type: Box\n props:\n className: max-w-2xl flex-1\n gap: lg\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 2\n text: Notifications\n - type: Paragraph\n props:\n text: Configure how you receive notifications.\n muted: true\n size: sm\n - type: Divider\n - type: Form\n props:\n label: Notifications settings\n pending:\n _or:\n - _state: saving\n - _state: loading\n idempotent: true\n children:\n - type: Field\n props:\n name: notify\n label: Notify me about...\n kind: radio\n options:\n - label: All new messages\n value: all\n - label: Direct messages and mentions\n value: mentions\n - label: Nothing\n value: none\n value:\n _bindState: form.notify\n - type: Field\n props:\n name: communication\n kind: switch\n label: Communication emails\n description: Receive emails about your account activity.\n value:\n _bindState: form.communication\n - type: Field\n props:\n name: marketing\n kind: switch\n label: Marketing emails\n description: Receive emails about new products and features.\n value:\n _bindState: form.marketing\n - type: Field\n props:\n name: social\n kind: switch\n label: Social emails\n description: Receive emails for friend requests and follows.\n value:\n _bindState: form.social\n - type: Field\n props:\n name: security\n kind: switch\n label: Security emails\n description: Receive emails about your account security.\n value:\n _bindState: form.security\n - type: Paragraph\n props:\n text:\n _state: uiError.message\n muted: true\n visible:\n _state: uiError\n - type: Form.Submit\n props:\n label: Update notifications\n disabled:\n _state: saving\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n onSubmit:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: save-preferences\n connectionId: preferences-db\n payload:\n _if:\n - _eq:\n - _if:\n - _state: preferences.0.id\n - UpdateOne\n - InsertOne\n - InsertOne\n - operation: InsertOne\n data:\n section: notifications\n values:\n _event: values\n - operation: UpdateOne\n data:\n section: notifications\n values:\n _event: values\n filter:\n id:\n _state: preferences.0.id\n version:\n _state: preferences.0.version\n loadingPath: saving\n errorPath: uiError\n onSuccess:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: notifications\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - action: SetState\n params:\n path: saved\n value:\n _not:\n _state: uiError\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - type: Paragraph\n props:\n text: Settings saved.\n muted: true\n visible:\n _state: saved\n events:\n onThemeChange:\n - action: SetState\n params:\n path: theme\n value:\n _event: value\n props:\n headerLinks:\n - label: Settings · Notifications\n href: /settings/notifications\n appearance: admin\n routes:\n - label: Settings · Notifications\n href: /settings/notifications\n theme:\n _state: theme\n direction:\n _state: direction\n font:\n _state: font\n lifecycle:\n onMount:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: notifications\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - id: settings-display\n path: /settings/display\n title: Settings · Display\n state:\n direction: ltr\n font: Inter\n loading: false\n theme: light\n currentPath: /settings/display\n saving: false\n uiError: null\n saved: false\n form:\n recents: true\n home: true\n applications: true\n desktop: true\n downloads: true\n documents: true\n preferences: []\n blocks:\n - type: PageLayout\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 1\n text: Settings\n - type: Paragraph\n props:\n text: Manage your account settings and set e-mail preferences.\n muted: true\n size: sm\n - type: Divider\n - type: Box\n props:\n className: \"!flex-col gap-10 lg:!flex-row\"\n children:\n - type: Box\n props:\n className: w-full shrink-0 !flex-row flex-wrap gap-1 lg:!flex-col lg:w-48\n [&>a]:shrink-0 [&>a]:px-3 [&>a]:py-2 [&>a]:rounded-md\n lg:[&>a]:px-0 lg:[&>a]:py-0\n children:\n - type: Link\n props:\n label: Profile\n href: /settings/profile\n variant: muted\n - type: Link\n props:\n label: Account\n href: /settings/account\n variant: muted\n - type: Link\n props:\n label: Appearance\n href: /settings/appearance\n variant: muted\n - type: Link\n props:\n label: Notifications\n href: /settings/notifications\n variant: muted\n - type: Link\n props:\n label: Display\n href: /settings/display\n variant: default\n className: bg-muted font-medium lg:bg-transparent\n - type: Box\n props:\n className: max-w-2xl flex-1\n gap: lg\n children:\n - type: Box\n props:\n className: \"!flex-row items-start justify-between gap-4 mb-6\"\n children:\n - type: Box\n props:\n gap: xs\n children:\n - type: Heading\n props:\n level: 2\n text: Display\n - type: Paragraph\n props:\n text: Turn items on or off to control what’s displayed in the app.\n muted: true\n size: sm\n - type: Divider\n - type: Form\n props:\n label: Display settings\n pending:\n _or:\n - _state: saving\n - _state: loading\n idempotent: true\n children:\n - type: Paragraph\n props:\n text: Select the items you want to display in the sidebar.\n muted: true\n - type: Field\n props:\n name: recents\n label: Recents\n kind: checkbox\n value:\n _bindState: form.recents\n - type: Field\n props:\n name: home\n label: Home\n kind: checkbox\n value:\n _bindState: form.home\n - type: Field\n props:\n name: applications\n label: Applications\n kind: checkbox\n value:\n _bindState: form.applications\n - type: Field\n props:\n name: desktop\n label: Desktop\n kind: checkbox\n value:\n _bindState: form.desktop\n - type: Field\n props:\n name: downloads\n label: Downloads\n kind: checkbox\n value:\n _bindState: form.downloads\n - type: Field\n props:\n name: documents\n label: Documents\n kind: checkbox\n value:\n _bindState: form.documents\n - type: Paragraph\n props:\n text:\n _state: uiError.message\n muted: true\n visible:\n _state: uiError\n - type: Form.Submit\n props:\n label: Update display\n disabled:\n _state: saving\n events:\n onChange:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n onSubmit:\n - action: SetState\n params:\n path: saved\n value: false\n - action: SetState\n params:\n path: uiError\n value: null\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: save-preferences\n connectionId: preferences-db\n payload:\n _if:\n - _eq:\n - _if:\n - _state: preferences.0.id\n - UpdateOne\n - InsertOne\n - InsertOne\n - operation: InsertOne\n data:\n section: display\n values:\n _event: values\n - operation: UpdateOne\n data:\n section: display\n values:\n _event: values\n filter:\n id:\n _state: preferences.0.id\n version:\n _state: preferences.0.version\n loadingPath: saving\n errorPath: uiError\n onSuccess:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: display\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - action: SetState\n params:\n path: saved\n value:\n _not:\n _state: uiError\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\n - type: Paragraph\n props:\n text: Settings saved.\n muted: true\n visible:\n _state: saved\n events:\n onThemeChange:\n - action: SetState\n params:\n path: theme\n value:\n _event: value\n props:\n headerLinks:\n - label: Settings · Display\n href: /settings/display\n appearance: admin\n routes:\n - label: Settings · Display\n href: /settings/display\n theme:\n _state: theme\n direction:\n _state: direction\n font:\n _state: font\n lifecycle:\n onMount:\n - action: Request\n params:\n connectionId: preferences-db\n request:\n id: load-preferences\n connectionId: preferences-db\n payload:\n operation: Find\n filter:\n section: display\n responsePath: preferences\n loadingPath: loading\n errorPath: uiError\n onSuccess:\n - action: SetState\n params:\n path: form\n value:\n _if:\n - _state: preferences.0.id\n - _state: preferences.0.values\n - _state: form\n onError:\n - action: SetState\n params:\n path: requestFailed\n value: true\nconnections:\n - id: preferences-db\n type: Collection\n entity: preferences\n mock:\n seed: []\ndata:\n entities:\n tasks:\n key: id\n version: version\n fields:\n version:\n type: number\n readOnly: true\n id:\n type: string\n readOnly: true\n title:\n type: string\n label:\n type: string\n status:\n type: string\n priority:\n type: string\n users:\n key: id\n version: version\n fields:\n version:\n type: number\n readOnly: true\n id:\n type: string\n readOnly: true\n username:\n type: string\n firstName:\n type: string\n lastName:\n type: string\n email:\n type: string\n phoneNumber:\n type: string\n status:\n type: string\n role:\n type: string\n preferences:\n key: id\n version: version\n fields:\n version:\n type: number\n readOnly: true\n id:\n type: string\n readOnly: true\n section:\n type: string\n values:\n type: json\n integrations:\n key: id\n version: version\n fields:\n version:\n type: number\n readOnly: true\n id:\n type: string\n readOnly: true\n provider:\n type: string\n enabled:\n type: boolean\n config:\n type: json\n conversations:\n key: id\n fields:\n id:\n type: string\n readOnly: true\n name:\n type: string\n initials:\n type: string\n preview:\n type: string\n createdAt:\n type: datetime\n readOnly: true\n messages:\n key: id\n fields:\n id:\n type: string\n readOnly: true\n conversationId:\n type: string\n text:\n type: string\n time:\n type: string\n own:\n type: boolean\n createdAt:\n type: datetime\n senderId:\n type: string\n readOnly: true\n",
|
|
18
18
|
"type": "registry:lib"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
"type": "registry:ui",
|
|
5
5
|
"description": "Workspace navigation with configured groups, brand and account",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"react@19.3.0"
|
|
7
|
+
"react@19.3.0",
|
|
8
|
+
"radix-ui@1.4.3"
|
|
8
9
|
],
|
|
9
10
|
"registryDependencies": [
|
|
10
11
|
"@uibot/uibot-base"
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
{
|
|
14
15
|
"path": "components/uibot/admin-shell.tsx",
|
|
15
16
|
"target": "components/uibot/admin-shell.tsx",
|
|
16
|
-
"content": "import {\n useCallback,\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport type { RendererComponent } from \"@/lib/uibot-renderer\";\nimport { Icon } from \"./icons\";\nimport { emit, records, text, type BlockContext } from \"./interaction\";\nimport { PREVIEW_SCOPE_CSS, SCROLLBAR_CSS } from \"./preview-scope\";\nimport { STANDARD_CONTAINER_CSS } from \"./layout-container\";\n\nconst layoutStyle = `\n.uibot-admin{position:relative}.nui-sidebar-space{width:256px;flex:none;min-height:0;position:relative}.nui-sidebar-space>.nui-sidebar{width:100%;height:100%}.nui-rail .nui-sidebar-space{width:64px}.nui-content-inner{min-height:100%}.nui-content-inner>*+*{margin-top:20px}\n.uibot-admin[data-container=boxed]>.nui-main{max-width:1120px;margin:0;flex-basis:0}.uibot-admin[data-container=boxed]{padding:16px;gap:16px;justify-content:center;background:var(--nui-sidebar,var(--muted,#eee))}\n.uibot-admin[data-navigation-style=attached]:not([data-container=boxed])>.nui-main{margin:0;border-radius:0;border-block:0;border-inline-end:0;box-shadow:none}\n.uibot-admin[data-navigation-style=floating]>.nui-sidebar-space{padding:8px}.uibot-admin[data-navigation-style=floating]>.nui-sidebar-space>.nui-sidebar{border:1px solid var(--nui-border,#e5e5e5);border-radius:12px;background:var(--nui-surface,#fff);height:100%}\n.uibot-admin[data-sidebar=hover]>.nui-sidebar-space{width:64px;z-index:30}.uibot-admin[data-sidebar=hover]>.nui-sidebar-space>.nui-sidebar{position:absolute;inset-inline-start:0;background:var(--nui-sidebar,#fafafa);width:64px}.uibot-admin[data-sidebar=hover]:not(.nui-rail)>.nui-sidebar-space>.nui-sidebar{width:256px;box-shadow:8px 0 25px #0002}\n.uibot-admin[data-offcanvas=floating]>.nui-mobile{margin:8px;height:calc(100dvh - 16px);max-height:calc(100dvh - 16px);border:1px solid var(--nui-border,#ddd);border-radius:12px}\n@media(min-width:768px){\n.uibot-admin[data-navigation=navbar]{flex-direction:column}.uibot-admin[data-navigation=navbar]>.nui-sidebar-space{width:100%;z-index:31}.uibot-admin[data-navigation=navbar]>.nui-sidebar-space>.nui-sidebar{position:relative;display:flex;flex-direction:row;align-items:center;gap:24px;height:auto;width:100%;overflow:visible;padding:8px 16px;border-bottom:1px solid var(--nui-border,#ddd)}\n.uibot-admin[data-navigation=navbar] .nui-sidebar>.nui-brand-picker{flex:none}.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-brand{margin:0}.uibot-admin[data-navigation=navbar] .nui-sidebar>nav{display:flex;flex-wrap:wrap;gap:8px 20px}.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-nav-group{display:flex;align-items:center;gap:4px;margin:0}.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-nav-label,.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-nav-footer,.uibot-admin[data-navigation=navbar] .nui-header-links{display:none}\n.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-nav-section,.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-brand-picker{position:relative}.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-nav-section>div,.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-brand-picker>nav{position:absolute;inset-block-start:100%;inset-inline-start:0;min-width:190px;max-height:60dvh;overflow:auto;margin:0;padding:8px;border:1px solid var(--nui-border,#ddd);border-radius:8px;background:var(--nui-surface,#fff);box-shadow:0 8px 20px #0002}\n.uibot-admin[data-navigation=navbar]>.nui-main{width:100%;flex-basis:0;margin-inline:0}.uibot-admin[data-navigation=navbar][data-navigation-style=floating]>.nui-sidebar-space{padding:8px}.uibot-admin[data-navigation=navbar][data-navigation-style=floating]>.nui-main{width:calc(100% - 16px);margin-inline:8px}\n.uibot-admin[data-navigation=navbar][data-container=boxed]{justify-content:flex-start}.uibot-admin[data-navigation=navbar][data-container=boxed]>.nui-sidebar-space{width:100%;max-width:1120px;padding:0;align-self:center}.uibot-admin[data-navigation=navbar][data-container=boxed]>.nui-main{width:100%;margin-inline:auto}\n}\n@media(min-width:768px){.uibot-admin[data-navigation=navbar] .nui-sidebar .uibot-sider-menu{flex-direction:row;height:auto;align-items:center;gap:16px}.uibot-admin[data-navigation=navbar] .uibot-sider-menu>ul,.uibot-admin[data-navigation=navbar] .uibot-menu-group>ul{display:flex;flex-wrap:wrap;gap:4px;overflow:visible}.uibot-admin[data-navigation=navbar] .uibot-menu-group-title{display:none}.uibot-admin[data-navigation=navbar] .uibot-sider-title{border:0;padding:8px}}\n.nui-rail .uibot-menu-label,.nui-rail .uibot-menu-badge,.nui-rail .uibot-sider-full-title,.nui-rail .uibot-menu-group-title{display:none}.nui-rail .uibot-menu-fallback,.nui-rail .uibot-sider-abbreviation{display:block}.nui-rail .uibot-menu-link{justify-content:center;padding-inline:0;gap:0}\n@media(max-width:767px){.nui-sidebar-space{display:none}.uibot-admin[data-container=boxed]{padding:8px;gap:0}.uibot-admin[data-container=boxed]>.nui-main{width:100%}}\n`;\nconst shellStyle = `\n.uibot-admin{font-family:var(--nui-font,var(--font-body,Inter,ui-sans-serif,system-ui,sans-serif));display:flex;height:100dvh;overflow:hidden;background:var(--nui-sidebar,#fafafa);color:var(--nui-foreground,#171717);font-size:14px;line-height:1.5}.uibot-admin.dark{background:#141414;color:#fafafa}.uibot-admin *{box-sizing:border-box}.uibot-admin button,.uibot-admin a,.uibot-admin summary{touch-action:manipulation}.uibot-admin button:focus-visible,.uibot-admin a:focus-visible,.uibot-admin summary:focus-visible{outline:2px solid #737373;outline-offset:3px}.nui-sidebar{width:256px;flex:none;padding:8px;position:sticky;top:0;height:100dvh;overflow:auto;display:flex;flex-direction:column}.nui-main{min-width:0;min-height:0;flex:1;display:flex;flex-direction:column;overflow:hidden;margin:8px;margin-inline-start:0;border:1px solid var(--nui-border,#e5e5e5);border-radius:12px;background:var(--nui-surface,#fff);box-shadow:0 1px 2px #00000005}.dark .nui-main{background:#0a0a0a;border-color:#262626}.nui-header{flex:none;height:64px;display:flex;gap:20px;align-items:center;padding:0 24px}.nui-header-links{display:flex;gap:24px;font-weight:500;font-size:14px}.nui-header-links a{color:#737373;text-decoration:none}.nui-header-links a[aria-current=page]{color:inherit}.nui-toolbar{display:flex;gap:12px;align-items:center;margin-inline-start:auto}.nui-icon-button{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:6px;background:transparent;border:0;color:inherit;cursor:pointer}.nui-icon-button:hover{background:#88888815}.nui-search{display:flex;align-items:center;gap:9px;border:1px solid #e5e5e5;background:transparent;color:#737373;border-radius:6px;padding:5px 10px;width:240px;text-align:start}.nui-search kbd{margin-inline-start:auto;background:#88888810;border-radius:4px;padding:0 4px;font-size:11px}.nui-avatar{width:32px;height:32px;border-radius:50%;background:#eaeaea;color:#353535;display:grid;place-items:center;font-size:12px;font-weight:500}.nui-content{flex:1;min-height:0;overflow:auto;padding:20px 24px 28px}.nui-content>*+*{margin-top:20px}.nui-no-sidebar .nui-main{margin-inline-start:8px}.nui-brand{display:flex;align-items:center;gap:10px;padding:8px;margin-bottom:14px;text-align:start;width:100%;border:0;background:transparent;color:inherit}.nui-brand-mark{width:32px;height:32px;border-radius:8px;background:#171717;color:white;display:grid;place-items:center}.dark .nui-brand-mark{background:#fafafa;color:#171717}.nui-brand-copy{display:flex;flex:1;flex-direction:column;font-size:14px;line-height:19px}.nui-brand-copy small{font-size:12px;color:#737373}.nui-nav-group{margin:12px 0}.nui-nav-label{font-size:12px;font-weight:500;color:#737373;padding:0 8px;margin-bottom:6px}.nui-nav-link{display:flex;align-items:center;gap:9px;padding:7px 8px;border-radius:6px;font-size:14px;color:inherit;text-decoration:none;white-space:nowrap}.nui-nav-link:hover{background:#88888810}.nui-nav-link[aria-current=page]{background:var(--nui-accent,#e9e9e9);color:var(--nui-accent-foreground,inherit);font-weight:500}.dark .nui-nav-link[aria-current=page]{background:var(--nui-accent,#272727)}.dark .nui-nav-link .nui-badge{background:#fafafa;color:#171717}.nui-nav-link .nui-badge{margin-inline-start:auto;border-radius:5px;background:#171717;color:#fff;font-size:11px;padding:0 6px}.nui-nav-section summary{cursor:pointer;list-style:none}.nui-nav-section summary>svg:last-child{margin-inline-start:auto}.nui-nav-section[open] summary>svg:last-child{transform:rotate(90deg)}.nui-rail .nui-nav-section>div{display:none}.nui-nav-footer{margin-top:auto;padding-top:24px}.nui-rail .nui-sidebar{width:64px}.nui-rail .nui-nav-label,.nui-rail .nui-nav-text,.nui-rail .nui-brand-copy,.nui-rail .nui-badge,.nui-rail .nui-brand-chevron{display:none}.nui-rail .nui-nav-link{justify-content:center;padding:10px 0}.nui-command{border:1px solid #ddd;border-radius:10px;width:500px;max-width:calc(100vw - 32px);padding:0;margin:auto;background:inherit;color:inherit;box-shadow:0 20px 80px #0003}.nui-command::backdrop,.nui-mobile::backdrop{background:#0008}.nui-command input{width:100%;padding:16px;border:0;border-bottom:1px solid #8883;background:transparent;outline:none}.nui-command nav{padding:8px;max-height:360px;overflow:auto}.nui-mobile{margin:0;padding:8px;width:280px;max-width:85vw;height:100dvh;max-height:100dvh;border:0;background:#fafafa;color:#171717}.nui-mobile .nui-nav-footer{margin-top:24px}.nui-user-menu{position:relative}.nui-user-menu summary{list-style:none;cursor:pointer}.nui-user-menu nav{position:absolute;inset-inline-end:0;top:40px;min-width:190px;border:1px solid #8883;background:var(--nui-surface,#fff);border-radius:8px;padding:8px;z-index:40;box-shadow:0 4px 12px #0002}.nui-user-menu a{display:block;padding:8px;color:inherit;text-decoration:none}.dark .nui-user-menu nav,.dark .nui-command,.dark .nui-mobile{background:var(--nui-surface,#171717);color:#fafafa}.nui-mobile-close{float:right}.nui-brand-picker summary{list-style:none;cursor:pointer}.nui-brand-picker nav{padding:4px 8px;margin-bottom:12px}.nui-brand-picker a{display:block;padding:4px;color:inherit}\n@media(max-width:1024px){.nui-header-links{display:none}.nui-search{width:200px}}@media(max-width:767px){.nui-sidebar{display:none}.nui-main{margin:0;border:0;border-radius:0}.nui-header{padding:0 16px;gap:8px;height:60px}.nui-content{padding:16px}.nui-search{width:150px;font-size:12px}.nui-search kbd{display:none}.nui-toolbar{gap:5px}.uibot-admin table{min-width:680px}.uibot-admin h1{font-size:24px}}\n${PREVIEW_SCOPE_CSS}${SCROLLBAR_CSS}${layoutStyle}${STANDARD_CONTAINER_CSS}`;\nexport const AppNavigation: RendererComponent = (props, ctx) => (\n <>\n <style>{shellStyle}</style>\n <Navigation props={props} ctx={ctx} />\n </>\n);\nfunction Navigation({ props, ctx }: { props: Record<string, unknown>; ctx: BlockContext }) {\n return (\n <>\n <details className=\"nui-brand-picker\">\n <summary aria-label={text(props.brand, \"Shadcn Admin\")}>\n <div className=\"nui-brand\">\n {typeof props.logoSrc === \"string\" && props.logoSrc ? (\n <img\n src={props.logoSrc}\n alt={text(props.brand, \"Brand\")}\n width={32}\n height={32}\n style={{ objectFit: \"contain\", flexShrink: 0 }}\n />\n ) : (\n <span className=\"nui-brand-mark\">\n <Icon name=\"command\" />\n </span>\n )}\n <span className=\"nui-brand-copy\">\n <strong>{text(props.brand, \"Shadcn Admin\")}</strong>\n <small>{text(props.subtitle, \"Vite + ShadcnUI\")}</small>\n </span>\n <span className=\"nui-brand-chevron\">\n <Icon name=\"chevrons-up-down\" size={16} />\n </span>\n </div>\n </summary>\n <nav aria-label=\"Workspaces\">\n {records(props.workspaces).map((w) => (\n <a\n key={text(w.href)}\n href={text(w.href)}\n onClick={() => emit(ctx, \"onNavigate\", { href: text(w.href) })}\n >\n {text(w.label)}\n </a>\n ))}\n </nav>\n </details>\n <nav aria-label=\"Main navigation\">\n {records(props.groups).map((group) => (\n <div className=\"nui-nav-group\" key={text(group.label)}>\n <div className=\"nui-nav-label\">{text(group.label)}</div>\n {records(group.items).map((item) =>\n records(item.children).length ? (\n <details\n key={text(item.label)}\n className=\"nui-nav-section\"\n open={\n records(item.children).some((child) => child.href === props.activePath) ||\n undefined\n }\n >\n <summary\n className=\"nui-nav-link\"\n aria-label={text(item.label)}\n title={text(item.label)}\n >\n <Icon name={text(item.icon, \"boxes\")} />\n <span className=\"nui-nav-text\">{text(item.label)}</span>\n <Icon name=\"chevron-right\" size={16} />\n </summary>\n <div className=\"ms-4 border-s ps-3\">\n {records(item.children).map((child) => (\n <a\n className=\"nui-nav-link\"\n key={text(child.href)}\n href={text(child.href)}\n aria-current={child.href === props.activePath ? \"page\" : undefined}\n onClick={() => emit(ctx, \"onNavigate\", { href: text(child.href) })}\n >\n {text(child.label)}\n </a>\n ))}\n </div>\n </details>\n ) : (\n <a\n key={text(item.href)}\n className=\"nui-nav-link\"\n title={text(item.label)}\n href={text(item.href)}\n aria-current={\n item.active === true || item.href === props.activePath ? \"page\" : undefined\n }\n onClick={() => emit(ctx, \"onNavigate\", { href: text(item.href) })}\n >\n <Icon name={text(item.icon, \"boxes\")} />\n <span className=\"nui-nav-text\">{text(item.label)}</span>\n {Boolean(item.badge) && <span className=\"nui-badge\">{text(item.badge)}</span>}\n </a>\n ),\n )}\n </div>\n ))}\n </nav>\n <div className=\"nui-nav-footer\">\n <a className=\"nui-nav-link\" href={text(props.profileHref, \"/settings/profile\")}>\n <span className=\"nui-avatar\">{text(props.initials, \"SN\")}</span>\n <span className=\"nui-brand-copy\">\n <strong>{text(props.userName, \"shadcn\")}</strong>\n <small>{text(props.email, \"m@example.com\")}</small>\n </span>\n <Icon name=\"chevrons-up-down\" size={16} />\n </a>\n </div>\n </>\n );\n}\nexport function AdminFrame({ props, ctx }: { props: Record<string, unknown>; ctx: BlockContext }) {\n const layout =\n props.layout && typeof props.layout === \"object\"\n ? (props.layout as Record<string, unknown>)\n : {};\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const [rail, setRail] = useState(layout.sidebar === \"folded\"),\n [localDark, setDark] = useState(props.theme === \"dark\"),\n [query, setQuery] = useState(\"\");\n useEffect(() => {\n setRail(layout.sidebar === \"folded\");\n setHovered(false);\n setFocused(false);\n }, [layout.sidebar]);\n const [systemDark, setSystemDark] = useState(false);\n const [smallScreen, setSmallScreen] = useState(false);\n const [mobileOpen, setMobileOpen] = useState(false);\n const collapsed =\n layout.navigation !== \"navbar\" &&\n !smallScreen &&\n (layout.sidebar === \"hover\" ? !(hovered || focused) : rail);\n useEffect(() => {\n const media = window.matchMedia(\"(max-width:767px)\");\n const sync = () => setSmallScreen(media.matches);\n sync();\n media.addEventListener(\"change\", sync);\n return () => media.removeEventListener(\"change\", sync);\n }, []);\n useEffect(() => {\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const sync = () => setSystemDark(media.matches);\n sync();\n media.addEventListener(\"change\", sync);\n return () => media.removeEventListener(\"change\", sync);\n }, []);\n const dark =\n props.theme === \"system\"\n ? systemDark\n : typeof props.theme === \"string\"\n ? props.theme === \"dark\"\n : localDark;\n const root = useRef<HTMLDivElement>(null);\n // A page without sidebar content gets no empty navigation rail, toggle or drawer.\n const hasSidebarSlot: unknown = ctx.slots.sidebar;\n const hasSidebar = Array.isArray(hasSidebarSlot)\n ? hasSidebarSlot.length > 0\n : Boolean(hasSidebarSlot);\n const mobile = useRef<HTMLDialogElement>(null),\n command = useRef<HTMLDialogElement>(null),\n trigger = useRef<HTMLElement | null>(null);\n const close = (dialog: HTMLDialogElement | null) => {\n dialog?.close();\n trigger.current?.focus();\n };\n const show = useCallback((dialog: HTMLDialogElement | null) => {\n trigger.current = document.activeElement as HTMLElement;\n dialog?.showModal();\n }, []);\n useEffect(() => {\n const key = (e: KeyboardEvent) => {\n if (root.current?.closest(\"[inert]\")) return;\n if (\n document.activeElement !== document.body &&\n !root.current?.contains(document.activeElement)\n )\n return;\n if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === \"k\") {\n e.preventDefault();\n show(command.current);\n }\n };\n document.addEventListener(\"keydown\", key);\n return () => document.removeEventListener(\"keydown\", key);\n }, [show]);\n useEffect(() => {\n const menus = () =>\n Array.from(\n root.current?.querySelectorAll<HTMLDetailsElement>(\n `.nui-user-menu[open],.nui-brand-picker[open]${layout.navigation === \"navbar\" ? \",.nui-nav-section[open]\" : \"\"}`,\n ) ?? [],\n );\n const dismissOutside = (event: PointerEvent) => {\n for (const menu of menus()) if (!menu.contains(event.target as Node)) menu.open = false;\n };\n const dismissEscape = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || root.current?.querySelector(\"dialog[open]\")) return;\n for (const menu of menus()) {\n if (!menu.contains(document.activeElement)) continue;\n event.preventDefault();\n menu.open = false;\n menu.querySelector<HTMLElement>(\"summary\")?.focus();\n }\n };\n document.addEventListener(\"pointerdown\", dismissOutside);\n document.addEventListener(\"keydown\", dismissEscape);\n return () => {\n document.removeEventListener(\"pointerdown\", dismissOutside);\n document.removeEventListener(\"keydown\", dismissEscape);\n };\n }, [layout.navigation]);\n useEffect(() => {\n if (!smallScreen) mobile.current?.close();\n }, [smallScreen]);\n const activePath = props.activePath ?? ctx.resolve?.getState?.(\"currentPath\");\n const routes = records(props.routes).filter((r) =>\n text(r.label).toLowerCase().includes(query.toLowerCase()),\n );\n return (\n <div\n ref={root}\n style={\n {\n fontFamily:\n props.font === \"System\"\n ? \"system-ui,sans-serif\"\n : props.font === \"Manrope\"\n ? \"Manrope,system-ui,sans-serif\"\n : undefined,\n ...pageLayoutTokenStyle(props.tokens, true),\n } as CSSProperties\n }\n data-uibot-type=\"PageLayout\"\n data-appearance=\"admin\"\n data-navigation={layout.navigation as string | undefined}\n data-container={layout.container as string | undefined}\n data-navigation-style={layout.navigationStyle as string | undefined}\n data-offcanvas={layout.offcanvas as string | undefined}\n data-sidebar={\n layout.navigation === \"navbar\" ? undefined : (layout.sidebar as string | undefined)\n }\n dir={props.direction === \"rtl\" ? \"rtl\" : \"ltr\"}\n className={`uibot-admin ${collapsed ? \"nui-rail\" : \"\"} ${dark ? \"dark\" : \"\"} ${hasSidebar ? \"\" : \"nui-no-sidebar\"}`}\n onClickCapture={(event) => {\n if (rail && (event.target as HTMLElement).closest(\".nui-sidebar summary\")) setRail(false);\n }}\n >\n <style>{shellStyle}</style>\n {hasSidebar && (\n <div\n className=\"nui-sidebar-space\"\n onPointerEnter={() => setHovered(true)}\n onPointerLeave={() => setHovered(false)}\n onFocusCapture={() => setFocused(true)}\n onBlurCapture={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node)) setFocused(false);\n }}\n >\n <aside className=\"nui-sidebar\">{ctx.slots.sidebar as ReactNode[]}</aside>\n </div>\n )}\n <div className=\"nui-main\">\n <header className=\"nui-header\">\n {hasSidebar && (smallScreen || layout.navigation !== \"navbar\") && (\n <button\n type=\"button\"\n className=\"nui-icon-button\"\n aria-label=\"Toggle sidebar\"\n aria-expanded={smallScreen ? mobileOpen : !collapsed}\n onClick={() => {\n if (smallScreen) {\n setMobileOpen(true);\n show(mobile.current);\n } else if (layout.sidebar === \"hover\") setHovered(!hovered);\n else setRail(!rail);\n }}\n >\n <Icon name=\"panel-left\" />\n </button>\n )}\n {props.appearance !== \"admin\" && typeof props.title === \"string\" && (\n <strong>{props.title}</strong>\n )}\n <nav className=\"nui-header-links\" aria-label=\"Workspace\">\n {records(props.headerLinks).map((link) => (\n <a\n href={text(link.href)}\n key={text(link.label)}\n aria-current={\n link.href === activePath ||\n (link.href === \"/settings/profile\" &&\n typeof activePath === \"string\" &&\n activePath.startsWith(\"/settings/\"))\n ? \"page\"\n : undefined\n }\n >\n {text(link.label)}\n </a>\n ))}\n </nav>\n <div className=\"nui-toolbar\">\n <button type=\"button\" className=\"nui-search\" onClick={() => show(command.current)}>\n <Icon name=\"search\" size={16} />\n Search<kbd>⌘ K</kbd>\n </button>\n <button\n type=\"button\"\n className=\"nui-icon-button\"\n aria-label={dark ? \"Use light theme\" : \"Use dark theme\"}\n onClick={() => {\n setDark(!dark);\n emit(\n ctx,\n \"onThemeChange\",\n { theme: dark ? \"light\" : \"dark\" },\n dark ? \"light\" : \"dark\",\n );\n }}\n >\n <Icon name={dark ? \"moon\" : \"sun\"} />\n </button>\n <details className=\"nui-user-menu\">\n <summary aria-label=\"Open account menu\">\n <span className=\"nui-avatar\">{text(props.initials, \"SN\")}</span>\n </summary>\n <nav aria-label=\"Account\">\n {records(\n props.accountLinks ?? [\n { href: \"/settings/profile\", label: \"Profile\" },\n { href: \"/settings/account\", label: \"Account\" },\n { href: \"/settings/notifications\", label: \"Notifications\" },\n { href: \"/sign-in\", label: \"Sign in\" },\n ],\n ).map((link) => (\n <a key={text(link.href)} href={text(link.href)}>\n {text(link.label)}\n </a>\n ))}\n </nav>\n </details>\n {ctx.slots.headerActions as ReactNode[]}\n </div>\n </header>\n <main className=\"nui-content\">\n <div className=\"nui-content-inner\">{ctx.children as ReactNode[]}</div>\n </main>\n {ctx.slots.footer as ReactNode[]}\n </div>\n {hasSidebar && (\n <dialog\n ref={mobile}\n className=\"nui-mobile\"\n aria-label=\"Navigation\"\n onClose={() => {\n setMobileOpen(false);\n trigger.current?.focus();\n }}\n >\n <button\n type=\"button\"\n className=\"nui-icon-button nui-mobile-close\"\n aria-label=\"Close navigation\"\n onClick={() => close(mobile.current)}\n >\n <Icon name=\"x\" />\n </button>\n <div\n onClick={(e) => {\n if ((e.target as HTMLElement).closest(\"a\")) close(mobile.current);\n }}\n >\n {ctx.slots.sidebar as ReactNode[]}\n </div>\n </dialog>\n )}\n <dialog\n ref={command}\n className=\"nui-command\"\n aria-label=\"Search pages\"\n onClose={() => {\n setQuery(\"\");\n trigger.current?.focus();\n }}\n onKeyDown={(event) => {\n if (\n ![\"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"].includes(event.key) ||\n event.target instanceof HTMLInputElement\n )\n return;\n const links = Array.from(\n command.current?.querySelectorAll<HTMLAnchorElement>(\"nav a\") ?? [],\n );\n if (!links.length) return;\n event.preventDefault();\n const index = links.indexOf(document.activeElement as HTMLAnchorElement);\n const next =\n event.key === \"Home\"\n ? 0\n : event.key === \"End\"\n ? links.length - 1\n : (index + (event.key === \"ArrowDown\" ? 1 : -1) + links.length) % links.length;\n links[next]?.focus();\n }}\n >\n <input\n aria-label=\"Search pages\"\n autoComplete=\"off\"\n placeholder=\"Type a command or search...\"\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n const links = command.current?.querySelectorAll<HTMLAnchorElement>(\"nav a\");\n if (!links?.length) return;\n e.preventDefault();\n links[e.key === \"ArrowDown\" ? 0 : links.length - 1]?.focus();\n }\n }}\n />\n <nav>\n {routes.map((route) => (\n <a\n className=\"nui-nav-link\"\n href={text(route.href)}\n key={text(route.href)}\n onClick={() => close(command.current)}\n >\n <Icon name={text(route.icon, \"chevron-right\")} />\n {text(route.label)}\n </a>\n ))}\n {!routes.length && <p className=\"p-4 text-sm\">No results found.</p>}\n </nav>\n </dialog>\n </div>\n );\n}\nimport { pageLayoutTokenStyle } from \"./layout-tokens\";\n",
|
|
17
|
+
"content": "import {\n useCallback,\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport type { RendererComponent } from \"@/lib/uibot-renderer\";\nimport { Icon } from \"./icons\";\nimport { emit, records, text, type BlockContext } from \"./interaction\";\nimport { containPreviewNavigationDialog, PREVIEW_SCOPE_CSS } from \"./preview-scope\";\nimport { usePreviewWidth } from \"./preview-responsive\";\nimport { ScrollArea } from \"./scroll-area\";\nimport { Direction } from \"radix-ui\";\nimport { STANDARD_CONTAINER_CSS } from \"./layout-container\";\n\n/** Static exports retain viewport CSS until a mounted frame provides its local breakpoint. */\nfunction adminResponsiveCss(query: string, match: string, rules: string): string {\n const scoped = (selector: string) => rules.replaceAll(\".uibot-admin\", selector);\n return (\n scoped(`.uibot-admin${match}`) +\n `@media${query}{${scoped(\".uibot-admin:not([data-responsive])\")}}`\n );\n}\n\nconst layoutStyle = `\n${adminResponsiveCss(\"(max-width:480px)\", \"[data-compact-search=true]\", `.uibot-admin .nui-search{width:32px;height:32px;padding:0;justify-content:center}.uibot-admin .nui-search span,.uibot-admin .nui-search kbd{display:none}`)}\n.uibot-admin{position:relative}.nui-sidebar-space{width:256px;flex:none;min-height:0;position:relative}.nui-sidebar-space>.nui-sidebar{width:100%;height:100%}.nui-rail .nui-sidebar-space{width:64px}.nui-content-inner{min-height:100%}.nui-content-inner>*+*:not(dialog){margin-top:20px}\n.uibot-admin[data-container=boxed]>.nui-main{max-width:1120px;margin:0;flex-basis:0}.uibot-admin[data-container=boxed]{padding:16px;gap:16px;justify-content:center;background:var(--nui-sidebar,var(--muted,#eee))}\n.uibot-admin[data-navigation-style=attached]:not([data-container=boxed]):not([data-shell=sidebar-inset])>.nui-main{margin:0;border-radius:0;border-block:0;border-inline-end:0;box-shadow:none}\n.uibot-admin[data-shell=sidebar-inset]>.nui-main{margin:8px;margin-inline-start:0;border:1px solid var(--nui-border,var(--border,#e5e5e5));border-radius:12px;background:var(--nui-surface,var(--background,#fff));box-shadow:0 1px 3px #0000000d}\n.uibot-admin[data-navigation-style=floating]>.nui-sidebar-space{padding:8px}.uibot-admin[data-navigation-style=floating]>.nui-sidebar-space>.nui-sidebar{border:1px solid var(--nui-border,var(--border,#e5e5e5));border-radius:12px;background:var(--nui-surface,var(--background,#fff));height:100%}\n.uibot-admin[data-sidebar=hover]>.nui-sidebar-space{width:64px;z-index:30}.uibot-admin[data-sidebar=hover]>.nui-sidebar-space>.nui-sidebar{position:absolute;inset-inline-start:0;background:var(--nui-sidebar,#fafafa);width:64px}.uibot-admin[data-sidebar=hover]:not(.nui-rail)>.nui-sidebar-space>.nui-sidebar{width:256px;box-shadow:8px 0 25px #0002}\n.uibot-admin[data-offcanvas=floating]>.nui-mobile{margin:8px;height:calc(100dvh - 16px);max-height:calc(100dvh - 16px);border:1px solid var(--nui-border,#ddd);border-radius:12px}\n${adminResponsiveCss(\"(min-width:768px)\", \":is([data-responsive=desktop],[data-responsive=tablet])\", `.uibot-admin[data-navigation=navbar]{flex-direction:column}.uibot-admin[data-navigation=navbar]>.nui-sidebar-space{width:100%;z-index:31}.uibot-admin[data-navigation=navbar]>.nui-sidebar-space>.nui-sidebar{position:relative;display:flex;flex-direction:row;align-items:center;gap:24px;height:auto;width:100%;overflow:visible;padding:8px 16px;border-bottom:1px solid var(--nui-border,#ddd)}.uibot-admin[data-navigation=navbar] .nui-sidebar>.nui-brand-picker{flex:none}.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-brand{margin:0}.uibot-admin[data-navigation=navbar] .nui-sidebar>nav{display:flex;flex-wrap:wrap;gap:8px 20px}.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-nav-group{display:flex;align-items:center;gap:4px;margin:0}.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-nav-label,.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-nav-footer,.uibot-admin[data-navigation=navbar] .nui-header-links{display:none}.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-nav-section,.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-brand-picker{position:relative}.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-nav-section>div,.uibot-admin[data-navigation=navbar] .nui-sidebar .nui-brand-picker>nav{position:absolute;inset-block-start:100%;inset-inline-start:0;min-width:190px;max-height:60dvh;overflow:hidden;margin:0;padding:8px;border:1px solid var(--nui-border,#ddd);border-radius:8px;background:var(--nui-surface,#fff);box-shadow:0 8px 20px #0002}.uibot-admin[data-navigation=navbar]>.nui-main{width:100%;flex-basis:0;margin-inline:0}.uibot-admin[data-navigation=navbar][data-navigation-style=floating]>.nui-sidebar-space{padding:8px}.uibot-admin[data-navigation=navbar][data-navigation-style=floating]>.nui-main{width:calc(100% - 16px);margin-inline:8px}.uibot-admin[data-navigation=navbar][data-container=boxed]{justify-content:flex-start}.uibot-admin[data-navigation=navbar][data-container=boxed]>.nui-sidebar-space{width:100%;max-width:1120px;padding:0;align-self:center}.uibot-admin[data-navigation=navbar][data-container=boxed]>.nui-main{width:100%;margin-inline:auto}`)}\n${adminResponsiveCss(\"(min-width:768px)\", \":is([data-responsive=desktop],[data-responsive=tablet])\", `.uibot-admin[data-navigation=navbar] .uibot-menu-scroll{overflow:visible}.uibot-admin[data-navigation=navbar] .uibot-menu-scroll>.uibot-scroll-viewport{overflow:visible!important}.uibot-admin[data-navigation=navbar] .nui-sidebar .uibot-sider-menu{flex-direction:row;height:auto;align-items:center;gap:16px}.uibot-admin[data-navigation=navbar] .uibot-sider-menu ul,.uibot-admin[data-navigation=navbar] .uibot-menu-group>ul{display:flex;flex-wrap:wrap;gap:4px;overflow:visible}.uibot-admin[data-navigation=navbar] .uibot-menu-group-title{display:none}.uibot-admin[data-navigation=navbar] .uibot-sider-title{border:0;padding:8px}`)}\n.nui-rail .uibot-menu-label,.nui-rail .uibot-menu-badge,.nui-rail .uibot-sider-full-title,.nui-rail .uibot-menu-group-title{display:none}.nui-rail .uibot-menu-fallback,.nui-rail .uibot-sider-abbreviation{display:block}.nui-sidebar:has(.uibot-sider-menu){padding:0;overflow:hidden}.nui-rail .uibot-sider-footer{padding-inline:8px}.nui-rail .uibot-sider-title{padding-inline:0;text-align:center}.nui-rail .uibot-menu-link{width:calc(100% - 12px);min-height:36px;margin-inline:6px;justify-content:center;padding-inline:0;gap:0}\n${adminResponsiveCss(\"(max-width:767px)\", \"[data-responsive=mobile]\", `.uibot-admin .nui-sidebar-space{display:none}.uibot-admin[data-container=boxed]{padding:8px;gap:0}.uibot-admin[data-container=boxed]>.nui-main{width:100%}`)}\n`;\nconst shellStyle = `\n.uibot-admin{font-family:var(--nui-font,var(--font-body,Inter,ui-sans-serif,system-ui,sans-serif));display:flex;height:100dvh;overflow:hidden;background:var(--nui-sidebar,#fafafa);color:var(--nui-foreground,#171717);font-size:14px;line-height:1.5}.uibot-admin.dark{background:#141414;color:#fafafa}.uibot-admin *{box-sizing:border-box}.uibot-admin button,.uibot-admin a,.uibot-admin summary{touch-action:manipulation}.uibot-admin button:focus-visible,.uibot-admin a:focus-visible,.uibot-admin summary:focus-visible{outline:2px solid #737373;outline-offset:3px}.nui-sidebar{width:256px;flex:none;padding:8px;position:sticky;top:0;height:100dvh;overflow:hidden;display:flex;flex-direction:column}.nui-main{min-width:0;min-height:0;flex:1;display:flex;flex-direction:column;overflow:hidden;margin:8px;margin-inline-start:0;border:1px solid var(--nui-border,#e5e5e5);border-radius:12px;background:var(--nui-surface,#fff);box-shadow:0 1px 2px #00000005}.dark .nui-main{background:#0a0a0a;border-color:#262626}.nui-header{flex:none;height:64px;display:flex;gap:20px;align-items:center;padding:0 24px}.nui-header-links{display:flex;gap:24px;font-weight:500;font-size:14px}.nui-header-links a{color:#737373;text-decoration:none}.nui-header-links a[aria-current=page]{color:inherit}.nui-toolbar{display:flex;gap:12px;align-items:center;margin-inline-start:auto}.nui-icon-button{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:6px;background:transparent;border:0;color:inherit;cursor:pointer}.nui-icon-button:hover{background:#88888815}.nui-search{display:flex;align-items:center;gap:9px;border:1px solid #e5e5e5;background:transparent;color:#737373;border-radius:6px;padding:5px 10px;width:240px;text-align:start}.nui-search kbd{margin-inline-start:auto;background:#88888810;border-radius:4px;padding:0 4px;font-size:11px}.nui-avatar{width:32px;height:32px;border-radius:50%;background:#eaeaea;color:#353535;display:grid;place-items:center;font-size:12px;font-weight:500}.nui-content{box-sizing:border-box;min-height:0;padding:20px 24px 28px}.nui-content>*+*{margin-top:20px}.nui-no-sidebar .nui-main{margin-inline-start:8px}.nui-brand{display:flex;align-items:center;gap:10px;padding:8px;margin-bottom:14px;text-align:start;width:100%;border:0;background:transparent;color:inherit}.nui-brand-mark{width:32px;height:32px;border-radius:8px;background:#171717;color:white;display:grid;place-items:center}.dark .nui-brand-mark{background:#fafafa;color:#171717}.nui-brand-copy{display:flex;flex:1;flex-direction:column;font-size:14px;line-height:19px}.nui-brand-copy small{font-size:12px;color:#737373}.nui-nav-group{margin:12px 0}.nui-nav-label{font-size:12px;font-weight:500;color:#737373;padding:0 8px;margin-bottom:6px}.nui-nav-link{display:flex;align-items:center;gap:9px;padding:7px 8px;border-radius:6px;font-size:14px;color:inherit;text-decoration:none;white-space:nowrap}.nui-nav-link:hover{background:#88888810}.nui-nav-link[aria-current=page]{background:var(--nui-accent,#e9e9e9);color:var(--nui-accent-foreground,inherit);font-weight:500}.dark .nui-nav-link[aria-current=page]{background:var(--nui-accent,#272727)}.dark .nui-nav-link .nui-badge{background:#fafafa;color:#171717}.nui-nav-link .nui-badge{margin-inline-start:auto;border-radius:5px;background:#171717;color:#fff;font-size:11px;padding:0 6px}.nui-nav-section summary{cursor:pointer;list-style:none}.nui-nav-section summary>svg:last-child{margin-inline-start:auto}.nui-nav-section[open] summary>svg:last-child{transform:rotate(90deg)}.nui-rail .nui-nav-section>div{display:none}.nui-nav-footer{margin-top:auto;padding-top:24px}.nui-rail .nui-sidebar{width:64px}.nui-rail .nui-nav-label,.nui-rail .nui-nav-text,.nui-rail .nui-brand-copy,.nui-rail .nui-badge,.nui-rail .nui-brand-chevron{display:none}.nui-rail .nui-nav-link{justify-content:center;padding:10px 0}.nui-command{border:1px solid #ddd;border-radius:10px;width:500px;max-width:calc(100vw - 32px);padding:0;margin:auto;background:inherit;color:inherit;box-shadow:0 20px 80px #0003}.nui-command::backdrop,.nui-mobile::backdrop{background:#0008}.nui-command input{width:100%;padding:16px;border:0;border-bottom:1px solid #8883;background:transparent;outline:none}.nui-command nav{padding:8px}.nui-mobile{overflow:hidden;margin:0;padding:8px;width:280px;max-width:85vw;height:100dvh;max-height:100dvh;border:0;background:#fafafa;color:#171717}.nui-mobile .nui-nav-footer{margin-top:24px}.nui-user-menu{position:relative}.nui-user-menu summary{list-style:none;cursor:pointer}.nui-user-menu nav{position:absolute;inset-inline-end:0;top:40px;min-width:190px;border:1px solid #8883;background:var(--nui-surface,#fff);border-radius:8px;padding:8px;z-index:40;box-shadow:0 4px 12px #0002}.nui-user-menu a{display:block;padding:8px;color:inherit;text-decoration:none}.dark .nui-user-menu nav,.dark .nui-command,.dark .nui-mobile{background:var(--nui-surface,#171717);color:#fafafa}.nui-mobile-close{float:right}.nui-brand-picker summary{list-style:none;cursor:pointer}.nui-brand-picker nav{padding:4px 8px;margin-bottom:12px}.nui-brand-picker a{display:block;padding:4px;color:inherit}\n${adminResponsiveCss(\"(max-width:1024px)\", \":is([data-responsive=mobile],[data-responsive=tablet])\", `.uibot-admin .nui-header-links{display:none}.uibot-admin .nui-search{width:200px}`)}${adminResponsiveCss(\"(max-width:767px)\", \"[data-responsive=mobile]\", `.uibot-admin .nui-sidebar{display:none}.uibot-admin .nui-main{margin:0;border:0;border-radius:0}.uibot-admin .nui-header{padding:0 16px;gap:8px;height:60px}.uibot-admin .nui-content{padding:16px}.uibot-admin .nui-search{width:150px;font-size:12px}.uibot-admin .nui-search kbd{display:none}.uibot-admin .nui-toolbar{gap:5px}.uibot-admin table{min-width:680px}.uibot-admin h1{font-size:24px}`)}\n${PREVIEW_SCOPE_CSS}${layoutStyle}${STANDARD_CONTAINER_CSS}`;\nexport const AppNavigation: RendererComponent = (props, ctx) => (\n <>\n <style>{shellStyle}</style>\n <Navigation props={props} ctx={ctx} />\n </>\n);\nfunction Navigation({ props, ctx }: { props: Record<string, unknown>; ctx: BlockContext }) {\n return (\n <>\n <details className=\"nui-brand-picker\">\n <summary aria-label={text(props.brand, \"Shadcn Admin\")}>\n <div className=\"nui-brand\">\n {typeof props.logoSrc === \"string\" && props.logoSrc ? (\n <img\n src={props.logoSrc}\n alt={text(props.brand, \"Brand\")}\n width={32}\n height={32}\n style={{ objectFit: \"contain\", flexShrink: 0 }}\n />\n ) : (\n <span className=\"nui-brand-mark\">\n <Icon name=\"command\" />\n </span>\n )}\n <span className=\"nui-brand-copy\">\n <strong>{text(props.brand, \"Shadcn Admin\")}</strong>\n <small>{text(props.subtitle, \"Vite + ShadcnUI\")}</small>\n </span>\n <span className=\"nui-brand-chevron\">\n <Icon name=\"chevrons-up-down\" size={16} />\n </span>\n </div>\n </summary>\n <nav aria-label=\"Workspaces\">\n <ScrollArea\n style={{ maxHeight: \"60dvh\" }}\n viewportProps={{ \"aria-label\": \"Workspace choices\" }}\n >\n {records(props.workspaces).map((w) => (\n <a\n key={text(w.href)}\n href={text(w.href)}\n onClick={() => emit(ctx, \"onNavigate\", { href: text(w.href) })}\n >\n {text(w.label)}\n </a>\n ))}\n </ScrollArea>\n </nav>\n </details>\n <nav aria-label=\"Main navigation\">\n {records(props.groups).map((group) => (\n <div className=\"nui-nav-group\" key={text(group.label)}>\n <div className=\"nui-nav-label\">{text(group.label)}</div>\n {records(group.items).map((item) =>\n records(item.children).length ? (\n <details\n key={text(item.label)}\n className=\"nui-nav-section\"\n open={\n records(item.children).some((child) => child.href === props.activePath) ||\n undefined\n }\n >\n <summary\n className=\"nui-nav-link\"\n aria-label={text(item.label)}\n title={text(item.label)}\n >\n <Icon name={text(item.icon, \"boxes\")} />\n <span className=\"nui-nav-text\">{text(item.label)}</span>\n <Icon name=\"chevron-right\" size={16} />\n </summary>\n <div className=\"ms-4 border-s ps-3\">\n <ScrollArea\n style={{ maxHeight: \"60dvh\" }}\n viewportProps={{ \"aria-label\": text(item.label) }}\n >\n {records(item.children).map((child) => (\n <a\n className=\"nui-nav-link\"\n key={text(child.href)}\n href={text(child.href)}\n aria-current={child.href === props.activePath ? \"page\" : undefined}\n onClick={() => emit(ctx, \"onNavigate\", { href: text(child.href) })}\n >\n {text(child.label)}\n </a>\n ))}\n </ScrollArea>\n </div>\n </details>\n ) : (\n <a\n key={text(item.href)}\n className=\"nui-nav-link\"\n title={text(item.label)}\n href={text(item.href)}\n aria-current={\n item.active === true || item.href === props.activePath ? \"page\" : undefined\n }\n onClick={() => emit(ctx, \"onNavigate\", { href: text(item.href) })}\n >\n <Icon name={text(item.icon, \"boxes\")} />\n <span className=\"nui-nav-text\">{text(item.label)}</span>\n {Boolean(item.badge) && <span className=\"nui-badge\">{text(item.badge)}</span>}\n </a>\n ),\n )}\n </div>\n ))}\n </nav>\n <div className=\"nui-nav-footer\">\n <a className=\"nui-nav-link\" href={text(props.profileHref, \"/settings/profile\")}>\n <span className=\"nui-avatar\">{text(props.initials, \"SN\")}</span>\n <span className=\"nui-brand-copy\">\n <strong>{text(props.userName, \"shadcn\")}</strong>\n <small>{text(props.email, \"m@example.com\")}</small>\n </span>\n <Icon name=\"chevrons-up-down\" size={16} />\n </a>\n </div>\n </>\n );\n}\nexport function AdminFrame({ props, ctx }: { props: Record<string, unknown>; ctx: BlockContext }) {\n const layout =\n props.layout && typeof props.layout === \"object\"\n ? (props.layout as Record<string, unknown>)\n : {};\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const [rail, setRail] = useState(layout.sidebar === \"folded\"),\n [localDark, setDark] = useState(props.theme === \"dark\"),\n [query, setQuery] = useState(\"\");\n useEffect(() => {\n setRail(layout.sidebar === \"folded\");\n setHovered(false);\n setFocused(false);\n }, [layout.sidebar]);\n const [systemDark, setSystemDark] = useState(false);\n const root = useRef<HTMLDivElement>(null);\n const width = usePreviewWidth(root);\n const smallScreen = width > 0 && width < 768;\n const [mobileOpen, setMobileOpen] = useState(false);\n const collapsed =\n layout.navigation !== \"navbar\" &&\n !smallScreen &&\n (layout.sidebar === \"hover\" ? !(hovered || focused) : rail);\n useEffect(() => {\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const sync = () => setSystemDark(media.matches);\n sync();\n media.addEventListener(\"change\", sync);\n return () => media.removeEventListener(\"change\", sync);\n }, []);\n const dark =\n props.theme === \"system\"\n ? systemDark\n : typeof props.theme === \"string\"\n ? props.theme === \"dark\"\n : localDark;\n // A page without sidebar content gets no empty navigation rail, toggle or drawer.\n const hasSidebarSlot: unknown = ctx.slots.sidebar;\n const hasSidebar = Array.isArray(hasSidebarSlot)\n ? hasSidebarSlot.length > 0\n : Boolean(hasSidebarSlot);\n const mobile = useRef<HTMLDialogElement>(null),\n command = useRef<HTMLDialogElement>(null),\n trigger = useRef<HTMLElement | null>(null);\n const releaseMobileBounds = useRef<(() => void) | null>(null);\n useEffect(() => () => releaseMobileBounds.current?.(), []);\n const close = (dialog: HTMLDialogElement | null) => {\n dialog?.close();\n trigger.current?.focus();\n };\n const show = useCallback(\n (dialog: HTMLDialogElement | null) => {\n trigger.current = document.activeElement as HTMLElement;\n if (dialog && dialog === mobile.current) {\n releaseMobileBounds.current?.();\n releaseMobileBounds.current = containPreviewNavigationDialog(\n dialog,\n layout.offcanvas === \"floating\" ? 8 : 0,\n );\n }\n dialog?.showModal();\n },\n [layout.offcanvas],\n );\n useEffect(() => {\n const key = (e: KeyboardEvent) => {\n if (root.current?.closest(\"[inert]\")) return;\n if (\n document.activeElement !== document.body &&\n !root.current?.contains(document.activeElement)\n )\n return;\n if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === \"k\") {\n e.preventDefault();\n show(command.current);\n }\n };\n document.addEventListener(\"keydown\", key);\n return () => document.removeEventListener(\"keydown\", key);\n }, [show]);\n useEffect(() => {\n const menus = () =>\n Array.from(\n root.current?.querySelectorAll<HTMLDetailsElement>(\n `.nui-user-menu[open],.nui-brand-picker[open]${layout.navigation === \"navbar\" ? \",.nui-nav-section[open]\" : \"\"}`,\n ) ?? [],\n );\n const dismissOutside = (event: PointerEvent) => {\n for (const menu of menus()) if (!menu.contains(event.target as Node)) menu.open = false;\n };\n const dismissEscape = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || root.current?.querySelector(\"dialog[open]\")) return;\n for (const menu of menus()) {\n if (!menu.contains(document.activeElement)) continue;\n event.preventDefault();\n menu.open = false;\n menu.querySelector<HTMLElement>(\"summary\")?.focus();\n }\n };\n document.addEventListener(\"pointerdown\", dismissOutside);\n document.addEventListener(\"keydown\", dismissEscape);\n return () => {\n document.removeEventListener(\"pointerdown\", dismissOutside);\n document.removeEventListener(\"keydown\", dismissEscape);\n };\n }, [layout.navigation]);\n useEffect(() => {\n if (!smallScreen) mobile.current?.close();\n }, [smallScreen]);\n const activePath = props.activePath ?? ctx.resolve?.getState?.(\"currentPath\");\n const routes = records(props.routes).filter((r) =>\n text(r.label).toLowerCase().includes(query.toLowerCase()),\n );\n return (\n <Direction.Provider dir={props.direction === \"rtl\" ? \"rtl\" : \"ltr\"}>\n <div\n ref={root}\n style={\n {\n fontFamily:\n props.font === \"System\"\n ? \"system-ui,sans-serif\"\n : props.font === \"Manrope\"\n ? \"Manrope,system-ui,sans-serif\"\n : undefined,\n ...pageLayoutTokenStyle(props.tokens, true),\n } as CSSProperties\n }\n data-uibot-type=\"PageLayout\"\n data-appearance=\"admin\"\n data-shell={typeof layout.shell === \"string\" ? layout.shell : undefined}\n data-responsive={\n width > 0 ? (smallScreen ? \"mobile\" : width <= 1024 ? \"tablet\" : \"desktop\") : undefined\n }\n data-compact-search={width > 0 && width <= 480 ? \"true\" : undefined}\n data-navigation={layout.navigation as string | undefined}\n data-container={layout.container as string | undefined}\n data-navigation-style={layout.navigationStyle as string | undefined}\n data-offcanvas={layout.offcanvas as string | undefined}\n data-sidebar={\n layout.navigation === \"navbar\" ? undefined : (layout.sidebar as string | undefined)\n }\n dir={props.direction === \"rtl\" ? \"rtl\" : \"ltr\"}\n className={`uibot-admin ${collapsed ? \"nui-rail\" : \"\"} ${dark ? \"dark\" : \"\"} ${hasSidebar ? \"\" : \"nui-no-sidebar\"}`}\n onClickCapture={(event) => {\n if (rail && (event.target as HTMLElement).closest(\".nui-sidebar summary\")) setRail(false);\n }}\n >\n <style>{shellStyle}</style>\n {hasSidebar && (\n <div\n className=\"nui-sidebar-space\"\n onPointerEnter={() => setHovered(true)}\n onPointerLeave={() => setHovered(false)}\n onFocusCapture={() => setFocused(true)}\n onBlurCapture={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node)) setFocused(false);\n }}\n >\n <aside className=\"nui-sidebar\">\n {layout.navigation === \"navbar\" && !smallScreen ? (\n (ctx.slots.sidebar as ReactNode[])\n ) : (\n <ScrollArea\n style={{ height: \"100%\", width: \"100%\" }}\n fillContent\n viewportProps={{ \"aria-label\": \"Sidebar navigation\" }}\n >\n {ctx.slots.sidebar as ReactNode[]}\n </ScrollArea>\n )}\n </aside>\n </div>\n )}\n <div className=\"nui-main\">\n <header className=\"nui-header\">\n {hasSidebar && (smallScreen || layout.navigation !== \"navbar\") && (\n <button\n type=\"button\"\n className=\"nui-icon-button\"\n aria-label=\"Toggle sidebar\"\n aria-expanded={smallScreen ? mobileOpen : !collapsed}\n onClick={() => {\n if (smallScreen) {\n setMobileOpen(true);\n show(mobile.current);\n } else if (layout.sidebar === \"hover\") setHovered(!hovered);\n else setRail(!rail);\n }}\n >\n <Icon name=\"panel-left\" />\n </button>\n )}\n {props.appearance !== \"admin\" && typeof props.title === \"string\" && (\n <strong>{props.title}</strong>\n )}\n <nav className=\"nui-header-links\" aria-label=\"Workspace\">\n {records(props.headerLinks).map((link) => (\n <a\n href={text(link.href)}\n key={text(link.label)}\n aria-current={\n link.href === activePath ||\n (link.href === \"/settings/profile\" &&\n typeof activePath === \"string\" &&\n activePath.startsWith(\"/settings/\"))\n ? \"page\"\n : undefined\n }\n >\n {text(link.label)}\n </a>\n ))}\n </nav>\n <div className=\"nui-toolbar\">\n <button\n type=\"button\"\n aria-label=\"Search\"\n className=\"nui-search\"\n onClick={() => show(command.current)}\n >\n <Icon name=\"search\" size={16} />\n <span>Search</span>\n <kbd>⌘ K</kbd>\n </button>\n <button\n type=\"button\"\n className=\"nui-icon-button\"\n aria-label={dark ? \"Use light theme\" : \"Use dark theme\"}\n onClick={() => {\n setDark(!dark);\n emit(\n ctx,\n \"onThemeChange\",\n { theme: dark ? \"light\" : \"dark\" },\n dark ? \"light\" : \"dark\",\n );\n }}\n >\n <Icon name={dark ? \"moon\" : \"sun\"} />\n </button>\n <details className=\"nui-user-menu\">\n <summary aria-label=\"Open account menu\">\n <span className=\"nui-avatar\">{text(props.initials, \"SN\")}</span>\n </summary>\n <nav aria-label=\"Account\">\n {records(\n props.accountLinks ?? [\n { href: \"/settings/profile\", label: \"Profile\" },\n { href: \"/settings/account\", label: \"Account\" },\n { href: \"/settings/notifications\", label: \"Notifications\" },\n { href: \"/sign-in\", label: \"Sign in\" },\n ],\n ).map((link) => (\n <a key={text(link.href)} href={text(link.href)}>\n {text(link.label)}\n </a>\n ))}\n </nav>\n </details>\n {ctx.slots.headerActions as ReactNode[]}\n </div>\n </header>\n <main className=\"nui-content-shell\" style={{ flex: 1, minHeight: 0, minWidth: 0 }}>\n <ScrollArea\n style={{ height: \"100%\" }}\n viewportProps={{ className: \"nui-content\", \"aria-label\": \"Page content\" }}\n >\n <div className=\"nui-content-inner\">{ctx.children as ReactNode[]}</div>\n </ScrollArea>\n </main>\n {ctx.slots.footer as ReactNode[]}\n </div>\n {hasSidebar && (\n <dialog\n ref={mobile}\n className=\"nui-mobile\"\n aria-label=\"Navigation\"\n onClose={() => {\n releaseMobileBounds.current?.();\n releaseMobileBounds.current = null;\n setMobileOpen(false);\n trigger.current?.focus();\n }}\n >\n <button\n type=\"button\"\n className=\"nui-icon-button nui-mobile-close\"\n aria-label=\"Close navigation\"\n onClick={() => close(mobile.current)}\n >\n <Icon name=\"x\" />\n </button>\n <ScrollArea\n style={{ height: \"calc(100% - 40px)\" }}\n fillContent\n viewportProps={{ \"aria-label\": \"Navigation links\" }}\n >\n <div\n onClick={(e) => {\n if ((e.target as Element).closest('a, button[data-uibot-type=\"MenuLink\"]'))\n close(mobile.current);\n }}\n >\n {ctx.slots.sidebar as ReactNode[]}\n </div>\n </ScrollArea>\n </dialog>\n )}\n <dialog\n ref={command}\n className=\"nui-command\"\n aria-label=\"Search pages\"\n onClose={() => {\n setQuery(\"\");\n trigger.current?.focus();\n }}\n onKeyDown={(event) => {\n if (\n ![\"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"].includes(event.key) ||\n event.target instanceof HTMLInputElement\n )\n return;\n const links = Array.from(\n command.current?.querySelectorAll<HTMLAnchorElement>(\"nav a\") ?? [],\n );\n if (!links.length) return;\n event.preventDefault();\n const index = links.indexOf(document.activeElement as HTMLAnchorElement);\n const next =\n event.key === \"Home\"\n ? 0\n : event.key === \"End\"\n ? links.length - 1\n : (index + (event.key === \"ArrowDown\" ? 1 : -1) + links.length) % links.length;\n links[next]?.focus();\n }}\n >\n <input\n aria-label=\"Search pages\"\n autoComplete=\"off\"\n placeholder=\"Type a command or search...\"\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n const links = command.current?.querySelectorAll<HTMLAnchorElement>(\"nav a\");\n if (!links?.length) return;\n e.preventDefault();\n links[e.key === \"ArrowDown\" ? 0 : links.length - 1]?.focus();\n }\n }}\n />\n <ScrollArea style={{ maxHeight: 360 }} viewportProps={{ \"aria-label\": \"Search results\" }}>\n <nav>\n {routes.map((route) => (\n <a\n className=\"nui-nav-link\"\n href={text(route.href)}\n key={text(route.href)}\n onClick={() => close(command.current)}\n >\n <Icon name={text(route.icon, \"chevron-right\")} />\n {text(route.label)}\n </a>\n ))}\n {!routes.length && <p className=\"p-4 text-sm\">No results found.</p>}\n </nav>\n </ScrollArea>\n </dialog>\n </div>\n </Direction.Provider>\n );\n}\n\nimport { pageLayoutTokenStyle } from \"./layout-tokens\";\n",
|
|
17
18
|
"type": "registry:ui"
|
|
18
19
|
},
|
|
19
20
|
{
|
|
@@ -31,7 +32,19 @@
|
|
|
31
32
|
{
|
|
32
33
|
"path": "components/uibot/preview-scope.ts",
|
|
33
34
|
"target": "components/uibot/preview-scope.ts",
|
|
34
|
-
"content": "/**\n * Page frames (`PageLayout`) fill the viewport so only their main area scrolls. Hosts that embed a\n * rendered page in a smaller pane mark the pane with `data-uibot-preview-scope`; inside it the frame\n * fills the pane instead of the viewport: wrappers between the pane and the frame become a flex column\n * chain, so a pane that is a flex column with a definite height hands the frame exactly the space\n * left under any sibling (such as a notice strip). Without such a pane the frame falls back to\n * `height:100%`, and to content height when that is not definite either. The pane also becomes the\n * containing block for fixed-position content
|
|
35
|
+
"content": "/**\n * Page frames (`PageLayout`) fill the viewport so only their main area scrolls. Hosts that embed a\n * rendered page in a smaller pane mark the pane with `data-uibot-preview-scope`; inside it the frame\n * fills the pane instead of the viewport: wrappers between the pane and the frame become a flex column\n * chain, so a pane that is a flex column with a definite height hands the frame exactly the space\n * left under any sibling (such as a notice strip). Without such a pane the frame falls back to\n * `height:100%`, and to content height when that is not definite either. The pane also becomes the\n * containing block for fixed-position content such as floating toasts. Native modal navigation\n * escapes that containment and uses containPreviewNavigationDialog for its visible bounds.\n */\nexport const PREVIEW_SCOPE_CSS =\n \"[data-uibot-preview-dialog]::backdrop{clip-path:inset(var(--uibot-preview-backdrop-inset))}[data-uibot-preview-scope]{contain:layout}[data-uibot-preview-scope] .uibot-admin,[data-uibot-preview-scope] .uibot-page-layout{height:100%;min-height:0;flex:1 1 0}[data-uibot-preview-scope] div:has(.uibot-admin),[data-uibot-preview-scope] div:has(.uibot-page-layout){display:flex;flex-direction:column;min-height:0;flex:1 1 0}\";\n\n/**\n * shadcn/ui Scroll Area look for every scroll container inside a page frame (content area, sidebar,\n * table wrappers, dialogs): a slim 10px track with a rounded, theme-aware thumb. This styles the\n * native scrollbar so it matches shadcn's `ScrollArea`; it does not load Radix.\n */\nexport const SCROLLBAR_CSS =\n \".uibot-admin,.uibot-admin *,.uibot-page-layout,.uibot-page-layout *{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,currentColor 28%,transparent) transparent}.uibot-admin ::-webkit-scrollbar,.uibot-page-layout ::-webkit-scrollbar{width:10px;height:10px}.uibot-admin ::-webkit-scrollbar-track,.uibot-page-layout ::-webkit-scrollbar-track{background:transparent}.uibot-admin ::-webkit-scrollbar-thumb,.uibot-page-layout ::-webkit-scrollbar-thumb{border:2px solid transparent;border-radius:9999px;background:color-mix(in srgb,currentColor 28%,transparent);background-clip:padding-box}.uibot-admin ::-webkit-scrollbar-thumb:hover,.uibot-page-layout ::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb,currentColor 45%,transparent);background-clip:padding-box}.uibot-admin ::-webkit-scrollbar-corner,.uibot-page-layout ::-webkit-scrollbar-corner{background:transparent}\";\n\n/** Native modal dialogs escape layout containment; navigation stays in its host preview. */\nexport function containPreviewNavigationDialog(dialog: HTMLDialogElement, inset = 0): () => void {\n const scope = dialog.closest<HTMLElement>(\"[data-uibot-preview-scope]\");\n if (!scope) return () => {};\n const originalStyle = dialog.getAttribute(\"style\");\n const originalVisibility = dialog.style.visibility;\n const originalMarker = dialog.getAttribute(\"data-uibot-preview-dialog\");\n dialog.setAttribute(\"data-uibot-preview-dialog\", \"\");\n let active = true;\n const sync = () => {\n if (!active) return;\n const rect = scope.getBoundingClientRect();\n const left = Math.max(0, rect.left),\n top = Math.max(0, rect.top);\n const right = Math.min(window.innerWidth, rect.right);\n const bottom = Math.min(window.innerHeight, rect.bottom);\n const width = right - left,\n height = bottom - top;\n if (width <= 0 || height <= 0) {\n dialog.style.visibility = \"hidden\";\n dialog.style.setProperty(\"--uibot-preview-backdrop-inset\", \"100% 100% 0px 0px\");\n return;\n }\n dialog.style.visibility = originalVisibility;\n const gap = Math.min(inset, width / 4, height / 4);\n const maxWidth = Math.max(0, Math.min(width * 0.85, width - gap * 2));\n const rtl = getComputedStyle(dialog).direction === \"rtl\";\n Object.assign(dialog.style, {\n position: \"fixed\",\n top: `${top + gap}px`,\n bottom: \"auto\",\n left: rtl ? \"auto\" : `${left + gap}px`,\n right: rtl ? `${window.innerWidth - right + gap}px` : \"auto\",\n height: `${height - gap * 2}px`,\n maxHeight: `${height - gap * 2}px`,\n maxWidth: `${maxWidth}px`,\n margin: \"0px\",\n });\n dialog.style.setProperty(\n \"--uibot-preview-backdrop-inset\",\n `${top}px ${window.innerWidth - right}px ${window.innerHeight - bottom}px ${left}px`,\n );\n };\n sync();\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(sync);\n observer?.observe(scope);\n window.addEventListener(\"resize\", sync);\n window.addEventListener(\"scroll\", sync, true);\n return () => {\n active = false;\n observer?.disconnect();\n window.removeEventListener(\"resize\", sync);\n window.removeEventListener(\"scroll\", sync, true);\n if (originalStyle === null) dialog.removeAttribute(\"style\");\n else dialog.setAttribute(\"style\", originalStyle);\n if (originalMarker === null) dialog.removeAttribute(\"data-uibot-preview-dialog\");\n else dialog.setAttribute(\"data-uibot-preview-dialog\", originalMarker);\n };\n}\n",
|
|
36
|
+
"type": "registry:ui"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "components/uibot/preview-responsive.ts",
|
|
40
|
+
"target": "components/uibot/preview-responsive.ts",
|
|
41
|
+
"content": "import { useEffect, useState, type RefObject } from \"react\";\n\n/** Read the explicit host pane's layout width; transforms must not change breakpoints. */\nexport function usePreviewWidth(root: RefObject<HTMLElement | null>): number {\n const [width, setWidth] = useState(0);\n useEffect(() => {\n const scope = root.current?.closest<HTMLElement>(\"[data-uibot-preview-scope]\");\n const fallback = () => setWidth(window.innerWidth);\n if (!scope || typeof ResizeObserver === \"undefined\") {\n fallback();\n window.addEventListener(\"resize\", fallback);\n return () => window.removeEventListener(\"resize\", fallback);\n }\n let paneWidth = 0;\n const sync = () => setWidth(paneWidth > 0 ? paneWidth : window.innerWidth);\n const style = getComputedStyle(scope);\n paneWidth =\n scope.clientWidth -\n (Number.parseFloat(style.paddingLeft) || 0) -\n (Number.parseFloat(style.paddingRight) || 0);\n sync();\n const observer = new ResizeObserver(([entry]) => {\n if (!entry) return;\n paneWidth = entry.contentRect.width;\n sync();\n });\n observer.observe(scope);\n window.addEventListener(\"resize\", sync);\n return () => {\n observer.disconnect();\n window.removeEventListener(\"resize\", sync);\n };\n }, [root]);\n return width;\n}\n",
|
|
42
|
+
"type": "registry:ui"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "components/uibot/scroll-area.tsx",
|
|
46
|
+
"target": "components/uibot/scroll-area.tsx",
|
|
47
|
+
"content": "// Adapted from shadcn/ui Scroll Area (MIT).\nimport type { ComponentProps } from \"react\";\nimport { ScrollArea as Primitive } from \"radix-ui\";\n\nconst styles = `\n.uibot-scroll-area{position:relative;min-width:0;min-height:0;overflow:hidden}\n.uibot-scroll-viewport{width:100%;height:100%;max-height:inherit;border-radius:inherit;outline:none}\n.uibot-scroll-viewport:focus-visible{outline:2px solid var(--ring,#94a3b8);outline-offset:-2px}\n.uibot-scroll-viewport>div{display:block!important;min-width:100%}\n.uibot-scroll-area[data-fill-content=true]>.uibot-scroll-viewport>div{display:flex!important;flex-direction:column;min-height:100%}\n.uibot-scroll-area[data-scrollbars=horizontal]>.uibot-scroll-viewport{height:auto}\n.uibot-scrollbar{display:flex;touch-action:none;user-select:none;padding:1px;z-index:20}\n.uibot-scrollbar[data-orientation=vertical]{width:10px;border-inline-start:1px solid transparent}\n.uibot-scrollbar[data-orientation=horizontal]{height:10px;flex-direction:column;border-top:1px solid transparent}\n.uibot-scroll-thumb{position:relative;flex:1;border-radius:9999px;background:var(--nui-border,var(--border,#d4d4d8))}\n.uibot-scroll-thumb:hover,.uibot-scrollbar[data-state=visible]:active .uibot-scroll-thumb{background:var(--muted-foreground,#71717a)}\n`;\n\n/** Shared presentation primitive; refs and scroll events belong to the actual viewport. */\nexport function ScrollArea({\n children,\n className,\n scrollbars = \"vertical\",\n viewportProps,\n fillContent = false,\n ...props\n}: ComponentProps<typeof Primitive.Root> & {\n scrollbars?: \"vertical\" | \"horizontal\" | \"both\";\n viewportProps?: ComponentProps<typeof Primitive.Viewport>;\n fillContent?: boolean;\n}) {\n const { className: viewportClassName, ...viewportRest } = viewportProps ?? {};\n return (\n <Primitive.Root\n data-slot=\"scroll-area\"\n data-scrollbars={scrollbars}\n data-fill-content={fillContent}\n className={`uibot-scroll-area ${className ?? \"\"}`}\n type=\"auto\"\n {...props}\n >\n <style>{styles}</style>\n <Primitive.Viewport\n data-slot=\"scroll-area-viewport\"\n className={`uibot-scroll-viewport ${viewportClassName ?? \"\"}`}\n tabIndex={0}\n {...viewportRest}\n >\n {children}\n </Primitive.Viewport>\n {scrollbars !== \"horizontal\" && <ScrollBar />}\n {scrollbars !== \"vertical\" && <ScrollBar orientation=\"horizontal\" />}\n <Primitive.Corner />\n </Primitive.Root>\n );\n}\n\nexport function ScrollBar({\n className,\n orientation = \"vertical\",\n ...props\n}: ComponentProps<typeof Primitive.Scrollbar>) {\n return (\n <Primitive.Scrollbar\n data-slot=\"scroll-area-scrollbar\"\n orientation={orientation}\n className={`uibot-scrollbar ${className ?? \"\"}`}\n {...props}\n >\n <Primitive.Thumb data-slot=\"scroll-area-thumb\" className=\"uibot-scroll-thumb\" />\n </Primitive.Scrollbar>\n );\n}\n",
|
|
35
48
|
"type": "registry:ui"
|
|
36
49
|
},
|
|
37
50
|
{
|