@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.
- package/lib/hooks/index.d.ts +2 -0
- package/lib/hooks/index.js +2 -0
- package/lib/hooks/use-safe-button-props.hook.d.ts +285 -0
- package/lib/hooks/use-safe-button-props.hook.js +17 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/theme/css/button.css +69 -0
- package/lib/theme/css/main.css +2 -0
- package/lib/theme/css/span.css +5 -0
- package/lib/theme/main.css +1426 -159
- package/lib/types/index.d.ts +3 -3
- package/lib/types/index.js +1 -3
- package/lib/types/ui/base/constants.types.d.ts +1 -0
- package/lib/types/ui/base/dom.types.d.ts +3 -0
- package/lib/types/ui/base/dom.types.js +1 -0
- package/lib/types/ui/base/index.d.ts +1 -0
- package/lib/types/ui/components/button.types.d.ts +15 -0
- package/lib/types/ui/components/button.types.js +1 -0
- package/lib/types/ui/components/index.d.ts +2 -2
- package/lib/types/ui/forms/radio.types.d.ts +0 -1
- package/lib/ui/components/button/button.component.d.ts +4 -0
- package/lib/ui/components/button/button.component.js +27 -0
- package/lib/ui/components/button/index.d.ts +2 -0
- package/lib/ui/components/button/index.js +2 -0
- package/lib/ui/components/index.d.ts +1 -0
- package/lib/ui/components/index.js +1 -0
- package/lib/ui/forms/dropdown/dropdown.component.js +1 -1
- package/lib/ui/forms/radio-list/radio-list.component.js +1 -1
- package/package.json +24 -24
package/lib/types/index.d.ts
CHANGED
|
@@ -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';
|
package/lib/types/index.js
CHANGED
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
-
|
|
2
|
-
export type
|
|
1
|
+
export type * from './avatar.types';
|
|
2
|
+
export type * from './button.types';
|
|
@@ -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;
|
|
@@ -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 '
|
|
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 '
|
|
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.
|
|
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.
|
|
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.
|
|
65
|
-
"@storybook/addon-interactions": "7.6.
|
|
66
|
-
"@storybook/addon-links": "7.6.
|
|
67
|
-
"@storybook/addon-mdx-gfm": "7.6.
|
|
68
|
-
"@storybook/blocks": "7.6.
|
|
69
|
-
"@storybook/react": "7.6.
|
|
70
|
-
"@storybook/react-webpack5": "7.6.
|
|
71
|
-
"@storybook/test": "7.6.
|
|
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.
|
|
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.
|
|
78
|
-
"@types/react": "18.2.
|
|
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.
|
|
81
|
-
"autoprefixer": "10.4.
|
|
82
|
-
"chromatic": "10.
|
|
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.
|
|
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.
|
|
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": "
|
|
107
|
-
"prettier": "3.
|
|
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.
|
|
111
|
-
"storybook": "7.6.
|
|
110
|
+
"react-icons": "5.0.1",
|
|
111
|
+
"storybook": "7.6.10",
|
|
112
112
|
"storybook-addon-themes": "6.1.0",
|
|
113
|
-
"string-width": "7.
|
|
114
|
-
"ts-jest": "29.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",
|