Comparing version 0.0.114 to 0.0.115
import { SvelteComponentTyped } from "svelte"; | ||
declare const __propDef: { | ||
props: { | ||
[x: string]: any; | ||
style?: string | undefined; | ||
@@ -28,24 +27,2 @@ secondary?: boolean | undefined; | ||
events: { | ||
auxclick: MouseEvent; | ||
click: MouseEvent; | ||
contextmenu: MouseEvent; | ||
dblclick: MouseEvent; | ||
mousedown: MouseEvent; | ||
mouseenter: MouseEvent; | ||
mouseleave: MouseEvent; | ||
mousemove: MouseEvent; | ||
mouseout: MouseEvent; | ||
mouseover: MouseEvent; | ||
mouseup: MouseEvent; | ||
select: Event; | ||
wheel: WheelEvent; | ||
drag: DragEvent; | ||
dragend: DragEvent; | ||
dragenter: DragEvent; | ||
dragleave: DragEvent; | ||
dragover: DragEvent; | ||
dragstart: DragEvent; | ||
drop: DragEvent; | ||
scroll: Event; | ||
} & { | ||
[evt: string]: CustomEvent<any>; | ||
@@ -52,0 +29,0 @@ }; |
@@ -14,24 +14,2 @@ import { SvelteComponentTyped } from "svelte"; | ||
events: { | ||
auxclick: MouseEvent; | ||
click: MouseEvent; | ||
contextmenu: MouseEvent; | ||
dblclick: MouseEvent; | ||
mousedown: MouseEvent; | ||
mouseenter: MouseEvent; | ||
mouseleave: MouseEvent; | ||
mousemove: MouseEvent; | ||
mouseout: MouseEvent; | ||
mouseover: MouseEvent; | ||
mouseup: MouseEvent; | ||
select: Event; | ||
wheel: WheelEvent; | ||
drag: DragEvent; | ||
dragend: DragEvent; | ||
dragenter: DragEvent; | ||
dragleave: DragEvent; | ||
dragover: DragEvent; | ||
dragstart: DragEvent; | ||
drop: DragEvent; | ||
scroll: Event; | ||
} & { | ||
[evt: string]: CustomEvent<any>; | ||
@@ -38,0 +16,0 @@ }; |
@@ -12,23 +12,2 @@ import { SvelteComponentTyped } from "svelte"; | ||
events: { | ||
auxclick: MouseEvent; | ||
click: MouseEvent; | ||
contextmenu: MouseEvent; | ||
dblclick: MouseEvent; | ||
mousedown: MouseEvent; | ||
mouseenter: MouseEvent; | ||
mouseleave: MouseEvent; | ||
mousemove: MouseEvent; | ||
mouseout: MouseEvent; | ||
mouseover: MouseEvent; | ||
mouseup: MouseEvent; | ||
select: Event; | ||
wheel: WheelEvent; | ||
drag: DragEvent; | ||
dragend: DragEvent; | ||
dragenter: DragEvent; | ||
dragleave: DragEvent; | ||
dragover: DragEvent; | ||
dragstart: DragEvent; | ||
drop: DragEvent; | ||
scroll: Event; | ||
change: Event; | ||
@@ -35,0 +14,0 @@ } & { |
@@ -12,24 +12,2 @@ import { SvelteComponentTyped } from "svelte"; | ||
events: { | ||
auxclick: MouseEvent; | ||
click: MouseEvent; | ||
contextmenu: MouseEvent; | ||
dblclick: MouseEvent; | ||
mousedown: MouseEvent; | ||
mouseenter: MouseEvent; | ||
mouseleave: MouseEvent; | ||
mousemove: MouseEvent; | ||
mouseout: MouseEvent; | ||
mouseover: MouseEvent; | ||
mouseup: MouseEvent; | ||
select: Event; | ||
wheel: WheelEvent; | ||
drag: DragEvent; | ||
dragend: DragEvent; | ||
dragenter: DragEvent; | ||
dragleave: DragEvent; | ||
dragover: DragEvent; | ||
dragstart: DragEvent; | ||
drop: DragEvent; | ||
scroll: Event; | ||
} & { | ||
[evt: string]: CustomEvent<any>; | ||
@@ -36,0 +14,0 @@ }; |
@@ -13,24 +13,2 @@ import { SvelteComponentTyped } from "svelte"; | ||
events: { | ||
auxclick: MouseEvent; | ||
click: MouseEvent; | ||
contextmenu: MouseEvent; | ||
dblclick: MouseEvent; | ||
mousedown: MouseEvent; | ||
mouseenter: MouseEvent; | ||
mouseleave: MouseEvent; | ||
mousemove: MouseEvent; | ||
mouseout: MouseEvent; | ||
mouseover: MouseEvent; | ||
mouseup: MouseEvent; | ||
select: Event; | ||
wheel: WheelEvent; | ||
drag: DragEvent; | ||
dragend: DragEvent; | ||
dragenter: DragEvent; | ||
dragleave: DragEvent; | ||
dragover: DragEvent; | ||
dragstart: DragEvent; | ||
drop: DragEvent; | ||
scroll: Event; | ||
} & { | ||
[evt: string]: CustomEvent<any>; | ||
@@ -37,0 +15,0 @@ }; |
@@ -23,29 +23,5 @@ import { SvelteComponentTyped } from "svelte"; | ||
events: { | ||
auxclick: MouseEvent; | ||
click: MouseEvent; | ||
contextmenu: MouseEvent; | ||
dblclick: MouseEvent; | ||
mousedown: MouseEvent; | ||
mouseenter: MouseEvent; | ||
mouseleave: MouseEvent; | ||
mousemove: MouseEvent; | ||
mouseout: MouseEvent; | ||
mouseover: MouseEvent; | ||
mouseup: MouseEvent; | ||
select: Event; | ||
wheel: WheelEvent; | ||
drag: DragEvent; | ||
dragend: DragEvent; | ||
dragenter: DragEvent; | ||
dragleave: DragEvent; | ||
dragover: DragEvent; | ||
dragstart: DragEvent; | ||
drop: DragEvent; | ||
scroll: Event; | ||
} & { | ||
[evt: string]: CustomEvent<any>; | ||
}; | ||
slots: { | ||
default: {}; | ||
}; | ||
slots: {}; | ||
}; | ||
@@ -52,0 +28,0 @@ export type IconButtonProps = typeof __propDef.props; |
@@ -6,2 +6,3 @@ import { SvelteComponentTyped } from "svelte"; | ||
outlined?: boolean | undefined; | ||
plain?: boolean | undefined; | ||
placeholder: string; | ||
@@ -25,6 +26,2 @@ value?: string | undefined; | ||
events: { | ||
change: Event; | ||
keydown: KeyboardEvent; | ||
focus: FocusEvent; | ||
blur: FocusEvent; | ||
submit: CustomEvent<any>; | ||
@@ -31,0 +28,0 @@ } & { |
@@ -13,24 +13,2 @@ import { SvelteComponentTyped } from "svelte"; | ||
events: { | ||
auxclick: MouseEvent; | ||
click: MouseEvent; | ||
contextmenu: MouseEvent; | ||
dblclick: MouseEvent; | ||
mousedown: MouseEvent; | ||
mouseenter: MouseEvent; | ||
mouseleave: MouseEvent; | ||
mousemove: MouseEvent; | ||
mouseout: MouseEvent; | ||
mouseover: MouseEvent; | ||
mouseup: MouseEvent; | ||
select: Event; | ||
wheel: WheelEvent; | ||
drag: DragEvent; | ||
dragend: DragEvent; | ||
dragenter: DragEvent; | ||
dragleave: DragEvent; | ||
dragover: DragEvent; | ||
dragstart: DragEvent; | ||
drop: DragEvent; | ||
scroll: Event; | ||
} & { | ||
[evt: string]: CustomEvent<any>; | ||
@@ -37,0 +15,0 @@ }; |
{ | ||
"name": "nunui", | ||
"description": "Svelte UI Component Library", | ||
"version": "0.0.114", | ||
"version": "0.0.115", | ||
"devDependencies": { | ||
@@ -6,0 +6,0 @@ "@sveltejs/adapter-static": "^3.0.1", |
@@ -5,2 +5,3 @@ import { SvelteComponentTyped } from "svelte"; | ||
outlined?: boolean | undefined; | ||
plain?: boolean | undefined; | ||
placeholder: string; | ||
@@ -21,4 +22,2 @@ error?: string | undefined; | ||
events: { | ||
change: Event; | ||
keydown: KeyboardEvent; | ||
select: CustomEvent<any>; | ||
@@ -25,0 +24,0 @@ } & { |
@@ -1,4 +0,3 @@ | ||
import { SvelteComponent } from 'svelte/internal'; | ||
export default function <T extends SvelteComponent | Element>(node: HTMLElement, additionalEvents?: string[]): { | ||
destroy(): void; | ||
export default function forward(): (node: HTMLElement | SVGElement) => { | ||
destroy: () => void; | ||
}; |
@@ -1,37 +0,129 @@ | ||
import { SvelteComponent, bubble, listen, get_current_component } from 'svelte/internal'; | ||
import { onMount, onDestroy } from 'svelte'; | ||
export default function (node, additionalEvents = []) { | ||
const events = [ | ||
'focus', 'blur', | ||
'fullscreenchange', 'fullscreenerror', 'scroll', | ||
'cut', 'copy', 'paste', | ||
'keydown', 'keypress', 'keyup', | ||
'auxclick', 'click', 'contextmenu', 'dblclick', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseover', 'mouseout', 'mouseup', 'pointerlockchange', 'pointerlockerror', 'select', 'wheel', | ||
'drag', 'dragend', 'dragenter', 'dragstart', 'dragleave', 'dragover', 'drop', | ||
'touchcancel', 'touchend', 'touchmove', 'touchstart', | ||
'pointerover', 'pointerenter', 'pointerdown', 'pointermove', 'pointerup', 'pointercancel', 'pointerout', 'pointerleave', 'gotpointercapture', 'lostpointercapture', | ||
...additionalEvents | ||
]; | ||
import { get_current_component } from 'svelte/internal'; | ||
export default function forward() { | ||
const component = get_current_component(); | ||
const destructors = []; | ||
function forward(e) { | ||
bubble(component, e); | ||
let $on; | ||
const events = []; | ||
component.$on = (fullEventType, callback) => { | ||
let destructor = () => { | ||
}; | ||
if ($on) { | ||
destructor = $on(fullEventType, callback); | ||
} | ||
else { | ||
events.push([fullEventType, callback]); | ||
} | ||
return destructor; | ||
}; | ||
function bubble(e) { | ||
const callbacks = component.$$.callbacks[e.type]; | ||
if (callbacks) { | ||
callbacks.slice().forEach((fn) => fn.call(component, e)); | ||
} | ||
} | ||
if (node instanceof Element) { | ||
events.forEach((event) => { | ||
destructors.push(listen(node, event, forward)); | ||
}); | ||
} | ||
else { | ||
events.forEach((event) => { | ||
destructors.push(component.$on(event, forward)); | ||
}); | ||
} | ||
return { | ||
destroy() { | ||
while (destructors.length) { | ||
destructors.pop()?.(); | ||
return (node) => { | ||
const destructors = []; | ||
const forwardDestructors = {}; | ||
$on = (fullEventType, callback) => { | ||
const { eventType, modifiers } = parseEventModifiers(fullEventType); | ||
let handler = callback; | ||
const addEventListenerOptions = {}; | ||
if (modifiers.passive) { | ||
addEventListenerOptions.passive = true; | ||
} | ||
if (modifiers.nonpassive) { | ||
addEventListenerOptions.passive = false; | ||
} | ||
if (modifiers.capture) { | ||
addEventListenerOptions.capture = true; | ||
} | ||
if (modifiers.once) { | ||
addEventListenerOptions.once = true; | ||
} | ||
if (modifiers.preventDefault) { | ||
handler = prevent_default(handler); | ||
} | ||
if (modifiers.stopPropagation) { | ||
handler = stop_propagation(handler); | ||
} | ||
if (modifiers.stopImmediatePropagation) { | ||
handler = stop_immediate_propagation(handler); | ||
} | ||
if (modifiers.self) { | ||
handler = self_event(node, handler); | ||
} | ||
if (modifiers.trusted) { | ||
handler = trusted_event(handler); | ||
} | ||
const off = listen(node, eventType, handler, addEventListenerOptions); | ||
const destructor = () => { | ||
off(); | ||
const idx = destructors.indexOf(destructor); | ||
if (idx > -1) { | ||
destructors.splice(idx, 1); | ||
} | ||
}; | ||
destructors.push(destructor); | ||
if (!(eventType in forwardDestructors)) { | ||
forwardDestructors[eventType] = listen(node, eventType, bubble); | ||
} | ||
return destructor; | ||
}; | ||
for (let i = 0; i < events.length; i++) { | ||
$on(events[i][0], events[i][1]); | ||
} | ||
return { | ||
destroy: () => { | ||
destructors.forEach((destructor) => destructor()); | ||
Object.values(forwardDestructors).forEach((destructor) => destructor()); | ||
} | ||
}; | ||
}; | ||
} | ||
function parseEventModifiers(fullEventType) { | ||
const parts = fullEventType.split('$'); | ||
const eventType = parts[0]; | ||
const eventModifiers = parts.slice(1); | ||
const modifiers = eventModifiers.reduce((acc, modifier) => { | ||
acc[modifier] = true; | ||
return acc; | ||
}, {}); | ||
return { eventType, modifiers }; | ||
} | ||
function listen(node, event, handler, options) { | ||
node.addEventListener(event, handler, options); | ||
return () => node.removeEventListener(event, handler, options); | ||
} | ||
function prevent_default(fn) { | ||
return function (event) { | ||
event.preventDefault(); | ||
return fn.call(this, event); | ||
}; | ||
} | ||
function stop_propagation(fn) { | ||
return function (event) { | ||
event.stopPropagation(); | ||
return fn.call(this, event); | ||
}; | ||
} | ||
function stop_immediate_propagation(fn) { | ||
return function (event) { | ||
event.stopImmediatePropagation(); | ||
return fn.call(this, event); | ||
}; | ||
} | ||
function self_event(node, fn) { | ||
return function (event) { | ||
if (event.target !== node) { | ||
return; | ||
} | ||
return fn.call(this, event); | ||
}; | ||
} | ||
function trusted_event(fn) { | ||
return function (event) { | ||
if (!event.isTrusted) { | ||
return; | ||
} | ||
return fn.call(this, event); | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
137062
1193