@tempots/ui 0.1.0 → 0.2.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.
@@ -4,7 +4,7 @@ import { type ButtonVariant } from '../StyleProvider/StyleProvider';
4
4
  export interface ButtonProps {
5
5
  children?: JSX.DOMNode;
6
6
  disabled?: Signal<boolean>;
7
- onClick?: () => void;
7
+ onClick?: (e: MouseEvent) => void;
8
8
  size?: Signal<Size>;
9
9
  variant?: Signal<ButtonVariant>;
10
10
  compact?: Signal<boolean>;
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@tempots/dom/jsx-runtime";
2
- import { Consumer, Signal, ClassName } from '@tempots/dom';
3
- import { StyleMarker } from '../StyleProvider/StyleProvider';
2
+ import { Signal, ClassName } from '@tempots/dom';
3
+ import { StyleConsumer } from '../StyleProvider/StyleProvider';
4
4
  export function Button({ children, size, disabled, onClick, variant, compact }) {
5
- return (_jsx(Consumer, { mark: StyleMarker, children: (theme) => {
5
+ return (_jsx(StyleConsumer, { children: (theme) => {
6
6
  const cls = Signal.combine([
7
7
  theme.styles,
8
8
  size ?? Signal.of('md'),
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx } from "@tempots/dom/jsx-runtime";
2
- import { Consumer, Signal } from '@tempots/dom';
3
- import { StyleMarker } from '../StyleProvider/StyleProvider';
2
+ import { Signal } from '@tempots/dom';
3
+ import { StyleConsumer } from '../StyleProvider/StyleProvider';
4
4
  export const Control = (props) => {
5
5
  const { children, size, spacing } = props;
6
- return (_jsx(Consumer, { mark: StyleMarker, children: ({ styles }) => {
6
+ return (_jsx(StyleConsumer, { children: ({ styles }) => {
7
7
  const cls = Signal.combine([
8
8
  styles,
9
9
  size ?? Signal.of('md'),
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@tempots/dom/jsx-runtime";
2
- import { Consumer, Signal } from '@tempots/dom';
3
- import { StyleMarker } from '../StyleProvider/StyleProvider';
2
+ import { Signal } from '@tempots/dom';
3
+ import { StyleConsumer } from '../StyleProvider/StyleProvider';
4
4
  import { Sx } from '../styling/Sx';
5
5
  export const Group = (props) => {
6
6
  const { children, align, grow, noWrap, position, spacing } = props;
7
- return (_jsx(Consumer, { mark: StyleMarker, children: ({ styles }) => {
7
+ return (_jsx(StyleConsumer, { children: ({ styles }) => {
8
8
  return (_jsxs("div", { children: [_jsx(Sx, { sx: {
9
9
  display: 'flex',
10
10
  flexDirection: 'row',
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@tempots/dom/jsx-runtime";
2
- import { Consumer, Signal, Attribute } from '@tempots/dom';
2
+ import { Signal, Attribute } from '@tempots/dom';
3
3
  import { UnstyledPopover } from '../Popover';
4
4
  import { onTargetClickMount, onTargetOverMount } from '../Popover/UnstyledPopover';
5
- import { StyleMarker } from '../StyleProvider/StyleProvider';
5
+ import { StyleConsumer } from '../StyleProvider/StyleProvider';
6
6
  import { Sx } from '../styling/Sx';
7
7
  const ARROW_SIZE = 8;
8
8
  export function Popover({ children, openStrategy, maxWidth, opened }) {
9
- return (_jsx(_Fragment, { children: _jsx(Consumer, { mark: StyleMarker, children: ({ styles }) => {
9
+ return (_jsx(_Fragment, { children: _jsx(StyleConsumer, { children: ({ styles }) => {
10
10
  const at = styles.at('styles').at;
11
11
  return (_jsxs(UnstyledPopover, { opened: opened, arrowOver: true, onTargetMount: openStrategy === 'hover' ? onTargetOverMount : onTargetClickMount, placement: Signal.of('bottom'), offset: Signal.of(ARROW_SIZE), arrow: _jsx("div", { children: _jsx(Sx, { sx: {
12
12
  backgroundColor: at('background').at('color'),
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@tempots/dom/jsx-runtime";
2
- import { Consumer, Signal } from '@tempots/dom';
3
- import { StyleMarker } from '../StyleProvider/StyleProvider';
2
+ import { Signal } from '@tempots/dom';
3
+ import { StyleConsumer } from '../StyleProvider/StyleProvider';
4
4
  import { Sx } from '../styling/Sx';
5
5
  export const Stack = (props) => {
6
6
  const { children, align, justify, spacing } = props;
7
- return (_jsx(Consumer, { mark: StyleMarker, children: ({ styles }) => {
7
+ return (_jsx(StyleConsumer, { children: ({ styles }) => {
8
8
  return (_jsxs("div", { children: [_jsx(Sx, { sx: {
9
9
  display: 'flex',
10
10
  flexDirection: 'column',
@@ -14,6 +14,10 @@ export interface StyleProviderProps {
14
14
  }
15
15
  export declare const StyleMarker: symbol;
16
16
  export declare const StyleProvider: ({ children }: StyleProviderProps) => JSX.DOMNode;
17
+ export interface StyleConsumerProps {
18
+ children?: (theme: UITheme) => JSX.DOMNode;
19
+ }
20
+ export declare function StyleConsumer({ children }: StyleConsumerProps): JSX.DOMNode;
17
21
  export type ComponentClasses<T> = (options: T) => string;
18
22
  export interface UIComponentStyles {
19
23
  button: {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@tempots/dom/jsx-runtime";
2
2
  import { css } from '@emotion/css';
3
- import { Portal, Prop, OnRemove, Provider, makeProviderMark, When } from '@tempots/dom';
3
+ import { Portal, Prop, OnRemove, Provider, makeProviderMark, When, Consumer } from '@tempots/dom';
4
4
  import { resetCss } from '../../styles/reset';
5
5
  import { getRadiusSize, getSize } from '../../styles/size';
6
6
  import { defaultDarkStyles, defaultLightStyles } from '../../styles/ui-styles';
@@ -26,6 +26,9 @@ export const StyleProvider = ({ children }) => {
26
26
  counter.update(v => v + 1);
27
27
  return (_jsxs(Provider, { value: { styles, isLight }, mark: StyleMarker, children: [_jsx(Sx, { sx: { backgroundColor: styles.map(v => v.styles.background.color) } }), _jsx(When, { is: counter.map(v => v > 0), children: _jsx(Portal, { selector: "head", children: _jsx("style", { children: resetCss }) }) }), children, _jsx(OnRemove, { clear: () => { counter.update(v => v - 1); } })] }));
28
28
  };
29
+ export function StyleConsumer({ children }) {
30
+ return _jsx(Consumer, { mark: StyleMarker, children: children });
31
+ }
29
32
  export const defaultComponentStyle = ({ font, border, spacing, background, control }) => {
30
33
  return {
31
34
  button: {
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@tempots/dom/jsx-runtime";
2
- import { Consumer, Signal, Attribute } from '@tempots/dom';
2
+ import { Signal, Attribute } from '@tempots/dom';
3
3
  import { UnstyledPopover } from '../Popover';
4
4
  import { onTargetOverMount } from '../Popover/UnstyledPopover';
5
- import { StyleMarker } from '../StyleProvider/StyleProvider';
5
+ import { StyleConsumer } from '../StyleProvider/StyleProvider';
6
6
  import { Sx } from '../styling/Sx';
7
7
  const ARROW_SIZE = 8;
8
8
  export function Tooltip({ children }) {
9
- return (_jsx(_Fragment, { children: _jsx(Consumer, { mark: StyleMarker, children: ({ styles }) => {
9
+ return (_jsx(_Fragment, { children: _jsx(StyleConsumer, { children: ({ styles }) => {
10
10
  const at = styles.at('styles').at;
11
11
  return (_jsxs(UnstyledPopover, { onTargetMount: onTargetOverMount, placement: Signal.of('top'), arrow: _jsx("div", { children: _jsx(Sx, { sx: {
12
12
  backgroundColor: at('background').at('inverseColor'),
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "@tempots/dom/jsx-runtime";
2
- import { Signal, ClassName, Consumer } from '@tempots/dom';
2
+ import { Signal, ClassName } from '@tempots/dom';
3
3
  import { getSizeOrNull } from '../../styles/size';
4
4
  import { objectOfPropertiesToSignalOfObject, sxToClassProp } from '../../styles/sx';
5
- import { StyleMarker } from '../StyleProvider/StyleProvider';
5
+ import { StyleConsumer } from '../StyleProvider/StyleProvider';
6
6
  const map = {
7
7
  m: ['margin'],
8
8
  mt: ['marginTop'],
@@ -28,7 +28,7 @@ const map = {
28
28
  pv: ['paddingTop', 'paddingBottom']
29
29
  };
30
30
  export const Spacing = (props) => {
31
- return (_jsx(Consumer, { mark: StyleMarker, children: (theme) => {
31
+ return (_jsx(StyleConsumer, { children: (theme) => {
32
32
  const keys = Object.keys(props).filter(k => k !== 'children');
33
33
  if (keys.length === 0)
34
34
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/ui",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  "dependencies": {
16
16
  "@emotion/css": "^11.10.6",
17
17
  "@floating-ui/dom": "^1.2.6",
18
- "@tempots/dom": "^5.0.2",
18
+ "@tempots/dom": "^6.0.0",
19
19
  "@tempots/std": "^0.9.7"
20
20
  },
21
21
  "devDependencies": {