najm-kit 2.7.1 → 2.7.2
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 +112 -112
- package/dist/{NajmUIProvider-Dj32bd5d.d.ts → NajmUIProvider-ClpHD-55.d.ts} +3 -142
- package/dist/adapters/app.d.ts +26 -1
- package/dist/adapters/app.mjs +29 -4
- package/dist/adapters/next.d.ts +2 -1
- package/dist/chunk-7J7DWGKB.mjs +93 -0
- package/dist/chunk-QOP7L6RD.mjs +218 -0
- package/dist/index.d.ts +142 -3
- package/dist/index.mjs +3 -2
- package/dist/pagination-BvukSZir.d.ts +130 -0
- package/dist/paginationLabels-CY2PvbMj.d.ts +143 -0
- package/dist/query.d.ts +299 -0
- package/dist/query.mjs +131 -0
- package/package.json +11 -1
- package/dist/chunk-5LW62RB6.mjs +0 -65
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { useNajmPreferencesContext } from './chunk-USZUOJMK.mjs';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { createContext, useContext, useMemo, useState, useCallback } from 'react';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
function normalizeBranding(input) {
|
|
7
|
+
if (!input) return {};
|
|
8
|
+
const value = {};
|
|
9
|
+
const expanded = input.logoExpanded ?? input.sidebarLogoExpandedPath;
|
|
10
|
+
const collapsed = input.logoCollapsed ?? input.sidebarLogoCollapsedPath;
|
|
11
|
+
if (input.appName !== void 0) value.appName = input.appName;
|
|
12
|
+
if (input.logoFallback !== void 0) value.logoFallback = input.logoFallback;
|
|
13
|
+
if (input.logoHref !== void 0) value.logoHref = input.logoHref;
|
|
14
|
+
if (expanded !== void 0) value.logoExpanded = expanded;
|
|
15
|
+
if (collapsed !== void 0) value.logoCollapsed = collapsed;
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
var NBrandingContext = createContext(null);
|
|
19
|
+
function useNBranding() {
|
|
20
|
+
return useContext(NBrandingContext);
|
|
21
|
+
}
|
|
22
|
+
function NBrandingProvider({
|
|
23
|
+
children,
|
|
24
|
+
appName,
|
|
25
|
+
logoExpanded,
|
|
26
|
+
logoCollapsed,
|
|
27
|
+
logoFallback,
|
|
28
|
+
logoHref
|
|
29
|
+
}) {
|
|
30
|
+
const value = useMemo(
|
|
31
|
+
() => ({ appName, logoExpanded, logoCollapsed, logoFallback, logoHref }),
|
|
32
|
+
[appName, logoExpanded, logoCollapsed, logoFallback, logoHref]
|
|
33
|
+
);
|
|
34
|
+
return /* @__PURE__ */ jsx(NBrandingContext.Provider, { value, children });
|
|
35
|
+
}
|
|
36
|
+
var NBrandingEditorContext = createContext(null);
|
|
37
|
+
function useNBrandingEditor() {
|
|
38
|
+
return useContext(NBrandingEditorContext);
|
|
39
|
+
}
|
|
40
|
+
function NBrandingStateProvider({
|
|
41
|
+
children,
|
|
42
|
+
branding,
|
|
43
|
+
initialBranding
|
|
44
|
+
}) {
|
|
45
|
+
const [state, setState] = useState(
|
|
46
|
+
() => normalizeBranding(initialBranding ?? branding)
|
|
47
|
+
);
|
|
48
|
+
const setBranding = useCallback((patch) => {
|
|
49
|
+
const marks = normalizeBranding(patch);
|
|
50
|
+
setState((current) => ({ ...current, ...marks }));
|
|
51
|
+
}, []);
|
|
52
|
+
const controlled = useMemo(
|
|
53
|
+
() => branding ? normalizeBranding(branding) : void 0,
|
|
54
|
+
[branding]
|
|
55
|
+
);
|
|
56
|
+
const resolved = controlled ?? state;
|
|
57
|
+
const editor = useMemo(
|
|
58
|
+
() => ({ branding: resolved, setBranding: branding ? noop : setBranding }),
|
|
59
|
+
[resolved, branding, setBranding]
|
|
60
|
+
);
|
|
61
|
+
return /* @__PURE__ */ jsx(NBrandingEditorContext.Provider, { value: editor, children: /* @__PURE__ */ jsx(NBrandingProvider, { ...resolved, children }) });
|
|
62
|
+
}
|
|
63
|
+
function noop() {
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/format/format.ts
|
|
67
|
+
var DEFAULT_PLACEHOLDER = "\u2014";
|
|
68
|
+
var numberFormats = /* @__PURE__ */ new Map();
|
|
69
|
+
var dateFormats = /* @__PURE__ */ new Map();
|
|
70
|
+
function numberFormat(locale, options) {
|
|
71
|
+
const key = `${locale}|${options ? JSON.stringify(options) : ""}`;
|
|
72
|
+
let format = numberFormats.get(key);
|
|
73
|
+
if (!format) {
|
|
74
|
+
format = new Intl.NumberFormat(locale, options);
|
|
75
|
+
numberFormats.set(key, format);
|
|
76
|
+
}
|
|
77
|
+
return format;
|
|
78
|
+
}
|
|
79
|
+
function dateFormat(locale, options) {
|
|
80
|
+
const key = `${locale}|${JSON.stringify(options)}`;
|
|
81
|
+
let format = dateFormats.get(key);
|
|
82
|
+
if (!format) {
|
|
83
|
+
format = new Intl.DateTimeFormat(locale, options);
|
|
84
|
+
dateFormats.set(key, format);
|
|
85
|
+
}
|
|
86
|
+
return format;
|
|
87
|
+
}
|
|
88
|
+
function minorUnitScale(locale, currency) {
|
|
89
|
+
const digits = numberFormat(locale, { style: "currency", currency }).resolvedOptions().maximumFractionDigits ?? 2;
|
|
90
|
+
return 10 ** digits;
|
|
91
|
+
}
|
|
92
|
+
function toDate(value) {
|
|
93
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
94
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
95
|
+
}
|
|
96
|
+
function isBlank(value) {
|
|
97
|
+
return value === null || value === void 0 || value === "";
|
|
98
|
+
}
|
|
99
|
+
function formatCurrency(minorUnits, { locale, currency, placeholder = DEFAULT_PLACEHOLDER }) {
|
|
100
|
+
if (!currency) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
"formatCurrency requires a `currency`. Set it on NajmFormatProvider or pass it here."
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
if (minorUnits === null || minorUnits === void 0) return placeholder;
|
|
106
|
+
if (!Number.isSafeInteger(minorUnits)) return placeholder;
|
|
107
|
+
return numberFormat(locale, {
|
|
108
|
+
style: "currency",
|
|
109
|
+
currency
|
|
110
|
+
}).format(minorUnits / minorUnitScale(locale, currency));
|
|
111
|
+
}
|
|
112
|
+
function formatNumber(value, { locale, placeholder = DEFAULT_PLACEHOLDER }, options) {
|
|
113
|
+
if (value === null || value === void 0 || !Number.isFinite(value)) {
|
|
114
|
+
return placeholder;
|
|
115
|
+
}
|
|
116
|
+
return numberFormat(locale, options).format(value);
|
|
117
|
+
}
|
|
118
|
+
function formatPercent(value, config, fractionDigits = 0) {
|
|
119
|
+
return formatNumber(value, config, {
|
|
120
|
+
style: "percent",
|
|
121
|
+
minimumFractionDigits: fractionDigits,
|
|
122
|
+
maximumFractionDigits: fractionDigits
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function formatDate(value, {
|
|
126
|
+
locale,
|
|
127
|
+
timeZone,
|
|
128
|
+
placeholder = DEFAULT_PLACEHOLDER
|
|
129
|
+
}, options = { dateStyle: "medium" }) {
|
|
130
|
+
if (isBlank(value)) return placeholder;
|
|
131
|
+
const date = toDate(value);
|
|
132
|
+
if (!date) return placeholder;
|
|
133
|
+
return dateFormat(locale, { ...options, timeZone }).format(date);
|
|
134
|
+
}
|
|
135
|
+
function formatDateTime(value, config, options = {
|
|
136
|
+
dateStyle: "short",
|
|
137
|
+
timeStyle: "short"
|
|
138
|
+
}) {
|
|
139
|
+
return formatDate(value, config, options);
|
|
140
|
+
}
|
|
141
|
+
function formatTime(value, config) {
|
|
142
|
+
return formatDate(value, config, { timeStyle: "short" });
|
|
143
|
+
}
|
|
144
|
+
var RELATIVE_UNITS = [
|
|
145
|
+
["year", 31536e6],
|
|
146
|
+
["month", 2592e6],
|
|
147
|
+
["day", 864e5],
|
|
148
|
+
["hour", 36e5],
|
|
149
|
+
["minute", 6e4],
|
|
150
|
+
["second", 1e3]
|
|
151
|
+
];
|
|
152
|
+
function formatRelativeTime(value, { locale, placeholder = DEFAULT_PLACEHOLDER }, now = Date.now()) {
|
|
153
|
+
if (isBlank(value)) return placeholder;
|
|
154
|
+
const date = toDate(value);
|
|
155
|
+
if (!date) return placeholder;
|
|
156
|
+
const elapsed = date.getTime() - (now instanceof Date ? now.getTime() : now);
|
|
157
|
+
const format = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
158
|
+
for (const [unit, ms] of RELATIVE_UNITS) {
|
|
159
|
+
if (Math.abs(elapsed) >= ms) {
|
|
160
|
+
return format.format(Math.trunc(elapsed / ms), unit);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return format.format(0, "second");
|
|
164
|
+
}
|
|
165
|
+
function humanizeToken(value) {
|
|
166
|
+
return value.trim().replace(/[_-]+/g, " ").replace(/\s+/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
|
|
167
|
+
}
|
|
168
|
+
var NajmFormatContext = React.createContext(
|
|
169
|
+
null
|
|
170
|
+
);
|
|
171
|
+
function NajmFormatProvider({
|
|
172
|
+
children,
|
|
173
|
+
locale,
|
|
174
|
+
currency,
|
|
175
|
+
timeZone,
|
|
176
|
+
placeholder = DEFAULT_PLACEHOLDER
|
|
177
|
+
}) {
|
|
178
|
+
const preferences = useNajmPreferencesContext();
|
|
179
|
+
const resolvedTimeZone = timeZone ?? preferences?.timeZone ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
180
|
+
const value = React.useMemo(() => {
|
|
181
|
+
const config = {
|
|
182
|
+
locale,
|
|
183
|
+
timeZone: resolvedTimeZone,
|
|
184
|
+
currency,
|
|
185
|
+
placeholder
|
|
186
|
+
};
|
|
187
|
+
return {
|
|
188
|
+
locale,
|
|
189
|
+
timeZone: resolvedTimeZone,
|
|
190
|
+
currency,
|
|
191
|
+
placeholder,
|
|
192
|
+
config,
|
|
193
|
+
money: (minorUnits) => formatCurrency(minorUnits, config),
|
|
194
|
+
number: (value_, options) => formatNumber(value_, config, options),
|
|
195
|
+
percent: (value_, digits) => formatPercent(value_, config, digits),
|
|
196
|
+
date: (value_, options) => formatDate(value_, config, options),
|
|
197
|
+
dateTime: (value_) => formatDateTime(value_, config),
|
|
198
|
+
time: (value_) => formatTime(value_, config),
|
|
199
|
+
relativeTime: (value_) => formatRelativeTime(value_, config),
|
|
200
|
+
humanize: humanizeToken
|
|
201
|
+
};
|
|
202
|
+
}, [locale, resolvedTimeZone, currency, placeholder]);
|
|
203
|
+
return /* @__PURE__ */ jsx(NajmFormatContext.Provider, { value, children });
|
|
204
|
+
}
|
|
205
|
+
function useNajmFormatContext() {
|
|
206
|
+
return React.useContext(NajmFormatContext);
|
|
207
|
+
}
|
|
208
|
+
function useNajmFormat() {
|
|
209
|
+
const value = React.useContext(NajmFormatContext);
|
|
210
|
+
if (!value) {
|
|
211
|
+
throw new Error(
|
|
212
|
+
"useNajmFormat must be rendered under a NajmFormatProvider or NajmAppProvider."
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
return value;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { DEFAULT_PLACEHOLDER, NBrandingProvider, NBrandingStateProvider, NajmFormatProvider, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTime, humanizeToken, normalizeBranding, useNBranding, useNBrandingEditor, useNajmFormat, useNajmFormatContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { a as NajmDesignConfig, b as NajmThemeProviderProps, c as NajmAppearance, d as NajmMode, e as NajmThemeConfig, f as NajmAccent, g as NajmThemeTokens, h as NajmPreset, i as NajmComponentName, j as NajmComponentStyleConfig, k as NajmComponentThemeConfig, l as NajmTypographyConfig, m as NajmLayoutConfig, n as NajmVariantStyle, o as
|
|
3
|
-
export { D as
|
|
2
|
+
import { a as NajmDesignConfig, b as NajmThemeProviderProps, c as NajmAppearance, d as NajmMode, e as NajmThemeConfig, f as NajmAccent, g as NajmThemeTokens, h as NajmPreset, i as NajmComponentName, j as NajmComponentStyleConfig, k as NajmComponentThemeConfig, l as NajmTypographyConfig, m as NajmLayoutConfig, n as NajmVariantStyle, o as NajmResponsiveBreakpoint, p as NajmResponsiveValue } from './NajmUIProvider-ClpHD-55.js';
|
|
3
|
+
export { D as DEFAULT_TIME_ZONE, q as NAJM_COMPONENT_NAMES, r as NTableDefaults, s as NTableDefaultsProvider, t as NajmComponentRadius, u as NajmDensity, v as NajmPreferencesContextValue, w as NajmPreferencesProvider, x as NajmPreferencesProviderProps, y as NajmSlotStyle, z as NajmUIProvider, N as NajmUIProviderProps, R as RADIUS_VALUE_MAP, A as resolveRadiusValue, B as useNTableDefaults, C as useNajmPreferencesContext, E as useNajmTheme, F as useNajmTimeZone } from './NajmUIProvider-ClpHD-55.js';
|
|
4
4
|
import * as React$1 from 'react';
|
|
5
5
|
import React__default, { RefObject, ReactNode, ComponentType, InputHTMLAttributes, Ref, ImgHTMLAttributes, CSSProperties, MouseEvent, MouseEventHandler } from 'react';
|
|
6
|
+
import { N as NTablePaginationVariant, a as NTablePaginationLabels, b as NTableCardPagination } from './paginationLabels-CY2PvbMj.js';
|
|
7
|
+
export { D as DEFAULT_PAGINATION_KEY_PREFIX, c as NTableInfinitePagination, d as NTableLoadMorePagination, e as NajmTranslate, f as buildPaginationLabels } from './paginationLabels-CY2PvbMj.js';
|
|
6
8
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
7
9
|
import { VariantProps } from 'class-variance-authority';
|
|
8
10
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
@@ -37,6 +39,7 @@ import { ZodTypeAny, TypeOf } from 'zod';
|
|
|
37
39
|
import { SortingState, ExpandedState, ColumnDef, Row, ColumnFiltersState, VisibilityState, RowSelectionState } from '@tanstack/react-table';
|
|
38
40
|
export { N as NTableJson } from './NTableJson-tXqgfZI1.js';
|
|
39
41
|
import * as _tanstack_table_core from '@tanstack/table-core';
|
|
42
|
+
export { A as ApiPage, C as CardPaginationLabels, a as CardPaginationState, D as DEFAULT_CARD_PAGINATION_KEY_PREFIX, b as DEFAULT_MAX_PAGE_SIZE, c as DEFAULT_PAGE_SIZE, L as ListStrategy, O as OffsetPage, d as OffsetPageFetcher, e as OffsetPageOptions, f as OffsetPagination, Q as QueryValue, R as ResolvedListMode, g as buildCardPaginationLabels, h as cleanQuery, i as createCardPagination, j as createOffsetPagination, k as fetchOffsetPage, l as getPageIndex } from './pagination-BvukSZir.js';
|
|
40
43
|
import { ClassValue } from 'clsx';
|
|
41
44
|
|
|
42
45
|
/**
|
|
@@ -386,6 +389,31 @@ declare function useSelection(visibleIds: string[]): {
|
|
|
386
389
|
someVisibleSelected: boolean;
|
|
387
390
|
};
|
|
388
391
|
|
|
392
|
+
/**
|
|
393
|
+
* A media query read during render rather than after it.
|
|
394
|
+
*
|
|
395
|
+
* `matchMedia` answers synchronously, so the answer belongs in the render that
|
|
396
|
+
* asks for it. Holding it in state and filling it from an effect makes every
|
|
397
|
+
* mount paint one frame of the wrong viewport: on a desktop table page that
|
|
398
|
+
* frame renders the card skeleton, which is then torn down for the table
|
|
399
|
+
* skeleton, so a single load appears to load twice.
|
|
400
|
+
*
|
|
401
|
+
* `useSyncExternalStore` still uses `serverSnapshot` for SSR and for the
|
|
402
|
+
* hydration render — nothing can be measured before the document exists — but
|
|
403
|
+
* every render after that, including every client-side navigation, reads the
|
|
404
|
+
* live value on its first pass.
|
|
405
|
+
*/
|
|
406
|
+
declare function useMediaQuery(query: string, serverSnapshot?: boolean): boolean;
|
|
407
|
+
/**
|
|
408
|
+
* The viewport width below which a table renders as cards. Matches the `lg`
|
|
409
|
+
* breakpoint, which is where a row of table columns stops fitting.
|
|
410
|
+
*/
|
|
411
|
+
declare const DEFAULT_CARD_BREAKPOINT = 1024;
|
|
412
|
+
/** Whether the viewport is narrow enough that a table should render as cards. */
|
|
413
|
+
declare function useCardViewport(breakpoint?: number): boolean;
|
|
414
|
+
/** The same decision as `useCardViewport`, as the mode name NTable takes. */
|
|
415
|
+
declare function useDesktopTableMode(breakpoint?: number): "table" | "cards";
|
|
416
|
+
|
|
389
417
|
type NIconSource = React__default.ReactElement | React__default.ComponentType<any> | React__default.ExoticComponent<any> | string | {
|
|
390
418
|
src: string;
|
|
391
419
|
alt?: string;
|
|
@@ -3700,6 +3728,117 @@ declare function cn(...inputs: ClassValue[]): string;
|
|
|
3700
3728
|
|
|
3701
3729
|
declare function resolveSlot<T>(slot: T | ((ctx: any) => ReactNode), ctx?: any): ReactNode;
|
|
3702
3730
|
|
|
3731
|
+
/**
|
|
3732
|
+
* Locale-aware value formatting.
|
|
3733
|
+
*
|
|
3734
|
+
* Pure functions with no React and no DOM: every input arrives through
|
|
3735
|
+
* `NajmFormatConfig`. `NajmFormatProvider` binds them to the live locale and
|
|
3736
|
+
* time zone, and is what an application normally uses — these are exported for
|
|
3737
|
+
* the server, where there is no context to read.
|
|
3738
|
+
*/
|
|
3739
|
+
/** Rendered in place of a value that is absent or not formattable. */
|
|
3740
|
+
declare const DEFAULT_PLACEHOLDER = "\u2014";
|
|
3741
|
+
interface NajmFormatConfig {
|
|
3742
|
+
/** BCP 47 tag handed to `Intl`, e.g. `"fr-MA"`. */
|
|
3743
|
+
locale: string;
|
|
3744
|
+
/**
|
|
3745
|
+
* IANA zone every date is rendered in. Omitted means the host zone, which is
|
|
3746
|
+
* the runtime's guess rather than the user's preference — supply it.
|
|
3747
|
+
*/
|
|
3748
|
+
timeZone?: string;
|
|
3749
|
+
/** ISO 4217 code for `formatCurrency`, e.g. `"MAD"`. */
|
|
3750
|
+
currency?: string;
|
|
3751
|
+
/** Defaults to an em dash. */
|
|
3752
|
+
placeholder?: string;
|
|
3753
|
+
}
|
|
3754
|
+
/**
|
|
3755
|
+
* Formats an integer count of minor units — cents, centimes — as currency.
|
|
3756
|
+
*
|
|
3757
|
+
* Minor units are the input because money that survives a round trip is an
|
|
3758
|
+
* integer; a major-unit float cannot represent 0.1 exactly and has no business
|
|
3759
|
+
* in a ledger. A non-integer input is refused rather than rounded, since at
|
|
3760
|
+
* this layer it means the caller has already lost precision upstream.
|
|
3761
|
+
*/
|
|
3762
|
+
declare function formatCurrency(minorUnits: number | null | undefined, { locale, currency, placeholder }: NajmFormatConfig): string;
|
|
3763
|
+
declare function formatNumber(value: number | null | undefined, { locale, placeholder }: NajmFormatConfig, options?: Intl.NumberFormatOptions): string;
|
|
3764
|
+
declare function formatPercent(value: number | null | undefined, config: NajmFormatConfig, fractionDigits?: number): string;
|
|
3765
|
+
declare function formatDate(value: Date | number | string | null | undefined, { locale, timeZone, placeholder, }: NajmFormatConfig, options?: Intl.DateTimeFormatOptions): string;
|
|
3766
|
+
declare function formatDateTime(value: Date | number | string | null | undefined, config: NajmFormatConfig, options?: Intl.DateTimeFormatOptions): string;
|
|
3767
|
+
declare function formatTime(value: Date | number | string | null | undefined, config: NajmFormatConfig): string;
|
|
3768
|
+
/**
|
|
3769
|
+
* Renders a timestamp as distance from now — "3 days ago", "in 2 hours".
|
|
3770
|
+
*
|
|
3771
|
+
* Time zone is not a parameter: an elapsed duration is the same in every zone.
|
|
3772
|
+
*/
|
|
3773
|
+
declare function formatRelativeTime(value: Date | number | string | null | undefined, { locale, placeholder }: NajmFormatConfig, now?: Date | number): string;
|
|
3774
|
+
/**
|
|
3775
|
+
* Turns a machine token into readable text: `out_for_delivery` → `Out For
|
|
3776
|
+
* Delivery`.
|
|
3777
|
+
*
|
|
3778
|
+
* The fallback for a value with no catalog entry, not a substitute for one.
|
|
3779
|
+
* Anything user-visible and known in advance belongs in the translations.
|
|
3780
|
+
*/
|
|
3781
|
+
declare function humanizeToken(value: string): string;
|
|
3782
|
+
|
|
3783
|
+
interface NajmFormatContextValue extends Required<Pick<NajmFormatConfig, "locale" | "timeZone" | "placeholder">> {
|
|
3784
|
+
currency?: string;
|
|
3785
|
+
/** Formats an integer count of minor units as `currency`. */
|
|
3786
|
+
money: (minorUnits: number | null | undefined) => string;
|
|
3787
|
+
number: (value: number | null | undefined, options?: Intl.NumberFormatOptions) => string;
|
|
3788
|
+
percent: (value: number | null | undefined, fractionDigits?: number) => string;
|
|
3789
|
+
date: (value: Date | number | string | null | undefined, options?: Intl.DateTimeFormatOptions) => string;
|
|
3790
|
+
dateTime: (value: Date | number | string | null | undefined) => string;
|
|
3791
|
+
time: (value: Date | number | string | null | undefined) => string;
|
|
3792
|
+
relativeTime: (value: Date | number | string | null | undefined) => string;
|
|
3793
|
+
humanize: (value: string) => string;
|
|
3794
|
+
/** The resolved inputs, for handing to the pure functions directly. */
|
|
3795
|
+
config: NajmFormatConfig;
|
|
3796
|
+
}
|
|
3797
|
+
interface NajmFormatProviderProps {
|
|
3798
|
+
children: React$1.ReactNode;
|
|
3799
|
+
/**
|
|
3800
|
+
* BCP 47 tag. `NajmAppProvider` derives this from the active `najm-i18n`
|
|
3801
|
+
* language, so applications using it rarely pass this by hand.
|
|
3802
|
+
*/
|
|
3803
|
+
locale: string;
|
|
3804
|
+
/**
|
|
3805
|
+
* ISO 4217 code for `money`. Omitted means the application does not format
|
|
3806
|
+
* currency; calling `money` without it throws rather than guessing a symbol.
|
|
3807
|
+
*/
|
|
3808
|
+
currency?: string;
|
|
3809
|
+
/**
|
|
3810
|
+
* Overrides the time zone from `NajmPreferencesProvider`.
|
|
3811
|
+
*
|
|
3812
|
+
* Reading preferences is the point — it is where the user's choice already
|
|
3813
|
+
* lives, and formatting dates against anything else is how a table ends up
|
|
3814
|
+
* disagreeing with the picker that set it.
|
|
3815
|
+
*/
|
|
3816
|
+
timeZone?: string;
|
|
3817
|
+
/** Rendered for absent values. Defaults to an em dash. */
|
|
3818
|
+
placeholder?: string;
|
|
3819
|
+
}
|
|
3820
|
+
/**
|
|
3821
|
+
* Binds the formatters to the live locale and time zone.
|
|
3822
|
+
*
|
|
3823
|
+
* The time zone comes from `NajmPreferencesProvider` when one is mounted, which
|
|
3824
|
+
* is what makes this worth a provider rather than a helper import: the
|
|
3825
|
+
* preference and the rendering of every date derived from it stay in one place,
|
|
3826
|
+
* and a zone change re-renders the consumers instead of leaving stale text.
|
|
3827
|
+
*/
|
|
3828
|
+
declare function NajmFormatProvider({ children, locale, currency, timeZone, placeholder, }: NajmFormatProviderProps): react_jsx_runtime.JSX.Element;
|
|
3829
|
+
/** Returns the context when one is mounted, or `null`. */
|
|
3830
|
+
declare function useNajmFormatContext(): NajmFormatContextValue | null;
|
|
3831
|
+
/**
|
|
3832
|
+
* The bound formatters.
|
|
3833
|
+
*
|
|
3834
|
+
* ```tsx
|
|
3835
|
+
* const fmt = useNajmFormat();
|
|
3836
|
+
* fmt.money(order.totalMinor); // "1 250,00 MAD"
|
|
3837
|
+
* fmt.date(order.createdAt); // "8 août 2026"
|
|
3838
|
+
* ```
|
|
3839
|
+
*/
|
|
3840
|
+
declare function useNajmFormat(): NajmFormatContextValue;
|
|
3841
|
+
|
|
3703
3842
|
interface JsonViewColors {
|
|
3704
3843
|
background: string;
|
|
3705
3844
|
phrase: string;
|
|
@@ -4122,4 +4261,4 @@ interface NGridItemProps extends Omit<React$1.AllHTMLAttributes<HTMLDivElement>,
|
|
|
4122
4261
|
declare function NGrid({ as: Comp, children, cols, smCols, mdCols, lgCols, xlCols, gap, className, style, ...props }: NGridProps): react_jsx_runtime.JSX.Element;
|
|
4123
4262
|
declare function NGridItem({ children, span, smSpan, mdSpan, lgSpan, xlSpan, className, ...props }: NGridItemProps): react_jsx_runtime.JSX.Element;
|
|
4124
4263
|
|
|
4125
|
-
export { Alert, type AlertLook, type AlertOrientation, type AlertProps, type AlertSize, type AlertTone, type AlertVariant, NCard as AsyncCard, Avatar, AvatarFallback, AvatarFormInput, type AvatarFormInputProps, AvatarGroup, type AvatarGroupProps, AvatarImage, AvatarInput, type AvatarInputProps, type AvatarInputRadius, type AvatarProps$1 as AvatarProps, type AvatarShape$1 as AvatarShape, type AvatarSize, AvatarStatus, type AvatarStatusType, Badge, type BadgeColor, type BadgeIcon, type BadgeLook, type BadgeProps, type BadgeShape, type BadgeSize, type BadgeVariant, BaseInput, type BuildDefaultFileColumnsOptions, Button, type ButtonConfig, type ButtonIcon, type ButtonLoaderPosition, type ButtonProps, type ButtonRounded, type ButtonSize, type ButtonVariant, Calendar, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxGroupInput, type CheckboxGroupInputProps, CheckboxInput, type CheckboxInputProps, Collapsible, CollapsibleContent, CollapsibleTrigger, ColorArrayInput, type ColorArrayInputProps, type ColorFormat, ColorPickerInput, type ColorPickerInputProps, Combobox, ComboboxInput, type ComboboxInputProps, type ComboboxOption, type ComboboxProps, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, type ContextMenuItem, DEFAULT_THEME_FILE_NAME, DateInput, type DateInputProps, type DeleteDialogOptions, Dialog, type DialogActionMode, type DialogApi, DialogClose, type DialogConfig, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogHeader, type DialogHeight, DialogOverlay, type DialogPadding, DialogPortal, type DialogRenderContext, type DialogRenderer, type DialogSize, type DialogStore, DialogTitle, DialogTrigger, type DialogVariant, type DialogWidth, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DynamicArray, type DynamicArrayProps, EMPTY_DESIGN, EmojiInput, type EmojiInputProps, type FileBrowserMode, FileImportButton, FileInput, type FileInputProps, type FileNode, Form, FormControl, FormDescription, FormField, FormInput, type FormInputBackground, type FormInputProps, FormItem, FormLabel, FormMessage, type FormProps, type FormSlotClassNames, type FormVariant, IconButton, type IconButtonProps, type IconButtonSize, type IconButtonVariant, ImageInput, type ImageInputPreviewError, type ImageInputPreviewSource, type ImageInputProps, Indicator, type IndicatorHorizontal, type IndicatorOverlay, type IndicatorPosition, type IndicatorProps, type IndicatorResponsivePosition, type IndicatorSize, type IndicatorVertical, Input, type InputIcon, Label, LangInput, type LangInputProps, type LinkComponentType, MultiSelectInput, type MultiSelectInputProps, NAJM_SAVED_THEME_VALUE, NAlert, type NAppCommandItem, NAppShell, type NAppShellAction, type NAppShellClassNames, type NAppShellProps, type NAppShellUser, NCard as NAsyncCard, type CardClassNames as NAsyncCardClassNames, type CardProps as NAsyncCardProps, NAvatar, type NAvatarClassNames, type NAvatarProps, type AvatarShape as NAvatarShape, NBadge, type NBadgeLook, type NBadgeProps, NBarChart, type NBarChartProps, type NBulkAction, type NBulkActionButton, type NBulkActionSelect, NBulkActionsBar, type NBulkActionsBarProps, NButton, type NButtonProps, NCard, NCardAction, type CardClassNames as NCardClassNames, type NCardDensity, NCardFooter, NCardInfo, type NCardInfoProps, NCardMedia, type NCardMediaAspect, type NCardMediaPlacement, type NCardMediaProps, type NCardMediaSize, type NCardMediaVariant, type CardProps as NCardProps, NCardSection, type NCardSectionProps, type NCardSectionSurface, type NCartesianChartProps, type NChartCardProps, type NChartDatum, type NChartItem, type NChartSeries, type NChartSize, NChartSkeleton, type NChartSkeletonProps, type NChartSkeletonVariant, NCommandPalette, type NCommandPaletteProps, NConfirmDialog, type NConfirmDialogProps, NContextMenu, type NContextMenuItem, type NContextMenuProps, NDataCardShell, type NDataCardShellActions, type NDataCardShellProps, NDeleteDialog, NDeleteDialogContent, type NDeleteDialogContentProps, type NDeleteDialogProps, NDetailCard, type NDetailCardClassNames, type NDetailCardProps, NDetailItem, type NDetailItemProps, NDetailList, type NDetailListItem, type NDetailListProps, NDialog, type NDialogActionProps, NDialogDescription, type NDialogDescriptionProps, type NDialogDirectProps, NDialogHeader, type NDialogHeaderProps, NDialogPrimaryButton, type NDialogProps, NDialogSecondaryButton, NDonutCard, type NDonutCardClassNames, type NDonutCardItem, type NDonutCardLayout, type NDonutCardLegendMarker, type NDonutCardProps, type NDonutCardVariant, type NEditorTab, NEditorTabs, type NEditorTabsProps, NEmptyState, type NEmptyStateProps, NErrorBoundary, NErrorState, type NErrorStateProps, NFileBrowser, type NFileBrowserCardProps, type NFileBrowserProps, type NFileBrowserRenderThumbProps, NFileTypeIcon, type NFileTypeIconProps, NFilterBar, NFolderIcon, type NFolderIconProps, NForm, NFormSectionHeader, type NFormSectionHeaderProps, NGrid, type NGridCols, NGridItem, type NGridItemProps, type NGridProps, type NGridSpan, NIcon, type NIconProps, type NIconSource, NImage, type NImageProps, NIndicator, NInspectorSheet, NLineChart, type NLineChartProps, NLoadingState, type NLoadingStateProps, NMultiDialog, type NMultiDialogProps, NNavbar, NPageHeader, NPageHeaderActions, type NPageHeaderBreakpoint, NPageHeaderCompactActions, NPageHeaderFilters, type NPageHeaderProps, NPageHeaderTop, NPageLayout, type NPageLayoutProps, NPieChart, type NPieChartProps, NPortalScopeProvider, NProgress, type NProgressProps, NRowActions, NSection, NSectionHeader, type NSectionHeaderActionsProps, type NSectionHeaderContentProps, type NSectionHeaderProps, type NSectionHeaderSubtitleProps, type NSectionHeaderTitleProps, NSectionInfo, type NSectionInfoProps, type NSectionProps, NSectionWithInfo, type NSectionWithInfoItem, type NSectionWithInfoProps, NSheet, type NSheetClassNames, type NSheetProps, NSidebar, NSidebarBrand, type NSidebarBrandProps, NSidebarContent, type NSidebarContentProps, type NSidebarContextValue, NSidebarFooter, type NSidebarFooterProps, NSidebarHeader, type NSidebarHeaderProps, NSidebarItem, NSidebarMobile, type NSidebarMobileProps, NSidebarProvider, NSidebarSection, type NSidebarSectionProps, NSkeleton, NSkeletonCalendar, NSkeletonChart, NSkeletonDonut, NSkeletonEventList, NSkeletonWidget, NSkeletonWidgets, NSlider, type NSliderProps, NSmartPasteDialog, type NSmartPasteDialogProps, NSpinner, type NSpinnerProps, NStatCard, type NStatCardClassNames, type NStatCardProps, NStatCardSkeleton, type NStatCardVariant, NStatusBreakdown, type NStatusBreakdownProps, Swap as NSwap, type NSwapProps, NTable, NTableCardPagination, NTableCardRoot, type NTableCardRootProps, NTableCards, type NTableClassNames, type NTableColumnBreakpoint, type NTableColumnDef, type NTableColumnMeta, NTableContent, NTableHeader, NTableLoadingSkeleton, type NTableMenu, type NTableMenuProp, type NTablePageItem, NTablePagination, NTablePaginationLabels, NTablePaginationVariant, type NTableProps, NTableRowSkeleton, NTableSkeleton, type NTableState, NTabs, type NTabsClassNames, type NTabsColor, type NTabsItem, type NTabsProps, type NTabsStyles, NThemeCustomizer, type NThemeCustomizerFontOption, type NThemeCustomizerLabels, type NThemeCustomizerProps, type NThemeCustomizerTab, type NThemePreset, NThemePresets, type NThemePresetsLabels, type NThemePresetsProps, type NThemePresetsStatus, NUploader, type NUploaderItem, type NUploaderItemStatus, type NUploaderProps, NViewBody, NViewToggle, NajmAccent, NajmAppearance, type NajmBorderSide, NajmComponentName, NajmComponentStyleConfig, NajmComponentThemeConfig, NajmDesignConfig, NajmDesignEditorProvider, type NajmDesignEditorProviderProps, type NajmDesignEditorValue, NajmDesignProvider, type NajmDesignProviderProps, NajmLayoutConfig, NajmMode, NajmPreset, NajmResponsiveBreakpoint, NajmResponsiveValue, NajmScroll, type NajmScrollProps, NajmThemeConfig, NajmThemeProvider, NajmThemeProviderProps, NajmThemeTokens, NajmTypographyConfig, NajmVariantStyle, NativeSelect, type NativeSelectOption, type NativeSelectProps, type NavItem, type NavItemGroup, NumberInput, type NumberInputProps, OtpInput, type OtpInputProps, PasswordInput, type PasswordInputProps, PhoneInput, type PhoneInputProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PrefixProvider, Progress, type ProgressColor, type ProgressLabelPosition, type ProgressProps, type ProgressSize, type PushDialogOptions, RadioGroup, RadioGroupInput, type RadioGroupInputProps, RadioGroupItem, type RenderSlot, RepeatingFields, type RepeatingFieldsProps, ScrollArea, type ScrollAreaProps, SearchField, SearchField as SearchInput, SegmentedControl, type SegmentedControlOption, type SegmentedControlProps, Select, SelectContent, SelectGroup, SelectInput, type SelectInputProps, SelectItem, type SelectItemType$1 as SelectItemDataType, type SelectItemType, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, type SidebarItemProps, type SidebarLogo, type SidebarLogoRender, type SidebarProps, type SidebarWidth, type SidebarWidths, SimpleTooltip, type SimpleTooltipProps, NSkeleton as Skeleton, Slider, SliderInput, type SliderInputProps, type SliderOrientation, type SliderProps, type SliderSize, type SliderVariant, type SmartPastePreview, type SpinnerVariant, StarRatingInput, type StarRatingInputProps, StatusPill, type StatusPillProps, type StatusPillTone, type StepConfig, StepIndicator, type StepMeta, StepsHeader, StepsProgress, type StorageMenuAction, type StorageSortOption, type StorageTarget, Swap, type SwapEffect, SwapIndeterminate, SwapOff, SwapOn, type SwapProps, type SwapSize, type SwapState, Switch, type SwitchColor, SwitchInput, type SwitchInputProps, type SwitchSize, TAB_COLORS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, type TableHeaderColor, TableRow, type TableState, type TableStore, TableStoreContext, Tabs, TabsContent, TabsList, type TabsListProps, type TabsOrientation, type TabsProps, TabsTrigger, type TabsTriggerProps, type TabsVariant, TextAreaInput, type TextAreaInputProps, TextInput, type TextInputProps, Textarea, TimeInput, type TimeInputProps, TimeZoneInput, type TimeZoneInputProps, Toaster, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseContextMenuResult, type UseNFormOptions, type UseStorageContextMenuOptions, type UseStorageContextMenuResult, type UserMenuAction, VariantProvider, type WizardClassNames, WizardForm, type WizardFormProps, alertVariants, avatarVariants, badgeColorVariants, badgeVariants, buildDefaultFileColumns, buildPageItems, buttonVariants, cn, composePreset, createDialogStore, createTableStore, defineNajmDesignConfig, defineNajmThemeConfig, detectFormat, dialogVariants, filterResponsiveColumns, formatColor, formatFileBytes, formatFileRelative, getIconColorProps, getNChartColor, getNextEditorTabValue, hiddenBelowClasses, indicatorVariants, inputBorderClasses, normalizeThemeFileName, parseColor, parseNajmDesignConfig, parseNajmThemeConfig, parseThemeFile, resolveHiddenBelowClass, resolvePreset, resolveSlot, resolveVariantAlias, sidebarBorderClasses, sliderVariants, stringifyNajmDesignConfig, stringifyNajmThemeConfig, stringifyThemeFile, surfaceBorderClasses, swapVariants, toPickerHex, toggleVariants, tooltipContentVariants, truncateByCharacters, useClickOutside, useContextMenu, useDebouncedValue, useDelayedLoading, useDialog, useDialogStore, useDynamicPageSize, useFormField, useFormSubmission, useInfiniteScroll, useKeyboard, useLocalStorageState, useNForm, useNPortalScope, useNSidebar, useNajmAppearance, useNajmComponentStyle, useNajmDesign, useNajmDesignEditor, useNajmThemeMode, usePrefix, useSelection, useStepNavigation, useStorageContextMenu, useStoreSync, useTable, useTableKeyboard, useTableStore, useVariant, useVariantPreset };
|
|
4264
|
+
export { Alert, type AlertLook, type AlertOrientation, type AlertProps, type AlertSize, type AlertTone, type AlertVariant, NCard as AsyncCard, Avatar, AvatarFallback, AvatarFormInput, type AvatarFormInputProps, AvatarGroup, type AvatarGroupProps, AvatarImage, AvatarInput, type AvatarInputProps, type AvatarInputRadius, type AvatarProps$1 as AvatarProps, type AvatarShape$1 as AvatarShape, type AvatarSize, AvatarStatus, type AvatarStatusType, Badge, type BadgeColor, type BadgeIcon, type BadgeLook, type BadgeProps, type BadgeShape, type BadgeSize, type BadgeVariant, BaseInput, type BuildDefaultFileColumnsOptions, Button, type ButtonConfig, type ButtonIcon, type ButtonLoaderPosition, type ButtonProps, type ButtonRounded, type ButtonSize, type ButtonVariant, Calendar, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxGroupInput, type CheckboxGroupInputProps, CheckboxInput, type CheckboxInputProps, Collapsible, CollapsibleContent, CollapsibleTrigger, ColorArrayInput, type ColorArrayInputProps, type ColorFormat, ColorPickerInput, type ColorPickerInputProps, Combobox, ComboboxInput, type ComboboxInputProps, type ComboboxOption, type ComboboxProps, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, type ContextMenuItem, DEFAULT_CARD_BREAKPOINT, DEFAULT_PLACEHOLDER, DEFAULT_THEME_FILE_NAME, DateInput, type DateInputProps, type DeleteDialogOptions, Dialog, type DialogActionMode, type DialogApi, DialogClose, type DialogConfig, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogHeader, type DialogHeight, DialogOverlay, type DialogPadding, DialogPortal, type DialogRenderContext, type DialogRenderer, type DialogSize, type DialogStore, DialogTitle, DialogTrigger, type DialogVariant, type DialogWidth, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DynamicArray, type DynamicArrayProps, EMPTY_DESIGN, EmojiInput, type EmojiInputProps, type FileBrowserMode, FileImportButton, FileInput, type FileInputProps, type FileNode, Form, FormControl, FormDescription, FormField, FormInput, type FormInputBackground, type FormInputProps, FormItem, FormLabel, FormMessage, type FormProps, type FormSlotClassNames, type FormVariant, IconButton, type IconButtonProps, type IconButtonSize, type IconButtonVariant, ImageInput, type ImageInputPreviewError, type ImageInputPreviewSource, type ImageInputProps, Indicator, type IndicatorHorizontal, type IndicatorOverlay, type IndicatorPosition, type IndicatorProps, type IndicatorResponsivePosition, type IndicatorSize, type IndicatorVertical, Input, type InputIcon, Label, LangInput, type LangInputProps, type LinkComponentType, MultiSelectInput, type MultiSelectInputProps, NAJM_SAVED_THEME_VALUE, NAlert, type NAppCommandItem, NAppShell, type NAppShellAction, type NAppShellClassNames, type NAppShellProps, type NAppShellUser, NCard as NAsyncCard, type CardClassNames as NAsyncCardClassNames, type CardProps as NAsyncCardProps, NAvatar, type NAvatarClassNames, type NAvatarProps, type AvatarShape as NAvatarShape, NBadge, type NBadgeLook, type NBadgeProps, NBarChart, type NBarChartProps, type NBulkAction, type NBulkActionButton, type NBulkActionSelect, NBulkActionsBar, type NBulkActionsBarProps, NButton, type NButtonProps, NCard, NCardAction, type CardClassNames as NCardClassNames, type NCardDensity, NCardFooter, NCardInfo, type NCardInfoProps, NCardMedia, type NCardMediaAspect, type NCardMediaPlacement, type NCardMediaProps, type NCardMediaSize, type NCardMediaVariant, type CardProps as NCardProps, NCardSection, type NCardSectionProps, type NCardSectionSurface, type NCartesianChartProps, type NChartCardProps, type NChartDatum, type NChartItem, type NChartSeries, type NChartSize, NChartSkeleton, type NChartSkeletonProps, type NChartSkeletonVariant, NCommandPalette, type NCommandPaletteProps, NConfirmDialog, type NConfirmDialogProps, NContextMenu, type NContextMenuItem, type NContextMenuProps, NDataCardShell, type NDataCardShellActions, type NDataCardShellProps, NDeleteDialog, NDeleteDialogContent, type NDeleteDialogContentProps, type NDeleteDialogProps, NDetailCard, type NDetailCardClassNames, type NDetailCardProps, NDetailItem, type NDetailItemProps, NDetailList, type NDetailListItem, type NDetailListProps, NDialog, type NDialogActionProps, NDialogDescription, type NDialogDescriptionProps, type NDialogDirectProps, NDialogHeader, type NDialogHeaderProps, NDialogPrimaryButton, type NDialogProps, NDialogSecondaryButton, NDonutCard, type NDonutCardClassNames, type NDonutCardItem, type NDonutCardLayout, type NDonutCardLegendMarker, type NDonutCardProps, type NDonutCardVariant, type NEditorTab, NEditorTabs, type NEditorTabsProps, NEmptyState, type NEmptyStateProps, NErrorBoundary, NErrorState, type NErrorStateProps, NFileBrowser, type NFileBrowserCardProps, type NFileBrowserProps, type NFileBrowserRenderThumbProps, NFileTypeIcon, type NFileTypeIconProps, NFilterBar, NFolderIcon, type NFolderIconProps, NForm, NFormSectionHeader, type NFormSectionHeaderProps, NGrid, type NGridCols, NGridItem, type NGridItemProps, type NGridProps, type NGridSpan, NIcon, type NIconProps, type NIconSource, NImage, type NImageProps, NIndicator, NInspectorSheet, NLineChart, type NLineChartProps, NLoadingState, type NLoadingStateProps, NMultiDialog, type NMultiDialogProps, NNavbar, NPageHeader, NPageHeaderActions, type NPageHeaderBreakpoint, NPageHeaderCompactActions, NPageHeaderFilters, type NPageHeaderProps, NPageHeaderTop, NPageLayout, type NPageLayoutProps, NPieChart, type NPieChartProps, NPortalScopeProvider, NProgress, type NProgressProps, NRowActions, NSection, NSectionHeader, type NSectionHeaderActionsProps, type NSectionHeaderContentProps, type NSectionHeaderProps, type NSectionHeaderSubtitleProps, type NSectionHeaderTitleProps, NSectionInfo, type NSectionInfoProps, type NSectionProps, NSectionWithInfo, type NSectionWithInfoItem, type NSectionWithInfoProps, NSheet, type NSheetClassNames, type NSheetProps, NSidebar, NSidebarBrand, type NSidebarBrandProps, NSidebarContent, type NSidebarContentProps, type NSidebarContextValue, NSidebarFooter, type NSidebarFooterProps, NSidebarHeader, type NSidebarHeaderProps, NSidebarItem, NSidebarMobile, type NSidebarMobileProps, NSidebarProvider, NSidebarSection, type NSidebarSectionProps, NSkeleton, NSkeletonCalendar, NSkeletonChart, NSkeletonDonut, NSkeletonEventList, NSkeletonWidget, NSkeletonWidgets, NSlider, type NSliderProps, NSmartPasteDialog, type NSmartPasteDialogProps, NSpinner, type NSpinnerProps, NStatCard, type NStatCardClassNames, type NStatCardProps, NStatCardSkeleton, type NStatCardVariant, NStatusBreakdown, type NStatusBreakdownProps, Swap as NSwap, type NSwapProps, NTable, NTableCardPagination, NTableCardRoot, type NTableCardRootProps, NTableCards, type NTableClassNames, type NTableColumnBreakpoint, type NTableColumnDef, type NTableColumnMeta, NTableContent, NTableHeader, NTableLoadingSkeleton, type NTableMenu, type NTableMenuProp, type NTablePageItem, NTablePagination, NTablePaginationLabels, NTablePaginationVariant, type NTableProps, NTableRowSkeleton, NTableSkeleton, type NTableState, NTabs, type NTabsClassNames, type NTabsColor, type NTabsItem, type NTabsProps, type NTabsStyles, NThemeCustomizer, type NThemeCustomizerFontOption, type NThemeCustomizerLabels, type NThemeCustomizerProps, type NThemeCustomizerTab, type NThemePreset, NThemePresets, type NThemePresetsLabels, type NThemePresetsProps, type NThemePresetsStatus, NUploader, type NUploaderItem, type NUploaderItemStatus, type NUploaderProps, NViewBody, NViewToggle, NajmAccent, NajmAppearance, type NajmBorderSide, NajmComponentName, NajmComponentStyleConfig, NajmComponentThemeConfig, NajmDesignConfig, NajmDesignEditorProvider, type NajmDesignEditorProviderProps, type NajmDesignEditorValue, NajmDesignProvider, type NajmDesignProviderProps, type NajmFormatConfig, type NajmFormatContextValue, NajmFormatProvider, type NajmFormatProviderProps, NajmLayoutConfig, NajmMode, NajmPreset, NajmResponsiveBreakpoint, NajmResponsiveValue, NajmScroll, type NajmScrollProps, NajmThemeConfig, NajmThemeProvider, NajmThemeProviderProps, NajmThemeTokens, NajmTypographyConfig, NajmVariantStyle, NativeSelect, type NativeSelectOption, type NativeSelectProps, type NavItem, type NavItemGroup, NumberInput, type NumberInputProps, OtpInput, type OtpInputProps, PasswordInput, type PasswordInputProps, PhoneInput, type PhoneInputProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PrefixProvider, Progress, type ProgressColor, type ProgressLabelPosition, type ProgressProps, type ProgressSize, type PushDialogOptions, RadioGroup, RadioGroupInput, type RadioGroupInputProps, RadioGroupItem, type RenderSlot, RepeatingFields, type RepeatingFieldsProps, ScrollArea, type ScrollAreaProps, SearchField, SearchField as SearchInput, SegmentedControl, type SegmentedControlOption, type SegmentedControlProps, Select, SelectContent, SelectGroup, SelectInput, type SelectInputProps, SelectItem, type SelectItemType$1 as SelectItemDataType, type SelectItemType, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, type SidebarItemProps, type SidebarLogo, type SidebarLogoRender, type SidebarProps, type SidebarWidth, type SidebarWidths, SimpleTooltip, type SimpleTooltipProps, NSkeleton as Skeleton, Slider, SliderInput, type SliderInputProps, type SliderOrientation, type SliderProps, type SliderSize, type SliderVariant, type SmartPastePreview, type SpinnerVariant, StarRatingInput, type StarRatingInputProps, StatusPill, type StatusPillProps, type StatusPillTone, type StepConfig, StepIndicator, type StepMeta, StepsHeader, StepsProgress, type StorageMenuAction, type StorageSortOption, type StorageTarget, Swap, type SwapEffect, SwapIndeterminate, SwapOff, SwapOn, type SwapProps, type SwapSize, type SwapState, Switch, type SwitchColor, SwitchInput, type SwitchInputProps, type SwitchSize, TAB_COLORS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, type TableHeaderColor, TableRow, type TableState, type TableStore, TableStoreContext, Tabs, TabsContent, TabsList, type TabsListProps, type TabsOrientation, type TabsProps, TabsTrigger, type TabsTriggerProps, type TabsVariant, TextAreaInput, type TextAreaInputProps, TextInput, type TextInputProps, Textarea, TimeInput, type TimeInputProps, TimeZoneInput, type TimeZoneInputProps, Toaster, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseContextMenuResult, type UseNFormOptions, type UseStorageContextMenuOptions, type UseStorageContextMenuResult, type UserMenuAction, VariantProvider, type WizardClassNames, WizardForm, type WizardFormProps, alertVariants, avatarVariants, badgeColorVariants, badgeVariants, buildDefaultFileColumns, buildPageItems, buttonVariants, cn, composePreset, createDialogStore, createTableStore, defineNajmDesignConfig, defineNajmThemeConfig, detectFormat, dialogVariants, filterResponsiveColumns, formatColor, formatCurrency, formatDate, formatDateTime, formatFileBytes, formatFileRelative, formatNumber, formatPercent, formatRelativeTime, formatTime, getIconColorProps, getNChartColor, getNextEditorTabValue, hiddenBelowClasses, humanizeToken, indicatorVariants, inputBorderClasses, normalizeThemeFileName, parseColor, parseNajmDesignConfig, parseNajmThemeConfig, parseThemeFile, resolveHiddenBelowClass, resolvePreset, resolveSlot, resolveVariantAlias, sidebarBorderClasses, sliderVariants, stringifyNajmDesignConfig, stringifyNajmThemeConfig, stringifyThemeFile, surfaceBorderClasses, swapVariants, toPickerHex, toggleVariants, tooltipContentVariants, truncateByCharacters, useCardViewport, useClickOutside, useContextMenu, useDebouncedValue, useDelayedLoading, useDesktopTableMode, useDialog, useDialogStore, useDynamicPageSize, useFormField, useFormSubmission, useInfiniteScroll, useKeyboard, useLocalStorageState, useMediaQuery, useNForm, useNPortalScope, useNSidebar, useNajmAppearance, useNajmComponentStyle, useNajmDesign, useNajmDesignEditor, useNajmFormat, useNajmFormatContext, useNajmThemeMode, usePrefix, useSelection, useStepNavigation, useStorageContextMenu, useStoreSync, useTable, useTableKeyboard, useTableStore, useVariant, useVariantPreset };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { useNBranding } from './chunk-
|
|
2
|
-
export { NBrandingProvider, NBrandingStateProvider, normalizeBranding, useNBranding, useNBrandingEditor } from './chunk-
|
|
1
|
+
import { useNBranding } from './chunk-QOP7L6RD.mjs';
|
|
2
|
+
export { DEFAULT_PLACEHOLDER, NBrandingProvider, NBrandingStateProvider, NajmFormatProvider, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTime, humanizeToken, normalizeBranding, useNBranding, useNBrandingEditor, useNajmFormat, useNajmFormatContext } from './chunk-QOP7L6RD.mjs';
|
|
3
3
|
import { useResolvedPaginationLabels } from './chunk-USZUOJMK.mjs';
|
|
4
4
|
export { DEFAULT_PAGINATION_KEY_PREFIX, DEFAULT_TIME_ZONE, EMPTY_DESIGN, NTableDefaultsProvider, NajmDesignEditorProvider, NajmPreferencesProvider, NajmUIProvider, buildPaginationLabels, useNTableDefaults, useNajmDesignEditor, useNajmPreferencesContext, useNajmTheme, useNajmTimeZone } from './chunk-USZUOJMK.mjs';
|
|
5
5
|
import { resolveRadiusValue, inputBorderClasses, Button, NIcon, NajmScroll, surfaceBorderClasses, useNajmScrollViewport, resolveVariantAlias, buttonVariants, NButton, parseNajmDesignConfig, useTableStore, TableStoreContext, sidebarBorderClasses, NTableJson } from './chunk-6OOBAEH2.mjs';
|
|
6
6
|
export { Button, NAJM_COMPONENT_NAMES, NButton, NIcon, NTableJson, NajmScroll, RADIUS_VALUE_MAP, TableStoreContext, buttonVariants, defineNajmDesignConfig, defineNajmThemeConfig, inputBorderClasses, parseNajmDesignConfig, parseNajmThemeConfig, resolveRadiusValue, resolveVariantAlias, sidebarBorderClasses, stringifyNajmDesignConfig, stringifyNajmThemeConfig, surfaceBorderClasses, useTableStore } from './chunk-6OOBAEH2.mjs';
|
|
7
7
|
import { useNajmComponentStyle, cn, NajmThemeContainerCtx, useNajmThemeMode, useNajmDesign, composePreset } from './chunk-KVZACF4G.mjs';
|
|
8
8
|
export { NajmDesignProvider, NajmThemeProvider, cn, composePreset, resolvePreset, useNajmAppearance, useNajmComponentStyle, useNajmDesign, useNajmThemeMode } from './chunk-KVZACF4G.mjs';
|
|
9
|
+
export { DEFAULT_CARD_BREAKPOINT, DEFAULT_CARD_PAGINATION_KEY_PREFIX, DEFAULT_MAX_PAGE_SIZE, DEFAULT_PAGE_SIZE, buildCardPaginationLabels, cleanQuery, createCardPagination, createOffsetPagination, fetchOffsetPage, getPageIndex, useCardViewport, useDesktopTableMode, useMediaQuery } from './chunk-7J7DWGKB.mjs';
|
|
9
10
|
import * as React60 from 'react';
|
|
10
11
|
import React60__default, { createContext, useRef, useMemo, useState, useEffect, useContext, useCallback, useLayoutEffect, isValidElement } from 'react';
|
|
11
12
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { e as NajmTranslate, b as NTableCardPagination } from './paginationLabels-CY2PvbMj.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How a list continues.
|
|
5
|
+
*
|
|
6
|
+
* - `paged` — numbered pages on desktop, scroll continuation on card viewports.
|
|
7
|
+
* - `infinite` — scroll continuation everywhere.
|
|
8
|
+
* - `all` — one request for the whole set, no controls. Only valid for a list
|
|
9
|
+
* with a proven bound.
|
|
10
|
+
*/
|
|
11
|
+
type ListStrategy = "all" | "infinite" | "paged";
|
|
12
|
+
/** The presentation mode resolved for the current viewport and strategy. */
|
|
13
|
+
type ResolvedListMode = "all" | "infinite" | "paged";
|
|
14
|
+
interface CardPaginationState {
|
|
15
|
+
/**
|
|
16
|
+
* The resolved mode. When omitted, `cardViewport` alone decides — a card
|
|
17
|
+
* viewport continues on scroll, a desktop one paginates.
|
|
18
|
+
*/
|
|
19
|
+
mode?: ResolvedListMode;
|
|
20
|
+
cardViewport?: boolean;
|
|
21
|
+
hasNextPage: boolean;
|
|
22
|
+
loadingMore: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Truthy when the last append failed. The value is not rendered — the message
|
|
25
|
+
* shown is `loadMoreError` from the labels, so a thrown `Error` or an API
|
|
26
|
+
* envelope can be passed straight through without leaking its text into the UI.
|
|
27
|
+
*/
|
|
28
|
+
loadMoreError?: unknown;
|
|
29
|
+
onLoadMore: () => unknown | Promise<unknown>;
|
|
30
|
+
}
|
|
31
|
+
interface CardPaginationLabels {
|
|
32
|
+
loadMoreError?: string;
|
|
33
|
+
retryLabel?: string;
|
|
34
|
+
itemsLoaded?: (count: number) => string;
|
|
35
|
+
}
|
|
36
|
+
declare const DEFAULT_CARD_PAGINATION_KEY_PREFIX = "common.pagination";
|
|
37
|
+
/**
|
|
38
|
+
* Projects a translator onto the three card-continuation labels, matching
|
|
39
|
+
* `buildPaginationLabels` — same prefix convention, same key-per-field naming.
|
|
40
|
+
*/
|
|
41
|
+
declare function buildCardPaginationLabels(t: NajmTranslate, prefix?: string): CardPaginationLabels;
|
|
42
|
+
/**
|
|
43
|
+
* Builds the `cardPagination` prop from the state a paged list already holds.
|
|
44
|
+
*
|
|
45
|
+
* The three modes are not interchangeable presentations of one thing: `paged`
|
|
46
|
+
* hands page-size control back to NTable, which measures the container and
|
|
47
|
+
* reports the size it wants through `onPaginationChange`; `all` renders exactly
|
|
48
|
+
* what it is given and shows no controls; `infinite` is the only one that needs
|
|
49
|
+
* continuation wiring, which is why the other two ignore the labels entirely.
|
|
50
|
+
*/
|
|
51
|
+
declare function createCardPagination(state: CardPaginationState, labels?: CardPaginationLabels): NTableCardPagination;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The offset-pagination protocol behind `NTable`'s page controls.
|
|
55
|
+
*
|
|
56
|
+
* The kit already owns the consuming half — `useDynamicPageSize` measures how
|
|
57
|
+
* many rows fit, `buildPageItems` renders the bar. This is the fetching half:
|
|
58
|
+
* how one page is requested, and how "is there another one" is answered when
|
|
59
|
+
* the endpoint does not say.
|
|
60
|
+
*
|
|
61
|
+
* Pure, framework-agnostic, and usable on the server. Nothing here knows about
|
|
62
|
+
* react-query.
|
|
63
|
+
*/
|
|
64
|
+
/** A page response from an endpoint that reports a result total. */
|
|
65
|
+
interface ApiPage<T> {
|
|
66
|
+
rows: T[];
|
|
67
|
+
/** Rows matching the query on the server, or `null` if the endpoint is silent. */
|
|
68
|
+
total: number | null;
|
|
69
|
+
}
|
|
70
|
+
interface OffsetPagination {
|
|
71
|
+
limit: number;
|
|
72
|
+
offset: number;
|
|
73
|
+
}
|
|
74
|
+
interface OffsetPage<T> {
|
|
75
|
+
rows: T[];
|
|
76
|
+
hasNextPage: boolean;
|
|
77
|
+
nextOffset: number;
|
|
78
|
+
/** How many rows match in total, or `null` if the endpoint does not say. */
|
|
79
|
+
total: number | null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Fetches one window.
|
|
83
|
+
*
|
|
84
|
+
* The bare-array return is not a legacy concession to delete later: plenty of
|
|
85
|
+
* endpoints have no cheap way to count, and `COUNT(*)` over a filtered join is
|
|
86
|
+
* exactly the query worth avoiding. Both shapes are first-class.
|
|
87
|
+
*/
|
|
88
|
+
type OffsetPageFetcher<T> = (pagination: OffsetPagination) => Promise<ApiPage<T> | T[]>;
|
|
89
|
+
declare const DEFAULT_PAGE_SIZE = 25;
|
|
90
|
+
/**
|
|
91
|
+
* The largest `limit` a server will honour. Requests are clamped to it, and it
|
|
92
|
+
* is the ceiling the probe row cannot exceed — see `fetchOffsetPage`.
|
|
93
|
+
*/
|
|
94
|
+
declare const DEFAULT_MAX_PAGE_SIZE = 100;
|
|
95
|
+
interface OffsetPageOptions {
|
|
96
|
+
/** Defaults to `DEFAULT_MAX_PAGE_SIZE`. Match your server's clamp. */
|
|
97
|
+
maxLimit?: number;
|
|
98
|
+
}
|
|
99
|
+
declare function createOffsetPagination(pageIndex?: number, pageSize?: number, { maxLimit }?: OffsetPageOptions): OffsetPagination;
|
|
100
|
+
declare function getPageIndex({ limit, offset }: OffsetPagination): number;
|
|
101
|
+
/**
|
|
102
|
+
* Fetches one page and answers whether another follows.
|
|
103
|
+
*
|
|
104
|
+
* Two strategies, chosen by what the endpoint returns:
|
|
105
|
+
*
|
|
106
|
+
* - **With a total**, continuation is arithmetic — no extra rows, no extra
|
|
107
|
+
* request.
|
|
108
|
+
* - **Without one**, the request carries a *probe row*: it asks for `limit + 1`
|
|
109
|
+
* and reports a next page when that extra row comes back. The probe is
|
|
110
|
+
* discarded before returning, so callers always receive at most `limit` rows.
|
|
111
|
+
*
|
|
112
|
+
* Whether an endpoint reports a total is only knowable from its response, so
|
|
113
|
+
* the probe row rides along on the first request either way. The one case the
|
|
114
|
+
* probe cannot cover is a request already at `maxLimit`, where there is no room
|
|
115
|
+
* to ask for one more; continuation then costs a second single-row lookahead.
|
|
116
|
+
* That is the case a result total exists to avoid, and why the endpoints
|
|
117
|
+
* backing numbered pages should report one.
|
|
118
|
+
*/
|
|
119
|
+
declare function fetchOffsetPage<T>(fetchPage: OffsetPageFetcher<T>, pagination: OffsetPagination, { maxLimit }?: OffsetPageOptions): Promise<OffsetPage<T>>;
|
|
120
|
+
type QueryValue = string | number | boolean | null | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Drops empty entries from a query object, so an untouched filter contributes
|
|
123
|
+
* no parameter at all rather than `?status=`.
|
|
124
|
+
*
|
|
125
|
+
* `false` and `0` are kept — both are meaningful filter values, and dropping
|
|
126
|
+
* them is the bug this exists to prevent.
|
|
127
|
+
*/
|
|
128
|
+
declare function cleanQuery(query: Record<string, QueryValue>): Record<string, QueryValue>;
|
|
129
|
+
|
|
130
|
+
export { type ApiPage as A, type CardPaginationLabels as C, DEFAULT_CARD_PAGINATION_KEY_PREFIX as D, type ListStrategy as L, type OffsetPage as O, type QueryValue as Q, type ResolvedListMode as R, type CardPaginationState as a, DEFAULT_MAX_PAGE_SIZE as b, DEFAULT_PAGE_SIZE as c, type OffsetPageFetcher as d, type OffsetPageOptions as e, type OffsetPagination as f, buildCardPaginationLabels as g, cleanQuery as h, createCardPagination as i, createOffsetPagination as j, fetchOffsetPage as k, getPageIndex as l };
|