uisv 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ > [!WARNING]
2
+ This project is heavily WIP
3
+
1
4
  # uisv
2
5
 
3
6
  ui library for the rest of us
@@ -1,5 +1,10 @@
1
1
  <script lang="ts" module>
2
- export type ButtonVariant = 'link' | 'solid' | 'outline' | 'soft' | 'subtle' | 'ghost';
2
+ // import { FORM_LOADING_CONTEXT_KEY } from '../utils/keys.js';
3
+ import { type Component, type Snippet } from 'svelte';
4
+ import { isSnippet } from '../utils/common.js';
5
+ import { tv } from 'tailwind-variants';
6
+ import type { PropColor } from '../types.js';
7
+ import type { ClassNameValue } from 'tailwind-merge';
3
8
 
4
9
  export type ButtonProps = {
5
10
  /** The underlying DOM element being rendered. You can bind to this to get a reference to the element. */
@@ -30,7 +35,7 @@
30
35
  /**
31
36
  * @defaultValue 'solid'
32
37
  */
33
- variant?: ButtonVariant;
38
+ variant?: 'link' | 'solid' | 'outline' | 'soft' | 'subtle' | 'ghost';
34
39
  // activevariant?: ButtonVariant;
35
40
  /**
36
41
  * @defaultValue 'md'
@@ -42,21 +47,14 @@
42
47
  loadingauto?: boolean;
43
48
  onclick?: (event: MouseEvent) => void | Promise<void>;
44
49
  ui?: {
45
- base?: ClassValue;
46
- icon?: ClassValue;
50
+ base?: ClassNameValue;
51
+ icon?: ClassNameValue;
47
52
  };
48
53
  children?: Snippet;
49
54
  };
50
55
  </script>
51
56
 
52
57
  <script lang="ts">
53
- // import { FORM_LOADING_CONTEXT_KEY } from '../utils/keys.js';
54
- import { type Component, type Snippet } from 'svelte';
55
- import { isSnippet } from '../utils/common.js';
56
- import { tv } from 'tailwind-variants';
57
- import type { ClassValue } from 'svelte/elements';
58
- import type { PropColor } from '../types.js';
59
-
60
58
  // let form_loading = getContext<{ value: boolean } | undefined>(FORM_LOADING_CONTEXT_KEY);
61
59
  let {
62
60
  ref = $bindable(),
@@ -93,7 +91,7 @@
93
91
  tv({
94
92
  slots: {
95
93
  icon: '',
96
- base: 'transition flex items-center font-sans'
94
+ base: 'transition flex-inline items-center font-sans'
97
95
  },
98
96
  variants: {
99
97
  color: {
@@ -126,7 +124,8 @@
126
124
  true: 'w-full'
127
125
  },
128
126
  disabled: {
129
- true: 'cursor-not-allowed'
127
+ true: 'cursor-not-allowed',
128
+ false: 'cursor-pointer'
130
129
  }
131
130
  },
132
131
  compoundVariants: [
@@ -333,7 +332,9 @@
333
332
  <a
334
333
  {href}
335
334
  {target}
336
- class={[classes.base(), !children && icon ? 'px-0 aspect-square' : '', ui.base]}
335
+ class={classes.base({
336
+ class: [!children && icon ? 'px-0 aspect-square justify-center' : '', ui.base]
337
+ })}
337
338
  onclick={onClickWrapper}
338
339
  >
339
340
  {@render Content()}
@@ -342,7 +343,9 @@
342
343
  <button
343
344
  {type}
344
345
  disabled={disabled || is_loading}
345
- class={[classes.base(), !children && icon ? 'px-0 aspect-square' : '', ui.base]}
346
+ class={classes.base({
347
+ class: [!children && icon ? 'px-0 aspect-square justify-center' : '', ui.base]
348
+ })}
346
349
  onclick={onClickWrapper}
347
350
  >
348
351
  {@render Content()}
@@ -370,7 +373,9 @@
370
373
 
371
374
  {#if IconCom}
372
375
  {#if typeof IconCom === 'string'}
373
- <div class={['pi', IconCom, is_loading ? 'animate-spin' : '', classes.icon(), ui.icon]}></div>
376
+ <div
377
+ class={classes.icon({ class: ['pi', IconCom, is_loading && 'animate-spin', ui.icon] })}
378
+ ></div>
374
379
  {:else if isSnippet(IconCom)}
375
380
  {@render IconCom()}
376
381
  {:else}
@@ -1,4 +1,6 @@
1
- export type ButtonVariant = 'link' | 'solid' | 'outline' | 'soft' | 'subtle' | 'ghost';
1
+ import { type Component, type Snippet } from 'svelte';
2
+ import type { PropColor } from '../types.js';
3
+ import type { ClassNameValue } from 'tailwind-merge';
2
4
  export type ButtonProps = {
3
5
  /** The underlying DOM element being rendered. You can bind to this to get a reference to the element. */
4
6
  ref?: HTMLButtonElement | HTMLAnchorElement;
@@ -26,7 +28,7 @@ export type ButtonProps = {
26
28
  /**
27
29
  * @defaultValue 'solid'
28
30
  */
29
- variant?: ButtonVariant;
31
+ variant?: 'link' | 'solid' | 'outline' | 'soft' | 'subtle' | 'ghost';
30
32
  /**
31
33
  * @defaultValue 'md'
32
34
  */
@@ -37,14 +39,11 @@ export type ButtonProps = {
37
39
  loadingauto?: boolean;
38
40
  onclick?: (event: MouseEvent) => void | Promise<void>;
39
41
  ui?: {
40
- base?: ClassValue;
41
- icon?: ClassValue;
42
+ base?: ClassNameValue;
43
+ icon?: ClassNameValue;
42
44
  };
43
45
  children?: Snippet;
44
46
  };
45
- import { type Component, type Snippet } from 'svelte';
46
- import type { ClassValue } from 'svelte/elements';
47
- import type { PropColor } from '../types.js';
48
47
  declare const Button: Component<ButtonProps, {}, "ref">;
49
48
  type Button = ReturnType<typeof Button>;
50
49
  export default Button;
@@ -0,0 +1,28 @@
1
+ <script module lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { ClassNameValue } from 'tailwind-merge';
4
+ import { tv } from 'tailwind-variants';
5
+
6
+ export type H1Props = {
7
+ children: Snippet;
8
+ ui?: { root?: ClassNameValue };
9
+ };
10
+ </script>
11
+
12
+ <script lang="ts">
13
+ const { children, ui = {} }: H1Props = $props();
14
+
15
+ const classes = $derived(
16
+ tv({
17
+ variants: {
18
+ slots: {
19
+ root: 'text-4xl text-highlighted font-bold mb-8 scroll-mt-[calc(45px+var(--ui-header-height))] lg:scroll-mt-(--ui-header-height)'
20
+ }
21
+ }
22
+ })({ class: ui.root })
23
+ );
24
+ </script>
25
+
26
+ <h1 class={classes}>
27
+ {@render children()}
28
+ </h1>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ export type H1Props = {
4
+ children: Snippet;
5
+ ui?: {
6
+ root?: ClassNameValue;
7
+ };
8
+ };
9
+ declare const H1: import("svelte").Component<H1Props, {}, "">;
10
+ type H1 = ReturnType<typeof H1>;
11
+ export default H1;
@@ -0,0 +1,30 @@
1
+ <script module lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { ClassNameValue } from 'tailwind-merge';
4
+ import { tv } from 'tailwind-variants';
5
+
6
+ export type H2Props = {
7
+ children: Snippet;
8
+ ui?: { root?: ClassNameValue };
9
+ };
10
+ </script>
11
+
12
+ <script lang="ts">
13
+ const { children, ui = {} }: H2Props = $props();
14
+
15
+ const classes = $derived(
16
+ tv({
17
+ base: [
18
+ 'relative text-2xl text-highlighted font-bold mt-12 mb-6',
19
+ 'scroll-mt-[calc(48px+45px+var(--ui-header-height))] lg:scroll-mt-[calc(48px+var(--ui-header-height))]',
20
+ 'hover:[&>a>code]:(border-primary text-primary)',
21
+ '[&>a>code]:(transition-colors text-xl/7 font-bold border-dashed)',
22
+ '[&>a]:focus-visible:outline-primary'
23
+ ]
24
+ })({ class: ui.root })
25
+ );
26
+ </script>
27
+
28
+ <h1 class={classes}>
29
+ {@render children()}
30
+ </h1>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ export type H2Props = {
4
+ children: Snippet;
5
+ ui?: {
6
+ root?: ClassNameValue;
7
+ };
8
+ };
9
+ declare const H2: import("svelte").Component<H2Props, {}, "">;
10
+ type H2 = ReturnType<typeof H2>;
11
+ export default H2;
@@ -20,3 +20,11 @@ export * from './checkbox.svelte';
20
20
  export { default as Checkbox } from './checkbox.svelte';
21
21
  export * from './checkboxgroup.svelte';
22
22
  export { default as CheckboxGroup } from './checkboxgroup.svelte';
23
+ export * from './h1.svelte';
24
+ export { default as H1 } from './h1.svelte';
25
+ export * from './h2.svelte';
26
+ export { default as H2 } from './h2.svelte';
27
+ export * from './p.svelte';
28
+ export { default as P } from './p.svelte';
29
+ export * from './pin-input.svelte';
30
+ export { default as PinInput } from './pin-input.svelte';
@@ -20,3 +20,11 @@ export * from './checkbox.svelte';
20
20
  export { default as Checkbox } from './checkbox.svelte';
21
21
  export * from './checkboxgroup.svelte';
22
22
  export { default as CheckboxGroup } from './checkboxgroup.svelte';
23
+ export * from './h1.svelte';
24
+ export { default as H1 } from './h1.svelte';
25
+ export * from './h2.svelte';
26
+ export { default as H2 } from './h2.svelte';
27
+ export * from './p.svelte';
28
+ export { default as P } from './p.svelte';
29
+ export * from './pin-input.svelte';
30
+ export { default as PinInput } from './pin-input.svelte';
@@ -0,0 +1,22 @@
1
+ <script module lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { ClassNameValue } from 'tailwind-merge';
4
+ import { tv } from 'tailwind-variants';
5
+
6
+ export type ParagraphProps = {
7
+ children: Snippet;
8
+ ui?: { root?: ClassNameValue };
9
+ };
10
+ </script>
11
+
12
+ <script lang="ts">
13
+ const { children, ui = {} }: ParagraphProps = $props();
14
+ </script>
15
+
16
+ <p
17
+ class={tv({
18
+ base: 'my-5 leading-7 text-pretty'
19
+ })({ class: ui.root })}
20
+ >
21
+ {@render children()}
22
+ </p>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ export type ParagraphProps = {
4
+ children: Snippet;
5
+ ui?: {
6
+ root?: ClassNameValue;
7
+ };
8
+ };
9
+ declare const P: import("svelte").Component<ParagraphProps, {}, "">;
10
+ type P = ReturnType<typeof P>;
11
+ export default P;
@@ -0,0 +1,162 @@
1
+ <script module lang="ts">
2
+ import type { PropColor } from '../types.js';
3
+ import { onMount } from 'svelte';
4
+ import type { ClassNameValue } from 'tailwind-merge';
5
+ import { tv } from 'tailwind-variants';
6
+
7
+ export type PinInputProps = {
8
+ value?: number[] | string[];
9
+ color?: PropColor;
10
+ variant?: 'outline' | 'soft' | 'subtle' | 'ghost' | 'none';
11
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
12
+ length?: number;
13
+ autofocus?: boolean | number;
14
+ id?: string;
15
+ mask?: boolean;
16
+ name?: string;
17
+ disabled?: boolean;
18
+ otp?: boolean;
19
+ placeholder?: string;
20
+ required?: boolean;
21
+ type?: 'text' | 'number';
22
+ ui?: { root?: ClassNameValue; cell?: ClassNameValue };
23
+ };
24
+ </script>
25
+
26
+ <script lang="ts">
27
+ const KEYS_TO_IGNORE = [
28
+ 'ArrowLeft',
29
+ 'ArrowRight',
30
+ 'ArrowUp',
31
+ 'ArrowDown',
32
+ 'Home',
33
+ 'End',
34
+ 'Escape',
35
+ 'Enter',
36
+ 'Tab',
37
+ 'Shift',
38
+ 'Control',
39
+ 'Meta'
40
+ ];
41
+
42
+ let {
43
+ value = $bindable([]),
44
+ color = 'primary',
45
+ variant = 'outline',
46
+ size = 'md',
47
+ length = 5,
48
+ autofocus,
49
+ id,
50
+ mask,
51
+ name,
52
+ disabled,
53
+ otp,
54
+ placeholder,
55
+ required,
56
+ type = 'text',
57
+ ui = {}
58
+ }: PinInputProps = $props();
59
+ const internal_id = $props.id();
60
+ let input_els = $state<HTMLInputElement[]>([]);
61
+
62
+ const classes = $derived(
63
+ tv({
64
+ slots: { root: 'flex gap-2', cell: 'rounded text-center outline-none transition relative' },
65
+ variants: {
66
+ color: {
67
+ primary: '',
68
+ secondary: '',
69
+ info: '',
70
+ success: '',
71
+ warning: '',
72
+ error: ''
73
+ },
74
+ size: {
75
+ xs: { root: '', cell: 'size-6' },
76
+ sm: { root: '', cell: 'size-7' },
77
+ md: { root: '', cell: 'size-8' },
78
+ lg: { root: '', cell: 'size-9' },
79
+ xl: { root: '', cell: 'size-10' }
80
+ },
81
+ variant: {
82
+ outline: {
83
+ cell: 'border border-secondary-300 focus:(border-2)'
84
+ },
85
+ soft: {
86
+ cell: 'bg-secondary-50 hover:(bg-secondary-100) focus:(bg-secondary-100)'
87
+ },
88
+ subtle: { cell: 'border border-secondary-300 bg-secondary-100 focus:(border-2)' },
89
+ ghost: { cell: 'hover:(bg-secondary-100) focus:(bg-secondary-100)' },
90
+ none: { cell: '' }
91
+ }
92
+ },
93
+ compoundVariants: [
94
+ {
95
+ variant: ['outline', 'subtle'],
96
+ color: 'primary',
97
+ class: { cell: 'focus:(border-primary-500)' }
98
+ },
99
+ {
100
+ variant: ['outline', 'subtle'],
101
+ color: 'secondary',
102
+ class: { cell: 'focus:(border-secondary-900)' }
103
+ },
104
+ {
105
+ variant: ['outline', 'subtle'],
106
+ color: 'info',
107
+ class: { cell: 'focus:(border-info-500)' }
108
+ },
109
+ {
110
+ variant: ['outline', 'subtle'],
111
+ color: 'success',
112
+ class: { cell: 'focus:(border-success-500)' }
113
+ },
114
+ {
115
+ variant: ['outline', 'subtle'],
116
+ color: 'warning',
117
+ class: { cell: 'focus:(border-warning-500)' }
118
+ },
119
+ {
120
+ variant: ['outline', 'subtle'],
121
+ color: 'error',
122
+ class: { cell: 'focus:(border-error-500)' }
123
+ }
124
+ ]
125
+ })({ size, color, variant, class: ui.root })
126
+ );
127
+
128
+ onMount(() => {
129
+ if (!autofocus || input_els.length === 0) return;
130
+
131
+ input_els[0].focus();
132
+ });
133
+ </script>
134
+
135
+ <div id={id || internal_id} class={classes.root({ class: ui.root })}>
136
+ {#each { length }, i (i)}
137
+ <input
138
+ bind:this={input_els[i]}
139
+ bind:value={
140
+ () => (mask ? '•' : value[i]?.toString()?.slice(-1)),
141
+ (v: string) => {
142
+ try {
143
+ value[i] = type === 'text' ? v.slice(-1) : parseInt(v.slice(-1));
144
+
145
+ if (value[i] && input_els[i + 1]) input_els[i + 1].focus();
146
+ } catch {
147
+ return;
148
+ }
149
+ }
150
+ }
151
+ class={classes.cell({ class: ui.cell })}
152
+ onkeydown={(e) => {
153
+ if (KEYS_TO_IGNORE.includes(e.key)) e.preventDefault();
154
+ if (type === 'number' && isNaN(parseInt(e.key))) e.preventDefault();
155
+ const DIR: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1 };
156
+ if (!DIR[e.key] || !input_els[i + DIR[e.key]]) return;
157
+ input_els[i + DIR[e.key]].focus();
158
+ }}
159
+ {placeholder}
160
+ />
161
+ {/each}
162
+ </div>
@@ -0,0 +1,25 @@
1
+ import type { PropColor } from '../types.js';
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ export type PinInputProps = {
4
+ value?: number[] | string[];
5
+ color?: PropColor;
6
+ variant?: 'outline' | 'soft' | 'subtle' | 'ghost' | 'none';
7
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
8
+ length?: number;
9
+ autofocus?: boolean | number;
10
+ id?: string;
11
+ mask?: boolean;
12
+ name?: string;
13
+ disabled?: boolean;
14
+ otp?: boolean;
15
+ placeholder?: string;
16
+ required?: boolean;
17
+ type?: 'text' | 'number';
18
+ ui?: {
19
+ root?: ClassNameValue;
20
+ cell?: ClassNameValue;
21
+ };
22
+ };
23
+ declare const PinInput: import("svelte").Component<PinInputProps, {}, "value">;
24
+ type PinInput = ReturnType<typeof PinInput>;
25
+ export default PinInput;
@@ -122,6 +122,7 @@
122
122
  data-state={value ? 'checked' : 'unchecked'}
123
123
  class={classes.container({ class: [loading && 'cursor-not-allowed', ui.thumb] })}
124
124
  onclick={() => {
125
+ console.log('click');
125
126
  if (loading) return;
126
127
  value = !value;
127
128
  }}
package/dist/vite.js CHANGED
@@ -24,7 +24,7 @@ export function uisv(options) {
24
24
  uno_plugin({
25
25
  theme: {
26
26
  radius: {
27
- base: `${_opts.radius || 0.25}rem`
27
+ base: `${_opts.radius || 0.375}rem`
28
28
  }
29
29
  },
30
30
  preflights: [
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "uisv",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "ui library for the rest of us",
5
5
  "license": "MIT",
6
6
  "repository": "ui-sv/uisv",
7
- "homepage": "https://github.com/ui-sv/uisv",
7
+ "homepage": "https://uisv.pages.dev",
8
8
  "scripts": {
9
9
  "dev": "vite dev",
10
10
  "build": "vite build && npm run prepack",
@@ -45,6 +45,7 @@
45
45
  "devDependencies": {
46
46
  "@eslint/compat": "^1.2.5",
47
47
  "@eslint/js": "^9.22.0",
48
+ "@iconify-json/logos": "^1.2.9",
48
49
  "@iconify-json/lucide": "^1.2.68",
49
50
  "@iconify-json/solar": "^1.2.4",
50
51
  "@sveltejs/adapter-auto": "^6.0.0",
@@ -57,13 +58,13 @@
57
58
  "@unocss/reset": "^66.5.1",
58
59
  "@vitest/browser": "^3.2.3",
59
60
  "bits-ui": "^2.11.0",
60
- "carta-md": "^4.11.1",
61
61
  "defu": "^6.1.4",
62
62
  "eslint": "^9.22.0",
63
63
  "eslint-config-prettier": "^10.0.1",
64
64
  "eslint-plugin-svelte": "^3.0.0",
65
65
  "globals": "^16.0.0",
66
66
  "mdsvex": "^0.12.3",
67
+ "mode-watcher": "^1.1.0",
67
68
  "playwright": "^1.53.0",
68
69
  "prettier": "^3.4.2",
69
70
  "prettier-plugin-svelte": "^3.3.3",
@@ -73,7 +74,6 @@
73
74
  "svelte-check": "^4.0.0",
74
75
  "tailwind-merge": "^3.3.1",
75
76
  "tailwind-variants": "^3.1.1",
76
- "tailwindcss": "^4.1.13",
77
77
  "theme-colors": "^0.1.0",
78
78
  "typescript": "^5.0.0",
79
79
  "typescript-eslint": "^8.20.0",