@uni-design-system/uni-react 0.0.11 → 0.0.13

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.
@@ -41,11 +41,10 @@ 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
46
  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)();
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];
@@ -1,13 +1,14 @@
1
- import { ReactNode } from 'react';
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
2
  import { ContainerColorToken, ShadowElevation, Size } from '@uni-design-system/uni-core';
3
+ import { Property } from 'csstype';
3
4
  export type CardType = 'elevated' | 'filled' | 'outlined';
4
- export interface CardProps {
5
+ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
5
6
  children?: ReactNode;
6
7
  cardType?: CardType;
7
8
  colorToken?: ContainerColorToken;
8
9
  elevation?: ShadowElevation;
9
- width?: number;
10
- height?: number | string | undefined;
10
+ width?: Property.Width<number | string>;
11
+ height?: Property.Height<number | string>;
11
12
  borderRadius?: Size | 'none';
12
13
  }
13
- export declare function Card({ children, cardType, elevation, colorToken, width, height, borderRadius, }: CardProps): JSX.Element;
14
+ export declare function Card({ children, cardType, elevation, colorToken, width, height, borderRadius, style, ...rest }: CardProps): JSX.Element;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
@@ -6,17 +17,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
17
  exports.Card = void 0;
7
18
  const react_1 = __importDefault(require("react"));
8
19
  const core_1 = require("../../core");
9
- function Card({ children, cardType, elevation, colorToken = 'primary-container', width, height, borderRadius, }) {
20
+ function Card(_a) {
21
+ var { children, cardType, elevation, colorToken = 'surface', width, height, borderRadius, style } = _a, rest = __rest(_a, ["children", "cardType", "elevation", "colorToken", "width", "height", "borderRadius", "style"]);
10
22
  const { colors, containers } = (0, core_1.useTheme)();
11
23
  const { borderRadii } = containers.card;
12
- const style = Object.assign({ height,
13
- width, backgroundColor: colors[colorToken || 'surface'], color: colors[`on-${colorToken}` || 'on-surface'] }, (0, core_1.Padding)('md', 'all'));
24
+ const styles = Object.assign(Object.assign({ height,
25
+ width, backgroundColor: colors[colorToken || 'surface'], color: colors[`on-${colorToken}` || 'on-surface'] }, (0, core_1.Padding)('md', 'all')), style);
14
26
  if (cardType === 'elevated') {
15
- style.boxShadow = (0, core_1.BoxShadow)(elevation || 'raised');
27
+ styles.boxShadow = (0, core_1.BoxShadow)(elevation || 'raised');
16
28
  }
17
29
  if (borderRadii && borderRadius !== 'none') {
18
- style.borderRadius = borderRadii[borderRadius || 'md'];
30
+ styles.borderRadius = borderRadii[borderRadius || 'md'];
19
31
  }
20
- return react_1.default.createElement("div", { style: style }, children);
32
+ return (react_1.default.createElement("div", Object.assign({ style: styles }, rest), children));
21
33
  }
22
34
  exports.Card = Card;
@@ -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;
@@ -10,9 +10,8 @@ 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
17
  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"]);
@@ -1,13 +1,14 @@
1
- import { ReactNode } from 'react';
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
2
  import { ContainerColorToken, ShadowElevation, Size } from '@uni-design-system/uni-core';
3
+ import { Property } from 'csstype';
3
4
  export type CardType = 'elevated' | 'filled' | 'outlined';
4
- export interface CardProps {
5
+ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
5
6
  children?: ReactNode;
6
7
  cardType?: CardType;
7
8
  colorToken?: ContainerColorToken;
8
9
  elevation?: ShadowElevation;
9
- width?: number;
10
- height?: number | string | undefined;
10
+ width?: Property.Width<number | string>;
11
+ height?: Property.Height<number | string>;
11
12
  borderRadius?: Size | 'none';
12
13
  }
13
- export declare function Card({ children, cardType, elevation, colorToken, width, height, borderRadius, }: CardProps): JSX.Element;
14
+ export declare function Card({ children, cardType, elevation, colorToken, width, height, borderRadius, style, ...rest }: CardProps): JSX.Element;
@@ -1,15 +1,27 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import React from 'react';
2
13
  import { BoxShadow, Padding, useTheme } from '../../core';
3
- export function Card({ children, cardType, elevation, colorToken = 'primary-container', width, height, borderRadius, }) {
14
+ export function Card(_a) {
15
+ var { children, cardType, elevation, colorToken = 'surface', width, height, borderRadius, style } = _a, rest = __rest(_a, ["children", "cardType", "elevation", "colorToken", "width", "height", "borderRadius", "style"]);
4
16
  const { colors, containers } = useTheme();
5
17
  const { borderRadii } = containers.card;
6
- const style = Object.assign({ height,
7
- width, backgroundColor: colors[colorToken || 'surface'], color: colors[`on-${colorToken}` || 'on-surface'] }, Padding('md', 'all'));
18
+ const styles = Object.assign(Object.assign({ height,
19
+ width, backgroundColor: colors[colorToken || 'surface'], color: colors[`on-${colorToken}` || 'on-surface'] }, Padding('md', 'all')), style);
8
20
  if (cardType === 'elevated') {
9
- style.boxShadow = BoxShadow(elevation || 'raised');
21
+ styles.boxShadow = BoxShadow(elevation || 'raised');
10
22
  }
11
23
  if (borderRadii && borderRadius !== 'none') {
12
- style.borderRadius = borderRadii[borderRadius || 'md'];
24
+ styles.borderRadius = borderRadii[borderRadius || 'md'];
13
25
  }
14
- return React.createElement("div", { style: style }, children);
26
+ return (React.createElement("div", Object.assign({ style: styles }, rest), children));
15
27
  }
@@ -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.11",
3
+ "version": "0.0.13",
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",