lapikit 0.6.1 → 0.6.2

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.
@@ -1,6 +1,19 @@
1
+ import type { Action } from 'svelte/action';
2
+ /** Accordion */
1
3
  export type AccordionOptions = {
2
4
  multiple?: boolean;
3
5
  readOnly?: boolean;
4
6
  };
5
7
  /**Modal */
6
8
  export type ModalState = boolean | 'persistent';
9
+ /**Theme */
10
+ export type ThemeOptions = {
11
+ name?: string;
12
+ key?: string;
13
+ overridden?: boolean;
14
+ };
15
+ export type ThemeAction = {
16
+ action: Action<HTMLElement, ThemeOptions | undefined>;
17
+ set: (name: string) => void;
18
+ readonly active: string;
19
+ };
@@ -2,3 +2,10 @@ export type PropValue = string | boolean | number | null | undefined;
2
2
  export type SizeType = 'default' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
3
3
  export type RoundedType = 0 | '0' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
4
4
  export type DensityType = 'none' | 'compact' | 'default' | 'comfortable';
5
+ export type ElevationType = '0' | '1' | '2' | '3' | '4' | '5';
6
+ export interface ElevationState {
7
+ base?: ElevationType;
8
+ hover?: ElevationType;
9
+ active?: ElevationType;
10
+ }
11
+ export type ElevationProps = ElevationType | ElevationState;
@@ -1,92 +1,43 @@
1
1
  <script lang="ts">
2
- let { ref = $bindable(), children, ...rest } = $props();
2
+ import { makeComponentProps } from '../../html-mapped';
3
+ import { useClassName, useStyles } from '../../utils';
4
+ import type { AppProps } from './app.types';
5
+
6
+ let {
7
+ ref = $bindable(),
8
+ children,
9
+ class: className = '',
10
+ style: styleAttr = '',
11
+ 's-class': sClass,
12
+ 's-style': sStyle,
13
+ ...rest
14
+ }: AppProps = $props();
15
+
16
+ let { classProps, styleProps, restProps } = $derived(makeComponentProps(rest));
17
+
18
+ let componentClass = $derived(
19
+ useClassName({
20
+ baseClass: 'kit-application',
21
+ className: `${className ?? ''}`.trim(),
22
+ sClass,
23
+ classProps
24
+ })
25
+ );
26
+
27
+ let componentStyle = $derived(
28
+ useStyles({
29
+ styleAttr,
30
+ sStyle,
31
+ styleProps
32
+ })
33
+ );
3
34
  </script>
4
35
 
5
- <div id="kit-app" bind:this={ref} {...rest} class={['kit-application', rest.class]}>
36
+ <div id="kit-app" bind:this={ref} class={componentClass} style={componentStyle} {...restProps}>
6
37
  {@render children?.()}
7
38
  </div>
8
39
 
9
40
  <style>
