najm-kit 2.8.2 → 2.10.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.
@@ -1,165 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as React$1 from 'react';
2
+ import * as React from 'react';
3
3
  import React__default from 'react';
4
+ import { e as NajmMode, a as NajmDesignConfig } from './design-types-Rkpt8Pg1.js';
4
5
  import { b as NTablePaginationLabels, N as NajmTranslate } from './paginationLabels-dZLSNxfo.js';
5
-
6
- type NajmMode = 'light' | 'dark';
7
- type NajmAccent = 'neutral' | 'emerald' | 'green' | 'slate' | 'blue' | 'violet';
8
- type NajmPreset = 'light' | 'dark' | 'dark-emerald' | 'dark-green' | 'dark-slate' | 'dark-blue' | 'dark-violet';
9
- interface NajmAppearance {
10
- /** Global border thickness, e.g. `'0'`, `'1px'`, `'2px'`. `'0'` hides borders. */
11
- borderWidth?: string;
12
- }
13
- interface NajmThemeTokens {
14
- background?: string;
15
- foreground?: string;
16
- card?: string;
17
- 'card-foreground'?: string;
18
- popover?: string;
19
- 'popover-foreground'?: string;
20
- primary?: string;
21
- 'primary-foreground'?: string;
22
- secondary?: string;
23
- 'secondary-foreground'?: string;
24
- tertiary?: string;
25
- 'tertiary-foreground'?: string;
26
- muted?: string;
27
- 'muted-foreground'?: string;
28
- accent?: string;
29
- 'accent-foreground'?: string;
30
- destructive?: string;
31
- 'destructive-foreground'?: string;
32
- border?: string;
33
- input?: string;
34
- ring?: string;
35
- sidebar?: string;
36
- 'sidebar-foreground'?: string;
37
- 'sidebar-primary'?: string;
38
- 'sidebar-primary-foreground'?: string;
39
- 'sidebar-accent'?: string;
40
- 'sidebar-accent-foreground'?: string;
41
- 'sidebar-border'?: string;
42
- 'sidebar-ring'?: string;
43
- 'chart-1'?: string;
44
- 'chart-2'?: string;
45
- 'chart-3'?: string;
46
- 'chart-4'?: string;
47
- 'chart-5'?: string;
48
- radius?: string;
49
- }
50
- /** Serializable theme settings suitable for JSON files, APIs, or local storage. */
51
- interface NajmThemeConfig {
52
- preset?: NajmPreset;
53
- mode?: NajmMode;
54
- accent?: NajmAccent;
55
- tokens?: NajmThemeTokens;
56
- /**
57
- * Per-mode token overrides authored on top of the composed preset. Keeps
58
- * light and dark customizations independent: editing a token in one mode
59
- * records it here so it survives switching to the other mode and back.
60
- * Providers resolve this field on top of the composed mode/accent preset.
61
- */
62
- overrides?: Partial<Record<NajmMode, NajmThemeTokens>>;
63
- accentOnly?: boolean;
64
- appearance?: NajmAppearance;
65
- radius?: string;
66
- }
67
- interface NajmThemeProviderProps {
68
- /** Serializable theme settings. Explicit provider props override this config. */
69
- config?: NajmThemeConfig;
70
- preset?: NajmPreset;
71
- mode?: NajmMode;
72
- accent?: NajmAccent;
73
- tokens?: NajmThemeTokens;
74
- /** When true, only inject accent tokens (primary, ring, accent and their foregrounds).
75
- * Everything else (bg, card, fg…) is inherited from the parent cascade. */
76
- accentOnly?: boolean;
77
- /** App-wide UI preferences (currently global border width). */
78
- appearance?: NajmAppearance;
79
- /** Global base radius, for example `0`, `0.5rem`, or `0.75rem`. */
80
- radius?: string;
81
- className?: string;
82
- asChild?: boolean;
83
- children: React.ReactNode;
84
- }
85
-
86
- type NajmDensity = "compact" | "default" | "comfortable";
87
- /** Tailwind's mobile-first viewport breakpoints, plus the default value. */
88
- type NajmResponsiveBreakpoint = "base" | "sm" | "md" | "lg" | "xl" | "2xl";
89
- /**
90
- * A scalar value for every viewport, or mobile-first breakpoint overrides.
91
- * For example: `{ base: 164, lg: 200, xl: 240 }`.
92
- */
93
- type NajmResponsiveValue<T> = T | Partial<Record<NajmResponsiveBreakpoint, T>>;
94
- type NajmComponentRadius = "inherit" | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "full" | string;
95
- interface NajmSlotStyle {
96
- className?: string;
97
- radius?: NajmComponentRadius;
98
- borderWidth?: string;
99
- padding?: string;
100
- paddingTop?: string;
101
- }
102
- interface NajmVariantStyle {
103
- /** Reuse another variant's recipe. Example: primary badge uses secondary. */
104
- use?: string;
105
- className?: string;
106
- tokens?: Record<string, string>;
107
- }
108
- interface NajmComponentStyleConfig {
109
- /** Render components that support it as a card-like surface. */
110
- card?: boolean;
111
- /** Sidebar-only: render section titles above grouped nav items. */
112
- showSectionLabels?: boolean;
113
- /** Sidebar-only: render separator lines between nav item sections. */
114
- showSectionSeparators?: boolean;
115
- /** Sidebar-only: expanded width in px (default 240). Supports responsive overrides. */
116
- expandedWidth?: NajmResponsiveValue<number>;
117
- /** Sidebar-only: collapsed width in px (default 64). Supports responsive overrides. */
118
- collapsedWidth?: NajmResponsiveValue<number>;
119
- /** Sidebar-only: mobile drawer width in px. Defaults to the expanded width. */
120
- mobileWidth?: NajmResponsiveValue<number>;
121
- defaultVariant?: string;
122
- defaultSize?: string;
123
- density?: NajmDensity;
124
- /** NTable-only: CSS color used for the table header and add button. */
125
- headerColor?: string;
126
- /** NTable-only: CSS color used for table header text and add button text. */
127
- headerTextColor?: string;
128
- /** NTable-only: CSS color used for table container and row borders. */
129
- borderColor?: string;
130
- radius?: NajmComponentRadius;
131
- borderWidth?: string;
132
- slots?: Record<string, NajmSlotStyle>;
133
- variants?: Record<string, NajmVariantStyle>;
134
- }
135
- type NajmComponentName = "button" | "badge" | "card" | "table" | "tabs" | "dialog" | "alert" | "sidebar" | "pageHeader" | "input" | "select" | "dropdown" | "sheet" | "popover" | "tooltip" | "progress" | "avatar";
136
- type NajmComponentThemeConfig = Partial<Record<NajmComponentName, NajmComponentStyleConfig>>;
137
- interface NajmTypographyConfig {
138
- fontSans?: string;
139
- fontHeading?: string;
140
- fontMono?: string;
141
- baseSize?: string;
142
- scale?: "compact" | "default" | "comfortable";
143
- lineHeight?: string;
144
- letterSpacing?: string;
145
- }
146
- interface NajmLayoutConfig {
147
- /** Page inline padding, usually used by NPageLayout. */
148
- pageGutter?: string;
149
- /** Vertical page padding and stacked section gap, usually used by NPageLayout. */
150
- sectionGap?: string;
151
- }
152
- interface NajmDesignConfig {
153
- version: 1;
154
- theme: NajmThemeConfig;
155
- typography?: NajmTypographyConfig;
156
- components?: NajmComponentThemeConfig;
157
- layout?: NajmLayoutConfig;
158
- }
159
- declare const NAJM_COMPONENT_NAMES: readonly NajmComponentName[];
160
- /** Maps a NajmComponentRadius keyword to a CSS value (or var). */
161
- declare const RADIUS_VALUE_MAP: Record<string, string>;
162
- declare function resolveRadiusValue(radius: NajmComponentRadius | undefined): string | undefined;
6
+ import * as class_variance_authority_types from 'class-variance-authority/types';
7
+ import { VariantProps } from 'class-variance-authority';
163
8
 
