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 CHANGED
@@ -1,112 +1,112 @@
1
- # Changelog
2
-
3
- ## 2.6.2
4
-
5
- - Added `NSidebarProvider` and `useNSidebar`, so sidebar state can be read from a distance. `NSidebar` renders beside the page content rather than around it, which left applications hand-rolling a context to hand `setMobileOpen` down to a page header — a wrapper component plus an aliased import at every call site. Wrap the shell in `NSidebarProvider` and `NPageHeader` now resolves both `onSidebarOpen` and `mobileBreakpoint` from it, so a header nested anywhere below renders a working mobile trigger with no props threaded to it. Also exports the `NSidebarContextValue` type.
6
- - `NSidebar` resolves its open and collapsed state as explicit prop → surrounding provider → internal state. Passing `collapsed`, `mobileOpen`, `onCollapsedChange`, or `onMobileOpenChange` keeps behaving exactly as before, and a sidebar with no provider around it still owns its own state, so this is additive for every existing consumer.
7
- - `logo` accepts a render prop, `({ collapsed, isMobile }) => ReactNode`, alongside the existing node. It receives the state the sidebar actually resolved — including whatever `autoCollapseAt` decided — which consumers previously had to approximate with their own responsive classes, guessing at a breakpoint the sidebar had already computed. The mobile drawer always reports `collapsed: false`, matching how it renders. Exported as `SidebarLogoRender`.
8
-
9
- ## 2.6.1
10
-
11
- - Fixed the non-card `NPageHeader` bleed never taking effect. 2.6.0 cancelled the page padding with the Tailwind utilities `-mt-[var(--najm-section-gap,0px)]` and `-mx-[var(--najm-page-gutter,0px)]`, which only work if the consuming app's Tailwind build happens to emit those arbitrary classes — they exist nowhere but inside this package's bundle, so a consumer could load a stylesheet without them and the header stayed exactly where it was. The offsets are inline styles now and no longer depend on the consumer's CSS pipeline.
12
-
13
- ## 2.6.0
14
-
15
- - Added `NThemePresets`, and wired it into `NThemeCustomizer` through `presets`, `selectedPresetId`, `presetsStatus`, `savedDesign`, `onPresetSelect`, `onPresetSave`, `onPresetDelete`, and `presetLabels`. The picker renders only when a host supplies both `presets` and `onPresetSelect`. It is presentational: the host owns where presets live and what saving one means, and selecting a row hands the design back so it can be previewed before anything is stored. Each row draws a swatch strip from the design's own `sidebar`, `primary`, `secondary`, `accent`, and `background` tokens; the selected row's check sits left in the success colour and per-row delete sits right. Omit `onPresetSave` or `onPresetDelete` to hide those controls. Deleting is pointer-only — Radix owns roving focus inside the listbox.
16
- - **`NPageHeader` in non-card mode is now flush.** It rendered as a full-bleed bar (`border-b`, no radius) but still sat inside the padding `NPageLayout` applies, so it floated below and inside the page gutter and its bottom rule never met the sidebar header's. It now cancels that padding, and its base height goes `min-h-12` → `min-h-14` to match `NSidebarHeader`. **Non-card page headers move up and out to the page edges, and grow 8px below `sm`.** Card mode is unchanged.
17
- - `NPageLayout` publishes its resolved spacing as `--najm-page-gutter` and `--najm-section-gap`. Descendants could not previously cancel the page padding: a design config resolves the gutter to a literal, so the pre-existing `--page-gutter` / `--section-gap` variables only ever held the fallbacks. Full-bleed children should negate these, with `0px` fallbacks so they stay inert outside `NPageLayout`.
18
- - Fixed `SelectInput` discarding `SelectItemType.icon`. The prop was declared but `renderItems` rendered the label alone, so every per-item icon was silently dropped. Items with an icon now render it before a truncating label; items without one are unchanged.
19
-
20
- ## 2.5.0
21
-
22
- - Added `NTableDefaultsProvider`, so an application supplies `paginationLabels` once instead of at every table. Labels merge per key, most specific first: a table's own `paginationLabels` override the provider's for the keys it sets, the provider covers the rest, and anything neither supplies falls back to the packaged English. Also exports `useNTableDefaults` and the `NTableDefaults` type.
23
- - `value` is passed through the provider unmemoized; memoize it in the caller, or every table below re-renders with the shell.
24
-
25
- ## 2.4.0
26
-
27
- - `NTablePagination` renders numbered page buttons instead of `Page X of Y`. The window shows the first and last page, the current page, and one page either side, collapsing the rest into at most two gaps. The slot count is constant for any result longer than the window, so the bar does not change width as the reader pages through it, and a gap never stands in for a single page — that slot goes to the page instead.
28
- - Added `paginationVariant`, defaulting to `"numbered"`. Pass `"compact"` to keep the previous position text with first/previous/next/last controls. **This changes the default appearance of every paginated `NTable`.**
29
- - The numbered variant drops the first/last double chevrons, because page 1 and page N are now single-click targets of their own. Previous and next remain. The compact variant is unchanged.
30
- - Numbered pages fall back to compact on their own when the page count is not trustworthy — that is, under `manualPagination` with no `pageCount` supplied, where TanStack infers a count from the rows it happens to hold rather than from a result total. Numbering that would invite clicks on pages that may not exist is not rendered.
31
- - Below the `sm` breakpoint the numbers give way to the position text; seven page buttons plus the rows-per-page select do not fit a phone.
32
- - Added `paginationLabels` so the bar can be localized: `rowsPerPage`, `pagination`, `goToPage`, `currentPage`, `firstPage`, `previousPage`, `nextPage`, `lastPage`, `pageOf`, and `rowsSelected`. All optional, all falling back to the previous English strings.
33
- - Pagination chevrons now mirror under `dir="rtl"`. They previously pointed against the reading direction in right-to-left layouts.
34
- - The page controls are wrapped in a labelled `nav`, and the current page carries `aria-current="page"`.
35
- - Exported `buildPageItems` and `NTablePageItem` for consumers that need the same windowing outside the table.
36
-
37
- ## 2.2.1
38
-
39
- - Fixed a regression in 2.2.0: the dynamic page size reported under `manualPagination` could oscillate. Card row height is measured from rendered cards, so it grows as images decode; feeding that back into the page size refetched, re-rendered, re-measured, and refetched again. A list visibly settled from one page size to another with the loading skeleton flashing twice. The report is now allowed once per container geometry, which does not depend on the rows inside it, so it terminates. A resize still re-arms it, and the debounce still waits for the measurement to settle before reporting.
40
-
41
- ## 2.2.0
42
-
43
- - Added `cardPagination` mode `infinite`: card lists continue on scroll instead of behind a button. No control and no end-of-list element render while the list is healthy. The continuation button appears only after an append failure, as the retry target.
44
- - Infinite continuation is owned by `NTableCards`, so the sentinel lives inside the card list's own `NajmScroll` viewport and uses it as the observer root. An appending page renders shaped card placeholders at the grid tail rather than a spinner in a fixed strip, and the polite `aria-live` announcement of appended row counts is preserved.
45
- - `cardPagination: { mode: "all" }` is now honored in table mode as well as cards: every supplied row renders and no pagination controls are shown.
46
- - `dynamicHeight` now takes effect under `manualPagination`. The measured page size is reported through the ordinary `onPaginationChange` callback, debounced, so server-paginated tables fill their container while the consumer keeps ownership of fetching. `maxHeight` stays caller-owned under manual pagination, and no page size is reported before the first measurement.
47
- - Added `calculateCardPageSize`, floored to whole card rows, published as `calculatedCardPageSize`. A card grid page no longer ends in a ragged partial row. This deliberately differs from `calculateCardSkeletonCount`, which ceils because overfilling placeholders is harmless.
48
- - Removed the deprecated `baseUrl` compiler option from the package tsconfig; `paths` resolves relative to the config file.
49
-
50
- ## 2.1.56
51
-
52
- - Honor `showIcon` on NTable `select` and `combobox` filters. The leading filter icon is still shown by default; pass `showIcon: false` on a filter to hide it.
53
-
54
- ## 2.1.55
55
-
56
- - Added controlled remote-search and loading-state props to `ComboboxInput` and `FormInput type="combobox"` while preserving client filtering by default.
57
-
58
- ## 2.1.53 - 2026-08-05
59
-
60
- - Add typed `NBarChart`, `NLineChart`, `NPieChart`, and `NStatusBreakdown`
61
- components with caller-formatted generic data, accessible summaries, empty
62
- states, responsive RTL-safe layouts, and shape-matched loading skeletons.
63
- - Default chart colors to the live `--chart-1` through `--chart-5` theme
64
- variables, cycle deterministically after five items, and retain explicit
65
- per-series/item color overrides.
66
- - Add preset and numeric chart diameter contracts to `NPieChart` and
67
- `NDonutCard`, including narrow-container shrinking without clipped legends.
68
- - Make `NDonutCard` item colors optional and add accessible loading states to
69
- `NDonutCard` and `NStatCard`.
70
- - Add public API tests, component tests, README guidance, and playground
71
- examples for the chart and loading contracts.
72
-
73
- ## 2.1.49 - 2026-08-04
74
-
75
- ### ImageInput and AvatarInput
76
-
77
- - Add `previewAlt`, `fallbackImage`, `fallbackAlt`, `unavailableContent`,
78
- `imageClassName`, `onPreviewError`, `replaceAriaLabel`, and `clearAriaLabel`
79
- to `ImageInputProps`. `AvatarInput` forwards every new prop unchanged.
80
- - Preview sources resolve in this priority order: `value`, `fallbackImage`,
81
- `defaultImage`. Candidate URLs are deduplicated so a failing primary URL is
82
- never retried through multiple stages. When every candidate fails, the
83
- broken `<img>` is unmounted and `unavailableContent` (or a neutral default)
84
- is rendered in its place.
85
- - `imageVersion` is appended safely to relative, absolute, queried, and
86
- fragmented URLs. `data:`, `blob:`, `javascript:`, and `file:` URLs are
87
- left unchanged.
88
- - Expose `data-image-input-state="empty" | "preview" | "fallback" | "unavailable"`
89
- on the preview container for styling, testing, and consumer diagnostics.
90
- - File selection is race-safe: stale `FileReader` completions cannot replace
91
- a newer value. Object URLs created by the component are tracked so
92
- consumer-owned blob URLs are never revoked.
93
- - Replace and clear controls are real `<button>` elements, are reachable
94
- with the keyboard, and stay visible on touch and coarse-pointer devices.
95
- Only on `(hover: hover) and (pointer: fine)` desktops do the controls fall
96
- back to a hover/focus reveal. `focus-visible` always restores visibility.
97
- - Use logical positioning (`end-*`) so the clear button works correctly in
98
- RTL layouts.
99
- - Re-export `ImageInputPreviewSource` and `ImageInputPreviewError` from
100
- `najm-kit/components/inputs` and the package root.
101
-
102
- ## 2.1.48 - 2026-08-04
103
-
104
- - Keep responsive card row actions visible on phone, tablet, and touch input,
105
- while retaining hover and keyboard-focus reveal on fine-pointer desktops.
106
- - Size table and card loading skeletons from the measured body and active grid,
107
- and keep loading borders, radius, color, and shadow aligned with loaded
108
- surfaces.
109
- - Add the exported `NTableCardPagination` and `NTableLoadMorePagination`
110
- contracts for paged, complete supplied-data, and explicit server-backed Load
111
- more card presentation, including guarded append/retry behavior and accessible
112
- loading, result, error, and terminal feedback.
1
+ # Changelog
2
+
3
+ ## 2.6.2
4
+
5
+ - Added `NSidebarProvider` and `useNSidebar`, so sidebar state can be read from a distance. `NSidebar` renders beside the page content rather than around it, which left applications hand-rolling a context to hand `setMobileOpen` down to a page header — a wrapper component plus an aliased import at every call site. Wrap the shell in `NSidebarProvider` and `NPageHeader` now resolves both `onSidebarOpen` and `mobileBreakpoint` from it, so a header nested anywhere below renders a working mobile trigger with no props threaded to it. Also exports the `NSidebarContextValue` type.
6
+ - `NSidebar` resolves its open and collapsed state as explicit prop → surrounding provider → internal state. Passing `collapsed`, `mobileOpen`, `onCollapsedChange`, or `onMobileOpenChange` keeps behaving exactly as before, and a sidebar with no provider around it still owns its own state, so this is additive for every existing consumer.
7
+ - `logo` accepts a render prop, `({ collapsed, isMobile }) => ReactNode`, alongside the existing node. It receives the state the sidebar actually resolved — including whatever `autoCollapseAt` decided — which consumers previously had to approximate with their own responsive classes, guessing at a breakpoint the sidebar had already computed. The mobile drawer always reports `collapsed: false`, matching how it renders. Exported as `SidebarLogoRender`.
8
+
9
+ ## 2.6.1
10
+
11
+ - Fixed the non-card `NPageHeader` bleed never taking effect. 2.6.0 cancelled the page padding with the Tailwind utilities `-mt-[var(--najm-section-gap,0px)]` and `-mx-[var(--najm-page-gutter,0px)]`, which only work if the consuming app's Tailwind build happens to emit those arbitrary classes — they exist nowhere but inside this package's bundle, so a consumer could load a stylesheet without them and the header stayed exactly where it was. The offsets are inline styles now and no longer depend on the consumer's CSS pipeline.
12
+
13
+ ## 2.6.0
14
+
15
+ - Added `NThemePresets`, and wired it into `NThemeCustomizer` through `presets`, `selectedPresetId`, `presetsStatus`, `savedDesign`, `onPresetSelect`, `onPresetSave`, `onPresetDelete`, and `presetLabels`. The picker renders only when a host supplies both `presets` and `onPresetSelect`. It is presentational: the host owns where presets live and what saving one means, and selecting a row hands the design back so it can be previewed before anything is stored. Each row draws a swatch strip from the design's own `sidebar`, `primary`, `secondary`, `accent`, and `background` tokens; the selected row's check sits left in the success colour and per-row delete sits right. Omit `onPresetSave` or `onPresetDelete` to hide those controls. Deleting is pointer-only — Radix owns roving focus inside the listbox.
16
+ - **`NPageHeader` in non-card mode is now flush.** It rendered as a full-bleed bar (`border-b`, no radius) but still sat inside the padding `NPageLayout` applies, so it floated below and inside the page gutter and its bottom rule never met the sidebar header's. It now cancels that padding, and its base height goes `min-h-12` → `min-h-14` to match `NSidebarHeader`. **Non-card page headers move up and out to the page edges, and grow 8px below `sm`.** Card mode is unchanged.
17
+ - `NPageLayout` publishes its resolved spacing as `--najm-page-gutter` and `--najm-section-gap`. Descendants could not previously cancel the page padding: a design config resolves the gutter to a literal, so the pre-existing `--page-gutter` / `--section-gap` variables only ever held the fallbacks. Full-bleed children should negate these, with `0px` fallbacks so they stay inert outside `NPageLayout`.
18
+ - Fixed `SelectInput` discarding `SelectItemType.icon`. The prop was declared but `renderItems` rendered the label alone, so every per-item icon was silently dropped. Items with an icon now render it before a truncating label; items without one are unchanged.
19
+
20
+ ## 2.5.0
21
+
22
+ - Added `NTableDefaultsProvider`, so an application supplies `paginationLabels` once instead of at every table. Labels merge per key, most specific first: a table's own `paginationLabels` override the provider's for the keys it sets, the provider covers the rest, and anything neither supplies falls back to the packaged English. Also exports `useNTableDefaults` and the `NTableDefaults` type.
23
+ - `value` is passed through the provider unmemoized; memoize it in the caller, or every table below re-renders with the shell.
24
+
25
+ ## 2.4.0
26
+
27
+ - `NTablePagination` renders numbered page buttons instead of `Page X of Y`. The window shows the first and last page, the current page, and one page either side, collapsing the rest into at most two gaps. The slot count is constant for any result longer than the window, so the bar does not change width as the reader pages through it, and a gap never stands in for a single page — that slot goes to the page instead.
28
+ - Added `paginationVariant`, defaulting to `"numbered"`. Pass `"compact"` to keep the previous position text with first/previous/next/last controls. **This changes the default appearance of every paginated `NTable`.**
29
+ - The numbered variant drops the first/last double chevrons, because page 1 and page N are now single-click targets of their own. Previous and next remain. The compact variant is unchanged.
30
+ - Numbered pages fall back to compact on their own when the page count is not trustworthy — that is, under `manualPagination` with no `pageCount` supplied, where TanStack infers a count from the rows it happens to hold rather than from a result total. Numbering that would invite clicks on pages that may not exist is not rendered.
31
+ - Below the `sm` breakpoint the numbers give way to the position text; seven page buttons plus the rows-per-page select do not fit a phone.
32
+ - Added `paginationLabels` so the bar can be localized: `rowsPerPage`, `pagination`, `goToPage`, `currentPage`, `firstPage`, `previousPage`, `nextPage`, `lastPage`, `pageOf`, and `rowsSelected`. All optional, all falling back to the previous English strings.
33
+ - Pagination chevrons now mirror under `dir="rtl"`. They previously pointed against the reading direction in right-to-left layouts.
34
+ - The page controls are wrapped in a labelled `nav`, and the current page carries `aria-current="page"`.
35
+ - Exported `buildPageItems` and `NTablePageItem` for consumers that need the same windowing outside the table.
36
+
37
+ ## 2.2.1
38
+
39
+ - Fixed a regression in 2.2.0: the dynamic page size reported under `manualPagination` could oscillate. Card row height is measured from rendered cards, so it grows as images decode; feeding that back into the page size refetched, re-rendered, re-measured, and refetched again. A list visibly settled from one page size to another with the loading skeleton flashing twice. The report is now allowed once per container geometry, which does not depend on the rows inside it, so it terminates. A resize still re-arms it, and the debounce still waits for the measurement to settle before reporting.
40
+
41
+ ## 2.2.0
42
+
43
+ - Added `cardPagination` mode `infinite`: card lists continue on scroll instead of behind a button. No control and no end-of-list element render while the list is healthy. The continuation button appears only after an append failure, as the retry target.
44
+ - Infinite continuation is owned by `NTableCards`, so the sentinel lives inside the card list's own `NajmScroll` viewport and uses it as the observer root. An appending page renders shaped card placeholders at the grid tail rather than a spinner in a fixed strip, and the polite `aria-live` announcement of appended row counts is preserved.
45
+ - `cardPagination: { mode: "all" }` is now honored in table mode as well as cards: every supplied row renders and no pagination controls are shown.
46
+ - `dynamicHeight` now takes effect under `manualPagination`. The measured page size is reported through the ordinary `onPaginationChange` callback, debounced, so server-paginated tables fill their container while the consumer keeps ownership of fetching. `maxHeight` stays caller-owned under manual pagination, and no page size is reported before the first measurement.
47
+ - Added `calculateCardPageSize`, floored to whole card rows, published as `calculatedCardPageSize`. A card grid page no longer ends in a ragged partial row. This deliberately differs from `calculateCardSkeletonCount`, which ceils because overfilling placeholders is harmless.
48
+ - Removed the deprecated `baseUrl` compiler option from the package tsconfig; `paths` resolves relative to the config file.
49
+
50
+ ## 2.1.56
51
+
52
+ - Honor `showIcon` on NTable `select` and `combobox` filters. The leading filter icon is still shown by default; pass `showIcon: false` on a filter to hide it.
53
+
54
+ ## 2.1.55
55
+
56
+ - Added controlled remote-search and loading-state props to `ComboboxInput` and `FormInput type="combobox"` while preserving client filtering by default.
57
+
58
+ ## 2.1.53 - 2026-08-05
59
+
60
+ - Add typed `NBarChart`, `NLineChart`, `NPieChart`, and `NStatusBreakdown`
61
+ components with caller-formatted generic data, accessible summaries, empty
62
+ states, responsive RTL-safe layouts, and shape-matched loading skeletons.
63
+ - Default chart colors to the live `--chart-1` through `--chart-5` theme
64
+ variables, cycle deterministically after five items, and retain explicit
65
+ per-series/item color overrides.
66
+ - Add preset and numeric chart diameter contracts to `NPieChart` and
67
+ `NDonutCard`, including narrow-container shrinking without clipped legends.
68
+ - Make `NDonutCard` item colors optional and add accessible loading states to
69
+ `NDonutCard` and `NStatCard`.
70
+ - Add public API tests, component tests, README guidance, and playground
71
+ examples for the chart and loading contracts.
72
+
73
+ ## 2.1.49 - 2026-08-04
74
+
75
+ ### ImageInput and AvatarInput
76
+
77
+ - Add `previewAlt`, `fallbackImage`, `fallbackAlt`, `unavailableContent`,
78
+ `imageClassName`, `onPreviewError`, `replaceAriaLabel`, and `clearAriaLabel`
79
+ to `ImageInputProps`. `AvatarInput` forwards every new prop unchanged.
80
+ - Preview sources resolve in this priority order: `value`, `fallbackImage`,
81
+ `defaultImage`. Candidate URLs are deduplicated so a failing primary URL is
82
+ never retried through multiple stages. When every candidate fails, the
83
+ broken `<img>` is unmounted and `unavailableContent` (or a neutral default)
84
+ is rendered in its place.
85
+ - `imageVersion` is appended safely to relative, absolute, queried, and
86
+ fragmented URLs. `data:`, `blob:`, `javascript:`, and `file:` URLs are
87
+ left unchanged.
88
+ - Expose `data-image-input-state="empty" | "preview" | "fallback" | "unavailable"`
89
+ on the preview container for styling, testing, and consumer diagnostics.
90
+ - File selection is race-safe: stale `FileReader` completions cannot replace
91
+ a newer value. Object URLs created by the component are tracked so
92
+ consumer-owned blob URLs are never revoked.
93
+ - Replace and clear controls are real `<button>` elements, are reachable
94
+ with the keyboard, and stay visible on touch and coarse-pointer devices.
95
+ Only on `(hover: hover) and (pointer: fine)` desktops do the controls fall
96
+ back to a hover/focus reveal. `focus-visible` always restores visibility.
97
+ - Use logical positioning (`end-*`) so the clear button works correctly in
98
+ RTL layouts.
99
+ - Re-export `ImageInputPreviewSource` and `ImageInputPreviewError` from
100
+ `najm-kit/components/inputs` and the package root.
101
+
102
+ ## 2.1.48 - 2026-08-04
103
+
104
+ - Keep responsive card row actions visible on phone, tablet, and touch input,
105
+ while retaining hover and keyboard-focus reveal on fine-pointer desktops.
106
+ - Size table and card loading skeletons from the measured body and active grid,
107
+ and keep loading borders, radius, color, and shadow aligned with loaded
108
+ surfaces.
109
+ - Add the exported `NTableCardPagination` and `NTableLoadMorePagination`
110
+ contracts for paged, complete supplied-data, and explicit server-backed Load
111
+ more card presentation, including guarded append/retry behavior and accessible
112
+ loading, result, error, and terminal feedback.
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
- import React__default, { ReactNode } from 'react';
3
+ import React__default from 'react';
4
+ import { a as NTablePaginationLabels, e as NajmTranslate } from './paginationLabels-CY2PvbMj.js';
4
5
 
