@valerius_petrini/corekit-ui 0.1.54 → 0.1.56

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.
@@ -37,7 +37,7 @@
37
37
  });
38
38
 
39
39
  let defaultClass = "text-main-text rounded-lg transition-colors ease-in-out bg-sub-background p-4";
40
- let linkClass = "hover:bg-sub-background-hover cursor-pointer";
40
+ let linkClass = "block hover:bg-sub-background-hover cursor-pointer";
41
41
  let combinedClass = $derived(twMerge(
42
42
  defaultClass,
43
43
  href ? linkClass : "",
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { FloatingInputProps } from "../types/FloatingInput.js";
2
+ import type { InputProps } from "../types/Input.js";
3
3
  import { twMerge } from "tailwind-merge";
4
4
  import Text from "./Text.svelte";
5
5
  import { sizeStyleParts, type SizeStyleTheme } from "../styles/size.js";
@@ -11,6 +11,8 @@
11
11
  import Phone from "@lucide/svelte/icons/phone";
12
12
  import Eye from "@lucide/svelte/icons/eye";
13
13
  import EyeOff from "@lucide/svelte/icons/eye-off";
14
+ import ChevronUp from "@lucide/svelte/icons/chevron-up";
15
+ import ChevronDown from "@lucide/svelte/icons/chevron-down";
14
16
 
15
17
  let {
16
18
  children = undefined,
@@ -30,8 +32,13 @@
30
32
  size = "md",
31
33
  radius = "md",
32
34
  id = crypto.randomUUID(),
35
+ min = undefined,
36
+ max = undefined,
37
+ step = undefined,
33
38
  ...restProps
34
- }: FloatingInputProps = $props();
39
+ }: InputProps = $props();
40
+
41
+ let isHovered = $state(false);
35
42
 
36
43
  const sizeParts = $derived(typeof size === "string" ? sizeStyleParts[size as SizeStyleTheme] : null);
37
44
  const radiusParts = $derived(typeof radius === "string" ? sizeStyleParts[radius as SizeStyleTheme] : null);
@@ -93,7 +100,7 @@
93
100
  const lifted = $derived(isFloating && (isFocused || hasContent));
94
101
 
95
102
  const Icon = $derived(icon ?? ({
96
- mail: Mail, password: Lock, tel: Phone
103
+ email: Mail, password: Lock, tel: Phone
97
104
  }[restProps.type as string] as Component ?? null));
98
105
 
99
106
  let defaultClass = "text-main-text w-full rounded outline-none px-1.5 w-full bg-inherit border-0 focus:ring-0 focus-visible:ring-0";
@@ -137,6 +144,44 @@
137
144
  let combinedOuterDivClass = $derived(twMerge("flex flex-col bg-transparent border-0 p-0", divSizeClass, divFullClass, divClass, disabledClass));
138
145
 
139
146
  let EyeComponent = $derived(canSeePassword ? Eye : EyeOff);
147
+
148
+ let numberIconClass = $derived(twMerge(iconClass, sizeClasses, "text-sub-text/70 w-fit aspect-auto p-0 flex-center flex-col transition-all duration-150"));
149
+ let numberButtonClass = $derived(twMerge(iconContainerClass, "h-1/2 gap-0 px-0.5 hover:bg-form-border aspect-square rounded-none"));
150
+
151
+ function increment() {
152
+ if (max === undefined || value < max) value = (value || 0) + (step || 1);
153
+ }
154
+
155
+ function decrement() {
156
+ if (min === undefined || value > min) value = (value || 0) - (step || 1);
157
+ }
158
+
159
+ let incrementInterval: ReturnType<typeof setInterval> | null = null;
160
+ let decrementInterval: ReturnType<typeof setInterval> | null = null;
161
+
162
+ function startIncrement() {
163
+ increment();
164
+ incrementInterval = setInterval(increment, 100);
165
+ }
166
+
167
+ function stopIncrement() {
168
+ if (incrementInterval) {
169
+ clearInterval(incrementInterval);
170
+ incrementInterval = null;
171
+ }
172
+ }
173
+
174
+ function startDecrement() {
175
+ decrement();
176
+ decrementInterval = setInterval(decrement, 100);
177
+ }
178
+
179
+ function stopDecrement() {
180
+ if (decrementInterval) {
181
+ clearInterval(decrementInterval);
182
+ decrementInterval = null;
183
+ }
184
+ }
140
185
  </script>
141
186
 
142
187
  {#snippet labelElement()}
@@ -149,7 +194,8 @@
149
194
  {/snippet}
150
195
 
151
196
  {#snippet innerDivElement()}
152
- <div class={combinedDivClass}>
197
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
198
+ <div class={combinedDivClass} onmouseenter={() => isHovered = true} onmouseleave={() => isHovered = false}>
153
199
  {#if Icon}
154
200
  <div class={iconContainerClass}>
155
201
  <Icon class={iconClass}></Icon>
@@ -166,6 +212,9 @@
166
212
  class={combinedClass}
167
213
  {required}
168
214
  {disabled}
215
+ {min}
216
+ {max}
217
+ {step}
169
218
  placeholder={variant === "floating" ? "" : placeholder}
170
219
  aria-disabled={disabled}
171
220
  style={customStyle}
@@ -176,6 +225,27 @@
176
225
  <Button class={iconContainerClass} onclick={() => { canSeePassword = !canSeePassword; }}>
177
226
  <EyeComponent class={iconClass}></EyeComponent>
178
227
  </Button>
228
+ {:else if restProps.type === "number"}
229
+ <div class={twMerge(numberIconClass, isHovered ? "opacity-100 scale-100" : "opacity-0 scale-75")}>
230
+ <Button
231
+ size="none" radius="none"
232
+ class={numberButtonClass}
233
+ onmousedown={startIncrement}
234
+ onmouseup={stopIncrement}
235
+ onmouseleave={stopIncrement}
236
+ disabled={max !== undefined && value >= max}>
237
+ <ChevronUp class="w-full h-full"/>
238
+ </Button>
239
+ <Button
240
+ size="none" radius="none"
241
+ class={numberButtonClass}
242
+ onmousedown={startDecrement}
243
+ onmouseup={stopDecrement}
244
+ onmouseleave={stopDecrement}
245
+ disabled={min !== undefined && value <= min}>
246
+ <ChevronDown class="w-full h-full"/>
247
+ </Button>
248
+ </div>
179
249
  {/if}
180
250
  </div>
181
251
  {/snippet}
@@ -0,0 +1,5 @@
1
+ import type { InputProps } from "../types/Input.ts";
2
+ import { type Component } from "svelte";
3
+ declare const Input: Component<InputProps, {}, "value">;
4
+ type Input = ReturnType<typeof Input>;
5
+ export default Input;
@@ -0,0 +1,36 @@
1
+ <script lang="ts">
2
+ import type { ModalProps } from "../types/Modal.js";
3
+ import { fade, fly } from "svelte/transition";
4
+ import Card from "./Card.svelte";
5
+ import { positionParts } from "../styles/posititon.js";
6
+ import { twMerge } from "tailwind-merge";
7
+
8
+ let {
9
+ children = undefined,
10
+ class: className = "",
11
+ open = $bindable(),
12
+ position = "center",
13
+ ...restProps
14
+ }: ModalProps = $props();
15
+
16
+ const defaultOuterDivClass = "w-full h-screen absolute bg-black/50 z-200 flex items-center justify-center top-0 left-0 p-4";
17
+ const positionOuterDivClass = $derived(positionParts[position] || "");
18
+ const combinedOuterDivClass = $derived(twMerge(defaultOuterDivClass, positionOuterDivClass));
19
+
20
+ const defaultInnerDivClass = "z-300 max-h-full";
21
+
22
+ const defaultCardClass = "overflow-y-auto max-h-[95vh]";
23
+ const combinedCardClass = $derived(twMerge(defaultCardClass, className));
24
+ </script>
25
+
26
+ {#if open}
27
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
28
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
29
+ <div class={combinedOuterDivClass} transition:fade={{ duration: 200 }} onclick={() => open = false}>
30
+ <div class={defaultInnerDivClass} transition:fly={{ y: -20, duration: 200 }} onclick={(e) => e.stopPropagation()}>
31
+ <Card class={combinedCardClass} {...restProps}>
32
+ {@render children()}
33
+ </Card>
34
+ </div>
35
+ </div>
36
+ {/if}
@@ -0,0 +1,4 @@
1
+ import type { ModalProps } from "../types/Modal.js";
2
+ declare const Modal: import("svelte").Component<ModalProps, {}, "open">;
3
+ type Modal = ReturnType<typeof Modal>;
4
+ export default Modal;
@@ -52,6 +52,7 @@
52
52
 
53
53
  let combinedInnerClass = $derived(twMerge(
54
54
  "h-full",
55
+ sizeClasses,
55
56
  colorStyleParts[color]?.base,
56
57
  className
57
58
  ))
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { FloatingSelectProps } from "../types/FloatingSelect.js";
2
+ import type { SelectProps } from "../types/Select.js";
3
3
  import { twMerge } from "tailwind-merge";
4
4
  import Text from "./Text.svelte";
5
5
 
@@ -13,7 +13,7 @@
13
13
  options = [],
14
14
  id = crypto.randomUUID(),
15
15
  ...restProps
16
- }: FloatingSelectProps = $props();
16
+ }: SelectProps = $props();
17
17
 
18
18
  let defaultSelectClass = "cursor-pointer bg-form-background border-[1px] border-form-border text-main-text z-20 w-full rounded px-1 pt-4 pb-1 text-xs outline-none focus:ring-2 focus:ring-blue-500 transition-all";
19
19
  let defaultLabelClass = "block text-sub-text rounded-md text-sm font-medium mb-1 absolute transition-all duration-100 pointer-events-none";
@@ -0,0 +1,4 @@
1
+ import type { SelectProps } from "../types/Select.js";
2
+ declare const Select: import("svelte").Component<SelectProps, {}, "value">;
3
+ type Select = ReturnType<typeof Select>;
4
+ export default Select;
@@ -0,0 +1,47 @@
1
+ <script lang="ts">
2
+ import type { TableProps } from "../types/Table.js";
3
+ import { twMerge } from "tailwind-merge";
4
+
5
+ let {
6
+ children = undefined,
7
+ class: className = "",
8
+ tableHeaders = [],
9
+ tableData = [],
10
+ size = "md",
11
+ radius = "md",
12
+ ...restProps
13
+ }: TableProps = $props();
14
+
15
+ const defaultTableClass = "w-full border-collapse text-main-text border border-form-border border-l-0";
16
+ const defaultTableHeaderClass = "text-left border-b border-b-1 border-b-form-border bg-sub-background font-medium";
17
+ const defaultTableCellClass = "p-2 text-sm border-l border-l-[1px] border-l-form-border";
18
+ const defaultTableBodyClass = "even:bg-sub-background odd:bg-form-background";
19
+
20
+ const combinedTableClass = $derived(twMerge(
21
+ defaultTableClass,
22
+ className
23
+ ));
24
+
25
+ const combinedTableHeaderClass = $derived(twMerge(defaultTableHeaderClass, defaultTableCellClass));
26
+ </script>
27
+
28
+ <div class="overflow-auto w-full">
29
+ <table {...restProps} class={combinedTableClass}>
30
+ <thead>
31
+ <tr>
32
+ {#each tableHeaders as header}
33
+ <th class={combinedTableHeaderClass}>{header.label}</th>
34
+ {/each}
35
+ </tr>
36
+ </thead>
37
+ <tbody>
38
+ {#each tableData as row}
39
+ <tr class={defaultTableBodyClass}>
40
+ {#each row as cell}
41
+ <td class={defaultTableCellClass}>{cell}</td>
42
+ {/each}
43
+ </tr>
44
+ {/each}
45
+ </tbody>
46
+ </table>
47
+ </div>
@@ -0,0 +1,4 @@
1
+ import type { TableProps } from "../types/Table.ts";
2
+ declare const Table: import("svelte").Component<TableProps, {}, "">;
3
+ type Table = ReturnType<typeof Table>;
4
+ export default Table;
package/dist/index.d.ts CHANGED
@@ -5,11 +5,12 @@ export { default as SEO } from "./components/SEO.svelte";
5
5
  export { default as Navbar } from "./components/Navbar.svelte";
6
6
  export { default as NavbarSeparator } from "./components/NavbarSeparator.svelte";
7
7
  export { default as NavbarElement } from "./components/NavbarElement.svelte";
8
- export { default as FloatingInput } from "./components/FloatingInput.svelte";
9
- export { default as FloatingSelect } from "./components/FloatingSelect.svelte";
8
+ export { default as Input } from "./components/Input.svelte";
9
+ export { default as Select } from "./components/Select.svelte";
10
10
  export { default as Text } from "./components/Text.svelte";
11
11
  export { default as Card } from "./components/Card.svelte";
12
12
  export { default as Checkbox } from "./components/Checkbox.svelte";
13
13
  export { default as Progress } from "./components/Progress.svelte";
14
+ export { default as Modal } from "./components/Modal.svelte";
14
15
  export { fbmBackground } from "./actions/fbm.ts";
15
16
  export type { TypewriterAction, DisplaySegment } from "./types/Typewriter.ts";
package/dist/index.js CHANGED
@@ -5,10 +5,11 @@ export { default as SEO } from "./components/SEO.svelte";
5
5
  export { default as Navbar } from "./components/Navbar.svelte";
6
6
  export { default as NavbarSeparator } from "./components/NavbarSeparator.svelte";
7
7
  export { default as NavbarElement } from "./components/NavbarElement.svelte";
8
- export { default as FloatingInput } from "./components/FloatingInput.svelte";
9
- export { default as FloatingSelect } from "./components/FloatingSelect.svelte";
8
+ export { default as Input } from "./components/Input.svelte";
9
+ export { default as Select } from "./components/Select.svelte";
10
10
  export { default as Text } from "./components/Text.svelte";
11
11
  export { default as Card } from "./components/Card.svelte";
12
12
  export { default as Checkbox } from "./components/Checkbox.svelte";
13
13
  export { default as Progress } from "./components/Progress.svelte";
14
+ export { default as Modal } from "./components/Modal.svelte";
14
15
  export { fbmBackground } from "./actions/fbm.js";
@@ -43,10 +43,43 @@ html.dark {
43
43
  --vpcui-sub-text: #A0A0A0;
44
44
  --vpcui-contrast-text: #111;
45
45
  --vpcui-form-background: #2A2A2A;
46
- --vpcui-form-border: #3A3A3A;
46
+ --vpcui-form-border: #4A4A4A;
47
47
  --vpcui-navbar-element-hover-background: var(--color-zinc-900);
48
48
  }
49
49
 
50
50
  html {
51
51
  background-color: var(--color-main-background);
52
+ }
53
+
54
+ * {
55
+ scrollbar-width: thin;
56
+ scrollbar-color: var(--color-sub-background-hover) transparent;
57
+ }
58
+
59
+ *::-webkit-scrollbar {
60
+ width: 6px;
61
+ height: 6px;
62
+ }
63
+
64
+ *::-webkit-scrollbar-track {
65
+ background: transparent;
66
+ }
67
+
68
+ *::-webkit-scrollbar-thumb {
69
+ background-color: var(--color-sub-background-hover);
70
+ border-radius: 999px;
71
+ }
72
+
73
+ *::-webkit-scrollbar-thumb:hover {
74
+ background-color: var(--color-main-text);
75
+ }
76
+
77
+ input[type="number"]::-webkit-outer-spin-button,
78
+ input[type="number"]::-webkit-inner-spin-button {
79
+ -webkit-appearance: none;
80
+ margin: 0;
81
+ }
82
+
83
+ input[type="number"] {
84
+ -moz-appearance: textfield;
52
85
  }
@@ -0,0 +1,2 @@
1
+ export type PositionStyle = "top" | "right" | "bottom" | "left" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center";
2
+ export declare const positionParts: Record<PositionStyle, string>;
@@ -0,0 +1,11 @@
1
+ export const positionParts = {
2
+ "top": "flex items-start justify-center",
3
+ "right": "flex items-center justify-end",
4
+ "bottom": "flex items-end justify-center",
5
+ "left": "flex items-center justify-start",
6
+ "top-left": "flex items-start justify-start",
7
+ "top-right": "flex items-start justify-end",
8
+ "bottom-left": "flex items-end justify-start",
9
+ "bottom-right": "flex items-end justify-end",
10
+ "center": "flex-center"
11
+ };
@@ -1,6 +1,7 @@
1
+ import type { HTMLButtonAttributes } from "svelte/elements";
1
2
  import type { ColorStyle, ColorStyleType } from "../styles/color.ts";
2
3
  import type { SizeStyle } from "../styles/size.ts";
3
- export interface ButtonProps {
4
+ export interface ButtonProps extends Omit<HTMLButtonAttributes, 'size'> {
4
5
  children?: any;
5
6
  class?: string;
6
7
  pill?: boolean;
@@ -1,7 +1,8 @@
1
+ import type { HTMLAttributes } from "svelte/elements";
1
2
  import type { SizeStyle } from "../styles/size.ts";
2
3
  export type CardVariant = "bordered" | "elevated";
3
4
  export declare const cardVariantStyles: Record<CardVariant, string>;
4
- export interface CardProps {
5
+ export interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'size'> {
5
6
  children?: any;
6
7
  class?: string;
7
8
  href?: string;
@@ -1,7 +1,8 @@
1
1
  import type { Component } from "svelte";
2
2
  import type { SizeStyle } from "../styles/size.ts";
3
+ import type { HTMLInputAttributes } from "svelte/elements";
3
4
  export type InputVariant = "default" | "floating";
4
- export interface FloatingInputProps {
5
+ export interface InputProps extends Omit<HTMLInputAttributes, 'size'> {
5
6
  children?: any;
6
7
  class?: string;
7
8
  label?: string;
@@ -13,6 +14,9 @@ export interface FloatingInputProps {
13
14
  disabled?: boolean;
14
15
  variant?: InputVariant;
15
16
  placeholder?: string;
17
+ min?: number;
18
+ max?: number;
19
+ step?: number;
16
20
  onfocus?: (e?: FocusEvent) => void;
17
21
  onblur?: (e?: FocusEvent) => void;
18
22
  validInputRegex?: RegExp;
@@ -0,0 +1,6 @@
1
+ import type { PositionStyle } from "../styles/posititon.js";
2
+ import type { CardProps } from "./Card.ts";
3
+ export interface ModalProps extends CardProps {
4
+ open?: boolean;
5
+ position?: PositionStyle;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- export interface FloatingSelectProps {
1
+ export interface SelectProps {
2
2
  children?: any;
3
3
  class?: string;
4
4
  label?: string;
@@ -0,0 +1,14 @@
1
+ import type { SizeStyle } from "../styles/size.js";
2
+ export interface TableHeaders {
3
+ key: string;
4
+ label: string;
5
+ }
6
+ export interface TableProps {
7
+ children?: any;
8
+ class?: string;
9
+ tableHeaders?: TableHeaders[];
10
+ tableData?: any[];
11
+ size?: SizeStyle;
12
+ radius?: SizeStyle;
13
+ [key: string]: any;
14
+ }
@@ -0,0 +1,3 @@
1
+ ;
2
+ ;
3
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerius_petrini/corekit-ui",
3
- "version": "0.1.54",
3
+ "version": "0.1.56",
4
4
  "description": "Component Library used across all my projects",
5
5
  "author": "Valerius Petrini Jr.",
6
6
  "license": "MIT",
@@ -1,5 +0,0 @@
1
- import type { FloatingInputProps } from "../types/FloatingInput.ts";
2
- import { type Component } from "svelte";
3
- declare const FloatingInput: Component<FloatingInputProps, {}, "value">;
4
- type FloatingInput = ReturnType<typeof FloatingInput>;
5
- export default FloatingInput;
@@ -1,4 +0,0 @@
1
- import type { FloatingSelectProps } from "../types/FloatingSelect.ts";
2
- declare const FloatingSelect: import("svelte").Component<FloatingSelectProps, {}, "value">;
3
- type FloatingSelect = ReturnType<typeof FloatingSelect>;
4
- export default FloatingSelect;
File without changes
File without changes