@dxtmisha/functional 1.15.2 → 1.15.5
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 +26 -0
- package/README.md +42 -21
- package/ai-description.md +29 -25
- package/ai-doc.md +36 -106
- package/ai-types.md +379 -392
- package/dist/classes/ref/GeoIntlRef.d.ts +7 -0
- package/dist/composables/ref/useGeoIntlRef.d.ts +7 -0
- package/dist/composables/ref/useLazyItemByMarginRef.d.ts +6 -4
- package/dist/composables/ref/useLazyRef.d.ts +1 -1
- package/dist/composables/ref/useMeta.d.ts +5 -5
- package/dist/composables/ref/useSearchRef.d.ts +2 -2
- package/dist/library.js +17 -18
- package/dist/types/searchTypes.d.ts +5 -1
- package/package.json +36 -11
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.15.5] - 2026-07-25
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **useSearchRef**: Supported reactive `Ref` and getter callbacks for the `columns` parameter via `SearchColumnsInput` (`SearchColumnsRef<T, K>`), dynamically updating search results when target columns change.
|
|
9
|
+
- **searchTypes**: Introduced `SearchColumnsRef` and `SearchColumnsInput` type definitions to support reactive column definitions.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- **GeoIntlRef & useGeoIntlRef**: Added JSDoc `@remarks` guidelines recommending the use of standard non-reactive `GeoIntl` from `@dxtmisha/functional-basic` when reactivity is not required.
|
|
13
|
+
- **package.json**: Updated package `description` and expanded `keywords` list to comprehensively cover composables, `executeUse` singletons, and reactive utilities. Fixed `homepage` and `repository.directory` paths.
|
|
14
|
+
- **README.md**: Updated documentation and Quick Start code examples to showcase `executeUseGlobal` state singletons and reactive composables while preserving original document layout and style.
|
|
15
|
+
|
|
16
|
+
## [1.15.4] - 2026-07-24
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- **useLazyItemByMarginRef**: Added explicit return type annotations (`ReturnType<typeof useLazyRef>`) for `getItemByMargin` and `LazyItemByMargin[]` for `getItems`.
|
|
20
|
+
- **useLazyRef**: Updated `getItem(element?: HTMLElement)` method signature to accept optional element references.
|
|
21
|
+
|
|
22
|
+
## [1.15.3] - 2026-07-14
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- **executeUse**: Refactored singleton lifecycle and cache management to use `ServerStorage` with key `__executeUse::${id}__` via a `storageKey` constant, replacing local closure variables and supporting clean instance removal.
|
|
26
|
+
- **useMeta**: Updated metadata initialization to reference `MetaStatic.getItem()` rather than using the class object itself.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- **Tests**: Fixed the mock setup in `useMeta.test.ts` to include the `getItem` method on the mocked `MetaStatic` class.
|
|
30
|
+
|
|
5
31
|
## [1.15.0] - 2026-07-02
|
|
6
32
|
|
|
7
33
|
### Added
|
package/README.md
CHANGED
|
@@ -4,25 +4,27 @@
|
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
|
|
7
|
-
`@dxtmisha/functional` is a library of utilities, base classes, and composables for complex web development in Vue 3. The package operates on the foundation of `@dxtmisha/functional-basic`, providing reactive wrappers and architectural solutions designed specifically for the Vue ecosystem (Composition API).
|
|
7
|
+
`@dxtmisha/functional` is a library of utilities, base classes, and composables for complex web development in Vue 3. The package operates on the foundation of `@dxtmisha/functional-basic`, providing reactive wrappers, state singletons, and architectural solutions designed specifically for the Vue ecosystem (Composition API).
|
|
8
8
|
|
|
9
9
|
## Why this library?
|
|
10
10
|
|
|
11
|
-
Every modern frontend application inevitably faces the same set of challenges: managing HTTP requests, localization, dates, cookies, caching, loading states, and side effects.
|
|
11
|
+
Every modern frontend application inevitably faces the same set of challenges: managing HTTP requests, state synchronization, localization, dates, cookies, caching, loading states, and side effects.
|
|
12
12
|
|
|
13
|
-
When developers solve these tasks locally within components, it often leads to code duplication, bloated `.vue` files,
|
|
13
|
+
When developers solve these tasks locally within components, it often leads to code duplication, bloated `.vue` files, memory leaks from forgotten subscriptions, and difficult-to-maintain state. `functional` solves this by moving business logic into ready-made reactive abstractions and state singletons (`executeUse`). You simply call the necessary composable or class, and under the hood, the library manages `ref` dependencies, monitors the Vue lifecycle, handles SSR hydration, and maintains strict TypeScript typing.
|
|
14
14
|
|
|
15
15
|
## What does it do?
|
|
16
16
|
|
|
17
|
-
For **network requests (API)** — a set of composables (`useApiGet`, `useApiPost`, `
|
|
17
|
+
For **network requests (API)** — a set of reactive composables (`useApiRef`, `useApiManagementRef`, `useApiGet`, `useApiPost`, `useApiPut`, `useApiDelete`) that encapsulate server interactions. They return a fully reactive object with loading states, errors, client-side search, schema validation, and fetched data. They intelligently handle response caching, SSR hydration, headers, and automatic cancellation of outdated requests.
|
|
18
18
|
|
|
19
|
-
For **
|
|
19
|
+
For **state management & singletons (`executeUse`)** — `executeUseLocal`, `executeUseGlobal`, and `executeUseProvide` factories that allow creating managed singleton state hooks. This decouples complex API and business logic completely from `.vue` components, ensuring unified state across component trees and preventing duplicate requests.
|
|
20
20
|
|
|
21
|
-
For **
|
|
21
|
+
For **browser state management** — convenient reactive hooks (`useStorageRef`, `useSessionRef`, `useCookieRef`, `useHashRef`, `useQueryRef`, `useBroadcastValueRef`) that seamlessly bind Vue variables to LocalStorage, SessionStorage, cookies, URL hash/query parameters, or BroadcastChannels with automatic cross-tab synchronization.
|
|
22
22
|
|
|
23
|
-
For **
|
|
23
|
+
For **geolocation and internationalization** — utilities like `useTranslateRef` (`t`), `useGeoIntlRef`, `useGeoUnitRef`, `GeoFlagRef`, and `DatetimeRef` that automatically respond to changes in global environment settings (language, currency, region) and dynamically rebuild dates, numbers, units, and translations without manual event listeners.
|
|
24
24
|
|
|
25
|
-
For **
|
|
25
|
+
For **UI component architecture** — a powerful system of base classes (`DesignConstructorAbstract`, `DesignComponents`, `DesignComp`, `DesignAbstract`, `DesignAsyncAbstract`) that provides a structured class-based inheritance model for building complex UI component constructors with automatic lifecycle, slot rendering, and BEM styling.
|
|
26
|
+
|
|
27
|
+
For **auxiliary utilities** — specialized reactive modules for SEO meta tags (`useMeta`), reactive scrollbar tracking (`ScrollbarWidthRef`), IntersectionObserver lazy loading (`useLazyRef`), list selection management (`ListDataRef`), debounced list search (`useSearchRef`), and asynchronous computation primitives (`computedAsync`, `computedEternity`).
|
|
26
28
|
|
|
27
29
|
## Installation
|
|
28
30
|
|
|
@@ -33,22 +35,41 @@ npm install @dxtmisha/functional
|
|
|
33
35
|
## Quick Start
|
|
34
36
|
|
|
35
37
|
```typescript
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
+
import { ref } from 'vue'
|
|
39
|
+
import {
|
|
40
|
+
executeUseGlobal,
|
|
41
|
+
useApiManagementRef,
|
|
42
|
+
useStorageRef,
|
|
43
|
+
useGeoIntlRef,
|
|
44
|
+
t
|
|
45
|
+
} from '@dxtmisha/functional'
|
|
46
|
+
|
|
47
|
+
// 1. Decoupled API & state singleton service
|
|
48
|
+
export const useUserManagement = executeUseGlobal(() => {
|
|
49
|
+
return useApiManagementRef(
|
|
50
|
+
{ path: '/api/users' }, // GET list endpoint
|
|
51
|
+
{ date: (v) => new Date(v).toLocaleString() }, // Formatters
|
|
52
|
+
{ columns: ['name', 'email'] } // Search columns
|
|
53
|
+
)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
// 2. Component usage (Composition API)
|
|
38
57
|
export default {
|
|
39
58
|
setup() {
|
|
40
|
-
// Reactive
|
|
41
|
-
const
|
|
59
|
+
// Reactive storage with cross-tab auto-sync
|
|
60
|
+
const theme = useStorageRef<'light' | 'dark'>('theme', 'dark')
|
|
61
|
+
|
|
62
|
+
// Reactive locale-aware formatting
|
|
63
|
+
const intl = useGeoIntlRef()
|
|
64
|
+
const formattedPrice = intl.currency(150, 'EUR')
|
|
42
65
|
|
|
43
|
-
// Reactive
|
|
44
|
-
const
|
|
45
|
-
theme: 'dark'
|
|
46
|
-
})
|
|
66
|
+
// Reactive translations
|
|
67
|
+
const labels = t(['global.save', 'global.cancel'])
|
|
47
68
|
|
|
48
|
-
//
|
|
49
|
-
const
|
|
69
|
+
// Shared state singleton hook
|
|
70
|
+
const users = useUserManagement()
|
|
50
71
|
|
|
51
|
-
return {
|
|
72
|
+
return { theme, intl, formattedPrice, labels, users }
|
|
52
73
|
}
|
|
53
74
|
}
|
|
54
75
|
```
|
|
@@ -56,7 +77,7 @@ export default {
|
|
|
56
77
|
## Principles
|
|
57
78
|
|
|
58
79
|
- **Full Composition API integration** — every utility is designed with Vue 3's reactivity system in mind, heavily utilizing `ref`, `computed`, and lifecycle hooks.
|
|
59
|
-
- **Separation of concerns** — ideologically encourages extracting validation, state management, and side-effects into specialized classes, maintaining "thin" components.
|
|
80
|
+
- **Separation of concerns** — ideologically encourages extracting validation, state management, and side-effects into specialized classes and `executeUse` singletons, maintaining "thin" components.
|
|
60
81
|
- **Type safety** — provides 100% TypeScript type coverage between APIs, storages, and the UI, protecting codebase scaling with smart type inference.
|
|
61
82
|
- **Predictable resource management** — safely manages subscriptions and frees memory. When a component is unmounted, associated tasks and watchers are cleanly terminated.
|
|
62
83
|
|
|
@@ -69,7 +90,7 @@ Full API reference, examples, and guides:
|
|
|
69
90
|
## Difference from @dxtmisha/functional-basic
|
|
70
91
|
|
|
71
92
|
- **`@dxtmisha/functional-basic`** — core utilities, no framework dependencies. Use this with vanilla JS, React, or any non-Vue stack, or when building a library.
|
|
72
|
-
- **`@dxtmisha/functional`** — extends `functional-basic` with Vue 3 composables and
|
|
93
|
+
- **`@dxtmisha/functional`** — extends `functional-basic` with Vue 3 composables, reactive wrappers, state singletons, and component design constructors. Use this when building complex Vue / Nuxt applications.
|
|
73
94
|
|
|
74
95
|
## License
|
|
75
96
|
|
package/ai-description.md
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
1. CORE PURPOSE
|
|
2
|
+
This library (@dxtmisha/functional) provides Vue 3 reactive abstractions, abstract base classes for component architecture, and advanced composables. It elevates low-level functional utilities from @dxtmisha/functional-basic into Vue 3 reactivity system (refs, computed, lifecycle, reactive singletons) to handle REST API orchestration, localization, meta management, routing, client-side storage, lazy loading, list/search data structures, and standard component state construction.
|
|
3
|
+
|
|
4
|
+
2. KEY EXPOSITIONS
|
|
5
|
+
Abstract Component Base Classes: DesignAbstract, DesignAsyncAbstract, DesignChanged, DesignComponents, DesignComp, DesignConstructorAbstract. These manage component state lifecycle, dynamic class and style processing, event hooks, slot rendering, component modifications, and property mutation tracking.
|
|
6
|
+
|
|
7
|
+
Reactive API Composables: useApiRef, useApiAsyncRef, useApiManagementRef, useApiManagementAsyncRef, useApiGet, useApiPost, useApiPut, useApiDelete, useApiRequest. These handle REST operations with SSR prefetching, response contract validation, mutation handling, error contract mapping, client-side pagination/filtering, and automatic state reactivity.
|
|
8
|
+
|
|
9
|
+
Singleton State & Execution Control: executeUse, executeUseGlobal, executeUseProvide, executeUseLocal, executeUseGlobalInit. These encapsulate factory initialization into global, component-tree inject/provide, or closure-local singletons.
|
|
10
|
+
|
|
11
|
+
Localization & Formatting Classes and Composables: DatetimeRef, GeoFlagRef, GeoIntlRef, GeoRef, GeoUnitRef, useGeoIntlRef, useGeoUnitRef, useFormattersRef, useTranslateRef, t. These offer reactive locale-aware date/time formatting, unit conversion, flag retrieval, and multi-key translation refs.
|
|
12
|
+
|
|
13
|
+
Data Structures & UI Management: ListDataRef, useRouterList, useSearchRef, useSearchValueRef, useLazyRef, useLazyItemByMarginRef, ScrollbarWidthRef, EventRef, EffectScopeGlobal. These provide reactive list data mapping, search query debounce and highlighting, lazy-loading via IntersectionObserver, scrollbar width tracking, and global effect scopes.
|
|
14
|
+
|
|
15
|
+
State Persistence & Browser Composables: useBroadcastValueRef, useCookieRef, useHashRef, useQueryRef, useSessionRef, useStorageRef, useMeta. These control cross-tab communication, cookies, URL query/hash reactive synchronization, session/local storage, and reactive HTML document metadata.
|
|
16
|
+
|
|
17
|
+
Utility Functions & Plugin: computedAsync, computedByLanguage, computedEternity, getBind, getBindRef, render, toBind, toBinds, dxtFunctionalPlugin.
|
|
18
|
+
|
|
19
|
+
3. TRIGGERS FOR STUDYING AI-TYPES.MD
|
|
20
|
+
Reading ai-types.md is mandatory under any of the following conditions, keywords, or implementation tasks:
|
|
21
|
+
- Extending or sub-classing DesignConstructorAbstract, DesignAbstract, DesignAsyncAbstract, or DesignComponents.
|
|
22
|
+
- Configuring API integrations requiring complex typing, specifically ApiManagementGet, ApiManagementSearch, ApiManagementRequest, or ApiOptions.
|
|
23
|
+
- Utilizing component metadata and binding types, such as ConstrBind, ConstrClasses, ConstrStyles, ConstrOptions, ConstrSetup, ConstrComponentMod, or ConstrProps.
|
|
24
|
+
- Constructing managed singletons using executeUse, executeUseGlobal, executeUseProvide, or executeUseLocal.
|
|
25
|
+
- Typing complex list inputs, search items, and reactive parameters using ListList, ListDataItem, ListDataFull, RefOrNormal, RefType, or RefOrNormalOrFunction.
|
|
26
|
+
- Implementing contract validation functions (validateResponseContract, validateRequestContract) or error contracts (ApiErrorStorageList) with schema validation libraries.
|
|
27
|
+
|
|
28
|
+
4. INTEGRATION CONTEXT
|
|
29
|
+
Initializes as a Vue 3 plugin via dxtFunctionalPlugin. Connects directly with Vue 3 reactivity and rendering APIs (ref, computed, VNode, provide/inject). Wraps base functional logic from @dxtmisha/functional-basic, integrates with vue-router via RouterItemRef, links to @dxtmisha/media for social icons, and supports runtime schema validation (such as @effect/schema) inside API payload contracts.
|
package/ai-doc.md
CHANGED
|
@@ -1,112 +1,42 @@
|
|
|
1
1
|
# @dxtmisha/functional Reference
|
|
2
|
-
|
|
3
|
-
Vue 3 reactive utilities, composables, and classes built on `@dxtmisha/functional-basic`. Refer to [ai-types.md](file:///Volumes/T7/Code/dxt-ui/packages/functional/ai-types.md) for full signatures, types, and exported methods.
|
|
4
|
-
|
|
5
|
-
---
|
|
2
|
+
Vue 3 reactive utilities built on `@dxtmisha/functional-basic`. See `ai-types.md` for full signatures.
|
|
6
3
|
|
|
7
4
|
## Usage Rules & Strategies
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
2. **API & State (`useApi*` / `executeUse*`)**:
|
|
11
|
-
- **Never** call `useApiGet`, `useApiPost`, `useApiPut`, `useApiDelete`, `useApiRequest`, `useApiRef`, `useApiAsyncRef`, `useApiManagementRef`, `useApiManagementAsyncRef` directly inside components (SFC).
|
|
12
|
-
- Move all API configurations into separate files (services/stores).
|
|
13
|
-
- Wrap setups in `executeUse` factories (`executeUseLocal`, `executeUseGlobal`, `executeUseProvide`) to ensure singletons, prevent duplicate requests, and process data (mappings, skeletons) in the callback.
|
|
14
|
-
- Components only import/call the singleton hook.
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
import { executeUseGlobal, useApiManagementRef } from '@dxtmisha/functional';
|
|
18
|
-
|
|
19
|
-
export const useUserManagement = executeUseGlobal(() => {
|
|
20
|
-
return useApiManagementRef(
|
|
21
|
-
{ path: '/api/users' }, // GET
|
|
22
|
-
{ date: (v) => new Date(v).toLocaleString() }, // Formatters
|
|
23
|
-
{ columns: ['name', 'email'] }, // Search
|
|
24
|
-
{ path: '/api/users' }, // POST
|
|
25
|
-
{ path: (o) => `/api/users/${o.id}` }, // PUT
|
|
26
|
-
{ path: (o) => `/api/users/${o.id}` } // DELETE
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### `executeUse` Strategies:
|
|
32
|
-
- `executeUseLocal` (Preferred): Lazy-loaded when first called. Persists until session end.
|
|
33
|
-
- `executeUseGlobal`: Eagerly loaded at application startup (useful for critical configs, SDKs). Must be initialized via `executeUseGlobalInit()`.
|
|
34
|
-
- `executeUseProvide`: Scoped via `provide/inject` to a component tree branch (useful for form/tab hierarchies).
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Key API Examples
|
|
39
|
-
|
|
40
|
-
### 1. Storage & State (Reactive)
|
|
41
|
-
Reactively syncs Vue refs with browser storages or cross-tab broadcast channels.
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { useStorageRef, useSessionRef, useCookieRef, useBroadcastValueRef, useHashRef } from '@dxtmisha/functional';
|
|
45
|
-
|
|
46
|
-
const theme = useStorageRef<'light' | 'dark'>('theme_key', 'light');
|
|
47
|
-
const step = useSessionRef<number>('form_step', 1);
|
|
48
|
-
const token = useCookieRef<string>('auth_token', '', { secure: true });
|
|
49
|
-
const syncState = useBroadcastValueRef<string>('active_channel', 'idle');
|
|
50
|
-
const hashPage = useHashRef<string>('page', 'home');
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 2. Geolocation & Internationalization
|
|
54
|
-
Static helpers and reactive wrappers for localization and translation.
|
|
5
|
+
- **Priority**: Always use this package over `@dxtmisha/functional-basic` in Vue.
|
|
6
|
+
- **API/State Singletons**: **NEVER** call `useApi*` / `executeUse*` hooks directly in Vue components. Wrap them in `executeUseGlobal` (startup), `executeUseLocal` (lazy, session scope), or `executeUseProvide` (scoped tree) inside external service files. Components only import and call the resulting hook.
|
|
55
7
|
|
|
56
8
|
```typescript
|
|
57
|
-
import { GeoRef, useGeoIntlRef, useTranslateRef } from '@dxtmisha/functional';
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Orchestrates list state (selection, pagination, highlights) and performs debounced list searches.
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
import { ListDataRef, useSearchRef } from '@dxtmisha/functional';
|
|
94
|
-
|
|
95
|
-
const listData = new ListDataRef(items, selectedId);
|
|
96
|
-
const isSelected = listData.isSelected;
|
|
97
|
-
const nextItem = listData.getSelectedNext();
|
|
98
|
-
|
|
99
|
-
const query = ref('search_term');
|
|
100
|
-
const { listSearch, loading, length } = useSearchRef(items, ['label'], query);
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### 6. DOM & Lazy Rendering
|
|
104
|
-
Lifecycle-aware event listeners and IntersectionObserver wrappers.
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
import { EventRef, useLazyRef } from '@dxtmisha/functional';
|
|
108
|
-
|
|
109
|
-
const keyListener = new EventRef(window, window, 'keydown', (e) => console.log(e.key));
|
|
110
|
-
const lazyManager = useLazyRef();
|
|
111
|
-
const isVisible = lazyManager.addLazyItem(elementRef);
|
|
9
|
+
import { executeUseLocal, useApiManagementRef, useStorageRef, useSessionRef, useCookieRef, useBroadcastValueRef, useHashRef, GeoRef, useGeoIntlRef, useTranslateRef, useMeta, ScrollbarWidthRef, computedAsync, computedEternity, ListDataRef, useSearchRef, EventRef, useLazyRef } from '@dxtmisha/functional';
|
|
10
|
+
|
|
11
|
+
// 1. API Management
|
|
12
|
+
export const useUsers = executeUseLocal(() => useApiManagementRef(
|
|
13
|
+
{ path: '/api/users' }, { date: (v) => new Date(v).toLocaleString() }, { columns: ['name'] },
|
|
14
|
+
{ path: '/api/users' }, { path: (o) => `/api/users/${o.id}` }, { path: (o) => `/api/users/${o.id}` }
|
|
15
|
+
));
|
|
16
|
+
|
|
17
|
+
// 2. Storage & State
|
|
18
|
+
const theme = useStorageRef<'light' | 'dark'>('theme', 'light');
|
|
19
|
+
const step = useSessionRef<number>('step', 1);
|
|
20
|
+
const token = useCookieRef<string>('auth', '', { secure: true });
|
|
21
|
+
const sync = useBroadcastValueRef<string>('ch', 'idle');
|
|
22
|
+
const page = useHashRef<string>('page', 'home');
|
|
23
|
+
|
|
24
|
+
// 3. Geo & Formatting
|
|
25
|
+
const country = GeoRef.getCountry(); const intl = useGeoIntlRef(); intl.currency(150, 'EUR');
|
|
26
|
+
const t = useTranslateRef(['global.save']);
|
|
27
|
+
|
|
28
|
+
// 4. SEO & Layout
|
|
29
|
+
useMeta().setTitle('Page'); const scrollW = new ScrollbarWidthRef().width;
|
|
30
|
+
|
|
31
|
+
// 5. Reactivity Helpers
|
|
32
|
+
const asyncData = computedAsync(async () => fetch(), 'loading...');
|
|
33
|
+
const cached = computedEternity(async () => fetch(), 'loading...');
|
|
34
|
+
|
|
35
|
+
// 6. Lists & Search
|
|
36
|
+
const list = new ListDataRef(items, selectedId); list.isSelected;
|
|
37
|
+
const { listSearch } = useSearchRef(items, ['label'], ref('query'));
|
|
38
|
+
|
|
39
|
+
// 7. DOM Events & Lazy
|
|
40
|
+
const listener = new EventRef(window, window, 'keydown', (e) => console.log(e.key));
|
|
41
|
+
const lazy = useLazyRef(); lazy.addLazyItem(elementRef);
|
|
112
42
|
```
|