@nice2dev/ui-core 1.0.28 → 1.0.30
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 +159 -0
- package/dist/core/hooks.d.ts +12 -0
- package/dist/core/hooks.d.ts.map +1 -1
- package/dist/core/i18nDictionaries.d.ts.map +1 -1
- package/dist/core/icons.d.ts +1 -1
- package/dist/core/icons.d.ts.map +1 -1
- package/dist/core/spatialNav.d.ts +75 -0
- package/dist/core/spatialNav.d.ts.map +1 -0
- package/dist/core/useGamepad.d.ts +70 -0
- package/dist/core/useGamepad.d.ts.map +1 -0
- package/dist/core/useThemeIsDark.d.ts +15 -8
- package/dist/core/useThemeIsDark.d.ts.map +1 -1
- package/dist/index.cjs +21 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +3490 -2903
- package/dist/index.mjs.map +1 -1
- package/dist/viewSchema.d.ts +2 -2
- package/dist/viewSchema.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,154 @@
|
|
|
1
1
|
# @nice2dev/ui-core — Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2f9e5d4: Showcase-feedback round 10 (editors state/props + bugs + datetime consolidation):
|
|
8
|
+
- NiceCheckbox: tri-state `indeterminate` now reaches all three states; expose
|
|
9
|
+
readOnly/loading/labelPlacement/errorPlacement in the props panel.
|
|
10
|
+
- NiceToggle/NiceRating: expose readOnly/loading/error/placement props; Rating
|
|
11
|
+
`loading` now replaces the stars with a spinner.
|
|
12
|
+
- NiceRadioGroup / NiceTagBox: implement `readOnly` (was ignored).
|
|
13
|
+
- NiceNumberInput: value stays right-aligned on blur; new `suffixSeparator` prop
|
|
14
|
+
(default false) gating the value↔suffix divider.
|
|
15
|
+
- NiceDatePicker: datetime shows a dot separator instead of the ISO `T` (emitted
|
|
16
|
+
value keeps `T`); datetime mode gains `showSeconds`, `minuteStep`, `showNow`,
|
|
17
|
+
and `hourFormat` (native picker) — ported from the now-removed
|
|
18
|
+
NiceDateTimePicker.
|
|
19
|
+
- NiceTimePicker: honor the `placeholder` prop.
|
|
20
|
+
- NiceSlider: more spacing around a left-placed label.
|
|
21
|
+
|
|
22
|
+
Removed **NiceDateTimePicker** (breaking): its datetime capability is covered by
|
|
23
|
+
NiceDatePicker's datetime mode; NiceForm, ui-forms `formUtils`, and ui-core
|
|
24
|
+
`adapters` now resolve datetime fields to NiceDatePicker.
|
|
25
|
+
|
|
26
|
+
- 7771af3: Round-13 showcase-feedback fixes across ~23 controls.
|
|
27
|
+
|
|
28
|
+
**Behaviour / bug fixes**
|
|
29
|
+
- **NiceUpload** — restored the dropzone look (icon + themed box + hover tint;
|
|
30
|
+
`variant` now defaults to `"dropzone"`).
|
|
31
|
+
- **NiceCard** — `selected` now shows a ring (drawn on a `::after` pseudo-element
|
|
32
|
+
so the display-style inline chrome can't override it).
|
|
33
|
+
- **NiceMenu** — the active-item highlight fills the bar; `separated` (default)
|
|
34
|
+
gained a subtle toolbar surface.
|
|
35
|
+
- **NiceLookup** — implemented `disabled` (gray-out), `readOnly` (inert),
|
|
36
|
+
`loading` (spinner), and `labelPlacement` / `errorPlacement`.
|
|
37
|
+
- **NiceColorPicker** — the palette popup follows the theme instead of always
|
|
38
|
+
rendering light; hex input honours `withAlpha`; `withAlpha`/`compact` are now
|
|
39
|
+
documented. **`showInput` and `showRandom` now default to `false`** (was `true`).
|
|
40
|
+
- **NiceSignature** — theme-aware canvas (empty `penColor`/`backgroundColor`
|
|
41
|
+
resolve to the theme's text/background), plus a `label` prop and an
|
|
42
|
+
`onChangeDataUrl` callback ported from the removed NiceSignaturePad.
|
|
43
|
+
- **NiceSegmentedControl** — the active thumb is hidden while `loading`.
|
|
44
|
+
- **NiceAutocomplete** — multiple-mode selections render as separate bordered
|
|
45
|
+
chips with per-chip remove; the clear button matches the other controls.
|
|
46
|
+
- **NiceCalendar** — `multiple` works (uncontrolled fallback); `min`/`max` only
|
|
47
|
+
apply to complete ISO dates.
|
|
48
|
+
- **NiceDateRangeBox** — horizontal layout stays on one line; `labelPlacement`
|
|
49
|
+
works inline.
|
|
50
|
+
- **NicePickList** — drag-reorder works in both columns with insert-position
|
|
51
|
+
indicators. **When `sortable` is off (the default), both lists now auto-sort
|
|
52
|
+
alphabetically** (display-only; consumer arrays keep their order).
|
|
53
|
+
- **NiceColorPalette** — the hue ring supports press-and-drag.
|
|
54
|
+
- **NiceVirtualScroller** — `itemHeight`/`height` are honoured, and it gained
|
|
55
|
+
`size` + `disabled`/`loading`/`error` states.
|
|
56
|
+
- **NiceBusinessCard** — `variant` (card/inline/compact) and `showLogo` (with a
|
|
57
|
+
fallback avatar) now render.
|
|
58
|
+
|
|
59
|
+
**Breaking (patch, pre-1.2.0 convention)**
|
|
60
|
+
- **NiceSignaturePad is removed** — it duplicated **NiceSignature**. Its `label`
|
|
61
|
+
and data-URL value model were ported (`label`, `onChangeDataUrl`). Migrate to
|
|
62
|
+
`NiceSignature`; for a data-URL value use `onChangeDataUrl` or the imperative
|
|
63
|
+
`ref.toDataURL()`. (The separate touch-optimised `@nice2dev/ui-mobile`
|
|
64
|
+
`NiceSignaturePad` is unaffected.)
|
|
65
|
+
|
|
66
|
+
- da12dfb: Round-17 showcase-feedback fixes (6 select/editor controls).
|
|
67
|
+
- **Select-dropdown standardization** — the menus of NiceSelect / NiceAutocomplete /
|
|
68
|
+
NiceLookup / NiceTreeSelect / NiceDropDownBox now abut the input (new
|
|
69
|
+
`--nice-dropdown-gap`, default `0px`, replacing a hardcoded 4px). NiceAutocomplete /
|
|
70
|
+
NiceLookup / NiceTreeSelect gain an optional `menuGap` prop. NiceDropDownBox's menu
|
|
71
|
+
gains the standard border (its `.nice-dropdown` had no CSS), and its clear `×` moved
|
|
72
|
+
inside the trigger (it was rendering below the control). NiceTreeSelect option rows
|
|
73
|
+
get more left padding.
|
|
74
|
+
- **NiceDateTimePicker** — the time-spinner ▲/▼ buttons now support press-and-hold
|
|
75
|
+
auto-repeat (new shared `useHoldRepeat` hook in `@nice2dev/ui-core`). (The 24-hour
|
|
76
|
+
default was a demo-seed issue, fixed in the showcase.)
|
|
77
|
+
- **NiceLookup** — `readOnly` no longer changes the control height (the chevron slot is
|
|
78
|
+
kept), and `errorPlacement="right"` no longer widens the field when there's no error.
|
|
79
|
+
- **NiceCardGroup** — new `readOnly` (blocks selection without dimming) and `errorText`
|
|
80
|
+
props; `size` now scales the child cards (they inherit the group size via context),
|
|
81
|
+
not just the grid gap.
|
|
82
|
+
|
|
83
|
+
- bea5451: Round-18 showcase-feedback fixes (12 editor controls).
|
|
84
|
+
- **Select family** — NiceTreeSelect now has a stable trigger width (min-width like
|
|
85
|
+
NiceLookup, no longer tracking the value), its dropdown Search reuses the shared
|
|
86
|
+
`.nice-select__search` (left padding + normal vertical padding), and the empty state
|
|
87
|
+
gets padding. NiceAutocomplete inserts the option's DisplayName (label) on select
|
|
88
|
+
instead of the raw lowercase `value`. NiceLookup's `errorPlacement='right'` error is
|
|
89
|
+
absolutely positioned so it no longer widens the control.
|
|
90
|
+
- **NiceRangeSlider** — for `valuePlacement` right/bottom the value moves to a header
|
|
91
|
+
row above the track (mirroring NiceSlider) so it no longer overlaps the slider.
|
|
92
|
+
- **NiceDateRangeBox** — a stable `min-width` keeps disabled/readOnly from narrowing the
|
|
93
|
+
control; the loading spinner and `errorPlacement='right'` error align to the input row.
|
|
94
|
+
- **NiceDateTimePicker** — the time popup is now a slot-machine of vertical scroll-snap
|
|
95
|
+
columns for hours/minutes (animated, fade-masked); the ▲/▼ buttons keep hold-to-repeat
|
|
96
|
+
and typing a digit overwrites (INSERT).
|
|
97
|
+
- **NiceSkeleton** — new `animationSpeed` prop (seconds, default 1.8 ≈ 20% slower);
|
|
98
|
+
numeric-string `width`/`height` are coerced to px so both props apply.
|
|
99
|
+
- **NiceUpload** — new `labelPlacement` prop (`'right'` default | `'bottom'`): the text
|
|
100
|
+
sits beside the icon by default, below it when set.
|
|
101
|
+
- **NiceSignature** — the placeholder is translated (`signature.placeholder`, added to
|
|
102
|
+
the ui-core + i18n dictionaries for en/pl/de/fr/es/uk); the demo drops its synthetic
|
|
103
|
+
label + generic placeholder and the signature line is raised.
|
|
104
|
+
- **NiceColorPalette** — the collapsed field is a compact multi-colour strip at
|
|
105
|
+
NiceColorPicker's 32px height (chevron removed); the studio popup is split into
|
|
106
|
+
NiceTabs (Colors / Presets / Variations / Info / Schemes) and the swatch "kredki" are
|
|
107
|
+
reshaped into compact bars (chip + hex + remove ×) to the right of the wheel.
|
|
108
|
+
- **NiceGradientPicker** — redesigned to mirror NiceColorPicker/Palette: a compact 32×32
|
|
109
|
+
swatch field opens a portaled popup with NiceTabs (Editor / Presets / CSS); the
|
|
110
|
+
`NiceGradientValue`/`onChange` API and exported helpers are preserved.
|
|
111
|
+
|
|
112
|
+
- 783d0db: fix(controls): showcase-feedback round 3 — core controls, deeply honed
|
|
113
|
+
- **NiceButton**: icon-only is a properly padded square (symmetric padding per size), `fullWidth` stretches to 100% width with normal height (no giant square), and the loading spinner no longer collapses the box (the icon is kept in flow, hidden).
|
|
114
|
+
- **NiceDropDownButton**: the portaled menu now carries the trigger's theme (fixes white-on-white rows in scoped themes) and hover/selected set both background and colour; `readOnly` is now visually distinct from `disabled` (own class, not greyed) while still blocking the menu.
|
|
115
|
+
- **NiceSegmentedControl**: the active thumb now fills the selected segment exactly (removed a double-counted container inset that left a gap).
|
|
116
|
+
- **NiceBadge**: `size` now scales width + font too (the display style no longer pins `fontSize`/`padding` inline, so the size class governs).
|
|
117
|
+
- **NiceCarousel**: slide switching / autoPlay / circular work again (no longer frozen by a bare controlled `activeIndex`), `size` has real rules (arrow size + viewport height), and a new `fullWidth` prop (default `true`) toggles fill-vs-content width.
|
|
118
|
+
- **NicePDFViewer**: shows `1 / 1` and `100%` and stays interactive (non-positive controlled `page`/`zoom` are ignored); print converts a `data:` URI to a Blob URL so the tab actually prints.
|
|
119
|
+
- **NiceQRCode / NiceBarcodeGenerator**: the default module/bar colour follows the element's own theme surface (dark → light, light → dark) via a ref-aware `useThemeIsDark`; empty `color`/`background` are guarded.
|
|
120
|
+
- **NiceTooltip**: new `position: 'auto'` (now the default) picks the on-screen side with the most room (collision detection).
|
|
121
|
+
- **NiceFAQ**: items collapse regardless of `animateExpand` (only the transition is gated on it).
|
|
122
|
+
- **NiceTimeline**: horizontal mode draws its connector line and centres the item text; the body line renders at ~70%.
|
|
123
|
+
- **NiceDivider**: the text variant fills its container so the flanking lines are visible.
|
|
124
|
+
- **NiceSkeleton**: grouped rows (`count > 1`) get a definite width so `text`/`rect` variants render and animate (not just `circle`).
|
|
125
|
+
|
|
126
|
+
`useThemeIsDark` now accepts an optional element ref and resolves against that element's nearest theme scope (backwards-compatible: no-arg still observes `<html>`).
|
|
127
|
+
|
|
128
|
+
- 9816474: fix(controls): showcase-feedback round 6 — data + nav controls (8 items)
|
|
129
|
+
- **NiceTabs**: `vertical` now lays out as a sidebar (tab list left, content right) instead of stacking, and the panel keeps a stable size so switching tabs doesn't make the control jump.
|
|
130
|
+
- **NiceTable**: sort icons match NiceDataGrid — a neutral double-chevron when idle, a single up/down chevron for asc/desc, muted (new `sort` NiceIcon).
|
|
131
|
+
- **NiceDataGrid**: the aggregate summary is pinned directly above the pagination (no more jump on page change — it's no longer a sticky `<tfoot>`); the Filter button is now a proper `nice-btn` with a filter icon; toolbar placeholder glyphs (`?`/`??`) replaced with NiceIcons.
|
|
132
|
+
- **NiceList**: `size` now scales row density/font; `disabled`/`readOnly`/`error` states work; the loading spinner is centered and hides the search bar; new optional `header` prop that stays visible during loading.
|
|
133
|
+
- **NiceMenu**: bar-variant (separated/ghost/borderless) item highlight fills the item box edge-to-edge (no gap frame, no rounded-pill shrink; rounding only on the bar's outer corners).
|
|
134
|
+
- **NiceContextMenu**: item highlight fills each row (removed the container top/bottom padding and added `overflow:hidden`, so no top gap, no side overflow, corners clipped to the container).
|
|
135
|
+
|
|
136
|
+
Plus demo polish: NiceCardView cards now have a coloured header, status badge and footer actions; the NiceSpeedDialAction demo drops its bounded container (just the button).
|
|
137
|
+
|
|
138
|
+
## 1.0.29
|
|
139
|
+
|
|
140
|
+
### Patch Changes
|
|
141
|
+
|
|
142
|
+
- Library-wide consistency pass + showcase overhaul.
|
|
143
|
+
- **Universal app shell:** every genuine multi-panel editor/studio/designer/builder/workspace standardized onto `NiceAppShell` (slots + `flush`), incl. `NiceTeamsWorkspace` and `NiceAPIDesigner`. No public API changes — internal layout only.
|
|
144
|
+
- **Icons:** foreign icons (emoji, raw unicode glyphs, inline `<svg>`, FontAwesome) replaced with `@nice2dev/icons` / `NiceIcon` built-ins across the packages; ~110 built-in icon paths added to `NiceIcon`.
|
|
145
|
+
- **Control sizing:** every basic control now honours the full `xs · sm · md · lg · xl` size scale with working CSS — fixed `NiceCard`, `NiceAlert`, `NiceSkeleton`, `NiceDivider`, `NiceSearchInput`, `NiceCallout`, `NiceStatistic`, `NiceSegmentedControl`, `NiceCheckbox`, `NiceParagraph`, and a `NiceSpinner` CSS-shadow regression (`md` baseline unchanged). `NiceNumericInput` gained a `size` prop.
|
|
146
|
+
- **NiceKioskShell:** the `style` prop now overrides the default full-screen `position: fixed` (so it can be embedded contained).
|
|
147
|
+
- **Input devices + spatial navigation:** `NiceGamepad` / `NiceMicrophone` / `NiceDeviceManager` / `NiceDeviceTile` and `NavShell` spatial-navigation support.
|
|
148
|
+
- **Audio:** AudioVerse → `@nice2dev/ui-audio` parity (15 controls; optional `recharts` visualizers).
|
|
149
|
+
- **Display atoms + forms:** standardized atoms (`NiceBadge`/`NiceTag`/`NiceAvatarGroup`/`NiceProgress`/…), removed the deprecated `NiceStatusBadge` (migrated to `NiceBadge` variants), entity validation builder, selectable `NiceCard`.
|
|
150
|
+
- **Editors inside satellites** (`ui-ai`/`ui-api`/`ui-bi`/`ui-math`/`ui-video`/`ui-audio`/`events`) now declare `@nice2dev/ui` (and where used `@nice2dev/icons` / `@nice2dev/ui-core`) as peer dependencies.
|
|
151
|
+
|
|
3
152
|
All notable changes to the cross-framework core package.
|
|
4
153
|
|
|
5
154
|
## [0.2.0] — 2026-03-25
|
|
@@ -9,14 +158,17 @@ All notable changes to the cross-framework core package.
|
|
|
9
158
|
Framework-agnostic TypeScript contracts, state machines, validation utilities, and behavior logic for all major UI component categories. These are consumed by Angular/Vue/Web Component/Blazor adapters.
|
|
10
159
|
|
|
11
160
|
#### Shared
|
|
161
|
+
|
|
12
162
|
- `ComponentBaseProps`, `ComponentEvent`, `createComponentEvent`
|
|
13
163
|
- Types: `ComponentSize`, `ComponentVariant`, `ComponentDensity`, `Orientation`, `Placement`, `Alignment`
|
|
14
164
|
|
|
15
165
|
#### Buttons
|
|
166
|
+
|
|
16
167
|
- Contracts: `ButtonProps`, `ButtonGroupProps`, `DropDownButtonProps`, `IconButtonProps`, `SpeedDialProps`
|
|
17
168
|
- Types: `ButtonType`, `ButtonStyle`, `DropDownItem`, `SpeedDialAction`
|
|
18
169
|
|
|
19
170
|
#### Form Controls
|
|
171
|
+
|
|
20
172
|
- `FormFieldProps`, `ValidationRule`, `ValidationResult` + `validateField()` (pure validation, no framework deps)
|
|
21
173
|
- `TextInputProps` (type, mask, prefix/suffix, maxLength)
|
|
22
174
|
- `NumberInputProps` + `clampNumber()` (min/max/precision clamping)
|
|
@@ -26,30 +178,37 @@ Framework-agnostic TypeScript contracts, state machines, validation utilities, a
|
|
|
26
178
|
- `TextAreaProps`, `AutocompleteProps`, `ColorPickerProps`, `FileUploadProps`
|
|
27
179
|
|
|
28
180
|
#### Data Display
|
|
181
|
+
|
|
29
182
|
- `DataGridProps`, `ColumnDef`, `SortState`, `FilterState` + `multiSort()`, `applyFilters()`, `paginate()`
|
|
30
183
|
- `BadgeProps`, `ProgressProps`, `AvatarProps` + `getInitials()`
|
|
31
184
|
|
|
32
185
|
#### Navigation
|
|
186
|
+
|
|
33
187
|
- `TabsProps`, `TabItem` + `createTabsState()` (state machine with getActive/setActive/getNext/getPrev)
|
|
34
188
|
- `BreadcrumbProps`, `BreadcrumbItem` + `collapseBreadcrumb()` (keeps first + last N items)
|
|
35
189
|
- `AccordionProps`, `AccordionItem` + `toggleAccordion()` (single/multiple mode logic)
|
|
36
190
|
- `MenuProps`, `MenuItem`, `DrawerProps`
|
|
37
191
|
|
|
38
192
|
#### Overlays & Feedback
|
|
193
|
+
|
|
39
194
|
- `ModalProps`, `AlertProps`, `ToastConfig` + `ToastManager` class (queue, subscribe, dismiss, auto-expire)
|
|
40
195
|
- `PopoverProps`, `TooltipProps`
|
|
41
196
|
|
|
42
197
|
#### Charts
|
|
198
|
+
|
|
43
199
|
- `ChartProps`, `ChartSeries`, `ChartAxis`, `ChartLegend` (17 chart types)
|
|
44
200
|
|
|
45
201
|
#### Planning
|
|
202
|
+
|
|
46
203
|
- `SchedulerProps`, `SchedulerEvent`, `SchedulerResource` (day/week/month/timeline/agenda views)
|
|
47
204
|
- `GanttProps`, `GanttTask` (with dependencies, milestones, progress)
|
|
48
205
|
|
|
49
206
|
#### Tree View
|
|
207
|
+
|
|
50
208
|
- `TreeViewProps`, `TreeNode` + `flattenTree()` (for virtual scrolling), `searchTree()` (match with paths)
|
|
51
209
|
|
|
52
210
|
#### Layout
|
|
211
|
+
|
|
53
212
|
- `SplitterProps`, `SplitterPane` + `calculatePaneSizes()` (constrained resize logic)
|
|
54
213
|
|
|
55
214
|
---
|
package/dist/core/hooks.d.ts
CHANGED
|
@@ -19,6 +19,18 @@ export declare function useLongPress(callback: () => void, holdMs?: number): {
|
|
|
19
19
|
onPointerUp: () => void;
|
|
20
20
|
onPointerCancel: () => void;
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Press-and-hold auto-repeat for stepper buttons. `start(action)` repeats `action`
|
|
24
|
+
* at an accelerating rate while held (first repeat after 400ms, then speeding up to
|
|
25
|
+
* ~30ms); `stop()` ends it. Keep the button's own `onClick` for a single tap and
|
|
26
|
+
* wire `start`/`stop` to `onPointerDown` / `onPointerUp` + `onPointerLeave` (works
|
|
27
|
+
* for mouse, touch and pen). Used by NiceNumberInput and NiceDateTimePicker's time
|
|
28
|
+
* spinners.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useHoldRepeat(): {
|
|
31
|
+
start: (action: () => void) => void;
|
|
32
|
+
stop: () => void;
|
|
33
|
+
};
|
|
22
34
|
/**
|
|
23
35
|
* Returns a stable unique HTML id. Passes through `externalId` when provided,
|
|
24
36
|
* otherwise generates one via React's `useId()`.
|
package/dist/core/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/core/hooks.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAY1C;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,OAAO,GAAG,OAAO,CAqBhD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,IAAI,EACpB,MAAM,SAAM,GACX;IACD,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC;IAC/C,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B,CAmBA;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAOjE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,IAAI,QAe5F;AAED;;;;;;GAMG;AACH,wBAA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ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,+IAuBvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"i18nDictionaries.d.ts","sourceRoot":"","sources":["../../src/core/i18nDictionaries.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,+IAuBvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAu6KtE,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuBpF,CAAC"}
|
package/dist/core/icons.d.ts
CHANGED
|
@@ -40,6 +40,6 @@ export declare const NiceIcon: React.FC<NiceIconProps>;
|
|
|
40
40
|
export declare function useNiceIcon(): {
|
|
41
41
|
renderIcon: (icon: React.ReactNode | string | undefined, size?: NiceIconSize | number) => React.ReactNode;
|
|
42
42
|
};
|
|
43
|
-
/** Array of all
|
|
43
|
+
/** Array of all built-in icon names available without a custom resolver. */
|
|
44
44
|
export declare const NICE_BUILTIN_ICONS: string[];
|
|
45
45
|
//# sourceMappingURL=icons.d.ts.map
|
package/dist/core/icons.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/core/icons.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/core/icons.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAuNtE,yFAAyF;AACzF,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAU5D,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;AAW3F,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACpC,8DAA8D;IAC9D,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAE5D,CAAC;AAiDF;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA0C5C,CAAC;AAKF;;;GAGG;AACH,wBAAgB,WAAW;uBAKf,KAAK,CAAC,SAAS,GAAG,MAAM,GAAG,SAAS,SACpC,YAAY,GAAG,MAAM,KAC1B,KAAK,CAAC,SAAS;EAarB;AAED,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,UAA6B,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spatial navigation — controller + arrow-key directional focus for UI controls.
|
|
3
|
+
*
|
|
4
|
+
* Headless mechanism (lives in ui-core so any package can use it): a provider
|
|
5
|
+
* tracks registered focusable elements and moves focus by direction using a
|
|
6
|
+
* dot-product gate + nearest-by-distance heuristic. Inputs: keyboard arrows
|
|
7
|
+
* (+ Enter to activate, Escape to dismiss a focus trap) and a gamepad d-pad /
|
|
8
|
+
* left-stick (A = activate, B = dismiss trap) via {@link useGamepad}.
|
|
9
|
+
*
|
|
10
|
+
* Wrap a subtree in `NiceSpatialNavProvider`; register controls with
|
|
11
|
+
* `useSpatialFocusable(ref, { id })` or the `<NiceFocusable>` wrapper.
|
|
12
|
+
*/
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import type { NiceBaseProps } from './types';
|
|
15
|
+
export interface SpatialFocusableMeta {
|
|
16
|
+
id: string;
|
|
17
|
+
ref: React.RefObject<HTMLElement | null>;
|
|
18
|
+
onActivate?: () => void;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface NiceSpatialNavContextValue {
|
|
22
|
+
register: (meta: SpatialFocusableMeta) => void;
|
|
23
|
+
unregister: (id: string) => void;
|
|
24
|
+
/** Move focus in a direction (dx,dy ∈ {-1,0,1}). */
|
|
25
|
+
moveFocus: (dx: number, dy: number) => void;
|
|
26
|
+
/** Activate the active (or given) focusable. */
|
|
27
|
+
activate: (id?: string) => void;
|
|
28
|
+
setActive: (id: string) => void;
|
|
29
|
+
activeId: string | null;
|
|
30
|
+
focusables: SpatialFocusableMeta[];
|
|
31
|
+
/** Constrain navigation to ids starting with `prefix` (modal/menu scope). */
|
|
32
|
+
pushFocusTrap: (prefix: string, onDismiss?: () => void) => void;
|
|
33
|
+
popFocusTrap: () => void;
|
|
34
|
+
/** Ref-counted lock that suspends navigation (e.g. while a slider is open). */
|
|
35
|
+
pauseNavigation: () => void;
|
|
36
|
+
resumeNavigation: () => void;
|
|
37
|
+
}
|
|
38
|
+
export interface NiceSpatialNavProviderProps extends NiceBaseProps {
|
|
39
|
+
/** Handle keyboard arrow keys (default true). */
|
|
40
|
+
keyboard?: boolean;
|
|
41
|
+
/** Poll a gamepad for navigation (default true). */
|
|
42
|
+
gamepad?: boolean;
|
|
43
|
+
/** Gamepad index forwarded to useGamepad (default 0). */
|
|
44
|
+
gamepadIndex?: number;
|
|
45
|
+
children: React.ReactNode;
|
|
46
|
+
}
|
|
47
|
+
export declare const NiceSpatialNavProvider: React.FC<NiceSpatialNavProviderProps>;
|
|
48
|
+
/** Access the spatial-nav context. Returns `null` outside a provider. */
|
|
49
|
+
export declare function useSpatialNavOptional(): NiceSpatialNavContextValue | null;
|
|
50
|
+
/** Access the spatial-nav context. Throws outside a provider. */
|
|
51
|
+
export declare function useSpatialNav(): NiceSpatialNavContextValue;
|
|
52
|
+
export interface UseSpatialFocusableOptions {
|
|
53
|
+
id: string;
|
|
54
|
+
onActivate?: () => void;
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Register `ref`'s element as a spatial-nav focusable. No-op (returns
|
|
59
|
+
* `{ active: false }`) when used outside a provider. Sets `data-active` on the
|
|
60
|
+
* element while it is the active focusable.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useSpatialFocusable(ref: React.RefObject<HTMLElement | null>, opts: UseSpatialFocusableOptions): {
|
|
63
|
+
active: boolean;
|
|
64
|
+
};
|
|
65
|
+
export interface NiceFocusableProps extends NiceBaseProps {
|
|
66
|
+
/** Unique id within the provider (prefix it to scope to a focus trap). */
|
|
67
|
+
focusId: string;
|
|
68
|
+
onActivate?: () => void;
|
|
69
|
+
disabled?: boolean;
|
|
70
|
+
as?: React.ElementType;
|
|
71
|
+
children: React.ReactNode;
|
|
72
|
+
}
|
|
73
|
+
/** Thin wrapper that registers its element with the spatial-nav provider. */
|
|
74
|
+
export declare const NiceFocusable: React.FC<NiceFocusableProps>;
|
|
75
|
+
//# sourceMappingURL=spatialNav.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spatialNav.d.ts","sourceRoot":"","sources":["../../src/core/spatialNav.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAQN,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,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sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CA+QxE,CAAC;AAIF,yEAAyE;AACzE,wBAAgB,qBAAqB,IAAI,0BAA0B,GAAG,IAAI,CAEzE;AAED,iEAAiE;AACjE,wBAAgB,aAAa,IAAI,0BAA0B,CAM1D;AAED,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACxC,IAAI,EAAE,0BAA0B,GAC/B;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CA8CrB;AAID,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,6EAA6E;AAC7E,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAwBtD,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useGamepad — headless hook for gamepad/controller support.
|
|
3
|
+
*
|
|
4
|
+
* Supports Xbox, PlayStation and generic controllers via the standard Gamepad
|
|
5
|
+
* API: button mapping, axis input with deadzone, rumble, action binding and
|
|
6
|
+
* rising/falling button-edge callbacks. This is the canonical, dependency-free
|
|
7
|
+
* implementation; `@nice2dev/ui-graphics` and `@nice2dev/game-engine` re-export
|
|
8
|
+
* it (and add their own game-specific UI on top).
|
|
9
|
+
*/
|
|
10
|
+
export type GamepadButton = 'A' | 'B' | 'X' | 'Y' | 'LB' | 'RB' | 'LT' | 'RT' | 'Back' | 'Start' | 'LS' | 'RS' | 'DpadUp' | 'DpadDown' | 'DpadLeft' | 'DpadRight' | 'Home';
|
|
11
|
+
export type GamepadAxis = 'LeftX' | 'LeftY' | 'RightX' | 'RightY';
|
|
12
|
+
export interface GamepadState {
|
|
13
|
+
connected: boolean;
|
|
14
|
+
id: string;
|
|
15
|
+
buttons: Record<GamepadButton, boolean>;
|
|
16
|
+
axes: Record<GamepadAxis, number>;
|
|
17
|
+
/** Trigger pressure (0-1). */
|
|
18
|
+
leftTrigger: number;
|
|
19
|
+
rightTrigger: number;
|
|
20
|
+
/** Trigger rumble on the underlying device (no-op if unsupported). */
|
|
21
|
+
vibrate: (duration: number, weakMagnitude?: number, strongMagnitude?: number) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface GamepadAction {
|
|
24
|
+
button?: GamepadButton;
|
|
25
|
+
buttons?: GamepadButton[];
|
|
26
|
+
axis?: GamepadAxis;
|
|
27
|
+
axisDirection?: 'positive' | 'negative';
|
|
28
|
+
trigger?: 'LT' | 'RT';
|
|
29
|
+
onPress?: () => void;
|
|
30
|
+
onRelease?: () => void;
|
|
31
|
+
onHold?: () => void;
|
|
32
|
+
onAxisChange?: (value: number) => void;
|
|
33
|
+
repeatDelay?: number;
|
|
34
|
+
repeatRate?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface UseGamepadOptions {
|
|
37
|
+
/** Gamepad index to use (default: 0). */
|
|
38
|
+
index?: number;
|
|
39
|
+
/** Deadzone for analog sticks (default: 0.15). */
|
|
40
|
+
deadzone?: number;
|
|
41
|
+
/** Polling rate in ms (default: 16 = ~60fps). */
|
|
42
|
+
pollRate?: number;
|
|
43
|
+
/** Action bindings. */
|
|
44
|
+
actions?: Record<string, GamepadAction>;
|
|
45
|
+
/** Enable/disable (default: true). */
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
/** Fired on the rising edge of any button (for live highlighting). */
|
|
48
|
+
onButtonDown?: (button: GamepadButton) => void;
|
|
49
|
+
/** Fired on the falling edge of any button. */
|
|
50
|
+
onButtonUp?: (button: GamepadButton) => void;
|
|
51
|
+
}
|
|
52
|
+
/** PlayStation button-name aliases → canonical (Xbox) button names. */
|
|
53
|
+
export declare const PS_BUTTON_ALIASES: Record<string, GamepadButton>;
|
|
54
|
+
/** All gamepad button names, in Gamepad-API index order. */
|
|
55
|
+
export declare const GAMEPAD_BUTTONS: GamepadButton[];
|
|
56
|
+
export declare function useGamepad(options?: UseGamepadOptions): GamepadState;
|
|
57
|
+
export interface NavigationActions {
|
|
58
|
+
onNavigateUp?: () => void;
|
|
59
|
+
onNavigateDown?: () => void;
|
|
60
|
+
onNavigateLeft?: () => void;
|
|
61
|
+
onNavigateRight?: () => void;
|
|
62
|
+
onConfirm?: () => void;
|
|
63
|
+
onCancel?: () => void;
|
|
64
|
+
onTabNext?: () => void;
|
|
65
|
+
onTabPrev?: () => void;
|
|
66
|
+
onMenu?: () => void;
|
|
67
|
+
}
|
|
68
|
+
/** Create a standard UI-navigation action map for {@link useGamepad}. */
|
|
69
|
+
export declare function createNavigationActions(handlers: NavigationActions): Record<string, GamepadAction>;
|
|
70
|
+
//# sourceMappingURL=useGamepad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGamepad.d.ts","sourceRoot":"","sources":["../../src/core/useGamepad.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,MAAM,aAAa,GACrB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,MAAM,GACN,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,QAAQ,GACR,UAAU,GACV,UAAU,GACV,WAAW,GACX,MAAM,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElE,MAAM,WAAW,YAA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ACtE,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,+CAA+C;IAC/C,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAC9C;AAgCD,uEAAuE;AACvE,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAc3D,CAAC;AAEF,4DAA4D;AAC5D,eAAO,MAAM,eAAe,EAAE,aAAa,EAA8B,CAAC;AAI1E,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,YAAY,CAqPxE;AA4BD,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,yEAAyE;AACzE,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,iBAAiB,GAC1B,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAsE/B"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* Live boolean indicating whether the active theme renders as "dark".
|
|
3
4
|
*
|
|
4
|
-
* Resolution order
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Resolution order (evaluated against the nearest theme scope of `ref`, or
|
|
6
|
+
* `<html>` when no ref is given):
|
|
7
|
+
* 1. `data-theme="dark|light"` on the nearest scoped ancestor (explicit wins)
|
|
8
|
+
* 2. `nice-dark` / `nice-light` (and bare `dark`) class on that scope
|
|
9
|
+
* 3. the element's own resolved `--text-primary` luminance (light text → dark)
|
|
8
10
|
* 4. `prefers-color-scheme: dark` media query as last-resort fallback
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* Pass a `ref` to a rendered element (e.g. a canvas) so the result reflects the
|
|
13
|
+
* element's **own** surface — `NiceThemeProvider` themes a scoped container, not
|
|
14
|
+
* `<html>`, so a canvas nested under a scoped provider must read its own scope,
|
|
15
|
+
* not the document root. Without a ref it observes `<html>` as before.
|
|
16
|
+
*
|
|
17
|
+
* Updates whenever the observed scope (or `<html>`) attributes/class/style or the
|
|
18
|
+
* media query change, so canvas-based renderers (QR, barcode, charts…) stay in
|
|
19
|
+
* sync without consumers wiring `useDarkMode`.
|
|
13
20
|
*/
|
|
14
|
-
export declare function useThemeIsDark(): boolean;
|
|
21
|
+
export declare function useThemeIsDark(ref?: RefObject<HTMLElement | null>): boolean;
|
|
15
22
|
//# sourceMappingURL=useThemeIsDark.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThemeIsDark.d.ts","sourceRoot":"","sources":["../../src/core/useThemeIsDark.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useThemeIsDark.d.ts","sourceRoot":"","sources":["../../src/core/useThemeIsDark.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,OAAO,CAoC3E"}
|