5
6
  type NajmMode = 'light' | 'dark';
6
7
  type NajmAccent = 'neutral' | 'emerald' | 'green' | 'slate' | 'blue' | 'violet';
@@ -160,121 +161,6 @@ declare const NAJM_COMPONENT_NAMES: readonly NajmComponentName[];
160
161
  declare const RADIUS_VALUE_MAP: Record<string, string>;
161
162
  declare function resolveRadiusValue(radius: NajmComponentRadius | undefined): string | undefined;
162
163
 
163
- /**
164
- * How the page controls present position within the result.
165
- *
166
- * `numbered` renders a windowed list of page buttons. `compact` renders the
167
- * `Page X of Y` text with first/previous/next/last controls.
168
- *
169
- * `numbered` needs a trustworthy page count. Under `manualPagination` that
170
- * means the application must pass a `pageCount` derived from a real result
171
- * total, or — when its endpoint reports no total — pass `hasNextPage` and no
172
- * `pageCount` at all, which renders the unbounded bar described on the NTable
173
- * prop. With neither, the bar falls back to `compact` on its own rather than
174
- * inviting clicks on pages that may not exist.
175
- *
176
- * What it must never be handed is a `pageCount` that is really a lower bound,
177
- * such as `pageIndex + 2`. That reads as a two-page result on page one and a
178
- * three-page result on page two, so the bar grows a number per click with
179
- * nothing to say why. NTable warns in development when it catches a count
180
- * moving in lockstep with the page index.
181
- */
182
- type NTablePaginationVariant = "numbered" | "compact";
183
- /**
184
- * Accessible names and visible copy for the page controls.
185
- *
186
- * Every field is optional and falls back to English. Supply them to localize —
187
- * the numbered variant is mostly digits, but its controls still need names.
188
- */
189
- interface NTablePaginationLabels {
190
- /** Labels the rows-per-page select. Defaults to `"Rows/page"`. */
191
- rowsPerPage?: string;
192
- /** Accessible name of the whole page control group. Defaults to `"Pagination"`. */
193
- pagination?: string;
194
- /** Accessible name for one page button, given a 1-based page. */
195
- goToPage?: (page: number) => string;
196
- /** Accessible name of the current page button, given a 1-based page. */
197
- currentPage?: (page: number) => string;
198
- firstPage?: string;
199
- previousPage?: string;
200
- nextPage?: string;
201
- lastPage?: string;
202
- /** The `compact` variant's position text, given 1-based values. */
203
- pageOf?: (page: number, pageCount: number) => string;
204
- /**
205
- * The position text when the result has no known total, given the 1-based
206
- * page. Defaults to `"Page X"` — there is no `of Y` to state, and repeating
207
- * the moving lower bound there would be the same lie the numbered bar avoids.
208
- */
209
- pageOfUnknown?: (page: number) => string;
210
- /** The selection summary, given selected and total row counts. */
211
- rowsSelected?: (selected: number, total: number) => string;
212
- }
213
- interface NTableLoadMorePagination {
214
- /** Render the supplied rows as one card list with an explicit continuation control. */
215
- mode: "load-more";
216
- /** Whether the owning application has another server page available. */
217
- hasNextPage: boolean;
218
- /** True while the owning application is appending the next page. */
219
- loadingMore?: boolean;
220
- /** A controlled append error. Existing rows remain rendered and the control becomes Retry. */
221
- loadMoreError?: ReactNode;
222
- /** Fetch exactly one additional page. Najm Kit never constructs or owns the request. */
223
- onLoadMore: () => unknown | Promise<unknown>;
224
- loadMoreLabel?: string;
225
- loadingMoreLabel?: string;
226
- retryLabel?: string;
227
- endLabel?: string;
228
- loadMoreErrorLabel?: string;
229
- /** Localize the polite announcement made after appended rows arrive. */
230
- itemsLoadedLabel?: (count: number) => string;
231
- }
232
- interface NTableInfinitePagination {
233
- /**
234
- * Render the supplied rows as one card list that continues automatically when
235
- * the end of the list scrolls into view. No control and no end-of-list
236
- * element are rendered while the list is healthy; the continuation button
237
- * appears only after an append failure, as the retry target.
238
- */
239
- mode: "infinite";
240
- /** Whether the owning application has another server page available. */
241
- hasNextPage: boolean;
242
- /** True while the owning application is appending the next page. */
243
- loadingMore?: boolean;
244
- /** A controlled append error. Existing rows remain rendered and Retry appears. */
245
- loadMoreError?: ReactNode;
246
- /** Fetch exactly one additional page. Najm Kit never constructs or owns the request. */
247
- onLoadMore: () => unknown | Promise<unknown>;
248
- /**
249
- * Distance ahead of the list end at which the next page is requested.
250
- * Defaults to `"80px"`.
251
- */
252
- rootMargin?: string;
253
- loadingMoreLabel?: string;
254
- retryLabel?: string;
255
- loadMoreErrorLabel?: string;
256
- /** Localize the polite announcement made after appended rows arrive. */
257
- itemsLoadedLabel?: (count: number) => string;
258
- }
259
- /**
260
- * Presentation policy used while NTable is actually rendering cards.
261
- *
262
- * `paged` preserves the existing page controls. `all` renders every supplied
263
- * row without a footer, in card and table modes alike. `load-more` renders
264
- * every supplied row and adds a guarded, accessible continuation control.
265
- * `infinite` renders every supplied row and continues on scroll instead.
266
- *
267
- * Applications remain responsible for fetching, accumulating, filtering,
268
- * sorting, authorization, and privacy. `all` renders exactly the rows it is
269
- * given and never fetches, so a caller that has not loaded the whole set must
270
- * not select it.
271
- */
272
- type NTableCardPagination = {
273
- mode?: "paged";
274
- } | {
275
- mode: "all";
276
- } | NTableLoadMorePagination | NTableInfinitePagination;
277
-
278
164
  /**
279
165
  * Defaults every `NTable` beneath the provider inherits.
280
166
  *
@@ -360,31 +246,6 @@ declare function useNajmTheme(): Pick<NajmPreferencesContextValue, "theme" | "se
360
246
  /** The live time zone and a setter that persists through `onTimeZoneChange`. */
