lapikit 0.0.0-insiders.bf30361 → 0.0.0-insiders.c8d4fe2

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/bin/presets.js CHANGED
@@ -2,8 +2,8 @@ function presets({ adapterCSS }) {
2
2
  let content = '';
3
3
 
4
4
  content += `/**\n`;
5
- content += `\t* Lapikit\n`;
6
- content += `\t* Library documentation: https://lapikit.dev\n`;
5
+ content += ` * Lapikit\n`;
6
+ content += ` * Library documentation: https://lapikit.dev\n`;
7
7
  content += ` */\n\n`;
8
8
 
9
9
  if (adapterCSS === 'css') {
@@ -20,7 +20,7 @@
20
20
  text-decoration: none;
21
21
  }
22
22
 
23
- .kit-chip:not(div):not(span) {
23
+ .kit-chip:not(div):not(span):not(.kit-chip--readonly) {
24
24
  cursor: pointer;
25
25
  }
26
26
 
@@ -49,13 +49,13 @@
49
49
  pointer-events: none;
50
50
  border-radius: inherit;
51
51
  }
52
- .kit-chip:not(div):not(span):hover::after {
52
+ .kit-chip:not(div):not(span):not(.kit-chip--readonly):hover::after {
53
53
  opacity: 0.08;
54
54
  }
55
- .kit-chip:not(div):not(span):active::after {
55
+ .kit-chip:not(div):not(span):not(.kit-chip--readonly):active::after {
56
56
  opacity: 0.12;
57
57
  }
58
- .kit-chip:not(div):not(span):focus-visible::after {
58
+ .kit-chip:not(div):not(span):not(.kit-chip--readonly):focus-visible::after {
59
59
  opacity: 0.12;
60
60
  }
61
61
 
@@ -37,6 +37,7 @@
37
37
  rounded,
38
38
  closable,
39
39
  noRipple,
40
+ readonly = false,
40
41
  ...rest
41
42
  }: ChipProps = $props();
42
43
 
@@ -44,7 +45,7 @@
44
45
 
45
46
  $effect(() => {
46
47
  const refProps = { ...rest };
47
- if (refProps?.onclick) is = 'button';
48
+ if (refProps?.onclick && !readonly) is = 'button';
48
49
  });
49
50
  </script>
50
51
 
@@ -68,6 +69,7 @@
68
69
  disabled && 'kit-chip--disabled',
69
70
  active && 'kit-chip--active',
70
71
  loading && 'kit-chip--loading',
72
+ readonly && 'kit-chip--readonly',
71
73
  rest.class
72
74
  ]}
73
75
  tabindex={href && disabled ? -1 : 0}
@@ -77,7 +79,7 @@
77
79
  type={href ? undefined : type}
78
80
  use:ripple={{
79
81
  component: 'chip',
80
- disabled: noRipple || disabled || is === 'div' || is === 'span'
82
+ disabled: noRipple || readonly || disabled || is === 'div' || is === 'span'
81
83
  }}
82
84
  style:--base={assets.color(background)}
83
85
  style:--on={assets.color(color)}
@@ -109,7 +111,7 @@
109
111
  </div>
110
112
  {/if}
111
113
 
112
- {#if closable}
114
+ {#if closable && !readonly}
113
115
  <button
114
116
  class="kit-chip--close"
115
117
  type="button"
@@ -28,4 +28,5 @@ export interface ChipProps extends Component {
28
28
  label?: string;
29
29
  closable?: boolean;
30
30
  noRipple?: boolean;
31
+ readonly?: boolean;
31
32
  }
@@ -60,7 +60,9 @@
60
60
  }
61
61
 
62
62
  .kit-dialog[breakpoint]kit-dialog--position-center {
63
- margin: auto;
63
+ /* margin: auto; */
64
+ margin-top: auto;
65
+ margin-bottom: auto;
64
66
  }
65
67
 
66
68
  .kit-dialog[breakpoint]kit-dialog--size-xs {
@@ -49,7 +49,6 @@
49
49
  max-height: calc(100% - 3rem);
50
50
  height: fit-content;
51
51
  margin: 0 auto;
52
- top: 50%;
53
52
  left: 50%;
54
53
  bottom: initial;
55
54
  translate: var(--modal-translate-x) var(--modal-translate-y);
@@ -60,7 +59,6 @@
60
59
  max-height: calc(100% - 3rem);
61
60
  height: fit-content;
62
61
  margin: 0 auto;
63
- top: 50%;
64
62
  left: 50%;
65
63
  bottom: initial;
66
64
  translate: var(--modal-translate-x) var(--modal-translate-y);
@@ -71,7 +69,6 @@
71
69
  max-height: calc(100% - 3rem);
72
70
  height: fit-content;
73
71
  margin: 0 auto;
74
- top: 50%;
75
72
  left: 50%;
76
73
  bottom: initial;
77
74
  translate: var(--modal-translate-x) var(--modal-translate-y);
@@ -82,7 +79,6 @@
82
79
  max-height: calc(100% - 3rem);
83
80
  height: fit-content;
84
81
  margin: 0 auto;
85
- top: 50%;
86
82
  left: 50%;
87
83
  bottom: initial;
88
84
  translate: var(--modal-translate-x) var(--modal-translate-y);
@@ -93,7 +89,6 @@
93
89
  max-height: calc(100% - 3rem);
94
90
  height: fit-content;
95
91
  margin: 0 auto;
96
- top: 50%;
97
92
  left: 50%;
98
93
  bottom: initial;
99
94
  translate: var(--modal-translate-x) var(--modal-translate-y);
@@ -130,15 +125,21 @@
130
125
  /* position */
131
126
  .kit-modal [breakpoint]kit-modal-container--position-bottom {
132
127
  --modal-translate-y: 0;
133
- bottom: 0;
128
+ margin: auto;
134
129
  top: initial;
130
+ bottom: 0;
135
131
  }
136
132
 
137
133
  .kit-modal [breakpoint]kit-modal-container--position-top {
138
134
  --modal-translate-y: 0;
135
+ margin: auto;
139
136
  top: 0;
137
+ bottom: initial;
140
138
  }
141
139
 
142
140
  .kit-modal [breakpoint]kit-modal-container--position-center {
141
+ --modal-translate-y: -50%;
143
142
  margin: auto;
143
+ top: 50%;
144
+ bottom: initial;
144
145
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  interface Lapikit {
2
2
  adapterCSS: string;
3
+ breakpoints: {
4
+ thresholds: {
5
+ [key: string]: number | string;
6
+ };
7
+ };
3
8
  }
4
9
  declare function createLapikit(lapikit: Lapikit): void;
5
10
  export default createLapikit;
package/dist/index.js CHANGED
@@ -1,5 +1,14 @@
1
+ import { deepMerge } from './internal/deepMerge.js';
2
+ import { breakpoints } from './stores/breakpoints.js';
3
+ import { get } from 'svelte/store';
1
4
  function createLapikit(lapikit) {
2
5
  console.log('Creating a new Lapikit instance...');
3
6
  console.log('Options loaded:', lapikit);
7
+ if (lapikit?.breakpoints?.thresholds) {
8
+ const currentBreakpoints = get(breakpoints);
9
+ const breakpointMerged = deepMerge(currentBreakpoints, lapikit.breakpoints.thresholds);
10
+ breakpoints.set(breakpointMerged);
11
+ console.log('Breakpoints found:', breakpointMerged);
12
+ }
4
13
  }
5
14
  export default createLapikit;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Recursively merges two objects together.
3
+ * Properties from the source object override those from the target object.
4
+ * Nested objects are merged recursively.
5
+ *
6
+ * @param target - The base object
7
+ * @param source - The source object to merge (can be null or undefined)
8
+ * @returns A new object containing the merge of both objects
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const obj1 = { primary: { light: 'pink', medium: 'purple' } };
13
+ * const obj2 = { primary: { dark: 'red' } };
14
+ * const result = deepMerge(obj1, obj2);
15
+ * // Result: { primary: { light: 'pink', medium: 'purple', dark: 'red' } }
16
+ *
17
+ * // Works with null/undefined source
18
+ * const result2 = deepMerge(obj1, null);
19
+ * // Result: { primary: { light: 'pink', medium: 'purple' } }
20
+ * ```
21
+ */
22
+ export declare function deepMerge<T extends Record<string, unknown>, U extends Record<string, unknown>>(target: T, source: U | null | undefined): T & U;
23
+ /**
24
+ * Merges multiple objects together recursively.
25
+ *
26
+ * @param objects - The objects to merge (null and undefined values are ignored)
27
+ * @returns A new object containing the merge of all objects
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const result = deepMergeMultiple(
32
+ * { primary: { light: 'pink' } },
33
+ * null,
34
+ * { primary: { dark: 'red' } },
35
+ * undefined,
36
+ * { secondary: { light: 'blue' } }
37
+ * );
38
+ * // Result: {
39
+ * // primary: { light: 'pink', dark: 'red' },
40
+ * // secondary: { light: 'blue' }
41
+ * // }
42
+ * ```
43
+ */
44
+ export declare function deepMergeMultiple(...objects: (Record<string, unknown> | null | undefined)[]): Record<string, unknown>;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Checks if a value is a plain object (object literal)
3
+ */
4
+ function isPlainObject(value) {
5
+ return (value !== null &&
6
+ typeof value === 'object' &&
7
+ Object.prototype.toString.call(value) === '[object Object]');
8
+ }
9
+ /**
10
+ * Recursively merges two objects together.
11
+ * Properties from the source object override those from the target object.
12
+ * Nested objects are merged recursively.
13
+ *
14
+ * @param target - The base object
15
+ * @param source - The source object to merge (can be null or undefined)
16
+ * @returns A new object containing the merge of both objects
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const obj1 = { primary: { light: 'pink', medium: 'purple' } };
21
+ * const obj2 = { primary: { dark: 'red' } };
22
+ * const result = deepMerge(obj1, obj2);
23
+ * // Result: { primary: { light: 'pink', medium: 'purple', dark: 'red' } }
24
+ *
25
+ * // Works with null/undefined source
26
+ * const result2 = deepMerge(obj1, null);
27
+ * // Result: { primary: { light: 'pink', medium: 'purple' } }
28
+ * ```
29
+ */
30
+ export function deepMerge(target, source) {
31
+ // If source is null or undefined, return a copy of target
32
+ if (source == null) {
33
+ return { ...target };
34
+ }
35
+ // Create a copy of the target object to avoid mutations
36
+ const result = { ...target };
37
+ for (const key in source) {
38
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
39
+ const sourceValue = source[key];
40
+ const targetValue = result[key];
41
+ // If both values are plain objects, merge them recursively
42
+ if (isPlainObject(targetValue) && isPlainObject(sourceValue)) {
43
+ result[key] = deepMerge(targetValue, sourceValue);
44
+ }
45
+ else {
46
+ // Otherwise, the source value overrides the target value
47
+ result[key] = sourceValue;
48
+ }
49
+ }
50
+ }
51
+ return result;
52
+ }
53
+ /**
54
+ * Merges multiple objects together recursively.
55
+ *
56
+ * @param objects - The objects to merge (null and undefined values are ignored)
57
+ * @returns A new object containing the merge of all objects
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const result = deepMergeMultiple(
62
+ * { primary: { light: 'pink' } },
63
+ * null,
64
+ * { primary: { dark: 'red' } },
65
+ * undefined,
66
+ * { secondary: { light: 'blue' } }
67
+ * );
68
+ * // Result: {
69
+ * // primary: { light: 'pink', dark: 'red' },
70
+ * // secondary: { light: 'blue' }
71
+ * // }
72
+ * ```
73
+ */
74
+ export function deepMergeMultiple(...objects) {
75
+ return objects
76
+ .filter((obj) => obj != null)
77
+ .reduce((acc, obj) => {
78
+ return deepMerge(acc, obj);
79
+ }, {});
80
+ }
@@ -0,0 +1,6 @@
1
+ import { type Writable } from 'svelte/store';
2
+ type Breakpoints = {
3
+ [key: string]: number | string;
4
+ };
5
+ export declare const breakpoints: Writable<Breakpoints>;
6
+ export {};
@@ -0,0 +1,23 @@
1
+ // store breakpoints and thresholds
2
+ import { writable } from 'svelte/store';
3
+ // presets
4
+ const ref = {
5
+ base: 0, // 0px
6
+ xs: '28rem', //448px
7
+ sm: '40rem', //640px
8
+ md: '48rem', //768px
9
+ lg: '64rem', //1024px
10
+ xl: '80rem', //1280px
11
+ '2xl': '96rem', //1536px
12
+ '3xl': '112rem' //1792px
13
+ };
14
+ export const breakpoints = writable(ref);
15
+ // export function setBreakpoints(newBreakpoints: Breakpoints) {
16
+ // breakpoints.set(newBreakpoints);
17
+ // }
18
+ // export function updateBreakpoint(key: string, value: number) {
19
+ // breakpoints.update((bp) => ({
20
+ // ...bp,
21
+ // [key]: value
22
+ // }));
23
+ // }
@@ -8,3 +8,4 @@ export declare function setColorScheme(scheme: 'system' | 'dark' | 'light'): voi
8
8
  export declare function setOpenModal(state: boolean | 'persistent'): void;
9
9
  export declare const pushModal: (id: string) => void;
10
10
  export declare const popModal: (id: string) => void;
11
+ export * from './breakpoints.js';
@@ -45,3 +45,4 @@ export const popModal = (id) => {
45
45
  return newStack.length === 0 ? [] : newStack;
46
46
  });
47
47
  };
48
+ export * from './breakpoints.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapikit",
3
- "version": "0.0.0-insiders.bf30361",
3
+ "version": "0.0.0-insiders.c8d4fe2",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"