najm-kit 2.11.12 → 2.11.14
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 +388 -350
- package/README.md +1195 -1032
- package/dist/{NajmUIProvider-DSjvh4x2.d.ts → NajmUIProvider-BwL5HFIV.d.ts} +17 -4
- package/dist/adapters/app.d.ts +15 -3
- package/dist/adapters/app.mjs +8 -4
- package/dist/adapters/next.d.ts +2 -2
- package/dist/adapters/next.mjs +2 -2
- package/dist/{chunk-56JQI3VL.mjs → chunk-26EASWUY.mjs} +1 -1
- package/dist/{chunk-3J24TPLA.mjs → chunk-BDQK6ECA.mjs} +100 -94
- package/dist/{chunk-VSK75GSS.mjs → chunk-DKHIQFXX.mjs} +1 -1
- package/dist/chunk-XGIYOEWD.mjs +28 -0
- package/dist/{design-config-D_x1GCu3.d.ts → design-config-CL9vqqQ9.d.ts} +1 -1
- package/dist/{design-types-Rkpt8Pg1.d.ts → design-types-DffH_9XC.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +6 -29
- package/dist/server/index.d.ts +160 -3
- package/dist/server/index.mjs +129 -0
- package/dist/server/react.d.ts +2 -2
- package/dist/{uiBootstrap-Ci6K5j5t.d.ts → uiBootstrap-C66AFCo_.d.ts} +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { b as NajmMode, N as NajmDesignConfig } from './design-types-DffH_9XC.js';
|
|
4
4
|
import { b as NTablePaginationLabels, N as NajmTranslate } from './paginationLabels-dZLSNxfo.js';
|
|
5
5
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
6
|
import { VariantProps } from 'class-variance-authority';
|
|
@@ -217,11 +217,24 @@ interface NFeedbackDefaults {
|
|
|
217
217
|
*/
|
|
218
218
|
labelKeys?: NFeedbackLabelKeys;
|
|
219
219
|
/**
|
|
220
|
-
* Catalog prefix for translated keys
|
|
221
|
-
* Defaults to
|
|
220
|
+
* Catalog prefix for translated keys, read as `<prefix>.<field>` for every
|
|
221
|
+
* field `labelKeys` does not name explicitly. Defaults to
|
|
222
|
+
* `"common.feedback"`, so an application whose catalog follows the
|
|
223
|
+
* convention supplies no `feedbackDefaults` at all.
|
|
224
|
+
*
|
|
225
|
+
* A prefix key the catalog does not answer falls through to packaged
|
|
226
|
+
* English rather than rendering the key.
|
|
222
227
|
*/
|
|
223
228
|
prefix?: string;
|
|
224
229
|
}
|
|
230
|
+
declare const DEFAULT_FEEDBACK_KEY_PREFIX = "common.feedback";
|
|
231
|
+
type DefaultFeedbackPrefix = typeof DEFAULT_FEEDBACK_KEY_PREFIX;
|
|
232
|
+
/**
|
|
233
|
+
* The nine catalog keys the feedback states read under `Prefix`, matching the
|
|
234
|
+
* `ToolbarKey` and `CardPaginationKey` conventions — same prefix, same
|
|
235
|
+
* key-per-field naming.
|
|
236
|
+
*/
|
|
237
|
+
type FeedbackKey<Prefix extends string = DefaultFeedbackPrefix> = `${Prefix}.loadingLabel` | `${Prefix}.emptyTitle` | `${Prefix}.errorTitle` | `${Prefix}.errorMessage` | `${Prefix}.retryLabel` | `${Prefix}.forbiddenTitle` | `${Prefix}.forbiddenDescription` | `${Prefix}.notFoundTitle` | `${Prefix}.notFoundDescription`;
|
|
225
238
|
|
|
226
239
|
/**
|
|
227
240
|
* Theme and time zone, the two preferences that outlive a render.
|
|
@@ -413,4 +426,4 @@ interface NajmUIProviderProps extends Omit<NajmPreferencesProviderProps, "childr
|
|
|
413
426
|
*/
|
|
414
427
|
declare function NajmUIProvider({ children, design, initialDesign, className, t, paginationKeyPrefix, toolbarKeyPrefix, dir, tableDefaults, badgeDefaults, feedbackDefaults, initialTheme, initialTimeZone, onThemeChange, onTimeZoneChange, normalizeTimeZone, }: NajmUIProviderProps): React.JSX.Element;
|
|
415
428
|
|
|
416
|
-
export {
|
|
429
|
+
export { badgeVariants as A, type BadgeColor as B, useDocumentDirection as C, DEFAULT_FEEDBACK_KEY_PREFIX as D, useNTableDefaults as E, type FeedbackKey as F, useNajmPreferencesContext as G, useNajmTheme as H, useNajmTimeZone as I, useResolvedToolbarLabels as J, type NFeedbackDefaults as N, type NFeedbackLabelKeys as a, type NFeedbackLabels as b, type NajmUIProviderProps as c, type NTableToolbarLabels as d, type NIconSource as e, type BadgeShape as f, Badge as g, type BadgeIcon as h, type BadgeLook as i, type BadgeProps as j, type BadgeSize as k, type BadgeVariant as l, DEFAULT_TIME_ZONE as m, NBadge as n, type NBadgeDefaults as o, type NBadgeLook as p, type NBadgeProps as q, NIcon as r, type NIconProps as s, type NTableDefaults as t, NTableDefaultsProvider as u, type NajmPreferencesContextValue as v, NajmPreferencesProvider as w, type NajmPreferencesProviderProps as x, NajmUIProvider as y, badgeColorVariants as z };
|
package/dist/adapters/app.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import { Translations } from 'najm-i18n';
|
|
|
3
3
|
import { F as FormDevToolsOptions, N as NBrandingInput } from '../NNotFoundState-CgU76llk.js';
|
|
4
4
|
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-CgU76llk.js';
|
|
5
5
|
import { NajmNextUIProviderProps } from './next.js';
|
|
6
|
-
export { N as NFeedbackDefaults, a as NFeedbackLabelKeys, b as NFeedbackLabels } from '../NajmUIProvider-
|
|
6
|
+
export { D as DEFAULT_FEEDBACK_KEY_PREFIX, F as FeedbackKey, N as NFeedbackDefaults, a as NFeedbackLabelKeys, b as NFeedbackLabels } from '../NajmUIProvider-BwL5HFIV.js';
|
|
7
7
|
import 'zod';
|
|
8
8
|
import 'lucide-react';
|
|
9
9
|
import 'next/image';
|
|
10
|
-
import '../design-types-
|
|
10
|
+
import '../design-types-DffH_9XC.js';
|
|
11
11
|
import '../paginationLabels-dZLSNxfo.js';
|
|
12
12
|
import 'class-variance-authority/types';
|
|
13
13
|
import 'class-variance-authority';
|
|
@@ -33,6 +33,18 @@ interface NajmAppProviderProps extends Omit<NajmNextUIProviderProps, 't'> {
|
|
|
33
33
|
translations?: Translations;
|
|
34
34
|
initialLanguage?: string;
|
|
35
35
|
defaultLanguage?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Resolves a key missing from the active language against `defaultLanguage`
|
|
38
|
+
* instead of echoing the key. Forwarded to `najm-i18n`'s `I18nProvider`; see
|
|
39
|
+
* that package's "Missing-key fallback" for the full matrix.
|
|
40
|
+
*
|
|
41
|
+
* Off by default, matching the package. An application shipping an
|
|
42
|
+
* incomplete locale beside a complete one turns it on here rather than
|
|
43
|
+
* pre-merging its catalogs.
|
|
44
|
+
*/
|
|
45
|
+
fallbackToDefaultLanguage?: boolean;
|
|
46
|
+
/** Maps a language to the writing direction applied to `<html>`. */
|
|
47
|
+
getLanguageDirection?: (language: string) => 'ltr' | 'rtl';
|
|
36
48
|
/**
|
|
37
49
|
* Where the chosen language is POSTed, as `{ language }`. Defaults to
|
|
38
50
|
* `/api/ui-language`.
|
|
@@ -110,6 +122,6 @@ interface NajmAppProviderProps extends Omit<NajmNextUIProviderProps, 't'> {
|
|
|
110
122
|
* state machine of its own above this provider. The controlled `design` and
|
|
111
123
|
* `branding` props still work for applications that already do.
|
|
112
124
|
*/
|
|
113
|
-
declare function NajmAppProvider({ translations, initialLanguage, defaultLanguage, languageEndpoint, appName, initialBranding, formDevTools, ...props }: NajmAppProviderProps): React.JSX.Element;
|
|
125
|
+
declare function NajmAppProvider({ translations, initialLanguage, defaultLanguage, fallbackToDefaultLanguage, getLanguageDirection, languageEndpoint, appName, initialBranding, formDevTools, ...props }: NajmAppProviderProps): React.JSX.Element;
|
|
114
126
|
|
|
115
127
|
export { type NajmAppBranding, NajmAppProvider, type NajmAppProviderProps };
|
package/dist/adapters/app.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { FormDevToolsProvider, NBrandingStateProvider, NajmFormatProvider } from '../chunk-
|
|
3
|
-
export { NEmptyState, NErrorState, NForbiddenState, NLoadingState, NNotFoundState } from '../chunk-
|
|
4
|
-
import { NajmNextUIProvider } from '../chunk-
|
|
5
|
-
|
|
2
|
+
import { FormDevToolsProvider, NBrandingStateProvider, NajmFormatProvider } from '../chunk-26EASWUY.mjs';
|
|
3
|
+
export { NEmptyState, NErrorState, NForbiddenState, NLoadingState, NNotFoundState } from '../chunk-26EASWUY.mjs';
|
|
4
|
+
import { NajmNextUIProvider } from '../chunk-DKHIQFXX.mjs';
|
|
5
|
+
export { DEFAULT_FEEDBACK_KEY_PREFIX } from '../chunk-BDQK6ECA.mjs';
|
|
6
6
|
import '../chunk-M5VGBZ7R.mjs';
|
|
7
7
|
import '../chunk-LK3SMYUP.mjs';
|
|
8
8
|
import '../chunk-JABLSOQN.mjs';
|
|
@@ -72,6 +72,8 @@ function NajmAppProvider({
|
|
|
72
72
|
translations,
|
|
73
73
|
initialLanguage,
|
|
74
74
|
defaultLanguage,
|
|
75
|
+
fallbackToDefaultLanguage,
|
|
76
|
+
getLanguageDirection,
|
|
75
77
|
languageEndpoint = DEFAULT_LANGUAGE_ENDPOINT,
|
|
76
78
|
appName,
|
|
77
79
|
initialBranding,
|
|
@@ -104,6 +106,8 @@ function NajmAppProvider({
|
|
|
104
106
|
translations,
|
|
105
107
|
initialLanguage: initialLanguage ?? defaultLanguage ?? "en",
|
|
106
108
|
defaultLanguage,
|
|
109
|
+
fallbackToDefaultLanguage,
|
|
110
|
+
getLanguageDirection,
|
|
107
111
|
onLanguageChange: persistLanguage,
|
|
108
112
|
children: /* @__PURE__ */ jsx(NajmAppUI, { ...props, initialBranding: seeded })
|
|
109
113
|
}
|
package/dist/adapters/next.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { ImageProps } from 'next/image';
|
|
3
|
-
import { c as NajmUIProviderProps } from '../NajmUIProvider-
|
|
4
|
-
import '../design-types-
|
|
3
|
+
import { c as NajmUIProviderProps } from '../NajmUIProvider-BwL5HFIV.js';
|
|
4
|
+
import '../design-types-DffH_9XC.js';
|
|
5
5
|
import '../paginationLabels-dZLSNxfo.js';
|
|
6
6
|
import 'class-variance-authority/types';
|
|
7
7
|
import 'class-variance-authority';
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { NNextImage, NajmNextUIProvider, NextLinkAdapter, useNextNavigationAdapter } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { NNextImage, NajmNextUIProvider, NextLinkAdapter, useNextNavigationAdapter } from '../chunk-DKHIQFXX.mjs';
|
|
2
|
+
import '../chunk-BDQK6ECA.mjs';
|
|
3
3
|
import '../chunk-LK3SMYUP.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useResolvedFeedbackLabels, useNajmPreferencesContext } from './chunk-
|
|
1
|
+
import { useResolvedFeedbackLabels, useNajmPreferencesContext } from './chunk-BDQK6ECA.mjs';
|
|
2
2
|
import { Button } from './chunk-M5VGBZ7R.mjs';
|
|
3
3
|
import { useNajmDesign, cn } from './chunk-LK3SMYUP.mjs';
|
|
4
4
|
import { humanizeToken, DEFAULT_PLACEHOLDER, formatRelativeTime, formatTime, formatDateTime, formatDate, formatPercent, formatNumber, formatCurrency } from './chunk-JABLSOQN.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NajmDesignProvider, cn } from './chunk-LK3SMYUP.mjs';
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
2
|
+
import * as React3 from 'react';
|
|
3
|
+
import React3__default from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
import { DirectionProvider } from '@radix-ui/react-direction';
|
|
6
6
|
|
|
@@ -74,7 +74,7 @@ function statusTextClass(status, statusMap, fallback) {
|
|
|
74
74
|
const color = findStatusColor(status, statusMap) ?? fallback;
|
|
75
75
|
return color ? colorTextClass(color) : "";
|
|
76
76
|
}
|
|
77
|
-
var NTableDefaultsContext =
|
|
77
|
+
var NTableDefaultsContext = React3__default.createContext({});
|
|
78
78
|
function NTableDefaultsProvider({
|
|
79
79
|
children,
|
|
80
80
|
value
|
|
@@ -82,12 +82,12 @@ function NTableDefaultsProvider({
|
|
|
82
82
|
return /* @__PURE__ */ jsx(NTableDefaultsContext.Provider, { value, children });
|
|
83
83
|
}
|
|
84
84
|
function useNTableDefaults() {
|
|
85
|
-
return
|
|
85
|
+
return React3__default.useContext(NTableDefaultsContext);
|
|
86
86
|
}
|
|
87
87
|
function useResolvedPaginationLabels(own) {
|
|
88
88
|
const defaults = useNTableDefaults();
|
|
89
89
|
const inherited = defaults.paginationLabels;
|
|
90
|
-
return
|
|
90
|
+
return React3__default.useMemo(
|
|
91
91
|
() => ({ ...inherited, ...own }),
|
|
92
92
|
[inherited, own]
|
|
93
93
|
);
|
|
@@ -95,12 +95,72 @@ function useResolvedPaginationLabels(own) {
|
|
|
95
95
|
function useResolvedToolbarLabels(own) {
|
|
96
96
|
const defaults = useNTableDefaults();
|
|
97
97
|
const inherited = defaults.toolbarLabels;
|
|
98
|
-
return
|
|
98
|
+
return React3__default.useMemo(
|
|
99
99
|
() => ({ ...inherited, ...own }),
|
|
100
100
|
[inherited, own]
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
|
-
var
|
|
103
|
+
var ENGLISH_FEEDBACK_LABELS = {
|
|
104
|
+
loadingLabel: "Loading...",
|
|
105
|
+
emptyTitle: "No data",
|
|
106
|
+
errorTitle: "Something went wrong",
|
|
107
|
+
retryLabel: "Try again",
|
|
108
|
+
forbiddenTitle: "Access denied",
|
|
109
|
+
forbiddenDescription: "You do not have permission to view this page.",
|
|
110
|
+
notFoundTitle: "Page not found",
|
|
111
|
+
notFoundDescription: "The requested page could not be found."
|
|
112
|
+
};
|
|
113
|
+
var NFeedbackDefaultsContext = React3.createContext(null);
|
|
114
|
+
function NFeedbackDefaultsProvider({
|
|
115
|
+
value,
|
|
116
|
+
children
|
|
117
|
+
}) {
|
|
118
|
+
return /* @__PURE__ */ jsx(NFeedbackDefaultsContext.Provider, { value, children });
|
|
119
|
+
}
|
|
120
|
+
function useNFeedbackDefaults() {
|
|
121
|
+
return React3.useContext(NFeedbackDefaultsContext);
|
|
122
|
+
}
|
|
123
|
+
var DEFAULT_FEEDBACK_KEY_PREFIX = "common.feedback";
|
|
124
|
+
function useResolvedFeedbackLabels() {
|
|
125
|
+
const ctx = useNFeedbackDefaults();
|
|
126
|
+
return React3.useMemo(() => resolveFeedbackLabels(ctx), [ctx]);
|
|
127
|
+
}
|
|
128
|
+
function resolveFeedbackLabels(ctx) {
|
|
129
|
+
const defaults = ctx?.defaults;
|
|
130
|
+
const t = ctx?.t;
|
|
131
|
+
const labels = defaults?.labels;
|
|
132
|
+
const labelKeys = defaults?.labelKeys;
|
|
133
|
+
const prefix = defaults?.prefix ?? DEFAULT_FEEDBACK_KEY_PREFIX;
|
|
134
|
+
const translated = (key) => {
|
|
135
|
+
if (!t) return void 0;
|
|
136
|
+
const value = t(key);
|
|
137
|
+
return value === key ? void 0 : value;
|
|
138
|
+
};
|
|
139
|
+
const pick = (field, hasFallback) => {
|
|
140
|
+
const literal = labels?.[field];
|
|
141
|
+
if (literal !== void 0) return literal;
|
|
142
|
+
const key = labelKeys?.[field];
|
|
143
|
+
const fromCatalog = translated(key ?? `${prefix}.${field}`);
|
|
144
|
+
if (fromCatalog !== void 0) return fromCatalog;
|
|
145
|
+
if (hasFallback) return ENGLISH_FEEDBACK_LABELS[field];
|
|
146
|
+
return void 0;
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
loadingLabel: pick("loadingLabel", true) ?? ENGLISH_FEEDBACK_LABELS.loadingLabel,
|
|
150
|
+
emptyTitle: pick("emptyTitle", true) ?? ENGLISH_FEEDBACK_LABELS.emptyTitle,
|
|
151
|
+
errorTitle: pick("errorTitle", true) ?? ENGLISH_FEEDBACK_LABELS.errorTitle,
|
|
152
|
+
errorMessage: pick("errorMessage", false),
|
|
153
|
+
retryLabel: pick("retryLabel", true) ?? ENGLISH_FEEDBACK_LABELS.retryLabel,
|
|
154
|
+
forbiddenTitle: pick("forbiddenTitle", true) ?? ENGLISH_FEEDBACK_LABELS.forbiddenTitle,
|
|
155
|
+
forbiddenDescription: pick("forbiddenDescription", true) ?? ENGLISH_FEEDBACK_LABELS.forbiddenDescription,
|
|
156
|
+
notFoundTitle: pick("notFoundTitle", true) ?? ENGLISH_FEEDBACK_LABELS.notFoundTitle,
|
|
157
|
+
notFoundDescription: pick("notFoundDescription", true) ?? ENGLISH_FEEDBACK_LABELS.notFoundDescription
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function resolveFeedbackDefaultsValue(defaults, t) {
|
|
161
|
+
return { defaults: defaults ?? {}, t };
|
|
162
|
+
}
|
|
163
|
+
var NajmPreferencesContext = React3.createContext(null);
|
|
104
164
|
var DEFAULT_TIME_ZONE = "UTC";
|
|
105
165
|
function isValidTimeZone(value) {
|
|
106
166
|
try {
|
|
@@ -129,44 +189,44 @@ function NajmPreferencesProvider({
|
|
|
129
189
|
onTimeZoneChange,
|
|
130
190
|
normalizeTimeZone = defaultNormalizeTimeZone
|
|
131
191
|
}) {
|
|
132
|
-
const [theme, setThemeState] =
|
|
133
|
-
const [timeZone, setTimeZoneState] =
|
|
192
|
+
const [theme, setThemeState] = React3.useState(initialTheme);
|
|
193
|
+
const [timeZone, setTimeZoneState] = React3.useState(
|
|
134
194
|
() => normalizeTimeZone(initialTimeZone)
|
|
135
195
|
);
|
|
136
|
-
const onThemeChangeRef =
|
|
137
|
-
const onTimeZoneChangeRef =
|
|
138
|
-
const normalizeRef =
|
|
139
|
-
|
|
196
|
+
const onThemeChangeRef = React3.useRef(onThemeChange);
|
|
197
|
+
const onTimeZoneChangeRef = React3.useRef(onTimeZoneChange);
|
|
198
|
+
const normalizeRef = React3.useRef(normalizeTimeZone);
|
|
199
|
+
React3.useEffect(() => {
|
|
140
200
|
onThemeChangeRef.current = onThemeChange;
|
|
141
201
|
onTimeZoneChangeRef.current = onTimeZoneChange;
|
|
142
202
|
normalizeRef.current = normalizeTimeZone;
|
|
143
203
|
});
|
|
144
|
-
|
|
204
|
+
React3.useEffect(() => {
|
|
145
205
|
applyTheme(theme);
|
|
146
206
|
applyTimeZone(timeZone);
|
|
147
207
|
}, []);
|
|
148
|
-
const setTheme =
|
|
208
|
+
const setTheme = React3.useCallback(async (next) => {
|
|
149
209
|
setThemeState(next);
|
|
150
210
|
applyTheme(next);
|
|
151
211
|
await onThemeChangeRef.current?.(next);
|
|
152
212
|
}, []);
|
|
153
|
-
const setTimeZone =
|
|
213
|
+
const setTimeZone = React3.useCallback(async (next) => {
|
|
154
214
|
const normalized = normalizeRef.current(next);
|
|
155
215
|
setTimeZoneState(normalized);
|
|
156
216
|
applyTimeZone(normalized);
|
|
157
217
|
await onTimeZoneChangeRef.current?.(normalized);
|
|
158
218
|
}, []);
|
|
159
|
-
const value =
|
|
219
|
+
const value = React3.useMemo(
|
|
160
220
|
() => ({ theme, setTheme, timeZone, setTimeZone }),
|
|
161
221
|
[theme, setTheme, timeZone, setTimeZone]
|
|
162
222
|
);
|
|
163
223
|
return /* @__PURE__ */ jsx(NajmPreferencesContext.Provider, { value, children });
|
|
164
224
|
}
|
|
165
225
|
function useNajmPreferencesContext() {
|
|
166
|
-
return
|
|
226
|
+
return React3.useContext(NajmPreferencesContext);
|
|
167
227
|
}
|
|
168
228
|
function usePreferencesOrThrow(hook) {
|
|
169
|
-
const value =
|
|
229
|
+
const value = React3.useContext(NajmPreferencesContext);
|
|
170
230
|
if (!value) {
|
|
171
231
|
throw new Error(
|
|
172
232
|
`${hook} must be rendered under a NajmUIProvider or NajmPreferencesProvider.`
|
|
@@ -176,11 +236,11 @@ function usePreferencesOrThrow(hook) {
|
|
|
176
236
|
}
|
|
177
237
|
function useNajmTheme() {
|
|
178
238
|
const { theme, setTheme } = usePreferencesOrThrow("useNajmTheme");
|
|
179
|
-
return
|
|
239
|
+
return React3.useMemo(() => ({ theme, setTheme }), [theme, setTheme]);
|
|
180
240
|
}
|
|
181
241
|
function useNajmTimeZone() {
|
|
182
242
|
const { timeZone, setTimeZone } = usePreferencesOrThrow("useNajmTimeZone");
|
|
183
|
-
return
|
|
243
|
+
return React3.useMemo(
|
|
184
244
|
() => ({ timeZone, setTimeZone }),
|
|
185
245
|
[timeZone, setTimeZone]
|
|
186
246
|
);
|
|
@@ -225,10 +285,10 @@ function buildToolbarLabels(t, prefix) {
|
|
|
225
285
|
};
|
|
226
286
|
}
|
|
227
287
|
function useDocumentDirection(override) {
|
|
228
|
-
const [direction, setDirection] =
|
|
288
|
+
const [direction, setDirection] = React3.useState(
|
|
229
289
|
override ?? "ltr"
|
|
230
290
|
);
|
|
231
|
-
|
|
291
|
+
React3.useEffect(() => {
|
|
232
292
|
if (override) {
|
|
233
293
|
setDirection(override);
|
|
234
294
|
return;
|
|
@@ -247,9 +307,9 @@ var EMPTY_DESIGN = Object.freeze({
|
|
|
247
307
|
theme: {},
|
|
248
308
|
components: {}
|
|
249
309
|
});
|
|
250
|
-
var NajmDesignEditorContext =
|
|
310
|
+
var NajmDesignEditorContext = React3.createContext(null);
|
|
251
311
|
function useNajmDesignEditor() {
|
|
252
|
-
return
|
|
312
|
+
return React3.useContext(NajmDesignEditorContext);
|
|
253
313
|
}
|
|
254
314
|
function cloneDesign(design) {
|
|
255
315
|
return structuredClone(design);
|
|
@@ -259,29 +319,29 @@ function NajmDesignEditorProvider({
|
|
|
259
319
|
design,
|
|
260
320
|
initialDesign
|
|
261
321
|
}) {
|
|
262
|
-
const [state, setState] =
|
|
322
|
+
const [state, setState] = React3.useState(() => ({
|
|
263
323
|
committed: initialDesign ?? design ?? EMPTY_DESIGN,
|
|
264
324
|
draft: null
|
|
265
325
|
}));
|
|
266
|
-
const beginDraft =
|
|
326
|
+
const beginDraft = React3.useCallback(() => {
|
|
267
327
|
setState(
|
|
268
328
|
(current) => current.draft ? current : { ...current, draft: cloneDesign(current.committed) }
|
|
269
329
|
);
|
|
270
330
|
}, []);
|
|
271
|
-
const setDraft =
|
|
331
|
+
const setDraft = React3.useCallback((next) => {
|
|
272
332
|
setState((current) => ({ ...current, draft: cloneDesign(next) }));
|
|
273
333
|
}, []);
|
|
274
|
-
const cancelDraft =
|
|
334
|
+
const cancelDraft = React3.useCallback(() => {
|
|
275
335
|
setState(
|
|
276
336
|
(current) => current.draft === null ? current : { ...current, draft: null }
|
|
277
337
|
);
|
|
278
338
|
}, []);
|
|
279
|
-
const setCommitted =
|
|
339
|
+
const setCommitted = React3.useCallback((next) => {
|
|
280
340
|
setState(
|
|
281
341
|
(current) => current.committed === next && current.draft === null ? current : { committed: next, draft: null }
|
|
282
342
|
);
|
|
283
343
|
}, []);
|
|
284
|
-
const value =
|
|
344
|
+
const value = React3.useMemo(() => {
|
|
285
345
|
if (design) {
|
|
286
346
|
return {
|
|
287
347
|
design,
|
|
@@ -309,20 +369,20 @@ function NajmDesignEditorProvider({
|
|
|
309
369
|
}
|
|
310
370
|
function noop() {
|
|
311
371
|
}
|
|
312
|
-
var NBadgeDefaultsContext =
|
|
372
|
+
var NBadgeDefaultsContext = React3.createContext(null);
|
|
313
373
|
function NBadgeDefaultsProvider({
|
|
314
374
|
defaults,
|
|
315
375
|
t,
|
|
316
376
|
children
|
|
317
377
|
}) {
|
|
318
|
-
const value =
|
|
378
|
+
const value = React3.useMemo(
|
|
319
379
|
() => ({ defaults, t }),
|
|
320
380
|
[defaults, t]
|
|
321
381
|
);
|
|
322
382
|
return /* @__PURE__ */ jsx(NBadgeDefaultsContext.Provider, { value, children });
|
|
323
383
|
}
|
|
324
384
|
function useNBadgeDefaults() {
|
|
325
|
-
return
|
|
385
|
+
return React3.useContext(NBadgeDefaultsContext);
|
|
326
386
|
}
|
|
327
387
|
function resolveBadgeStatusLabel(status, defaults, t) {
|
|
328
388
|
if (!defaults) return void 0;
|
|
@@ -337,60 +397,6 @@ function mergeBadgeMaps(base, overrides) {
|
|
|
337
397
|
if (!overrides) return base;
|
|
338
398
|
return { ...base, ...overrides };
|
|
339
399
|
}
|
|
340
|
-
var ENGLISH_FEEDBACK_LABELS = {
|
|
341
|
-
loadingLabel: "Loading...",
|
|
342
|
-
emptyTitle: "No data",
|
|
343
|
-
errorTitle: "Something went wrong",
|
|
344
|
-
retryLabel: "Try again",
|
|
345
|
-
forbiddenTitle: "Access denied",
|
|
346
|
-
forbiddenDescription: "You do not have permission to view this page.",
|
|
347
|
-
notFoundTitle: "Page not found",
|
|
348
|
-
notFoundDescription: "The requested page could not be found."
|
|
349
|
-
};
|
|
350
|
-
var NFeedbackDefaultsContext = React2.createContext(null);
|
|
351
|
-
function NFeedbackDefaultsProvider({
|
|
352
|
-
value,
|
|
353
|
-
children
|
|
354
|
-
}) {
|
|
355
|
-
return /* @__PURE__ */ jsx(NFeedbackDefaultsContext.Provider, { value, children });
|
|
356
|
-
}
|
|
357
|
-
function useNFeedbackDefaults() {
|
|
358
|
-
return React2.useContext(NFeedbackDefaultsContext);
|
|
359
|
-
}
|
|
360
|
-
var DEFAULT_FEEDBACK_KEY_PREFIX = "common.feedback";
|
|
361
|
-
function useResolvedFeedbackLabels() {
|
|
362
|
-
const ctx = useNFeedbackDefaults();
|
|
363
|
-
return React2.useMemo(() => resolveFeedbackLabels(ctx), [ctx]);
|
|
364
|
-
}
|
|
365
|
-
function resolveFeedbackLabels(ctx) {
|
|
366
|
-
const defaults = ctx?.defaults;
|
|
367
|
-
const t = ctx?.t;
|
|
368
|
-
const labels = defaults?.labels;
|
|
369
|
-
const labelKeys = defaults?.labelKeys;
|
|
370
|
-
defaults?.prefix ?? DEFAULT_FEEDBACK_KEY_PREFIX;
|
|
371
|
-
const pick = (field, hasFallback) => {
|
|
372
|
-
const literal = labels?.[field];
|
|
373
|
-
if (literal !== void 0) return literal;
|
|
374
|
-
const key = labelKeys?.[field];
|
|
375
|
-
if (key && t) return t(key);
|
|
376
|
-
if (hasFallback) return ENGLISH_FEEDBACK_LABELS[field];
|
|
377
|
-
return void 0;
|
|
378
|
-
};
|
|
379
|
-
return {
|
|
380
|
-
loadingLabel: pick("loadingLabel", true) ?? ENGLISH_FEEDBACK_LABELS.loadingLabel,
|
|
381
|
-
emptyTitle: pick("emptyTitle", true) ?? ENGLISH_FEEDBACK_LABELS.emptyTitle,
|
|
382
|
-
errorTitle: pick("errorTitle", true) ?? ENGLISH_FEEDBACK_LABELS.errorTitle,
|
|
383
|
-
errorMessage: pick("errorMessage", false),
|
|
384
|
-
retryLabel: pick("retryLabel", true) ?? ENGLISH_FEEDBACK_LABELS.retryLabel,
|
|
385
|
-
forbiddenTitle: pick("forbiddenTitle", true) ?? ENGLISH_FEEDBACK_LABELS.forbiddenTitle,
|
|
386
|
-
forbiddenDescription: pick("forbiddenDescription", true) ?? ENGLISH_FEEDBACK_LABELS.forbiddenDescription,
|
|
387
|
-
notFoundTitle: pick("notFoundTitle", true) ?? ENGLISH_FEEDBACK_LABELS.notFoundTitle,
|
|
388
|
-
notFoundDescription: pick("notFoundDescription", true) ?? ENGLISH_FEEDBACK_LABELS.notFoundDescription
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
function resolveFeedbackDefaultsValue(defaults, t) {
|
|
392
|
-
return { defaults: defaults ?? {}, t };
|
|
393
|
-
}
|
|
394
400
|
function NajmUICore({
|
|
395
401
|
children,
|
|
396
402
|
className,
|
|
@@ -405,7 +411,7 @@ function NajmUICore({
|
|
|
405
411
|
const { theme } = useNajmTheme();
|
|
406
412
|
const direction = useDocumentDirection(dir);
|
|
407
413
|
const design = useNajmDesignEditor()?.design ?? EMPTY_DESIGN;
|
|
408
|
-
const defaults =
|
|
414
|
+
const defaults = React3.useMemo(() => {
|
|
409
415
|
const translated = t ? buildPaginationLabels(t, paginationKeyPrefix) : void 0;
|
|
410
416
|
const overrides = tableDefaults?.paginationLabels;
|
|
411
417
|
const paginationLabels = translated || overrides ? { ...translated, ...overrides } : void 0;
|
|
@@ -414,7 +420,7 @@ function NajmUICore({
|
|
|
414
420
|
const toolbarLabels = translatedToolbar || toolbarOverrides ? { ...translatedToolbar, ...toolbarOverrides } : void 0;
|
|
415
421
|
return { ...tableDefaults, paginationLabels, toolbarLabels };
|
|
416
422
|
}, [t, paginationKeyPrefix, toolbarKeyPrefix, tableDefaults]);
|
|
417
|
-
const feedbackValue =
|
|
423
|
+
const feedbackValue = React3.useMemo(
|
|
418
424
|
() => resolveFeedbackDefaultsValue(feedbackDefaults, t),
|
|
419
425
|
[feedbackDefaults, t]
|
|
420
426
|
);
|
|
@@ -499,7 +505,7 @@ function selectImageSource(sources, failed) {
|
|
|
499
505
|
var NO_FAILURES = [];
|
|
500
506
|
function useImageChain(sources) {
|
|
501
507
|
const key = JSON.stringify(sources);
|
|
502
|
-
const [state, setState] =
|
|
508
|
+
const [state, setState] = React3.useState(() => ({
|
|
503
509
|
key,
|
|
504
510
|
failed: NO_FAILURES,
|
|
505
511
|
loaded: null
|
|
@@ -508,13 +514,13 @@ function useImageChain(sources) {
|
|
|
508
514
|
const current = state.key === key ? state : fresh;
|
|
509
515
|
if (state.key !== key) setState(fresh);
|
|
510
516
|
const active = selectImageSource(sources, current.failed);
|
|
511
|
-
const markLoaded =
|
|
517
|
+
const markLoaded = React3.useCallback(() => {
|
|
512
518
|
if (active === void 0) return;
|
|
513
519
|
setState(
|
|
514
520
|
(prev) => prev.key !== key || prev.loaded === active ? prev : { ...prev, loaded: active }
|
|
515
521
|
);
|
|
516
522
|
}, [key, active]);
|
|
517
|
-
const markFailed =
|
|
523
|
+
const markFailed = React3.useCallback(() => {
|
|
518
524
|
if (active === void 0) return;
|
|
519
525
|
setState((prev) => {
|
|
520
526
|
if (prev.key !== key || prev.failed.includes(active)) return prev;
|
|
@@ -534,4 +540,4 @@ function useImageChain(sources) {
|
|
|
534
540
|
};
|
|
535
541
|
}
|
|
536
542
|
|
|
537
|
-
export { DEFAULT_PAGINATION_KEY_PREFIX, DEFAULT_TIME_ZONE, DEFAULT_TOOLBAR_KEY_PREFIX, EMPTY_DESIGN, NAJM_COLOR_TEXT_CLASSES, NAJM_STATUS_COLORS, NTableDefaultsProvider, NajmDesignEditorProvider, NajmPreferencesProvider, NajmUIProvider, buildPaginationLabels, buildToolbarLabels, colorTextClass, findStatusColor, mergeBadgeMaps, normalizeImageSources, normalizeStatusToken, resolveBadgeStatusLabel, resolveStatusColor, statusTextClass, useDocumentDirection, useImageChain, useNBadgeDefaults, useNTableDefaults, useNajmDesignEditor, useNajmPreferencesContext, useNajmTheme, useNajmTimeZone, useResolvedFeedbackLabels, useResolvedPaginationLabels, useResolvedToolbarLabels };
|
|
543
|
+
export { DEFAULT_FEEDBACK_KEY_PREFIX, DEFAULT_PAGINATION_KEY_PREFIX, DEFAULT_TIME_ZONE, DEFAULT_TOOLBAR_KEY_PREFIX, EMPTY_DESIGN, NAJM_COLOR_TEXT_CLASSES, NAJM_STATUS_COLORS, NTableDefaultsProvider, NajmDesignEditorProvider, NajmPreferencesProvider, NajmUIProvider, buildPaginationLabels, buildToolbarLabels, colorTextClass, findStatusColor, mergeBadgeMaps, normalizeImageSources, normalizeStatusToken, resolveBadgeStatusLabel, resolveStatusColor, statusTextClass, useDocumentDirection, useImageChain, useNBadgeDefaults, useNTableDefaults, useNajmDesignEditor, useNajmPreferencesContext, useNajmTheme, useNajmTimeZone, useResolvedFeedbackLabels, useResolvedPaginationLabels, useResolvedToolbarLabels };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useImageChain, normalizeImageSources, NajmUIProvider } from './chunk-
|
|
1
|
+
import { useImageChain, normalizeImageSources, NajmUIProvider } from './chunk-BDQK6ECA.mjs';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useRouter } from 'next/navigation';
|
|
4
4
|
import NextImage from 'next/image';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/lib/timeZones.ts
|
|
2
|
+
var NAJM_TIME_ZONES = [
|
|
3
|
+
"UTC",
|
|
4
|
+
"Atlantic/Azores",
|
|
5
|
+
"America/Los_Angeles",
|
|
6
|
+
"America/Denver",
|
|
7
|
+
"America/Chicago",
|
|
8
|
+
"America/New_York",
|
|
9
|
+
"America/Sao_Paulo",
|
|
10
|
+
"Pacific/Honolulu",
|
|
11
|
+
"Europe/London",
|
|
12
|
+
"Europe/Paris",
|
|
13
|
+
"Africa/Casablanca",
|
|
14
|
+
"Africa/Tunis",
|
|
15
|
+
"Africa/Cairo",
|
|
16
|
+
"Africa/Nairobi",
|
|
17
|
+
"Asia/Riyadh",
|
|
18
|
+
"Asia/Dubai",
|
|
19
|
+
"Asia/Kolkata",
|
|
20
|
+
"Asia/Bangkok",
|
|
21
|
+
"Asia/Shanghai",
|
|
22
|
+
"Asia/Tokyo",
|
|
23
|
+
"Australia/Sydney",
|
|
24
|
+
"Pacific/Auckland"
|
|
25
|
+
];
|
|
26
|
+
var NAJM_DEFAULT_TIME_ZONE = "UTC";
|
|
27
|
+
|
|
28
|
+
export { NAJM_DEFAULT_TIME_ZONE, NAJM_TIME_ZONES };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { N as NajmDesignConfig, a as NajmVariantStyle } from './design-types-DffH_9XC.js';
|
|
2
2
|
|
|
3
3
|
/** Keeps authored TypeScript design objects type-checked without changing them. */
|
|
4
4
|
declare function defineNajmDesignConfig(config: NajmDesignConfig): NajmDesignConfig;
|
|
@@ -156,4 +156,4 @@ declare const NAJM_COMPONENT_NAMES: readonly NajmComponentName[];
|
|
|
156
156
|
declare const RADIUS_VALUE_MAP: Record<string, string>;
|
|
157
157
|
declare function resolveRadiusValue(radius: NajmComponentRadius | undefined): string | undefined;
|
|
158
158
|
|
|
159
|
-
export { type
|
|
159
|
+
export { type NajmDesignConfig as N, RADIUS_VALUE_MAP as R, type NajmVariantStyle as a, type NajmMode as b, type NajmComponentThemeConfig as c, type NajmLayoutConfig as d, type NajmTypographyConfig as e, type NajmThemeProviderProps as f, type NajmAppearance as g, type NajmThemeConfig as h, type NajmAccent as i, type NajmThemeTokens as j, type NajmPreset as k, type NajmComponentName as l, type NajmComponentStyleConfig as m, type NajmResponsiveBreakpoint as n, type NajmResponsiveValue as o, NAJM_COMPONENT_NAMES as p, type NajmComponentRadius as q, type NajmDensity as r, type NajmSlotStyle as s, resolveRadiusValue as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
2
|
import React__default, { RefObject, ReactNode, ComponentType, InputHTMLAttributes, Ref, ImgHTMLAttributes, CSSProperties, MouseEvent, MouseEventHandler } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { p as NAJM_COMPONENT_NAMES, q as NajmComponentRadius, r as NajmDensity, s as NajmSlotStyle,
|
|
5
|
-
import { d as NTableToolbarLabels, e as NIconSource, B as BadgeColor, f as BadgeShape } from './NajmUIProvider-
|
|
6
|
-
export { g as Badge, h as BadgeIcon, i as BadgeLook, j as BadgeProps, k as BadgeSize, l as BadgeVariant, D as
|
|
3
|
+
import { N as NajmDesignConfig, f as NajmThemeProviderProps, g as NajmAppearance, b as NajmMode, h as NajmThemeConfig, i as NajmAccent, j as NajmThemeTokens, k as NajmPreset, l as NajmComponentName, m as NajmComponentStyleConfig, c as NajmComponentThemeConfig, e as NajmTypographyConfig, d as NajmLayoutConfig, n as NajmResponsiveBreakpoint, o as NajmResponsiveValue } from './design-types-DffH_9XC.js';
|
|
4
|
+
export { p as NAJM_COMPONENT_NAMES, q as NajmComponentRadius, r as NajmDensity, s as NajmSlotStyle, a as NajmVariantStyle, R as RADIUS_VALUE_MAP, t as resolveRadiusValue } from './design-types-DffH_9XC.js';
|
|
5
|
+
import { d as NTableToolbarLabels, e as NIconSource, B as BadgeColor, f as BadgeShape } from './NajmUIProvider-BwL5HFIV.js';
|
|
6
|
+
export { g as Badge, h as BadgeIcon, i as BadgeLook, j as BadgeProps, k as BadgeSize, l as BadgeVariant, D as DEFAULT_FEEDBACK_KEY_PREFIX, m as DEFAULT_TIME_ZONE, F as FeedbackKey, n as NBadge, o as NBadgeDefaults, p as NBadgeLook, q as NBadgeProps, N as NFeedbackDefaults, a as NFeedbackLabelKeys, b as NFeedbackLabels, r as NIcon, s as NIconProps, t as NTableDefaults, u as NTableDefaultsProvider, v as NajmPreferencesContextValue, w as NajmPreferencesProvider, x as NajmPreferencesProviderProps, y as NajmUIProvider, c as NajmUIProviderProps, z as badgeColorVariants, A as badgeVariants, C as useDocumentDirection, E as useNTableDefaults, G as useNajmPreferencesContext, H as useNajmTheme, I as useNajmTimeZone, J as useResolvedToolbarLabels } from './NajmUIProvider-BwL5HFIV.js';
|
|
7
7
|
import { N as NajmTranslate, c as NTablePaginationVariant, b as NTablePaginationLabels, a as NTableCardPagination } from './paginationLabels-dZLSNxfo.js';
|
|
8
8
|
export { D as DEFAULT_PAGINATION_KEY_PREFIX, d as NTableInfinitePagination, e as NTableLoadMorePagination, f as buildPaginationLabels } from './paginationLabels-dZLSNxfo.js';
|
|
9
|
-
export { d as defineNajmDesignConfig, p as parseNajmDesignConfig, r as resolveVariantAlias, s as stringifyNajmDesignConfig } from './design-config-
|
|
9
|
+
export { d as defineNajmDesignConfig, p as parseNajmDesignConfig, r as resolveVariantAlias, s as stringifyNajmDesignConfig } from './design-config-CL9vqqQ9.js';
|
|
10
10
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
11
11
|
import { VariantProps } from 'class-variance-authority';
|
|
12
12
|
import * as LabelPrimitive from '@radix-ui/react-label';
|