tinywidgets 0.0.2 → 0.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinywidgets",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinywidgets",
6
6
  "module": "index.ts",
@@ -1,11 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../index.ts';
3
+ import {classNames, createElement} from '../index.ts';
5
4
  import {avatar} from './index.css.ts';
6
5
 
7
- const {createElement} = React;
8
-
9
6
  export const Avatar = ({
10
7
  src,
11
8
  title,
@@ -1,11 +1,9 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {axis, gapStyle, justifyStyle, verticalStyle} from './index.css';
6
6
 
7
- const {createElement} = React;
8
-
9
7
  export const Axis = ({
10
8
  justify = true,
11
9
  gap = true,
@@ -17,7 +15,7 @@ export const Axis = ({
17
15
  justify?: boolean;
18
16
  gap?: boolean;
19
17
  vertical?: boolean;
20
- children: React.ReactNode;
18
+ children: ReactNode;
21
19
  className?: string;
22
20
  title?: string;
23
21
  }) => {
@@ -1,13 +1,11 @@
1
1
  /** @jsx createElement */
2
2
  /** @jsxFrag Fragment */
3
3
 
4
- import React from 'react';
4
+ import type {ComponentType, ReactNode, Ref} from 'react';
5
5
  import {iconSize} from '../index.css.ts';
6
- import {classNames} from '../index.ts';
6
+ import {classNames, createElement, forwardRef, useCallback} from '../index.ts';
7
7
  import {button, buttonVariant, highlight, labelStyle} from './index.css.ts';
8
8
 
9
- const {createElement, useCallback, forwardRef} = React;
10
-
11
9
  export const Button = forwardRef(
12
10
  (
13
11
  {
@@ -22,10 +20,10 @@ export const Button = forwardRef(
22
20
  title,
23
21
  current,
24
22
  }: {
25
- icon?: React.ComponentType<{className?: string}>;
26
- label?: React.ReactNode;
27
- labelRight?: React.ReactNode;
28
- iconRight?: React.ComponentType<{className?: string}>;
23
+ icon?: ComponentType<{className?: string}>;
24
+ label?: ReactNode;
25
+ labelRight?: ReactNode;
26
+ iconRight?: ComponentType<{className?: string}>;
29
27
  onClick?: () => void;
30
28
  variant?: keyof typeof buttonVariant;
31
29
  className?: string;
@@ -33,7 +31,7 @@ export const Button = forwardRef(
33
31
  title?: string;
34
32
  current?: boolean;
35
33
  },
36
- ref: React.Ref<HTMLButtonElement>,
34
+ ref: Ref<HTMLButtonElement>,
37
35
  ) => {
38
36
  const icon = Icon ? <Icon className={iconSize} /> : null;
39
37
  const iconRight = IconRight ? <IconRight className={iconSize} /> : null;
@@ -1,15 +1,13 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {card} from './index.css';
6
6
 
7
- const {createElement} = React;
8
-
9
7
  export const Card = ({
10
8
  children,
11
9
  className,
12
10
  }: {
13
- children: React.ReactNode;
11
+ children: ReactNode;
14
12
  className?: string;
15
13
  }) => <div className={classNames(card, className)}>{children}</div>;
@@ -1,9 +1,15 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
3
+ import type {ComponentType, ReactNode} from 'react';
4
4
  import {ChevronDown, ChevronRight} from 'lucide-react';
5
5
  import {Button} from '../Button/index.tsx';
6
- import {classNames} from '../index.ts';
6
+ import {
7
+ classNames,
8
+ createElement,
9
+ useCallback,
10
+ useRef,
11
+ useState,
12
+ } from '../index.ts';
7
13
  import {
8
14
  useCollapsibleOpen,
9
15
  useSetCollapsibleOpen,
@@ -16,8 +22,6 @@ import {
16
22
  content,
17
23
  } from './index.css.ts';
18
24
 
19
- const {createElement, useState, useCallback, useRef} = React;
20
-
21
25
  export const Collapsible = ({
22
26
  id = '',
23
27
  icon: Icon,
@@ -27,11 +31,11 @@ export const Collapsible = ({
27
31
  children,
28
32
  }: {
29
33
  id?: string;
30
- icon?: React.ComponentType<{className?: string}>;
31
- label?: React.ReactNode;
32
- labelRight?: React.ReactNode;
34
+ icon?: ComponentType<{className?: string}>;
35
+ label?: ReactNode;
36
+ labelRight?: ReactNode;
33
37
  className?: string;
34
- children: React.ReactNode;
38
+ children: ReactNode;
35
39
  }) => {
36
40
  // State is in session Store if id is present, otherwise here in component.
37
41
  const storedIsOpen = useCollapsibleOpen(id) ?? false;
@@ -42,7 +46,7 @@ export const Collapsible = ({
42
46
  const setIsOpen = id ? setStoredIsOpen : setStateIsOpen;
43
47
 
44
48
  const [render, setRender] = useState(isOpen);
45
- const timer = useRef<Timer>();
49
+ const timer = useRef<NodeJS.Timeout>();
46
50
 
47
51
  const toggle = useCallback(() => {
48
52
  setIsOpen(!isOpen);
@@ -1,16 +1,14 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {detailCell, detailRow, detailTable} from './index.css';
6
6
 
7
- const {createElement} = React;
8
-
9
7
  export const Detail = ({
10
8
  data,
11
9
  className,
12
10
  }: {
13
- data: Record<string, React.ReactNode>;
11
+ data: Record<string, ReactNode>;
14
12
  className?: string;
15
13
  }) => {
16
14
  return (
package/src/Hr/index.tsx CHANGED
@@ -1,10 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
3
+ import {createElement} from '../';
4
4
  import {hr} from './index.css';
5
5
 
6
- const {createElement} = React;
7
-
8
6
  export const Hr = () => {
9
7
  return <hr className={hr} />;
10
8
  };
@@ -1,21 +1,19 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ComponentType, ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {iconSize} from '../index.css';
6
6
  import {metric, metricLabel, metricNumber} from './index.css';
7
7
 
8
- const {createElement} = React;
9
-
10
8
  export const Metric = ({
11
9
  icon: Icon,
12
10
  label,
13
11
  number,
14
12
  className,
15
13
  }: {
16
- icon?: React.ComponentType<{className?: string}>;
17
- label: React.ReactNode;
18
- number: React.ReactNode;
14
+ icon?: ComponentType<{className?: string}>;
15
+ label: ReactNode;
16
+ number: ReactNode;
19
17
  className?: string;
20
18
  }) => (
21
19
  <div className={classNames(metric, className)}>
@@ -1,12 +1,10 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ComponentType, ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {Avatar} from '../Avatar';
6
6
  import {summary, summaryContent, summaryImage} from './index.css';
7
7
 
8
- const {createElement} = React;
9
-
10
8
  export const Summary = ({
11
9
  icon: Icon,
12
10
  src,
@@ -14,10 +12,10 @@ export const Summary = ({
14
12
  children,
15
13
  className,
16
14
  }: {
17
- icon?: React.ComponentType<{className?: string}>;
15
+ icon?: ComponentType<{className?: string}>;
18
16
  src?: string;
19
- label: React.ReactNode;
20
- children: React.ReactNode;
17
+ label: ReactNode;
18
+ children: ReactNode;
21
19
  className?: string;
22
20
  }) => (
23
21
  <div className={classNames(summary, className)}>
@@ -22,6 +22,6 @@ export const tagVariant = styleVariants({
22
22
  });
23
23
 
24
24
  export const tagIcon = style({
25
- width: '0.75rem',
26
- height: '0.75rem',
25
+ width: '0.7rem',
26
+ height: '0.7rem',
27
27
  });
package/src/Tag/index.tsx CHANGED
@@ -1,20 +1,18 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ComponentType, ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {Axis} from '../Axis';
6
6
  import {tag, tagIcon, tagVariant} from './index.css';
7
7
 
8
- const {createElement} = React;
9
-
10
8
  export const Tag = ({
11
9
  icon: Icon,
12
10
  label,
13
11
  title,
14
12
  variant = 'default',
15
13
  }: {
16
- icon?: React.ComponentType<{className?: string}>;
17
- label?: React.ReactNode;
14
+ icon?: ComponentType<{className?: string}>;
15
+ label?: ReactNode;
18
16
  title?: string;
19
17
  variant?: keyof typeof tagVariant;
20
18
  }) => {
@@ -1,14 +1,13 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
3
  import {Moon, Sun, SunMoon} from 'lucide-react';
5
4
  import {Button} from '../../../../Button/index.tsx';
5
+ import {createElement} from '../../../../index.ts';
6
6
  import {
7
7
  useDarkChoice,
8
8
  useToggleDarkChoiceCallback,
9
9
  } from '../../../LocalStore.tsx';
10
10
 
11
- const {createElement} = React;
12
11
  const icons = [Sun, Moon, SunMoon];
13
12
 
14
13
  export const DarkButton = () => (
@@ -1,12 +1,10 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
4
- import {classNames} from '../../../../index.ts';
3
+ import {type ReactNode} from 'react';
4
+ import {classNames, createElement} from '../../../../index.ts';
5
5
  import {useSideNavOpen} from '../../../SessionStore.tsx';
6
6
  import {open, sideNav} from './index.css.ts';
7
7
 
8
- const {createElement} = React;
9
-
10
8
  export const SideNav = ({sideNav: sideNavComponents}: {sideNav: ReactNode}) => {
11
9
  return (
12
10
  <nav className={classNames(sideNav, useSideNavOpen() && open)}>
@@ -1,12 +1,11 @@
1
1
  /** @jsx createElement */
2
- import React from 'react';
2
+
3
3
  import {Menu, X} from 'lucide-react';
4
4
  import {Button} from '../../../../Button/index.tsx';
5
+ import {createElement} from '../../../../index.ts';
5
6
  import {useSideNavOpen, useToggleSideNavOpen} from '../../../SessionStore.tsx';
6
7
  import {sideNavButton} from './index.css';
7
8
 
8
- const {createElement} = React;
9
-
10
9
  export const SideNavButton = () => (
11
10
  <Button
12
11
  variant="icon"
@@ -1,10 +1,9 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
3
+ import {type ReactNode} from 'react';
4
+ import {createElement} from '../../../../index.ts';
4
5
  import {title} from './index.css.ts';
5
6
 
6
- const {createElement} = React;
7
-
8
7
  export const Title = ({title: titleComponents}: {title: ReactNode}) => {
9
8
  return <nav className={title}>{titleComponents}</nav>;
10
9
  };
@@ -1,10 +1,9 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
3
+ import type {ReactNode} from 'react';
4
+ import {createElement} from '../../../../index.ts';
4
5
  import {topNav} from './index.css.ts';
5
6
 
6
- const {createElement} = React;
7
-
8
7
  export const TopNav = ({
9
8
  topNavLeft = <div />,
10
9
  topNavRight = <div />,
@@ -1,6 +1,7 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
3
+ import type {ReactNode} from 'react';
4
+ import {createElement} from '../../../index.ts';
4
5
  import {DarkButton} from './DarkButton/index.tsx';
5
6
  import {header} from './index.css.ts';
6
7
  import {SideNav} from './SideNav/index.tsx';
@@ -8,8 +9,6 @@ import {SideNavButton} from './SideNavButton/index.tsx';
8
9
  import {Title} from './Title/index.tsx';
9
10
  import {TopNav} from './TopNav/index.tsx';
10
11
 
11
- const {createElement} = React;
12
-
13
12
  export const Header = ({
14
13
  title,
15
14
  topNavLeft,
@@ -1,10 +1,9 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
3
+ import type {ReactNode} from 'react';
4
+ import {createElement} from '../../../../index.ts';
4
5
  import {article} from './index.css.ts';
5
6
 
6
- const {createElement} = React;
7
-
8
7
  export const Article = ({article: articleComponents}: {article: ReactNode}) => {
9
8
  return <article className={article}>{articleComponents}</article>;
10
9
  };
@@ -1,10 +1,9 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
3
+ import type {ReactNode} from 'react';
4
+ import {createElement} from '../../../../index.ts';
4
5
  import {footer} from './index.css.ts';
5
6
 
6
- const {createElement} = React;
7
-
8
7
  export const Footer = ({footer: footerComponents}: {footer: ReactNode}) => {
9
8
  return <footer className={footer}>{footerComponents}</footer>;
10
9
  };
@@ -1,13 +1,11 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
4
- import {classNames} from '../../../index.ts';
3
+ import type {ReactNode} from 'react';
4
+ import {classNames, createElement} from '../../../index.ts';
5
5
  import {Article} from './Article/index.tsx';
6
6
  import {Footer} from './Footer/index.tsx';
7
7
  import {main, mainHasSideNav} from './index.css.ts';
8
8
 
9
- const {createElement} = React;
10
-
11
9
  export const Main = ({
12
10
  article,
13
11
  footer,
@@ -1,15 +1,13 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
3
+ import type {ReactNode} from 'react';
4
4
  import {themeDark, themeLight} from '../../index.css.ts';
5
- import {classNames} from '../../index.ts';
5
+ import {classNames, createElement} from '../../index.ts';
6
6
  import {useDarkChoice, useDarkPreference} from '../LocalStore.tsx';
7
7
  import {Header} from './Header/index.tsx';
8
8
  import {layout} from './index.css.ts';
9
9
  import {Main} from './Main/index.tsx';
10
10
 
11
- const {createElement} = React;
12
-
13
11
  export const Layout = ({
14
12
  title,
15
13
  topNavLeft,
@@ -1,5 +1,3 @@
1
- /** @jsx createElement */
2
- import React from 'react';
3
1
  import {createStore} from 'tinybase';
4
2
  import {createLocalPersister} from 'tinybase/persisters/persister-browser';
5
3
  import {
@@ -9,8 +7,7 @@ import {
9
7
  useSetValueCallback,
10
8
  useValue,
11
9
  } from 'tinybase/ui-react';
12
-
13
- const {useEffect} = React;
10
+ import {useEffect} from '../';
14
11
 
15
12
  const PREFERS_DARK = matchMedia?.('(prefers-color-scheme: dark)');
16
13
 
package/src/Ui/index.tsx CHANGED
@@ -1,13 +1,12 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
3
+ import type {ReactNode} from 'react';
4
4
  import {Provider} from 'tinybase/ui-react';
5
+ import {createElement} from '../index.ts';
5
6
  import {Layout} from './Layout/index.tsx';
6
7
  import {LocalStore} from './LocalStore.tsx';
7
8
  import {SessionStore} from './SessionStore.tsx';
8
9
 
9
- const {createElement} = React;
10
-
11
10
  export const Ui = (props: {
12
11
  title: ReactNode;
13
12
  topNavLeft?: ReactNode;
package/src/index.ts CHANGED
@@ -1,7 +1,18 @@
1
+ import React from 'react';
1
2
  import type {StyleRule} from '@vanilla-extract/css';
2
3
 
3
4
  const LARGE = 'screen and (min-width: 1000px)';
4
5
 
6
+ export const {
7
+ createElement,
8
+ Fragment,
9
+ useEffect,
10
+ useRef,
11
+ useState,
12
+ useCallback,
13
+ forwardRef,
14
+ } = React;
15
+
5
16
  export const large = (style: StyleRule) => ({
6
17
  '@media': {
7
18
  [LARGE]: style,