@finsweet/webflow-apps-utils 1.0.24 → 1.0.25
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/dist/ui/components/color-picker/ColorPicker.svelte +14 -23
- package/dist/ui/components/color-picker/ColorSelect.svelte +8 -1
- package/dist/ui/components/color-picker/ColorSelect.svelte.d.ts +1 -0
- package/dist/ui/components/tooltip/Tooltip.svelte +10 -0
- package/dist/ui/components/tooltip/Tooltip.svelte.d.ts +1 -0
- package/package.json +1 -1
|
@@ -50,28 +50,6 @@
|
|
|
50
50
|
id
|
|
51
51
|
}: Props = $props();
|
|
52
52
|
|
|
53
|
-
// Remove local inputValue state
|
|
54
|
-
// let inputValue = $state(color);
|
|
55
|
-
|
|
56
|
-
// Helper: normalize hex to 6-digit uppercase
|
|
57
|
-
// function normalizeHex(value: string): string {
|
|
58
|
-
// if (/^#[A-Fa-f0-9]{3}$/.test(value)) {
|
|
59
|
-
// return (
|
|
60
|
-
// '#' +
|
|
61
|
-
// value
|
|
62
|
-
// .slice(1)
|
|
63
|
-
// .split('')
|
|
64
|
-
// .map((c) => c + c)
|
|
65
|
-
// .join('')
|
|
66
|
-
// .toUpperCase()
|
|
67
|
-
// );
|
|
68
|
-
// }
|
|
69
|
-
// if (/^#[A-Fa-f0-9]{6}$/.test(value)) {
|
|
70
|
-
// return value.toUpperCase();
|
|
71
|
-
// }
|
|
72
|
-
// return value;
|
|
73
|
-
// }
|
|
74
|
-
|
|
75
53
|
function isValidColor(value: string): boolean {
|
|
76
54
|
const hexRegex = /^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/;
|
|
77
55
|
return hexRegex.test(value.startsWith('#') ? value.slice(1) : value);
|
|
@@ -211,11 +189,19 @@
|
|
|
211
189
|
color = fullColor.hex;
|
|
212
190
|
}
|
|
213
191
|
|
|
192
|
+
function handleDragEnd() {
|
|
193
|
+
// Signal the tooltip to ignore the next click event
|
|
194
|
+
// This prevents the tooltip from closing when dragging and releasing outside
|
|
195
|
+
tooltipRef?.ignoreNextClickEvent?.();
|
|
196
|
+
}
|
|
197
|
+
|
|
214
198
|
let showColorSelect = $state(defaultShowColorSelect);
|
|
199
|
+
let tooltipRef: { ignoreNextClickEvent?: () => void } | undefined = $state();
|
|
215
200
|
</script>
|
|
216
201
|
|
|
217
202
|
<div class="color-picker">
|
|
218
203
|
<Tooltip
|
|
204
|
+
bind:this={tooltipRef}
|
|
219
205
|
listener="click"
|
|
220
206
|
listenerout="click"
|
|
221
207
|
showArrow={false}
|
|
@@ -235,7 +221,7 @@
|
|
|
235
221
|
{/snippet}
|
|
236
222
|
{#snippet tooltip()}
|
|
237
223
|
{#if showColorSelect}
|
|
238
|
-
<ColorSelect bind:color oncolorchange={handleFullColorChange} />
|
|
224
|
+
<ColorSelect bind:color oncolorchange={handleFullColorChange} ondragend={handleDragEnd} />
|
|
239
225
|
{/if}
|
|
240
226
|
{/snippet}
|
|
241
227
|
</Tooltip>
|
|
@@ -275,6 +261,11 @@
|
|
|
275
261
|
0px 4px 4px -4px rgba(0, 0, 0, 0.17) inset,
|
|
276
262
|
0px 3px 3px -3px rgba(0, 0, 0, 0.17) inset,
|
|
277
263
|
0px 1px 1px -1px rgba(0, 0, 0, 0.13) inset;
|
|
264
|
+
|
|
265
|
+
user-select: none;
|
|
266
|
+
-webkit-user-select: none;
|
|
267
|
+
-moz-user-select: none;
|
|
268
|
+
-ms-user-select: none;
|
|
278
269
|
}
|
|
279
270
|
|
|
280
271
|
.color-picker__swatch {
|
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
alpha: number;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
let {
|
|
15
|
+
let {
|
|
16
|
+
color = $bindable('#fff'),
|
|
17
|
+
oncolorchange,
|
|
18
|
+
ondragend
|
|
19
|
+
} = $props<{
|
|
16
20
|
color?: string;
|
|
17
21
|
oncolorchange?: (fullColor: ColorObject) => void;
|
|
22
|
+
ondragend?: () => void;
|
|
18
23
|
}>();
|
|
19
24
|
|
|
20
25
|
function setColor(newColor: string) {
|
|
@@ -510,6 +515,8 @@
|
|
|
510
515
|
if (isDragging) {
|
|
511
516
|
isDragging = false;
|
|
512
517
|
dragTarget = null;
|
|
518
|
+
// Signal that a drag operation just ended
|
|
519
|
+
ondragend?.();
|
|
513
520
|
}
|
|
514
521
|
|
|
515
522
|
// Reset drag detection state
|
|
@@ -24,6 +24,7 @@ interface ColorObject {
|
|
|
24
24
|
type $$ComponentProps = {
|
|
25
25
|
color?: string;
|
|
26
26
|
oncolorchange?: (fullColor: ColorObject) => void;
|
|
27
|
+
ondragend?: () => void;
|
|
27
28
|
};
|
|
28
29
|
declare const ColorSelect: import("svelte").Component<$$ComponentProps, {}, "color">;
|
|
29
30
|
type ColorSelect = ReturnType<typeof ColorSelect>;
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
let arrowElement: HTMLDivElement | undefined = $state();
|
|
65
65
|
let observer: MutationObserver | null = null;
|
|
66
66
|
let documentClickListener: ((event: MouseEvent) => void) | null = null;
|
|
67
|
+
let ignoreNextClick = $state(false);
|
|
67
68
|
const tooltipId = `tooltip-${uuidv4()}`;
|
|
68
69
|
|
|
69
70
|
/**
|
|
@@ -214,6 +215,12 @@
|
|
|
214
215
|
|
|
215
216
|
// Store reference to the click handler for cleanup
|
|
216
217
|
documentClickListener = (event: MouseEvent) => {
|
|
218
|
+
// Ignore clicks that happen immediately after a drag operation
|
|
219
|
+
if (ignoreNextClick) {
|
|
220
|
+
ignoreNextClick = false;
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
217
224
|
if (
|
|
218
225
|
tooltipElement &&
|
|
219
226
|
toggle &&
|
|
@@ -263,6 +270,9 @@
|
|
|
263
270
|
|
|
264
271
|
export const show = () => tooltipInstance?.showTooltip();
|
|
265
272
|
export const hide = () => tooltipInstance?.hideTooltip();
|
|
273
|
+
export const ignoreNextClickEvent = () => {
|
|
274
|
+
ignoreNextClick = true;
|
|
275
|
+
};
|
|
266
276
|
|
|
267
277
|
// Svelte 5 effect for hidden prop
|
|
268
278
|
$effect(() => {
|
|
@@ -3,6 +3,7 @@ import type { TooltipProps } from './types';
|
|
|
3
3
|
declare const Tooltip: Component<TooltipProps, {
|
|
4
4
|
show: () => void | undefined;
|
|
5
5
|
hide: () => void | undefined;
|
|
6
|
+
ignoreNextClickEvent: () => void;
|
|
6
7
|
}, "hidden" | "isActive">;
|
|
7
8
|
type Tooltip = ReturnType<typeof Tooltip>;
|
|
8
9
|
export default Tooltip;
|