@hashrytech/quick-components-kit 0.4.1 → 0.6.0

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @hashrytech/quick-components-kit
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: adding modal component
8
+ - feat: adding checkbox component
9
+ - feat: Adding drawer component
10
+ - feat: adding radio button component
11
+
12
+ ### Patch Changes
13
+
14
+ - fix: removing navbar-aside component
15
+
16
+ ## 0.5.0
17
+
18
+ ### Minor Changes
19
+
20
+ - feat: adding navbar and nad-aside
21
+
3
22
  ## 0.4.1
4
23
 
5
24
  ### Patch Changes
@@ -0,0 +1,41 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import type { ClassNameValue } from 'tailwind-merge';
4
+ import {twMerge} from 'tailwind-merge';
5
+
6
+ export type CheckBoxProps = {
7
+ id: string;
8
+ name?: string;
9
+ label?: string;
10
+ disabled?: boolean;
11
+ checked?: boolean;
12
+ group?: any[];
13
+ labelPosition?: "left" | "right";
14
+ size?: "sm" | "md" | "lg";
15
+ children?: Snippet;
16
+ icon?: Snippet;
17
+ onclick?: (event: MouseEvent) => void;
18
+ labelClass?: ClassNameValue;
19
+ class?: ClassNameValue;
20
+ };
21
+
22
+ </script>
23
+
24
+ <script lang="ts">
25
+
26
+ let {id, name, label="", labelPosition="right", checked=$bindable(true), group=$bindable(), size="md", disabled=$bindable(false), onclick, labelClass, ...props}: CheckBoxProps = $props();
27
+
28
+ const sizeMap = {
29
+ sm: 'w-4 h-4',
30
+ md: 'w-5 h-5',
31
+ lg: 'w-6 h-6',
32
+ };
33
+
34
+ </script>
35
+
36
+ <label for={id} class="inline-flex items-center gap-2 cursor-pointer select-none">
37
+ {#if labelPosition === "left"}<span class={twMerge("text-sm", labelClass)}>{label}</span>{/if}
38
+ <input {id} name={name ? name : id} type="checkbox" bind:checked bind:group {disabled} class={twMerge("rounded border-border-primary focus:ring-2 ring-focus-primary text-button-primary accent-button-primary cursor-pointer",
39
+ sizeMap[size], props.class)} />
40
+ {#if labelPosition === "right"}<span class={twMerge("text-sm", labelClass)}>{label}</span>{/if}
41
+ </label>
@@ -0,0 +1,20 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ export type CheckBoxProps = {
4
+ id: string;
5
+ name?: string;
6
+ label?: string;
7
+ disabled?: boolean;
8
+ checked?: boolean;
9
+ group?: any[];
10
+ labelPosition?: "left" | "right";
11
+ size?: "sm" | "md" | "lg";
12
+ children?: Snippet;
13
+ icon?: Snippet;
14
+ onclick?: (event: MouseEvent) => void;
15
+ labelClass?: ClassNameValue;
16
+ class?: ClassNameValue;
17
+ };
18
+ declare const Checkbox: import("svelte").Component<CheckBoxProps, {}, "disabled" | "checked" | "group">;
19
+ type Checkbox = ReturnType<typeof Checkbox>;
20
+ export default Checkbox;
@@ -0,0 +1 @@
1
+ export { default as Checkbox } from './Checkbox.svelte';
@@ -0,0 +1 @@
1
+ export { default as Checkbox } from './Checkbox.svelte';
@@ -0,0 +1,82 @@
1
+ <script lang="ts" module>
2
+ import { onDestroy, onMount, type Snippet } from 'svelte';
3
+ import type { ClassNameValue } from 'tailwind-merge';
4
+ import { fade, fly } from 'svelte/transition';
5
+ import {twMerge} from 'tailwind-merge';
6
+ import { browser } from '$app/environment';
7
+
8
+ export type DrawerProps = {
9
+ open?: boolean;
10
+ escapeKeyClose?: boolean;
11
+ disableBodyScroll?: boolean;
12
+ ariaLabel?: string;
13
+ transitionDuration?: number;
14
+ transitionDistance?: number;
15
+ transitionPosition?: "left" | "right" | "top" | "bottom";
16
+ overlayClasses?: string;
17
+ children?: Snippet;
18
+ class?: ClassNameValue;
19
+ };
20
+
21
+ </script>
22
+
23
+ <script lang="ts">
24
+ let {open=$bindable(false), escapeKeyClose=true, disableBodyScroll=true, ariaLabel="Drawer", transitionPosition="left", transitionDuration=200, transitionDistance=240, overlayClasses="", children, ...props}: DrawerProps = $props();
25
+
26
+ const transitionProperties = {
27
+ x: transitionPosition == "left" ? -transitionDistance : transitionPosition == "right" ? transitionDistance : 0,
28
+ y: transitionPosition == "top" ? -transitionDistance : transitionPosition == "bottom" ? transitionDistance : 0,
29
+ duration: transitionDuration
30
+ };
31
+
32
+ const postionClasses = {
33
+ left: "top-0 bottom-0 left-0 w-60",
34
+ right: "top-0 bottom-0 right-0 w-60",
35
+ top: "top-0 left-0 right-0 h-60",
36
+ bottom: "bottom-0 left-0 right-0 h-60",
37
+ };
38
+
39
+ const lockScroll = () => document.body.style.overflow = 'hidden';
40
+ const unlockScroll = () => document.body.style.overflow = '';
41
+
42
+ $effect(() => {
43
+ if (open && disableBodyScroll) lockScroll(); else unlockScroll();
44
+ });
45
+
46
+ onMount(() => {
47
+ if(browser){
48
+ window.addEventListener('keydown', handleKeydown);
49
+ }
50
+ });
51
+
52
+ onDestroy(() => {
53
+ if(browser){
54
+ window.removeEventListener('keydown', handleKeydown);
55
+ }
56
+ });
57
+
58
+
59
+ export function closeDrawer() {
60
+ open = false;
61
+ };
62
+
63
+ function handleKeydown (event: { key: string; }) {
64
+ if(open && escapeKeyClose && event.key === "Escape") {
65
+ closeDrawer();
66
+ }
67
+ };
68
+
69
+ </script>
70
+
71
+ {#if open}
72
+ <!-- Overlay -->
73
+ <div transition:fade={{duration: transitionDuration}} class={twMerge("fixed inset-0 bg-overlay-primary", overlayClasses)} role="presentation" onclick={() => open = false}></div>
74
+
75
+ <div role="dialog" aria-modal="true" aria-label={ariaLabel} tabindex="{open ? 0 : -1}" aria-hidden="{!open}"
76
+ class={twMerge("fixed flex flex-col items-center gap-2 bg-white outline-0 focus:outline-0 active:outline-focus-primary focus:outline-focus-primary overflow-y-auto", postionClasses[transitionPosition], props.class)}
77
+ in:fly={transitionProperties}
78
+ out:fly={transitionProperties}>
79
+ {@render children?.()}
80
+ </div>
81
+ {/if}
82
+
@@ -0,0 +1,19 @@
1
+ import { type Snippet } from 'svelte';
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ export type DrawerProps = {
4
+ open?: boolean;
5
+ escapeKeyClose?: boolean;
6
+ disableBodyScroll?: boolean;
7
+ ariaLabel?: string;
8
+ transitionDuration?: number;
9
+ transitionDistance?: number;
10
+ transitionPosition?: "left" | "right" | "top" | "bottom";
11
+ overlayClasses?: string;
12
+ children?: Snippet;
13
+ class?: ClassNameValue;
14
+ };
15
+ declare const Drawer: import("svelte").Component<DrawerProps, {
16
+ closeDrawer: () => void;
17
+ }, "open">;
18
+ type Drawer = ReturnType<typeof Drawer>;
19
+ export default Drawer;
@@ -0,0 +1 @@
1
+ export { default as Drawer } from './Drawer.svelte';
@@ -0,0 +1 @@
1
+ export { default as Drawer } from './Drawer.svelte';
@@ -0,0 +1,30 @@
1
+ <script lang="ts" module>
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+
4
+ export type ButtonProps = {
5
+ open?: boolean;
6
+ ariaLabel: string;
7
+ linesClasses?: string;
8
+ numberOfLines?: number;
9
+ onclick?: (event: MouseEvent) => void;
10
+ class?: ClassNameValue;
11
+ };
12
+
13
+ </script>
14
+
15
+ <script lang="ts">
16
+ import {twMerge} from 'tailwind-merge';
17
+
18
+ let { open=$bindable(true), ariaLabel, linesClasses, numberOfLines=3, onclick, ...props }: ButtonProps = $props();
19
+
20
+ </script>
21
+
22
+ <button class={twMerge("p-2 rounded focus:outline-none focus:ring-2 focus:ring-focus-primary cursor-pointer w-fit", props.class)} aria-label={ariaLabel} {onclick}>
23
+ <!-- Icon -->
24
+ <div class="space-y-2">
25
+ {#each Array(numberOfLines) as _}
26
+ <span class={twMerge("block w-7 h-0.5 bg-button-primary", linesClasses)}></span>
27
+ {/each}
28
+ </div>
29
+ </button>
30
+
@@ -0,0 +1,12 @@
1
+ import type { ClassNameValue } from 'tailwind-merge';
2
+ export type ButtonProps = {
3
+ open?: boolean;
4
+ ariaLabel: string;
5
+ linesClasses?: string;
6
+ numberOfLines?: number;
7
+ onclick?: (event: MouseEvent) => void;
8
+ class?: ClassNameValue;
9
+ };
10
+ declare const HamburgerMenu: import("svelte").Component<ButtonProps, {}, "open">;
11
+ type HamburgerMenu = ReturnType<typeof HamburgerMenu>;
12
+ export default HamburgerMenu;
@@ -0,0 +1 @@
1
+ export { default as HamburgerMenu } from './HamburgerMenu.svelte';
@@ -0,0 +1 @@
1
+ export { default as HamburgerMenu } from './HamburgerMenu.svelte';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export * from './text-input/index.js';
1
2
  export * from './button/index.js';
2
3
  export * from './link-button/index.js';
3
- export * from './text-input/index.js';
4
+ export * from './hamburger-menu/index.js';
5
+ export * from './drawer/index.js';
6
+ export * from './modal/index.js';
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  // Reexport your entry components here
2
2
  // lib/index.js
3
+ export * from './text-input/index.js';
3
4
  export * from './button/index.js';
4
5
  export * from './link-button/index.js';
5
- export * from './text-input/index.js';
6
+ export * from './hamburger-menu/index.js';
7
+ export * from './drawer/index.js';
8
+ export * from './modal/index.js';
6
9
  // Add more components here...
@@ -0,0 +1,64 @@
1
+ <script lang="ts" module>
2
+ import { onDestroy, onMount, type Snippet } from 'svelte';
3
+ import type { ClassNameValue } from 'tailwind-merge';
4
+ import { fade } from 'svelte/transition';
5
+ import {twMerge} from 'tailwind-merge';
6
+ import { browser } from '$app/environment';
7
+
8
+ export type ModalProps = {
9
+ open?: boolean;
10
+ escapeKeyClose?: boolean;
11
+ disableBodyScroll?: boolean;
12
+ ariaLabel?: string;
13
+ overlayTransitionDuration?: number;
14
+ overlayClasses?: string;
15
+ children?: Snippet;
16
+ class?: ClassNameValue;
17
+ };
18
+
19
+ </script>
20
+
21
+ <script lang="ts">
22
+ let {open=$bindable(false), escapeKeyClose=true, disableBodyScroll=true, overlayTransitionDuration=0, ariaLabel="Modal", overlayClasses="", children, ...props}: ModalProps = $props();
23
+
24
+ const lockScroll = () => document.body.style.overflow = 'hidden';
25
+ const unlockScroll = () => document.body.style.overflow = '';
26
+
27
+ $effect(() => {
28
+ if (open && disableBodyScroll) lockScroll(); else unlockScroll();
29
+ });
30
+
31
+ onMount(() => {
32
+ if(browser){
33
+ window.addEventListener('keydown', handleKeydown);
34
+ }
35
+ });
36
+
37
+ onDestroy(() => {
38
+ if(browser){
39
+ window.removeEventListener('keydown', handleKeydown);
40
+ }
41
+ });
42
+
43
+ export function closeDrawer() {
44
+ open = false;
45
+ };
46
+
47
+ function handleKeydown (event: { key: string; }) {
48
+ if(open && escapeKeyClose && event.key === "Escape") {
49
+ closeDrawer();
50
+ }
51
+ };
52
+
53
+ </script>
54
+
55
+ {#if open}
56
+ <!-- Overlay -->
57
+ <div transition:fade={{duration: overlayTransitionDuration}} class={twMerge("fixed inset-0 bg-overlay-primary", overlayClasses)} role="presentation" onclick={() => open = false}></div>
58
+
59
+ <div role="dialog" aria-modal="true" aria-label={ariaLabel} tabindex="{open ? 0 : -1}" aria-hidden="{!open}"
60
+ class={twMerge("fixed bg-white top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 outline-0 focus:outline-0 active:outline-focus-primary focus:outline-focus-primary overflow-y-auto w-full max-w-md h-96", props.class)}>
61
+ {@render children?.()}
62
+ </div>
63
+ {/if}
64
+
@@ -0,0 +1,17 @@
1
+ import { type Snippet } from 'svelte';
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ export type ModalProps = {
4
+ open?: boolean;
5
+ escapeKeyClose?: boolean;
6
+ disableBodyScroll?: boolean;
7
+ ariaLabel?: string;
8
+ overlayTransitionDuration?: number;
9
+ overlayClasses?: string;
10
+ children?: Snippet;
11
+ class?: ClassNameValue;
12
+ };
13
+ declare const Modal: import("svelte").Component<ModalProps, {
14
+ closeDrawer: () => void;
15
+ }, "open">;
16
+ type Modal = ReturnType<typeof Modal>;
17
+ export default Modal;
@@ -0,0 +1 @@
1
+ export { default as Modal } from './modal.svelte';
@@ -0,0 +1 @@
1
+ export { default as Modal } from './modal.svelte';
@@ -0,0 +1,41 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import type { ClassNameValue } from 'tailwind-merge';
4
+ import {twMerge} from 'tailwind-merge';
5
+
6
+ export type RadioProps = {
7
+ id: string;
8
+ name?: string;
9
+ label?: string;
10
+ disabled?: boolean;
11
+ value?: any;
12
+ group?: any;
13
+ labelPosition?: "left" | "right";
14
+ size?: "sm" | "md" | "lg";
15
+ children?: Snippet;
16
+ icon?: Snippet;
17
+ onclick?: (event: MouseEvent) => void;
18
+ labelClass?: ClassNameValue;
19
+ class?: ClassNameValue;
20
+ };
21
+
22
+ </script>
23
+
24
+ <script lang="ts">
25
+
26
+ let {id, name, label="", labelPosition="right", value=$bindable(), group=$bindable(), size="md", disabled=$bindable(false), onclick, labelClass, ...props}: RadioProps = $props();
27
+
28
+ const sizeMap = {
29
+ sm: 'w-4 h-4',
30
+ md: 'w-5 h-5',
31
+ lg: 'w-6 h-6',
32
+ };
33
+
34
+ </script>
35
+
36
+ <label for={id} class="inline-flex items-center gap-2 cursor-pointer select-none">
37
+ {#if labelPosition === "left"}<span class={twMerge("text-sm", labelClass)}>{label}</span>{/if}
38
+ <input {id} name={name ? name : id} type="radio" bind:value bind:group {disabled} class={twMerge("border-border-primary focus:ring-2 ring-focus-primary text-button-primary accent-button-primary cursor-pointer",
39
+ sizeMap[size], props.class)} />
40
+ {#if labelPosition === "right"}<span class={twMerge("text-sm", labelClass)}>{label}</span>{/if}
41
+ </label>
@@ -0,0 +1,20 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ export type RadioProps = {
4
+ id: string;
5
+ name?: string;
6
+ label?: string;
7
+ disabled?: boolean;
8
+ value?: any;
9
+ group?: any;
10
+ labelPosition?: "left" | "right";
11
+ size?: "sm" | "md" | "lg";
12
+ children?: Snippet;
13
+ icon?: Snippet;
14
+ onclick?: (event: MouseEvent) => void;
15
+ labelClass?: ClassNameValue;
16
+ class?: ClassNameValue;
17
+ };
18
+ declare const Radio: import("svelte").Component<RadioProps, {}, "value" | "disabled" | "group">;
19
+ type Radio = ReturnType<typeof Radio>;
20
+ export default Radio;
@@ -0,0 +1 @@
1
+ export { default as Radio } from './Radio.svelte';
@@ -0,0 +1 @@
1
+ export { default as Radio } from './Radio.svelte';
@@ -19,7 +19,7 @@
19
19
  * @prop {string} [value] - The bound value of the input.
20
20
  * @prop {string} [placeholder] - Placeholder text.
21
21
  * @prop {string} [labelText] - Optional label text.
22
- * @prop {ClassNameValue} [inputStyle] - Additional Tailwind classes to apply to the input. Example: "border-red-500 text-green-600"
22
+ * @prop {ClassNameValue} [inputClasses] - Additional Tailwind classes to apply to the input. Example: "border-red-500 text-green-600"
23
23
  * @prop {TextInputSize} [size] - Size variant ("sm", "md", "lg") with predefined Tailwind styles.
24
24
  * - "sm": h-[2.05rem] text-sm placeholder:text-sm
25
25
  * - "md": h-[2.375rem] text-sm placeholder:text-sm
@@ -35,7 +35,7 @@
35
35
  type?: TextInputType;
36
36
  placeholder?: string;
37
37
  labelText?: string;
38
- inputStyle?: ClassNameValue;
38
+ inputClasses?: ClassNameValue;
39
39
  size?: TextInputSize;
40
40
  disabled?: boolean;
41
41
  required?: boolean;
@@ -52,7 +52,7 @@
52
52
  <script lang="ts">
53
53
  import { twMerge } from 'tailwind-merge';
54
54
 
55
- let { id, type="text", name="", value="", placeholder="", labelText, size="md", inputStyle="", disabled=false, required=false, error, onchange, onmouseup, label, icon}: TextInputProps = $props();
55
+ let { id, type="text", name="", value="", placeholder="", labelText, size="md", inputClasses="", disabled=false, required=false, error, onchange, onmouseup, label, icon}: TextInputProps = $props();
56
56
 
57
57
  /**
58
58
  * Predefined size classes for the TextBox input.
@@ -73,10 +73,10 @@
73
73
  <div class="relative">
74
74
  {#if icon}<div class="absolute inset-y-0 left-0 flex items-center justify-center rounded-l-primary m-0.5 w-10">{@render icon()}</div>{/if}
75
75
  <input {disabled} {required} {type} {id} {name} {placeholder} {onchange} {onmouseup} bind:value
76
- class={twMerge("rounded-primary border-neutral-300 focus:border-primary-500 focus:ring-primary-500 placeholder:opacity-50 disabled:bg-neutral-300/30 disabled:border-gray-300/30",
76
+ class={twMerge("rounded-primary border-border-primary focus:border-primary-500 focus:ring-primary-500 placeholder:opacity-50 disabled:bg-neutral-300/30 disabled:border-gray-300/30",
77
77
  error ? "bg-red-50 border-red-300 ring-red-300" : "",
78
78
  icon ? "pl-10" : "",
79
- sizeStyle[size], inputStyle)}
79
+ sizeStyle[size], inputClasses)}
80
80
  />
81
81
  </div>
82
82
  {#if error}
@@ -16,7 +16,7 @@ export type TextInputType = "text" | "password" | "number" | "email" | "tel" | "
16
16
  * @prop {string} [value] - The bound value of the input.
17
17
  * @prop {string} [placeholder] - Placeholder text.
18
18
  * @prop {string} [labelText] - Optional label text.
19
- * @prop {ClassNameValue} [inputStyle] - Additional Tailwind classes to apply to the input. Example: "border-red-500 text-green-600"
19
+ * @prop {ClassNameValue} [inputClasses] - Additional Tailwind classes to apply to the input. Example: "border-red-500 text-green-600"
20
20
  * @prop {TextInputSize} [size] - Size variant ("sm", "md", "lg") with predefined Tailwind styles.
21
21
  * - "sm": h-[2.05rem] text-sm placeholder:text-sm
22
22
  * - "md": h-[2.375rem] text-sm placeholder:text-sm
@@ -32,7 +32,7 @@ export type TextInputProps = {
32
32
  type?: TextInputType;
33
33
  placeholder?: string;
34
34
  labelText?: string;
35
- inputStyle?: ClassNameValue;
35
+ inputClasses?: ClassNameValue;
36
36
  size?: TextInputSize;
37
37
  disabled?: boolean;
38
38
  required?: boolean;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hashrytech/quick-components-kit.git"
7
7
  },
8
- "version": "0.4.1",
8
+ "version": "0.6.0",
9
9
  "license": "MIT",
10
10
  "author": "Hashry Tech",
11
11
  "files": [