@finsweet/webflow-apps-utils 1.0.22 → 1.0.24

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.
@@ -89,8 +89,11 @@
89
89
  .join('');
90
90
  }
91
91
 
92
- // Remove alpha channel if present (8-digit hex)
92
+ // Extract alpha channel if present (8-digit hex)
93
+ let alpha = 100;
93
94
  if (normalizedHex.length === 8) {
95
+ const alphaHex = normalizedHex.substring(6, 8);
96
+ alpha = Math.round((parseInt(alphaHex, 16) / 255) * 100);
94
97
  normalizedHex = normalizedHex.substring(0, 6);
95
98
  }
96
99
 
@@ -203,8 +206,9 @@
203
206
 
204
207
  function handleFullColorChange(fullColor: ColorObject) {
205
208
  oncolorchange?.(fullColor);
206
- const normalizedValue = normalizeHex(fullColor.hex);
207
- color = normalizedValue;
209
+ // Preserve the alpha channel by using the full hex value with alpha
210
+ // The fullColor.hex already includes the alpha channel if alpha < 100
211
+ color = fullColor.hex;
208
212
  }
209
213
 
210
214
  let showColorSelect = $state(defaultShowColorSelect);
@@ -108,6 +108,26 @@
108
108
  return normalizeHex(colorInput);
109
109
  }
110
110
 
111
+ // Helper function to extract alpha value from hex color
112
+ function extractAlphaFromHex(hexColor: string): number {
113
+ if (hexColor.startsWith('#') && hexColor.length === 9) {
114
+ // 8-digit hex with alpha channel (#RRGGBBAA)
115
+ const alphaHex = hexColor.slice(7, 9);
116
+ const alphaValue = parseInt(alphaHex, 16);
117
+ return Math.round((alphaValue / 255) * 100);
118
+ }
119
+ return 100; // Default to 100% opacity if no alpha channel
120
+ }
121
+
122
+ // Helper function to get hex without alpha channel
123
+ function getHexWithoutAlpha(hexColor: string): string {
124
+ if (hexColor.startsWith('#') && hexColor.length === 9) {
125
+ // Remove alpha channel from 8-digit hex
126
+ return hexColor.slice(0, 7);
127
+ }
128
+ return hexColor;
129
+ }
130
+
111
131
  // Color conversion utilities
