tinywidgets 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/bun.lockb CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinywidgets",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinywidgets",
6
6
  "module": "index.ts",
@@ -18,7 +18,7 @@
18
18
  "@vanilla-extract/css": "^1.15.5",
19
19
  "react": "^18.3.1",
20
20
  "react-dom": "^18.3.1",
21
- "tinybase": "^5.3.0-beta.1"
21
+ "tinybase": "^5.3.0-beta.2"
22
22
  },
23
23
  "exports": {
24
24
  ".": "./index.ts",
@@ -1,8 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import type { ComponentType, ReactNode } from 'react';
4
- import { ChevronDown, ChevronRight } from 'lucide-react';
5
- import { Button } from '../Button/index.tsx';
3
+ import type {ComponentType, ReactNode} from 'react';
4
+ import {ChevronDown, ChevronRight} from 'lucide-react';
5
+ import {Button} from '../Button/index.tsx';
6
6
  import {
7
7
  classNames,
8
8
  createElement,
@@ -27,6 +27,7 @@ export const Collapsible = ({
27
27
  icon: Icon,
28
28
  label = <div />,
29
29
  labelRight = <div />,
30
+ startOpen = false,
30
31
  className,
31
32
  children,
32
33
  }: {
@@ -34,19 +35,20 @@ export const Collapsible = ({
34
35
  icon?: ComponentType<{className?: string}>;
35
36
  label?: ReactNode;
36
37
  labelRight?: ReactNode;
38
+ startOpen?: boolean;
37
39
  className?: string;
38
40
  children: ReactNode;
39
41
  }) => {
40
42
  // State is in session Store if id is present, otherwise here in component.
41
- const storedIsOpen = useCollapsibleOpen(id) ?? false;
43
+ const storedIsOpen = useCollapsibleOpen(id) ?? startOpen;
42
44
  const setStoredIsOpen = useSetCollapsibleOpen(id);
43
- const [stateIsOpen, setStateIsOpen] = useState(false);
45
+ const [stateIsOpen, setStateIsOpen] = useState(startOpen);
44
46
 
45
47
  const isOpen = id ? storedIsOpen : stateIsOpen;
46
48
  const setIsOpen = id ? setStoredIsOpen : setStateIsOpen;
47
49
 
48
50
  const [render, setRender] = useState(isOpen);
49
- const timer = useRef<NodeJS.Timer>();
51
+ const timer = useRef<Timer>();
50
52
 
51
53
  const toggle = useCallback(() => {
52
54
  setIsOpen(!isOpen);
@@ -1,5 +1,5 @@
1
- import { createStore } from 'tinybase';
2
- import { createLocalPersister } from 'tinybase/persisters/persister-browser';
1
+ import {createStore} from 'tinybase';
2
+ import {createLocalPersister} from 'tinybase/persisters/persister-browser';
3
3
  import {
4
4
  useCreatePersister,
5
5
  useCreateStore,
@@ -7,11 +7,11 @@ import {
7
7
  useSetValueCallback,
8
8
  useValue,
9
9
  } from 'tinybase/ui-react';
10
- import { useEffect } from '../';
10
+ import {useEffect} from '../';
11
11
 
12
12
  const PREFERS_DARK = matchMedia?.('(prefers-color-scheme: dark)');
13
13
 
14
- const LOCAL_STORE = 'uiLocal';
14
+ const LOCAL_STORE = 'tinywidgets/Local';
15
15
  const DARK_PREFERENCE_VALUE = 'darkPreference';
16
16
  const DARK_CHOICE_VALUE = 'darkChoice';
17
17
 
@@ -10,7 +10,7 @@ import {
10
10
  useValue,
11
11
  } from 'tinybase/ui-react';
12
12
 
13
- const SESSION_STORE = 'uiSession';
13
+ const SESSION_STORE = 'tinywidgets/Session';
14
14
 
15
15
  const COLLAPSIBLE_TABLE = 'collapsible';
16
16
  const COLLAPSIBLE_OPEN_CELL = 'open';