@creativecodeco/ui 0.6.2 → 1.0.0

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.
Files changed (71) hide show
  1. package/README.md +13 -19
  2. package/lib/helpers/index.js +8 -2
  3. package/lib/helpers/react-hook-form/controller.component.js +7 -4
  4. package/lib/helpers/react-hook-form/index.js +7 -2
  5. package/lib/hooks/index.js +8 -2
  6. package/lib/hooks/use-safe-button-props.hook.d.ts +98 -97
  7. package/lib/hooks/use-safe-button-props.hook.js +17 -8
  8. package/lib/index.js +23 -7
  9. package/lib/theme/css/accordion.css +5 -7
  10. package/lib/theme/css/avatar.css +19 -21
  11. package/lib/theme/css/badge.css +38 -44
  12. package/lib/theme/css/button.css +49 -53
  13. package/lib/theme/css/checkbox.css +31 -35
  14. package/lib/theme/css/main.css +3 -4
  15. package/lib/theme/css/radio.css +31 -35
  16. package/lib/theme/css/span.css +2 -4
  17. package/lib/theme/css/textbox.css +115 -0
  18. package/lib/theme/index.js +10 -6
  19. package/lib/theme/main.css +2669 -4112
  20. package/lib/types/helpers/controller.types.js +2 -1
  21. package/lib/types/index.js +2 -1
  22. package/lib/types/ui/base/constants.types.js +2 -1
  23. package/lib/types/ui/base/dom.types.js +2 -1
  24. package/lib/types/ui/base/error.types.js +2 -1
  25. package/lib/types/ui/base/index.js +2 -1
  26. package/lib/types/ui/components/accordion.types.js +2 -1
  27. package/lib/types/ui/components/avatar.types.js +2 -1
  28. package/lib/types/ui/components/badge.types.js +2 -1
  29. package/lib/types/ui/components/button.types.js +2 -1
  30. package/lib/types/ui/components/index.js +2 -1
  31. package/lib/types/ui/forms/checkbox.types.js +2 -1
  32. package/lib/types/ui/forms/dropdown.types.d.ts +1 -1
  33. package/lib/types/ui/forms/dropdown.types.js +2 -1
  34. package/lib/types/ui/forms/index.d.ts +1 -1
  35. package/lib/types/ui/forms/index.js +2 -1
  36. package/lib/types/ui/forms/radio.types.js +2 -1
  37. package/lib/types/ui/forms/textbox.types.js +2 -0
  38. package/lib/ui/components/accordion/accordion.component.js +11 -6
  39. package/lib/ui/components/accordion/index.js +8 -2
  40. package/lib/ui/components/avatar/avatar.component.js +18 -13
  41. package/lib/ui/components/avatar/index.js +8 -2
  42. package/lib/ui/components/badge/badge.component.js +12 -7
  43. package/lib/ui/components/badge/index.js +8 -2
  44. package/lib/ui/components/button/button.component.js +18 -13
  45. package/lib/ui/components/button/index.js +8 -2
  46. package/lib/ui/components/index.js +20 -4
  47. package/lib/ui/forms/checkbox/checkbox.component.js +15 -10
  48. package/lib/ui/forms/checkbox/index.js +8 -2
  49. package/lib/ui/forms/dropdown/dropdown.component.js +20 -18
  50. package/lib/ui/forms/dropdown/index.js +8 -2
  51. package/lib/ui/forms/index.d.ts +1 -1
  52. package/lib/ui/forms/index.js +21 -5
  53. package/lib/ui/forms/radio/index.js +8 -2
  54. package/lib/ui/forms/radio/radio.component.js +15 -10
  55. package/lib/ui/forms/radio-list/index.js +8 -2
  56. package/lib/ui/forms/radio-list/radio-list.component.js +6 -4
  57. package/lib/ui/forms/textbox/index.d.ts +2 -0
  58. package/lib/ui/forms/textbox/index.js +8 -0
  59. package/lib/ui/forms/textbox/textbox.component.js +26 -0
  60. package/lib/ui/provider/creativecode/creativecode-ui.provider.js +8 -5
  61. package/lib/ui/provider/index.js +8 -2
  62. package/lib/utils/index.js +17 -1
  63. package/lib/utils/string.utils.js +7 -3
  64. package/package.json +54 -61
  65. package/lib/theme/css/text-box.css +0 -113
  66. package/lib/types/ui/forms/text-box.types.js +0 -1
  67. package/lib/ui/forms/text-box/index.d.ts +0 -2
  68. package/lib/ui/forms/text-box/index.js +0 -2
  69. package/lib/ui/forms/text-box/text-box.component.js +0 -21
  70. /package/lib/types/ui/forms/{text-box.types.d.ts → textbox.types.d.ts} +0 -0
  71. /package/lib/ui/forms/{text-box/text-box.component.d.ts → textbox/textbox.component.d.ts} +0 -0
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { TextBoxType } from './text-box.types';
1
+ import { TextBoxType } from './textbox.types';
2
2
  export interface DropdownOption {
3
3
  value: string | number;
4
4
  label: string;
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
1
  export type * from './checkbox.types';
2
2
  export type * from './dropdown.types';
3
3
  export type * from './radio.types';
4
- export type * from './text-box.types';
4
+ export type * from './textbox.types';
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +1,17 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import cls from 'classnames';
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 jsx_runtime_1 = require("react/jsx-runtime");
7
+ const classnames_1 = __importDefault(require("classnames"));
3
8
  const Accordion = ({ name, join, options, iconType = 'arrow', multiple }) => {
4
- return (_jsx("div", { className: cls('flex flex-wrap', {
9
+ return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('flex flex-wrap', {
5
10
  'join join-vertical w-full': join,
6
11
  'gap-2': !join
7
- }), children: options.map(({ header, body }, index) => (_jsxs("div", { className: cls('collapse bg-base-200', {
12
+ }), children: options.map(({ header, body }, index) => ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('collapse bg-base-200', {
8
13
  [`accordion-type-${iconType}`]: iconType,
9
14
  'join-item border border-base-300': join
10
- }), children: [_jsx("input", { type: multiple ? 'checkbox' : 'radio', name: name }), _jsx("div", { className: 'collapse-title text-xl font-medium', children: header }), _jsx("div", { className: 'collapse-content', children: body })] }, index))) }));
15
+ }), children: [(0, jsx_runtime_1.jsx)("input", { type: multiple ? 'checkbox' : 'radio', name: name }), (0, jsx_runtime_1.jsx)("div", { className: 'collapse-title text-xl font-medium', children: header }), (0, jsx_runtime_1.jsx)("div", { className: 'collapse-content', children: body })] }, index))) }));
11
16
  };