164
9
  /**
165
10
  * Defaults every `NTable` beneath the provider inherits.
@@ -185,6 +30,89 @@ declare function NTableDefaultsProvider({ children, value, }: {
185
30
  }): react_jsx_runtime.JSX.Element;
186
31
  declare function useNTableDefaults(): NTableDefaults;
187
32
 
33
+ type NIconSource = React__default.ReactElement | React__default.ComponentType<any> | React__default.ExoticComponent<any> | string | {
34
+ src: string;
35
+ alt?: string;
36
+ };
37
+ type NIconProps = Omit<React__default.HTMLAttributes<HTMLElement>, "children"> & {
38
+ size?: string | number;
39
+ icon: NIconSource;
40
+ alt?: string;
41
+ color?: string;
42
+ className?: string;
43
+ strokeWidth?: number;
44
+ stroke?: string;
45
+ fill?: string;
46
+ onClick?: React__default.MouseEventHandler<HTMLElement>;
47
+ style?: React__default.CSSProperties;
48
+ };
49
+ declare const NIcon: React__default.FC<NIconProps>;
50
+
51
+ declare const badgeVariants: (props?: {
52
+ variant?: "secondary" | "destructive" | "default" | "outline" | "success" | "warning";
53
+ } & class_variance_authority_types.ClassProp) => string;
54
+ declare const badgeColorVariants: (props?: {
55
+ color?: "neutral" | "primary" | "accent" | "secondary" | "destructive" | "success" | "warning" | "info";
56
+ look?: "solid" | "outline" | "soft" | "dash";
57
+ size?: "sm" | "md" | "lg";
58
+ shape?: "default" | "square" | "pill";
59
+ } & class_variance_authority_types.ClassProp) => string;
60
+ type BadgeVariantProps = VariantProps<typeof badgeVariants>;
61
+ type BadgeColorVariantProps = VariantProps<typeof badgeColorVariants>;
62
+ type BadgeColor = NonNullable<BadgeColorVariantProps["color"]>;
63
+ type BadgeLook = NonNullable<BadgeColorVariantProps["look"]>;
64
+ type BadgeDisplayLook = BadgeLook | "minimal" | "text";
65
+ type BadgeSize = NonNullable<BadgeColorVariantProps["size"]>;
66
+ type BadgeShape = NonNullable<BadgeColorVariantProps["shape"]>;
67
+ type BadgeVariant = NonNullable<BadgeVariantProps["variant"]>;
68
+ type BadgeIcon = NIconSource;
69
+ type BadgeProps = React.ComponentProps<"span"> & {
70
+ asChild?: boolean;
71
+ variant?: BadgeVariantProps["variant"];
72
+ status?: string;
73
+ statusMap?: Record<string, BadgeColor>;
74
+ label?: string;
75
+ showIcon?: boolean;
76
+ color?: BadgeColor;
77
+ look?: BadgeDisplayLook;
78
+ size?: BadgeSize;
79
+ shape?: BadgeShape;
80
+ icon?: BadgeIcon;
81
+ iconMap?: Record<string, BadgeIcon>;
82
+ iconPosition?: "left" | "right";
83
+ };
84
+ declare function Badge({ className, variant, status, statusMap, label, showIcon, color, look, size, shape, icon, iconMap, iconPosition, asChild, children, style, ...props }: BadgeProps): react_jsx_runtime.JSX.Element;
85
+ declare const NBadge: typeof Badge;
86
+ type NBadgeLook = BadgeDisplayLook;
87
+ type NBadgeProps = BadgeProps;
88
+
89
+ /**
90
+ * Application-wide presentation policy for `<NBadge status="…" />`.
91
+ *
92
+ * This is the whole reason a project ends up with a `StatusBadge` wrapper: the
93
+ * badge itself is already correct, but every call site has to repeat the same
94
+ * look, the same shape, and the same translation lookup. Declared once on the
95
+ * provider, none of that reaches a call site.
96
+ *
97
+ * What stays in the application: the vocabulary and the catalog. `statusMap`
98
+ * and `statusLabelKeys` take *its* status tokens and *its* catalog keys — this
99
+ * package ships neither.
100
+ */
101
+ interface NBadgeDefaults {
102
+ look?: NBadgeLook;
103
+ shape?: BadgeShape;
104
+ size?: BadgeSize;
105
+ showIcon?: boolean;
106
+ /** Status token to badge color. Merged over the packaged vocabulary. */
107
+ statusMap?: Record<string, BadgeColor>;
108
+ /** Badge color to icon, used when `showIcon` is on. */
109
+ iconMap?: Record<string, BadgeIcon>;
110
+ /** Status token to finished label text. Wins over `statusLabelKeys`. */
111
+ statusLabels?: Record<string, string>;
112
+ /** Status token to catalog key, resolved through the provider's `t`. */
113
+ statusLabelKeys?: Record<string, string>;
114
+ }
115
+
188
116
  /**
189
117
  * Theme and time zone, the two preferences that outlive a render.
190
118
  *
@@ -205,7 +133,7 @@ interface NajmPreferencesContextValue {
205
133
  }
206
134
  declare const DEFAULT_TIME_ZONE = "UTC";
207
135
  interface NajmPreferencesProviderProps {
208
- children: React$1.ReactNode;
136
+ children: React.ReactNode;
209
137
  /** Seeds theme state; ignored after mount. Defaults to `"light"`. */
