Compare commits
1 Commits
master
..
63b3c5f2fd
| Author | SHA1 | Date | |
|---|---|---|---|
| 63b3c5f2fd |
+30
-23
@@ -13,40 +13,47 @@ env:
|
||||
NODE_VERSION: 24.x
|
||||
|
||||
jobs:
|
||||
# Enumerate the workspace packages so the matrix below fans out one job per
|
||||
# package (kept dynamic so new packages are picked up automatically).
|
||||
discover:
|
||||
name: Discover packages
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
packages: ${{ steps.list.outputs.packages }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6
|
||||
with:
|
||||
run_install: false
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: List workspace packages
|
||||
id: list
|
||||
run: echo "packages=$(pnpm -r ls --depth -1 --json | jq -c '[.[] | select(.name != "tools") | .name]')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# One job per package — build (with its workspace deps), lint and test run in
|
||||
# parallel across packages. fail-fast: false so every package is reported.
|
||||
#
|
||||
# The list is static: Gitea's act_runner does not expand a dynamic matrix
|
||||
# built from a previous job's outputs (the strategy is evaluated before the
|
||||
# producing job runs), so `matrix.package` came out empty. When you add a
|
||||
# workspace package, add a line here.
|
||||
check:
|
||||
name: ${{ matrix.package }}
|
||||
needs: discover
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
package:
|
||||
- "@robonen/eslint"
|
||||
- "@robonen/tsconfig"
|
||||
- "@robonen/tsdown"
|
||||
- "@robonen/crdt"
|
||||
- "@robonen/encoding"
|
||||
- "@robonen/fetch"
|
||||
- "@robonen/platform"
|
||||
- "@robonen/stdlib"
|
||||
- "@robonen/docs"
|
||||
- "@robonen/renovate"
|
||||
- "@robonen/primitives"
|
||||
- "@robonen/primitives-playground"
|
||||
- "@robonen/stories"
|
||||
- "@robonen/vue"
|
||||
- "@robonen/writekit"
|
||||
- "@robonen/writekit-playground"
|
||||
package: ${{ fromJSON(needs.discover.outputs.packages) }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6
|
||||
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
name: Check version changes and publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"node": ">=24.16.0"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
@@ -48,15 +47,15 @@
|
||||
"dependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@stylistic/eslint-plugin": "catalog:",
|
||||
"@vitest/eslint-plugin": "^1.6.20",
|
||||
"@vitest/eslint-plugin": "^1.6.19",
|
||||
"eslint-plugin-import-x": "^4.16.2",
|
||||
"eslint-plugin-n": "^18.1.0",
|
||||
"eslint-plugin-regexp": "^3.1.0",
|
||||
"eslint-plugin-unicorn": "^67.0.0",
|
||||
"eslint-plugin-unicorn": "^65.0.1",
|
||||
"eslint-plugin-vue": "^10.9.2",
|
||||
"globals": "^17.6.0",
|
||||
"jiti": "^2.7.0",
|
||||
"typescript-eslint": "^8.61.1",
|
||||
"typescript-eslint": "^8.61.0",
|
||||
"vue-eslint-parser": "^10.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"node": ">=24.16.0"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
"node": ">=24.16.0"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
|
||||
@@ -15,7 +15,7 @@ const ASCII_ZERO = 0x30;
|
||||
* luhn('4111 1111 1111 1111'); // true
|
||||
* luhn('4111 1111 1111 1112'); // false
|
||||
*
|
||||
* @since 0.0.1
|
||||
* @since 0.0.2
|
||||
*/
|
||||
export function luhn(value: string): boolean {
|
||||
const digits = value.replaceAll(NON_DIGIT, '');
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
"node": ">=24.16.0"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
|
||||
@@ -128,7 +128,7 @@ import type { FetchExecuteMiddleware, FetchHook, FetchHooks, FetchOptions, Fetch
|
||||
* });
|
||||
* await billing('/invoices', { method: 'POST', body: { amount: 100 } });
|
||||
*
|
||||
* @since 0.0.1
|
||||
* @since 0.1.0
|
||||
*/
|
||||
export function definePlugin<
|
||||
const Name extends string,
|
||||
@@ -228,7 +228,7 @@ function applyDefaults(
|
||||
* Ordering: plugin defaults (in declaration order) → user defaults (user wins).
|
||||
* Headers are merged independently through a single Headers instance.
|
||||
*
|
||||
* @since 0.0.1
|
||||
* @since 0.1.0
|
||||
*/
|
||||
export function composePlugins(
|
||||
plugins: readonly FetchPlugin[] | undefined,
|
||||
@@ -331,7 +331,7 @@ function composeExecute(middlewares: readonly FetchExecuteMiddleware[]): FetchEx
|
||||
* @description Runs all instance-level (plugin) hooks for a single phase, then the
|
||||
* optional user per-request hook(s). Avoids allocating an intermediate array per call.
|
||||
*
|
||||
* @since 0.0.1
|
||||
* @since 0.1.0
|
||||
*/
|
||||
export async function runHookPhase<C>(
|
||||
instance: ReadonlyArray<FetchHook<C>> | undefined,
|
||||
|
||||
@@ -44,7 +44,7 @@ function shouldRetryStatus(options: ResolvedFetchOptions, status: number): boole
|
||||
*
|
||||
* Auto-registered by `createFetch`; disable per-request via `retry: false`.
|
||||
*
|
||||
* @since 0.0.1
|
||||
* @since 0.1.0
|
||||
*/
|
||||
export function retryPlugin() {
|
||||
return definePlugin({
|
||||
|
||||
@@ -20,7 +20,7 @@ const baseSignals = new WeakMap<object, AbortSignal | undefined>();
|
||||
*
|
||||
* Auto-registered by `createFetch`; no-op when `timeout` is unset.
|
||||
*
|
||||
* @since 0.0.1
|
||||
* @since 0.1.0
|
||||
*/
|
||||
export function timeoutPlugin() {
|
||||
return definePlugin({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@robonen/platform",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.4",
|
||||
"license": "Apache-2.0",
|
||||
"description": "Platform dependent utilities for javascript development",
|
||||
"keywords": [
|
||||
@@ -23,7 +23,6 @@
|
||||
"node": ">=24.16.0"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @category Multi
|
||||
* @description Global object that works in any environment
|
||||
*
|
||||
* @since 0.0.2
|
||||
* @since 0.0.1
|
||||
*/
|
||||
export const _global
|
||||
= typeof globalThis !== 'undefined'
|
||||
@@ -23,6 +23,6 @@ export const _global
|
||||
* @category Multi
|
||||
* @description Check if the current environment is the client
|
||||
*
|
||||
* @since 0.0.2
|
||||
* @since 0.0.1
|
||||
*/
|
||||
export const isClient = typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@robonen/stdlib",
|
||||
"version": "0.0.10",
|
||||
"version": "0.0.9",
|
||||
"license": "Apache-2.0",
|
||||
"description": "A collection of tools, utilities, and helpers for TypeScript",
|
||||
"keywords": [
|
||||
@@ -23,7 +23,6 @@
|
||||
"node": ">=24.16.0"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
|
||||
+2
-2
@@ -26,11 +26,11 @@
|
||||
"@nuxt/fonts": "^0.14.0",
|
||||
"@nuxt/kit": "^4.4.8",
|
||||
"@robonen/eslint": "workspace:*",
|
||||
"@tailwindcss/vite": "^4.3.1",
|
||||
"@tailwindcss/vite": "^4.3.0",
|
||||
"eslint": "catalog:",
|
||||
"jiti": "^2.7.0",
|
||||
"nuxt": "catalog:",
|
||||
"tailwindcss": "^4.3.1",
|
||||
"tailwindcss": "^4.3.0",
|
||||
"ts-morph": "^28.0.0",
|
||||
"vue": "catalog:",
|
||||
"vue-router": "^5.1.0"
|
||||
|
||||
@@ -27,6 +27,6 @@
|
||||
"test": "renovate-config-validator ./default.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"renovate": "^43.228.0"
|
||||
"renovate": "^43.216.1"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
},
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@types/node": "^25.9.3",
|
||||
"@types/node": "^25.9.2",
|
||||
"@vitest/coverage-v8": "catalog:",
|
||||
"@vitest/ui": "catalog:",
|
||||
"citty": "^0.2.2",
|
||||
|
||||
Generated
+3535
-2765
File diff suppressed because it is too large
Load Diff
+8
-22
@@ -6,34 +6,20 @@ packages:
|
||||
- vue/*/playground
|
||||
- docs
|
||||
|
||||
allowBuilds:
|
||||
'@parcel/watcher': true
|
||||
core-js-pure: true
|
||||
dtrace-provider: true
|
||||
esbuild: true
|
||||
re2: true
|
||||
unrs-resolver: true
|
||||
|
||||
catalog:
|
||||
'@stylistic/eslint-plugin': ^5.10.0
|
||||
'@vitest/browser': ^4.1.9
|
||||
'@vitest/coverage-v8': ^4.1.9
|
||||
'@vitest/ui': ^4.1.9
|
||||
'@vue/shared': ^3.5.38
|
||||
'@vitest/browser': ^4.1.8
|
||||
'@vitest/coverage-v8': ^4.1.8
|
||||
'@vitest/ui': ^4.1.8
|
||||
'@vue/shared': ^3.5.35
|
||||
'@vue/test-utils': ^2.4.11
|
||||
eslint: ^10.5.0
|
||||
eslint: ^10.4.1
|
||||
jsdom: ^29.1.1
|
||||
nuxt: ^4.4.8
|
||||
tsdown: ^0.22.3
|
||||
vitest: ^4.1.9
|
||||
vue: ^3.5.38
|
||||
tsdown: ^0.22.2
|
||||
vitest: ^4.1.8
|
||||
vue: ^3.5.35
|
||||
|
||||
ignoredBuiltDependencies:
|
||||
- '@parcel/watcher'
|
||||
- esbuild
|
||||
|
||||
minimumReleaseAgeExclude:
|
||||
- ast-kit@3.0.0
|
||||
- renovate@43.228.0
|
||||
- rolldown-plugin-dts@0.26.0
|
||||
- tsdown@0.22.3
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
"node": ">=24.16.0"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
@@ -59,26 +58,23 @@
|
||||
"@robonen/tsconfig": "workspace:*",
|
||||
"@robonen/tsdown": "workspace:*",
|
||||
"@vitest/browser": "catalog:",
|
||||
"@vitest/browser-playwright": "^4.1.9",
|
||||
"@vitest/browser-playwright": "^4.1.8",
|
||||
"@vue/test-utils": "catalog:",
|
||||
"axe-core": "^4.12.1",
|
||||
"axe-core": "^4.12.0",
|
||||
"eslint": "catalog:",
|
||||
"playwright": "^1.61.0",
|
||||
"playwright": "^1.60.0",
|
||||
"tsdown": "catalog:",
|
||||
"unplugin-vue": "^7.2.0",
|
||||
"vitest-browser-vue": "^2.1.0",
|
||||
"vue": "catalog:",
|
||||
"vue-tsc": "^3.3.5"
|
||||
"vue-tsc": "^3.3.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@floating-ui/vue": "^2.0.0",
|
||||
"@floating-ui/vue": "^1.1.11",
|
||||
"@robonen/encoding": "workspace:*",
|
||||
"@robonen/platform": "workspace:*",
|
||||
"@robonen/stdlib": "workspace:*",
|
||||
"@robonen/vue": "workspace:*",
|
||||
"@vue/shared": "catalog:"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^3.5"
|
||||
"@vue/shared": "catalog:",
|
||||
"vue": "catalog:"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@robonen/tsconfig": "workspace:*",
|
||||
"@tailwindcss/vite": "^4.3.1",
|
||||
"@tailwindcss/vite": "^4.3.0",
|
||||
"@vitejs/plugin-vue": "^6.0.7",
|
||||
"tailwindcss": "^4.3.1",
|
||||
"tailwindcss": "^4.3.0",
|
||||
"vite": "^8.0.16",
|
||||
"vue-tsc": "^3.3.5"
|
||||
"vue-tsc": "^3.3.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,14 +12,8 @@ import {
|
||||
CalendarHeadCell,
|
||||
CalendarRoot,
|
||||
} from '../index';
|
||||
import { nativeDateAdapter } from '../../../utilities/config-provider';
|
||||
import { findFirstFocusableDate, getLocaleWeekStartsOn, toIsoDate } from '../utils';
|
||||
|
||||
// A date adapter whose "today" sits far outside any month exercised below, so
|
||||
// the roving-tabindex fallback never anchors on the real system date (which
|
||||
// would otherwise make date-sensitive expectations flaky).
|
||||
const fixedTodayAdapter = { ...nativeDateAdapter, now: () => new Date(2020, 0, 1) };
|
||||
|
||||
function mountCalendar(
|
||||
props: Record<string, unknown> = {},
|
||||
options: Record<string, unknown> = {},
|
||||
@@ -209,7 +203,6 @@ describe('Calendar — roving fallback tabindex', () => {
|
||||
const w = mountCalendar({
|
||||
defaultPlaceholder: new Date(2026, 5, 1),
|
||||
isDateDisabled: (d: Date) => d.getMonth() === 5 && d.getDate() < 16,
|
||||
dateAdapter: fixedTodayAdapter,
|
||||
});
|
||||
const focusable = w.findAll('[data-primitives-calendar-cell-trigger][tabindex="0"]');
|
||||
expect(focusable).toHaveLength(1);
|
||||
|
||||
@@ -149,27 +149,19 @@ describe('scroll-area — ref forwarding', () => {
|
||||
|
||||
describe('scroll-area — glimpse type', () => {
|
||||
it('accepts type="glimpse" and reveals scrollbars on pointer enter', async () => {
|
||||
const w = track(mount(makeApp({ type: 'glimpse', scrollHideDelay: 5000 }), { attachTo: document.body }));
|
||||
track(mount(makeApp({ type: 'glimpse', scrollHideDelay: 5000 }), { attachTo: document.body }));
|
||||
await waitFrames();
|
||||
const root = w.element as HTMLElement;
|
||||
const root = document.querySelector('[dir]') as HTMLElement;
|
||||
root.dispatchEvent(new PointerEvent('pointerenter'));
|
||||
await waitFrames();
|
||||
// Scope to this component's root: browser-mode suites share one document,
|
||||
// so a global query can also count scrollbars mounted by other suites.
|
||||
expect(root.querySelectorAll('[data-state="visible"]').length).toBeGreaterThan(0);
|
||||
expect(document.querySelectorAll('[data-state="visible"]').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('glimpse stays hidden when the pointer is away', async () => {
|
||||
const w = track(mount(makeApp({ type: 'glimpse', scrollHideDelay: 5000 }), { attachTo: document.body }));
|
||||
const root = w.element as HTMLElement;
|
||||
// Browser mode uses a real cursor: the area mounts at the top-left, so a
|
||||
// leftover pointer from a previous suite can land on it and fire a stray
|
||||
// `pointerenter` (revealing the glimpse). Let that settle, then assert the
|
||||
// deterministic "pointer not over the area" state via `pointerleave`.
|
||||
it('glimpse stays hidden before any interaction', async () => {
|
||||
track(mount(makeApp({ type: 'glimpse', scrollHideDelay: 5000 }), { attachTo: document.body }));
|
||||
await waitFrames();
|
||||
root.dispatchEvent(new PointerEvent('pointerleave'));
|
||||
await waitFrames();
|
||||
expect(root.querySelectorAll('[data-state="visible"]').length).toBe(0);
|
||||
// No pointer enter / scroll => no visible scrollbar yet.
|
||||
expect(document.querySelectorAll('[data-state="visible"]').length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
@@ -31,7 +31,7 @@ function isInClosedPopover(el: Element): boolean {
|
||||
*
|
||||
* @param {MaybeComputedElementRef} target Element whose siblings should be aria-hidden
|
||||
*
|
||||
* @since 0.0.1
|
||||
* @since 0.0.14
|
||||
*/
|
||||
export function useHideOthers(target: MaybeComputedElementRef): void {
|
||||
if (!defaultWindow) return;
|
||||
|
||||
@@ -11,10 +11,7 @@ export default defineConfig({
|
||||
dts: { vue: true },
|
||||
deps: {
|
||||
neverBundle: ['vue'],
|
||||
// `@robonen/*` stay external (deduped by the package manager); only the
|
||||
// stateless `@vue/shared` helpers are inlined (a Vue internal consumers
|
||||
// don't install directly, so it can't be externalized reliably).
|
||||
alwaysBundle: ['@vue/shared'],
|
||||
alwaysBundle: [/^@robonen\//, '@vue/shared'],
|
||||
},
|
||||
inputOptions: {
|
||||
resolve: {
|
||||
|
||||
@@ -13,9 +13,6 @@ export default defineConfig({
|
||||
'@': resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
optimizeDeps: {
|
||||
include: ['@robonen/vue'],
|
||||
},
|
||||
test: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
"devDependencies": {
|
||||
"@robonen/eslint": "workspace:*",
|
||||
"@robonen/tsconfig": "workspace:*",
|
||||
"@storybook/addon-a11y": "^10.4.6",
|
||||
"@storybook/addon-docs": "^10.4.6",
|
||||
"@storybook/vue3-vite": "^10.4.6",
|
||||
"@storybook/addon-a11y": "^10.4.2",
|
||||
"@storybook/addon-docs": "^10.4.2",
|
||||
"@storybook/vue3-vite": "^10.4.2",
|
||||
"@vitejs/plugin-vue": "^6.0.7",
|
||||
"eslint": "catalog:",
|
||||
"storybook": "^10.4.6",
|
||||
"storybook": "^10.4.2",
|
||||
"vite": "^8.0.16"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@robonen/vue",
|
||||
"version": "0.0.14",
|
||||
"version": "0.0.13",
|
||||
"license": "Apache-2.0",
|
||||
"description": "Collection of powerful tools for Vue",
|
||||
"keywords": [
|
||||
@@ -21,7 +21,6 @@
|
||||
"node": ">=24.16.0"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
@@ -50,14 +49,11 @@
|
||||
"@robonen/tsdown": "workspace:*",
|
||||
"@vue/test-utils": "catalog:",
|
||||
"eslint": "catalog:",
|
||||
"tsdown": "catalog:",
|
||||
"vue": "catalog:"
|
||||
"tsdown": "catalog:"
|
||||
},
|
||||
"dependencies": {
|
||||
"@robonen/platform": "workspace:*",
|
||||
"@robonen/stdlib": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^3.5"
|
||||
"@robonen/stdlib": "workspace:*",
|
||||
"vue": "catalog:"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ const RESERVED_KEYS = [
|
||||
* // Shorthand: third argument is the duration in milliseconds
|
||||
* useAnimate(el, { opacity: [0, 1] }, 500);
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useAnimate(
|
||||
target: MaybeComputedElementRef,
|
||||
|
||||
@@ -81,7 +81,7 @@ export interface UseCountdownReturn extends ResumableActions {
|
||||
* onComplete: () => console.log('done'),
|
||||
* });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useCountdown(
|
||||
initialCountdown: MaybeRefOrGetter<number>,
|
||||
|
||||
@@ -44,15 +44,15 @@ export type UseDateFormatReturn = ComputedRef<string>;
|
||||
|
||||
// Matches a token, or a `[literal]` escape that is emitted verbatim.
|
||||
const REGEX_FORMAT
|
||||
= /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|z{1,4}|SSS/g;
|
||||
= /* #__PURE__ */ /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|z{1,4}|SSS/g;
|
||||
|
||||
// Loose ISO-ish parser used for date strings without a trailing `Z`. The optional
|
||||
// separators make adjacent digit groups technically "misleading" to the linter,
|
||||
// but this is the deliberate lenient dayjs parser (accepts `2024-01-01` and
|
||||
// `20240101`); JS lacks possessive quantifiers to disambiguate it.
|
||||
// eslint-disable-next-line regexp/no-misleading-capturing-group
|
||||
const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
|
||||
const REGEX_ISO_SUFFIX = /z$/i;
|
||||
const REGEX_PARSE = /* #__PURE__ */ /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
|
||||
const REGEX_ISO_SUFFIX = /* #__PURE__ */ /z$/i;
|
||||
|
||||
const ORDINAL_SUFFIXES = ['th', 'st', 'nd', 'rd'] as const;
|
||||
|
||||
@@ -207,7 +207,7 @@ export function formatDate(
|
||||
* customMeridiem: (h) => (h < 12 ? 'morning' : 'evening'),
|
||||
* });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useDateFormat(
|
||||
date: MaybeRefOrGetter<DateLike>,
|
||||
|
||||
@@ -59,7 +59,7 @@ export type UseIntervalReturn = Readonly<ShallowRef<number>> | UseIntervalContro
|
||||
* @example
|
||||
* const { counter, isActive, pause, resume, reset } = useInterval(1000, { controls: true });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useInterval(interval?: MaybeRefOrGetter<number>, options?: UseIntervalOptions<false>): Readonly<ShallowRef<number>>;
|
||||
export function useInterval(interval: MaybeRefOrGetter<number>, options: UseIntervalOptions<true>): UseIntervalControls;
|
||||
|
||||
@@ -70,7 +70,7 @@ export type UseNowReturn<Controls extends boolean>
|
||||
* // Run a callback on every update
|
||||
* useNow({ interval: 1000, callback: date => console.log(date.toISOString()) });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useNow(options?: UseNowOptions<false>): Ref<Date>;
|
||||
export function useNow(options: UseNowOptions<true>): UseNowControls;
|
||||
|
||||
@@ -165,7 +165,7 @@ const DEFAULT_UNITS: Array<UseTimeAgoUnit<UseTimeAgoUnitName>> = [
|
||||
{ max: Number.POSITIVE_INFINITY, value: 31536000000, name: 'year' },
|
||||
];
|
||||
|
||||
const REGEX_DIGIT = /\d/;
|
||||
const REGEX_DIGIT = /* #__PURE__ */ /\d/;
|
||||
|
||||
const DEFAULT_MESSAGES: UseTimeAgoMessages<UseTimeAgoUnitName> = {
|
||||
justNow: 'just now',
|
||||
@@ -197,7 +197,7 @@ function defaultFullDateFormatter(date: Date): string {
|
||||
* @example
|
||||
* formatTimeAgo(new Date(Date.now() - 3 * 60_000)); // '3 minutes ago'
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function formatTimeAgo<UnitNames extends string = UseTimeAgoUnitName>(
|
||||
from: Date,
|
||||
@@ -303,7 +303,7 @@ export function formatTimeAgo<UnitNames extends string = UseTimeAgoUnitName>(
|
||||
* fullDateFormatter: d => d.toLocaleDateString('fr-FR'),
|
||||
* });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useTimeAgo<UnitNames extends string = UseTimeAgoUnitName>(
|
||||
time: MaybeRefOrGetter<Date | number | string>,
|
||||
|
||||
@@ -61,7 +61,7 @@ export type UseTimeoutReturn
|
||||
* // Run a callback when the timeout elapses
|
||||
* useTimeout(5000, { callback: refresh });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useTimeout(interval?: MaybeRefOrGetter<number>, options?: UseTimeoutOptions<false>): ComputedRef<boolean>;
|
||||
export function useTimeout(interval: MaybeRefOrGetter<number>, options: UseTimeoutOptions<true>): UseTimeoutControls;
|
||||
|
||||
@@ -58,7 +58,7 @@ export interface UseTimeoutFnReturn<Args extends unknown[]> {
|
||||
* // Fire once now and again after the delay
|
||||
* useTimeoutFn(refresh, 5000, { immediateCallback: true });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useTimeoutFn<T extends AnyFunction>(
|
||||
cb: T,
|
||||
|
||||
@@ -82,7 +82,7 @@ export type UseTimestampReturn<Controls extends boolean> = Controls extends true
|
||||
* const offset = ref(0);
|
||||
* const now = useTimestamp({ offset });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useTimestamp(options?: UseTimestampOptions<false>): Ref<number>;
|
||||
export function useTimestamp(options: UseTimestampOptions<true>): UseTimestampControls;
|
||||
|
||||
@@ -218,7 +218,7 @@ function valuesEqual(a: TransitionValue, b: TransitionValue): boolean {
|
||||
* const color = ref([0, 0, 0]);
|
||||
* const animated = useTransition(color, { duration: 1000 });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useTransition<T extends TransitionValue>(
|
||||
source: MaybeRefOrGetter<T>,
|
||||
|
||||
@@ -58,7 +58,7 @@ function isArrayDifferenceOptions<T>(value: unknown): value is UseArrayDifferenc
|
||||
* const b = ref([2, 3, 4]);
|
||||
* const symmetric = useArrayDifference(a, b, { symmetric: true }); // [1, 4]
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayDifference<T>(
|
||||
list: MaybeRefOrGetter<T[]>,
|
||||
|
||||
@@ -20,7 +20,7 @@ export type UseArrayEveryReturn = ComputedRef<boolean>;
|
||||
* const items = [ref(2), ref(4), ref(6)];
|
||||
* const allEven = useArrayEvery(items, n => n % 2 === 0); // true
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayEvery<T>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { ComputedRef, MaybeRefOrGetter } from 'vue';
|
||||
* const list = ref([1, 2, 3, 4]);
|
||||
* const even = useArrayFilter(list, n => n % 2 === 0); // [2, 4]
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayFilter<T>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { ComputedRef, MaybeRefOrGetter } from 'vue';
|
||||
* const list = ref([1, 2, 3]);
|
||||
* const found = useArrayFind(list, n => n > 1); // 2
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayFind<T>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
|
||||
@@ -16,7 +16,7 @@ export type UseArrayFindIndexReturn = ComputedRef<number>;
|
||||
* const list = ref([1, 2, 3]);
|
||||
* const index = useArrayFindIndex(list, n => n > 1); // 1
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayFindIndex<T>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
|
||||
@@ -35,7 +35,7 @@ const hasNativeFindLast = typeof Array.prototype.findLast === 'function';
|
||||
* const list = ref([1, 2, 3, 4]);
|
||||
* const found = useArrayFindLast(list, n => n % 2 === 0); // 4
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayFindLast<T>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
|
||||
@@ -50,7 +50,7 @@ function isArrayIncludesOptions<T, V>(value: unknown): value is UseArrayIncludes
|
||||
* const list = ref(['a', 'b', 'a']);
|
||||
* const fromSecond = useArrayIncludes(list, 'a', { fromIndex: 1 }); // true
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayIncludes<T, V = T>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
|
||||
@@ -18,7 +18,7 @@ export type UseArrayJoinReturn = ComputedRef<string>;
|
||||
* const sep = ref('-');
|
||||
* const joined = useArrayJoin(list, sep); // 'a-b-c'
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayJoin(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<unknown>>>,
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { ComputedRef, MaybeRefOrGetter } from 'vue';
|
||||
* const list = ref([1, 2, 3]);
|
||||
* const doubled = useArrayMap(list, n => n * 2); // [2, 4, 6]
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayMap<T, U = T>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
|
||||
@@ -19,7 +19,7 @@ export type UseArrayReduceReturn<T> = ComputedRef<T>;
|
||||
* const list = ref([1, 2, 3, 4]);
|
||||
* const sum = useArrayReduce(list, (acc, n) => acc + n); // 10
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayReduce<T>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
@@ -40,7 +40,7 @@ export function useArrayReduce<T>(
|
||||
* const list = ref([1, 2, 3, 4]);
|
||||
* const sum = useArrayReduce(list, (acc, n) => acc + n, 100); // 110
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayReduce<T, U>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
|
||||
@@ -20,7 +20,7 @@ export type UseArraySomeReturn = ComputedRef<boolean>;
|
||||
* const items = [ref(1), ref(3), ref(5)];
|
||||
* const hasEven = useArraySome(items, n => n % 2 === 0); // false
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArraySome<T>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
|
||||
@@ -42,7 +42,7 @@ export type UseArrayUniqueReturn<T = unknown> = ComputedRef<T[]>;
|
||||
* const list = ref([1.1, 1.4, 2.2]);
|
||||
* const byFloor = useArrayUnique(list, (a, b) => Math.floor(a) === Math.floor(b)); // [1.1, 2.2]
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useArrayUnique<T>(
|
||||
list: MaybeRefOrGetter<Array<MaybeRefOrGetter<T>>>,
|
||||
|
||||
@@ -99,7 +99,7 @@ const defaultSortFn: UseSortedFn = <T>(source: T[], compareFn: UseSortedCompareF
|
||||
* useSorted(list, { dirty: true });
|
||||
* // list.value is now [1, 2, 3]
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useSorted<T = unknown>(source: Ref<T[]>, compareFn?: UseSortedCompareFn<T>): Ref<T[]>;
|
||||
export function useSorted<T = unknown>(source: MaybeRefOrGetter<T[]>, compareFn?: UseSortedCompareFn<T>): ComputedRef<T[]>;
|
||||
|
||||
@@ -104,7 +104,7 @@ function increaseWithUnit(target: number | string, delta: number): number | stri
|
||||
* const bp = useBreakpoints({ mobile: 0, tablet: 640, desktop: 1024 });
|
||||
* const active = bp.active(); // ComputedRef<'mobile' | 'tablet' | 'desktop' | ''>
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useBreakpoints<K extends string>(
|
||||
breakpoints: Breakpoints<K>,
|
||||
|
||||
@@ -76,7 +76,7 @@ export interface UseClipboardReturn<Optional extends boolean> {
|
||||
* // Copy a lazily/asynchronously resolved value
|
||||
* copy(async () => (await fetch('/token').then(r => r.text())));
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useClipboard(options?: UseClipboardOptions<undefined>): UseClipboardReturn<false>;
|
||||
export function useClipboard(options: UseClipboardOptions<MaybeRefOrGetter<string>>): UseClipboardReturn<true>;
|
||||
|
||||
@@ -96,7 +96,7 @@ export interface UseClipboardItemsReturn<Optional extends boolean> {
|
||||
* const { content } = useClipboardItems({ read: true });
|
||||
* copy(async () => buildClipboardItems());
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useClipboardItems(options?: UseClipboardItemsOptions<undefined>): UseClipboardItemsReturn<false>;
|
||||
export function useClipboardItems(options: UseClipboardItemsOptions<MaybeRefOrGetter<ClipboardItems>>): UseClipboardItemsReturn<true>;
|
||||
|
||||
@@ -76,7 +76,7 @@ export interface UseCloseWatcherReturn {
|
||||
* // Programmatically request a close
|
||||
* close();
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useCloseWatcher(options: UseCloseWatcherOptions = {}): UseCloseWatcherReturn {
|
||||
const { window = defaultWindow } = options;
|
||||
|
||||
@@ -120,7 +120,7 @@ const CSS_DISABLE_TRANS = '*,*::before,*::after{-webkit-transition:none!importan
|
||||
* // Read the resolved system + effective state
|
||||
* const { system, state } = useColorMode();
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useColorMode<T extends string = BasicColorMode>(
|
||||
options: UseColorModeOptions<T> = {},
|
||||
|
||||
@@ -42,7 +42,7 @@ export interface UseCssVarReturn extends WritableComputedRef<string | null | und
|
||||
* @example
|
||||
* const theme = useCssVar('--theme', null, { initialValue: 'light', observe: true });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useCssVar(
|
||||
prop: MaybeRefOrGetter<string | null | undefined>,
|
||||
|
||||
@@ -58,7 +58,7 @@ export type UseDarkReturn = WritableComputedRef<boolean>;
|
||||
* const isDark = useDark();
|
||||
* const toggleDark = useToggle(isDark);
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useDark(options: UseDarkOptions = {}): UseDarkReturn {
|
||||
const {
|
||||
|
||||
@@ -109,7 +109,7 @@ export interface UseDocumentPiPReturn {
|
||||
* pipWindow.value.document.body.append(playerEl);
|
||||
* });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useDocumentPiP(options: UseDocumentPiPOptions = {}): UseDocumentPiPReturn {
|
||||
const {
|
||||
|
||||
@@ -67,7 +67,7 @@ export interface UseEyeDropperReturn {
|
||||
* if (isSupported.value)
|
||||
* await open();
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useEyeDropper(options: UseEyeDropperOptions = {}): UseEyeDropperReturn {
|
||||
const {
|
||||
|
||||
@@ -44,7 +44,7 @@ const FILE_EXTENSION_RE = /\.([a-z0-9]+)$/i;
|
||||
* const isDark = useDark();
|
||||
* const favicon = useFavicon(() => isDark.value ? '/dark.png' : '/light.png');
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useFavicon(
|
||||
newIcon: MaybeRefOrGetter<string | null | undefined>,
|
||||
|
||||
@@ -159,7 +159,7 @@ function toFileList(files: File[] | FileList | undefined): FileList | null {
|
||||
* const { open } = useFileDialog();
|
||||
* open({ multiple: false, accept: '.pdf' });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useFileDialog(options: UseFileDialogOptions = {}): UseFileDialogReturn {
|
||||
const {
|
||||
|
||||
@@ -186,7 +186,7 @@ export interface UseFileSystemAccessReturn<T = string | ArrayBuffer | Blob> {
|
||||
* // Read raw bytes
|
||||
* const { data } = useFileSystemAccess({ dataType: 'ArrayBuffer' });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useFileSystemAccess(): UseFileSystemAccessReturn<string | ArrayBuffer | Blob>;
|
||||
export function useFileSystemAccess(options: UseFileSystemAccessOptions & { dataType: 'Text' }): UseFileSystemAccessReturn<string>;
|
||||
|
||||
@@ -106,7 +106,7 @@ const listenerOptions = { capture: false, passive: true } as const;
|
||||
* // Fullscreen the whole page
|
||||
* const { toggle } = useFullscreen();
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useFullscreen(
|
||||
target?: MaybeComputedElementRef,
|
||||
|
||||
@@ -113,7 +113,7 @@ function loadImage(options: UseImageOptions, ctx: LoadImageContext): Promise<HTM
|
||||
* const src = ref('/a.png');
|
||||
* const { state } = useImage(() => ({ src: src.value, alt: 'photo' }));
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useImage(
|
||||
options: MaybeRefOrGetter<UseImageOptions>,
|
||||
|
||||
@@ -113,7 +113,7 @@ export interface UseLocalFontsReturn {
|
||||
* const { fonts, query } = useLocalFonts();
|
||||
* await query({ postscriptNames: ['Arial-BoldMT'] });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useLocalFonts(options: UseLocalFontsOptions = {}): UseLocalFontsReturn {
|
||||
const {
|
||||
|
||||
@@ -61,7 +61,7 @@ function matchSsrWidth(query: string, width: number): boolean {
|
||||
* // Resolve width queries during SSR to avoid hydration flicker
|
||||
* const isWide = useMediaQuery('(min-width: 1024px)', { ssrWidth: 1280 });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useMediaQuery(
|
||||
query: MaybeRefOrGetter<string>,
|
||||
|
||||
@@ -21,7 +21,7 @@ export type UseObjectUrlReturn = Readonly<ShallowRef<string | undefined>>;
|
||||
* const file = shallowRef<File>();
|
||||
* const url = useObjectUrl(file);
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useObjectUrl(
|
||||
object: MaybeRefOrGetter<Blob | MediaSource | null | undefined>,
|
||||
|
||||
@@ -151,7 +151,7 @@ const DEFAULT_TRANSPORT: OTPTransportType[] = ['sms'];
|
||||
* const { receive } = useOtpCredentials();
|
||||
* receive({ signal: AbortSignal.timeout(30_000) });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useOtpCredentials(options: UseOtpCredentialsOptions = {}): UseOtpCredentialsReturn {
|
||||
const {
|
||||
|
||||
@@ -79,7 +79,7 @@ export interface UsePermissionReturnWithControls {
|
||||
* @example
|
||||
* const { state, isSupported, query } = usePermission('camera', { controls: true });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function usePermission(
|
||||
permissionDesc: GeneralPermissionDescriptor | GeneralPermissionDescriptor['name'],
|
||||
|
||||
@@ -16,7 +16,7 @@ export type ColorSchemePreference = 'dark' | 'light' | 'no-preference';
|
||||
* @example
|
||||
* const scheme = usePreferredColorScheme();
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function usePreferredColorScheme(
|
||||
options: ConfigurableWindow = {},
|
||||
|
||||
@@ -32,7 +32,7 @@ export interface UsePreferredContrastOptions extends UseMediaQueryOptions {
|
||||
* // Provide an SSR fallback to avoid hydration flicker
|
||||
* const contrast = usePreferredContrast({ ssrContrast: 'more' });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function usePreferredContrast(
|
||||
options: UsePreferredContrastOptions = {},
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useMediaQuery } from '@/composables/browser/useMediaQuery';
|
||||
* @example
|
||||
* const isDark = usePreferredDark();
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function usePreferredDark(options: ConfigurableWindow = {}): Ref<boolean> {
|
||||
return useMediaQuery('(prefers-color-scheme: dark)', options);
|
||||
|
||||
@@ -24,7 +24,7 @@ import { useEventListener } from '@/composables/browser/useEventListener';
|
||||
* // Pass a custom window (e.g. an iframe)
|
||||
* const languages = usePreferredLanguages({ window: iframe.contentWindow });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function usePreferredLanguages(options: ConfigurableWindow = {}): ShallowRef<readonly string[]> {
|
||||
const { window = defaultWindow } = options;
|
||||
|
||||
@@ -30,7 +30,7 @@ export type UsePreferredReducedMotionReturn = ComputedRef<ReducedMotionType>;
|
||||
* transitionDuration.value = motion.value === 'reduce' ? 0 : 200;
|
||||
* });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function usePreferredReducedMotion(
|
||||
options: UsePreferredReducedMotionOptions = {},
|
||||
|
||||
@@ -19,7 +19,7 @@ export type ReducedTransparencyType
|
||||
* const transparency = usePreferredReducedTransparency();
|
||||
* // transparency.value === 'reduce' | 'no-preference'
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function usePreferredReducedTransparency(
|
||||
options: ConfigurableWindow = {},
|
||||
|
||||
@@ -140,7 +140,7 @@ export interface UseScriptTagReturn {
|
||||
* await load();
|
||||
* unload();
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useScriptTag(
|
||||
src: MaybeRefOrGetter<string>,
|
||||
|
||||
@@ -67,7 +67,7 @@ export interface UseShareReturn {
|
||||
* const { share } = useShare({ title: 'Default' });
|
||||
* share({ text: 'One-off message' });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useShare(
|
||||
shareOptions: MaybeRefOrGetter<UseShareOptions> = {},
|
||||
|
||||
@@ -101,7 +101,7 @@ const _refCount = new WeakMap<HTMLStyleElement, number>();
|
||||
* load();
|
||||
* unload();
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useStyleTag(
|
||||
css: MaybeRefOrGetter<string>,
|
||||
|
||||
@@ -85,7 +85,7 @@ export interface UseTextareaAutosizeReturn {
|
||||
* @example
|
||||
* const { textarea, input, triggerResize } = useTextareaAutosize({ maxHeight: 320 });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useTextareaAutosize(options: UseTextareaAutosizeOptions = {}): UseTextareaAutosizeReturn {
|
||||
const {
|
||||
|
||||
@@ -61,7 +61,7 @@ export type UseTitleReturn = Ref<string | null | undefined> | ComputedRef<string
|
||||
* // Restore the previous title when the component unmounts
|
||||
* useTitle('Checkout', { restoreOnUnmount: (original) => original });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useTitle(
|
||||
newTitle: () => string | null | undefined,
|
||||
|
||||
@@ -88,7 +88,7 @@ export type UseUrlSearchParamsReturn<T extends Record<string, any> = UrlParams>
|
||||
* const params = useUrlSearchParams<{ ids: string[] }>('history');
|
||||
* params.ids = ['1', '2']; // -> ?ids=1&ids=2
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
// `Record<string, any>` constraint mirrors `UseUrlSearchParamsReturn`: caller-supplied
|
||||
// `T` flows back out, so interface types must satisfy the bound (see note above).
|
||||
|
||||
@@ -76,7 +76,7 @@ export interface UseVibrateReturn {
|
||||
* const { vibrate, stop, intervalControls } = useVibrate({ pattern: [300, 100], interval: 2000 });
|
||||
* intervalControls?.resume();
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useVibrate(options: UseVibrateOptions = {}): UseVibrateReturn {
|
||||
const {
|
||||
|
||||
@@ -72,7 +72,7 @@ export interface UseWakeLockReturn {
|
||||
* const { forceRequest } = useWakeLock();
|
||||
* await forceRequest('screen');
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useWakeLock(options: UseWakeLockOptions = {}): UseWakeLockReturn {
|
||||
const {
|
||||
|
||||
@@ -163,7 +163,7 @@ export interface UseWebNotificationReturn {
|
||||
* const { show } = useWebNotification();
|
||||
* show({ title: 'Override', body: 'Per-call body' });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useWebNotification(
|
||||
options: UseWebNotificationOptions = {},
|
||||
|
||||
@@ -117,7 +117,7 @@ function makePair<
|
||||
* // <DefineItem v-slot="{ label }">{{ label }}</DefineItem>
|
||||
* // <ReuseItem label="A" /> <ReuseItem label="B" />
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function createReusableTemplate<
|
||||
Bindings extends Record<string, any>,
|
||||
|
||||
@@ -50,7 +50,7 @@ export type UseCurrentElementReturn<
|
||||
* const child = useTemplateRef('child');
|
||||
* const el = useCurrentElement(child);
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useCurrentElement<
|
||||
T extends MaybeElement = MaybeElement,
|
||||
|
||||
@@ -198,7 +198,7 @@ function createMetrics(length: number, itemSize: UseVirtualListItemSize): UseVir
|
||||
* // Variable heights and a wider overscan buffer.
|
||||
* const { list } = useVirtualList(items, { itemHeight: i => (i % 2 ? 40 : 80), overscan: 10 });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useVirtualList<T = unknown>(
|
||||
list: MaybeRefOrGetter<readonly T[]>,
|
||||
|
||||
@@ -32,7 +32,7 @@ export type OnElementRemovalReturn = VoidFunction;
|
||||
* @example
|
||||
* const stop = onElementRemoval(el, (records) => report(records), { flush: 'post' });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function onElementRemoval(
|
||||
target: MaybeComputedElementRef,
|
||||
|
||||
@@ -38,7 +38,7 @@ export type UseActiveElementReturn<T extends HTMLElement = HTMLElement> = Shallo
|
||||
* // keep tracking even if the focused node is detached from the DOM
|
||||
* const active = useActiveElement({ triggerOnRemoval: true });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useActiveElement<T extends HTMLElement>(
|
||||
options: UseActiveElementOptions = {},
|
||||
|
||||
@@ -41,7 +41,7 @@ export type UseDocumentReadyStateReturn = ShallowRef<DocumentReadyState>;
|
||||
* },
|
||||
* });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useDocumentReadyState(
|
||||
options: UseDocumentReadyStateOptions = {},
|
||||
|
||||
@@ -41,7 +41,7 @@ export type UseDocumentVisibilityReturn = ShallowRef<DocumentVisibilityState>;
|
||||
* },
|
||||
* });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useDocumentVisibility(
|
||||
options: UseDocumentVisibilityOptions = {},
|
||||
|
||||
@@ -167,7 +167,7 @@ export interface UseDraggableReturn {
|
||||
* // Lock to the horizontal axis and only drag from a handle.
|
||||
* const { position } = useDraggable(el, { axis: 'x', handle: handleEl });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useDraggable(
|
||||
target: MaybeComputedElementRef,
|
||||
|
||||
@@ -79,7 +79,7 @@ type DropZoneEventType = 'enter' | 'over' | 'leave' | 'drop';
|
||||
* onDrop: (files) => console.log(files),
|
||||
* });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useDropZone(
|
||||
target: MaybeComputedElementRef | MaybeRefOrGetter<Document | null | undefined>,
|
||||
|
||||
@@ -84,7 +84,7 @@ export interface UseElementBoundingReturn {
|
||||
* // Batch rapid scroll/resize reads into one measurement per frame
|
||||
* const bounds = useElementBounding(el, { updateTiming: 'next-frame' });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useElementBounding(
|
||||
target: MaybeComputedElementRef,
|
||||
|
||||
@@ -41,7 +41,7 @@ export interface UseElementSizeReturn {
|
||||
* @example
|
||||
* const { width, height, stop } = useElementSize(el, { width: 100, height: 100 }, { box: 'border-box' });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useElementSize(
|
||||
target: MaybeComputedElementRef,
|
||||
|
||||
@@ -56,7 +56,7 @@ export type UseElementVisibilityReturn<Controls extends boolean = false>
|
||||
* @example
|
||||
* const { isVisible, stop } = useElementVisibility(el, { controls: true, once: true });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useElementVisibility(
|
||||
target: MaybeComputedElementRef,
|
||||
|
||||
@@ -18,7 +18,7 @@ let counter = 0;
|
||||
* @example
|
||||
* useFocusGuard('my-namespace');
|
||||
*
|
||||
* @since 0.0.3
|
||||
* @since 0.0.2
|
||||
*/
|
||||
export function useFocusGuard(namespace?: string) {
|
||||
const manager = focusGuard(namespace);
|
||||
|
||||
@@ -62,7 +62,7 @@ export interface UseIntersectionObserverReturn {
|
||||
* visible.value = isIntersecting;
|
||||
* });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useIntersectionObserver(
|
||||
target: MaybeComputedElementRef | MaybeComputedElementRef[] | MaybeRefOrGetter<MaybeElement[]>,
|
||||
|
||||
@@ -61,7 +61,7 @@ export interface UseMutationObserverReturn {
|
||||
* @example
|
||||
* const { pause, resume } = useMutationObserver([elA, elB], onMutate, { childList: true });
|
||||
*
|
||||
* @since 0.0.14
|
||||
* @since 0.0.15
|
||||
*/
|
||||
export function useMutationObserver(
|
||||
target: MaybeComputedElementRef | MaybeComputedElementRef[] | MaybeRefOrGetter<MaybeElement[]>,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user