najm-kit 2.7.3 → 2.8.1

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/dist/query.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _tanstack_query_core from '@tanstack/query-core';
2
2
  import { OffsetPageFetcher, OffsetPage } from './pagination.js';
3
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';
4
+ import { L as ListStrategy, R as ResolvedListMode } from './cardPagination-Bwf3tEeN.js';
5
+ export { C as CardPaginationKey, a as CardPaginationLabels, b as CardPaginationState, c as buildCardPaginationLabels, d as createCardPagination } from './cardPagination-Bwf3tEeN.js';
6
+ import './paginationLabels-dZLSNxfo.js';
7
7
  import 'react';
8
8
 
9
9
  interface UseOffsetInfiniteQueryOptions<T> {
package/dist/query.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { useCardViewport } from './chunk-XGDMPI5U.mjs';
2
- export { buildCardPaginationLabels, createCardPagination } from './chunk-XGDMPI5U.mjs';
1
+ import { useCardViewport } from './chunk-OUS7OYVA.mjs';
2
+ export { buildCardPaginationLabels, createCardPagination } from './chunk-OUS7OYVA.mjs';
3
3
  import { fetchOffsetPage, DEFAULT_MAX_PAGE_SIZE } from './chunk-2NX2VKS2.mjs';
4
4
  export { DEFAULT_MAX_PAGE_SIZE, DEFAULT_PAGE_SIZE, cleanQuery, createOffsetPagination, fetchOffsetPage, getPageIndex } from './chunk-2NX2VKS2.mjs';
5
5
  import { useInfiniteQuery } from '@tanstack/react-query';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najm-kit",
3
- "version": "2.7.3",
3
+ "version": "2.8.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Reusable React UI component package for Najm framework",
@@ -1,116 +0,0 @@
1
- import { useNajmPreferencesContext } from './chunk-USZUOJMK.mjs';
2
- import { humanizeToken, DEFAULT_PLACEHOLDER, formatRelativeTime, formatTime, formatDateTime, formatDate, formatPercent, formatNumber, formatCurrency } from './chunk-GPHWBOSP.mjs';
3
- import * as React from 'react';
4
- import { createContext, useContext, useMemo, useState, useCallback } from 'react';
5
- import { jsx } from 'react/jsx-runtime';
6
-
7
- function normalizeBranding(input) {
8
- if (!input) return {};
9
- const value = {};
10
- const expanded = input.logoExpanded ?? input.sidebarLogoExpandedPath;
11
- const collapsed = input.logoCollapsed ?? input.sidebarLogoCollapsedPath;
12
- if (input.appName !== void 0) value.appName = input.appName;
13
- if (input.logoFallback !== void 0) value.logoFallback = input.logoFallback;
14
- if (input.logoHref !== void 0) value.logoHref = input.logoHref;
15
- if (expanded !== void 0) value.logoExpanded = expanded;
16
- if (collapsed !== void 0) value.logoCollapsed = collapsed;
17
- return value;
18
- }
19
- var NBrandingContext = createContext(null);
20
- function useNBranding() {
21
- return useContext(NBrandingContext);
22
- }
23
- function NBrandingProvider({
24
- children,
25
- appName,
26
- logoExpanded,
27
- logoCollapsed,
28
- logoFallback,
29
- logoHref
30
- }) {
31
- const value = useMemo(
32
- () => ({ appName, logoExpanded, logoCollapsed, logoFallback, logoHref }),
33
- [appName, logoExpanded, logoCollapsed, logoFallback, logoHref]
34
- );
35
- return /* @__PURE__ */ jsx(NBrandingContext.Provider, { value, children });
36
- }
37
- var NBrandingEditorContext = createContext(null);
38
- function useNBrandingEditor() {
39
- return useContext(NBrandingEditorContext);
40
- }
41
- function NBrandingStateProvider({
42
- children,
43
- branding,
44
- initialBranding
45
- }) {
46
- const [state, setState] = useState(
47
- () => normalizeBranding(initialBranding ?? branding)
48
- );
49
- const setBranding = useCallback((patch) => {
50
- const marks = normalizeBranding(patch);
51
- setState((current) => ({ ...current, ...marks }));
52
- }, []);
53
- const controlled = useMemo(
54
- () => branding ? normalizeBranding(branding) : void 0,
55
- [branding]
56
- );
57
- const resolved = controlled ?? state;
58
- const editor = useMemo(
59
- () => ({ branding: resolved, setBranding: branding ? noop : setBranding }),
60
- [resolved, branding, setBranding]
61
- );
62
- return /* @__PURE__ */ jsx(NBrandingEditorContext.Provider, { value: editor, children: /* @__PURE__ */ jsx(NBrandingProvider, { ...resolved, children }) });
63
- }
64
- function noop() {
65
- }
66
- var NajmFormatContext = React.createContext(
67
- null
68
- );
69
- function NajmFormatProvider({
70
- children,
71
- locale,
72
- currency,
73
- timeZone,
74
- placeholder = DEFAULT_PLACEHOLDER
75
- }) {
76
- const preferences = useNajmPreferencesContext();
77
- const resolvedTimeZone = timeZone ?? preferences?.timeZone ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
78
- const value = React.useMemo(() => {
79
- const config = {
80
- locale,
81
- timeZone: resolvedTimeZone,
82
- currency,
83
- placeholder
84
- };
85
- return {
86
- locale,
87
- timeZone: resolvedTimeZone,
88
- currency,
89
- placeholder,
90
- config,
91
- money: (minorUnits) => formatCurrency(minorUnits, config),
92
- number: (value_, options) => formatNumber(value_, config, options),
93
- percent: (value_, digits) => formatPercent(value_, config, digits),
94
- date: (value_, options) => formatDate(value_, config, options),
95
- dateTime: (value_) => formatDateTime(value_, config),
96
- time: (value_) => formatTime(value_, config),
97
- relativeTime: (value_) => formatRelativeTime(value_, config),
98
- humanize: humanizeToken
99
- };
100
- }, [locale, resolvedTimeZone, currency, placeholder]);
101
- return /* @__PURE__ */ jsx(NajmFormatContext.Provider, { value, children });
102
- }
103
- function useNajmFormatContext() {
104
- return React.useContext(NajmFormatContext);
105
- }
106
- function useNajmFormat() {
107
- const value = React.useContext(NajmFormatContext);
108
- if (!value) {
109
- throw new Error(
110
- "useNajmFormat must be rendered under a NajmFormatProvider or NajmAppProvider."
111
- );
112
- }
113
- return value;
114
- }
115
-
116
- export { NBrandingProvider, NBrandingStateProvider, NajmFormatProvider, normalizeBranding, useNBranding, useNBrandingEditor, useNajmFormat, useNajmFormatContext };