@valerius_petrini/corekit-ui 0.1.73 → 0.1.74

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.
@@ -0,0 +1,34 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from "@storybook/addon-svelte-csf";
3
+ import Button from "../../inputs/Button/index.svelte";
4
+ import Text from "../../typography/Text/index.svelte";
5
+ import Modal from "./index.svelte";
6
+ import { sizeStyles } from "../../../styles/size.js";
7
+
8
+ const { Story } = defineMeta({
9
+ title: "Components/Feedback/Modal",
10
+ component: Modal,
11
+ argTypes: {
12
+ variant: {
13
+ control: "select",
14
+ options: ["bordered", "elevated"],
15
+ },
16
+ size: {
17
+ control: "select",
18
+ options: sizeStyles,
19
+ },
20
+ radius: {
21
+ control: "select",
22
+ options: sizeStyles,
23
+ },
24
+ href: { control: "text" },
25
+ external: { control: "boolean" },
26
+ },
27
+ });
28
+ </script>
29
+
30
+ <Story name="Default" args={{ variant: "bordered", size: "md" }}>
31
+ <Text tag="h2" class="text-2xl font-bold mb-4">Customizable Modal</Text>
32
+ <Text class="mb-4">This is a customizable modal component. You can add any content here and style it as needed.</Text>
33
+ <Button href="https://example.com" target="_blank">Learn More</Button>
34
+ </Story>
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Index: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type Index = InstanceType<typeof Index>;
18
+ export default Index;
@@ -2,7 +2,8 @@
2
2
  import type { ModalProps } from "./types";
3
3
  import { fade, fly } from "svelte/transition";
4
4
  import Card from "../../display/Card/index.svelte";
5
- import { positionParts } from "../../../styles/posititon.js";
5
+ import { modalPositionParts } from "../../../styles/posititon.js";
6
+ import { getSizeStyleClass } from "../../../styles/size.js";
6
7
  import { twMerge } from "tailwind-merge";
7
8
 
8
9
  let {
@@ -11,26 +12,34 @@
11
12
  element = $bindable(),
12
13
  open = $bindable(),
13
14
  position = "center",
15
+ size = "md",
14
16
  ...restProps
15
17
  }: ModalProps = $props();
16
18
 
17
- const defaultOuterDivClass = "w-full h-screen fixed bg-black/50 z-200 flex items-center justify-center top-0 left-0 p-4";
18
- const combinedOuterDivClass = $derived(twMerge(defaultOuterDivClass));
19
+ const outerClass = $derived(twMerge(
20
+ "fixed inset-0 z-300 flex flex-col bg-black/50 p-4",
21
+ modalPositionParts[position]
22
+ ));
19
23
 
20
- const defaultInnerDivClass = "z-300 max-h-full absolute";
21
- const positionInnerDivClass = $derived(positionParts[position] || "");
22
- const combinedInnerDivClass = $derived(twMerge(defaultInnerDivClass, positionInnerDivClass));
23
-
24
- const defaultCardClass = "overflow-y-auto max-h-[95vh]";
25
- const combinedCardClass = $derived(twMerge(defaultCardClass, className));
24
+ const cardClass = $derived(twMerge(
25
+ "w-full max-h-[95vh] overflow-y-auto",
26
+ getSizeStyleClass(size, "card"),
27
+ className
28
+ ));
26
29
  </script>
27
30
 
