@kalink-ui/seedly 0.13.0 → 0.15.0
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/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/components/loader-overlay/loader-overlay.tsx +1 -1
- package/src/components/stack/stack.css.ts +32 -18
- package/src/components/stack/stack.tsx +2 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-local-storage.ts +99 -0
- package/src/index.ts +1 -0
- package/src/styles/define-responsive-properties.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @kalink-ui/seedly
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7893c13: [Stack] handle items positioning
|
|
8
|
+
- b1e9483: [LoaderOverlay] Correctly center elements
|
|
9
|
+
- 57ca2b9: [useLocalStorage] Add new local storage management hook
|
|
10
|
+
|
|
11
|
+
## 0.14.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 6d5d569: [Stack] Use flex-box instead of margin for spacing between elements
|
|
16
|
+
|
|
3
17
|
## 0.13.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export function LoaderOverlay({
|
|
|
21
21
|
}: LoaderOverlayProps) {
|
|
22
22
|
return (
|
|
23
23
|
<div className={clsx(loaderOverlay({ position }), className)}>
|
|
24
|
-
<Stack use={Center} spacing={spacing} intrinsic andText>
|
|
24
|
+
<Stack use={Center} align="center" spacing={spacing} intrinsic andText>
|
|
25
25
|
<MoonLoader active forceMount />
|
|
26
26
|
{text && <Text>{text}</Text>}
|
|
27
27
|
</Stack>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createVar
|
|
1
|
+
import { createVar } from '@vanilla-extract/css';
|
|
2
2
|
import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
3
3
|
|
|
4
4
|
import { sys, mapContractVars } from '../../styles';
|
|
@@ -16,19 +16,13 @@ export const stackRecipe = recipe({
|
|
|
16
16
|
[components]: {
|
|
17
17
|
display: 'flex',
|
|
18
18
|
flexDirection: 'column',
|
|
19
|
-
|
|
19
|
+
alignItems: 'flex-start',
|
|
20
|
+
gap: spacing,
|
|
20
21
|
},
|
|
21
22
|
},
|
|
22
23
|
},
|
|
23
24
|
|
|
24
25
|
variants: {
|
|
25
|
-
/**
|
|
26
|
-
* Whether the stack spacing should be applied recursively
|
|
27
|
-
*/
|
|
28
|
-
recursive: {
|
|
29
|
-
true: {},
|
|
30
|
-
},
|
|
31
|
-
|
|
32
26
|
/**
|
|
33
27
|
* The spacing between items
|
|
34
28
|
*/
|
|
@@ -41,18 +35,38 @@ export const stackRecipe = recipe({
|
|
|
41
35
|
},
|
|
42
36
|
},
|
|
43
37
|
})),
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
38
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
align: {
|
|
40
|
+
start: {
|
|
41
|
+
'@layer': {
|
|
42
|
+
[components]: {
|
|
43
|
+
alignItems: 'flex-start',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
center: {
|
|
48
|
+
'@layer': {
|
|
49
|
+
[components]: {
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
end: {
|
|
55
|
+
'@layer': {
|
|
56
|
+
[components]: {
|
|
57
|
+
alignItems: 'flex-end',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
stretch: {
|
|
62
|
+
'@layer': {
|
|
63
|
+
[components]: {
|
|
64
|
+
alignItems: 'stretch',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
53
67
|
},
|
|
54
68
|
},
|
|
55
69
|
},
|
|
56
|
-
);
|
|
70
|
+
});
|
|
57
71
|
|
|
58
72
|
export type StackVariants = NonNullable<RecipeVariants<typeof stackRecipe>>;
|
|
@@ -18,16 +18,16 @@ export type StackProps<TUse extends ElementType> =
|
|
|
18
18
|
* https://every-layout.dev/layouts/stack
|
|
19
19
|
*/
|
|
20
20
|
export function Stack<TUse extends ElementType = 'div'>({
|
|
21
|
-
recursive,
|
|
22
21
|
spacing,
|
|
23
22
|
className,
|
|
23
|
+
align,
|
|
24
24
|
...props
|
|
25
25
|
}: StackProps<TUse>) {
|
|
26
26
|
const { use: Comp = 'div', ...rest } = props;
|
|
27
27
|
|
|
28
28
|
return (
|
|
29
29
|
<Comp
|
|
30
|
-
className={clsx(stackRecipe({
|
|
30
|
+
className={clsx(stackRecipe({ spacing, align }), className)}
|
|
31
31
|
{...rest}
|
|
32
32
|
/>
|
|
33
33
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLocalStorage } from './use-local-storage';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useSyncExternalStore } from 'react';
|
|
4
|
+
|
|
5
|
+
type Serializable =
|
|
6
|
+
| string
|
|
7
|
+
| number
|
|
8
|
+
| boolean
|
|
9
|
+
| null
|
|
10
|
+
| Serializable[]
|
|
11
|
+
| { [key: string]: Serializable };
|
|
12
|
+
|
|
13
|
+
type StateUpdater<T> = (oldValue: T) => T;
|
|
14
|
+
|
|
15
|
+
function dispatchStorageEvent(key: string, newValue: string | null) {
|
|
16
|
+
window.dispatchEvent(new StorageEvent('storage', { key, newValue }));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function subscribeToStorageEvent(callback: () => void) {
|
|
20
|
+
window.addEventListener('storage', callback);
|
|
21
|
+
|
|
22
|
+
return () => window.removeEventListener('storage', callback);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function setLocalStorage<T>(key: string, value: T) {
|
|
26
|
+
const stringifiedValue = JSON.stringify(value);
|
|
27
|
+
|
|
28
|
+
window.localStorage.setItem(key, stringifiedValue);
|
|
29
|
+
|
|
30
|
+
dispatchStorageEvent(key, stringifiedValue);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function removeLocalStorage(key: string) {
|
|
34
|
+
window.localStorage.removeItem(key);
|
|
35
|
+
|
|
36
|
+
dispatchStorageEvent(key, null);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getLocalStorage(key: string) {
|
|
40
|
+
return window.localStorage.getItem(key);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getLocalStorageServerSnapshot<T>(initialValue: T) {
|
|
44
|
+
const initialSnapshot = JSON.stringify(initialValue);
|
|
45
|
+
|
|
46
|
+
return () => initialSnapshot;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const cachedStore = new Map<string, Serializable>();
|
|
50
|
+
|
|
51
|
+
export function useLocalStorage<T extends Serializable>(
|
|
52
|
+
key: string,
|
|
53
|
+
initialValue: T,
|
|
54
|
+
): [T, (value: T | StateUpdater<T>) => void] {
|
|
55
|
+
const getSnapshot = () => getLocalStorage(key);
|
|
56
|
+
|
|
57
|
+
const store = useSyncExternalStore(
|
|
58
|
+
subscribeToStorageEvent,
|
|
59
|
+
getSnapshot,
|
|
60
|
+
getLocalStorageServerSnapshot(initialValue),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const setValue = useCallback(
|
|
64
|
+
(value: T | StateUpdater<T>) => {
|
|
65
|
+
try {
|
|
66
|
+
const newValue =
|
|
67
|
+
typeof value === 'function'
|
|
68
|
+
? value(store ? JSON.parse(store) : null)
|
|
69
|
+
: value;
|
|
70
|
+
|
|
71
|
+
if (newValue === undefined || newValue === null) {
|
|
72
|
+
removeLocalStorage(key);
|
|
73
|
+
} else {
|
|
74
|
+
setLocalStorage(key, newValue);
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error(error);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[key, store],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (getLocalStorage(key) === null && typeof initialValue !== 'undefined') {
|
|
85
|
+
setLocalStorage(key, initialValue);
|
|
86
|
+
}
|
|
87
|
+
}, [key, initialValue]);
|
|
88
|
+
|
|
89
|
+
if (!store) {
|
|
90
|
+
return [initialValue, setValue];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!cachedStore.has(store)) {
|
|
94
|
+
cachedStore.clear();
|
|
95
|
+
cachedStore.set(store, JSON.parse(store));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return [cachedStore.get(store) as T, setValue];
|
|
99
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -61,11 +61,13 @@ export const defineResponsiveProperties = ({
|
|
|
61
61
|
flexDirection: ['row', 'row-reverse', 'column', 'column-reverse'],
|
|
62
62
|
|
|
63
63
|
justifyContent: [
|
|
64
|
+
'stretch',
|
|
64
65
|
'flex-start',
|
|
65
66
|
'flex-end',
|
|
66
67
|
'center',
|
|
67
68
|
'space-between',
|
|
68
69
|
'space-around',
|
|
70
|
+
'space-evenly',
|
|
69
71
|
],
|
|
70
72
|
alignItems: ['flex-start', 'flex-end', 'center', 'baseline', 'stretch'],
|
|
71
73
|
alignSelf: ['flex-start', 'flex-end', 'center', 'baseline', 'stretch'],
|