@tailor-platform/app-shell 1.14.0 → 1.16.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.
Files changed (101) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/app-shell-core.css +1 -1
  3. package/dist/app-shell.d.ts +1203 -316
  4. package/dist/app-shell.js +4562 -3307
  5. package/dist/{appshell-CtS8Y3LW.js → appshell-B0wh5Lq0.js} +850 -549
  6. package/dist/style-entry.d.ts +118 -98
  7. package/dist/testing.d.ts +118 -98
  8. package/dist/testing.js +1 -1
  9. package/dist/themes/_template.css +1 -1
  10. package/dist/vite-plugin.d.ts +118 -98
  11. package/package.json +13 -13
  12. package/skills/app-shell-patterns/SKILL.md +108 -24
  13. package/skills/app-shell-patterns/references/api/create-ai-gateway-client.md +115 -0
  14. package/skills/app-shell-patterns/references/api/create-typed-paths.md +117 -0
  15. package/skills/app-shell-patterns/references/api/define-i18n-labels.md +143 -0
  16. package/skills/app-shell-patterns/references/api/define-module.md +247 -0
  17. package/skills/app-shell-patterns/references/api/define-resource.md +307 -0
  18. package/skills/app-shell-patterns/references/api/guards/hidden.md +202 -0
  19. package/skills/app-shell-patterns/references/api/guards/overview.md +354 -0
  20. package/skills/app-shell-patterns/references/api/guards/pass.md +129 -0
  21. package/skills/app-shell-patterns/references/api/guards/redirect-to.md +307 -0
  22. package/skills/app-shell-patterns/references/api/router/use-location.md +240 -0
  23. package/skills/app-shell-patterns/references/api/router/use-navigate.md +138 -0
  24. package/skills/app-shell-patterns/references/api/router/use-params.md +218 -0
  25. package/skills/app-shell-patterns/references/api/use-ai-chat.md +110 -0
  26. package/skills/app-shell-patterns/references/api/use-app-shell-config.md +126 -0
  27. package/skills/app-shell-patterns/references/api/use-app-shell-data.md +146 -0
  28. package/skills/app-shell-patterns/references/api/use-app-shell.md +143 -0
  29. package/skills/app-shell-patterns/references/api/use-auth.md +145 -0
  30. package/skills/app-shell-patterns/references/api/use-override-breadcrumb.md +74 -0
  31. package/skills/app-shell-patterns/references/api/use-page-meta.md +96 -0
  32. package/skills/app-shell-patterns/references/api/use-register-command-palette-actions.md +90 -0
  33. package/skills/app-shell-patterns/references/api/use-resolved-locale.md +67 -0
  34. package/skills/app-shell-patterns/references/api/use-route-error.md +214 -0
  35. package/skills/app-shell-patterns/references/api/use-theme.md +108 -0
  36. package/skills/app-shell-patterns/references/api/use-time-zone.md +80 -0
  37. package/skills/app-shell-patterns/references/api/use-toast.md +107 -0
  38. package/skills/app-shell-patterns/references/components/action-panel.md +168 -0
  39. package/skills/app-shell-patterns/references/components/activity-card.md +142 -0
  40. package/skills/app-shell-patterns/references/components/ai-chat.md +315 -0
  41. package/skills/app-shell-patterns/references/components/alert.md +202 -0
  42. package/skills/app-shell-patterns/references/components/app-shell.md +530 -0
  43. package/skills/app-shell-patterns/references/components/appearance-switcher.md +87 -0
  44. package/skills/app-shell-patterns/references/components/attachment.md +138 -0
  45. package/skills/app-shell-patterns/references/components/autocomplete.md +278 -0
  46. package/skills/app-shell-patterns/references/components/avatar.md +80 -0
  47. package/skills/app-shell-patterns/references/components/badge.md +309 -0
  48. package/skills/app-shell-patterns/references/components/button.md +164 -0
  49. package/skills/app-shell-patterns/references/components/card.md +109 -0
  50. package/skills/app-shell-patterns/references/components/checkbox.md +169 -0
  51. package/skills/app-shell-patterns/references/components/combobox.md +318 -0
  52. package/skills/app-shell-patterns/references/components/command-palette.md +413 -0
  53. package/skills/app-shell-patterns/references/components/csv-importer.md +214 -0
  54. package/skills/app-shell-patterns/references/components/data-table.md +953 -0
  55. package/skills/app-shell-patterns/references/components/date-picker.md +248 -0
  56. package/skills/app-shell-patterns/references/components/default-header.md +75 -0
  57. package/skills/app-shell-patterns/references/components/default-sidebar.md +136 -0
  58. package/skills/app-shell-patterns/references/components/description-card.md +569 -0
  59. package/skills/app-shell-patterns/references/components/dialog.md +164 -0
  60. package/skills/app-shell-patterns/references/components/document-progress-card.md +154 -0
  61. package/skills/app-shell-patterns/references/components/form.md +378 -0
  62. package/skills/app-shell-patterns/references/components/global-header-layout.md +132 -0
  63. package/skills/app-shell-patterns/references/components/grid.md +184 -0
  64. package/skills/app-shell-patterns/references/components/input.md +83 -0
  65. package/skills/app-shell-patterns/references/components/layout.md +539 -0
  66. package/skills/app-shell-patterns/references/components/menu.md +218 -0
  67. package/skills/app-shell-patterns/references/components/metric-card.md +94 -0
  68. package/skills/app-shell-patterns/references/components/select.md +283 -0
  69. package/skills/app-shell-patterns/references/components/sheet.md +237 -0
  70. package/skills/app-shell-patterns/references/components/sidebar-group.md +466 -0
  71. package/skills/app-shell-patterns/references/components/sidebar-item.md +458 -0
  72. package/skills/app-shell-patterns/references/components/sidebar-layout.md +258 -0
  73. package/skills/app-shell-patterns/references/components/spinner.md +81 -0
  74. package/skills/app-shell-patterns/references/components/table.md +188 -0
  75. package/skills/app-shell-patterns/references/components/tabs.md +158 -0
  76. package/skills/app-shell-patterns/references/components/textarea.md +122 -0
  77. package/skills/app-shell-patterns/references/components/timeline.md +317 -0
  78. package/skills/app-shell-patterns/references/components/toolbar.md +138 -0
  79. package/skills/app-shell-patterns/references/components/tooltip.md +144 -0
  80. package/skills/app-shell-patterns/references/components/with-guard.md +445 -0
  81. package/skills/app-shell-patterns/references/concepts/authentication.md +301 -0
  82. package/skills/app-shell-patterns/references/concepts/custom-components.md +59 -0
  83. package/skills/app-shell-patterns/references/concepts/file-based-routing.md +350 -0
  84. package/skills/app-shell-patterns/references/{fundamental → concepts}/graphql.md +11 -4
  85. package/skills/app-shell-patterns/references/concepts/modules-and-resources.md +229 -0
  86. package/skills/app-shell-patterns/references/concepts/routing-navigation.md +387 -0
  87. package/skills/app-shell-patterns/references/concepts/sidebar-navigation.md +388 -0
  88. package/skills/app-shell-patterns/references/{fundamental/design-system.md → concepts/styling-theming.md} +260 -105
  89. package/skills/app-shell-patterns/references/migrations.md +34 -0
  90. package/skills/app-shell-patterns/references/pages/document-detail.md +1125 -0
  91. package/skills/app-shell-patterns/references/patterns/form-composer.md +44 -46
  92. package/skills/app-shell-patterns/references/patterns/form-modal.md +39 -100
  93. package/skills/app-shell-patterns/references/patterns/form-sectioned.md +12 -38
  94. package/skills/app-shell-patterns/references/patterns/form-single-page.md +11 -32
  95. package/skills/app-shell-patterns/references/patterns/form-wizard.md +12 -53
  96. package/skills/app-shell-patterns/references/patterns/interaction-confirm.md +11 -27
  97. package/skills/app-shell-patterns/references/patterns/interaction-multi-select.md +14 -28
  98. package/skills/app-shell-patterns/references/patterns/interaction-toast.md +10 -34
  99. package/skills/app-shell-patterns/references/patterns/list-dense-scan.md +11 -86
  100. package/skills/app-shell-patterns/references/fundamental/components.md +0 -981
  101. package/skills/app-shell-patterns/references/patterns/detail-hero-with-actions.md +0 -201