28
31
  {#if open}
29
32
  <!-- svelte-ignore a11y_click_events_have_key_events -->
30
33
  <!-- svelte-ignore a11y_no_static_element_interactions -->
31
- <div class={combinedOuterDivClass} transition:fade={{ duration: 200 }} onclick={() => open = false} bind:this={element}>
32
- <div class={combinedInnerDivClass} transition:fly={{ y: -20, duration: 200 }} onclick={(e) => e.stopPropagation()}>
33
- <Card class={combinedCardClass} {...restProps}>
34
+ <div
35
+ class={outerClass}
36
+ transition:fade={{ duration: 200 }}
37
+ onclick={() => open = false}
38
+ bind:this={element}>
39
+ <div
40
+ transition:fly={{ y: -20, duration: 200 }}
41
+ onclick={(e) => e.stopPropagation()}>
42
+ <Card class={cardClass} {...restProps}>
34
43
  {@render children()}
35
44
  </Card>
36
45
  </div>
@@ -0,0 +1,22 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from "@storybook/addon-svelte-csf";
3
+ import Textarea from "./index.svelte";
4
+ import { sizeStyles } from "../../../styles/size.js";
5
+
6
+ const { Story } = defineMeta({
7
+ title: "Components/Inputs/Textarea",
8
+ component: Textarea,
9
+ argTypes: {
10
+ size: {
11
+ control: "select",
12
+ options: sizeStyles,
13
+ },
14
+ radius: {
15
+ control: "select",
16
+ options: sizeStyles,
17
+ }
18
+ },
19
+ });
20
+ </script>
21
+
22
+ <Story name="Default" args={{ label: "Input Label", placeholder: "Enter text here..." }}></Story>
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Index: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type Index = InstanceType<typeof Index>;
18
+ export default Index;
@@ -0,0 +1,82 @@
1
+ <script module>
2
+ let count = 0;
3
+ </script>
4
+
5
+ <script lang="ts">
6
+ import type { TextareaProps } from "./types";
7
+ import { twMerge } from "tailwind-merge";
8
+ import { getSizeStyleClass } from "../../../styles/size.js";
9
+
10
+ import BaseInput from "../helper/BaseInput.svelte";
11
+
12
+ let {
13
+ children = undefined,
14
+ class: className = "",
15
+ element = $bindable(),
16
+ label = "",
17
+ labelClass = "",
18
+ divClass = "",
19
+ outerDivClass = "",
20
+ icon = undefined,
21
+ placeholder = "",
22
+ value = $bindable(),
23
+ required = false,
24
+ disabled = false,
25
+ size = "md",
26
+ radius = "md",
27
+ id = `textarea-${count++}`,
28
+ ...restProps
29
+ }: TextareaProps = $props();
30
+
31
+ const sizeClasses = $derived(getSizeStyleClass(size, "form"));
32
+ const labelSizeClass = $derived(getSizeStyleClass(size, "formLabel"));
33
+
34
+ const customStyle = $derived.by(() => {
35
+ const styles: string[] = [];
36
+
37
+ if (typeof size === "number")
38
+ styles.push(`width: ${size}px`);
39
+
40
+ if (typeof radius === "number")
41
+ styles.push(`border-radius: ${radius}px`);
42
+
43
+ return styles.join("; ");
44
+ });
45
+
46
+ let defaultClass = "text-main-text w-full outline-none px-1.5 w-full bg-inherit border-0 focus:ring-0 focus-visible:ring-0 rounded-none py-2.5!";
47
+
48
+ let combinedClass = $derived(twMerge(defaultClass, sizeClasses, labelSizeClass, className));
49
+ let combinedDivClass = $derived(twMerge(divClass));
50
+ </script>
51
+
52
+ <BaseInput
53
+ {children}
54
+ {className}
55
+ {label}
56
+ {labelClass}
57
+ divClass={combinedDivClass}
58
+ {outerDivClass}
59
+ {value}
60
+ {required}
61
+ {disabled}
62
+ {size}
63
+ {radius}
64
+ {id}
65
+ bind:wrapper={element}
66
+ {...restProps}>
67
+
68
+
69
+ {#snippet innerDivElement()}
70
+ <textarea
71
+ {id}
72
+ bind:value={value}
73
+ class={combinedClass}
74
+ {required}
75
+ {disabled}
76
+ placeholder={placeholder}
77
+ aria-disabled={disabled}
78
+ style={customStyle}
79
+ {...restProps}></textarea>
80
+ {/snippet}
81
+ </BaseInput>
82
+
@@ -0,0 +1,4 @@
1
+ import type { TextareaProps } from "./types";
2
+ declare const Index: import("svelte").Component<TextareaProps, {}, "element" | "value">;
3
+ type Index = ReturnType<typeof Index>;
4
+ export default Index;
@@ -0,0 +1,3 @@
1
+ import type { BaseInputProps } from "../../../types/BaseComponent";
2
+ export interface TextareaProps extends BaseInputProps {
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
1
  export type PositionStyle = "top" | "right" | "bottom" | "left" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center";
2
2
  export type TooltipPosition = "top" | "right" | "bottom" | "left";
3
3
  export declare const positionParts: Record<PositionStyle, string>;
4
+ export declare const modalPositionParts: Record<PositionStyle, string>;
@@ -9,3 +9,14 @@ export const positionParts = {
9
9
  "bottom-right": "bottom-4 right-4",
10
10
  "center": "top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
11
11
  };
12
+ export const modalPositionParts = {
13
+ "center": "items-center justify-center",
14
+ "top": "items-center justify-start pt-4",
15
+ "bottom": "items-center justify-end pb-4",
16
+ "left": "items-start justify-center pl-4",
17
+ "right": "items-end justify-center pr-4",
18
+ "top-left": "items-start justify-start p-4",
19
+ "top-right": "items-end justify-start p-4",
20
+ "bottom-left": "items-start justify-end p-4",
21
+ "bottom-right": "items-end justify-end p-4",
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerius_petrini/corekit-ui",
3
- "version": "0.1.73",
3
+ "version": "0.1.74",
4
4
  "description": "Component Library used across all my projects",
5
5
  "author": "Valerius Petrini Jr.",
6
6
  "license": "MIT",