@creativecodeco/ui 0.3.0 → 0.4.1

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,3 +1,3 @@
1
- export * from './ui/base';
2
- export * from './ui/components';
3
- export * from './ui/forms';
1
+ export type * from './ui/base';
2
+ export type * from './ui/components';
3
+ export type * from './ui/forms';
@@ -1,3 +1 @@
1
- export * from './ui/base';
2
- export * from './ui/components';
3
- export * from './ui/forms';
1
+ export {};
@@ -1,3 +1,4 @@
1
1
  export type SizeType = 'xs' | 'sm' | 'md' | 'lg';
2
2
  export type ColorType = 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'info' | 'error';
3
+ export type ColorButtonType = 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'info' | 'error' | 'ghost' | 'neutral';
3
4
  export type PositionType = 'left' | 'right';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export type ButtonEvent = React.MouseEvent<HTMLButtonElement, MouseEvent>;
3
+ export type ButtonEventHandler = React.MouseEventHandler<HTMLButtonElement>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,3 @@
1
1
  export type * from './constants.types';
2
+ export type * from './dom.types';
2
3
  export type * from './error.types';
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import type { ColorButtonType, SizeType } from '../../../types';
3
+ import type { IconType } from 'react-icons';
4
+ import type { PositionType } from '../../../types';
5
+ export interface ButtonType extends React.ButtonHTMLAttributes<HTMLButtonElement> {
6
+ isLink?: boolean;
7
+ color?: ColorButtonType;
8
+ outline?: boolean;
9
+ size?: SizeType;
10
+ icon?: IconType;
11
+ iconPosition?: PositionType;
12
+ loading?: boolean;
13
+ loadingLabel?: string;
14
+ }
15
+ export type ButtonRef = HTMLButtonElement;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,2 @@
1
- import { AvatarType } from './avatar.types';
2
- export type { AvatarType };
1
+ export type * from './avatar.types';
2
+ export type * from './button.types';
@@ -1,7 +1,6 @@
1
1
  import type { ColorType, ErrorType, PositionType, SizeType } from '../../../types';
2
2
  export interface RadioItemType {
3
3
  label?: string;
4
- checked?: boolean;
5
4
  value?: string | number;
6
5
  }
7
6
  export interface RadioType extends RadioItemType, ErrorType {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { type ButtonType } from '../../../types';
3
+ declare const Button: React.ForwardRefExoticComponent<ButtonType & React.RefAttributes<HTMLButtonElement>>;
4
+ export default Button;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useMemo } from 'react';
3
+ import cls from 'classnames';
4
+ import { useSafeButtonProps } from '../../../hooks';
5
+ const Button = forwardRef(({ children, isLink, color, outline, size = 'md', icon: Icon, iconPosition = 'left', loading, loadingLabel, ...otherProps }, ref) => {
6
+ const safeProps = useSafeButtonProps({ loading, ...otherProps });
7
+ const newIcon = useMemo(() => {
8
+ if (!Icon) {
9
+ return;
10
+ }
11
+ return _jsx(Icon, {});
12
+ }, [Icon]);
13
+ const content = useMemo(() => {
14
+ if (loading) {
15
+ return (_jsxs(_Fragment, { children: [_jsx("span", { className: 'span-loading' }), loadingLabel] }));
16
+ }
17
+ return (_jsxs(_Fragment, { children: [iconPosition === 'left' && newIcon, children, iconPosition === 'right' && newIcon] }));
18
+ }, [loading, loadingLabel, iconPosition, children, newIcon]);
19
+ return (_jsx("button", { ref: ref, className: cls('button', {
20
+ 'button-link': isLink,
21
+ 'button-outline': !isLink && outline,
22
+ [`button-color-${color}`]: !isLink && color,
23
+ [`button-size-${size}`]: size !== 'md',
24
+ 'button-loading': loading
25
+ }), ...safeProps, children: content }));
26
+ });
27
+ export default Button;
@@ -0,0 +1,2 @@
1
+ import Button from './button.component';
2
+ export { Button };
@@ -0,0 +1,2 @@
1
+ import Button from './button.component';
2
+ export { Button };
@@ -1 +1,2 @@
1
1
  export * from './avatar';
2
+ export * from './button';
@@ -1 +1,2 @@
1
1
  export * from './avatar';
2
+ export * from './button';
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { FaSortDown } from 'react-icons/fa';
4
4
  import { useOnClickOutside } from 'usehooks-ts';
