lapikit 0.4.6 → 0.4.8

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.
@@ -4,6 +4,7 @@ const lapikitComponents = [
4
4
  'btn',
5
5
  'icon',
6
6
  'avatar',
7
- 'spacer'
7
+ 'spacer',
8
+ 'separator'
8
9
  ];
9
10
  export default lapikitComponents;
@@ -4,3 +4,4 @@ export { default as KitBtn } from './btn/btn.svelte';
4
4
  export { default as KitIcon } from './icon/icon.svelte';
5
5
  export { default as KitAvatar } from './avatar/avatar.svelte';
6
6
  export { default as KitSpacer } from './spacer/spacer.svelte';
7
+ export { default as KitSeparator } from './separator/separator.svelte';
@@ -5,3 +5,4 @@ export { default as KitBtn } from './btn/btn.svelte';
5
5
  export { default as KitIcon } from './icon/icon.svelte';
6
6
  export { default as KitAvatar } from './avatar/avatar.svelte';
7
7
  export { default as KitSpacer } from './spacer/spacer.svelte';
8
+ export { default as KitSeparator } from './separator/separator.svelte';
@@ -0,0 +1,133 @@
1
+ <script lang="ts">
2
+ import { useClassName, useStyles } from '../../utils/index.js';
3
+ import { makeComponentProps } from '../../compiler/mapped-code.js';
4
+ import type { SeparatorProps } from './separator.types.js';
5
+
6
+ let {
7
+ ref = $bindable(),
8
+ is = 'hr',
9
+ light = false,
10
+ dark = false,
11
+ inset = false,
12
+ thickness,
13
+ orientation = 'horizontal',
14
+ opacity,
15
+ color,
16
+ class: className = '',
17
+ style: styleAttr = '',
18
+ 's-class': sClass,
19
+ 's-style': sStyle,
20
+ ...rest
21
+ }: SeparatorProps = $props();
22
+
23
+ let safeOrientation = $derived(
24
+ typeof orientation === 'string' && (orientation === 'horizontal' || orientation === 'vertical')
25
+ ? orientation
26
+ : 'horizontal'
27
+ );
28
+
29
+ let { classProps, styleProps, restProps } = $derived(
30
+ makeComponentProps(rest as Record<string, unknown>)
31
+ );
32
+
33
+ let componentClass = $derived(
34
+ useClassName({
35
+ baseClass: 'kit-separator',
36
+ className: `${className ?? ''}`.trim(),
37
+ sClass,
38
+ classProps
39
+ })
40
+ );
41
+
42
+ let componentStyle = $derived(
43
+ useStyles({
44
+ styleAttr,
45
+ sStyle,
46
+ styleProps
47
+ })
48
+ );
49
+
50
+ let mergedStyle = $derived(
51
+ [
52
+ componentStyle,
53
+ color ? `--kit-separator-color:${color}` : '',
54
+ opacity !== undefined ? `--kit-separator-opacity:${opacity}` : '',
55
+ thickness !== undefined && safeOrientation === 'horizontal'
56
+ ? `--kit-separator-top-width:${typeof thickness === 'number' ? `${thickness}px` : thickness}`
57
+ : '',
58
+ thickness !== undefined && safeOrientation === 'vertical'
59
+ ? `--kit-separator-right-width:${typeof thickness === 'number' ? `${thickness}px` : thickness}`
60
+ : ''
61
+ ]
62
+ .filter(Boolean)
63
+ .join('; ')
64
+ );
65
+ </script>
66
+
67
+ <svelte:element
68
+ this={is}
69
+ bind:this={ref}
70
+ {...restProps}
71
+ class={componentClass}
72
+ style={mergedStyle}
73
+ role="separator"
74
+ aria-orientation={safeOrientation}
75
+ data-light={light || undefined}
76
+ data-dark={dark || undefined}
77
+ data-inset={inset || undefined}
78
+ data-orientation={safeOrientation}
79
+ />
80
+
81
+ <style>
82
+ .kit-separator {
83
+ --kit-separator-color: var(--kit-fg);
84
+ --kit-separator-opacity: 0.12;
85
+ --kit-separator-top-width: thin;
86
+ --kit-separator-right-width: thin;
87
+ --kit-separator-vertical-min-size: 1.5rem;
88
+
89
+ display: block;
90
+ flex: 1 1 100%;
91
+ height: 0;
92
+ max-height: 0;
93
+ opacity: var(--kit-separator-opacity);
94
+ border-color: var(--kit-separator-color);
95
+ border-style: solid;
96
+ transition: inherit;
97
+ }
98
+
99
+ .kit-separator[data-light='true'] {
100
+ --kit-separator-color: color-mix(in oklab, var(--kit-fg), white 40%);
101
+ }
102
+
103
+ .kit-separator[data-dark='true'] {
104
+ --kit-separator-color: color-mix(in oklab, white, transparent 18%);
105
+ }
106
+
107
+ .kit-separator[data-inset]:not([data-orientation='vertical']) {
108
+ max-width: calc(100% - 4.5rem);
109
+ margin-inline-start: 4.5rem;
110
+ }
111
+
112
+ .kit-separator[data-inset][data-orientation='vertical'] {
113
+ margin-block: 0.5rem;
114
+ max-height: calc(100% - 1rem);
115
+ }
116
+
117
+ .kit-separator:not([data-orientation='vertical']) {
118
+ width: 100%;
119
+ border-width: var(--kit-separator-top-width) 0 0 0;
120
+ }
121
+
122
+ .kit-separator[data-orientation='vertical'] {
123
+ align-self: stretch;
124
+ display: inline-flex;
125
+ width: 0;
126
+ height: auto;
127
+ min-height: var(--kit-separator-vertical-min-size);
128
+ max-width: 0;
129
+ max-height: none;
130
+ vertical-align: text-bottom;
131
+ border-width: 0 var(--kit-separator-right-width) 0 0;
132
+ }
133
+ </style>
@@ -0,0 +1,4 @@
1
+ import type { SeparatorProps } from './separator.types.ts';
2
+ declare const Separator: import("svelte").Component<SeparatorProps, {}, "ref">;
3
+ type Separator = ReturnType<typeof Separator>;
4
+ export default Separator;
@@ -0,0 +1,14 @@
1
+ import type { Base } from '../../utils/types/index.js';
2
+ type Orientation = 'horizontal' | 'vertical';
3
+ export interface SeparatorProps extends Base {
4
+ ref?: HTMLElement | null;
5
+ is?: 'div' | 'hr';
6
+ light?: boolean;
7
+ dark?: boolean;
8
+ inset?: boolean;
9
+ thickness?: string | number;
10
+ opacity?: string | number;
11
+ color?: string;
12
+ orientation?: Orientation | Record<string, Orientation>;
13
+ }
14
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapikit",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"