210
138
  initialTheme?: NajmMode;
211
139
  /** Seeds time zone state; ignored after mount. Defaults to `"UTC"`. */
@@ -247,7 +175,7 @@ declare function useNajmTheme(): Pick<NajmPreferencesContextValue, "theme" | "se
247
175
  declare function useNajmTimeZone(): Pick<NajmPreferencesContextValue, "timeZone" | "setTimeZone">;
248
176
 
249
177
  interface NajmUIProviderProps extends Omit<NajmPreferencesProviderProps, "children"> {
250
- children: React$1.ReactNode;
178
+ children: React.ReactNode;
251
179
  /**
252
180
  * The design config handed to `NajmDesignProvider`, owned by the application.
253
181
  *
@@ -293,6 +221,14 @@ interface NajmUIProviderProps extends Omit<NajmPreferencesProviderProps, "childr
293
221
  * same reason as `t`.
294
222
  */
295
223
  tableDefaults?: NTableDefaults;
224
+ /**
225
+ * Presentation policy for `<NBadge status="…" />`: the look, the shape, and
226
+ * the map from the application's status tokens to its catalog keys.
227
+ *
228
+ * This is the prop that deletes a project's `StatusBadge` wrapper. Memoize it
229
+ * for the same reason as `t`.
230
+ */
231
+ badgeDefaults?: NBadgeDefaults;
296
232
  }
