najm-kit 2.8.1 → 2.9.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/CHANGELOG.md +145 -109
- package/README.md +205 -5
- package/dist/{NajmUIProvider-BSbXaqak.d.ts → NajmUIProvider-CI_73GEp.d.ts} +5 -162
- package/dist/adapters/app.d.ts +2 -1
- package/dist/adapters/next.d.ts +2 -1
- package/dist/chunk-7H6NFBQT.mjs +75 -0
- package/dist/chunk-BEGOH366.mjs +12 -0
- package/dist/chunk-JUYT2ISO.mjs +404 -0
- package/dist/{chunk-6OOBAEH2.mjs → chunk-TFHWLE7N.mjs} +1 -403
- package/dist/design-config-D_x1GCu3.d.ts +17 -0
- package/dist/design-types-Rkpt8Pg1.d.ts +159 -0
- package/dist/index.d.ts +5 -17
- package/dist/index.mjs +7 -14
- package/dist/json.mjs +3 -2
- package/dist/person-images.d.ts +98 -0
- package/dist/person-images.mjs +86 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.mjs +2 -0
- package/dist/server/react.d.ts +16 -0
- package/dist/server/react.mjs +23 -0
- package/dist/server/reactClientGuard.d.ts +2 -0
- package/dist/server/reactClientGuard.mjs +4 -0
- package/dist/uiBootstrap-Ci6K5j5t.d.ts +93 -0
- package/package.json +21 -2
|
@@ -1,166 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as 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
|
|
|
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;
|
|
163
|
-
|
|
164
7
|
/**
|
|
165
8
|
* Defaults every `NTable` beneath the provider inherits.
|
|
166
9
|
*
|
|
@@ -205,7 +48,7 @@ interface NajmPreferencesContextValue {
|
|
|
205
48
|
}
|
|
206
49
|
declare const DEFAULT_TIME_ZONE = "UTC";
|
|
207
50
|
interface NajmPreferencesProviderProps {
|
|
208
|
-
children: React
|
|
51
|
+
children: React.ReactNode;
|
|
209
52
|
/** Seeds theme state; ignored after mount. Defaults to `"light"`. */
|
|
210
53
|
initialTheme?: NajmMode;
|
|
211
54
|
/** Seeds time zone state; ignored after mount. Defaults to `"UTC"`. */
|
|
@@ -247,7 +90,7 @@ declare function useNajmTheme(): Pick<NajmPreferencesContextValue, "theme" | "se
|
|
|
247
90
|
declare function useNajmTimeZone(): Pick<NajmPreferencesContextValue, "timeZone" | "setTimeZone">;
|
|
248
91
|
|
|
249
92
|
interface NajmUIProviderProps extends Omit<NajmPreferencesProviderProps, "children"> {
|
|
250
|
-
children: React
|
|
93
|
+
children: React.ReactNode;
|
|
251
94
|
/**
|
|
252
95
|
* The design config handed to `NajmDesignProvider`, owned by the application.
|
|
253
96
|
*
|
|
@@ -315,4 +158,4 @@ interface NajmUIProviderProps extends Omit<NajmPreferencesProviderProps, "childr
|
|
|
315
158
|
*/
|
|
316
159
|
declare function NajmUIProvider({ children, design, initialDesign, className, t, paginationKeyPrefix, tableDefaults, initialTheme, initialTimeZone, onThemeChange, onTimeZoneChange, normalizeTimeZone, }: NajmUIProviderProps): react_jsx_runtime.JSX.Element;
|
|
317
160
|
|
|
318
|
-
export {
|
|
161
|
+
export { DEFAULT_TIME_ZONE as D, type NajmUIProviderProps as N, type NTableDefaults as a, NTableDefaultsProvider as b, type NajmPreferencesContextValue as c, NajmPreferencesProvider as d, type NajmPreferencesProviderProps as e, NajmUIProvider as f, useNajmPreferencesContext as g, useNajmTheme as h, useNajmTimeZone as i, useNTableDefaults as u };
|
package/dist/adapters/app.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ 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-
|
|
7
|
+
import '../NajmUIProvider-CI_73GEp.js';
|
|
8
|
+
import '../design-types-Rkpt8Pg1.js';
|
|
8
9
|
import '../paginationLabels-dZLSNxfo.js';
|
|
9
10
|
|
|
10
11
|
/** Branding shown by the kit's chrome. Purely presentational values. */
|
package/dist/adapters/next.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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-
|
|
3
|
+
import { N as NajmUIProviderProps } from '../NajmUIProvider-CI_73GEp.js';
|
|
4
|
+
import '../design-types-Rkpt8Pg1.js';
|
|
4
5
|
import '../paginationLabels-dZLSNxfo.js';
|
|
5
6
|
|
|
6
7
|
interface NextLinkAdapterProps extends Record<string, any> {
|
|
@@ -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 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/lib/avatar.ts
|
|
2
|
+
var PLACEHOLDER_AVATAR = /(^|\/)noavatar\.png(?:$|[?#])/i;
|
|
3
|
+
function isPlaceholderAvatar(src) {
|
|
4
|
+
const trimmed = src?.trim() ?? "";
|
|
5
|
+
return !trimmed || PLACEHOLDER_AVATAR.test(trimmed);
|
|
6
|
+
}
|
|
7
|
+
function resolveAvatarSrc(src, fallback) {
|
|
8
|
+
const trimmed = src?.trim() ?? "";
|
|
9
|
+
return trimmed && !PLACEHOLDER_AVATAR.test(trimmed) ? trimmed : fallback;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { isPlaceholderAvatar, resolveAvatarSrc };
|