@uni-design-system/uni-react 0.0.12 → 0.0.14

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.
@@ -1,5 +1,5 @@
1
1
  import React, { CSSProperties, ReactNode } from 'react';
2
- import { ButtonType } from '@uni-design-system/uni-core';
2
+ import { ButtonType, ContentColorToken } from '@uni-design-system/uni-core';
3
3
  import { IconName } from '../../core/icon';
4
4
  export interface ButtonProps {
5
5
  text?: string;
@@ -8,8 +8,9 @@ export interface ButtonProps {
8
8
  active?: boolean;
9
9
  disabled?: boolean;
10
10
  iconName?: IconName;
11
+ contentColor?: ContentColorToken;
11
12
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
12
13
  disableRipple?: boolean;
13
14
  style?: CSSProperties;
14
15
  }
15
- export declare const Button: ({ text, children, buttonType, disabled, iconName, onClick, disableRipple, style: userStyle, ...rest }: ButtonProps) => JSX.Element;
16
+ export declare const Button: ({ text, children, buttonType, disabled, iconName, contentColor: overrideContentColor, onClick, disableRipple, style: userStyle, ...rest }: ButtonProps) => JSX.Element;
@@ -41,23 +41,18 @@ exports.Button = void 0;
41
41
  const react_1 = __importStar(require("react"));
42
42
  const core_1 = require("../../core");
43
43
  const icon_text_row_1 = require("../icon-text-row");
44
- const layout_hook_1 = __importDefault(require("../../core/layout/layout.hook"));
45
44
  const use_ripple_hook_1 = __importDefault(require("use-ripple-hook"));
46
45
  const Button = (_a) => {
47
- var { text, children, buttonType = 'filled', disabled = false, iconName, onClick, disableRipple = false, style: userStyle } = _a, rest = __rest(_a, ["text", "children", "buttonType", "disabled", "iconName", "onClick", "disableRipple", "style"]);
48
- const { deviceSize } = (0, layout_hook_1.default)();
46
+ var { text, children, buttonType = 'filled', disabled = false, iconName, contentColor: overrideContentColor, onClick, disableRipple = false, style: userStyle } = _a, rest = __rest(_a, ["text", "children", "buttonType", "disabled", "iconName", "contentColor", "onClick", "disableRipple", "style"]);
47
+ const { deviceSize } = (0, core_1.useLayout)();
49
48
  const theme = (0, core_1.useTheme)();
50
49
  const [ref, createRipple] = (0, use_ripple_hook_1.default)({ disabled: disableRipple || buttonType === 'elevated' });
51
50
  const buttonProps = theme.buttons[buttonType];
52
51
  const getOnColorToken = (color) => `on-${color}`;
53
- const defaultContentColor = getOnColorToken(buttonProps.color);
52
+ const contentColor = overrideContentColor || getOnColorToken(buttonProps.color);
54
53
  const [hover, setHover] = (0, react_1.useState)(false);
55
54
  const [click, setClick] = (0, react_1.useState)(false);
56
- const [contentColor, setContentColor] = (0, react_1.useState)(defaultContentColor);
57
55
  const style = Style(theme, buttonType, deviceSize, hover, disabled, click);
58
- (0, react_1.useEffect)(() => {
59
- setContentColor(getOnColorToken(disabled ? 'inverse-on-surface' : buttonProps.color));
60
- }, [disabled]);
61
56
  (0, react_1.useEffect)(() => {
62
57
  setTimeout(() => {
63
58
  setClick(false);
@@ -1,5 +1,6 @@
1
1
  import React, { HTMLAttributes, ReactNode } from 'react';
2
2
  import { AlignContent, FlexDirection, FlexGrow, FlexShrink, FlexWrap, JustifyContent } from '@uni-design-system/uni-core';
3
+ import { Property } from 'csstype';
3
4
  export interface FlexOptions extends HTMLAttributes<HTMLDivElement> {
4
5
  /**
5
6
  * Shorthand for `alignItems` style prop
@@ -37,6 +38,7 @@ export interface FlexOptions extends HTMLAttributes<HTMLDivElement> {
37
38
  * @type FlexShrink
38
39
  */
39
40
  shrink?: FlexShrink;
41
+ gap?: Property.Gap<number | string>;
40
42
  }
41
43
  export interface FlexProps extends FlexOptions {
42
44
  children: ReactNode;
@@ -26,8 +26,8 @@ const react_2 = require("react");
26
26
  * @see Docs
27
27
  */
28
28
  exports.Flex = (0, react_2.forwardRef)((props, ref) => {
29
- const { direction, align, justify, wrap, basis, grow, shrink, style } = props, rest = __rest(props, ["direction", "align", "justify", "wrap", "basis", "grow", "shrink", "style"]);
30
- const styles = Object.assign({ display: 'flex', flexDirection: direction, alignItems: align, justifyContent: justify, flexWrap: wrap, flexBasis: basis, flexGrow: grow, flexShrink: shrink }, style);
29
+ const { direction, align, justify, wrap, basis, grow, shrink, gap, style } = props, rest = __rest(props, ["direction", "align", "justify", "wrap", "basis", "grow", "shrink", "gap", "style"]);
30
+ const styles = Object.assign({ display: 'flex', flexDirection: direction, alignItems: align, justifyContent: justify, flexWrap: wrap, flexBasis: basis, flexGrow: grow, flexShrink: shrink, gap }, style);
31
31
  return react_1.default.createElement("div", Object.assign({ ref: ref, style: styles }, rest));
32
32
  });
33
33
  exports.Flex.displayName = 'Flex';
@@ -1,2 +1,2 @@
1
1
  import { Layout } from '@uni-design-system/uni-core';
2
- export default function useLayout(): Layout;
2
+ export declare function useLayout(): Layout;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useLayout = void 0;
6
7
  const react_1 = __importDefault(require("react"));
7
8
  const uni_core_1 = require("@uni-design-system/uni-core");
8
9
  const layout_context_1 = __importDefault(require("./layout.context"));
@@ -12,4 +13,4 @@ function useLayout() {
12
13
  const orientation = (0, uni_core_1.getDeviceOrientation)(height, width);
13
14
  return { orientation, deviceSize };
14
15
  }
15
- exports.default = useLayout;
16
+ exports.useLayout = useLayout;
@@ -1,5 +1,5 @@
1
1
  import React, { CSSProperties, ReactNode } from 'react';
2
- import { ButtonType } from '@uni-design-system/uni-core';
2
+ import { ButtonType, ContentColorToken } from '@uni-design-system/uni-core';
3
3
  import { IconName } from '../../core/icon';
4
4
  export interface ButtonProps {
5
5
  text?: string;
@@ -8,8 +8,9 @@ export interface ButtonProps {
8
8
  active?: boolean;
9
9
  disabled?: boolean;
10
10
  iconName?: IconName;
11
+ contentColor?: ContentColorToken;
11
12
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
12
13
  disableRipple?: boolean;
13
14
  style?: CSSProperties;
14
15
  }
15
- export declare const Button: ({ text, children, buttonType, disabled, iconName, onClick, disableRipple, style: userStyle, ...rest }: ButtonProps) => JSX.Element;
16
+ export declare const Button: ({ text, children, buttonType, disabled, iconName, contentColor: overrideContentColor, onClick, disableRipple, style: userStyle, ...rest }: ButtonProps) => JSX.Element;
@@ -10,25 +10,20 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { useEffect, useState } from 'react';
13
- import { BoxShadow, Text, useTheme } from '../../core';
13
+ import { BoxShadow, Text, useLayout, useTheme } from '../../core';
14
14
  import { IconTextRow } from '../icon-text-row';
15
- import useLayout from '../../core/layout/layout.hook';
16
15
  import useRipple from 'use-ripple-hook';
17
16
  export const Button = (_a) => {
18
- var { text, children, buttonType = 'filled', disabled = false, iconName, onClick, disableRipple = false, style: userStyle } = _a, rest = __rest(_a, ["text", "children", "buttonType", "disabled", "iconName", "onClick", "disableRipple", "style"]);
17
+ var { text, children, buttonType = 'filled', disabled = false, iconName, contentColor: overrideContentColor, onClick, disableRipple = false, style: userStyle } = _a, rest = __rest(_a, ["text", "children", "buttonType", "disabled", "iconName", "contentColor", "onClick", "disableRipple", "style"]);
19
18
  const { deviceSize } = useLayout();
20
19
  const theme = useTheme();
21
20
  const [ref, createRipple] = useRipple({ disabled: disableRipple || buttonType === 'elevated' });
22
21
  const buttonProps = theme.buttons[buttonType];
23
22
  const getOnColorToken = (color) => `on-${color}`;
24
- const defaultContentColor = getOnColorToken(buttonProps.color);
23
+ const contentColor = overrideContentColor || getOnColorToken(buttonProps.color);
25
24
  const [hover, setHover] = useState(false);
26
25
  const [click, setClick] = useState(false);
27
- const [contentColor, setContentColor] = useState(defaultContentColor);
28
26
  const style = Style(theme, buttonType, deviceSize, hover, disabled, click);
29
- useEffect(() => {
30
- setContentColor(getOnColorToken(disabled ? 'inverse-on-surface' : buttonProps.color));
31
- }, [disabled]);
32
27
  useEffect(() => {
33
28
  setTimeout(() => {
34
29
  setClick(false);
@@ -1,5 +1,6 @@
1
1
  import React, { HTMLAttributes, ReactNode } from 'react';
2
2
  import { AlignContent, FlexDirection, FlexGrow, FlexShrink, FlexWrap, JustifyContent } from '@uni-design-system/uni-core';
3
+ import { Property } from 'csstype';
3
4
  export interface FlexOptions extends HTMLAttributes<HTMLDivElement> {
4
5
  /**
5
6
  * Shorthand for `alignItems` style prop
@@ -37,6 +38,7 @@ export interface FlexOptions extends HTMLAttributes<HTMLDivElement> {
37
38
  * @type FlexShrink
38
39
  */
39
40
  shrink?: FlexShrink;
41
+ gap?: Property.Gap<number | string>;
40
42
  }
41
43
  export interface FlexProps extends FlexOptions {
42
44
  children: ReactNode;
@@ -20,8 +20,8 @@ import { forwardRef } from 'react';
20
20
  * @see Docs
21
21
  */
22
22
  export const Flex = forwardRef((props, ref) => {
23
- const { direction, align, justify, wrap, basis, grow, shrink, style } = props, rest = __rest(props, ["direction", "align", "justify", "wrap", "basis", "grow", "shrink", "style"]);
24
- const styles = Object.assign({ display: 'flex', flexDirection: direction, alignItems: align, justifyContent: justify, flexWrap: wrap, flexBasis: basis, flexGrow: grow, flexShrink: shrink }, style);
23
+ const { direction, align, justify, wrap, basis, grow, shrink, gap, style } = props, rest = __rest(props, ["direction", "align", "justify", "wrap", "basis", "grow", "shrink", "gap", "style"]);
24
+ const styles = Object.assign({ display: 'flex', flexDirection: direction, alignItems: align, justifyContent: justify, flexWrap: wrap, flexBasis: basis, flexGrow: grow, flexShrink: shrink, gap }, style);
25
25
  return React.createElement("div", Object.assign({ ref: ref, style: styles }, rest));
26
26
  });
27
27
  Flex.displayName = 'Flex';
@@ -1,2 +1,2 @@
1
1
  import { Layout } from '@uni-design-system/uni-core';
2
- export default function useLayout(): Layout;
2
+ export declare function useLayout(): Layout;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { getDeviceOrientation, getDeviceSize } from '@uni-design-system/uni-core';
3
3
  import LayoutContext from './layout.context';
4
- export default function useLayout() {
4
+ export function useLayout() {
5
5
  const { height, width } = React.useContext(LayoutContext);
6
6
  const deviceSize = getDeviceSize(height, width);
7
7
  const orientation = getDeviceOrientation(height, width);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uni-design-system/uni-react",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "React component library for the UNI Design System.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -36,7 +36,7 @@
36
36
  "@dnd-kit/core": "^6.0.7",
37
37
  "@dnd-kit/modifiers": "^6.0.1",
38
38
  "@dnd-kit/sortable": "^7.0.2",
39
- "@uni-design-system/uni-core": "^0.0.33",
39
+ "@uni-design-system/uni-core": "^0.0.34",
40
40
  "@uni-design-system/uni-react-icons": "^0.1.2",
41
41
  "framer-motion": "4.1.17",
42
42
  "use-ripple-hook": "^1.0.22"