import * as React from 'react'; import { Translations } from 'najm-i18n'; import { N as NBrandingInput } from '../NNotFoundState-Z2n2gbhS.js'; export { a as NEmptyState, b as NEmptyStateProps, c as NErrorState, d as NErrorStateProps, e as NFeedbackSurface, f as NForbiddenState, g as NForbiddenStateProps, h as NLoadingState, i as NLoadingStateProps, j as NNotFoundState, k as NNotFoundStateProps } from '../NNotFoundState-Z2n2gbhS.js'; import { NajmNextUIProviderProps } from './next.js'; import { F as FormDevToolsOptions } from '../formFill-CQkTA0JS.js'; export { D as DEFAULT_FEEDBACK_KEY_PREFIX, F as FeedbackKey, N as NFeedbackDefaults, a as NFeedbackLabelKeys, b as NFeedbackLabels } from '../NajmUIProvider-wCcltXO6.js'; import 'lucide-react'; import 'next/image'; import 'zod'; import '../design-types-CJYLgxmw.js'; import '../paginationLabels-dZLSNxfo.js'; import 'class-variance-authority/types'; import 'class-variance-authority'; import '../NIcon-D73-C51g.js'; /** Branding shown by the kit's chrome. Purely presentational values. */ interface NajmAppBranding { appName?: string; logoExpanded?: string | null; logoCollapsed?: string | null; } /** * The part of a `najm-i18n` definition this provider reads. * * Structural, so a whole definition satisfies it — its methods are simply * extra — and named for data rather than behaviour because everything derived * here (the writing direction, the formatting tags) is declared metadata. * * That also decides what a Server Component may pass. This provider is a * Client Component, and React rejects a prop carrying functions outright, so a * server layout passes `definition.snapshot` — the same fields without the * methods — while a client parent passes the definition itself. */ interface NajmAppI18n { translations: Translations; defaultLanguage?: string; supportedLanguages?: readonly string[]; fallbackToDefaultLanguage?: boolean; languageMetadata?: { readonly [language: string]: { locale?: string; direction?: 'ltr' | 'rtl'; } | undefined; }; } /** * Request-owned UI values returned by a standard Najm server bootstrap. * Structural on purpose so Kit does not depend on a framework integration. */ interface NajmKitSnapshot { /** Optional for compatibility with snapshots emitted before display projection. */ app?: { appName?: string; currency?: string; }; preferences: { language: string; theme: NonNullable; timeZone: string; /** Institution-owned currency, when the application resolves one. */ currency?: string; }; appearance: { designConfig: NonNullable; }; branding: NBrandingInput; } interface NajmKitProviderProps extends Omit { /** * Standard public server snapshot. It seeds language, theme, time zone, * design, and branding without requiring applications to unpack each field. * Explicit `initial*` props remain supported and take precedence. */ snapshot?: NajmKitSnapshot; /** * Enables schema-driven form filling for every `NForm` and `WizardForm`. * `true` uses F8; an options object can choose another shortcut. */ formDevTools?: boolean | FormDevToolsOptions; /** * A `najm-i18n` definition, standing in for five props: `translations`, * `defaultLanguage`, `fallbackToDefaultLanguage`, `locales` and * `getLanguageDirection`. All five are already declared in the definition, so * an application that has one should not have to take it apart and hand the * pieces back. Any of them passed explicitly still wins, which is how an * application overrides one facet without abandoning the definition. * * From a Server Component, pass `definition.snapshot` instead — see * `NajmAppI18n`. * * `initialLanguage` is deliberately not part of it: the active language is a * per-request value no definition can know. */ i18n?: NajmAppI18n; /** * Catalog for `najm-i18n`. Supplying it mounts an `I18nProvider` and derives * the pagination labels from it, so `t` is not a prop here — the provider * already has the translator and passing one in would be a second source of * truth. * * Defaults to `i18n.translations`. */ translations?: Translations; initialLanguage?: string; /** Defaults to `i18n.defaultLanguage`. */ defaultLanguage?: string; /** * Resolves a key missing from the active language against `defaultLanguage` * instead of echoing the key. Forwarded to `najm-i18n`'s `I18nProvider`; see * that package's "Missing-key fallback" for the full matrix. * * Off by default, matching the package. An application shipping an * incomplete locale beside a complete one turns it on here rather than * pre-merging its catalogs. * * Defaults to `i18n.fallbackToDefaultLanguage`. */ fallbackToDefaultLanguage?: boolean; /** * Maps a language to the writing direction applied to ``. * * Defaults to `i18n.languageMetadata`, resolving an unsupported language * against `defaultLanguage` the way the definition's own `direction` does, * rather than falling through to `najm-i18n`'s built-in Arabic guess. */ getLanguageDirection?: (language: string) => 'ltr' | 'rtl'; /** * Where the chosen language is POSTed, as `{ language }`. Defaults to * `/api/ui-language`. * * Unlike theme and time zone, this deliberately does *not* refresh the * router: `najm-i18n` swaps catalogs reactively on the client, and a refresh * would discard that work to re-render the same strings from the server. */ languageEndpoint?: string; /** * The product name, used as the logo's `alt` and by the kit's chrome. * * Separate from `initialBranding` because it is a constant rather than * something a branding editor swaps, and because it is the one mark no * branding endpoint returns. An `appName` inside `initialBranding` wins. */ appName?: string; /** * ISO 4217 code for `useNajmFormat().money`, e.g. `"MAD"`. * * Omitted means the application does not format currency. It is not defaulted * to anything: rendering an amount in the wrong currency is worse than the * error thrown for the missing code. */ currency?: string; /** * Maps a `najm-i18n` language onto the BCP 47 tag used for formatting, e.g. * `{ en: "en-MA", fr: "fr-MA" }`. * * The distinction matters because language and region are separate choices: * `fr` alone formats dates and separators the French way, which is not how * they are written in Morocco. Unmapped languages are used as-is. * * Defaults to the `locale` of each `i18n.languageMetadata` entry. */ locales?: Record; /** * Fixes the formatting locale, ignoring the active language. Escape hatch for * an application whose language and number formats are genuinely independent. */ locale?: string; /** Rendered for absent values. Defaults to an em dash. */ formatPlaceholder?: string; /** * Controlled marks. Prefer `initialBranding` — passing this means the * application holds the state itself, which is the file this provider exists * to delete. */ branding?: NBrandingInput; /** * Seeds marks this provider owns from then on; ignored after mount. A * branding editor swaps them through `useNBrandingEditor`. * * Takes a branding endpoint's payload as-is — `sidebarLogoExpandedPath` and * `sidebarLogoCollapsedPath` are read straight off it, and unrelated fields * are ignored — so the application forwards its response rather than * renaming two keys here. */ initialBranding?: NBrandingInput; } /** * The whole UI provider stack for a Najm application, as one component. * * Language, theme, time zone, design, branding and `NTable` defaults — the * concerns that were previously a per-project folder of wrapper files, each one * existing only to read the context the one above it published. * * Auth and react-query are deliberately *not* here. They are not UI concerns, * they would drag `najm-auth` and `@tanstack/react-query` into this package, * and an application that wants different query policy should not have to fork * a provider to get it. Mount them above this, from their own packages. * * Design and branding are optional, and both are *uncontrolled* through their * `initial*` props: an application with a runtime theme or branding editor * seeds them from the server once and drives them afterwards through * `useNajmDesignEditor` and `useNBrandingEditor`, rather than holding a draft * state machine of its own above this provider. The controlled `design` and * `branding` props still work for applications that already do. */ declare function NajmKitProvider({ snapshot, i18n, translations, initialLanguage, initialDesign, initialTheme, initialTimeZone, defaultLanguage, fallbackToDefaultLanguage, getLanguageDirection: languageDirection, locales: localeTags, languageEndpoint, appName, currency, initialBranding, formDevTools, ...props }: NajmKitProviderProps): React.JSX.Element; /** @deprecated Use `NajmKitSnapshot`. */ type NajmAppSnapshot = NajmKitSnapshot; /** @deprecated Use `NajmKitProviderProps`. */ type NajmAppProviderProps = NajmKitProviderProps; /** * @deprecated Use `NajmKitProvider`. This alias retains the same component and * context identities throughout the compatibility window. */ declare const NajmAppProvider: typeof NajmKitProvider; export { type NajmAppBranding, type NajmAppI18n, NajmAppProvider, type NajmAppProviderProps, type NajmAppSnapshot, NajmKitProvider, type NajmKitProviderProps, type NajmKitSnapshot };