najm-kit 2.7.2 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
3
  import React__default from 'react';
4
- import { a as NTablePaginationLabels, e as NajmTranslate } from './paginationLabels-CY2PvbMj.js';
4
+ import { b as NTablePaginationLabels, N as NajmTranslate } from './paginationLabels-DgHutNWz.js';
5
5
 
6
6
  type NajmMode = 'light' | 'dark';
7
7
  type NajmAccent = 'neutral' | 'emerald' | 'green' | 'slate' | 'blue' | 'violet';
@@ -3,8 +3,8 @@ import { Translations } from 'najm-i18n';
3
3
  import { N as NBrandingInput } from '../NBrandingContext-dkADu8JS.js';
4
4
  import { NajmNextUIProviderProps } from './next.js';
5
5
  import 'react';
6
- import '../NajmUIProvider-ClpHD-55.js';
7
- import '../paginationLabels-CY2PvbMj.js';
6
+ import '../NajmUIProvider-IFU3dFkn.js';
7
+ import '../paginationLabels-DgHutNWz.js';
8
8
 
9
9
  /** Branding shown by the kit's chrome. Purely presentational values. */
10
10
  interface NajmAppBranding {
@@ -1,8 +1,9 @@
1
1
  'use client';
2
- import { NBrandingStateProvider, NajmFormatProvider } from '../chunk-QOP7L6RD.mjs';
2
+ import { NBrandingStateProvider, NajmFormatProvider } from '../chunk-VKQIRB7F.mjs';
3
3
  import { NajmNextUIProvider } from '../chunk-IRFFSAO2.mjs';
4
4
  import '../chunk-USZUOJMK.mjs';
5
5
  import '../chunk-KVZACF4G.mjs';
6
+ import '../chunk-GPHWBOSP.mjs';
6
7
  import * as React from 'react';
7
8
  import { I18nProvider, useTranslation } from 'najm-i18n/react';
8
9
  import { jsx } from 'react/jsx-runtime';
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React__default from 'react';
3
- import { N as NajmUIProviderProps } from '../NajmUIProvider-ClpHD-55.js';
4
- import '../paginationLabels-CY2PvbMj.js';
3
+ import { N as NajmUIProviderProps } from '../NajmUIProvider-IFU3dFkn.js';
4
+ import '../paginationLabels-DgHutNWz.js';
5
5
 
6
6
  interface NextLinkAdapterProps extends Record<string, any> {
7
7
  href: string;
@@ -0,0 +1,53 @@
1
+ import { N as NajmTranslate, a as NTableCardPagination } from './paginationLabels-DgHutNWz.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
+ export { type CardPaginationLabels as C, DEFAULT_CARD_PAGINATION_KEY_PREFIX as D, type ListStrategy as L, type ResolvedListMode as R, type CardPaginationState as a, buildCardPaginationLabels as b, createCardPagination as c };
@@ -0,0 +1,42 @@
1
+ // src/lib/pagination.ts
2
+ var DEFAULT_PAGE_SIZE = 25;
3
+ var DEFAULT_MAX_PAGE_SIZE = 100;
4
+ function toApiPage(result) {
5
+ return Array.isArray(result) ? { rows: result, total: null } : result;
6
+ }
7
+ function createOffsetPagination(pageIndex = 0, pageSize = DEFAULT_PAGE_SIZE, { maxLimit = DEFAULT_MAX_PAGE_SIZE } = {}) {
8
+ const safePageIndex = Math.max(0, Math.trunc(pageIndex));
9
+ const safePageSize = Math.min(maxLimit, Math.max(1, Math.trunc(pageSize)));
10
+ return { limit: safePageSize, offset: safePageIndex * safePageSize };
11
+ }
12
+ function getPageIndex({ limit, offset }) {
13
+ return Math.floor(Math.max(0, offset) / Math.max(1, limit));
14
+ }
15
+ async function fetchOffsetPage(fetchPage, pagination, { maxLimit = DEFAULT_MAX_PAGE_SIZE } = {}) {
16
+ const requestedLimit = Math.min(maxLimit, Math.max(1, pagination.limit));
17
+ const probeLimit = requestedLimit < maxLimit ? requestedLimit + 1 : requestedLimit;
18
+ const page = toApiPage(
19
+ await fetchPage({ limit: probeLimit, offset: pagination.offset })
20
+ );
21
+ const rows = page.rows.slice(0, requestedLimit);
22
+ const nextOffset = pagination.offset + rows.length;
23
+ if (page.total !== null) {
24
+ return {
25
+ rows,
26
+ hasNextPage: nextOffset < page.total,
27
+ nextOffset,
28
+ total: page.total
29
+ };
30
+ }
31
+ const hasNextPage = page.rows.length > requestedLimit || probeLimit === requestedLimit && page.rows.length === requestedLimit && toApiPage(await fetchPage({ limit: 1, offset: nextOffset })).rows.length > 0;
32
+ return { rows, hasNextPage, nextOffset, total: null };
33
+ }
34
+ function cleanQuery(query) {
35
+ return Object.fromEntries(
36
+ Object.entries(query).filter(
37
+ ([, value]) => value !== void 0 && value !== null && value !== ""
38
+ )
39
+ );
40
+ }
41
+
42
+ export { DEFAULT_MAX_PAGE_SIZE, DEFAULT_PAGE_SIZE, cleanQuery, createOffsetPagination, fetchOffsetPage, getPageIndex };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,104 @@
1
+ // src/format/format.ts
2
+ var DEFAULT_PLACEHOLDER = "\u2014";
3
+ var numberFormats = /* @__PURE__ */ new Map();
4
+ var dateFormats = /* @__PURE__ */ new Map();
5
+ function numberFormat(locale, options) {
6
+ const key = `${locale}|${options ? JSON.stringify(options) : ""}`;
7
+ let format = numberFormats.get(key);
8
+ if (!format) {
9
+ format = new Intl.NumberFormat(locale, options);
10
+ numberFormats.set(key, format);
11
+ }
12
+ return format;
13
+ }
14
+ function dateFormat(locale, options) {
15
+ const key = `${locale}|${JSON.stringify(options)}`;
16
+ let format = dateFormats.get(key);
17
+ if (!format) {
18
+ format = new Intl.DateTimeFormat(locale, options);
19
+ dateFormats.set(key, format);
20
+ }
21
+ return format;
22
+ }
23
+ function minorUnitScale(locale, currency) {
24
+ const digits = numberFormat(locale, { style: "currency", currency }).resolvedOptions().maximumFractionDigits ?? 2;
25
+ return 10 ** digits;
26
+ }
27
+ function toDate(value) {
28
+ const date = value instanceof Date ? value : new Date(value);
29
+ return Number.isNaN(date.getTime()) ? null : date;
30
+ }
31
+ function isBlank(value) {
32
+ return value === null || value === void 0 || value === "";
33
+ }
34
+ function formatCurrency(minorUnits, { locale, currency, placeholder = DEFAULT_PLACEHOLDER }) {
35
+ if (!currency) {
36
+ throw new Error(
37
+ "formatCurrency requires a `currency`. Set it on NajmFormatProvider or pass it here."
38
+ );
39
+ }
40
+ if (minorUnits === null || minorUnits === void 0) return placeholder;
41
+ if (!Number.isSafeInteger(minorUnits)) return placeholder;
42
+ return numberFormat(locale, {
43
+ style: "currency",
44
+ currency
45
+ }).format(minorUnits / minorUnitScale(locale, currency));
46
+ }
47
+ function formatNumber(value, { locale, placeholder = DEFAULT_PLACEHOLDER }, options) {
48
+ if (value === null || value === void 0 || !Number.isFinite(value)) {
49
+ return placeholder;
50
+ }
51
+ return numberFormat(locale, options).format(value);
52
+ }
53
+ function formatPercent(value, config, fractionDigits = 0) {
54
+ return formatNumber(value, config, {
55
+ style: "percent",
56
+ minimumFractionDigits: fractionDigits,
57
+ maximumFractionDigits: fractionDigits
58
+ });
59
+ }
60
+ function formatDate(value, {
61
+ locale,
62
+ timeZone,
63
+ placeholder = DEFAULT_PLACEHOLDER
64
+ }, options = { dateStyle: "medium" }) {
65
+ if (isBlank(value)) return placeholder;
66
+ const date = toDate(value);
67
+ if (!date) return placeholder;
68
+ return dateFormat(locale, { ...options, timeZone }).format(date);
69
+ }
70
+ function formatDateTime(value, config, options = {
71
+ dateStyle: "short",
72
+ timeStyle: "short"
73
+ }) {
74
+ return formatDate(value, config, options);
75
+ }
76
+ function formatTime(value, config) {
77
+ return formatDate(value, config, { timeStyle: "short" });
78
+ }
79
+ var RELATIVE_UNITS = [
80
+ ["year", 31536e6],
81
+ ["month", 2592e6],
82
+ ["day", 864e5],
83
+ ["hour", 36e5],
84
+ ["minute", 6e4],
85
+ ["second", 1e3]
86
+ ];
87
+ function formatRelativeTime(value, { locale, placeholder = DEFAULT_PLACEHOLDER }, now = Date.now()) {
88
+ if (isBlank(value)) return placeholder;
89
+ const date = toDate(value);
90
+ if (!date) return placeholder;
91
+ const elapsed = date.getTime() - (now instanceof Date ? now.getTime() : now);
92
+ const format = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
93
+ for (const [unit, ms] of RELATIVE_UNITS) {
94
+ if (Math.abs(elapsed) >= ms) {
95
+ return format.format(Math.trunc(elapsed / ms), unit);
96
+ }
97
+ }
98
+ return format.format(0, "second");
99
+ }
100
+ function humanizeToken(value) {
101
+ return value.trim().replace(/[_-]+/g, " ").replace(/\s+/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
102
+ }
103
+
104
+ export { DEFAULT_PLACEHOLDER, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTime, humanizeToken };
@@ -1,4 +1,5 @@
1
1
  import { useNajmPreferencesContext } from './chunk-USZUOJMK.mjs';
2
+ import { humanizeToken, DEFAULT_PLACEHOLDER, formatRelativeTime, formatTime, formatDateTime, formatDate, formatPercent, formatNumber, formatCurrency } from './chunk-GPHWBOSP.mjs';
2
3
  import * as React from 'react';
3
4
  import { createContext, useContext, useMemo, useState, useCallback } from 'react';
4
5
  import { jsx } from 'react/jsx-runtime';
@@ -62,109 +63,6 @@ function NBrandingStateProvider({
62
63
  }
63
64
  function noop() {
64
65
  }
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
66
  var NajmFormatContext = React.createContext(
169
67
  null
170
68
  );
@@ -215,4 +113,4 @@ function useNajmFormat() {
215
113
  return value;
216
114
  }
217
115
 
218
- export { DEFAULT_PLACEHOLDER, NBrandingProvider, NBrandingStateProvider, NajmFormatProvider, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTime, humanizeToken, normalizeBranding, useNBranding, useNBrandingEditor, useNajmFormat, useNajmFormatContext };
116
+ export { NBrandingProvider, NBrandingStateProvider, NajmFormatProvider, normalizeBranding, useNBranding, useNBrandingEditor, useNajmFormat, useNajmFormatContext };
@@ -0,0 +1,52 @@
1
+ import { useCallback, useSyncExternalStore } from 'react';
2
+
3
+ // src/hooks/useMediaQuery.ts
4
+ function useMediaQuery(query, serverSnapshot = false) {
5
+ const subscribe = useCallback(
6
+ (onStoreChange) => {
7
+ const media = window.matchMedia(query);
8
+ media.addEventListener("change", onStoreChange);
9
+ return () => media.removeEventListener("change", onStoreChange);
10
+ },
11
+ [query]
12
+ );
13
+ return useSyncExternalStore(
14
+ subscribe,
15
+ () => window.matchMedia(query).matches,
16
+ () => serverSnapshot
17
+ );
18
+ }
19
+ var DEFAULT_CARD_BREAKPOINT = 1024;
20
+ function useCardViewport(breakpoint = DEFAULT_CARD_BREAKPOINT) {
21
+ return useMediaQuery(`(max-width: ${breakpoint - 1}px)`);
22
+ }
23
+ function useDesktopTableMode(breakpoint = DEFAULT_CARD_BREAKPOINT) {
24
+ return useMediaQuery(`(min-width: ${breakpoint}px)`) ? "table" : "cards";
25
+ }
26
+
27
+ // src/components/table/cardPagination.ts
28
+ var DEFAULT_CARD_PAGINATION_KEY_PREFIX = "common.pagination";
29
+ function buildCardPaginationLabels(t, prefix = DEFAULT_CARD_PAGINATION_KEY_PREFIX) {
30
+ return {
31
+ loadMoreError: t(`${prefix}.loadMoreError`),
32
+ retryLabel: t(`${prefix}.retryLoadMore`),
33
+ itemsLoaded: (count) => t(`${prefix}.itemsLoaded`, { count })
34
+ };
35
+ }
36
+ function createCardPagination(state, labels = {}) {
37
+ const mode = state.mode ?? (state.cardViewport ? "infinite" : "paged");
38
+ if (mode === "paged") return { mode: "paged" };
39
+ if (mode === "all") return { mode: "all" };
40
+ return {
41
+ mode: "infinite",
42
+ hasNextPage: state.hasNextPage,
43
+ loadingMore: state.loadingMore,
44
+ loadMoreError: state.loadMoreError ? labels.loadMoreError : void 0,
45
+ onLoadMore: state.onLoadMore,
46
+ retryLabel: labels.retryLabel,
47
+ loadMoreErrorLabel: labels.loadMoreError,
48
+ itemsLoadedLabel: labels.itemsLoaded
49
+ };
50
+ }
51
+
52
+ export { DEFAULT_CARD_BREAKPOINT, DEFAULT_CARD_PAGINATION_KEY_PREFIX, buildCardPaginationLabels, createCardPagination, useCardViewport, useDesktopTableMode, useMediaQuery };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Locale-aware value formatting.
3
+ *
4
+ * Pure functions with no React and no DOM: every input arrives through
5
+ * `NajmFormatConfig`. `NajmFormatProvider` binds them to the live locale and
6
+ * time zone, and is what an application normally uses — these are exported for
7
+ * the server, where there is no context to read.
8
+ */
9
+ /** Rendered in place of a value that is absent or not formattable. */
10
+ declare const DEFAULT_PLACEHOLDER = "\u2014";
11
+ interface NajmFormatConfig {
12
+ /** BCP 47 tag handed to `Intl`, e.g. `"fr-MA"`. */
13
+ locale: string;
14
+ /**
15
+ * IANA zone every date is rendered in. Omitted means the host zone, which is
16
+ * the runtime's guess rather than the user's preference — supply it.
17
+ */
18
+ timeZone?: string;
19
+ /** ISO 4217 code for `formatCurrency`, e.g. `"MAD"`. */
20
+ currency?: string;
21
+ /** Defaults to an em dash. */
22
+ placeholder?: string;
23
+ }
24
+ /**
25
+ * Formats an integer count of minor units — cents, centimes — as currency.
26
+ *
27
+ * Minor units are the input because money that survives a round trip is an
28
+ * integer; a major-unit float cannot represent 0.1 exactly and has no business
29
+ * in a ledger. A non-integer input is refused rather than rounded, since at
30
+ * this layer it means the caller has already lost precision upstream.
31
+ */
32
+ declare function formatCurrency(minorUnits: number | null | undefined, { locale, currency, placeholder }: NajmFormatConfig): string;
33
+ declare function formatNumber(value: number | null | undefined, { locale, placeholder }: NajmFormatConfig, options?: Intl.NumberFormatOptions): string;
34
+ declare function formatPercent(value: number | null | undefined, config: NajmFormatConfig, fractionDigits?: number): string;
35
+ declare function formatDate(value: Date | number | string | null | undefined, { locale, timeZone, placeholder, }: NajmFormatConfig, options?: Intl.DateTimeFormatOptions): string;
36
+ declare function formatDateTime(value: Date | number | string | null | undefined, config: NajmFormatConfig, options?: Intl.DateTimeFormatOptions): string;
37
+ declare function formatTime(value: Date | number | string | null | undefined, config: NajmFormatConfig): string;
38
+ /**
39
+ * Renders a timestamp as distance from now — "3 days ago", "in 2 hours".
40
+ *
41
+ * Time zone is not a parameter: an elapsed duration is the same in every zone.
42
+ */
43
+ declare function formatRelativeTime(value: Date | number | string | null | undefined, { locale, placeholder }: NajmFormatConfig, now?: Date | number): string;
44
+ /**
45
+ * Turns a machine token into readable text: `out_for_delivery` → `Out For
46
+ * Delivery`.
47
+ *
48
+ * The fallback for a value with no catalog entry, not a substitute for one.
49
+ * Anything user-visible and known in advance belongs in the translations.
50
+ */
51
+ declare function humanizeToken(value: string): string;
52
+
53
+ export { DEFAULT_PLACEHOLDER, type NajmFormatConfig, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTime, humanizeToken };
@@ -0,0 +1,2 @@
1
+ import './chunk-F5KXJCCJ.mjs';
2
+ export { DEFAULT_PLACEHOLDER, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTime, humanizeToken } from './chunk-GPHWBOSP.mjs';
package/dist/index.d.ts CHANGED
@@ -1,10 +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 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';
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-IFU3dFkn.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-IFU3dFkn.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
+ import { c as NTablePaginationVariant, b as NTablePaginationLabels, a as NTableCardPagination } from './paginationLabels-DgHutNWz.js';
7
+ export { D as DEFAULT_PAGINATION_KEY_PREFIX, d as NTableInfinitePagination, e as NTableLoadMorePagination, N as NajmTranslate, f as buildPaginationLabels } from './paginationLabels-DgHutNWz.js';
8
8
  import * as class_variance_authority_types from 'class-variance-authority/types';
9
9
  import { VariantProps } from 'class-variance-authority';
10
10
  import * as LabelPrimitive from '@radix-ui/react-label';
@@ -39,8 +39,11 @@ import { ZodTypeAny, TypeOf } from 'zod';
39
39
  import { SortingState, ExpandedState, ColumnDef, Row, ColumnFiltersState, VisibilityState, RowSelectionState } from '@tanstack/react-table';
40
40
  export { N as NTableJson } from './NTableJson-tXqgfZI1.js';
41
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';
42
+ export { C as CardPaginationLabels, a as CardPaginationState, D as DEFAULT_CARD_PAGINATION_KEY_PREFIX, L as ListStrategy, R as ResolvedListMode, b as buildCardPaginationLabels, c as createCardPagination } from './cardPagination-A6h8vXuk.js';
43
43
  import { ClassValue } from 'clsx';
44
+ export { ApiPage, DEFAULT_MAX_PAGE_SIZE, DEFAULT_PAGE_SIZE, OffsetPage, OffsetPageFetcher, OffsetPageOptions, OffsetPagination, QueryValue, cleanQuery, createOffsetPagination, fetchOffsetPage, getPageIndex } from './pagination.js';
45
+ import { NajmFormatConfig } from './format.js';
46
+ export { DEFAULT_PLACEHOLDER, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTime, humanizeToken } from './format.js';
44
47
 
45
48
  /**
46
49
  * Shared so the identity is stable across renders — `NajmDesignProvider`
@@ -3728,58 +3731,6 @@ declare function cn(...inputs: ClassValue[]): string;
3728
3731
 
3729
3732
  declare function resolveSlot<T>(slot: T | ((ctx: any) => ReactNode), ctx?: any): ReactNode;
3730
3733
 
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
3734
  interface NajmFormatContextValue extends Required<Pick<NajmFormatConfig, "locale" | "timeZone" | "placeholder">> {
3784
3735
  currency?: string;
3785
3736
  /** Formats an integer count of minor units as `currency`. */
@@ -4261,4 +4212,4 @@ interface NGridItemProps extends Omit<React$1.AllHTMLAttributes<HTMLDivElement>,
4261
4212
  declare function NGrid({ as: Comp, children, cols, smCols, mdCols, lgCols, xlCols, gap, className, style, ...props }: NGridProps): react_jsx_runtime.JSX.Element;
4262
4213
  declare function NGridItem({ children, span, smSpan, mdSpan, lgSpan, xlSpan, className, ...props }: NGridItemProps): react_jsx_runtime.JSX.Element;
4263
4214
 
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 };
4215
+ 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_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, 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, 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, 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,12 +1,15 @@
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';
1
+ import { useNBranding } from './chunk-VKQIRB7F.mjs';
2
+ export { NBrandingProvider, NBrandingStateProvider, NajmFormatProvider, normalizeBranding, useNBranding, useNBrandingEditor, useNajmFormat, useNajmFormatContext } from './chunk-VKQIRB7F.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
+ export { DEFAULT_CARD_BREAKPOINT, DEFAULT_CARD_PAGINATION_KEY_PREFIX, buildCardPaginationLabels, createCardPagination, useCardViewport, useDesktopTableMode, useMediaQuery } from './chunk-XGDMPI5U.mjs';
10
+ import './chunk-F5KXJCCJ.mjs';
11
+ export { DEFAULT_PLACEHOLDER, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTime, humanizeToken } from './chunk-GPHWBOSP.mjs';
12
+ export { DEFAULT_MAX_PAGE_SIZE, DEFAULT_PAGE_SIZE, cleanQuery, createOffsetPagination, fetchOffsetPage, getPageIndex } from './chunk-2NX2VKS2.mjs';
10
13
  import * as React60 from 'react';
11
14
  import React60__default, { createContext, useRef, useMemo, useState, useEffect, useContext, useCallback, useLayoutEffect, isValidElement } from 'react';
12
15
  import * as TabsPrimitive from '@radix-ui/react-tabs';
@@ -1,55 +1,3 @@
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
1
  /**
54
2
  * The offset-pagination protocol behind `NTable`'s page controls.
55
3
  *
@@ -127,4 +75,4 @@ type QueryValue = string | number | boolean | null | undefined;
127
75
  */
128
76
  declare function cleanQuery(query: Record<string, QueryValue>): Record<string, QueryValue>;
129
77
 
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 };
78
+ export { type ApiPage, DEFAULT_MAX_PAGE_SIZE, DEFAULT_PAGE_SIZE, type OffsetPage, type OffsetPageFetcher, type OffsetPageOptions, type OffsetPagination, type QueryValue, cleanQuery, createOffsetPagination, fetchOffsetPage, getPageIndex };
@@ -0,0 +1 @@
1
+ export { DEFAULT_MAX_PAGE_SIZE, DEFAULT_PAGE_SIZE, cleanQuery, createOffsetPagination, fetchOffsetPage, getPageIndex } from './chunk-2NX2VKS2.mjs';
@@ -140,4 +140,4 @@ declare const DEFAULT_PAGINATION_KEY_PREFIX = "common.pagination";
140
140
  */
141
141
  declare function buildPaginationLabels(t: NajmTranslate, prefix?: string): NTablePaginationLabels;
142
142
 
143
- export { DEFAULT_PAGINATION_KEY_PREFIX as D, type NTablePaginationVariant as N, type NTablePaginationLabels as a, type NTableCardPagination as b, type NTableInfinitePagination as c, type NTableLoadMorePagination as d, type NajmTranslate as e, buildPaginationLabels as f };
143
+ export { DEFAULT_PAGINATION_KEY_PREFIX as D, type NajmTranslate as N, type NTableCardPagination as a, type NTablePaginationLabels as b, type NTablePaginationVariant as c, type NTableInfinitePagination as d, type NTableLoadMorePagination as e, buildPaginationLabels as f };
package/dist/query.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import * as _tanstack_query_core from '@tanstack/query-core';
2
- import { d as OffsetPageFetcher, O as OffsetPage, L as ListStrategy, R as ResolvedListMode } from './pagination-BvukSZir.js';
3
- export { A as ApiPage, C as CardPaginationLabels, a as CardPaginationState, b as DEFAULT_MAX_PAGE_SIZE, c as DEFAULT_PAGE_SIZE, e as OffsetPageOptions, f as OffsetPagination, Q as QueryValue, g as buildCardPaginationLabels, h as cleanQuery, i as createCardPagination, j as createOffsetPagination, k as fetchOffsetPage, l as getPageIndex } from './pagination-BvukSZir.js';
4
- import './paginationLabels-CY2PvbMj.js';
2
+ import { OffsetPageFetcher, OffsetPage } from './pagination.js';
3
+ export { ApiPage, DEFAULT_MAX_PAGE_SIZE, DEFAULT_PAGE_SIZE, OffsetPageOptions, OffsetPagination, QueryValue, cleanQuery, createOffsetPagination, fetchOffsetPage, getPageIndex } from './pagination.js';
4
+ import { L as ListStrategy, R as ResolvedListMode } from './cardPagination-A6h8vXuk.js';
5
+ export { C as CardPaginationLabels, a as CardPaginationState, b as buildCardPaginationLabels, c as createCardPagination } from './cardPagination-A6h8vXuk.js';
6
+ import './paginationLabels-DgHutNWz.js';
5
7
  import 'react';
6
8
 
7
9
  interface UseOffsetInfiniteQueryOptions<T> {
package/dist/query.mjs CHANGED
@@ -1,5 +1,7 @@
1
- import { fetchOffsetPage, useCardViewport, DEFAULT_MAX_PAGE_SIZE } from './chunk-7J7DWGKB.mjs';
2
- export { DEFAULT_MAX_PAGE_SIZE, DEFAULT_PAGE_SIZE, buildCardPaginationLabels, cleanQuery, createCardPagination, createOffsetPagination, fetchOffsetPage, getPageIndex } from './chunk-7J7DWGKB.mjs';
1
+ import { useCardViewport } from './chunk-XGDMPI5U.mjs';
2
+ export { buildCardPaginationLabels, createCardPagination } from './chunk-XGDMPI5U.mjs';
3
+ import { fetchOffsetPage, DEFAULT_MAX_PAGE_SIZE } from './chunk-2NX2VKS2.mjs';
4
+ export { DEFAULT_MAX_PAGE_SIZE, DEFAULT_PAGE_SIZE, cleanQuery, createOffsetPagination, fetchOffsetPage, getPageIndex } from './chunk-2NX2VKS2.mjs';
3
5
  import { useInfiniteQuery } from '@tanstack/react-query';
4
6
  import { useState, useRef, useEffect, useCallback } from 'react';
5
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najm-kit",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Reusable React UI component package for Najm framework",
@@ -38,6 +38,16 @@
38
38
  "import": "./dist/query.mjs",
39
39
  "default": "./dist/query.mjs"
40
40
  },
41
+ "./format": {
42
+ "types": "./dist/format.d.ts",
43
+ "import": "./dist/format.mjs",
44
+ "default": "./dist/format.mjs"
45
+ },
46
+ "./pagination": {
47
+ "types": "./dist/pagination.d.ts",
48
+ "import": "./dist/pagination.mjs",
49
+ "default": "./dist/pagination.mjs"
50
+ },
41
51
  "./json": {
42
52
  "types": "./dist/json.d.ts",
43
53
  "import": "./dist/json.mjs",
@@ -1,93 +0,0 @@
1
- import { useCallback, useSyncExternalStore } from 'react';
2
-
3
- // src/hooks/useMediaQuery.ts
4
- function useMediaQuery(query, serverSnapshot = false) {
5
- const subscribe = useCallback(
6
- (onStoreChange) => {
7
- const media = window.matchMedia(query);
8
- media.addEventListener("change", onStoreChange);
9
- return () => media.removeEventListener("change", onStoreChange);
10
- },
11
- [query]
12
- );
13
- return useSyncExternalStore(
14
- subscribe,
15
- () => window.matchMedia(query).matches,
16
- () => serverSnapshot
17
- );
18
- }
19
- var DEFAULT_CARD_BREAKPOINT = 1024;
20
- function useCardViewport(breakpoint = DEFAULT_CARD_BREAKPOINT) {
21
- return useMediaQuery(`(max-width: ${breakpoint - 1}px)`);
22
- }
23
- function useDesktopTableMode(breakpoint = DEFAULT_CARD_BREAKPOINT) {
24
- return useMediaQuery(`(min-width: ${breakpoint}px)`) ? "table" : "cards";
25
- }
26
-
27
- // src/components/table/cardPagination.ts
28
- var DEFAULT_CARD_PAGINATION_KEY_PREFIX = "common.pagination";
29
- function buildCardPaginationLabels(t, prefix = DEFAULT_CARD_PAGINATION_KEY_PREFIX) {
30
- return {
31
- loadMoreError: t(`${prefix}.loadMoreError`),
32
- retryLabel: t(`${prefix}.retryLoadMore`),
33
- itemsLoaded: (count) => t(`${prefix}.itemsLoaded`, { count })
34
- };
35
- }
36
- function createCardPagination(state, labels = {}) {
37
- const mode = state.mode ?? (state.cardViewport ? "infinite" : "paged");
38
- if (mode === "paged") return { mode: "paged" };
39
- if (mode === "all") return { mode: "all" };
40
- return {
41
- mode: "infinite",
42
- hasNextPage: state.hasNextPage,
43
- loadingMore: state.loadingMore,
44
- loadMoreError: state.loadMoreError ? labels.loadMoreError : void 0,
45
- onLoadMore: state.onLoadMore,
46
- retryLabel: labels.retryLabel,
47
- loadMoreErrorLabel: labels.loadMoreError,
48
- itemsLoadedLabel: labels.itemsLoaded
49
- };
50
- }
51
-
52
- // src/lib/pagination.ts
53
- var DEFAULT_PAGE_SIZE = 25;
54
- var DEFAULT_MAX_PAGE_SIZE = 100;
55
- function toApiPage(result) {
56
- return Array.isArray(result) ? { rows: result, total: null } : result;
57
- }
58
- function createOffsetPagination(pageIndex = 0, pageSize = DEFAULT_PAGE_SIZE, { maxLimit = DEFAULT_MAX_PAGE_SIZE } = {}) {
59
- const safePageIndex = Math.max(0, Math.trunc(pageIndex));
60
- const safePageSize = Math.min(maxLimit, Math.max(1, Math.trunc(pageSize)));
61
- return { limit: safePageSize, offset: safePageIndex * safePageSize };
62
- }
63
- function getPageIndex({ limit, offset }) {
64
- return Math.floor(Math.max(0, offset) / Math.max(1, limit));
65
- }
66
- async function fetchOffsetPage(fetchPage, pagination, { maxLimit = DEFAULT_MAX_PAGE_SIZE } = {}) {
67
- const requestedLimit = Math.min(maxLimit, Math.max(1, pagination.limit));
68
- const probeLimit = requestedLimit < maxLimit ? requestedLimit + 1 : requestedLimit;
69
- const page = toApiPage(
70
- await fetchPage({ limit: probeLimit, offset: pagination.offset })
71
- );
72
- const rows = page.rows.slice(0, requestedLimit);
73
- const nextOffset = pagination.offset + rows.length;
74
- if (page.total !== null) {
75
- return {
76
- rows,
77
- hasNextPage: nextOffset < page.total,
78
- nextOffset,
79
- total: page.total
80
- };
81
- }
82
- const hasNextPage = page.rows.length > requestedLimit || probeLimit === requestedLimit && page.rows.length === requestedLimit && toApiPage(await fetchPage({ limit: 1, offset: nextOffset })).rows.length > 0;
83
- return { rows, hasNextPage, nextOffset, total: null };
84
- }
85
- function cleanQuery(query) {
86
- return Object.fromEntries(
87
- Object.entries(query).filter(
88
- ([, value]) => value !== void 0 && value !== null && value !== ""
89
- )
90
- );
91
- }
92
-
93
- 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 };