297
233
  /**
298
234
  * The one provider a Najm application mounts for UI concerns.
@@ -313,6 +249,6 @@ interface NajmUIProviderProps extends Omit<NajmPreferencesProviderProps, "childr
313
249
  * an application with a runtime theme editor hoist preferences above its
314
250
  * design context without forking this component.
315
251
  */
316
- declare function NajmUIProvider({ children, design, initialDesign, className, t, paginationKeyPrefix, tableDefaults, initialTheme, initialTimeZone, onThemeChange, onTimeZoneChange, normalizeTimeZone, }: NajmUIProviderProps): react_jsx_runtime.JSX.Element;
252
+ declare function NajmUIProvider({ children, design, initialDesign, className, t, paginationKeyPrefix, tableDefaults, badgeDefaults, initialTheme, initialTimeZone, onThemeChange, onTimeZoneChange, normalizeTimeZone, }: NajmUIProviderProps): react_jsx_runtime.JSX.Element;
317
253
 
318
- export { resolveRadiusValue as A, useNTableDefaults as B, useNajmPreferencesContext as C, DEFAULT_TIME_ZONE as D, useNajmTheme as E, useNajmTimeZone as F, type NajmUIProviderProps as N, RADIUS_VALUE_MAP as R, type NajmDesignConfig as a, type NajmThemeProviderProps as b, type NajmAppearance as c, type NajmMode as d, type NajmThemeConfig as e, type NajmAccent as f, type NajmThemeTokens as g, type NajmPreset as h, type NajmComponentName as i, type NajmComponentStyleConfig as j, type NajmComponentThemeConfig as k, type NajmTypographyConfig as l, type NajmLayoutConfig as m, type NajmVariantStyle as n, type NajmResponsiveBreakpoint as o, type NajmResponsiveValue as p, NAJM_COMPONENT_NAMES as q, type NTableDefaults as r, NTableDefaultsProvider as s, type NajmComponentRadius as t, type NajmDensity as u, type NajmPreferencesContextValue as v, NajmPreferencesProvider as w, type NajmPreferencesProviderProps as x, type NajmSlotStyle as y, NajmUIProvider as z };
254
+ export { type BadgeColor as B, DEFAULT_TIME_ZONE as D, type NajmUIProviderProps as N, type NIconSource as a, type BadgeShape as b, Badge as c, type BadgeIcon as d, type BadgeLook as e, type BadgeProps as f, type BadgeSize as g, type BadgeVariant as h, NBadge as i, type NBadgeDefaults as j, type NBadgeLook as k, type NBadgeProps as l, NIcon as m, type NIconProps as n, type NTableDefaults as o, NTableDefaultsProvider as p, type NajmPreferencesContextValue as q, NajmPreferencesProvider as r, type NajmPreferencesProviderProps as s, NajmUIProvider as t, badgeColorVariants as u, badgeVariants as v, useNTableDefaults as w, useNajmPreferencesContext as x, useNajmTheme as y, useNajmTimeZone as z };
@@ -4,8 +4,12 @@ import { F as FormDevToolsOptions, N as NBrandingInput } from '../formFill-BcH-m
4
4
  import { NajmNextUIProviderProps } from './next.js';