10
- .kit-application {
11
- color-scheme: light;
12
-
13
- /* Hue vars — used by components for dynamic semantic color calculations */
14
- --kit-h-neutral: 220;
15
- --kit-h-success: 145;
16
- --kit-h-warning: 35;
17
- --kit-h-danger: 5;
18
- --kit-h-info: 205;
19
-
20
- --kit-bg: hsl(0 0% 100%);
21
- --kit-fg: hsl(222 20% 10%);
22
- --kit-muted: hsl(220 10% 45%);
23
-
24
- --kit-surface-1: hsl(0 0% 100%);
25
- --kit-surface-2: hsl(220 20% 98%);
26
- --kit-surface-3: hsl(220 18% 94%);
27
-
28
- --kit-border: hsl(220 16% 88%);
29
-
30
- --kit-accent: hsl(220 90% 56%);
31
-
32
- --kit-focus: hsl(35, 90%, 56%);
33
-
34
- /* Layout */
35
- --kit-radius-1: 8px;
36
- --kit-radius-2: 12px;
37
- --kit-space-1: 6px;
38
- --kit-space-2: 10px;
39
- --kit-space-3: 14px;
40
- --kit-disabled-opacity: 0.55;
41
- --kit-font:
42
- ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
43
- 'Segoe UI Symbol', 'Noto Color Emoji';
44
-
45
- /* ─── Color tokens (light mode defaults) ─────────────────────────── */
46
-
47
- /* Backgrounds */
48
- --kit-color-bg: hsl(0 0% 100%);
49
- --kit-color-bg-secondary: hsl(240 15% 96.5%);
50
- --kit-color-bg-tertiary: hsl(240 10% 93%);
51
-
52
- /* Surfaces — elevated layers (cards, sheets, popovers) */
53
- --kit-color-surface: hsl(0 0% 100%);
54
- --kit-color-surface-raised: hsl(0 0% 100%);
55
-
56
- /* Labels — text hierarchy */
57
- --kit-color-label: hsl(222 20% 10%);
58
- --kit-color-label-secondary: hsl(220 10% 40%);
59
- --kit-color-label-tertiary: hsl(220 8% 58%);
60
- --kit-color-label-quaternary: hsl(220 5% 76%);
61
-
62
- /* Fills — control & input backgrounds */
63
- --kit-color-fill: hsl(240 4% 91%);
64
- --kit-color-fill-secondary: hsl(240 8% 93%);
65
- --kit-color-fill-tertiary: hsl(240 11% 95%);
66
-
67
- /* Separator */
68
- --kit-color-separator: hsl(220 16% 88%);
69
-
70
- /* Semantic */
71
- --kit-color-accent: hsl(220 90% 56%);
72
- --kit-color-success: hsl(145 50% 38%);
73
- --kit-color-warning: hsl(35 80% 45%);
74
- --kit-color-danger: hsl(5 65% 48%);
75
- --kit-color-info: hsl(205 60% 42%);
76
- --kit-color-focus: hsl(35 90% 56%);
77
-
78
- /* ─── Backward-compat aliases (removed once components are updated) ─ */
79
- /* --kit-bg: var(--kit-color-bg);
80
- --kit-fg: var(--kit-color-label);
81
- --kit-muted: var(--kit-color-label-tertiary);
82
- --kit-surface-1: var(--kit-color-surface);
83
- --kit-surface-2: var(--kit-color-bg-secondary);
84
- --kit-surface-3: var(--kit-color-bg-tertiary);
85
- --kit-border: var(--kit-color-separator);
86
- --kit-accent: var(--kit-color-accent);
87
- --kit-focus: var(--kit-color-focus); */
88
- }
89
-
90
41
  .kit-application {
91
42
  --kit-shape-none: 0;
92
43
  --kit-shape-xs: 4px;
@@ -98,16 +49,17 @@
98
49
  --kit-space-compact: 6px;
99
50
  --kit-space-default: 10px;
100
51
  --kit-space-comfortable: 14px;
52
+
53
+ --kit-shadow-opacity: 30%;
54
+ --kit-shadow-ambiant-opacity: 15%;
101
55
  }
102
56
 