5
- import { TextBox } from '../../../ui/forms';
5
+ import { TextBox } from '../text-box';
6
6
  const Dropdown = forwardRef(({ name, options = [], disabled, onChange, onTextChange, value, ...otherProps }, ref) => {
7
7
  const [label, setLabel] = useState('');
8
8
  const [open, setOpen] = useState(false);
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Radio } from '../../../ui/forms';
2
+ import { Radio } from '../radio';
3
3
  const RadioList = ({ name, options, isError, error, value, ...otherOptions }) => {
4
4
  if (!options || options.length === 0) {
5
5
  return;
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "framework design",
11
11
  "design system"
12
12
  ],
13
- "version": "0.3.0",
13
+ "version": "0.4.1",
14
14
  "homepage": "https://github.com/creativecodeco/ui",
15
15
  "author": {
16
16
  "name": "John Toro",
@@ -53,7 +53,7 @@
53
53
  "react": "18.2.0",
54
54
  "react-hook-form": "7.49.3",
55
55
  "tailwindcss": "3.4.1",
56
- "usehooks-ts": "2.9.2"
56
+ "usehooks-ts": "2.9.5"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@babel/core": "7.23.7",
@@ -61,33 +61,33 @@
61
61
  "@babel/preset-react": "7.23.3",
62
62
  "@babel/preset-typescript": "7.23.3",
63
63
  "@jest/globals": "29.7.0",
64
- "@storybook/addon-essentials": "7.6.7",
65
- "@storybook/addon-interactions": "7.6.7",
66
- "@storybook/addon-links": "7.6.7",
67
- "@storybook/addon-mdx-gfm": "7.6.7",
68
- "@storybook/blocks": "7.6.7",
69
- "@storybook/react": "7.6.7",
70
- "@storybook/react-webpack5": "7.6.7",
71
- "@storybook/test": "7.6.7",
64
+ "@storybook/addon-essentials": "7.6.10",
65
+ "@storybook/addon-interactions": "7.6.10",
66
+ "@storybook/addon-links": "7.6.10",
67
+ "@storybook/addon-mdx-gfm": "7.6.10",
68
+ "@storybook/blocks": "7.6.10",
69
+ "@storybook/react": "7.6.10",
70
+ "@storybook/react-webpack5": "7.6.10",
71
+ "@storybook/test": "7.6.10",
72
72
  "@testing-library/dom": "9.3.4",
73
- "@testing-library/jest-dom": "6.2.0",
73
+ "@testing-library/jest-dom": "6.2.1",
74
74
  "@testing-library/react": "14.1.2",
75
75
  "@testing-library/user-event": "14.5.2",
76
76
  "@types/jest": "29.5.11",
77
- "@types/node": "20.10.8",
78
- "@types/react": "18.2.47",
77
+ "@types/node": "20.11.5",
78
+ "@types/react": "18.2.48",
79
79
  "@types/react-dom": "18.2.18",
80
- "@typescript-eslint/eslint-plugin": "6.18.1",
81
- "autoprefixer": "10.4.16",
82
- "chromatic": "10.2.1",
80
+ "@typescript-eslint/eslint-plugin": "6.19.1",
81
+ "autoprefixer": "10.4.17",
82
+ "chromatic": "10.3.1",
83
83
  "classnames": "2.5.1",
84
84
  "cpx2": "7.0.1",
85
- "daisyui": "4.5.0",
85
+ "daisyui": "4.6.0",
86
86
  "eslint": "8.56.0",
87
87
  "eslint-config-prettier": "9.1.0",
88
88
  "eslint-config-standard": "17.1.0",
89
89
  "eslint-config-standard-react": "13.0.0",
90
- "eslint-config-standard-with-typescript": "43.0.0",
90
+ "eslint-config-standard-with-typescript": "43.0.1",
91
91
  "eslint-plugin-import": "2.29.1",
92
92
  "eslint-plugin-import-order": "2.1.4",
93
93
  "eslint-plugin-n": "16.6.2",
@@ -103,15 +103,15 @@
103
103
  "jest-environment-jsdom": "29.7.0",
104
104
  "jest-junit": "16.0.0",
105
105
  "jest-transform-css": "6.0.1",
106
- "postcss-cli": "^11.0.0",
107
- "prettier": "3.1.1",
106
+ "postcss-cli": "11.0.0",
107
+ "prettier": "3.2.4",
108
108
  "prop-types": "15.8.1",
109
109
  "react-dom": "18.2.0",
110
- "react-icons": "5.0.0",
111
- "storybook": "7.6.7",
110
+ "react-icons": "5.0.1",
111
+ "storybook": "7.6.10",
112
112
  "storybook-addon-themes": "6.1.0",
113
- "string-width": "7.0.0",
114
- "ts-jest": "29.1.1",
113
+ "string-width": "7.1.0",
114
+ "ts-jest": "29.1.2",
115
115
  "ts-node": "10.9.2",
116
116
  "tsc-alias": "1.8.8",
117
117
  "tsconfig-paths-webpack-plugin": "4.1.0",