@hashrytech/quick-components-kit 0.19.13 → 0.19.15
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 +12 -0
- package/dist/components/text-input/TextInput.svelte +1 -1
- package/dist/components/text-input/TextInput.svelte.d.ts +1 -1
- package/dist/functions/click-outside.d.ts +22 -0
- package/dist/functions/click-outside.js +38 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -30,7 +30,7 @@ export type InputMode = "none" | "text" | "decimal" | "numeric" | "tel" | "searc
|
|
|
30
30
|
export type TextInputProps = {
|
|
31
31
|
id: string;
|
|
32
32
|
name?: string;
|
|
33
|
-
value?: string | number;
|
|
33
|
+
value?: string | number | null;
|
|
34
34
|
type?: TextInputType;
|
|
35
35
|
placeholder?: string;
|
|
36
36
|
labelText?: string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ClickOutsideEvent = MouseEvent | TouchEvent | PointerEvent;
|
|
2
|
+
export interface ClickOutsideOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Function to call when clicking outside
|
|
5
|
+
*/
|
|
6
|
+
callback: (event: ClickOutsideEvent) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Array of element IDs to ignore
|
|
9
|
+
*/
|
|
10
|
+
ignoreIds?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Whether the action is enabled
|
|
13
|
+
*/
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Triggers callback when clicking outside the element.
|
|
18
|
+
*/
|
|
19
|
+
export declare function clickOutside(node: HTMLElement, options: ClickOutsideOptions): {
|
|
20
|
+
update(options: ClickOutsideOptions): void;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Triggers callback when clicking outside the element.
|
|
3
|
+
*/
|
|
4
|
+
export function clickOutside(node, options) {
|
|
5
|
+
let { callback, ignoreIds = [], enabled = true } = options;
|
|
6
|
+
const handleClick = (event) => {
|
|
7
|
+
if (!enabled)
|
|
8
|
+
return;
|
|
9
|
+
const target = event.target;
|
|
10
|
+
if (!target)
|
|
11
|
+
return;
|
|
12
|
+
// Click inside the node → ignore
|
|
13
|
+
if (node.contains(target))
|
|
14
|
+
return;
|
|
15
|
+
// Click is on an ignored element or one of its parents → ignore
|
|
16
|
+
if (ignoreIds.length > 0) {
|
|
17
|
+
let element = target;
|
|
18
|
+
while (element) {
|
|
19
|
+
if (element.id && ignoreIds.includes(element.id)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
element = element.parentElement;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Click is outside and not on ignored element
|
|
26
|
+
callback(event);
|
|
27
|
+
};
|
|
28
|
+
// Attach listener
|
|
29
|
+
document.addEventListener('click', handleClick, true);
|
|
30
|
+
return {
|
|
31
|
+
update(newOptions) {
|
|
32
|
+
({ callback, ignoreIds = [], enabled = true } = newOptions);
|
|
33
|
+
},
|
|
34
|
+
destroy() {
|
|
35
|
+
document.removeEventListener('click', handleClick, true);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from './modules/crypto.js';
|
|
|
25
25
|
export * from './modules/problem-details.js';
|
|
26
26
|
export * from './functions/object-to-form-data.js';
|
|
27
27
|
export * from './functions/compare-objects.js';
|
|
28
|
+
export * from './functions/click-outside.js';
|
|
28
29
|
export * from './ui/headers/header-1/index.js';
|
|
29
30
|
export * from './ui/footers/footer-1/index.js';
|
|
30
31
|
export * from './ui/banners/banner-1/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// Reexport your entry components here
|
|
2
1
|
// lib/index.js
|
|
3
2
|
export * from './components/icon/index.js';
|
|
4
3
|
export * from './components/text-input/index.js';
|
|
@@ -15,18 +14,23 @@ export * from './components/checkbox/index.js';
|
|
|
15
14
|
export * from './components/tab-navigation/index.js';
|
|
16
15
|
export * from './components/portal/index.js';
|
|
17
16
|
export * from './components/table/index.js';
|
|
17
|
+
// Actions
|
|
18
18
|
export * from './actions/disable-scroll.js';
|
|
19
19
|
export * from './actions/on-keydown.js';
|
|
20
20
|
export * from './actions/lock-scroll.js';
|
|
21
21
|
export * from './actions/scroll-to.js';
|
|
22
22
|
export * from './actions/stop-interaction.js';
|
|
23
23
|
export * from './actions/portal.js';
|
|
24
|
+
// Modules
|
|
24
25
|
export * from './modules/fetch-client.js';
|
|
25
26
|
export * from './modules/api-proxy.js';
|
|
26
27
|
export * from './modules/crypto.js';
|
|
27
28
|
export * from './modules/problem-details.js';
|
|
29
|
+
// Functions
|
|
28
30
|
export * from './functions/object-to-form-data.js';
|
|
29
31
|
export * from './functions/compare-objects.js';
|
|
32
|
+
export * from './functions/click-outside.js';
|
|
33
|
+
// UI Components
|
|
30
34
|
export * from './ui/headers/header-1/index.js';
|
|
31
35
|
export * from './ui/footers/footer-1/index.js';
|
|
32
36
|
export * from './ui/banners/banner-1/index.js';
|