@via-profit/ui-kit 0.1.0-rc.7 → 0.1.0-rc.9

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.
@@ -30,11 +30,11 @@ export type AutocompleteRef<T> = Pick<MenuRef<T>, 'scrollToItem' | 'scrollTo' |
30
30
  readonly blur: () => void;
31
31
  readonly clearInput: () => void;
32
32
  };
33
- declare const _default: <T, Multiple extends boolean | undefined = undefined>(props: Pick<MenuProps<T, Multiple>, "zIndex" | "value" | "isOpen" | "estimatedItemSize" | "overscanCount" | "items" | "endThreshold" | "multiple" | "getOptionSelected" | "onEndReached" | "onSelectItem" | "renderItem" | "onRequestClose"> & {
33
+ declare const _default: <T, Multiple extends boolean | undefined = undefined>(props: Pick<MenuProps<T, Multiple>, "zIndex" | "value" | "multiple" | "overscanCount" | "isOpen" | "estimatedItemSize" | "items" | "endThreshold" | "getOptionSelected" | "onEndReached" | "onSelectItem" | "renderItem" | "onRequestClose"> & {
34
34
  readonly containerRef?: React.Ref<HTMLDivElement> | undefined;
35
35
  readonly itemToString: ItemToString<T, Multiple>;
36
36
  readonly renderInput: (params: RenderInputProps<T, Multiple>) => React.ReactNode;
37
- readonly onRequestOpen: (event?: MouseEvent | KeyboardEvent | FocusEvent | React.FocusEvent<Element, Element> | React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent> | undefined) => void;
37
+ readonly onRequestOpen: (event?: MouseEvent | FocusEvent | KeyboardEvent | React.FocusEvent<Element, Element> | React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent> | undefined) => void;
38
38
  readonly onInputChange?: React.ChangeEventHandler<HTMLInputElement> | undefined;
39
39
  readonly filterItems?: ((items: readonly T[], data: {
40
40
  readonly query: string;
@@ -1,10 +1,5 @@
1
1
  import React from 'react';
2
- export type ButtonAccentProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
3
- readonly startIcon?: JSX.Element;
4
- readonly endIcon?: JSX.Element;
5
- };
6
- declare const _default: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
7
- readonly startIcon?: JSX.Element | undefined;
8
- readonly endIcon?: JSX.Element | undefined;
9
- } & React.RefAttributes<HTMLButtonElement>>;
2
+ import { ButtonBaseProps } from './ButtonBase';
3
+ export type ButtonAccentProps = ButtonBaseProps;
4
+ declare const _default: React.ForwardRefExoticComponent<ButtonBaseProps & React.RefAttributes<HTMLButtonElement>>;
10
5
  export default _default;
@@ -16,33 +16,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const react_1 = __importDefault(require("react"));
18
18
  const styled_1 = __importDefault(require("@emotion/styled"));
19
+ const react_2 = require("@emotion/react");
19
20
  const ButtonBase_1 = __importDefault(require("./ButtonBase"));
20
21
  const Button = (0, styled_1.default)(ButtonBase_1.default) `
21
- color: ${({ theme }) => theme.colors.accentPrimaryContrast.toString()};
22
- background-color: ${({ theme }) => theme.colors.accentPrimary.toString()};
23
- box-shadow: 0 2px 12px
24
- ${({ theme }) => theme.colors.accentPrimary.darken(0.6).alpha(0.3).toString()};
25
- &:hover {
26
- background-color: ${({ theme }) => theme.colors.accentPrimary.darken(0.1).toString()};
27
- }
28
- &:active {
29
- background-color: ${({ theme }) => theme.colors.accentPrimary.darken(0.2).toString()};
30
- }
31
- &:focus-visible {
32
- outline: 2px solid ${({ theme }) => theme.colors.accentPrimary.darken(0.3).toString()};
33
- }
34
- `;
35
- const StartIconWrapper = styled_1.default.span `
36
- margin-right: 0.8em;
37
- `;
38
- const EndIconWrapper = styled_1.default.span `
39
- margin-left: 0.8em;
22
+ color: ${({ theme, disabled }) => disabled
23
+ ? theme.colors.textPrimary.alpha(0.4).toString()
24
+ : theme.colors.accentPrimaryContrast.toString()};
25
+ background-color: ${({ theme, disabled }) => disabled
26
+ ? theme.colors.backgroundGrey.darken(30).toString()
27
+ : theme.colors.accentPrimary.toString()};
28
+
29
+ ${({ disabled, theme }) => !disabled &&
30
+ (0, react_2.css) `
31
+ box-shadow: 0 2px 12px ${theme.colors.accentPrimary.darken(60).alpha(0.3).toString()};
32
+ &:hover {
33
+ background-color: ${theme.colors.accentPrimary.darken(20).toString()};
34
+ }
35
+ &:active {
36
+ background-color: ${theme.colors.accentPrimary.darken(30).toString()};
37
+ }
38
+ &:focus-visible {
39
+ outline: 2px solid ${theme.colors.accentPrimary.darken(20).toString()};
40
+ }
41
+ `};
40
42
  `;
41
43
  const ButtonAccent = (props, ref) => {
42
- const { children, startIcon, endIcon } = props, otherProps = __rest(props, ["children", "startIcon", "endIcon"]);
43
- return (react_1.default.createElement(Button, Object.assign({}, otherProps, { ref: ref }),
44
- typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(StartIconWrapper, null, startIcon)),
45
- children,
46
- typeof endIcon !== 'undefined' && endIcon !== null && (react_1.default.createElement(EndIconWrapper, null, endIcon))));
44
+ const { children } = props, restProps = __rest(props, ["children"]);
45
+ return (react_1.default.createElement(Button, Object.assign({}, restProps, { ref: ref }), children));
47
46
  };
48
47
  exports.default = react_1.default.forwardRef(ButtonAccent);
@@ -1,4 +1,7 @@
1
1
  import React from 'react';
2
- export type ButtonBaseProps = React.ButtonHTMLAttributes<HTMLButtonElement>;
2
+ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
+ readonly startIcon?: JSX.Element;
4
+ readonly endIcon?: JSX.Element;
5
+ }
3
6
  declare const _default: React.ForwardRefExoticComponent<ButtonBaseProps & React.RefAttributes<HTMLButtonElement>>;
4
7
  export default _default;
@@ -16,24 +16,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const react_1 = __importDefault(require("react"));
18
18
  const styled_1 = __importDefault(require("@emotion/styled"));
19
+ const StartIconWrapper_1 = __importDefault(require("./components/StartIconWrapper"));
20
+ const EndIconWrapper_1 = __importDefault(require("./components/EndIconWrapper"));
21
+ const TextWrapper_1 = __importDefault(require("./components/TextWrapper"));
19
22
  const Button = styled_1.default.button `
20
23
  border-radius: ${({ theme }) => theme.shape.radiusFactor * 2}em;
21
24
  padding: 0.8em 1em;
22
25
  font-size: 0.8rem;
23
- cursor: pointer;
26
+ cursor: ${({ disabled }) => (disabled ? 'default' : 'pointer')};
24
27
  font-size: 1em;
25
28
  border: 0;
26
29
  outline: transparent;
27
30
  transition: all 180ms ease-out 0s;
28
31
  background: none;
29
32
  color: currentColor;
30
- `;
31
- const ButtonText = styled_1.default.span `
32
- font-size: 0.86em;
33
+ display: inline-flex;
34
+ align-items: center;
33
35
  `;
34
36
  const ButtonBase = (props, ref) => {
35
- const { children } = props, otherProps = __rest(props, ["children"]);
37
+ const { children, startIcon, endIcon } = props, otherProps = __rest(props, ["children", "startIcon", "endIcon"]);
36
38
  return (react_1.default.createElement(Button, Object.assign({}, otherProps, { ref: ref }),
37
- react_1.default.createElement(ButtonText, null, children)));
39
+ typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(StartIconWrapper_1.default, null, startIcon)),
40
+ react_1.default.createElement(TextWrapper_1.default, null, children),
41
+ typeof endIcon !== 'undefined' && endIcon !== null && (react_1.default.createElement(EndIconWrapper_1.default, null, endIcon))));
38
42
  };