@@ -0,0 +1,143 @@
1
+ ---
2
+ title: useAppShell
3
+ description: Hook to access AppShell context data and configuration
4
+ ---
5
+
6
+ <!-- GENERATED by docs-kit from docs-src/hooks/use-app-shell.docs.outline.md — do not edit by hand. -->
7
+
8
+ # useAppShell
9
+
10
+ React hook to access AppShell context data and configuration within your components.
11
+
12
+ ## Signature
13
+
14
+ ```typescript
15
+ const useAppShell: () => {
16
+ context: ContextData;
17
+ contextData: ContextData;
18
+ configurations: AppShellConfig;
19
+ };
20
+ ```
21
+
22
+ ## Return Value
23
+
24
+ ### `context` / `contextData`
25
+
26
+ - **Type:** `ContextData`
27
+ - **Description:** Custom context data passed to AppShell. Same as the `contextData` prop.
28
+
29
+ ### `configurations`
30
+
31
+ - **Type:** `AppShellConfig`
32
+ - **Description:** AppShell configuration (locale, basePath, etc.)
33
+
34
+ ## Usage
35
+
36
+ ### Basic Access
37
+
38
+ ```typescript
39
+ import { useAppShell } from "@tailor-platform/app-shell";
40
+
41
+ function MyComponent() {
42
+ const { context } = useAppShell();
43
+
44
+ return <div>Welcome, {context.currentUser?.name}</div>;
45
+ }
46
+ ```
47
+
48
+ ### Access Configuration
49
+
50
+ ```typescript
51
+ function LocaleDisplay() {
52
+ const { configurations } = useAppShell();
53
+
54
+ return <div>Current locale: {configurations.locale}</div>;
55
+ }
56
+ ```
57
+
58
+ ## Context Data
59
+
60
+ Define your context type with module augmentation:
61
+
62
+ ```typescript
63
+ // types.d.ts
64
+ declare module "@tailor-platform/app-shell" {
65
+ interface AppShellRegister {
66
+ contextData: {
67
+ currentUser: User | null;
68
+ permissions: string[];
69
+ tenantId: string;
70
+ };
71
+ }
72
+ }
73
+
74
+ // App.tsx
75
+ <AppShell
76
+ modules={modules}
77
+ contextData={{
78
+ currentUser,
79
+ permissions,
80
+ tenantId,
81
+ }}
82
+ />
83
+
84
+ // MyComponent.tsx
85
+ const { context } = useAppShell();
86
+ context.currentUser // Fully typed!
87
+ context.permissions // Fully typed!
88
+ ```
89
+
90
+ ## Examples
91
+
92
+ ### Display User Info
93
+
94
+ ```typescript
95
+ function UserInfo() {
96
+ const { context } = useAppShell();
97
+
98
+ if (!context.currentUser) {
99
+ return <div>Not logged in</div>;
100
+ }
101
+
102
+ return (
103
+ <div>
104
+ <h2>{context.currentUser.name}</h2>
105
+ <p>{context.currentUser.email}</p>
106
+ </div>
107
+ );
108
+ }
109
+ ```
110
+
111
+ ### Check Permissions
112
+
113
+ ```typescript
114
+ function DeleteButton() {
115
+ const { context } = useAppShell();
116
+ const canDelete = context.permissions.includes("users:delete");
117
+
118
+ if (!canDelete) {
119
+ return null;
120
+ }
121
+
122
+ return <Button variant="destructive">Delete</Button>;
123
+ }
124
+ ```
125
+
126
+ ### Feature Flags
127
+
128
+ ```typescript
129
+ function BetaFeature() {
130
+ const { context } = useAppShell();
131
+
132
+ if (!context.featureFlags?.newDashboard) {
133
+ return <OldDashboard />;
134
+ }
135
+
136
+ return <NewDashboard />;
137
+ }
138
+ ```
139
+
140
+ ## Related
141
+
142
+ - [AppShell Component](../components/app-shell.md) - Root component
143
+ - [Guards Overview](./guards/overview.md) - Access control using context
@@ -0,0 +1,145 @@
1
+ ---
2
+ title: useAuth
3
+ description: Hook for accessing authentication state and methods
4
+ ---
5
+
6
+ <!-- GENERATED by docs-kit from docs-src/hooks/use-auth.docs.outline.md — do not edit by hand. -->
7
+
8
+ # useAuth
9
+
10
+ React hook to access authentication state and methods when using `AuthProvider`.
11
+
12
+ ## Signature
13
+
14
+ ```typescript
15
+ const useAuth: () => {
16
+ error: string | null;
17
+ isAuthenticated: boolean;
18
+ isReady: boolean;
19
+ login: () => Promise<void>;
20
+ logout: () => Promise<void>;
21
+ checkAuthStatus: () => Promise<AuthState>;
22
+ };
23
+ ```
24
+
25
+ ## Return Value
26
+
27
+ ### `error`
28
+
29
+ - **Type:** `string | null`
30
+ - **Description:** Error message if authentication failed
31
+
32
+ ### `isAuthenticated`
33
+
34
+ - **Type:** `boolean`
35
+ - **Description:** Whether the user is currently authenticated
36
+
37
+ ### `isReady`
38
+
39
+ - **Type:** `boolean`
40
+ - **Description:** Whether the initial auth check has completed. Always check this before rendering authenticated content to avoid flashing unauthenticated state.
41
+
42
+ ### `login()`
43
+
44
+ - **Type:** `() => Promise<void>`
45
+ - **Description:** Initiates the login process. Redirects to Tailor Platform authentication page.
46
+
47
+ ### `logout()`
48
+
49
+ - **Type:** `() => Promise<void>`
50
+ - **Description:** Logs out the current user. Clears tokens and session.
51
+
52
+ ### `checkAuthStatus()`
53
+
54
+ - **Type:** `() => Promise<AuthState>`
55
+ - **Description:** Checks current auth status. Makes network request to verify and refresh tokens if needed.
56
+
57
+ ## Usage
58
+
59
+ ### Basic Authentication Flow
60
+
61
+ ```typescript
62
+ import { useAuth } from "@tailor-platform/app-shell";
63
+
64
+ function MyComponent() {
65
+ const { isAuthenticated, isReady, login, logout } = useAuth();
66
+
67
+ if (!isReady) {
68
+ return <div>Loading...</div>;
69
+ }
70
+
71
+ if (!isAuthenticated) {
72
+ return <button onClick={login}>Log In</button>;
73
+ }
74
+
75
+ return (
76
+ <div>
77
+ <p>You are logged in!</p>
78
+ <button onClick={logout}>Log Out</button>
79
+ </div>
80
+ );
81
+ }
82
+ ```
83
+
84
+ ### Protected Content
85
+
86
+ ```typescript
87
+ function ProtectedPage() {
88
+ const { isAuthenticated, isReady } = useAuth();
89
+
90
+ if (!isReady) {
91
+ return <Spinner />;
92
+ }
93
+
94
+ if (!isAuthenticated) {
95
+ return <LoginPrompt />;
96
+ }
97
+
98
+ return <SecureContent />;
99
+ }
100
+ ```
101
+
102
+ ### Handle Auth Errors
103
+
104
+ ```typescript
105
+ function AuthStatus() {
106
+ const { isAuthenticated, error, login } = useAuth();
107
+
108
+ if (error) {
109
+ return (
110
+ <div>
111
+ <p>Authentication failed: {error}</p>
112
+ <button onClick={login}>Retry</button>
113
+ </div>
114
+ );
115
+ }
116
+
117
+ return <div>Status: {isAuthenticated ? "Logged in" : "Logged out"}</div>;
118
+ }
119
+ ```
120
+
121
+ ## With AuthProvider
122
+
123
+ ```typescript
124
+ import { AuthProvider, AppShell, useAuth } from "@tailor-platform/app-shell";
125
+
126
+ function App() {
127
+ return (
128
+ <AuthProvider
129
+ apiEndpoint="https://api.tailor.tech"
130
+ clientId="your-client-id"
131
+ redirectUri="http://localhost:3000/callback"
132
+ autoLogin={true}
133
+ >
134
+ <AppShell modules={modules}>
135
+ <SidebarLayout />
136
+ </AppShell>
137
+ </AuthProvider>
138
+ );
139
+ }
140
+ ```
141
+
142
+ ## Related
143
+
144
+ - [Authentication Concept](../concepts/authentication.md) - Authentication guide
145
+ - [AuthProvider](../components/app-shell.md) - Auth provider setup
@@ -0,0 +1,74 @@
1
+ ---
2
+ title: useOverrideBreadcrumb
3
+ description: Hook for dynamically overriding breadcrumb titles from within page components
4
+ ---
5
+
6
+ <!-- GENERATED by docs-kit from docs-src/hooks/use-override-breadcrumb.docs.outline.md — do not edit by hand. -->
7
+
8
+ # useOverrideBreadcrumb
9
+
10
+ React hook to dynamically override the breadcrumb title for the current page. Useful for displaying data-driven titles (e.g., record names fetched from an API) instead of static route-based titles.
11
+
12
+ ## Signature
13
+
14
+ ```typescript
15
+ function useOverrideBreadcrumb(title: string | undefined): void;
16
+ ```
17
+
18
+ ## Parameters
19
+
20
+ ### `title`
21
+
22
+ - **Type:** `string | undefined`
23
+ - **Required:** Yes
24
+ - **Description:** The title to display in the breadcrumb for the current path. When `undefined`, any previous override is removed and the default title (from `defineResource`) is restored.
25
+
26
+ ## Usage
27
+
28
+ ### With `defineResource`
29
+
30
+ ```tsx
31
+ import { useOverrideBreadcrumb } from "@tailor-platform/app-shell";
32
+
33
+ defineResource({
34
+ path: ":id",
35
+ component: () => {
36
+ const { id } = useParams();
37
+ const { data } = useQuery(GET_ORDER, { variables: { id } });
38
+
39
+ // Update breadcrumb with the order name
40
+ useOverrideBreadcrumb(data?.order?.name);
41
+
42
+ return <OrderDetail />;
43
+ },
44
+ });
45
+ ```
46
+
47
+ ### With file-based routing
48
+
49
+ ```tsx
50
+ import { useOverrideBreadcrumb, useParams } from "@tailor-platform/app-shell";
51
+
52
+ const OrderDetailPage = () => {
53
+ const { id } = useParams();
54
+ const { data } = useQuery(GET_ORDER, { variables: { id } });
55
+
56
+ // Update breadcrumb with the order name
57
+ useOverrideBreadcrumb(data?.order?.name);
58
+
59
+ return <div>...</div>;
60
+ };
61
+
62
+ export default OrderDetailPage;
63
+ ```
64
+
65
+ ## Notes
66
+
67
+ - The hook updates reactively — pass the result of a data-fetching query directly and the breadcrumb updates when the data resolves.
68
+ - When `title` is `undefined` (e.g., while data is loading), the override is cleared and the default title is shown.
69
+ - The override is automatically cleaned up when the component unmounts.
70
+
71
+ ## Related
72
+
73
+ - [defineResource](./define-resource.md) - Define routes and their default breadcrumb titles
74
+ - [Routing and Navigation](../concepts/routing-navigation.md) - Overview of breadcrumb behavior
@@ -0,0 +1,96 @@
1
+ ---
2
+ title: usePageMeta
3
+ description: Hook to resolve page metadata from route path
4
+ ---
5
+
6
+ <!-- GENERATED by docs-kit from docs-src/hooks/use-page-meta.docs.outline.md — do not edit by hand. -->
7
+
8
+ # usePageMeta
9
+
10
+ React hook to resolve page metadata (title, icon) from a route path.
11
+
12
+ ## Signature
13
+
14
+ ```typescript
15
+ const usePageMeta: (path: string) => {
16
+ title: string;
17
+ icon?: React.ReactNode;
18
+ } | null;
19
+ ```
20
+
21
+ ## Parameters
22
+
23
+ ### `path`
24
+
25
+ - **Type:** `string`
26
+ - **Required:** Yes
27
+ - **Description:** Route path to look up metadata for
28
+
29
+ ## Return Value
30
+
31
+ Returns an object with `title` and optional `icon`, or `null` when the path is external or does not match any AppShell route.
32
+
33
+ ## Usage
34
+
35
+ ### Resolve Title and Icon
36
+
37
+ ```typescript
38
+ import { usePageMeta } from "@tailor-platform/app-shell";
39
+
40
+ function NavigationItem({ path }: { path: string }) {
41
+ const meta = usePageMeta(path);
42
+
43
+ if (!meta) {
44
+ return null;
45
+ }
46
+
47
+ return (
48
+ <div>
49
+ {meta.icon}
50
+ <span>{meta.title}</span>
51
+ </div>
52
+ );
53
+ }
54
+ ```
55
+
56
+ ### Custom Link Component
57
+
58
+ ```typescript
59
+ function CustomLink({ to }: { to: string }) {
60
+ const meta = usePageMeta(to);
61
+
62
+ return (
63
+ <a href={to}>
64
+ {meta?.icon}
65
+ {meta?.title || to}
66
+ </a>
67
+ );
68
+ }
69
+ ```
70
+
71
+ ### Breadcrumb Builder
72
+
73
+ ```typescript
74
+ function Breadcrumb({ paths }: { paths: string[] }) {
75
+ return (
76
+ <div>
77
+ {paths.map((path) => {
78
+ const meta = usePageMeta(path);
79
+ return <span key={path}>{meta?.title}</span>;
80
+ })}
81
+ </div>
82
+ );
83
+ }
84
+ ```
85
+
86
+ ## Notes
87
+
88
+ - Used internally by `SidebarItem` to auto-resolve titles and icons
89
+ - Returns `null` for external URLs (`http://...` / `https://...`) and for paths that do not match any defined route
90
+ - Resolves from module and resource `meta` properties
91
+ - Prefers literal routes before dynamic siblings, so `/users/new` resolves that route's metadata instead of `/users/:id`
92
+
93
+ ## Related
94
+
95
+ - [SidebarItem](../components/sidebar-item.md) - Uses usePageMeta internally
96
+ - [defineModule](./define-module.md) - Define meta.title and meta.icon
@@ -0,0 +1,90 @@
1
+ ---
2
+ title: useRegisterCommandPaletteActions
3
+ description: Hook for registering contextual page actions into the CommandPalette
4
+ ---
5
+
6
+ <!-- GENERATED by docs-kit from docs-src/hooks/use-register-command-palette-actions.docs.outline.md — do not edit by hand. -->
7
+
8
+ # useRegisterCommandPaletteActions
9
+
10
+ React hook that declaratively registers page-level actions into the CommandPalette's **Actions** section. Actions are searchable and triggerable via the `Cmd+K` / `Ctrl+K` shortcut. They are automatically unregistered when the calling component unmounts.
11
+
12
+ ## Import
13
+
14
+ ```tsx
15
+ import {
16
+ useRegisterCommandPaletteActions,
17
+ type CommandPaletteAction,
18
+ } from "@tailor-platform/app-shell";
19
+ ```
20
+
21
+ ## Signature
22
+
23
+ ```typescript
24
+ function useRegisterCommandPaletteActions(group: string, actions: CommandPaletteAction[]): void;
25
+ ```
26
+
27
+ ## Parameters
28
+
29
+ | Parameter | Type | Description |
30
+ | --------- | ------------------------ | --------------------------------------------------------- |
31
+ | `group` | `string` | Display group name shown in the palette for these actions |
32
+ | `actions` | `CommandPaletteAction[]` | List of actions to register |
33
+
34
+ ## `CommandPaletteAction`
35
+
36
+ ```typescript
37
+ type CommandPaletteAction = {
38
+ key: string;
39
+ label: string;
40
+ icon?: ReactNode;
41
+ group?: string;
42
+ onSelect: () => void | Promise<void>;
43
+ };
44
+ ```
45
+
46
+ | Property | Type | Description |
47
+ | ---------- | ----------------------------- | ----------------------------------------------------------------------------- |
48
+ | `key` | `string` | Unique key for React reconciliation |
49
+ | `label` | `string` | Visible label shown in the palette; also used for search matching |
50
+ | `icon` | `ReactNode` | Optional icon rendered next to the label |
51
+ | `group` | `string` | Optional group override; defaults to the `group` parameter passed to the hook |
52
+ | `onSelect` | `() => void \| Promise<void>` | Callback invoked when the user selects the action |
53
+
54
+ ## Usage
55
+
56
+ ```tsx
57
+ import { useRegisterCommandPaletteActions } from "@tailor-platform/app-shell";
58
+
59
+ function OrderDetailPage() {
60
+ const [loading, setLoading] = useState(false);
61
+
62
+ const handleConfirm = async () => {
63
+ setLoading(true);
64
+ try {
65
+ await confirmOrder(orderId);
66
+ } finally {
67
+ setLoading(false);
68
+ }
69
+ };
70
+
71
+ useRegisterCommandPaletteActions("Order Actions", [
72
+ { key: "confirm", label: "Confirm order", onSelect: handleConfirm },
73
+ { key: "cancel", label: "Cancel order", icon: <XIcon />, onSelect: handleCancel },
74
+ ]);
75
+
76
+ return <div>{/* page content */}</div>;
77
+ }
78
+ ```
79
+
80
+ ## Behavior
81
+
82
+ - Actions are registered while the component is mounted and removed on unmount.
83
+ - Re-rendering with a new `actions` array replaces the previously registered set.
84
+ - `icon` changes alone do not trigger re-registration. If you need to reflect a dynamic icon update, also change the action's `key` or `label`.
85
+ - The hook requires `CommandPaletteProvider`, which is mounted automatically by `AppShell`.
86
+
87
+ ## Related
88
+
89
+ - [CommandPalette](../components/command-palette.md) — Keyboard-driven navigation and action palette
90
+ - [ActionPanel](../components/action-panel.md) — Automatically uses this hook to expose its actions in the palette
@@ -0,0 +1,67 @@
1
+ ---
2
+ title: useResolvedLocale
3
+ description: Hook to access the full BCP-47 locale and language code from AppShell context
4
+ ---
5
+
6
+ <!-- GENERATED by docs-kit from docs-src/hooks/use-resolved-locale.docs.outline.md — do not edit by hand. -->
7
+
8
+ # useResolvedLocale
9
+
10
+ React hook that returns the full BCP-47 locale (e.g. `"en-GB"`) and the language code (e.g. `"en"`) from the AppShell context. Use this for `Intl` APIs and date formatting that require a specific locale.
11
+
12
+ ## Signature
13
+
14
+ ```typescript
15
+ const useResolvedLocale: () => {
16
+ locale: string;
17
+ language: string;
18
+ };
19
+ ```
20
+
21
+ ## Return Value
22
+
23
+ ### `locale`
24
+
25
+ - **Type:** `string`
26
+ - **Description:** Full BCP-47 locale tag (e.g. `"en-GB"`, `"ja-JP"`). Sourced from the `locale` prop passed to `AppShell`, or auto-detected from the browser when omitted.
27
+
28
+ ### `language`
29
+
30
+ - **Type:** `string`
31
+ - **Description:** Language subtag only (e.g. `"en"`, `"ja"`). Used for resolving built-in UI label tables.
32
+
33
+ ## Usage
34
+
35
+ ```typescript
36
+ import { useResolvedLocale } from "@tailor-platform/app-shell";
37
+
38
+ function DateDisplay({ date }: { date: Date }) {
39
+ const { locale } = useResolvedLocale();
40
+
41
+ return (
42
+ <span>
43
+ {new Intl.DateTimeFormat(locale, { dateStyle: "long" }).format(date)}
44
+ </span>
45
+ );
46
+ }
47
+ ```
48
+
49
+ ### Locale-aware number formatting
50
+
51
+ ```typescript
52
+ function PriceDisplay({ amount }: { amount: number }) {
53
+ const { locale } = useResolvedLocale();
54
+
55
+ return (
56
+ <span>
57
+ {new Intl.NumberFormat(locale, { style: "currency", currency: "USD" }).format(amount)}
58
+ </span>
59
+ );
60
+ }
61
+ ```
62
+
63
+ ## Related
64
+
65
+ - [AppShell](../components/app-shell.md) — configure locale via the `locale` prop
66
+ - [useTimeZone](./use-time-zone.md) — access the configured IANA timezone
67
+ - [DatePicker](../components/date-picker.md) — date input components that consume this locale automatically