windmill-components 1.305.4 → 1.305.6

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.
@@ -45,17 +45,17 @@ if (controls) {
45
45
  let runnableComponent;
46
46
  let beforeIconComponent;
47
47
  let afterIconComponent;
48
- $: resolvedConfig.beforeIcon && handleBeforeIcon();
49
- $: resolvedConfig.afterIcon && handleAfterIcon();
48
+ $: resolvedConfig.beforeIcon && beforeIconComponent && handleBeforeIcon();
49
+ $: resolvedConfig.afterIcon && afterIconComponent && handleAfterIcon();
50
50
  let confirmedCallback = undefined;
51
51
  async function handleBeforeIcon() {
52
52
  if (resolvedConfig.beforeIcon) {
53
- beforeIconComponent = await loadIcon(resolvedConfig.beforeIcon);
53
+ beforeIconComponent = await loadIcon(resolvedConfig.beforeIcon, beforeIconComponent, 14, undefined, undefined);
54
54
  }
55
55
  }
56
56
  async function handleAfterIcon() {
57
57
  if (resolvedConfig.afterIcon) {
58
- afterIconComponent = await loadIcon(resolvedConfig.afterIcon);
58
+ afterIconComponent = await loadIcon(resolvedConfig.afterIcon, afterIconComponent, 14, undefined, undefined);
59
59
  }
60
60
  }
61
61
  onDestroy(() => {
@@ -177,17 +177,17 @@ let css = initCss($app.css?.buttoncomponent, customCss);
177
177
  on:click={handleClick}
178
178
  size={resolvedConfig.size}
179
179
  color={resolvedConfig.color}
180
- startIcon={{
181
- icon: resolvedConfig.beforeIcon ? beforeIconComponent : undefined
182
- }}
183
- endIcon={{
184
- icon: resolvedConfig.afterIcon ? afterIconComponent : undefined
185
- }}
186
180
  {loading}
187
181
  >
182
+ {#if resolvedConfig.beforeIcon}
183
+ <div class="min-w-4" bind:this={beforeIconComponent} />
184
+ {/if}
188
185
  {#if resolvedConfig.label?.toString() && resolvedConfig.label?.toString()?.length > 0}
189
186
  <div>{resolvedConfig.label.toString()}</div>
190
187
  {/if}
188
+ {#if resolvedConfig.afterIcon}
189
+ <div class="min-w-4" bind:this={afterIconComponent} />
190
+ {/if}
191
191
  </Button>
192
192
  {/key}
193
193
  </AlignWrapper>
@@ -19,9 +19,11 @@ let resolvedConfig = initConfig(components['iconcomponent'].initialData.configur
19
19
  //used so that we can count number of outputs setup for first refresh
20
20
  initOutput($worldStore, id, {});
21
21
  let iconComponent;
22
- $: handleIcon(resolvedConfig.icon);
23
- async function handleIcon(i) {
24
- iconComponent = i ? await loadIcon(i) : undefined;
22
+ $: handleIcon(resolvedConfig, iconComponent);
23
+ async function handleIcon(conf, comp) {
24
+ if (conf.icon && comp) {
25
+ await loadIcon(conf.icon, iconComponent, conf.size, conf.strokeWidth, conf.color);
26
+ }
25
27
  }
26
28
  let css = initCss($app.css?.iconcomponent, customCss);
27
29
  </script>
@@ -54,12 +56,9 @@ let css = initCss($app.css?.iconcomponent, customCss);
54
56
  class={twMerge(css?.container?.class, 'wm-icon-container')}
55
57
  style={css?.container?.style ?? ''}
56
58
  >
57
- {#if resolvedConfig.icon && iconComponent}
58
- <svelte:component
59
- this={iconComponent}
60
- size={resolvedConfig.size || 24}
61
- color={resolvedConfig.color || 'currentColor'}
62
- strokeWidth={resolvedConfig.strokeWidth || 2}
59
+ {#if resolvedConfig.icon}
60
+ <div
61
+ bind:this={iconComponent}
63
62
  class={twMerge(css?.icon?.class, 'wm-icon')}
64
63
  style={css?.icon?.style ?? ''}
65
64
  />
@@ -1 +1 @@
1
- export declare function loadIcon(name: string): Promise<any>;
1
+ export declare function loadIcon(name: string, parent: HTMLElement, size: number | undefined, strokeWidth: number | undefined, color: string | undefined): Promise<any>;
@@ -5,19 +5,28 @@ function toKebabCase(str) {
5
5
  .replace(/([a-z])([0-9])/g, '$1-$2') // Separate letters from digits
6
6
  .toLowerCase();
7
7
  }
8
- export async function loadIcon(name) {
9
- let iconComponent;
8
+ export async function loadIcon(name, parent, size, strokeWidth, color) {
10
9
  try {
11
10
  if (name) {
12
- iconComponent = (await import(`../../../../../node_modules/lucide-svelte/dist/svelte/icons/${toKebabCase(name)}.svelte`)).default;
13
- return iconComponent;
11
+ await fetch(`https://cdn.jsdelivr.net/npm/lucide-static@0.367.0/icons/${toKebabCase(name)}.svg`)
12
+ .then((response) => response.text())
13
+ .then((svg) => (parent.innerHTML = svg));
14
+ let elem = parent.children?.[0];
15
+ if (elem) {
16
+ elem.setAttribute('width', size?.toString() ?? '24');
17
+ elem.setAttribute('height', size?.toString() ?? '24');
18
+ if (strokeWidth) {
19
+ elem.setAttribute('stroke-width', strokeWidth.toString());
20
+ }
21
+ if (color) {
22
+ elem.setAttribute('stroke', color);
23
+ }
24
+ }
14
25
  }
15
26
  else {
16
- iconComponent = undefined;
17
27
  }
18
28
  }
19
29
  catch (error) {
20
30
  console.error(error);
21
- iconComponent = undefined;
22
31
  }
23
32
  }
@@ -1,5 +1,6 @@
1
1
  <script>import { Loader2 } from 'lucide-svelte';
2
2
  import { ClearableInput, Popup } from '../../../../common';
3
+ import { AllIcons } from './icons';
3
4
  export let componentInput;
4
5
  let loading = false;
5
6
  let items;
@@ -7,21 +8,16 @@ let filteredItems;
7
8
  let search = '';
8
9
  $: if (search) {
9
10
  filteredItems = items.filter((item) => {
10
- return item.label.toLowerCase().includes(search.toLowerCase());
11
+ return item.toLowerCase().includes(search.toLowerCase());
11
12
  });
12
13
  }
13
14
  else {
14
15
  filteredItems = items;
15
16
  }
16
17
  async function getData() {
17
- if (items) {
18
- }
19
18
  loading = true;
20
19
  // @ts-ignore
21
- const data = await import('lucide-svelte/icons');
22
- filteredItems = items = Object.entries(data)
23
- .filter(([key]) => !(key.endsWith('Icon') || key.startsWith('Lucide')))
24
- .map(([key, icon]) => ({ label: key, icon }));
20
+ items = AllIcons;
25
21
  loading = false;
26
22
  }
27
23
  function select(label) {
@@ -71,7 +67,7 @@ function select(label) {
71
67
  class="col-span-4 mb-2"
72
68
  />
73
69
  <div class="grid gap-1 grid-cols-4 max-h-[300px] overflow-auto">
74
- {#each filteredItems as { label, icon }}
70
+ {#each filteredItems as label}
75
71
  <button
76
72
  type="button"
77
73
  title={label}
@@ -83,7 +79,10 @@ function select(label) {
83
79
  hover:bg-gray-100 focus:bg-gray-100 rounded duration-200 dark:hover:bg-frost-900 dark:focus:bg-frost-900
84
80
  {label === componentInput.value ? 'text-blue-600 bg-blue-50 pointer-events-none' : ''}"
85
81
  >
86
- <svelte:component this={icon} size={22} />
82
+ <img
83
+ loading="lazy"
84
+ src="https://cdn.jsdelivr.net/npm/lucide-static@0.367.0/icons/{label}.svg"
85
+ />
87
86
  <span class="inline-block w-full text-[10px] ellipsize pt-0.5">
88
87
  {label}
89
88
  </span>
@@ -0,0 +1 @@
1
+ export declare const AllIcons: string[];