@hashrytech/quick-components-kit 0.17.9 → 0.18.1

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,17 @@
1
1
  # @hashrytech/quick-components-kit
2
2
 
3
+ ## 0.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - patch: parentDivClass for select
8
+
9
+ ## 0.18.0
10
+
11
+ ### Minor Changes
12
+
13
+ - feat: Adding select componennt
14
+
3
15
  ## 0.17.9
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,62 @@
1
+ <script lang="ts" module>
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ import type { Snippet } from 'svelte';
4
+
5
+ export type Option = {
6
+ value: string | number;
7
+ label: string;
8
+ disabled?: boolean;
9
+ };
10
+
11
+ export type SelectProps = {
12
+ id: string;
13
+ name?: string;
14
+ label?: string;
15
+ disabled?: boolean;
16
+ value?: string | number;
17
+ options: Option[];
18
+ size?: "sm" | "md" | "lg";
19
+ labelPosition?: "left" | "top" | "right" | "bottom";
20
+ class?: ClassNameValue;
21
+ labelClass?: ClassNameValue;
22
+ optionsClass?: ClassNameValue;
23
+ parentDivClass?: ClassNameValue;
24
+ icon?: Snippet;
25
+ onchange?: (event: Event) => void;
26
+ };
27
+ </script>
28
+
29
+ <script lang="ts">
30
+ import { twMerge } from 'tailwind-merge';
31
+
32
+ let { id, name, label = "", labelPosition = "top", value = $bindable(), options=$bindable([]), size = "md", disabled = $bindable(false), labelClass, parentDivClass, optionsClass, onchange, ...restProps}: SelectProps = $props();
33
+
34
+ const sizeMap = {
35
+ sm: "text-sm py-1 px-2 h-8",
36
+ md: "text-base py-2 px-3 h-10",
37
+ lg: "text-lg py-3 px-4 h-12",
38
+ };
39
+
40
+ const directionClass = {
41
+ top: "flex-col gap-1",
42
+ bottom: "flex-col-reverse gap-1",
43
+ left: "flex-row items-center gap-2",
44
+ right: "flex-row-reverse items-center gap-2",
45
+ };
46
+ </script>
47
+
48
+ <div class={twMerge("flex", directionClass[labelPosition] ?? directionClass.top, parentDivClass)}>
49
+ {#if label}
50
+ <label for={id} class={twMerge("text-sm font-medium text-primary-label-text ml-1", labelClass)}>{label}</label>
51
+ {/if}
52
+
53
+ <select {id} name={name ?? id} bind:value {disabled} onchange={onchange}
54
+ class={twMerge("rounded-primary border border-primary-input-border focus:border-primary-focus focus:ring-primary-focus placeholder:opacity-50 disabled:bg-neutral-300/30 disabled:border-neutral-300/30",
55
+ sizeMap[size], restProps.class)}>
56
+ {#each options as option}
57
+ <option value={option.value} disabled={option.disabled} class={twMerge("", optionsClass)}>
58
+ {option.label}
59
+ </option>
60
+ {/each}
61
+ </select>
62
+ </div>
@@ -0,0 +1,26 @@
1
+ import type { ClassNameValue } from 'tailwind-merge';
2
+ import type { Snippet } from 'svelte';
3
+ export type Option = {
4
+ value: string | number;
5
+ label: string;
6
+ disabled?: boolean;
7
+ };
8
+ export type SelectProps = {
9
+ id: string;
10
+ name?: string;
11
+ label?: string;
12
+ disabled?: boolean;
13
+ value?: string | number;
14
+ options: Option[];
15
+ size?: "sm" | "md" | "lg";
16
+ labelPosition?: "left" | "top" | "right" | "bottom";
17
+ class?: ClassNameValue;
18
+ labelClass?: ClassNameValue;
19
+ optionsClass?: ClassNameValue;
20
+ parentDivClass?: ClassNameValue;
21
+ icon?: Snippet;
22
+ onchange?: (event: Event) => void;
23
+ };
24
+ declare const Select: import("svelte").Component<SelectProps, {}, "value" | "disabled" | "options">;
25
+ type Select = ReturnType<typeof Select>;
26
+ export default Select;
@@ -0,0 +1 @@
1
+ export { default as Select } from './Select.svelte';
@@ -0,0 +1 @@
1
+ export { default as Select } from './Select.svelte';
@@ -73,7 +73,7 @@
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={name ? name: id} {placeholder} {onchange} {onmouseup} bind:value
76
- class={twMerge("rounded-primary border-primary-input-border focus:border-primary-focus focus:ring-primary-focus placeholder:opacity-50 disabled:bg-neutral-300/30 disabled:border-neutral-300/30",
76
+ class={twMerge("rounded-primary border border-primary-input-border focus:border-primary-focus focus:ring-primary-focus placeholder:opacity-50 disabled:bg-neutral-300/30 disabled:border-neutral-300/30",
77
77
  error ? "bg-red-50 border-red-300" : "",
78
78
  icon ? "pl-10" : "",
79
79
  sizeStyle[size], props.class)}
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './components/drawer/index.js';
6
6
  export * from './components/modal/index.js';
7
7
  export * from './components/overlay/index.js';
8
8
  export * from './components/radio/index.js';
9
+ export * from './components/select/index.js';
9
10
  export * from './components/checkbox/index.js';
10
11
  export * from './components/tab-navigation/index.js';
11
12
  export * from './components/portal/index.js';
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ export * from './components/drawer/index.js';
8
8
  export * from './components/modal/index.js';
9
9
  export * from './components/overlay/index.js';
10
10
  export * from './components/radio/index.js';
11
+ export * from './components/select/index.js';
11
12
  export * from './components/checkbox/index.js';
12
13
  export * from './components/tab-navigation/index.js';
13
14
  export * from './components/portal/index.js';
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.17.9",
8
+ "version": "0.18.1",
9
9
  "license": "MIT",
10
10
  "author": "Hashry Tech",
11
11
  "files": [