5
5
  import 'react';
6
6
  import 'zod';
7
- import '../NajmUIProvider-BSbXaqak.js';
7
+ import 'next/image';
8
+ import '../NajmUIProvider-BnReyojl.js';
9
+ import '../design-types-Rkpt8Pg1.js';
8
10
  import '../paginationLabels-dZLSNxfo.js';
11
+ import 'class-variance-authority/types';
12
+ import 'class-variance-authority';
9
13
 
10
14
  /** Branding shown by the kit's chrome. Purely presentational values. */
11
15
  interface NajmAppBranding {
@@ -1,7 +1,7 @@
1
1
  'use client';
2
- import { FormDevToolsProvider, NBrandingStateProvider, NajmFormatProvider } from '../chunk-GHMR45H3.mjs';
3
- import { NajmNextUIProvider } from '../chunk-IRFFSAO2.mjs';
4
- import '../chunk-USZUOJMK.mjs';
2
+ import { FormDevToolsProvider, NBrandingStateProvider, NajmFormatProvider } from '../chunk-HML2JZXT.mjs';
3
+ import { NajmNextUIProvider } from '../chunk-EUQOTPLV.mjs';
4
+ import '../chunk-FDONJASN.mjs';
5
5
  import '../chunk-KVZACF4G.mjs';
6
6
  import '../chunk-JABLSOQN.mjs';
7
7
  import * as React from 'react';
@@ -1,7 +1,11 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React__default from 'react';
3
- import { N as NajmUIProviderProps } from '../NajmUIProvider-BSbXaqak.js';
3
+ import { ImageProps } from 'next/image';
4
+ import { N as NajmUIProviderProps } from '../NajmUIProvider-BnReyojl.js';
5
+ import '../design-types-Rkpt8Pg1.js';
4
6
  import '../paginationLabels-dZLSNxfo.js';
7
+ import 'class-variance-authority/types';
8
+ import 'class-variance-authority';
5
9
 
6
10
  interface NextLinkAdapterProps extends Record<string, any> {
7
11
  href: string;
@@ -19,6 +23,28 @@ declare function useNextNavigationAdapter(): {
19
23
  push: (path: string) => void;
20
24
  replace: (path: string) => void;
21
25
  };
26
+ interface NNextImageProps extends Omit<ImageProps, 'src' | 'onError'> {
27
+ src: string;
28
+ /** Swapped in once `src` fails to load. Tried exactly once. */
29
+ fallbackSrc?: string;
30
+ onError?: ImageProps['onError'];
31
+ }
32
+ /**
33
+ * `next/image` with the fallback behavior of `NImage`, for applications that
34
+ * want the optimizer, the layout reservation, and `fill`/`sizes`.
35
+ *
36
+ * Lives only in `najm-kit/next`. The root entry must stay installable without
37
+ * Next, which is why this cannot be a prop on `NImage`.
38
+ *
39
+ * It classifies nothing. An application that serves an asset from a route the
40
+ * browser must reach directly — an authenticated one, say — passes
41
+ * `unoptimized` at the call site, because whether a route is protected is the
42
+ * application's fact and not something a URL shape can be read for. Note also
43
+ * what `unoptimized` is not: it changes delivery mechanics only. Session
44
+ * validation, permissions, and what bytes come back remain entirely the
45
+ * backend's.
46
+ */
47
+ declare function NNextImage({ src, fallbackSrc, loading, priority, onError, ...props }: NNextImageProps): react_jsx_runtime.JSX.Element;
22
48
  /** Where `NajmNextUIProvider` POSTs each preference. */
23
49
  interface NajmNextUIEndpoints {
24
50
  /** Defaults to `/api/ui-theme`. Receives `{ theme }`. */
@@ -49,4 +75,4 @@ interface NajmNextUIProviderProps extends Omit<NajmUIProviderProps, 'onThemeChan
49
75
  */
50
76
  declare function NajmNextUIProvider({ endpoints, refreshOnChange, ...props }: NajmNextUIProviderProps): react_jsx_runtime.JSX.Element;
51
77
 
52
- export { type NajmNextUIEndpoints, NajmNextUIProvider, type NajmNextUIProviderProps, NextLinkAdapter, type NextLinkAdapterProps, useNextNavigationAdapter };
78
+ export { NNextImage, type NNextImageProps, type NajmNextUIEndpoints, NajmNextUIProvider, type NajmNextUIProviderProps, NextLinkAdapter, type NextLinkAdapterProps, useNextNavigationAdapter };
@@ -1,3 +1,3 @@
1
- export { NajmNextUIProvider, NextLinkAdapter, useNextNavigationAdapter } from '../chunk-IRFFSAO2.mjs';
2
- import '../chunk-USZUOJMK.mjs';
1
+ export { NNextImage, NajmNextUIProvider, NextLinkAdapter, useNextNavigationAdapter } from '../chunk-EUQOTPLV.mjs';
2
+ import '../chunk-FDONJASN.mjs';
3
3
  import '../chunk-KVZACF4G.mjs';
@@ -0,0 +1,75 @@
1
+ // src/server/uiBootstrap.ts
2
+ var MISSING = Symbol("najm-kit/server: missing envelope");
3
+ function isRecord(value) {
4
+ return typeof value === "object" && value !== null;
5
+ }
6
+ function selectData(payload) {
7
+ return isRecord(payload) && "data" in payload ? payload.data : MISSING;
8
+ }
9
+ function describeThrown(value) {
10
+ return value instanceof Error ? `${value.name}: ${value.message}` : `non-error thrown: ${typeof value}`;
11
+ }
12
+ function createUiBootstrapLoader(config) {
13
+ const { fetcher, resources, onDiagnostic } = config;
14
+ const selectEnvelope = config.select ?? selectData;
15
+ const names = Object.keys(resources);
16
+ const report = (diagnostic) => {
17
+ if (!onDiagnostic) return;
18
+ try {
19
+ onDiagnostic(diagnostic);
20
+ } catch {
21
+ }
22
+ };
23
+ async function loadOne(name) {
24
+ const resource = resources[name];
25
+ const { path } = resource;
26
+ const select = resource.select ?? selectEnvelope;
27
+ const fail = (reason, detail = {}) => {
28
+ report({ resource: name, reason, path, ...detail });
29
+ return resource.fallback();
30
+ };
31
+ let response;
32
+ try {
33
+ response = await fetcher(path);
34
+ } catch (cause) {
35
+ return fail("fetch-failed", { error: describeThrown(cause) });
36
+ }
37
+ if (!response.ok) return fail("response-not-ok", { status: response.status });
38
+ let payload;
39
+ try {
40
+ payload = await response.json();
41
+ } catch (cause) {
42
+ return fail("invalid-json", { error: describeThrown(cause) });
43
+ }
44
+ let data;
45
+ try {
46
+ data = select(payload);
47
+ } catch (cause) {
48
+ return fail("invalid-envelope", { error: describeThrown(cause) });
49
+ }
50
+ if (data === MISSING) return fail("invalid-envelope");
51
+ try {
52
+ const parsed = resource.parse(data);
53
+ if (parsed !== void 0) return parsed;
54
+ } catch (cause) {
55
+ return fail("invalid-payload", { error: describeThrown(cause) });
56
+ }
57
+ return fail("invalid-payload");
58
+ }
59
+ const loaders = Object.fromEntries(
60
+ names.map((name) => [name, () => loadOne(name)])
61
+ );
62
+ async function load() {
63
+ const pending = names.map((name) => loadOne(name));
64
+ const settled = await Promise.all(pending);
65
+ const snapshot = {};
66
+ names.forEach((name, index) => {
67
+ snapshot[name] = settled[index];
68
+ });
69
+ Object.freeze(snapshot);
70
+ return snapshot;
71
+ }
72
+ return { load, loadResource: (name) => loaders[name](), loaders };
73
+ }
74
+
75
+ export { createUiBootstrapLoader };
@@ -1,6 +1,7 @@
1
- import { NajmUIProvider } from './chunk-USZUOJMK.mjs';
1
+ import { useImageChain, normalizeImageSources, NajmUIProvider } from './chunk-FDONJASN.mjs';
2
2
  import React from 'react';
3
3
  import { useRouter } from 'next/navigation';
4
+ import NextImage from 'next/image';
4
5
  import { jsx } from 'react/jsx-runtime';
5
6
 
6
7
  function NextLinkAdapter({ children, ...props }) {
@@ -21,6 +22,29 @@ function useNextNavigationAdapter() {
21
22
  }
22
23
  };
23
24
  }
25
+ function NNextImage({
26
+ src,
27
+ fallbackSrc,
28
+ loading,
29
+ priority,
30
+ onError,
31
+ ...props
32
+ }) {
33
+ const chain = useImageChain(normalizeImageSources([src, fallbackSrc]));
34
+ return /* @__PURE__ */ jsx(
35
+ NextImage,
36
+ {
37
+ ...props,
38
+ priority,
39
+ loading: loading ?? (priority ? void 0 : "lazy"),
40
+ src: chain.src ?? src,
41
+ onError: (event) => {
42
+ chain.markFailed();
43
+ onError?.(event);
44
+ }
45
+ }
46
+ );
47
+ }
24
48
  var DEFAULT_THEME_ENDPOINT = "/api/ui-theme";
25
49
  var DEFAULT_TIME_ZONE_ENDPOINT = "/api/ui-timezone";
26
50
  async function postPreference(endpoint, body) {
@@ -68,4 +92,4 @@ function NajmNextUIProvider({
68
92
  );
69
93
  }
70
94
 
71
- export { NajmNextUIProvider, NextLinkAdapter, useNextNavigationAdapter };
95
+ export { NNextImage, NajmNextUIProvider, NextLinkAdapter, useNextNavigationAdapter };