103
- /* Light — explicit override (same values as defaults, forces color-scheme) */
104
- .light {
57
+ .kit-application,
58
+ :global([data-kit-theme='light']) {
105
59
  color-scheme: light;
106
-
107
60
  --kit-color-bg: hsl(0 0% 100%);
108
61
  --kit-color-bg-secondary: hsl(240 15% 96.5%);
109
62
  --kit-color-bg-tertiary: hsl(240 10% 93%);
110
-
111
63
  --kit-color-surface: hsl(0 0% 100%);
112
64
  --kit-color-surface-raised: hsl(0 0% 100%);
113
65
 
@@ -121,6 +73,7 @@
121
73
  --kit-color-fill-tertiary: hsl(240 11% 95%);
122
74
 
123
75
  --kit-color-separator: hsl(220 16% 88%);
76
+ --kit-color-shadow: hsl(240 3% 11%);
124
77
 
125
78
  --kit-color-accent: hsl(220 90% 56%);
126
79
  --kit-color-success: hsl(145 50% 38%);
@@ -130,14 +83,12 @@
130
83
  --kit-color-focus: hsl(35 90% 56%);
131
84
  }
132
85
 
133
- /* Dark */
134
- .dark {
86
+ :global([data-kit-theme='dark']) {
135
87
  color-scheme: dark;
136
88
 
137
89
  --kit-color-bg: hsl(240 3% 11%);
138
90
  --kit-color-bg-secondary: hsl(240 2% 17.5%);
139
91
  --kit-color-bg-tertiary: hsl(240 1.5% 23%);
140
-
141
92
  --kit-color-surface: hsl(240 2% 19%);
142
93
  --kit-color-surface-raised: hsl(240 1.5% 25%);
143
94
 
@@ -151,6 +102,7 @@
151
102
  --kit-color-fill-tertiary: hsl(240 2% 20%);
152
103
 
153
104
  --kit-color-separator: hsl(240 2% 26%);
105
+ --kit-color-shadow: hsl(240 3% 11%);
154
106
 
155
107
  --kit-color-accent: hsl(220 85% 65%);
156
108
  --kit-color-success: hsl(145 50% 50%);
@@ -160,6 +112,42 @@
160
112
  --kit-color-focus: hsl(35 90% 62%);
161
113
  }
162
114
 
115
+ .kit-application {
116
+ color-scheme: light;
117
+
118
+ /* Hue vars — used by components for dynamic semantic color calculations */
119
+ --kit-h-neutral: 220;
120
+ --kit-h-success: 145;
121
+ --kit-h-warning: 35;
122
+ --kit-h-danger: 5;
123
+ --kit-h-info: 205;
124
+
125
+ --kit-bg: hsl(0 0% 100%);
126
+ --kit-fg: hsl(222 20% 10%);
127
+ --kit-muted: hsl(220 10% 45%);
128
+
129
+ --kit-surface-1: hsl(0 0% 100%);
130
+ --kit-surface-2: hsl(220 20% 98%);
131
+ --kit-surface-3: hsl(220 18% 94%);
132
+
133
+ --kit-border: hsl(220 16% 88%);
134
+
135
+ --kit-accent: hsl(220 90% 56%);
136
+
137
+ --kit-focus: hsl(35, 90%, 56%);
138
+
139
+ /* Layout */
140
+ --kit-radius-1: 8px;
141
+ --kit-radius-2: 12px;
142
+ --kit-space-1: 6px;
143
+ --kit-space-2: 10px;
144
+ --kit-space-3: 14px;
145
+ --kit-disabled-opacity: 0.55;
146
+ --kit-font:
147
+ ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
148
+ 'Segoe UI Symbol', 'Noto Color Emoji';
149
+ }
150
+
163
151
  :global(.outline) {
164
152
  position: absolute;
165
153
  inset: 0;
@@ -201,6 +189,56 @@
201
189
  border-radius: var(--system-ripple-radius);
202
190
  }
203
191
 
192
+ :global([data-elevation='0']),
193
+ :global([data-elevation-hover='0']:hover),
194
+ :global([data-elevation-active='0']):active {
195
+ box-shadow: none;
196
+ }
197
+
198
+ :global([data-elevation='1']),
199
+ :global([data-elevation-hover='1']:hover),
200
+ :global([data-elevation-active='1']:active) {
201
+ box-shadow:
202
+ 0 1px 2px color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-opacity), transparent),
203
+ 0 3px 8px -2px
204
+ color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-ambiant-opacity), transparent);
205
+ }
206
+
207
+ :global([data-elevation='2']),
208
+ :global([data-elevation-hover='2']:hover),
209
+ :global([data-elevation-active='2']:active) {
210
+ box-shadow:
211
+ 0 1px 3px color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-opacity), transparent),
212
+ 0 5px 12px -3px
213
+ color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-ambiant-opacity), transparent);
214
+ }
215
+
216
+ :global([data-elevation='3']),
217
+ :global([data-elevation-hover='3']:hover),
218
+ :global([data-elevation-active='3']:active) {
219
+ box-shadow:
220
+ 0 2px 4px color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-opacity), transparent),
221
+ 0 8px 20px -4px
222
+ color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-ambiant-opacity), transparent);
223
+ }
224
+
225
+ :global([data-elevation='4']),
226
+ :global([data-elevation-hover='4']):hover,
227
+ :global([data-elevation-active='4']):active {
228
+ box-shadow:
229
+ 0 3px 5px color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-opacity), transparent),
230
+ 0 11px 26px -5px
231
+ color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-ambiant-opacity), transparent);
232
+ }
233
+
234
+ :global([data-elevation='5']),
235
+ :global([data-elevation-hover='5']:hover),
236
+ :global([data-elevation-active='5']:active) {
237
+ box-shadow:
238
+ 0 4px 6px color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-opacity), transparent),
239
+ 0 14px 32px -6px
240
+ color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-ambiant-opacity), transparent);
241
+ }
204
242
  @keyframes -global-animation-l-ripple {
205
243
  from {
206
244
  scale: 0;
@@ -1,6 +1,4 @@
1
- declare const App: import("svelte").Component<{
2
- ref?: any;
3
- children: any;
4
- } & Record<string, any>, {}, "ref">;
1
+ import type { AppProps } from './app.types';
2
+ declare const App: import("svelte").Component<AppProps, {}, "ref">;
5
3
  type App = ReturnType<typeof App>;
6
4
  export default App;
@@ -0,0 +1,4 @@
1
+ import type { Component } from '../../@types';
2
+ export interface AppProps extends Component {
3
+ ref?: HTMLElement | null;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { useClassName, useIsInteractive, useStyles } from '../../utils';
2
+ import { useClassName, useElevation, useIsInteractive, useStyles } from '../../utils';
3
3
  import { makeComponentProps } from '../../html-mapped';
4
4
  import { ripple } from '../../animations';
5
5
  import type { CardProps } from './card.types.js';
@@ -23,6 +23,7 @@
23
23
  noRipple,
24
24
  color,
25
25
  background,
26
+ elevation,
26
27
  ...rest
27
28
  }: CardProps = $props();
28
29
 
@@ -36,6 +37,8 @@
36
37
 
37
38
  let { classProps, styleProps, restProps } = $derived(makeComponentProps(rest));
38
39
 
40
+ let elevationState = $derived(useElevation(elevation));
41
+
39
42
  let componentClass = $derived(
40
43
  useClassName({
41
44
  baseClass: 'kit-card',
@@ -66,6 +69,9 @@
66
69
  data-variant={variant}
67
70
  data-density={density}
68
71
  data-rounded={rounded}
72
+ data-elevation={elevationState.base}
73
+ data-elevation-hover={elevationState.hover}
74
+ data-elevation-active={elevationState.active}
69
75
  data-interactive={isInteractive}
70
76
  data-active={active}
71
77
  data-disabled={isDisabled}
@@ -192,7 +198,7 @@
192
198
  .kit-card[data-interactive='true'][data-disabled='false']:hover {
193
199
  translate: 0 -1px;
194
200
  background: var(--kit-card-hover-bg);
195
- box-shadow: 0 10px 28px hsl(220 35% 8% / 0.12);
201
+ /* box-shadow: 0 10px 28px hsl(220 35% 8% / 0.12); */
196
202
  }
197
203
 
198
204
  .kit-card[data-variant='text'][data-interactive='true'][data-disabled='false']:hover {
@@ -203,7 +209,7 @@
203
209
  .kit-card[data-interactive='true'][data-disabled='false']:active {
204
210
  translate: 0 0;
205
211
  background: var(--kit-card-active-bg);
206
- box-shadow: 0 4px 14px hsl(220 35% 8% / 0.1);
212
+ /* box-shadow: 0 4px 14px hsl(220 35% 8% / 0.1); */
207
213
  }
208
214
 
209
215
  .kit-card[data-variant='text'][data-interactive='true'][data-active='true'][data-disabled='false'],
@@ -1,4 +1,4 @@
1
- import type { Component, DensityType, RoundedType } from '../../@types';
1
+ import type { Component, DensityType, ElevationProps, RoundedType } from '../../@types';
2
2
  export interface CardProps extends Component {
3
3
  ref?: HTMLElement | null;
4
4
  is?: 'div' | 'article' | 'section' | 'aside' | 'a' | 'button';
@@ -7,6 +7,7 @@ export interface CardProps extends Component {
7
7
  variant?: 'filled' | 'outline' | 'text';
8
8
  density?: DensityType;
9
9
  rounded?: RoundedType;
10
+ elevation?: ElevationProps;
10
11
  interactive?: boolean;
11
12
  active?: boolean;
12
13
  disabled?: boolean;
@@ -46,6 +46,10 @@
46
46
 
47
47
  <style>
48
48
  .kit-card-title {
49
+ display: flex;
50
+ align-items: center;
51
+ gap: var(--kit-card-gap);
52
+
49
53
  font-weight: 600;
50
54
  line-height: 1.3;
51
55
  }
@@ -1,4 +1,4 @@
1
1
  import type { TextfieldProps } from './textfield.types.ts';
2
- declare const Textfield: import("svelte").Component<TextfieldProps, {}, "value" | "ref">;
2
+ declare const Textfield: import("svelte").Component<TextfieldProps, {}, "ref" | "value">;
3
3
  type Textfield = ReturnType<typeof Textfield>;
4
4
  export default Textfield;
@@ -0,0 +1,2 @@
1
+ export * from './themes.svelte.js';
2
+ export * from '../components/accordion/accordion.svelte.js';
@@ -0,0 +1,2 @@
1
+ export * from './themes.svelte.js';
2
+ export * from '../components/accordion/accordion.svelte.js';
@@ -0,0 +1,12 @@
1
+ import type { ThemeOptions, ThemeAction } from '../@types';
2
+ export declare const useTheme: (name: string) => void;
3
+ export declare function createGlobalTheme(params?: ThemeOptions): {
4
+ readonly active: string;
5
+ };
6
+ export declare function createTheme(): ThemeAction;
7
+ /** LEGACY CODE
8
+ * NEED UPDATE documentation with new theme system before removing this legacy code. The new theme system is designed to be more flexible and easier to use, allowing for better integration with Svelte's reactivity and component structure. It also provides a more consistent API for managing themes across different components and contexts.
9
+ * TODO: Remove this legacy code once the new theme system is fully implemented and tested. This code is kept for backward compatibility with existing components that rely on the old theme system.
10
+ */
11
+ import { type Writable } from 'svelte/store';
12
+ export declare const theme: Writable<string>;
@@ -0,0 +1,125 @@
1
+ // states
2
+ const isBrowser = typeof window !== 'undefined';
3
+ // presets
4
+ const default_theme = 'light';
5
+ const default_storage_key = '@lapikit/theme';
6
+ function generateGlobalTheme() {
7
+ let active = $state(default_theme);
8
+ let key = default_storage_key;
9
+ let initialized = false;
10
+ function applyToHtml(name) {
11
+ if (!isBrowser)
12
+ return;
13
+ document.documentElement.setAttribute('data-kit-theme', name);
14
+ active = name;
15
+ }
16
+ function set(name) {
17
+ applyToHtml(name);
18
+ if (isBrowser) {
19
+ localStorage.setItem(key, name);
20
+ }
21
+ }
22
+ function init(params = {}) {
23
+ if (initialized)
24
+ return;
25
+ initialized = true;
26
+ key = params.key ?? default_storage_key;
27
+ const stored = isBrowser ? localStorage.getItem(key) : null;
28
+ applyToHtml(stored ?? params.name ?? default_theme);
29
+ }
30
+ return {
31
+ init,
32
+ set,
33
+ get active() {
34
+ return active;
35
+ }
36
+ };
37
+ }
38
+ const refGlobalTheme = generateGlobalTheme();
39
+ export const useTheme = refGlobalTheme.set;
40
+ export function createGlobalTheme(params) {
41
+ refGlobalTheme.init(params);
42
+ return {
43
+ get active() {
44
+ return refGlobalTheme.active;
45
+ }
46
+ };
47
+ }
48
+ export function createTheme() {
49
+ let active = $state(default_theme);
50
+ let node;
51
+ let key;
52
+ let overridden = $state(false);
53
+ function applyTheme(name) {
54
+ const target = node;
55
+ if (!target)
56
+ return;
57
+ target.setAttribute('data-kit-theme', name);
58
+ active = name;
59
+ }
60
+ function set(name) {
61
+ applyTheme(name);
62
+ if (isBrowser && key) {
63
+ localStorage.setItem(key, name);
64
+ }
65
+ }
66
+ // skip the effect's first automatic pass so the mount's own initial value (from
67
+ // `name`, storage or default) isn't immediately clobbered by the current global value
68
+ let firstRun = true;
69
+ // re-syncs to the global theme whenever it changes, unless this zone is overridden
70
+ $effect(() => {
71
+ const value = refGlobalTheme.active;
72
+ const isOverridden = overridden;
73
+ const skip = firstRun;
74
+ firstRun = false;
75
+ if (!skip && !isOverridden) {
76
+ applyTheme(value);
77
+ }
78
+ });
79
+ const action = (n, params = {}) => {
80
+ node = n;
81
+ key = params.key;
82
+ overridden = params.overridden ?? false;
83
+ const stored = isBrowser && key ? localStorage.getItem(key) : null;
84
+ applyTheme(stored ?? params.name ?? (overridden ? default_theme : refGlobalTheme.active));
85
+ return {
86
+ update(newParams = {}) {
87
+ key = newParams.key;
88
+ overridden = newParams.overridden ?? false;
89
+ },
90
+ destroy() {
91
+ node = undefined;
92
+ }
93
+ };
94
+ };
95
+ return {
96
+ action,
97
+ set,
98
+ get active() {
99
+ return active;
100
+ }
101
+ };
102
+ }
103
+ /** LEGACY CODE
104
+ * NEED UPDATE documentation with new theme system before removing this legacy code. The new theme system is designed to be more flexible and easier to use, allowing for better integration with Svelte's reactivity and component structure. It also provides a more consistent API for managing themes across different components and contexts.
105
+ * TODO: Remove this legacy code once the new theme system is fully implemented and tested. This code is kept for backward compatibility with existing components that rely on the old theme system.
106
+ */
107
+ import { writable } from 'svelte/store';
108
+ // presets
109
+ const themeRef = 'light';
110
+ export const theme = writable(themeRef);
111
+ // export function useTheme(name: string, key: string = '@lapikit/theme') {
112
+ // theme.update(() => {
113
+ // if (isBrowser) {
114
+ // const html = document.documentElement;
115
+ // html.classList.forEach((cls) => {
116
+ // if (cls.startsWith('kit-theme--')) {
117
+ // html.classList.remove(cls);
118
+ // }
119
+ // });
120
+ // html.classList.add(`kit-theme--${name}`);
121
+ // localStorage.setItem(key, name);
122
+ // }
123
+ // return name;
124
+ // });
125
+ // }
@@ -1,4 +1,4 @@
1
- import type { useClassNameProps, useStylesProps } from '../@types';
1
+ import type { ElevationProps, ElevationState, useClassNameProps, useStylesProps } from '../@types';
2
2
  /**
3
3
  * useClassName - Utility to compute class names for a component.
4
4
  * @param baseClass - The base class name for the component.
@@ -17,3 +17,10 @@ export declare function useIsInteractive(props: Record<string, unknown>, tag: st
17
17
  * @returns A computed style string.
18
18
  */
19
19
  export declare function useStyles({ styleAttr, sStyle, styleProps }?: useStylesProps): string;
20
+ /**
21
+ * useElevation - Utility to resolve the `elevation` prop into its base/hover/active states.
22
+ * @param elevation - Either a single elevation value applied as `base`, or an object with
23
+ * independent `base`, `hover` and `active` values (each key is optional).
24
+ * @returns An object with `base`, `hover` and `active` keys, `undefined` when not provided.
25
+ */
26
+ export declare function useElevation(elevation?: ElevationProps | null): ElevationState;
@@ -106,3 +106,22 @@ export function useStyles({ styleAttr, sStyle, styleProps } = {}) {
106
106
  }
107
107
  return styles.filter(Boolean).join('; ');
108
108
  }
109
+ /**
110
+ * useElevation - Utility to resolve the `elevation` prop into its base/hover/active states.
111
+ * @param elevation - Either a single elevation value applied as `base`, or an object with
112
+ * independent `base`, `hover` and `active` values (each key is optional).
113
+ * @returns An object with `base`, `hover` and `active` keys, `undefined` when not provided.
114
+ */
115
+ export function useElevation(elevation) {
116
+ if (elevation === undefined || elevation === null) {
117
+ return { base: undefined, hover: undefined, active: undefined };
118
+ }
119
+ if (typeof elevation === 'string') {
120
+ return { base: elevation, hover: undefined, active: undefined };
121
+ }
122
+ return {
123
+ base: elevation.base,
124
+ hover: elevation.hover,
125
+ active: elevation.active
126
+ };
127
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapikit",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -66,7 +66,7 @@
66
66
  "default": "./dist/labs/index.js"
67
67
  },
68
68
  "./actions": {
69
- "default": "./dist/actions.js"
69
+ "default": "./dist/hooks/actions.js"
70
70
  }
71
71
  },
72
72
  "peerDependencies": {
package/dist/actions.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './utils/themes.js';
2
- export * from './components/accordion/accordion.svelte.js';
package/dist/actions.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './utils/themes.js';
2
- export * from './components/accordion/accordion.svelte.js';
@@ -1,3 +0,0 @@
1
- import { type Writable } from 'svelte/store';
2
- export declare const theme: Writable<string>;
3
- export declare function useTheme(name: string, key?: string): void;
@@ -1,21 +0,0 @@
1
- import { writable } from 'svelte/store';
2
- // states
3
- const isBrowser = typeof window !== 'undefined';
4
- // presets
5
- const themeRef = 'light';
6
- export const theme = writable(themeRef);
7
- export function useTheme(name, key = '@lapikit/theme') {
8
- theme.update(() => {
9
- if (isBrowser) {
10
- const html = document.documentElement;
11
- html.classList.forEach((cls) => {
12
- if (cls.startsWith('kit-theme--')) {
13
- html.classList.remove(cls);
14
- }
15
- });
16
- html.classList.add(`kit-theme--${name}`);
17
- localStorage.setItem(key, name);
18
- }
19
- return name;
20
- });
21
- }