@creativecodeco/ui 0.0.2 → 0.0.3
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/README.md +2 -0
- package/lib/theme/css/main.css +5 -0
- package/lib/theme/css/text-box.css +87 -0
- package/lib/theme/main.css +1313 -0
- package/lib/types/index.d.ts +2 -2
- package/lib/types/ui/forms/drop-down.types.d.ts +11 -0
- package/lib/types/ui/forms/drop-down.types.js +1 -0
- package/lib/types/ui/forms/index.d.ts +3 -2
- package/lib/types/ui/forms/text-box.types.d.ts +4 -0
- package/lib/ui/forms/drop-down/drop-down.component.d.ts +4 -0
- package/lib/ui/forms/drop-down/drop-down.component.js +43 -0
- package/lib/ui/forms/drop-down/index.d.ts +2 -0
- package/lib/ui/forms/drop-down/index.js +2 -0
- package/lib/ui/forms/index.d.ts +3 -2
- package/lib/ui/forms/index.js +3 -2
- package/lib/ui/forms/text-box/text-box.component.js +11 -4
- package/lib/ui/provider/creativecode/creativecode-ui.provider.d.ts +2 -0
- package/lib/ui/provider/creativecode/creativecode-ui.provider.js +9 -0
- package/lib/ui/provider/index.d.ts +1 -1
- package/lib/ui/provider/index.js +1 -1
- package/package.json +51 -36
- package/lib/theme/tailwindcss/input.css +0 -3
- package/lib/theme/tailwindcss/main.css +0 -5
- package/lib/ui/provider/creativecode-ui.provider.d.ts +0 -2
- package/lib/ui/provider/creativecode-ui.provider.js +0 -5
package/lib/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TextBoxType, TextBoxRef } from
|
|
2
|
-
export type { TextBoxType, TextBoxRef };
|
|
1
|
+
import { DropDownOption, DropDownType, TextBoxType, TextBoxRef } from './ui/forms';
|
|
2
|
+
export type { DropDownOption, DropDownType, TextBoxType, TextBoxRef };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextBoxType } from './text-box.types';
|
|
3
|
+
export interface DropDownOption {
|
|
4
|
+
value: string | number;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DropDownType extends TextBoxType {
|
|
8
|
+
options?: DropDownOption[];
|
|
9
|
+
onChange?: (option: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
|
+
onTextChange?: (text?: string) => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { DropDownOption, DropDownType } from './drop-down.types';
|
|
2
|
+
import { TextBoxType, TextBoxRef } from './text-box.types';
|
|
3
|
+
export type { DropDownOption, DropDownType, TextBoxType, TextBoxRef };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { IconType } from 'react-icons';
|
|
2
3
|
export interface TextBoxType extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
3
4
|
name: string;
|
|
4
5
|
label?: string;
|
|
@@ -6,5 +7,8 @@ export interface TextBoxType extends Omit<React.InputHTMLAttributes<HTMLInputEle
|
|
|
6
7
|
error?: string;
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
10
|
+
leftIcon?: IconType;
|
|
11
|
+
rightIcon?: IconType;
|
|
12
|
+
rightButton?: boolean;
|
|
9
13
|
}
|
|
10
14
|
export type TextBoxRef = HTMLInputElement;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { FaSortDown } from 'react-icons/fa';
|
|
4
|
+
import { useOnClickOutside } from 'usehooks-ts';
|
|
5
|
+
import { TextBox } from '../../../ui/forms';
|
|
6
|
+
const DropDown = forwardRef(({ name, options = [], disabled, onChange, onTextChange, ...otherProps }, ref) => {
|
|
7
|
+
const [label, setLabel] = useState('');
|
|
8
|
+
const [open, setOpen] = useState(false);
|
|
9
|
+
const [valueFilter, setValueFilter] = useState();
|
|
10
|
+
const refOutside = useRef(null);
|
|
11
|
+
const handleClickOutside = () => {
|
|
12
|
+
const option = options.find(({ label }) => String(label) === String(valueFilter));
|
|
13
|
+
if (!option) {
|
|
14
|
+
setLabel('');
|
|
15
|
+
onTextChange?.();
|
|
16
|
+
}
|
|
17
|
+
setOpen(false);
|
|
18
|
+
};
|
|
19
|
+
useOnClickOutside(refOutside, handleClickOutside);
|
|
20
|
+
const handleFocus = useCallback(() => {
|
|
21
|
+
if (disabled) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
setOpen(true);
|
|
25
|
+
}, [open, disabled]);
|
|
26
|
+
const handleSelect = useCallback((option) => {
|
|
27
|
+
onChange?.({
|
|
28
|
+
target: { value: String(option.value) }
|
|
29
|
+
});
|
|
30
|
+
setLabel(option.label);
|
|
31
|
+
setOpen(false);
|
|
32
|
+
}, [onChange]);
|
|
33
|
+
const handleChange = useCallback(({ target: { value } }) => {
|
|
34
|
+
onTextChange?.(value);
|
|
35
|
+
setValueFilter(value);
|
|
36
|
+
setLabel(value);
|
|
37
|
+
}, [onTextChange, setValueFilter]);
|
|
38
|
+
const filterOptions = useMemo(() => !valueFilter
|
|
39
|
+
? options
|
|
40
|
+
: options.filter(({ label }) => label.includes(valueFilter)), [valueFilter, options]);
|
|
41
|
+
return (_jsxs("div", { className: 'dropdown block', children: [_jsx(TextBox, { name: name, tabIndex: 0, ref: ref, disabled: disabled, rightButton: true, rightIcon: FaSortDown, value: label, onFocus: handleFocus, onChange: handleChange, ...otherProps }), open && (_jsx("ul", { tabIndex: 0, className: 'dropdown-content z-[1] menu w-full bg-base-100', id: `options-${name}`, ref: refOutside, role: 'listitem', "data-testid": `options-${name}`, children: filterOptions.map((option) => (_jsx("li", { value: option.value, onClick: () => handleSelect(option), children: _jsx("a", { children: option.label }) }, option.value))) }))] }));
|
|
42
|
+
});
|
|
43
|
+
export default DropDown;
|
package/lib/ui/forms/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { DropDown } from '../../ui/forms/drop-down';
|
|
2
|
+
import { TextBox } from '../../ui/forms/text-box';
|
|
3
|
+
export { DropDown, TextBox };
|
package/lib/ui/forms/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { DropDown } from '../../ui/forms/drop-down';
|
|
2
|
+
import { TextBox } from '../../ui/forms/text-box';
|
|
3
|
+
export { DropDown, TextBox };
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
3
3
|
import cls from 'classnames';
|
|
4
|
-
const TextBox = forwardRef(({ name, label, isError, error, disabled, size = 'md', ...otherProps }, ref) => {
|
|
4
|
+
const TextBox = forwardRef(({ name, label, isError, error, disabled, size = 'md', leftIcon: LeftIcon, rightIcon: RightIcon, rightButton, onClick, ...otherProps }, ref) => {
|
|
5
5
|
const inputRef = useRef(null);
|
|
6
6
|
useImperativeHandle(ref, () => inputRef.current);
|
|
7
|
-
return (_jsxs("div", { className: 'form-control w-full', children: [label && (_jsx("div", { className: 'label', children: _jsx("label", { htmlFor: name, className: 'label-text', children: label }) })),
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
return (_jsxs("div", { className: 'form-control w-full flex', children: [label && (_jsx("div", { className: 'label', children: _jsx("label", { htmlFor: name, className: 'label-text', children: label }) })), _jsxs("div", { className: 'relative', children: [LeftIcon && (_jsx(LeftIcon, { className: cls('text-box-left-icon', {
|
|
8
|
+
[`text-box-left-icon-size-${size}`]: size
|
|
9
|
+
}) })), _jsx("input", { ref: inputRef, id: name, name: name, "data-testid": name, ...otherProps, onClick: onClick, className: cls('input input-bordered w-full', `text-box-size-${size}`, {
|
|
10
|
+
'input-error': isError,
|
|
11
|
+
'text-box-with-left-icon': LeftIcon,
|
|
12
|
+
'text-box-with-right-icon': RightIcon
|
|
13
|
+
}), disabled: disabled }), RightIcon && (_jsx(RightIcon, { className: cls('text-box-right-icon', {
|
|
14
|
+
[`text-box-right-icon-size-${size}`]: size,
|
|
15
|
+
'cursor-pointer': rightButton
|
|
16
|
+
}), onClick: () => rightButton && inputRef.current?.click() }))] }), isError && _jsx("p", { className: 'text-red-500', children: error })] }));
|
|
10
17
|
});
|
|
11
18
|
export default TextBox;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, useEffect } from 'react';
|
|
3
|
+
export default function CreativeCodeUIProvider({ children }) {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const html = document.querySelector('html');
|
|
6
|
+
html?.setAttribute('data-theme', 'creativecode');
|
|
7
|
+
}, []);
|
|
8
|
+
return _jsx(Fragment, { children: children });
|
|
9
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import CreativeCodeUIProvider from './creativecode-ui.provider';
|
|
1
|
+
import CreativeCodeUIProvider from './creativecode/creativecode-ui.provider';
|
|
2
2
|
export { CreativeCodeUIProvider };
|
package/lib/ui/provider/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import CreativeCodeUIProvider from './creativecode-ui.provider';
|
|
1
|
+
import CreativeCodeUIProvider from './creativecode/creativecode-ui.provider';
|
|
2
2
|
export { CreativeCodeUIProvider };
|
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creativecodeco/ui",
|
|
3
3
|
"description": "CreativeCode.com.co UI",
|
|
4
|
-
"
|
|
4
|
+
"keywords": [
|
|
5
|
+
"CreativeCode.com.co",
|
|
6
|
+
"creativecodeco/ui",
|
|
7
|
+
"Tailwindcss",
|
|
8
|
+
"Daisyui",
|
|
9
|
+
"UI",
|
|
10
|
+
"Framework Design"
|
|
11
|
+
],
|
|
12
|
+
"version": "0.0.3",
|
|
5
13
|
"homepage": "https://github.com/creativecodeco/ui",
|
|
6
14
|
"author": {
|
|
7
15
|
"name": "John Toro",
|
|
@@ -11,53 +19,60 @@
|
|
|
11
19
|
"main": "lib/index.js",
|
|
12
20
|
"source": "src/index.ts",
|
|
13
21
|
"scripts": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"build:css": "postcss src/theme/main.css -o dist/theme/main.css --minify; cpx 'src/theme/*[.]css' 'lib/theme/tailwindcss'",
|
|
22
|
+
"dev": "npm run storybook",
|
|
23
|
+
"dev:css": "postcss src/theme/main.css -o lib/theme/main.css --watch",
|
|
17
24
|
"build": "rm -rf lib; tsc -p tsconfig.build.json; npm run build:alias; npm run build:css",
|
|
25
|
+
"build:alias": "tsc-alias -p tsconfig.build.json",
|
|
26
|
+
"build:css": "postcss src/theme/main.css -o lib/theme/main.css --minify; cpx 'src/theme/*[.]css' 'lib/theme/css'",
|
|
27
|
+
"build-storybook": "npm run build; storybook build",
|
|
18
28
|
"chromatic": "chromatic --only-changed true",
|
|
19
|
-
"
|
|
29
|
+
"lint": "npm run lint:eslint",
|
|
20
30
|
"lint:eslint": "eslint .",
|
|
21
31
|
"lint:fix": "npm run lint:eslint --fix --quiet",
|
|
22
|
-
"lint": "npm run lint:eslint",
|
|
23
32
|
"prepack": "npm run build",
|
|
24
33
|
"prepare": "husky install",
|
|
25
34
|
"release": "npm publish --access public",
|
|
26
35
|
"storybook": "storybook dev -p 6006",
|
|
36
|
+
"test": "jest .",
|
|
27
37
|
"test:action": "jest --coverage | tee ./coverage.txt && jest --ci --reporters=default --reporters=jest-junit",
|
|
28
38
|
"test:update": "jest --updateSnapshot",
|
|
29
|
-
"test:watch": "jest --watch"
|
|
30
|
-
"test": "jest ."
|
|
39
|
+
"test:watch": "jest --watch"
|
|
31
40
|
},
|
|
32
41
|
"peerDependencies": {
|
|
33
|
-
"
|
|
42
|
+
"postcss": "8.4.32",
|
|
43
|
+
"postcss-import": "15.1.0",
|
|
44
|
+
"react": "18.2.0",
|
|
45
|
+
"react-hook-form": "7.49.2",
|
|
46
|
+
"tailwindcss": "3.4.0"
|
|
34
47
|
},
|
|
35
48
|
"devDependencies": {
|
|
36
|
-
"@babel/core": "7.23.
|
|
37
|
-
"@babel/preset-
|
|
49
|
+
"@babel/core": "7.23.7",
|
|
50
|
+
"@babel/preset-env": "^7.23.7",
|
|
51
|
+
"@babel/preset-react": "^7.23.3",
|
|
52
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
38
53
|
"@jest/globals": "29.7.0",
|
|
39
|
-
"@storybook/addon-essentials": "7.6.
|
|
40
|
-
"@storybook/addon-interactions": "7.6.
|
|
41
|
-
"@storybook/addon-links": "7.6.
|
|
42
|
-
"@storybook/addon-
|
|
43
|
-
"@storybook/blocks": "7.6.
|
|
44
|
-
"@storybook/react": "7.6.
|
|
45
|
-
"@storybook/react-webpack5": "7.6.
|
|
46
|
-
"@storybook/test": "7.6.
|
|
54
|
+
"@storybook/addon-essentials": "7.6.7",
|
|
55
|
+
"@storybook/addon-interactions": "7.6.7",
|
|
56
|
+
"@storybook/addon-links": "7.6.7",
|
|
57
|
+
"@storybook/addon-mdx-gfm": "^7.6.7",
|
|
58
|
+
"@storybook/blocks": "7.6.7",
|
|
59
|
+
"@storybook/react": "7.6.7",
|
|
60
|
+
"@storybook/react-webpack5": "7.6.7",
|
|
61
|
+
"@storybook/test": "7.6.7",
|
|
47
62
|
"@testing-library/dom": "9.3.3",
|
|
48
|
-
"@testing-library/jest-dom": "
|
|
63
|
+
"@testing-library/jest-dom": "6.1.6",
|
|
49
64
|
"@testing-library/react": "14.1.2",
|
|
50
|
-
"@testing-library/user-event": "14.5.
|
|
65
|
+
"@testing-library/user-event": "14.5.2",
|
|
51
66
|
"@types/jest": "29.5.11",
|
|
52
|
-
"@types/node": "20.10.
|
|
53
|
-
"@types/react": "18.2.
|
|
67
|
+
"@types/node": "20.10.6",
|
|
68
|
+
"@types/react": "18.2.46",
|
|
54
69
|
"@types/react-dom": "18.2.18",
|
|
55
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "6.17.0",
|
|
56
71
|
"autoprefixer": "10.4.16",
|
|
57
|
-
"chromatic": "10.
|
|
58
|
-
"classnames": "2.
|
|
59
|
-
"cpx2": "
|
|
60
|
-
"daisyui": "4.4.
|
|
72
|
+
"chromatic": "10.2.0",
|
|
73
|
+
"classnames": "2.5.1",
|
|
74
|
+
"cpx2": "7.0.1",
|
|
75
|
+
"daisyui": "4.4.24",
|
|
61
76
|
"eslint": "8.56.0",
|
|
62
77
|
"eslint-config-prettier": "9.1.0",
|
|
63
78
|
"eslint-config-standard": "17.1.0",
|
|
@@ -65,9 +80,9 @@
|
|
|
65
80
|
"eslint-config-standard-with-typescript": "43.0.0",
|
|
66
81
|
"eslint-plugin-import": "2.29.1",
|
|
67
82
|
"eslint-plugin-import-order": "2.1.4",
|
|
68
|
-
"eslint-plugin-n": "16.
|
|
83
|
+
"eslint-plugin-n": "16.6.1",
|
|
69
84
|
"eslint-plugin-node": "11.1.0",
|
|
70
|
-
"eslint-plugin-prettier": "5.1.
|
|
85
|
+
"eslint-plugin-prettier": "5.1.2",
|
|
71
86
|
"eslint-plugin-promise": "6.1.1",
|
|
72
87
|
"eslint-plugin-react": "7.33.2",
|
|
73
88
|
"eslint-plugin-standard": "5.0.0",
|
|
@@ -85,7 +100,9 @@
|
|
|
85
100
|
"prop-types": "15.8.1",
|
|
86
101
|
"react": "18.2.0",
|
|
87
102
|
"react-dom": "18.2.0",
|
|
88
|
-
"
|
|
103
|
+
"react-hook-form": "7.49.2",
|
|
104
|
+
"react-icons": "4.12.0",
|
|
105
|
+
"storybook": "7.6.7",
|
|
89
106
|
"storybook-addon-themes": "6.1.0",
|
|
90
107
|
"string-width": "7.0.0",
|
|
91
108
|
"tailwindcss": "3.4.0",
|
|
@@ -93,12 +110,10 @@
|
|
|
93
110
|
"ts-node": "10.9.2",
|
|
94
111
|
"tsc-alias": "1.8.8",
|
|
95
112
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
96
|
-
"typescript": "5.3.3"
|
|
113
|
+
"typescript": "5.3.3",
|
|
114
|
+
"usehooks-ts": "^2.9.1"
|
|
97
115
|
},
|
|
98
116
|
"files": [
|
|
99
117
|
"lib"
|
|
100
|
-
]
|
|
101
|
-
"dependencies": {
|
|
102
|
-
"react-hook-form": "7.49.2"
|
|
103
|
-
}
|
|
118
|
+
]
|
|
104
119
|
}
|