12
- export default Accordion;
17
+ exports.default = Accordion;
@@ -1,2 +1,8 @@
1
- import Accordion from './accordion.component';
2
- export { Accordion };
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
+ exports.Accordion = void 0;
7
+ const accordion_component_1 = __importDefault(require("./accordion.component"));
8
+ exports.Accordion = accordion_component_1.default;
@@ -1,20 +1,25 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import cls from 'classnames';
4
- import { getInitials, isValidUrl } from '../../../utils';
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 jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const classnames_1 = __importDefault(require("classnames"));
9
+ const utils_1 = require("../../../utils");
5
10
  const Avatar = ({ isOnline = false, ring = false, rounded = false, size = 'md', src, withStatus = false }) => {
6
- const isUri = useMemo(() => isValidUrl(src), [src]);
7
- const letters = useMemo(() => getInitials(src), [src, isUri]);
8
- return (_jsx("div", { "data-testid": 'avatar', className: cls('avatar', {
9
- online: withStatus && isOnline,
10
- offline: withStatus && !isOnline,
11
- placeholder: !isUri
12
- }), children: _jsxs("div", { "data-testid": 'avatar-content', className: cls('text-neutral-content', {
11
+ const isUri = (0, react_1.useMemo)(() => (0, utils_1.isValidUrl)(src), [src]);
12
+ const letters = (0, react_1.useMemo)(() => (0, utils_1.getInitials)(src), [src, isUri]);
13
+ return ((0, jsx_runtime_1.jsx)("div", { "data-testid": 'avatar', className: (0, classnames_1.default)('avatar', {
14
+ 'avatar-online': withStatus && isOnline,
15
+ 'avatar-offline': withStatus && !isOnline,
16
+ 'avatar-placeholder': !isUri
17
+ }), children: (0, jsx_runtime_1.jsxs)("div", { "data-testid": 'avatar-content', className: (0, classnames_1.default)('text-neutral-content', {
13
18
  'bg-neutral': !isUri,
14
19
  [`avatar-size-${size}`]: size,
15
20
  'rounded-full': rounded,
16
21
  rounded: !rounded,
17
22
  'avatar-ring': ring
18
- }), children: [!isUri && _jsx("span", { children: letters }), isUri && _jsx("img", { src: src, alt: 'Avatar' })] }) }));
23
+ }), children: [!isUri && (0, jsx_runtime_1.jsx)("span", { children: letters }), isUri && (0, jsx_runtime_1.jsx)("img", { src: src, alt: 'Avatar' })] }) }));
19
24
  };
