@nice2dev/ui 1.0.0

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/README.md ADDED
@@ -0,0 +1,702 @@
1
+ # @nice2dev/ui
2
+
3
+ **Universal, themeable, i18n-ready React component library** — 160+ production-grade UI components with zero external runtime dependencies. Built as a complete replacement for DevExtreme with a modern, lightweight architecture.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@nice2dev/ui)](https://www.npmjs.com/package/@nice2dev/ui)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
8
+ [![React](https://img.shields.io/badge/React-17%2B-61DAFB?logo=react&logoColor=white)](https://react.dev/)
9
+ [![Bundle Size](https://img.shields.io/badge/bundle-347kB%20gzipped-brightgreen)](https://www.npmjs.com/package/@nice2dev/ui)
10
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-success)](https://www.npmjs.com/package/@nice2dev/ui)
11
+
12
+ ---
13
+
14
+ ## Table of Contents
15
+
16
+ - [Features](#features)
17
+ - [Installation](#installation)
18
+ - [Quick Start](#quick-start)
19
+ - [Component Catalog](#component-catalog)
20
+ - [Editors (28)](#editors-28-components)
21
+ - [Buttons (5)](#buttons-5-components)
22
+ - [Data Display (13)](#data-display-13-components)
23
+ - [Feedback (6 + 1 hook)](#feedback-6-components--1-hook)
24
+ - [Navigation (16)](#navigation-16-components)
25
+ - [Data (11)](#data-11-components)
26
+ - [Charts (16)](#charts-16-components)
27
+ - [Overlays & Layout (9)](#overlays--layout-9-components)
28
+ - [Planning (4)](#planning-4-components)
29
+ - [Tools (14)](#tools-14-components)
30
+ - [Validation (3 + 1 hook)](#validation-3-components--1-hook)
31
+ - [Core Infrastructure](#core-infrastructure)
32
+ - [Shared Types](#shared-types)
33
+ - [Hooks](#hooks)
34
+ - [Icon System](#icon-system)
35
+ - [Internationalization (i18n)](#internationalization-i18n)
36
+ - [Theming](#theming)
37
+ - [CSS Custom Properties](#css-custom-properties)
38
+ - [Dark Mode](#dark-mode)
39
+ - [Custom Themes](#custom-themes)
40
+ - [Build & Development](#build--development)
41
+ - [Architecture](#architecture)
42
+ - [Companion Package: @nice2dev/icons](#companion-package-nice2devicons)
43
+
44
+ ---
45
+
46
+ ## Features
47
+
48
+ - **160+ components** covering all major UI categories (editors, data grids, charts, planning, overlays, navigation, desktop, and more)
49
+ - **Zero runtime dependencies** — only `react` and `react-dom` as peer dependencies
50
+ - **78 built-in SVG icons** — no icon library required for common UI chrome
51
+ - **Pluggable icon system** — swap in FontAwesome, Material Icons, or any custom set via `NiceIconProvider`
52
+ - **i18n-ready** — plug in any translation function (react-i18next, custom) via `NiceI18nProvider`; works without a provider out of the box
53
+ - **CSS custom properties theming** — 7 built-in theme presets, live Theme Designer, full dark mode
54
+ - **Dark mode** — automatic (`prefers-color-scheme`) and manual (class or `data-theme` attribute)
55
+ - **Touch & mobile optimized** — adaptive 44px+ touch targets, pointer event support, responsive breakpoints, no hover stickiness
56
+ - **Access control** — built-in per-component access modes (`full`, `readOnly`, `disabled`, `hidden`) with `NiceAccessControl` provider
57
+ - **Responsive utilities** — `useBreakpoint`, `useMediaQuery`, `useResponsiveValue`, `useContainerSize` hooks + responsive CSS
58
+ - **Tree-shakeable** — ESM output for optimal bundling
59
+ - **TypeScript-first** — strict mode, full type definitions shipped with the package
60
+ - **Embeddable Showcase** — `<NiceShowcase />` component with About page, live demos, theme designer, and component configurator
61
+
62
+ ---
63
+
64
+ ## Installation
65
+
66
+ ```bash
67
+ npm install @nice2dev/ui
68
+ # or
69
+ yarn add @nice2dev/ui
70
+ # or
71
+ pnpm add @nice2dev/ui
72
+ ```
73
+
74
+ **Peer dependencies:** `react >= 17.0.0`, `react-dom >= 17.0.0`
75
+
76
+ ---
77
+
78
+ ## Quick Start
79
+
80
+ ```tsx
81
+ import { NiceButton, NiceTextInput, NiceIcon } from '@nice2dev/ui';
82
+ import '@nice2dev/ui/style.css';
83
+
84
+ function App() {
85
+ return (
86
+ <div>
87
+ <NiceTextInput label="Name" placeholder="Enter your name" />
88
+ <NiceButton variant="primary" icon={<NiceIcon name="check" />}>
89
+ Submit
90
+ </NiceButton>
91
+ </div>
92
+ );
93
+ }
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Component Catalog
99
+
100
+ ### Editors (28 components)
101
+
102
+ Form input components with consistent `NiceFormFieldProps` interface: `label`, `helperText`, `error`, `required`, `disabled`, `readOnly`, `size`, `name`.
103
+
104
+ | Component | Key Props | Description |
105
+ |-----------|-----------|-------------|
106
+ | `NiceTextInput` | `value`, `onChange`, `placeholder`, `type`, `clearable` | Standard text input |
107
+ | `NiceTextArea` | `value`, `onChange`, `rows`, `autoResize`, `maxLength` | Multi-line text input |
108
+ | `NiceNumberInput` | `value`, `onChange`, `min`, `max`, `step`, `format` | Numeric input with stepper |
109
+ | `NiceDatePicker` | `value`, `onChange`, `format`, `minDate`, `maxDate` | Date selection |
110
+ | `NiceSelect` | `value`, `onChange`, `options[]`, `searchable`, `clearable`, `multiple` | Dropdown select |
111
+ | `NiceCheckbox` | `checked`, `onChange`, `indeterminate` | Checkbox |
112
+ | `NiceToggle` | `checked`, `onChange`, `labelOn`, `labelOff` | Toggle switch |
113
+ | `NiceRadioGroup` | `value`, `onChange`, `options[]`, `direction` | Radio button group |
114
+ | `NiceSlider` | `value`, `onChange`, `min`, `max`, `step`, `showTooltip` | Single-value slider |
115
+ | `NiceColorPicker` | `value`, `onChange`, `format`, `presets[]` | Color picker with presets |
116
+ | `NiceAutocomplete` | `value`, `onChange`, `options[]`, `onSearch`, `debounce` | Autocomplete input |
117
+ | `NiceLookup` | `value`, `onChange`, `dataSource`, `displayExpr`, `valueExpr` | Lookup field |
118
+ | `NiceCalendar` | `value`, `onChange`, `minDate`, `maxDate`, `disabledDates` | Inline calendar |
119
+ | `NiceDateRangeBox` | `startDate`, `endDate`, `onChange`, `format` | Date range picker |
120
+ | `NiceTagBox` | `value`, `onChange`, `options[]`, `maxTags`, `allowCustom` | Tag/chip input |
121
+ | `NiceRangeSlider` | `value` (tuple), `onChange`, `min`, `max`, `step` | Dual-handle range slider |
122
+ | `NiceDropDownBox` | `value`, `onChange`, `renderContent`, `displayValue` | Generic drop-down container |
123
+ | `NiceHtmlEditor` | `value`, `onChange`, `toolbar`, `placeholder` | Rich text (HTML) editor |
124
+ | `NiceForm` | `children`, `onSubmit`, `layout`, `labelPosition` | Form layout wrapper |
125
+ | `NiceRating` | `value`, `onChange`, `max`, `icon`, `allowHalf` | Star/icon rating input |
126
+ | `NiceOtpInput` | `value`, `onChange`, `length`, `type` | One-time password input |
127
+ | `NiceSignaturePad` | `value`, `onChange`, `width`, `height`, `penColor` | Signature capture pad |
128
+ | `NiceMentionInput` | `value`, `onChange`, `users[]`, `trigger` | Text input with @mentions |
129
+ | `NiceTreeSelect` | `value`, `onChange`, `nodes[]`, `multiple` | Tree-based selection |
130
+ | `NiceMaskedInput` | `value`, `onChange`, `mask`, `placeholder` | Masked/formatted input |
131
+ | `NiceKnob` | `value`, `onChange`, `min`, `max`, `draggable` | Rotary knob input |
132
+ | `NicePickList` | `source[]`, `target[]`, `onChange` | Dual-list pick transfer |
133
+ | `NiceInlineEdit` | `value`, `onChange`, `renderDisplay`, `renderEditor` | Click-to-edit inline |
134
+ | `NiceLookup` | `value`, `onChange`, `dataSource`, `displayExpr`, `valueExpr` | Lookup field |
135
+
136
+ ### Buttons (5 components)
137
+
138
+ | Component | Key Props | Description |
139
+ |-----------|-----------|-------------|
140
+ | `NiceButton` | `variant`, `size`, `icon`, `loading`, `disabled`, `onClick` | Standard button |
141
+ | `NiceButtonGroup` | `items[]`, `selectedIndex`, `onSelect`, `variant` | Grouped buttons |
142
+ | `NiceIconButton` | `icon`, `size`, `variant`, `onClick`, `tooltip` | Icon-only button |
143
+ | `NiceDropDownButton` | `text`, `items[]`, `onItemClick`, `variant`, `icon` | Button with dropdown menu |
144
+ | `NiceSpeedDialAction` | `icon`, `actions[]`, `position`, `onClick` | Floating action button (FAB) |
145
+
146
+ ### Data Display (13 components)
147
+
148
+ | Component | Key Props | Description |
149
+ |-----------|-----------|-------------|
150
+ | `NiceBadge` | `count`, `variant`, `dot`, `max`, `children` | Notification badge |
151
+ | `NiceTag` | `children`, `variant`, `closable`, `onClose`, `icon` | Tag/chip |
152
+ | `NiceAvatar` | `src`, `alt`, `size`, `fallback`, `shape` | User avatar |
153
+ | `NiceAvatarGroup` | `items[]`, `max`, `size` | Stacked avatar group |
154
+ | `NiceProgress` | `value`, `max`, `variant`, `showLabel`, `size` | Progress bar |
155
+ | `NiceDivider` | `orientation`, `label`, `variant` | Horizontal/vertical divider |
156
+ | `NiceTooltip` | `content`, `position`, `delay`, `children` | Tooltip wrapper |
157
+ | `NiceSkeleton` | `variant` (`text`/`circle`/`rect`), `width`, `height`, `count` | Loading skeleton |
158
+ | `NiceSpinner` | `size`, `variant`, `overlay` | Loading spinner |
159
+ | `NiceEmpty` | `icon`, `title`, `description`, `action` | Empty state placeholder |
160
+ | `NiceTimeline` | `items[]`, `mode`, `pending` | Vertical/horizontal timeline |
161
+ | `NiceCarousel` | `items[]`, `autoPlay`, `interval`, `dots` | Image/content carousel |
162
+ | `NiceVirtualScroller` | `items[]`, `itemHeight`, `renderItem` | Virtualized list for large datasets |
163
+
164
+ ### Feedback (6 components + 1 hook)
165
+
166
+ | Component | Key Props | Description |
167
+ |-----------|-----------|-------------|
168
+ | `NiceAlert` | `variant` (`info`/`success`/`warning`/`error`), `title`, `closable`, `icon` | Alert banner |
169
+ | `NiceModal` | `open`, `onClose`, `title`, `size`, `footer`, `closeOnOverlay`, `closeOnEscape` | Modal dialog |
170
+ | `NiceDrawer` | `open`, `onClose`, `title`, `placement` (`left`/`right`/`top`/`bottom`), `width` | Slide-out drawer |
171
+ | `NiceToastContainer` | — | Container for toast notifications (mount once) |
172
+ | `useNiceToast()` | — | Hook: `{ show: (message, type?, duration?) => void }` |
173
+ | `NiceConfirmDialog` | `open`, `onConfirm`, `onCancel`, `title`, `message` | Confirmation prompt |
174
+ | `NiceCookieConsent` | `onAccept`, `onDecline`, `privacyUrl` | GDPR cookie consent bar |
175
+ | `NiceLoginForm` | `onLogin`, `onForgotPassword`, `logo` | Pre-built login form |
176
+
177
+ ### Navigation (16 components)
178
+
179
+ | Component | Key Props | Description |
180
+ |-----------|-----------|-------------|
181
+ | `NiceTabs` | `tabs[]`, `activeTab`, `onChange`, `variant` (`default`/`pills`/`enclosed`), `vertical` | Tab navigation |
182
+ | `NiceAccordion` | `items[]`, `multiple`, `defaultOpen` | Collapsible accordion panels |
183
+ | `NiceBreadcrumb` | `items[]`, `separator` | Breadcrumb trail |
184
+ | `NicePagination` | `current`, `total`, `onChange`, `pageSize`, `showSizeChanger` | Pagination controls |
185
+ | `NiceCard` | `title`, `extra`, `bordered`, `hoverable`, `loading`, `children` | Card container |
186
+ | `NiceMenu` | `items[]`, `theme`, `mode` (`vertical`/`horizontal`) | Navigation menu |
187
+ | `NiceContextMenu` | `items[]`, `onAction`, `children` | Right-click context menu |
188
+ | `NiceMultiView` | `views[]`, `activeView`, `onChange` | Multi-view container |
189
+ | `NiceTabPanel` | `label`, `icon`, `children` | Tab panel (used inside NiceMultiView) |
190
+ | `NiceSplitter` | `direction` (`horizontal`/`vertical`), `sizes`, `children` | Resizable split panes |
191
+ | `NiceToolbar` | `items[]`, `theme`, `mode` | Toolbar with configurable items |
192
+ | `NiceAppLayout` | `sidebar`, `header`, `footer`, `children` | Application shell layout |
193
+ | `NiceBottomNavigation` | `items[]`, `active`, `onChange` | Mobile bottom navigation bar |
194
+ | `NiceDashboardLayout` | `widgets[]`, `columns`, `draggable` | Dashboard grid layout |
195
+ | `NiceDesktop` | `windows[]`, `wallpaper`, `onWindowChange` | Desktop window manager |
196
+ | `NiceConsole` | `commands[]`, `onCommand`, `history` | Terminal/console emulator |
197
+
198
+ ### Data (11 components)
199
+
200
+ | Component | Key Props | Description |
201
+ |-----------|-----------|-------------|
202
+ | `NiceTable` | `columns[]`, `data[]`, `striped`, `compact`, `emptyText` | Simple data table |
203
+ | `NiceDataGrid` | `columns[]`, `data[]`, `virtualized`, `sortable`, `filterable`, `selectable` | Full-featured data grid |
204
+ | `NiceList` | `items[]`, `renderItem`, `emptyText`, `virtualized` | List view |
205
+ | `NiceTreeView` | `nodes[]`, `onSelect`, `selectable`, `expandable` | Tree structure viewer |
206
+ | `NiceTreeList` | `nodes[]`, `renderNode`, `editable` | Editable tree list |
207
+ | `NiceCardView` | `items[]`, `renderCard`, `columns`, `gap` | Card grid layout |
208
+ | `NiceTileView` | `items[]`, `renderTile`, `columns` | Tile grid layout |
209
+ | `NicePivotGrid` | `data[]`, `fields[]`, `rowGrandTotal`, `columnGrandTotal` | Pivot table |
210
+ | `NicePivotGridFieldChooser` | — | Field chooser companion for NicePivotGrid |
211
+ | `NiceKanbanBoard` | `columns[]`, `cards[]`, `onCardMove` | Kanban board |
212
+ | `NiceSpreadsheet` | `data[][]`, `columns[]`, `editable` | Excel-like spreadsheet |
213
+
214
+ ### Charts (16 components)
215
+
216
+ | Component | Key Props | Description |
217
+ |-----------|-----------|-------------|
218
+ | `NiceChart` | `data[]`, `series[]`, `type` (`line`/`bar`/`area`/`scatter`), `xAxis`, `yAxis` | Multi-type chart |
219
+ | `NicePieChart` | `data[]`, `legend`, `donut` | Pie / donut chart |
220
+ | `NicePolarChart` | `data[]`, `series[]`, `angleAxis`, `radiusAxis` | Polar coordinate chart |
221
+ | `NiceCircularGauge` | `value`, `min`, `max`, `threshold`, `unit` | Circular gauge |
222
+ | `NiceLinearGauge` | `value`, `min`, `max`, `orientation` | Linear gauge |
223
+ | `NiceBarGauge` | `value`, `max`, `count` | Bar gauge |
224
+ | `NiceSparkline` | `data[]`, `type`, `trend` | Inline sparkline |
225
+ | `NiceBullet` | `value`, `ranges[]`, `measure`, `comparative` | Bullet chart |
226
+ | `NiceFunnel` | `data[]`, `link` | Funnel chart |
227
+ | `NiceSankey` | `nodes[]`, `links[]` | Sankey diagram |
228
+ | `NiceRangeSelector` | `data[]`, `onRangeChange` | Range selector chart |
229
+ | `NiceVectorMap` | `regions[]`, `mapName`, `onRegionClick` | Vector map |
230
+ | `NiceHeatMap` | `data[][]`, `xLabels`, `yLabels`, `colorScale` | Heat map grid |
231
+ | `NiceTreeMap` | `data[]`, `valueField`, `labelField` | Hierarchical tree map |
232
+ | `NiceStockChart` | `data[]`, `type` (`candlestick`/`ohlc`), `volume` | Financial stock chart |
233
+ | `NiceOrganizationChart` | `nodes[]`, `direction`, `onNodeClick` | Org chart / hierarchy |
234
+
235
+ ### Overlays & Layout (9 components)
236
+
237
+ | Component | Key Props | Description |
238
+ |-----------|-----------|-------------|
239
+ | `NiceActionSheet` | `open`, `onClose`, `items[]`, `title` | Mobile-style action sheet |
240
+ | `NicePopover` | `content`, `trigger`, `position`, `visible`, `children` | Popover |
241
+ | `NiceLoadPanel` | `visible`, `message` | Full-screen loading overlay |
242
+ | `NiceBox` | `padding`, `margin`, `border`, `background`, `children` | Box layout container |
243
+ | `NiceResponsiveBox` | `items[]`, `children` | Responsive layout container |
244
+ | `NiceResizable` | `width`, `height`, `minWidth`, `minHeight`, `onResize`, `children` | Resizable container |
245
+ | `NiceScrollView` | `horizontal`, `vertical`, `showTrack`, `children` | Custom scroll container |
246
+ | `NiceBlockUI` | `blocked`, `message`, `children` | Block UI overlay |
247
+ | `NiceWindow` | `title`, `open`, `onClose`, `resizable`, `draggable` | Draggable/resizable window |
248
+
249
+ ### Planning (4 components)
250
+
251
+ | Component | Key Props | Description |
252
+ |-----------|-----------|-------------|
253
+ | `NiceScheduler` | `events[]`, `onEventChange`, `view`, `resources[]`, `workDays` | Calendar scheduler |
254
+ | `NiceGantt` | `tasks[]`, `columns[]`, `scale`, `onTaskChange` | Gantt chart |
255
+ | `NiceDiagram` | `nodes[]`, `edges[]`, `onNodeClick`, `onEdgeClick` | Node/edge diagram |
256
+ | `NiceStepper` | `steps[]`, `currentStep`, `onStepChange`, `vertical` | Step wizard |
257
+
258
+ ### Tools (14 components)
259
+
260
+ | Component | Key Props | Description |
261
+ |-----------|-----------|-------------|
262
+ | `NiceChat` | `messages[]`, `onSendMessage`, `currentUser` | Chat widget |
263
+ | `NiceDraggable` | `onDrag`, `ghostImage`, `children` | Drag source wrapper |
264
+ | `NiceSortable` | `items[]`, `onSort`, `direction` | Sortable list |
265
+ | `NiceFileUploader` | `onUpload`, `accept`, `multiple`, `maxSize`, `maxFiles` | File upload |
266
+ | `NiceFileManager` | `items[]`, `onDelete`, `onRename`, `onNavigate` | File browser |
267
+ | `NiceFilterBuilder` | `fields[]`, `onChange`, `value` | Visual filter/query builder |
268
+ | `NiceGallery` | `items[]`, `columns`, `gap`, `onItemClick` | Image gallery |
269
+ | `NiceMap` | `markers[]`, `center`, `zoom`, `onMarkerClick` | Map with markers |
270
+ | `NiceSpeechToText` | `onResult`, `language`, `continuous` | Speech recognition |
271
+ | `NiceThemeDesigner` | `onChange`, `onSave`, `onExport` | Live theme editor |
272
+ | `NiceThemeBuilder` | `sections[]`, `onChange`, `onExport` | Theme builder with CSS export |
273
+ | `NiceControlConfigurator` | `controlType`, `propDescriptors[]`, `renderPreview` | Interactive prop configurator |
274
+ | `NiceViewBuilder` | `definition`, `onChange`, `controlRegistry` | Drag-and-drop view builder |
275
+ | `NiceShowcase` | `defaultTab`, `showAbout`, `packageName`, `version` | Embeddable component showcase & docs |
276
+
277
+ ### Validation (3 components + 1 hook)
278
+
279
+ | Component | Key Props | Description |
280
+ |-----------|-----------|-------------|
281
+ | `NiceValidationGroup` | `onSubmit`, `children` | Validation group wrapper |
282
+ | `NiceValidator` | `rules[]`, `value`, `onChange` | Field-level validator |
283
+ | `NiceValidationSummary` | `errors` | Error summary display |
284
+ | `useNiceValidation()` | — | Hook: `{ validate: (data) => NiceValidationRule[] }` |
285
+
286
+ ---
287
+
288
+ ## Core Infrastructure
289
+
290
+ ### Shared Types
291
+
292
+ All components build on a shared type system defined in `src/core/types.ts`:
293
+
294
+ ```typescript
295
+ type NiceSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
296
+
297
+ type NiceVariant = 'primary' | 'secondary' | 'success' | 'warning'
298
+ | 'error' | 'info' | 'ghost' | 'outline';
299
+
300
+ type NiceDensity = 'compact' | 'normal' | 'comfortable';
301
+
302
+ interface NiceBaseProps {
303
+ className?: string;
304
+ style?: React.CSSProperties;
305
+ id?: string;
306
+ 'data-testid'?: string;
307
+ }
308
+
309
+ interface NiceFormFieldProps extends NiceBaseProps {
310
+ label?: string;
311
+ helperText?: string;
312
+ error?: string;
313
+ required?: boolean;
314
+ disabled?: boolean;
315
+ readOnly?: boolean;
316
+ size?: NiceSize;
317
+ name?: string;
318
+ }
319
+
320
+ type NiceOption<T = string> = {
321
+ value: T;
322
+ label: string;
323
+ disabled?: boolean;
324
+ icon?: React.ReactNode;
325
+ description?: string;
326
+ group?: string;
327
+ };
328
+ ```
329
+
330
+ ### Hooks
331
+
332
+ Utility hooks exported from the package:
333
+
334
+ | Hook | Signature | Description |
335
+ |------|-----------|-------------|
336
+ | `useControlId` | `(externalId?: string) => string` | Generates a stable unique ID for form field–label associations. Uses the provided ID if given, otherwise generates one via `useId()`. |
337
+ | `useDebouncedValue` | `<T>(value: T, delayMs: number) => T` | Returns a debounced version of the input value. |
338
+ | `useClickOutside` | `(ref: RefObject<HTMLElement>, handler: () => void) => void` | Fires `handler` when a click or touch occurs outside the referenced element. |
339
+ | `useFocusTrap` | `(ref: RefObject<HTMLElement>, active: boolean) => void` | Traps keyboard focus within the referenced element (Tab/Shift+Tab cycling). Used by modals and drawers. |
340
+ | `useIsTouchDevice` | `() => boolean` | Detects `(pointer: coarse)` media query — returns `true` on touch devices. |
341
+ | `useInputMode` | `() => 'touch' \| 'mouse'` | Dynamically switches based on last input type (touchstart vs pointerdown). |
342
+ | `useLongPress` | `(callback, holdMs?) => PointerHandlers` | Long-press gesture detection for touch (default 500ms). |
343
+ | `useBreakpoint` | `() => 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | Current viewport breakpoint. |
344
+ | `useMediaQuery` | `(query: string) => boolean` | CSS media query match. |
345
+ | `useResponsiveValue` | `<T>(map: Record<Breakpoint, T>) => T` | Returns value matching current breakpoint. |
346
+ | `useContainerSize` | `(ref: RefObject) => { width, height }` | Container element dimensions. |
347
+ | `useNiceToast` | `() => { show: (msg, type?, duration?) => void }` | Programmatic toast notifications. |
348
+ | `useNiceTranslation` | `() => { t: NiceTranslateFn }` | Access the current translation function. |
349
+ | `useNiceIcon` | `(name: string, size: number) => ReactNode \| undefined` | Resolve an icon name via the current icon provider. |
350
+ | `useNiceValidation` | `() => { validate: (data) => NiceValidationRule[] }` | Form validation. |
351
+
352
+ ### Icon System
353
+
354
+ The library ships with **78 built-in SVG icons** covering common UI needs. No external icon library is required for basic usage.
355
+
356
+ #### Built-in Icon Categories
357
+
358
+ | Category | Count | Examples |
359
+ |----------|-------|---------|
360
+ | Navigation | 8 | `chevron-down`, `arrow-left`, `arrow-right`, `arrow-up` |
361
+ | Actions | 10 | `close`, `plus`, `minus`, `check`, `edit`, `trash`, `copy`, `download`, `upload`, `refresh` |
362
+ | UI Chrome | 10 | `search`, `filter`, `sort-asc`, `sort-desc`, `menu`, `more-vertical`, `settings`, `eye`, `eye-off`, `lock` |
363
+ | Status | 6 | `info`, `warning`, `error`, `success`, `help`, `bell` |
364
+ | Content | 12 | `calendar`, `clock`, `file`, `folder`, `image`, `link`, `mail`, `phone`, `user`, `users`, `home`, `star` |
365
+ | Media | 3 | `play`, `pause`, `stop` |
366
+ | Toggle | 3 | `expand`, `collapse`, `external-link` |
367
+ | Misc | 3+ | `heart`, `grip`, `more-horizontal` |
368
+
369
+ #### Using Icons
370
+
371
+ ```tsx
372
+ import { NiceIcon } from '@nice2dev/ui';
373
+
374
+ // Built-in icon (no provider needed)
375
+ <NiceIcon name="check" size="md" />
376
+ <NiceIcon name="search" size={24} color="#3b82f6" />
377
+
378
+ // Icons can be used in any component that accepts an icon prop
379
+ <NiceButton icon={<NiceIcon name="plus" />}>Add Item</NiceButton>
380
+ ```
381
+
382
+ #### Pluggable Icon Resolver
383
+
384
+ You can replace or extend the built-in icons by wrapping your app with `NiceIconProvider`:
385
+
386
+ ```tsx
387
+ import { NiceIconProvider, NiceIconResolver } from '@nice2dev/ui';
388
+
389
+ const myResolver: NiceIconResolver = (name, size) => {
390
+ // Return a ReactNode for known icon names, or undefined to fall back to built-in
391
+ return <MyCustomIcon name={name} size={size} />;
392
+ };
393
+
394
+ <NiceIconProvider resolver={myResolver}>
395
+ <App />
396
+ </NiceIconProvider>
397
+ ```
398
+
399
+ The `NiceIconResolver` type signature:
400
+ ```typescript
401
+ type NiceIconResolver = (name: string, size: number) => React.ReactNode | undefined;
402
+ ```
403
+
404
+ The companion package [`@nice2dev/icons`](#companion-package-nice2devicons) provides a ready-made FontAwesome resolver.
405
+
406
+ #### Icon Sizes
407
+
408
+ | Size Key | Pixels |
409
+ |----------|--------|
410
+ | `xs` | 12 |
411
+ | `sm` | 16 |
412
+ | `md` | 20 |
413
+ | `lg` | 24 |
414
+ | `xl` | 32 |
415
+
416
+ You can also pass a numeric value directly: `<NiceIcon name="check" size={18} />`
417
+
418
+ ### Internationalization (i18n)
419
+
420
+ The library is fully i18n-ready with a pluggable translation system. It works **without any configuration** — all components render with sensible default English strings.
421
+
422
+ ```tsx
423
+ import { NiceI18nProvider, NiceTranslateFn } from '@nice2dev/ui';
424
+
425
+ // With react-i18next:
426
+ import { useTranslation } from 'react-i18next';
427
+
428
+ function App() {
429
+ const { t } = useTranslation();
430
+ return (
431
+ <NiceI18nProvider t={t}>
432
+ <MyPage />
433
+ </NiceI18nProvider>
434
+ );
435
+ }
436
+
437
+ // Custom translation function:
438
+ const myTranslate: NiceTranslateFn = (key, defaultValue) => {
439
+ const translations: Record<string, string> = {
440
+ 'nice.button.submit': 'Enviar',
441
+ 'nice.empty.noData': 'Sin datos',
442
+ };
443
+ return translations[key] ?? defaultValue;
444
+ };
445
+
446
+ <NiceI18nProvider t={myTranslate}>
447
+ <App />
448
+ </NiceI18nProvider>
449
+ ```
450
+
451
+ The `NiceTranslateFn` type:
452
+ ```typescript
453
+ type NiceTranslateFn = (key: string, defaultValue: string) => string;
454
+ ```
455
+
456
+ ---
457
+
458
+ ## NiceShowcase — Embeddable Documentation
459
+
460
+ Drop `<NiceShowcase />` into any React app to get a full interactive component library showcase with live demos, About page, theme designer, and configurator:
461
+
462
+ ```tsx
463
+ import { NiceShowcase } from '@nice2dev/ui';
464
+ import '@nice2dev/ui/style.css';
465
+
466
+ function DocsPage() {
467
+ return <NiceShowcase defaultTab="about" version="1.0.0" />;
468
+ }
469
+ ```
470
+
471
+ Props:
472
+ - `defaultTab` — initial tab (`'about'`, `'dashboard'`, `'forms'`, `'controls'`, etc.)
473
+ - `showAbout` — show/hide the About & Installation tab (default: `true`)
474
+ - `tabs` — array of visible tabs (default: all)
475
+ - `packageName` — package name shown in install instructions (default: `'@nice2dev/ui'`)
476
+ - `version` — version shown in hero section
477
+ - `renderPage` — custom page renderer for overriding built-in pages
478
+
479
+ ---
480
+
481
+ ## Access Control
482
+
483
+ Built-in per-component access modes allow controlling visibility and interactivity globally or per-component:
484
+
485
+ ```tsx
486
+ import { NiceAccessControl, NiceTextInput, NiceButton } from '@nice2dev/ui';
487
+
488
+ // Provider-level permissions:
489
+ <NiceAccessControl
490
+ defaultMode="full"
491
+ permissions={{ 'salary-field': 'readOnly', 'delete-btn': 'hidden' }}
492
+ >
493
+ <NiceTextInput accessMode="full" label="Name" />
494
+ <NiceTextInput componentId="salary-field" label="Salary" />
495
+ <NiceButton componentId="delete-btn" variant="error">Delete</NiceButton>
496
+ </NiceAccessControl>
497
+ ```
498
+
499
+ Modes: `'full'` (default), `'readOnly'`, `'disabled'`, `'hidden'`
500
+
501
+ ---
502
+
503
+ ## Theming
504
+
505
+ ### CSS Custom Properties
506
+
507
+ The entire design system is driven by CSS custom properties. Import the stylesheet and override variables to customize:
508
+
509
+ ```tsx
510
+ import '@nice2dev/ui/style.css';
511
+ ```
512
+
513
+ #### Available Variables
514
+
515
+ ```css
516
+ :root {
517
+ /* Colors */
518
+ --color-primary: #3b82f6;
519
+ --color-primary-hover: #2563eb;
520
+ --color-success: #10b981;
521
+ --color-warning: #f59e0b;
522
+ --color-error: #ef4444;
523
+ --color-info: #06b6d4;
524
+
525
+ /* Backgrounds */
526
+ --bg-primary: #ffffff;
527
+ --bg-secondary: #f8fafc;
528
+ --bg-tertiary: #f1f5f9;
529
+
530
+ /* Text */
531
+ --text-primary: #0f172a;
532
+ --text-secondary: #475569;
533
+ --text-muted: #94a3b8;
534
+
535
+ /* Borders & Interactions */
536
+ --border-color: #e2e8f0;
537
+ --hover-bg: #f1f5f9;
538
+
539
+ /* Shadows */
540
+ --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
541
+ --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
542
+ --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
543
+ --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
544
+ }
545
+ ```
546
+
547
+ ### Dark Mode
548
+
549
+ Dark mode is supported in three ways:
550
+
551
+ 1. **Automatic** — Follows `prefers-color-scheme: dark` media query by default
552
+ 2. **Class-based** — Add `nice-dark` class to any ancestor element
553
+ 3. **Attribute-based** — Set `data-theme="dark"` on any ancestor element
554
+
555
+ ```html
556
+ <!-- Auto: follows OS preference (default behavior, no extra code) -->
557
+
558
+ <!-- Manual toggle via class: -->
559
+ <body class="nice-dark">...</body>
560
+
561
+ <!-- Manual toggle via attribute: -->
562
+ <body data-theme="dark">...</body>
563
+
564
+ <!-- Opt-in light mode when OS is dark: -->
565
+ <body data-theme="light">...</body>
566
+ ```
567
+
568
+ ### Custom Themes
569
+
570
+ Create a custom theme by overriding CSS variables:
571
+
572
+ ```css
573
+ /* my-theme.css */
574
+ :root {
575
+ --color-primary: #8b5cf6; /* purple primary */
576
+ --color-primary-hover: #7c3aed;
577
+ --bg-primary: #faf5ff;
578
+ --border-color: #ddd6fe;
579
+ }
580
+ ```
581
+
582
+ ---
583
+
584
+ ## Build & Development
585
+
586
+ ### Prerequisites
587
+
588
+ - Node.js 18+
589
+ - npm 9+
590
+
591
+ ### Scripts
592
+
593
+ ```bash
594
+ npm run dev # Start Vite dev server with demo app
595
+ npm run build # Build library (tsc + vite)
596
+ npm run preview # Preview built library
597
+ ```
598
+
599
+ ### Build Output
600
+
601
+ | File | Format | Size | Purpose |
602
+ |------|--------|------|---------|
603
+ | `dist/index.mjs` | ESM | ~207 KB | Modern bundlers (Vite, webpack 5, Rollup) |
604
+ | `dist/index.cjs` | CJS | ~146 KB | Node.js, older bundlers |
605
+ | `dist/style.css` | CSS | ~79 KB | All component styles |
606
+ | `dist/index.d.ts` | TypeScript | — | Type definitions |
607
+
608
+ ### Build Configuration
609
+
610
+ - **Bundler:** Vite 5 with `@vitejs/plugin-react`
611
+ - **Types:** `vite-plugin-dts` with `rollupTypes: true` (single `.d.ts` bundle)
612
+ - **Target:** ES2020
613
+ - **External:** `react`, `react-dom`, `react/jsx-runtime`
614
+ - **CSS:** Single file output (`cssCodeSplit: false`)
615
+ - **TypeScript:** Strict mode, declaration maps, source maps
616
+
617
+ ### Project Structure
618
+
619
+ ```
620
+ nice2dev-ui/
621
+ ├── src/
622
+ │ ├── core/ # Types, hooks, i18n, icon system
623
+ │ │ ├── types.ts # NiceSize, NiceVariant, NiceBaseProps, etc.
624
+ │ │ ├── hooks.ts # useControlId, useDebouncedValue, useClickOutside, useFocusTrap
625
+ │ │ ├── i18n.tsx # NiceI18nProvider, useNiceTranslation
626
+ │ │ └── icons.tsx # 78 built-in SVG icons, NiceIcon, NiceIconProvider
627
+ │ ├── styles/
628
+ │ │ ├── controls.css # Base design system (CSS custom properties)
629
+ │ │ └── controls-extended.css # Extended component styles
630
+ │ ├── editors/ # 18 form input components
631
+ │ ├── buttons/ # NiceButton, NiceButtonGroup, NiceDropDownButton, etc.
632
+ │ ├── display/ # NiceBadge, NiceTag, NiceAvatar, NiceProgress, etc.
633
+ │ ├── feedback/ # NiceAlert, NiceModal, NiceDrawer, NiceToastContainer
634
+ │ ├── navigation/ # NiceTabs, NiceAccordion, NiceMenu, NiceSplitter, etc.
635
+ │ ├── data/ # NiceTable, NiceDataGrid, NiceTreeView, NicePivotGrid, etc.
636
+ │ ├── charts/ # NiceChart, NicePieChart, gauges, sparklines, maps
637
+ │ ├── overlays/ # NicePopover, NiceActionSheet, NiceResizable, etc.
638
+ │ ├── planning/ # NiceScheduler, NiceGantt, NiceDiagram, NiceStepper
639
+ │ ├── tools/ # NiceChat, NiceFileUploader, NiceFilterBuilder, etc.
640
+ │ └── index.ts # Main barrel export
641
+ ├── demo/
642
+ │ └── Demo.tsx # Comprehensive component demo application
643
+ ├── package.json
644
+ ├── vite.config.ts
645
+ ├── tsconfig.json
646
+ └── tsconfig.build.json
647
+ ```
648
+
649
+ ---
650
+
651
+ ## Architecture
652
+
653
+ ### Design Principles
654
+
655
+ 1. **Zero dependencies** — The library depends only on React. No lodash, no date-fns, no external CSS frameworks.
656
+ 2. **Consistent API** — All form components extend `NiceFormFieldProps` for uniform `label`, `error`, `disabled`, `size`, etc.
657
+ 3. **Composable** — Components are designed to work together. `NiceIcon` can be used inside `NiceButton`, `NiceSelect` options, `NiceMenu` items, etc.
658
+ 4. **Themeable at every level** — CSS custom properties for global theming, `className`/`style` props for per-instance customization, `variant`/`size` props for semantic variations.
659
+ 5. **Progressive enhancement** — i18n and custom icons are opt-in. Everything works out of the box with sensible defaults.
660
+
661
+ ### Provider Stack (optional)
662
+
663
+ ```tsx
664
+ import { NiceI18nProvider, NiceIconProvider } from '@nice2dev/ui';
665
+ import { NiceFaIconProvider } from '@nice2dev/icons'; // optional
666
+
667
+ // Full provider stack:
668
+ <NiceI18nProvider t={myTranslationFunction}>
669
+ <NiceFaIconProvider> {/* or <NiceIconProvider resolver={...}> */}
670
+ <App />
671
+ </NiceFaIconProvider>
672
+ </NiceI18nProvider>
673
+
674
+ // Minimal (no providers needed):
675
+ <App />
676
+ ```
677
+
678
+ ---
679
+
680
+ ## Companion Package: @nice2dev/icons
681
+
682
+ **[@nice2dev/icons](../nice2dev-icons/README.md)** provides 300+ multi-color SVG icons with 4 rendering variants (solid, outline, duotone, flat), 65+ CSS animations, gradient fills, and a searchable icon picker component. Includes brand icons for NiceToDev and OmniVerk.
683
+
684
+ ```bash
685
+ npm install @nice2dev/icons
686
+ ```
687
+
688
+ ```tsx
689
+ import { NtdHome, NtdSearch, NtdHeart } from '@nice2dev/icons';
690
+
691
+ <NtdHome size="lg" primaryColor="#3b82f6" />
692
+ <NtdSearch animation="pulse" />
693
+ <NtdHeart variant="duotone" gradient="sunset" />
694
+ ```
695
+
696
+ See the [@nice2dev/icons README](../nice2dev-icons/README.md) for full documentation.
697
+
698
+ ---
699
+
700
+ ## License
701
+
702
+ MIT © NiceToDev