@sierra-95/svelte-scaffold 1.2.12 → 1.2.14

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.
@@ -12,22 +12,25 @@
12
12
  width = '100%',
13
13
  maxWidth = '',
14
14
  textColor = 'inherit',
15
+ showInput = true,
15
16
  ...rest
16
17
  } = $props();
17
18
  </script>
18
19
 
19
- <label class="sierra-input" style="width: {width}; max-width: {maxWidth}; color: {textColor}" for={id}>{label}
20
- <textarea
21
- {...rest}
22
- id={id}
23
- name={id}
24
- rows={rows}
25
- bind:value={value}
26
- placeholder={placeholder}
27
- required={rest.required}
28
- readonly={rest.readonly}
29
- style="background-color: {background}; border: {borderSize} solid {borderColor}; border-radius: {borderRadius};"
30
- onclick={(e: MouseEvent) => {
31
- rest.onclick?.(e);
32
- }}></textarea>
33
- </label>
20
+ {#if showInput}
21
+ <label class="sierra-input" style="width: {width}; max-width: {maxWidth}; color: {textColor}" for={id}>{label}
22
+ <textarea
23
+ {...rest}
24
+ id={id}
25
+ name={id}
26
+ rows={rows}
27
+ bind:value={value}
28
+ placeholder={placeholder}
29
+ required={rest.required}
30
+ readonly={rest.readonly}
31
+ style="background-color: {background}; border: {borderSize} solid {borderColor}; border-radius: {borderRadius};"
32
+ onclick={(e: MouseEvent) => {
33
+ rest.onclick?.(e);
34
+ }}></textarea>
35
+ </label>
36
+ {/if}
@@ -11,6 +11,7 @@ declare const Textarea: import("svelte").Component<{
11
11
  width?: string;
12
12
  maxWidth?: string;
13
13
  textColor?: string;
14
+ showInput?: boolean;
14
15
  } & Record<string, any>, {}, "value">;
15
16
  type Textarea = ReturnType<typeof Textarea>;
16
17
  export default Textarea;
@@ -13,26 +13,29 @@
13
13
  width = '100%',
14
14
  maxWidth = '',
15
15
  textColor = 'inherit',
16
+ showInput = true,
16
17
  autocomplete = undefined as _autocomplete,
17
18
  ...rest
18
19
  } = $props();
19
20
  </script>
20
21
 