20
- export default Avatar;
25
+ exports.default = Avatar;
@@ -1,2 +1,8 @@
1
- import Avatar from './avatar.component';
2
- export { Avatar };
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
+ exports.Avatar = void 0;
7
+ const avatar_component_1 = __importDefault(require("./avatar.component"));
8
+ exports.Avatar = avatar_component_1.default;
@@ -1,14 +1,19 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import cls from 'classnames';
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 jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const classnames_1 = __importDefault(require("classnames"));
4
9
  const Badge = ({ children, color, icon: Icon, iconPosition = 'left', outline, size = 'md' }) => {
5
- const newIcon = useMemo(() => {
10
+ const newIcon = (0, react_1.useMemo)(() => {
6
11
  if (!Icon) {
7
12
  return;
8
13
  }
9
- return _jsx(Icon, {});
14
+ return (0, jsx_runtime_1.jsx)(Icon, {});
10
15
  }, [Icon]);
11
- return (_jsxs("div", { className: cls('badge', {
16
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('badge', {
12
17
  [`badge-color-${color}`]: !outline && color,
13
18
  [`badge-${color}`]: outline && color,
14
19
  'badge-outline': outline,
@@ -16,4 +21,4 @@ const Badge = ({ children, color, icon: Icon, iconPosition = 'left', outline, si
16
21
  'gap-2': Icon
17
22
  }), children: [iconPosition === 'left' && newIcon, children, iconPosition === 'right' && newIcon] }));
18
23
  };
19
- export default Badge;
24
+ exports.default = Badge;
@@ -1,2 +1,8 @@
1
- import Badge from './badge.component';
2
- export { Badge };
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
+ exports.Badge = void 0;
7
+ const badge_component_1 = __importDefault(require("./badge.component"));
8
+ exports.Badge = badge_component_1.default;
@@ -1,22 +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(() => {
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 jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const classnames_1 = __importDefault(require("classnames"));
9
+ const hooks_1 = require("../../../hooks");
10
+ const Button = (0, react_1.forwardRef)(({ children, isLink, color, outline, size = 'md', icon: Icon, iconPosition = 'left', loading, loadingLabel, ...otherProps }, ref) => {
11
+ const safeProps = (0, hooks_1.useSafeButtonProps)({ loading, ...otherProps });
12
+ const newIcon = (0, react_1.useMemo)(() => {
8
13
  if (!Icon) {
9
14
  return;
10
15
  }
11
- return _jsx(Icon, {});
16
+ return (0, jsx_runtime_1.jsx)(Icon, {});
12
17
  }, [Icon]);
13
- const content = useMemo(() => {
18
+ const content = (0, react_1.useMemo)(() => {
14
19
  if (loading) {
15
- return (_jsxs(_Fragment, { children: [_jsx("span", { className: 'span-loading' }), loadingLabel] }));
20
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: 'span-loading' }), loadingLabel] }));
16
21
  }
17
- return (_jsxs(_Fragment, { children: [iconPosition === 'left' && newIcon, children, iconPosition === 'right' && newIcon] }));
22
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [iconPosition === 'left' && newIcon, children, iconPosition === 'right' && newIcon] }));
18
23
  }, [loading, loadingLabel, iconPosition, children, newIcon]);
19
- return (_jsx("button", { ref: ref, className: cls('btn', {
24
+ return ((0, jsx_runtime_1.jsx)("button", { ref: ref, className: (0, classnames_1.default)('btn', {
20
25
  'button-link': isLink,
21
26
  'btn-outline': !isLink && outline,
22
27
  [`btn-${color}`]: outline && color,
@@ -25,4 +30,4 @@ const Button = forwardRef(({ children, isLink, color, outline, size = 'md', icon
25
30
  'button-loading': loading
26
31
  }), ...safeProps, children: content }));
27
32
  });
28
- export default Button;
33
+ exports.default = Button;
@@ -1,2 +1,8 @@
1
- import Button from './button.component';
2
- export { Button };
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
+ exports.Button = void 0;
7
+ const button_component_1 = __importDefault(require("./button.component"));
8
+ exports.Button = button_component_1.default;
@@ -1,4 +1,20 @@
1
- export * from './accordion';
2
- export * from './avatar';
3
- export * from './badge';
4
- export * from './button';
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
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./accordion"), exports);
18
+ __exportStar(require("./avatar"), exports);
19
+ __exportStar(require("./badge"), exports);
20
+ __exportStar(require("./button"), exports);
@@ -1,7 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { forwardRef } from 'react';
3
- import cls from 'classnames';
4
- const Checkbox = forwardRef(({ name, label, isError, disabled, error, position = 'left', color, size = 'md', checked, value, onChange, ...otherProps }, ref) => {
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 jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const classnames_1 = __importDefault(require("classnames"));
9
+ const Checkbox = (0, react_1.forwardRef)(({ name, label, isError, disabled, error, position = 'left', color, size = 'md', checked, value, onChange, ...otherProps }, ref) => {
5
10
  const handleChange = (e) => {
6
11
  onChange?.({
7
12
  isChecked: e.target.checked,
@@ -9,13 +14,13 @@ const Checkbox = forwardRef(({ name, label, isError, disabled, error, position =
9
14
  label
10
15
  });
11
16
  };
12
- const checkbox = () => (_jsx("input", { id: name, name: name, "data-testid": name, ref: ref, type: 'checkbox', className: cls('checkbox', {
17
+ const checkbox = () => ((0, jsx_runtime_1.jsx)("input", { id: name, name: name, "data-testid": name, ref: ref, type: 'checkbox', className: (0, classnames_1.default)('checkbox', {
13
18
  [`checkbox-color-${color}`]: color,
14
19
  [`checkbox-size-${size}`]: size
15
20
  }), disabled: disabled, checked: checked, onChange: handleChange, ...otherProps }));
16
- return (_jsxs(_Fragment, { children: [_jsxs("label", { className: cls('label', {
17
- 'cursor-pointer': !disabled,
18
- 'cursor-not-allowed': disabled
19
- }), children: [position === 'left' && checkbox(), label && _jsx("span", { className: 'label-text', children: label }), position === 'right' && checkbox()] }), isError && _jsx("p", { className: 'text-red-500', children: error })] }));
21
+ return ((0, jsx_runtime_1.jsx)("div", { className: 'form-control', children: (0, jsx_runtime_1.jsxs)("label", { className: (0, classnames_1.default)('label', {
22
+ 'cursor-pointer': !disabled,
23
+ 'cursor-not-allowed': disabled
24
+ }), htmlFor: name, children: [position === 'left' && checkbox(), label && (0, jsx_runtime_1.jsx)("span", { className: 'label-text', children: label }), position === 'right' && checkbox(), isError && (0, jsx_runtime_1.jsx)("p", { className: 'text-red-500', children: error })] }) }));
20
25
  });
21
- export default Checkbox;
26
+ exports.default = Checkbox;
@@ -1,2 +1,8 @@
1
- import Checkbox from './checkbox.component';
2
- export { Checkbox };
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
+ exports.Checkbox = void 0;
7
+ const checkbox_component_1 = __importDefault(require("./checkbox.component"));
8
+ exports.Checkbox = checkbox_component_1.default;
@@ -1,13 +1,15 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
- import { FaSortDown } from 'react-icons/fa';
4
- import { useOnClickOutside } from 'usehooks-ts';
5
- import { TextBox } from '../text-box';
6
- const Dropdown = forwardRef(({ name, options = [], disabled, onChange, onTextChange, value, ...otherProps }, ref) => {
7
- const [label, setLabel] = useState('');
8
- const [open, setOpen] = useState(false);
9
- const [valueFilter, setValueFilter] = useState();
10
- const refOutside = useRef(null);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const react_1 = require("react");
5
+ const fa_1 = require("react-icons/fa");
6
+ const usehooks_ts_1 = require("usehooks-ts");
7
+ const textbox_1 = require("../textbox");
8
+ const Dropdown = (0, react_1.forwardRef)(({ name, options = [], disabled, onChange, onTextChange, value, ...otherProps }, ref) => {
9
+ const [label, setLabel] = (0, react_1.useState)('');
10
+ const [open, setOpen] = (0, react_1.useState)(false);
11
+ const [valueFilter, setValueFilter] = (0, react_1.useState)();
12
+ const refOutside = (0, react_1.useRef)(null);
11
13
  const handleClickOutside = () => {
12
14
  const option = options.find(({ label }) => String(label) === String(valueFilter));
13
15
  if (!option) {
@@ -16,8 +18,8 @@ const Dropdown = forwardRef(({ name, options = [], disabled, onChange, onTextCha
16
18
  }
17
19
  setOpen(false);
18
20
  };
19
- useOnClickOutside(refOutside, handleClickOutside);
20
- useEffect(() => {
21
+ (0, usehooks_ts_1.useOnClickOutside)(refOutside, handleClickOutside);
22
+ (0, react_1.useEffect)(() => {
21
23
  const option = options.find((option) => String(option.value) === String(value));
22
24
  if (!option) {
23
25
  setLabel('');
@@ -27,27 +29,27 @@ const Dropdown = forwardRef(({ name, options = [], disabled, onChange, onTextCha
27
29
  setLabel(option.label);
28
30
  setValueFilter(option.label);
29
31
  }, [value]);
30
- const handleFocus = useCallback(() => {
32
+ const handleFocus = (0, react_1.useCallback)(() => {
31
33
  if (disabled) {
32
34
  return;
33
35
  }
34
36
  setOpen(true);
35
37
  }, [open, disabled]);
36
- const handleSelect = useCallback((option) => {
38
+ const handleSelect = (0, react_1.useCallback)((option) => {
37
39
  onChange?.({
38
40
  target: { value: String(option.value) }
39
41
  });
40
42
  setLabel(option.label);
41
43
  setOpen(false);
42
44
  }, [onChange]);
43
- const handleChange = useCallback(({ target: { value } }) => {
45
+ const handleChange = (0, react_1.useCallback)(({ target: { value } }) => {
44
46
  onTextChange?.(value);
45
47
  setValueFilter(value);
46
48
  setLabel(value);
47
49
  }, [onTextChange, setValueFilter]);
48
- const filterOptions = useMemo(() => !valueFilter
50
+ const filterOptions = (0, react_1.useMemo)(() => !valueFilter
49
51
  ? options
50
52
  : options.filter(({ label }) => label.includes(valueFilter)), [valueFilter, options]);
51
- return (_jsxs("div", { className: 'dropdown block', children: [_jsx(TextBox, { name: name, tabIndex: 0, ref: ref, disabled: disabled, rightButton: true, rightIcon: FaSortDown, onFocus: handleFocus, onChange: handleChange, ...otherProps, value: label }), 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))) }))] }));
53
+ return ((0, jsx_runtime_1.jsxs)("div", { className: 'dropdown block', children: [(0, jsx_runtime_1.jsx)(textbox_1.TextBox, { name: name, tabIndex: 0, ref: ref, disabled: disabled, rightButton: true, rightIcon: fa_1.FaSortDown, onFocus: handleFocus, onChange: handleChange, ...otherProps, value: label }), open && ((0, jsx_runtime_1.jsx)("ul", { tabIndex: 0, className: 'dropdown-content z-1 menu w-full bg-base-100 shadow rounded-box', id: `options-${name}`, ref: refOutside, role: 'listitem', "data-testid": `options-${name}`, children: filterOptions.map((option) => ((0, jsx_runtime_1.jsx)("li", { value: option.value, onClick: () => handleSelect(option), children: (0, jsx_runtime_1.jsx)("a", { children: option.label }) }, option.value))) }))] }));
52
54
  });
53
- export default Dropdown;
55
+ exports.default = Dropdown;
@@ -1,2 +1,8 @@
1
- import Dropdown from './dropdown.component';
2
- export { Dropdown };
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
+ exports.Dropdown = void 0;
7
+ const dropdown_component_1 = __importDefault(require("./dropdown.component"));
8
+ exports.Dropdown = dropdown_component_1.default;
@@ -2,4 +2,4 @@ export * from '../../ui/forms/checkbox';
2
2
  export * from '../../ui/forms/dropdown';
3
3
  export * from '../../ui/forms/radio';
4
4
  export * from '../../ui/forms/radio-list';
5
- export * from '../../ui/forms/text-box';
5
+ export * from '../../ui/forms/textbox';
@@ -1,5 +1,21 @@
1
- export * from '../../ui/forms/checkbox';
2
- export * from '../../ui/forms/dropdown';
3
- export * from '../../ui/forms/radio';
4
- export * from '../../ui/forms/radio-list';
5
- export * from '../../ui/forms/text-box';
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
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("../../ui/forms/checkbox"), exports);
18
+ __exportStar(require("../../ui/forms/dropdown"), exports);
19
+ __exportStar(require("../../ui/forms/radio"), exports);
20
+ __exportStar(require("../../ui/forms/radio-list"), exports);
21
+ __exportStar(require("../../ui/forms/textbox"), exports);
@@ -1,2 +1,8 @@
1
- import Radio from './radio.component';
2
- export { Radio };
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
+ exports.Radio = void 0;
7
+ const radio_component_1 = __importDefault(require("./radio.component"));
8
+ exports.Radio = radio_component_1.default;
@@ -1,7 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { forwardRef } from 'react';
3
- import cls from 'classnames';
4
- const Radio = forwardRef(({ name, label, isError, disabled, error, position = 'left', color, size = 'md', checked, value, onChange, ...otherProps }, ref) => {
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 jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const classnames_1 = __importDefault(require("classnames"));
9
+ const Radio = (0, react_1.forwardRef)(({ name, label, isError, disabled, error, position = 'left', color, size = 'md', checked, value, onChange, ...otherProps }, ref) => {
5
10
  const handleChange = (e) => {
6
11
  onChange?.({
7
12
  isChecked: e.target.checked,
@@ -9,13 +14,13 @@ const Radio = forwardRef(({ name, label, isError, disabled, error, position = 'l
9
14
  label
10
15
  });
11
16
  };
12
- const radio = () => (_jsx("input", { ref: ref, id: name, name: name, "data-testid": name, type: 'radio', className: cls('radio', {
17
+ const radio = () => ((0, jsx_runtime_1.jsx)("input", { ref: ref, id: name, name: name, "data-testid": name, type: 'radio', className: (0, classnames_1.default)('radio', {
13
18
  [`radio-color-${color}`]: color,
14
19
  [`radio-size-${size}`]: size
15
20
  }), disabled: disabled, checked: checked, onChange: handleChange, ...otherProps }));
16
- return (_jsxs(_Fragment, { children: [_jsxs("label", { className: cls('label justify-start gap-3', {
17
- 'cursor-pointer': !disabled,
18
- 'cursor-not-allowed': disabled
19
- }), children: [position === 'left' && radio(), label && _jsx("span", { className: 'label-text', children: label }), position === 'right' && radio()] }), isError && _jsx("p", { className: 'text-red-500', children: error })] }));
21
+ return ((0, jsx_runtime_1.jsx)("div", { className: 'form-control', children: (0, jsx_runtime_1.jsxs)("label", { className: (0, classnames_1.default)('label justify-start gap-3', {
22
+ 'cursor-pointer': !disabled,
23
+ 'cursor-not-allowed': disabled
24
+ }), htmlFor: name, children: [position === 'left' && radio(), label && (0, jsx_runtime_1.jsx)("span", { className: 'label-text', children: label }), position === 'right' && radio(), isError && (0, jsx_runtime_1.jsx)("p", { className: 'text-red-500', children: error })] }) }));
20
25
  });
21
- export default Radio;
26
+ exports.default = Radio;
@@ -1,2 +1,8 @@
1
- import RadioList from './radio-list.component';
2
- export { RadioList };
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
+ exports.RadioList = void 0;
7
+ const radio_list_component_1 = __importDefault(require("./radio-list.component"));
8
+ exports.RadioList = radio_list_component_1.default;
@@ -1,9 +1,11 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Radio } from '../radio';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const radio_1 = require("../radio");
3
5
  const RadioList = ({ name, options, isError, error, value, ...otherOptions }) => {
4
6
  if (!options || options.length === 0) {
5
7
  return;
6
8
  }
7
- return (_jsxs("div", { className: 'form-control', children: [options.map((option) => (_jsx(Radio, { name: name, ...option, ...otherOptions, checked: String(option.value) === String(value) }, option.value))), isError && _jsx("p", { className: 'text-red-500', children: error })] }));
9
+ return ((0, jsx_runtime_1.jsxs)("div", { className: 'form-control', children: [options.map((option) => ((0, jsx_runtime_1.jsx)(radio_1.Radio, { name: name, ...option, ...otherOptions, checked: String(option.value) === String(value) }, option.value))), isError && (0, jsx_runtime_1.jsx)("p", { className: 'text-red-500', children: error })] }));
8
10
  };
9
- export default RadioList;
11
+ exports.default = RadioList;
@@ -0,0 +1,2 @@
1
+ import TextBox from './textbox.component';
2
+ export { TextBox };
@@ -0,0 +1,8 @@
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
+ exports.TextBox = void 0;
7
+ const textbox_component_1 = __importDefault(require("./textbox.component"));
8
+ exports.TextBox = textbox_component_1.default;