112
132
  function hsbToRgb(h: number, s: number, b: number): [number, number, number] {
113
133
  h = h / 360;
@@ -377,6 +397,7 @@
377
397
  let hexInputValue = $state('');
378
398
  let isHexEditing = $state(false);
379
399
  let prevHexValue = $state('');
400
+ let isInitialized = $state(false);
380
401
 
381
402
  function handleHexFocus(event: FocusEvent) {
382
403
  prevHexValue = hexValue;
@@ -508,10 +529,18 @@
508
529
 
509
530
  // Watch for prop changes - FIXED: Better color normalization
510
531
  $effect(() => {
532
+ // Skip effect during initial mount to prevent overriding alpha
533
+ if (!isInitialized) return;
534
+
511
535
  const normalized = normalizeColorToHex(color);
512
- if (normalized !== hexValue) {
513
- hexValue = normalized;
514
- const [h, s, b] = hexToHsb(normalized);
536
+ // Extract alpha value from the original color if it has an alpha channel
537
+ const alphaFromColor = extractAlphaFromHex(color);
538
+
539
+ // Use hex without alpha for internal processing
540
+ const hexWithoutAlpha = getHexWithoutAlpha(normalized);
541
+ if (hexWithoutAlpha !== hexValue) {
542
+ hexValue = hexWithoutAlpha;
543
+ const [h, s, b] = hexToHsb(hexValue);
515
544
  hue = h;
516
545
  saturation = s;
517
546
  brightness = b;
@@ -519,6 +548,11 @@
519
548
  // Force position update after state changes
520
549
  setTimeout(() => updateColorPickerPosition(), 0);
521
550
  }
551
+
552
+ // Only update alpha if it's different from current alpha
553
+ if (alphaFromColor !== alpha) {
554
+ alpha = alphaFromColor;
555
+ }
522
556
  });
523
557
 
524
558
  let currentColor = $derived(
@@ -527,14 +561,19 @@
527
561
 
528
562
  onMount(() => {
529
563
  const normalized = normalizeColorToHex(color);
530
- hexValue = normalized;
531
- const [h, s, b] = hexToHsb(normalized);
564
+ // Extract alpha value from the original color if it has an alpha channel
565
+ const alphaFromColor = extractAlphaFromHex(color);
566
+ alpha = alphaFromColor;
567
+
568
+ // Use hex without alpha for internal processing
569
+ hexValue = getHexWithoutAlpha(normalized);
570
+ const [h, s, b] = hexToHsb(hexValue);
532
571
  hue = h;
533
572
  saturation = s;
534
573
  brightness = b;
535
574
  [rgbRed, rgbGreen, rgbBlue] = hsbToRgb(hue, saturation, brightness);
536
575
 
537
- console.log('ColorSelect mounted', { color });
576
+ console.log('ColorSelect mounted', { color, alpha: alphaFromColor });
538
577
  updateColor();
539
578
  // Delay position update to ensure DOM is ready
540
579
 
@@ -543,6 +582,9 @@
543
582
  document.addEventListener('mousemove', handleMouseMove);
544
583
  document.addEventListener('mouseup', handleMouseUp);
545
584
 
585
+ // Mark as initialized after setting up the initial state
586
+ isInitialized = true;
587
+
546
588
  return () => {
547
589
  document.removeEventListener('mousemove', handleMouseMove);
548
590
  document.removeEventListener('mouseup', handleMouseUp);
@@ -0,0 +1,14 @@
1
+ <svg width="100%" height="100%" viewBox="0 0 24 24" fill="none">
2
+ <g clip-path="url(#clip0_504_28)">
3
+ <path
4
+ d="M16
5
+ 11C17.66 11 18.99 9.66 18.99 8C18.99 6.34 17.66 5 16 5C14.34 5 13 6.34 13 8C13 9.66 14.34 11 16 11ZM8 11C9.66 11 10.99 9.66 10.99 8C10.99 6.34 9.66 5 8 5C6.34 5 5 6.34 5 8C5 9.66 6.34 11 8 11ZM8 13C5.67 13 1 14.17 1 16.5V19H15V16.5C15 14.17 10.33 13 8 13ZM16 13C15.71 13 15.38 13.02 15.03 13.05C16.19 13.89 17 15.02 17 16.5V19H23V16.5C23 14.17 18.33 13 16 13Z"
6
+ fill="currentColor"
7
+ ></path>
8
+ </g>
9
+ <defs>
10
+ <clipPath id="clip0_504_28">
11
+ <rect width="24" height="24" fill="currentColor"></rect>
12
+ </clipPath>
13
+ </defs>
14
+ </svg>
@@ -0,0 +1,26 @@
1
+ export default TeamIcon;
2
+ type TeamIcon = SvelteComponent<{
3
+ [x: string]: never;
4
+ }, {
5
+ [evt: string]: CustomEvent<any>;
6
+ }, {}> & {
7
+ $$bindings?: string | undefined;
8
+ };
9
+ declare const TeamIcon: $$__sveltets_2_IsomorphicComponent<{
10
+ [x: string]: never;
11
+ }, {
12
+ [evt: string]: CustomEvent<any>;
13
+ }, {}, {}, string>;
14
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
+ new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
16
+ $$bindings?: Bindings;
17
+ } & Exports;
18
+ (internal: unknown, props: {
19
+ $$events?: Events;
20
+ $$slots?: Slots;
21
+ }): Exports & {
22
+ $set?: any;
23
+ $on?: any;
24
+ };
25
+ z_$$bindings?: Bindings;
26
+ }
@@ -100,6 +100,7 @@ import Tablet from './Tablet.svelte';
100
100
  import TabletPreview from './TabletPreview.svelte';
101
101
  import TabNewIcon from './TabNewIcon.svelte';
102
102
  import TabsIcon from './TabsIcon.svelte';
103
+ import TeamIcon from './TeamIcon.svelte';
103
104
  import ThreeDotsIcon from './ThreeDotsIcon.svelte';
104
105
  import TimesIcon from './TimesIcon.svelte';
105
106
  import TooltipInfoCircleFilled from './TooltipInfoCircleFilled.svelte';
@@ -121,4 +122,4 @@ import WorkspaceIcon from './WorkspaceIcon.svelte';
121
122
  import XL from './XL.svelte';
122
123
  import XXL from './XXL.svelte';
123
124
  import XXXL from './XXXL.svelte';
124
- export { AccordionDownArrow, AccordionUpArrow, AccountIcon, ArrowIcon, BackIcon, BodyIcon, BookmarkIcon, BoxAddIcon, BrushIcon, BuilderEditIcon, BuilderIcon, CheckboxCheckedIcon, CheckCircleIcon, CheckCircleOutlinedIcon, CheckIcon, ChevronIcon, ChevronRightIcon, CircleIcon, CloseCircleIcon, CloseIcon, CMSIcon, CodeIcon, ComponentsIcon, CookieIcon, CopyIcon, CrossIcon, DeleteIcon, DeleteOutlinedIcon, Desktop, DesktopWithStar, DivBlock, DOMElement, EditIcon, ExpertIcon, EyeCancelIcon, EyeIcon, FavouriteIcon, FileUploadIcon, FilterIcon, FinsweetLibraryIcon, FinsweetLogoIcon, FinsweetLogoOutlineIcon, FolderIcon, FolderOutlinedIcon, FolderPlusIcon, FreeComponentIcon, GlobeIcon, HandPointUpIcon, HeartIcon, HeartIconOutlined, HelpAltIcon, HelpIcon, HomeIcon, InfoIcon, LineChartIcon, ListIcon, LockIcon, MessageIcon, MobileLandscape, MobilePortrait, NavigatorIcon, OpenBookIcon, PageDraftIcon, PageIcon, PageLockedIcon, PageOutlinedIcon, PageSectionIcon, Pencil, PencilOutlinedIcon, PinIcon, PlayIcon, PlusIcon, PreviewEyeIcon, ProfileIcon, PublishCancelIcon, PublishIcon, RefreshIcon, ReceiptIcon, RepairIcon, SaveIcon, SearchIcon, SelectIcon, SettingsIcon, SidebarToggleIcon, SliderAppIcon, SquareCheckIcon, StarIcon, StarOutlinedIcon, StaticContentIcon, SubtractIcon, TableAppIcon, Tablet, TabletPreview, TabNewIcon, TabsIcon, ThreeDotsIcon, TimesIcon, TooltipInfoCircleFilled, ToolTipInfoCircleIcon, TooltipInfoSquaredIcon, TriangleDownIcon, TriangleDownIconToggle, UndoIcon, UploadFileIcon, WarningCircleIcon, WarningCircleOutlineIcon, WarningTriangleIcon, WarningTriangleOutlineIcon, WebflowComponentIcon, WebflowComponentOutlinedIcon, WebflowInsightsIcon, WizedLogoIcon, WorkspaceIcon, XL, XXL, XXXL };
125
+ export { AccordionDownArrow, AccordionUpArrow, AccountIcon, ArrowIcon, BackIcon, BodyIcon, BookmarkIcon, BoxAddIcon, BrushIcon, BuilderEditIcon, BuilderIcon, CheckboxCheckedIcon, CheckCircleIcon, CheckCircleOutlinedIcon, CheckIcon, ChevronIcon, ChevronRightIcon, CircleIcon, CloseCircleIcon, CloseIcon, CMSIcon, CodeIcon, ComponentsIcon, CookieIcon, CopyIcon, CrossIcon, DeleteIcon, DeleteOutlinedIcon, Desktop, DesktopWithStar, DivBlock, DOMElement, EditIcon, ExpertIcon, EyeCancelIcon, EyeIcon, FavouriteIcon, FileUploadIcon, FilterIcon, FinsweetLibraryIcon, FinsweetLogoIcon, FinsweetLogoOutlineIcon, FolderIcon, FolderOutlinedIcon, FolderPlusIcon, FreeComponentIcon, GlobeIcon, HandPointUpIcon, HeartIcon, HeartIconOutlined, HelpAltIcon, HelpIcon, HomeIcon, InfoIcon, LineChartIcon, ListIcon, LockIcon, MessageIcon, MobileLandscape, MobilePortrait, NavigatorIcon, OpenBookIcon, PageDraftIcon, PageIcon, PageLockedIcon, PageOutlinedIcon, PageSectionIcon, Pencil, PencilOutlinedIcon, PinIcon, PlayIcon, PlusIcon, PreviewEyeIcon, ProfileIcon, PublishCancelIcon, PublishIcon, RefreshIcon, ReceiptIcon, RepairIcon, SaveIcon, SearchIcon, SelectIcon, SettingsIcon, SidebarToggleIcon, SliderAppIcon, SquareCheckIcon, StarIcon, StarOutlinedIcon, StaticContentIcon, SubtractIcon, TableAppIcon, Tablet, TabletPreview, TabNewIcon, TabsIcon, TeamIcon, ThreeDotsIcon, TimesIcon, TooltipInfoCircleFilled, ToolTipInfoCircleIcon, TooltipInfoSquaredIcon, TriangleDownIcon, TriangleDownIconToggle, UndoIcon, UploadFileIcon, WarningCircleIcon, WarningCircleOutlineIcon, WarningTriangleIcon, WarningTriangleOutlineIcon, WebflowComponentIcon, WebflowComponentOutlinedIcon, WebflowInsightsIcon, WizedLogoIcon, WorkspaceIcon, XL, XXL, XXXL };
@@ -100,6 +100,7 @@ import Tablet from './Tablet.svelte';
100
100
  import TabletPreview from './TabletPreview.svelte';
101
101
  import TabNewIcon from './TabNewIcon.svelte';
102
102
  import TabsIcon from './TabsIcon.svelte';
103
+ import TeamIcon from './TeamIcon.svelte';
103
104
  import ThreeDotsIcon from './ThreeDotsIcon.svelte';
104
105
  import TimesIcon from './TimesIcon.svelte';
105
106
  import TooltipInfoCircleFilled from './TooltipInfoCircleFilled.svelte';
@@ -121,4 +122,4 @@ import WorkspaceIcon from './WorkspaceIcon.svelte';
121
122
  import XL from './XL.svelte';
122
123
  import XXL from './XXL.svelte';
123
124
  import XXXL from './XXXL.svelte';
124
- export { AccordionDownArrow, AccordionUpArrow, AccountIcon, ArrowIcon, BackIcon, BodyIcon, BookmarkIcon, BoxAddIcon, BrushIcon, BuilderEditIcon, BuilderIcon, CheckboxCheckedIcon, CheckCircleIcon, CheckCircleOutlinedIcon, CheckIcon, ChevronIcon, ChevronRightIcon, CircleIcon, CloseCircleIcon, CloseIcon, CMSIcon, CodeIcon, ComponentsIcon, CookieIcon, CopyIcon, CrossIcon, DeleteIcon, DeleteOutlinedIcon, Desktop, DesktopWithStar, DivBlock, DOMElement, EditIcon, ExpertIcon, EyeCancelIcon, EyeIcon, FavouriteIcon, FileUploadIcon, FilterIcon, FinsweetLibraryIcon, FinsweetLogoIcon, FinsweetLogoOutlineIcon, FolderIcon, FolderOutlinedIcon, FolderPlusIcon, FreeComponentIcon, GlobeIcon, HandPointUpIcon, HeartIcon, HeartIconOutlined, HelpAltIcon, HelpIcon, HomeIcon, InfoIcon, LineChartIcon, ListIcon, LockIcon, MessageIcon, MobileLandscape, MobilePortrait, NavigatorIcon, OpenBookIcon, PageDraftIcon, PageIcon, PageLockedIcon, PageOutlinedIcon, PageSectionIcon, Pencil, PencilOutlinedIcon, PinIcon, PlayIcon, PlusIcon, PreviewEyeIcon, ProfileIcon, PublishCancelIcon, PublishIcon, RefreshIcon, ReceiptIcon, RepairIcon, SaveIcon, SearchIcon, SelectIcon, SettingsIcon, SidebarToggleIcon, SliderAppIcon, SquareCheckIcon, StarIcon, StarOutlinedIcon, StaticContentIcon, SubtractIcon, TableAppIcon, Tablet, TabletPreview, TabNewIcon, TabsIcon, ThreeDotsIcon, TimesIcon, TooltipInfoCircleFilled, ToolTipInfoCircleIcon, TooltipInfoSquaredIcon, TriangleDownIcon, TriangleDownIconToggle, UndoIcon, UploadFileIcon, WarningCircleIcon, WarningCircleOutlineIcon, WarningTriangleIcon, WarningTriangleOutlineIcon, WebflowComponentIcon, WebflowComponentOutlinedIcon, WebflowInsightsIcon, WizedLogoIcon, WorkspaceIcon, XL, XXL, XXXL };
125
+ export { AccordionDownArrow, AccordionUpArrow, AccountIcon, ArrowIcon, BackIcon, BodyIcon, BookmarkIcon, BoxAddIcon, BrushIcon, BuilderEditIcon, BuilderIcon, CheckboxCheckedIcon, CheckCircleIcon, CheckCircleOutlinedIcon, CheckIcon, ChevronIcon, ChevronRightIcon, CircleIcon, CloseCircleIcon, CloseIcon, CMSIcon, CodeIcon, ComponentsIcon, CookieIcon, CopyIcon, CrossIcon, DeleteIcon, DeleteOutlinedIcon, Desktop, DesktopWithStar, DivBlock, DOMElement, EditIcon, ExpertIcon, EyeCancelIcon, EyeIcon, FavouriteIcon, FileUploadIcon, FilterIcon, FinsweetLibraryIcon, FinsweetLogoIcon, FinsweetLogoOutlineIcon, FolderIcon, FolderOutlinedIcon, FolderPlusIcon, FreeComponentIcon, GlobeIcon, HandPointUpIcon, HeartIcon, HeartIconOutlined, HelpAltIcon, HelpIcon, HomeIcon, InfoIcon, LineChartIcon, ListIcon, LockIcon, MessageIcon, MobileLandscape, MobilePortrait, NavigatorIcon, OpenBookIcon, PageDraftIcon, PageIcon, PageLockedIcon, PageOutlinedIcon, PageSectionIcon, Pencil, PencilOutlinedIcon, PinIcon, PlayIcon, PlusIcon, PreviewEyeIcon, ProfileIcon, PublishCancelIcon, PublishIcon, RefreshIcon, ReceiptIcon, RepairIcon, SaveIcon, SearchIcon, SelectIcon, SettingsIcon, SidebarToggleIcon, SliderAppIcon, SquareCheckIcon, StarIcon, StarOutlinedIcon, StaticContentIcon, SubtractIcon, TableAppIcon, Tablet, TabletPreview, TabNewIcon, TabsIcon, TeamIcon, ThreeDotsIcon, TimesIcon, TooltipInfoCircleFilled, ToolTipInfoCircleIcon, TooltipInfoSquaredIcon, TriangleDownIcon, TriangleDownIconToggle, UndoIcon, UploadFileIcon, WarningCircleIcon, WarningCircleOutlineIcon, WarningTriangleIcon, WarningTriangleOutlineIcon, WebflowComponentIcon, WebflowComponentOutlinedIcon, WebflowInsightsIcon, WizedLogoIcon, WorkspaceIcon, XL, XXL, XXXL };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finsweet/webflow-apps-utils",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Shared utilities for Webflow apps",
5
5
  "homepage": "https://github.com/finsweet/webflow-apps-utils",
6
6
  "repository": {