mirror of
https://github.com/LukeHagar/svelte-interactions.git
synced 2025-12-06 04:21:32 +00:00
add changesets
This commit is contained in:
8
.changeset/README.md
Normal file
8
.changeset/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Changesets
|
||||
|
||||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
||||
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
||||
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
||||
|
||||
We have a quick list of common questions to get you started engaging with this project in
|
||||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
||||
14
.changeset/config.json
Normal file
14
.changeset/config.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
|
||||
"changelog": [
|
||||
"@svitejs/changesets-changelog-github-compact",
|
||||
{ "repo": "huntabyte/svelte-interactions" }
|
||||
],
|
||||
"commit": false,
|
||||
"fixed": [],
|
||||
"linked": [],
|
||||
"access": "public",
|
||||
"baseBranch": "main",
|
||||
"updateInternalDependencies": "patch",
|
||||
"ignore": []
|
||||
}
|
||||
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [huntabyte]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: huntabyte
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
95
.github/workflows/ci.yml
vendored
Normal file
95
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
Check:
|
||||
name: Run svelte-check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
# PNPM Store cache setup
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
run: |
|
||||
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Run svelte-check
|
||||
run: pnpm check
|
||||
|
||||
Lint:
|
||||
runs-on: ubuntu-latest
|
||||
name: Lint
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Node.JS
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- uses: pnpm/action-setup@v2
|
||||
name: Install pnpm
|
||||
id: pnpm-install
|
||||
with:
|
||||
version: 8
|
||||
|
||||
# PNPM Store cache setup
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
run: |
|
||||
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- run: pnpm lint
|
||||
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8.6.3
|
||||
run_install: true
|
||||
- run: pnpm run test
|
||||
41
.github/workflows/release.yml
vendored
Normal file
41
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
permissions:
|
||||
contents: write # to create release (changesets/action)
|
||||
pull-requests: write # to create pull request (changesets/action)
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||
fetch-depth: 0
|
||||
- uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 8.6.3
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18.x'
|
||||
cache: pnpm
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Create Release Pull Request or Publish to npm
|
||||
id: changesets
|
||||
uses: changesets/action@v1
|
||||
with:
|
||||
publish: pnpm release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
@@ -1,4 +1,4 @@
|
||||
svelte-press-events
|
||||
svelte-interactions
|
||||
=================
|
||||
The following is a list of sources from which code was used/modified in this codebase.
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ Creates a new `press` interaction instance. Each element should have its own ins
|
||||
`initPress` takes in an optional `PressConfig` object, which can be used to customize the interaction.
|
||||
|
||||
```ts
|
||||
type PressConfig = PressEvents {
|
||||
type PressConfig = PressHandlers {
|
||||
/**
|
||||
* Whether the target is in a controlled press state
|
||||
* (e.g. an overlay it triggers is open).
|
||||
@@ -96,12 +96,12 @@ type PressConfig = PressEvents {
|
||||
};
|
||||
```
|
||||
|
||||
The `PressConfig` object also includes handlers for all the different `PressEvents`. These are provided as a convenience, should you prefer to handle the events here rather than the custom `on:press*` events dispatched by the element with the `pressAction`.
|
||||
The `PressConfig` object also includes handlers for all the different `PressHandlers`. These are provided as a convenience, should you prefer to handle the events here rather than the custom `on:press*` events dispatched by the element with the `pressAction`.
|
||||
|
||||
Be aware that if you use these handlers, the custom `on:press*` events will still be dispatched, so be sure you aren't handling the same event twice.
|
||||
|
||||
```ts
|
||||
type PressEvents = {
|
||||
type PressHandlers = {
|
||||
/**
|
||||
* Handler that is called when the press is released
|
||||
* over the target.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"name": "svelte-interactions",
|
||||
"version": "0.0.0",
|
||||
"repository": "github:huntabyte/vaul-svelte",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build && npm run package",
|
||||
@@ -11,7 +13,9 @@
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"test": "vitest",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"format": "prettier --write ."
|
||||
"format": "prettier --write .",
|
||||
"release": "changeset publish",
|
||||
"changeset": "changeset"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
@@ -28,10 +32,12 @@
|
||||
"svelte": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@changesets/cli": "^2.27.1",
|
||||
"@sveltejs/adapter-auto": "^3.0.0",
|
||||
"@sveltejs/kit": "^2.0.0",
|
||||
"@sveltejs/package": "^2.0.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
||||
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
|
||||
"@types/eslint": "8.56.0",
|
||||
"@types/node": "^20.10.6",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
|
||||
1617
pnpm-lock.yaml
generated
1617
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
import { initPress, type PressConfig } from './press.js';
|
||||
import type { PressEvent } from './types/events.js';
|
||||
import { initPress, type PressConfig, type PressResult } from './press.js';
|
||||
import type { PressEvent, PointerType } from './types/events.js';
|
||||
|
||||
export { initPress, type PressEvent, type PressConfig };
|
||||
export { initPress, type PressEvent, type PressConfig, type PressResult, type PointerType };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { disableTextSelection, restoreTextSelection } from './utils/text-selection.js';
|
||||
import type { FocusableElement } from './types/dom.js';
|
||||
import type { PressEvent as IPressEvent, PointerType, PressEvents } from './types/events.js';
|
||||
import type { PressEvent as IPressEvent, PointerType, PressHandlers } from './types/events.js';
|
||||
import { focusWithoutScrolling } from './utils/focus-without-scroll.js';
|
||||
import { getOwnerDocument, getOwnerWindow } from './utils/get-owner.js';
|
||||
import { isMac } from './utils/platform.js';
|
||||
@@ -8,13 +8,13 @@ import { isVirtualClick, isVirtualPointerEvent } from './utils/is-virtual-event.
|
||||
import { openLink } from './utils/open-link.js';
|
||||
|
||||
import { createGlobalListeners } from './utils/global-listeners.js';
|
||||
import { get, writable, type Writable } from 'svelte/store';
|
||||
import { get, writable, type Readable, readonly } from 'svelte/store';
|
||||
import { toWritableStores } from './utils/to-writable-stores.js';
|
||||
import { executeCallbacks, noop } from './utils/callbacks.js';
|
||||
import { addEventListener } from './utils/event-listeners.js';
|
||||
import type { ActionReturn } from 'svelte/action';
|
||||
|
||||
export type PressConfig = PressEvents & {
|
||||
export type PressConfig = PressHandlers & {
|
||||
/** Whether the target is in a controlled press state (e.g. an overlay it triggers is open). */
|
||||
isPressed?: boolean;
|
||||
/** Whether the press events should be disabled. */
|
||||
@@ -67,7 +67,7 @@ type PressActionReturn = ActionReturn<
|
||||
|
||||
export type PressResult = {
|
||||
/** Whether the target is currently pressed. */
|
||||
isPressed: Writable<boolean>;
|
||||
isPressed: Readable<boolean>;
|
||||
/** A Svelte Action which handles applying the event listeners to the element. */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
pressAction: (node: HTMLElement | SVGElement) => PressActionReturn;
|
||||
@@ -860,7 +860,7 @@ export function initPress(config?: PressConfig): PressResult {
|
||||
|
||||
return {
|
||||
pressAction,
|
||||
isPressed
|
||||
isPressed: readonly(isPressed)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -916,21 +916,21 @@ function createEvent(target: FocusableElement, e: EventBase): EventBase {
|
||||
};
|
||||
}
|
||||
|
||||
interface Rect {
|
||||
type Rect = {
|
||||
top: number;
|
||||
right: number;
|
||||
bottom: number;
|
||||
left: number;
|
||||
}
|
||||
};
|
||||
|
||||
interface EventPoint {
|
||||
type EventPoint = {
|
||||
clientX: number;
|
||||
clientY: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
radiusX?: number;
|
||||
radiusY?: number;
|
||||
}
|
||||
};
|
||||
|
||||
function getPointClientRect(point: EventPoint): Rect {
|
||||
let offsetX = 0;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Portions of the code in this file are based on code from Adobe.
|
||||
// Original licensing for the following can be found:
|
||||
// See https://github.com/adobe/react-spectrum
|
||||
|
||||
export type PointerType = 'mouse' | 'pen' | 'touch' | 'keyboard' | 'virtual';
|
||||
|
||||
export interface PressEvent {
|
||||
@@ -27,46 +26,7 @@ export interface PressEvent {
|
||||
continuePropagation(): void;
|
||||
}
|
||||
|
||||
export interface LongPressEvent extends Omit<PressEvent, 'type' | 'continuePropagation'> {
|
||||
/** The type of long press event being fired. */
|
||||
type: 'longpressstart' | 'longpressend' | 'longpress';
|
||||
}
|
||||
|
||||
export interface HoverEvent {
|
||||
/** The type of hover event being fired. */
|
||||
type: 'hoverstart' | 'hoverend';
|
||||
/** The pointer type that triggered the hover event. */
|
||||
pointerType: 'mouse' | 'pen';
|
||||
/** The target element of the hover event. */
|
||||
target: HTMLElement;
|
||||
}
|
||||
|
||||
export interface KeyboardEvents {
|
||||
/** Handler that is called when a key is pressed. */
|
||||
onKeyDown?: (e: KeyboardEvent) => void;
|
||||
/** Handler that is called when a key is released. */
|
||||
onKeyUp?: (e: KeyboardEvent) => void;
|
||||
}
|
||||
|
||||
export interface FocusEvents {
|
||||
/** Handler that is called when the element receives focus. */
|
||||
onFocus?: (e: FocusEvent) => void;
|
||||
/** Handler that is called when the element loses focus. */
|
||||
onBlur?: (e: FocusEvent) => void;
|
||||
/** Handler that is called when the element's focus status changes. */
|
||||
onFocusChange?: (isFocused: boolean) => void;
|
||||
}
|
||||
|
||||
export interface HoverEvents {
|
||||
/** Handler that is called when a hover interaction starts. */
|
||||
onHoverStart?: (e: HoverEvent) => void;
|
||||
/** Handler that is called when a hover interaction ends. */
|
||||
onHoverEnd?: (e: HoverEvent) => void;
|
||||
/** Handler that is called when the hover state changes. */
|
||||
onHoverChange?: (isHovering: boolean) => void;
|
||||
}
|
||||
|
||||
export type PressEvents = {
|
||||
export type PressHandlers = {
|
||||
/** Handler that is called when the press is released over the target. */
|
||||
onPress?: (e: PressEvent) => void;
|
||||
/** Handler that is called when a press interaction starts. */
|
||||
@@ -84,63 +44,3 @@ export type PressEvents = {
|
||||
*/
|
||||
onPressUp?: (e: PressEvent) => void;
|
||||
};
|
||||
|
||||
export interface FocusableProps extends FocusEvents, KeyboardEvents {
|
||||
/** Whether the element should receive focus on render. */
|
||||
autoFocus?: boolean;
|
||||
}
|
||||
|
||||
interface BaseMoveEvent {
|
||||
/** The pointer type that triggered the move event. */
|
||||
pointerType: PointerType;
|
||||
/** Whether the shift keyboard modifier was held during the move event. */
|
||||
shiftKey: boolean;
|
||||
/** Whether the ctrl keyboard modifier was held during the move event. */
|
||||
ctrlKey: boolean;
|
||||
/** Whether the meta keyboard modifier was held during the move event. */
|
||||
metaKey: boolean;
|
||||
/** Whether the alt keyboard modifier was held during the move event. */
|
||||
altKey: boolean;
|
||||
}
|
||||
|
||||
export interface MoveStartEvent extends BaseMoveEvent {
|
||||
/** The type of move event being fired. */
|
||||
type: 'movestart';
|
||||
}
|
||||
|
||||
export interface MoveMoveEvent extends BaseMoveEvent {
|
||||
/** The type of move event being fired. */
|
||||
type: 'move';
|
||||
/** The amount moved in the X direction since the last event. */
|
||||
deltaX: number;
|
||||
/** The amount moved in the Y direction since the last event. */
|
||||
deltaY: number;
|
||||
}
|
||||
|
||||
export interface MoveEndEvent extends BaseMoveEvent {
|
||||
/** The type of move event being fired. */
|
||||
type: 'moveend';
|
||||
}
|
||||
|
||||
export type MoveEvent = MoveStartEvent | MoveMoveEvent | MoveEndEvent;
|
||||
|
||||
export interface MoveEvents {
|
||||
/** Handler that is called when a move interaction starts. */
|
||||
onMoveStart?: (e: MoveStartEvent) => void;
|
||||
/** Handler that is called when the element is moved. */
|
||||
onMove?: (e: MoveMoveEvent) => void;
|
||||
/** Handler that is called when a move interaction ends. */
|
||||
onMoveEnd?: (e: MoveEndEvent) => void;
|
||||
}
|
||||
|
||||
export interface ScrollEvent {
|
||||
/** The amount moved in the X direction since the last event. */
|
||||
deltaX: number;
|
||||
/** The amount moved in the Y direction since the last event. */
|
||||
deltaY: number;
|
||||
}
|
||||
|
||||
export interface ScrollEvents {
|
||||
/** Handler that is called when the scroll wheel moves. */
|
||||
onScroll?: (e: ScrollEvent) => void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user