39
43
  exports.default = react_1.default.forwardRef(ButtonBase);
@@ -1,19 +1,8 @@
1
1
  import React from 'react';
2
+ import { ButtonBaseProps } from './ButtonBase';
2
3
  /**
3
4
  * Standard
4
5
  */
5
- export type ButtonStandardProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
6
- /**
7
- * Starticon
8
- */
9
- readonly startIcon?: JSX.Element;
10
- readonly endIcon?: JSX.Element;
11
- };
12
- declare const _default: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
13
- /**
14
- * Starticon
15
- */
16
- readonly startIcon?: JSX.Element | undefined;
17
- readonly endIcon?: JSX.Element | undefined;
18
- } & React.RefAttributes<HTMLButtonElement>>;
6
+ export type ButtonStandardProps = ButtonBaseProps;
7
+ declare const _default: React.ForwardRefExoticComponent<ButtonBaseProps & React.RefAttributes<HTMLButtonElement>>;
19
8
  export default _default;
@@ -16,35 +16,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const react_1 = __importDefault(require("react"));
18
18
  const styled_1 = __importDefault(require("@emotion/styled"));
19
+ const react_2 = require("@emotion/react");
19
20
  const ButtonBase_1 = __importDefault(require("./ButtonBase"));
20
- const Button = (0, styled_1.default)(ButtonBase_1.default) `
21
- color: ${({ theme }) => theme.colors.textPrimary.toString()};
22
- background-color: ${({ theme }) => theme.isDark
23
- ? theme.colors.backgroundPrimary.lighten(20).toString()
24
- : theme.colors.backgroundPrimary.toString()};
25
- box-shadow: 0 2px 12px
26
- ${({ theme }) => theme.colors.backgroundPrimary.darken(40).alpha(0.6).toString()};
27
- &:hover {
28
- background-color: ${({ theme }) => theme.colors.backgroundPrimary.darken(20).toString()};
29
- }
30
- &:active {
31
- background-color: ${({ theme }) => theme.colors.backgroundPrimary.darken(40).toString()};
32
- }
33
- &:focus-visible {
34
- outline: 2px solid ${({ theme }) => theme.colors.accentPrimary.toString()};
35
- }
36
- `;
37
- const StartIconWrapper = styled_1.default.span `
38
- margin-right: 0.8em;
39
- `;
40
- const EndIconWrapper = styled_1.default.span `
41
- margin-left: 0.8em;
21
+ const StyledButtonBase = (0, styled_1.default)(ButtonBase_1.default) `
22
+ color: ${({ theme, disabled }) => disabled
23
+ ? theme.colors.textPrimary.alpha(0.4).toString()
24
+ : theme.colors.textPrimary.toString()};
25
+ background-color: ${({ theme, disabled }) => disabled
26
+ ? theme.colors.backgroundGrey.darken(10).toString()
27
+ : theme.isDark
28
+ ? theme.colors.backgroundPrimary.lighten(20).toString()
29
+ : theme.colors.backgroundPrimary.toString()};
30
+
31
+ ${({ disabled, theme }) => !disabled &&
32
+ (0, react_2.css) `
33
+ box-shadow: 0 2px 12px ${theme.colors.backgroundPrimary.darken(40).alpha(0.6).toString()};
34
+ &:hover {
35
+ background-color: ${theme.colors.backgroundPrimary.darken(20).toString()};
36
+ }
37
+ &:active {
38
+ background-color: ${theme.colors.backgroundPrimary.darken(40).toString()};
39
+ }
40
+ &:focus-visible {
41
+ outline: 2px solid ${theme.colors.accentPrimary.toString()};
42
+ }
43
+ `}
42
44
  `;
43
45
  const ButtonStandard = (props, ref) => {
44
- const { children, startIcon, endIcon } = props, otherProps = __rest(props, ["children", "startIcon", "endIcon"]);
45
- return (react_1.default.createElement(Button, Object.assign({}, otherProps, { ref: ref }),
46
- typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(StartIconWrapper, null, startIcon)),
47
- children,
48
- typeof endIcon !== 'undefined' && endIcon !== null && (react_1.default.createElement(EndIconWrapper, null, endIcon))));
46
+ const { children, disabled } = props, restProps = __rest(props, ["children", "disabled"]);
47
+ return (react_1.default.createElement(StyledButtonBase, Object.assign({ disabled: disabled }, restProps, { ref: ref }), children));
49
48
  };
50
49
  exports.default = react_1.default.forwardRef(ButtonStandard);
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare const EndIconWrapper: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
6
+ export default EndIconWrapper;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const styled_1 = __importDefault(require("@emotion/styled"));
7
+ const EndIconWrapper = styled_1.default.span `
8
+ margin-left: 0.8em;
9
+ `;
10
+ exports.default = EndIconWrapper;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare const StartIconWrapper: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
6
+ export default StartIconWrapper;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const styled_1 = __importDefault(require("@emotion/styled"));
7
+ const StartIconWrapper = styled_1.default.span `
8
+ margin-right: 0.8em;
9
+ `;
10
+ exports.default = StartIconWrapper;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare const TextWrapper: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
6
+ export default TextWrapper;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const styled_1 = __importDefault(require("@emotion/styled"));
7
+ const TextWrapper = styled_1.default.span `
8
+ font-size: 0.86em;
9
+ display: flex;
10
+ align-items: center;
11
+ `;
12
+ exports.default = TextWrapper;
package/Button/index.d.ts CHANGED
@@ -5,5 +5,5 @@ interface BaseProps {
5
5
  readonly variant?: 'standard' | 'accent';
6
6
  }
7
7
  export type ButtonProps = (ButtonStandardProps | ButtonAccentProps) & BaseProps;
8
- declare const _default: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
8
+ declare const _default: React.ForwardRefExoticComponent<import("./ButtonBase").ButtonBaseProps & BaseProps & React.RefAttributes<HTMLButtonElement>>;
9
9
  export default _default;
@@ -26,11 +26,11 @@ export type SelectBoxProps<T, Multiple extends boolean | undefined = undefined>
26
26
  readonly containerRef?: React.Ref<SelectoBoxContainerRef>;
27
27
  readonly notSelectedLabel?: React.ReactNode;
28
28
  };
29
- declare const _default: <T, Multiple extends boolean | undefined = false>(props: Pick<MenuProps<T, Multiple>, "zIndex" | "value" | "isOpen" | "estimatedItemSize" | "overscanCount" | "items" | "endThreshold" | "multiple" | "getOptionSelected" | "onEndReached" | "onSelectItem" | "renderItem" | "onRequestClose"> & {
29
+ declare const _default: <T, Multiple extends boolean | undefined = false>(props: Pick<MenuProps<T, Multiple>, "zIndex" | "value" | "multiple" | "overscanCount" | "isOpen" | "estimatedItemSize" | "items" | "endThreshold" | "getOptionSelected" | "onEndReached" | "onSelectItem" | "renderItem" | "onRequestClose"> & {
30
30
  readonly fullWidth?: boolean | undefined;
31
31
  readonly itemToString: ItemToString<T, Multiple>;
32
32
  readonly renderInput?: ((params: RenderInputProps<T, Multiple>) => React.ReactNode) | undefined;
33
- readonly onRequestOpen: (event?: MouseEvent | KeyboardEvent | FocusEvent | React.FocusEvent<Element, Element> | React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent> | undefined) => void;
33
+ readonly onRequestOpen: (event?: MouseEvent | FocusEvent | KeyboardEvent | React.FocusEvent<Element, Element> | React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent> | undefined) => void;
34
34
  } & {
35
35
  readonly containerRef?: React.Ref<HTMLButtonElement> | undefined;
36
36
  readonly notSelectedLabel?: React.ReactNode;
@@ -1,35 +1,3 @@
1
- import { ColorInterface } from '../color';
2
- export type CreateTheme = (overrides?: UIThemeOverrides) => UITheme;
3
- export interface UITheme {
4
- readonly isDark: boolean;
5
- readonly fontSize: Record<'small' | 'normal' | 'medium' | 'large', number>;
6
- readonly zIndex: {
7
- readonly header: number;
8
- readonly mainDrawer: number;
9
- readonly modal: number;
10
- };
11
- readonly colors: {
12
- readonly backgroundPrimary: ColorInterface;
13
- readonly backgroundSecondary: ColorInterface;
14
- readonly backgroundGrey: ColorInterface;
15
- readonly textPrimary: ColorInterface;
16
- readonly textSecondary: ColorInterface;
17
- readonly accentPrimary: ColorInterface;
18
- readonly accentPrimaryContrast: ColorInterface;
19
- readonly accentSecondary: ColorInterface;
20
- readonly accentSecondaryContrast: ColorInterface;
21
- readonly error: ColorInterface;
22
- };
23
- readonly shape: {
24
- readonly radiusFactor: 0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1;
25
- };
26
- }
27
- export interface UIThemeOverrides {
28
- readonly isDark?: UITheme['isDark'];
29
- readonly fontSize?: UITheme['fontSize'];
30
- readonly zIndex?: UITheme['zIndex'];
31
- readonly colors?: Partial<Record<keyof UITheme['colors'], string>>;
32
- readonly shape?: UITheme['shape'];
33
- }
1
+ import type { UITheme, UIThemeOverrides } from '@via-profit/ui-kit';
34
2
  declare const createTheme: (overrides?: UIThemeOverrides) => UITheme;
35
3
  export default createTheme;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import type { UITheme } from './createTheme';
2
+ import type { UITheme, UIThemeOverrides } from '@via-profit/ui-kit';
3
+ export { UITheme, UIThemeOverrides };
3
4
  export interface ThemeProviderProps {
4
5
  readonly children: React.ReactNode | readonly React.ReactNode[];
5
6
  readonly theme: UITheme;
package/color/Color.d.ts CHANGED
@@ -1,23 +1,4 @@
1
- export interface ColorInterface {
2
- parseColor(value: string | Color): ParsedColor;
3
- shade(decimal: number): this;
4
- alpha(decimal: number): this;
5
- lighten(decimal: number): this;
6
- darken(decimal: number): this;
7
- getHextByWebColor(value: string): string;
8
- rgb(): ParsedColor;
9
- rgbString(): string;
10
- hexString(): string;
11
- toString(): string;
12
- luminance(): number;
13
- contrast(rgb2: string | Color): number;
14
- }
15
- export type ParsedColor = {
16
- r: number;
17
- g: number;
18
- b: number;
19
- a: number;
20
- };
1
+ import type { ColorInterface, ParsedColor } from '@via-profit/ui-kit/color';
21
2
  declare class Color implements ColorInterface {
22
3
  #private;
23
4
  constructor(value: string | Color);
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@via-profit/ui-kit",
3
- "version": "0.1.0-rc.7",
3
+ "version": "0.1.0-rc.9",
4
4
  "description": "UI Kit",
5
- "main": "index.js",
6
5
  "repository": {
7
6
  "type": "git",
8
7
  "url": "git@github.com:via-profit/ui-kit.git"
package/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import Button from './Button';
2
- import { UITheme } from './ThemeProvider/createTheme';
3
- export * from './Button';
4
- export { Button, UITheme };
package/index.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.Button = void 0;
21
- const Button_1 = __importDefault(require("./Button"));
22
- exports.Button = Button_1.default;
23
- __exportStar(require("./Button"), exports);