361
247
  declare function useNajmTimeZone(): Pick<NajmPreferencesContextValue, "timeZone" | "setTimeZone">;
362
248
 
363
- /**
364
- * The translator shape `NajmUIProvider` accepts.
365
- *
366
- * Deliberately structural rather than an import from `najm-i18n`: the kit
367
- * depends on no `najm-*` package, and this signature is satisfied by every
368
- * mainstream i18n library. The application keeps its catalog and its own
369
- * language provider.
370
- */
371
- type NajmTranslate = (key: string, params?: Record<string, string | number>) => string;
372
- declare const DEFAULT_PAGINATION_KEY_PREFIX = "common.pagination";
373
- /**
374
- * Projects a translator onto the ten pagination labels.
375
- *
376
- * Keys are `<prefix>.<field>`, matching the `NTablePaginationLabels` field
377
- * names one-for-one, so a catalog is readable next to the type. Interpolation
378
- * params are named for what they are: `page`, `pageCount`, `selected`, `total`.
379
- *
380
- * No result is inspected or second-guessed. A translator that echoes missing
381
- * keys will render those keys — that is the translator's contract to define,
382
- * and quietly swapping in English would hide the missing entry rather than
383
- * surface it. Applications that want the packaged English for a given label
384
- * should omit the key from the prefix and override it via `tableDefaults`.
385
- */
386
- declare function buildPaginationLabels(t: NajmTranslate, prefix?: string): NTablePaginationLabels;
387
-
388
249
  interface NajmUIProviderProps extends Omit<NajmPreferencesProviderProps, "children"> {
389
250
  children: React$1.ReactNode;
390
251
  /**
@@ -454,4 +315,4 @@ interface NajmUIProviderProps extends Omit<NajmPreferencesProviderProps, "childr
454
315
  */
455
316
  declare function NajmUIProvider({ children, design, initialDesign, className, t, paginationKeyPrefix, tableDefaults, initialTheme, initialTimeZone, onThemeChange, onTimeZoneChange, normalizeTimeZone, }: NajmUIProviderProps): react_jsx_runtime.JSX.Element;
456
317
 
457
- export { type NajmDensity as A, type NajmPreferencesContextValue as B, NajmPreferencesProvider as C, DEFAULT_PAGINATION_KEY_PREFIX as D, type NajmPreferencesProviderProps as E, type NajmSlotStyle as F, type NajmTranslate as G, NajmUIProvider as H, buildPaginationLabels as I, resolveRadiusValue as J, useNTableDefaults as K, useNajmPreferencesContext as L, useNajmTheme as M, type NajmUIProviderProps as N, useNajmTimeZone as O, RADIUS_VALUE_MAP as R, type NajmDesignConfig as a, type NajmThemeProviderProps as b, type NajmAppearance as c, type NajmMode as d, type NajmThemeConfig as e, type NajmAccent as f, type NajmThemeTokens as g, type NajmPreset as h, type NajmComponentName as i, type NajmComponentStyleConfig as j, type NajmComponentThemeConfig as k, type NajmTypographyConfig as l, type NajmLayoutConfig as m, type NajmVariantStyle as n, type NTablePaginationVariant as o, type NTablePaginationLabels as p, type NTableCardPagination as q, type NajmResponsiveBreakpoint as r, type NajmResponsiveValue as s, DEFAULT_TIME_ZONE as t, NAJM_COMPONENT_NAMES as u, type NTableDefaults as v, NTableDefaultsProvider as w, type NTableInfinitePagination as x, type NTableLoadMorePagination as y, type NajmComponentRadius as z };
318
+ export { resolveRadiusValue as A, useNTableDefaults as B, useNajmPreferencesContext as C, DEFAULT_TIME_ZONE as D, useNajmTheme as E, useNajmTimeZone as F, type NajmUIProviderProps as N, RADIUS_VALUE_MAP as R, type NajmDesignConfig as a, type NajmThemeProviderProps as b, type NajmAppearance as c, type NajmMode as d, type NajmThemeConfig as e, type NajmAccent as f, type NajmThemeTokens as g, type NajmPreset as h, type NajmComponentName as i, type NajmComponentStyleConfig as j, type NajmComponentThemeConfig as k, type NajmTypographyConfig as l, type NajmLayoutConfig as m, type NajmVariantStyle as n, type NajmResponsiveBreakpoint as o, type NajmResponsiveValue as p, NAJM_COMPONENT_NAMES as q, type NTableDefaults as r, NTableDefaultsProvider as s, type NajmComponentRadius as t, type NajmDensity as u, type NajmPreferencesContextValue as v, NajmPreferencesProvider as w, type NajmPreferencesProviderProps as x, type NajmSlotStyle as y, NajmUIProvider as z };
@@ -3,7 +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-Dj32bd5d.js';
6
+ import '../NajmUIProvider-ClpHD-55.js';
7
+ import '../paginationLabels-CY2PvbMj.js';
7
8
 
8
9
  /** Branding shown by the kit's chrome. Purely presentational values. */
9
10
  interface NajmAppBranding {
@@ -38,6 +39,30 @@ interface NajmAppProviderProps extends Omit<NajmNextUIProviderProps, 't'> {
38
39
  * branding endpoint returns. An `appName` inside `initialBranding` wins.
39
40
  */
40
41
  appName?: string;
42
+ /**
43
+ * ISO 4217 code for `useNajmFormat().money`, e.g. `"MAD"`.
44
+ *
45
+ * Omitted means the application does not format currency. It is not defaulted
46
+ * to anything: rendering an amount in the wrong currency is worse than the
47
+ * error thrown for the missing code.
48
+ */
49
+ currency?: string;
50
+ /**
51
+ * Maps a `najm-i18n` language onto the BCP 47 tag used for formatting, e.g.
52
+ * `{ en: "en-MA", fr: "fr-MA" }`.
53
+ *
54
+ * The distinction matters because language and region are separate choices:
55
+ * `fr` alone formats dates and separators the French way, which is not how
56
+ * they are written in Morocco. Unmapped languages are used as-is.
57
+ */
58
+ locales?: Record<string, string>;
59
+ /**
60
+ * Fixes the formatting locale, ignoring the active language. Escape hatch for
61
+ * an application whose language and number formats are genuinely independent.
62
+ */
63
+ locale?: string;
64
+ /** Rendered for absent values. Defaults to an em dash. */
65
+ formatPlaceholder?: string;
41
66
  /**
42
67
  * Controlled marks. Prefer `initialBranding` — passing this means the
43
68
  * application holds the state itself, which is the file this provider exists
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { NBrandingStateProvider } from '../chunk-5LW62RB6.mjs';
2
+ import { NBrandingStateProvider, NajmFormatProvider } from '../chunk-QOP7L6RD.mjs';
3
3
  import { NajmNextUIProvider } from '../chunk-IRFFSAO2.mjs';
4
4
  import '../chunk-USZUOJMK.mjs';
5
5
  import '../chunk-KVZACF4G.mjs';
@@ -12,15 +12,28 @@ function NajmAppUI({
12
12
  children,
13
13
  branding,
14
14
  initialBranding,
15
+ currency,
16
+ locale,
17
+ locales,
18
+ formatPlaceholder,
15
19
  ...props
16
20
  }) {
17
- const { t } = useTranslation();
21
+ const { t, language } = useTranslation();
22
+ const resolved = locale ?? locales?.[language] ?? language;
18
23
  return /* @__PURE__ */ jsx(NajmNextUIProvider, { t, ...props, children: /* @__PURE__ */ jsx(
19
24
  NBrandingStateProvider,
20
25
  {
21
26
  branding,
22
27
  initialBranding,
23
- children
28
+ children: /* @__PURE__ */ jsx(
29
+ NajmFormatProvider,
30
+ {
31
+ locale: resolved,
32
+ currency,
33
+ placeholder: formatPlaceholder,
34
+ children
35
+ }
36
+ )
24
37
  }
25
38
  ) });
26
39
  }
@@ -28,6 +41,10 @@ function NajmAppNoI18n({
28
41
  children,
29
42
  branding,
30
43
  initialBranding,
44
+ currency,
45
+ locale,
46
+ locales,
47
+ formatPlaceholder,
31
48
  ...props
32
49
  }) {
33
50
  return /* @__PURE__ */ jsx(NajmNextUIProvider, { ...props, children: /* @__PURE__ */ jsx(
@@ -35,7 +52,15 @@ function NajmAppNoI18n({
35
52
  {
36
53
  branding,
37
54
  initialBranding,
38
- children
55
+ children: /* @__PURE__ */ jsx(
56
+ NajmFormatProvider,
57
+ {
58
+ locale: locale ?? "en",
59
+ currency,
60
+ placeholder: formatPlaceholder,
61
+ children
62
+ }
63
+ )
39
64
  }
40
65
  ) });
41
66
  }
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React__default from 'react';
3
- import { N as NajmUIProviderProps } from '../NajmUIProvider-Dj32bd5d.js';
3
+ import { N as NajmUIProviderProps } from '../NajmUIProvider-ClpHD-55.js';
4
+ import '../paginationLabels-CY2PvbMj.js';
4
5
 
5
6
  interface NextLinkAdapterProps extends Record<string, any> {
6
7
  href: string;
@@ -0,0 +1,93 @@
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 };