21
- <label class="sierra-input" style="width: {width}; max-width: {maxWidth}; color: {textColor}" for={id}>{label}
22
- <input
23
- {...rest}
24
- id={id}
25
- name={id}
26
- type={type}
27
- bind:value={value}
28
- placeholder={placeholder}
29
- autocomplete={autocomplete ?? undefined}
30
- required={rest.required}
31
- readonly={rest.readonly}
32
- class="{underline? 'underline-input':''}"
33
- style="background-color: {background}; border: {borderSize} solid {borderColor};"
34
- onclick={(e: MouseEvent) => {
35
- rest.onclick?.(e);
36
- }}
37
- />
38
- </label>
22
+ {#if showInput}
23
+ <label class="sierra-input" style="width: {width}; max-width: {maxWidth}; color: {textColor}" for={id}>{label}
24
+ <input
25
+ {...rest}
26
+ id={id}
27
+ name={id}
28
+ type={type}
29
+ bind:value={value}
30
+ placeholder={placeholder}
31
+ autocomplete={autocomplete ?? undefined}
32
+ required={rest.required}
33
+ readonly={rest.readonly}
34
+ class="{underline? 'underline-input':''}"
35
+ style="background-color: {background}; border: {borderSize} solid {borderColor};"
36
+ onclick={(e: MouseEvent) => {
37
+ rest.onclick?.(e);
38
+ }}
39
+ />
40
+ </label>
41
+ {/if}
@@ -11,6 +11,7 @@ declare const Input: import("svelte").Component<{
11
11
  width?: string;
12
12
  maxWidth?: string;
13
13
  textColor?: string;
14
+ showInput?: boolean;
14
15
  autocomplete?: AutoFill | null | undefined;
15
16
  } & Record<string, any>, {}, "value">;
16
17
  type Input = ReturnType<typeof Input>;
@@ -12,31 +12,34 @@
12
12
  export let width: string = '100%';
13
13
  export let maxWidth: string = '';
14
14
  export let textColor: string = 'inherit';
15
+ export let showInput = true;
15
16
  export let autocomplete = undefined as _autocomplete;
16
17
  export let required = false;
17
18
 
18
19
  let show: boolean = false;
19
20
  </script>
20
21
 
21
- <label class="sierra-input" style="width: {width}; max-width: {maxWidth}; color: {textColor}" for={id}>{label}
22
- <div style="position: relative;">
23
- <input
24
- type={show ? "text" : "password"}
25
- id={id}
26
- name={id}
27
- bind:value={value}
28
- placeholder={placeholder}
29
- autocomplete={autocomplete ?? undefined}
30
- required={required}
31
- class="{underline? 'underline-input':''}"
32
- style="width: 100%; background-color: {background}; border: {borderSize} solid {borderColor}; border-radius: 4px;"
33
- />
34
- <button on:click|preventDefault={() => show = !show}>
35
- {#if show}
36
- <i class="fa fa-eye"></i>
37
- {:else}
38
- <i class="fa fa-eye-slash"></i>
39
- {/if}
40
- </button>
41
- </div>
42
- </label>
22
+ {#if showInput}
23
+ <label class="sierra-input" style="width: {width}; max-width: {maxWidth}; color: {textColor}" for={id}>{label}
24
+ <div style="position: relative;">
25
+ <input
26
+ type={show ? "text" : "password"}
27
+ id={id}
28
+ name={id}
29
+ bind:value={value}
30
+ placeholder={placeholder}
31
+ autocomplete={autocomplete ?? undefined}
32
+ required={required}
33
+ class="{underline? 'underline-input':''}"
34
+ style="width: 100%; background-color: {background}; border: {borderSize} solid {borderColor}; border-radius: 4px;"
35
+ />
36
+ <button on:click|preventDefault={() => show = !show}>
37
+ {#if show}
38
+ <i class="fa fa-eye"></i>
39
+ {:else}
40
+ <i class="fa fa-eye-slash"></i>
41
+ {/if}
42
+ </button>
43
+ </div>
44
+ </label>
45
+ {/if}
@@ -23,6 +23,7 @@ declare const Password: $$__sveltets_2_IsomorphicComponent<{
23
23
  width?: string;
24
24
  maxWidth?: string;
25
25
  textColor?: string;
26
+ showInput?: boolean;
26
27
  autocomplete?: AutoFill | null | undefined;
27
28
  required?: boolean;
28
29
  }, {
@@ -1,26 +1,29 @@
1
1
  <script lang="ts">
2
- export let id: string = '';
3
- export let label: string = '';
4
- export let value: string | number = '';
5
- export let options: { value: string | number; label: string; disabled?: boolean }[] = [];
6
- export let background: string ='transparent';
7
- export let width: string = '100%';
8
- export let maxWidth: string = '';
9
- export let height: string = '100%';
10
- export let textColor: string = 'inherit';
11
- export let optionsColor: string = 'inherit';
12
- export let optionsBackground: string = 'white';
2
+ export let id: string = '';
3
+ export let label: string = '';
4
+ export let value: string | number = '';
5
+ export let options: { value: string | number; label: string; disabled?: boolean }[] = [];
6
+ export let background: string ='transparent';
7
+ export let width: string = '100%';
8
+ export let maxWidth: string = '';
9
+ export let height: string = '100%';
10
+ export let textColor: string = 'inherit';
11
+ export let optionsColor: string = 'inherit';
12
+ export let optionsBackground: string = 'white';
13
+ export let showInput = true;
13
14
  </script>
14
15
 
15
- <label class="sierra-input" style="width: {width}; max-width: {maxWidth}; color: {textColor}" for={id}>{label}
16
- <select bind:value={value} id={id} name={id} required style="background-color: {background}; height: {height}">
17
- {#each options as option}
18
- <option
19
- value={option.value}
20
- disabled={option.disabled}
21
- style="color: {optionsColor}; background-color: {optionsBackground};"
22
- >{option.label}
23
- </option>
24
- {/each}
25
- </select>
26
- </label>
16
+ {#if showInput}
17
+ <label class="sierra-input" style="width: {width}; max-width: {maxWidth}; color: {textColor}" for={id}>{label}
18
+ <select bind:value={value} id={id} name={id} required style="background-color: {background}; height: {height}">
19
+ {#each options as option}
20
+ <option
21
+ value={option.value}
22
+ disabled={option.disabled}
23
+ style="color: {optionsColor}; background-color: {optionsBackground};"
24
+ >{option.label}
25
+ </option>
26
+ {/each}
27
+ </select>
28
+ </label>
29
+ {/if}
@@ -27,6 +27,7 @@ declare const Select: $$__sveltets_2_IsomorphicComponent<{
27
27
  textColor?: string;
28
28
  optionsColor?: string;
29
29
  optionsBackground?: string;
30
+ showInput?: boolean;
30
31
  }, {
31
32
  [evt: string]: CustomEvent<any>;
32
33
  }, {}, {}, string>;
@@ -0,0 +1,56 @@
1
+ <script lang="ts">
2
+ import { Button, addToast } from "../../../../index.js";
3
+ const {
4
+ shareURL,
5
+ shareTitle = '',
6
+ shareText = '',
7
+ limitShareText = 30,
8
+ label = "Share on WhatsApp",
9
+ } = $props();
10
+
11
+ let copyLink = $state(false);
12
+
13
+ const limitWords = (text:string, maxWords:number) => {
14
+ const words = text.split(/\s+/);
15
+ const trimmed = words.slice(0, maxWords).join(' ');
16
+ return words.length > maxWords ? trimmed + ' ...' : trimmed;
17
+ };
18
+
19
+ const handleShare = async () => {
20
+ if (navigator.share) {
21
+ try {
22
+ await navigator.share({
23
+ title: shareTitle,
24
+ text: limitWords(shareText, limitShareText),
25
+ url: shareURL,
26
+ });
27
+ } catch (err) {
28
+ console.error('Error sharing:', err);
29
+ }
30
+ } else {
31
+ const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
32
+ const message = `${limitWords(shareText, limitShareText)}\n\n${shareURL}`;
33
+ const encoded = encodeURIComponent(message);
34
+
35
+ const url = isMobile
36
+ ? `https://wa.me/?text=${encoded}`
37
+ : `https://web.whatsapp.com/send?text=${encoded}`;
38
+
39
+ window.open(url, "_blank");
40
+ copyLink = true;
41
+ }
42
+ };
43
+ const copyToClipboard = () => {
44
+ navigator.clipboard.writeText(shareURL);
45
+ copyLink = false;
46
+ addToast({
47
+ status: 'success',
48
+ message: 'Link copied to clipboard!'
49
+ })
50
+ };
51
+ </script>
52
+ {#if copyLink}
53
+ <Button variant="outlined" startIcon="fa-solid fa-copy" onclick={copyToClipboard}>Copy Link</Button>
54
+ {:else}
55
+ <Button onclick={handleShare} variant="outlined" startIcon="fa-brands fa-whatsapp" iconSize="1.2rem" color="none" style="text-[#25D366]">{label}</Button>
56
+ {/if}
@@ -0,0 +1,9 @@
1
+ declare const Whatsapp: import("svelte").Component<{
2
+ shareURL: any;
3
+ shareTitle?: string;
4
+ shareText?: string;
5
+ limitShareText?: number;
6
+ label?: string;
7
+ }, {}, "">;
8
+ type Whatsapp = ReturnType<typeof Whatsapp>;
9
+ export default Whatsapp;
package/dist/index.d.ts CHANGED
@@ -41,6 +41,7 @@ export { default as Form } from './Core/components/Form/Form/form.svelte';
41
41
  export { default as Carousel } from './Core/components/others/Carousel/carousel.svelte';
42
42
  export { default as Avatar } from './Core/components/others/Avatar/avatar.svelte';
43
43
  export { default as ColorPicker } from './Core/components/others/ColorPicker/main.svelte';
44
+ export { default as WhatsappShare } from './Core/components/others/WhatsappShare/whatsapp.svelte';
44
45
  export { default as GlobalSearch } from './Core/features/GlobalSearch/main.svelte';
45
46
  export { default as ToastManager } from './Core/features/ToastManager/toastManager.svelte';
46
47
  export { default as Editor } from './Modules/Editor/main.svelte';
package/dist/index.js CHANGED
@@ -48,6 +48,7 @@ export { default as Form } from './Core/components/Form/Form/form.svelte';
48
48
  export { default as Carousel } from './Core/components/others/Carousel/carousel.svelte';
49
49
  export { default as Avatar } from './Core/components/others/Avatar/avatar.svelte';
50
50
  export { default as ColorPicker } from './Core/components/others/ColorPicker/main.svelte';
51
+ export { default as WhatsappShare } from './Core/components/others/WhatsappShare/whatsapp.svelte';
51
52
  //####################Features##################################
52
53
  export { default as GlobalSearch } from './Core/features/GlobalSearch/main.svelte';
53
54
  export { default as ToastManager } from './Core/features/ToastManager/toastManager.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sierra-95/svelte-scaffold",
3
- "version": "1.2.12",
3
+ "version": "1.2.14",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",