@creativecodeco/ui 0.2.0 → 0.3.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.
package/lib/index.d.ts CHANGED
@@ -3,5 +3,5 @@ export * from './theme';
3
3
  export * from './ui/components';
4
4
  export * from './ui/forms';
5
5
  export * from './ui/provider';
6
- export * from './types';
6
+ export type * from './types';
7
7
  export * from './utils';
package/lib/index.js CHANGED
@@ -3,5 +3,4 @@ export * from './theme';
3
3
  export * from './ui/components';
4
4
  export * from './ui/forms';
5
5
  export * from './ui/provider';
6
- export * from './types';
7
6
  export * from './utils';
@@ -4,4 +4,5 @@
4
4
 
5
5
  @import './avatar.css';
6
6
  @import './checkbox.css';
7
+ @import './radio.css';
7
8
  @import './text-box.css';
@@ -0,0 +1,47 @@
1
+ .radio-color {
2
+ &-primary {
3
+ @apply radio-primary;
4
+ }
5
+
6
+ &-secondary {
7
+ @apply radio-secondary;
8
+ }
9
+
10
+ &-accent {
11
+ @apply radio-accent;
12
+ }
13
+
14
+ &-success {
15
+ @apply radio-success;
16
+ }
17
+
18
+ &-warning {
19
+ @apply radio-warning;
20
+ }
21
+
22
+ &-info {
23
+ @apply radio-info;
24
+ }
25
+
26
+ &-error {
27
+ @apply radio-error;
28
+ }
29
+ }
30
+
31
+ .radio-size {
32
+ &-xs {
33
+ @apply radio-xs;
34
+ }
35
+
36
+ &-sm {
37
+ @apply radio-sm;
38
+ }
39
+
40
+ &-md {
41
+ @apply radio-md;
42
+ }
43
+
44
+ &-lg {
45
+ @apply radio-lg;
46
+ }
47
+ }
@@ -658,6 +658,11 @@ html {
658
658
  color: var(--fallback-nc,oklch(var(--nc)/var(--tw-text-opacity)));
659
659
  }
660
660
 
661
+ .radio-primary:hover {
662
+ --tw-border-opacity: 1;
663
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
664
+ }
665
+
661
666
  .table tr.hover:hover,
662
667
  .table tr.hover:nth-child(even):hover {
663
668
  --tw-bg-opacity: 1;
@@ -1329,6 +1334,23 @@ html {
1329
1334
  box-shadow: 0 0 0 4px var(--fallback-b1,oklch(var(--b1)/1)) inset,
1330
1335
  0 0 0 4px var(--fallback-b1,oklch(var(--b1)/1)) inset;
1331
1336
  }
1337
+ .radio-primary {
1338
+ --chkbg: var(--p);
1339
+ --tw-border-opacity: 1;
1340
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1341
+ }
1342
+ .radio-primary:focus-visible {
1343
+ outline-color: var(--fallback-p,oklch(var(--p)/1));
1344
+ }
1345
+ .radio-primary:checked,
1346
+ .radio-primary[aria-checked="true"] {
1347
+ --tw-border-opacity: 1;
1348
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1349
+ --tw-bg-opacity: 1;
1350
+ background-color: var(--fallback-p,oklch(var(--p)/var(--tw-bg-opacity)));
1351
+ --tw-text-opacity: 1;
1352
+ color: var(--fallback-pc,oklch(var(--pc)/var(--tw-text-opacity)));
1353
+ }
1332
1354
  .radio:disabled {
1333
1355
  cursor: not-allowed;
1334
1356
  opacity: 0.2;
@@ -1553,6 +1575,12 @@ html {
1553
1575
  .cursor-pointer {
1554
1576
  cursor: pointer;
1555
1577
  }
1578
+ .justify-start {
1579
+ justify-content: flex-start;
1580
+ }
1581
+ .gap-3 {
1582
+ gap: 0.75rem;
1583
+ }
1556
1584
  .\!rounded {
1557
1585
  border-radius: 0.25rem !important;
1558
1586
  }
@@ -1807,6 +1835,183 @@ html {
1807
1835
  height: 2rem;
1808
1836
  width: 2rem;
1809
1837
  }
1838
+ @media (hover:hover) {
1839
+
1840
+ .radio-color-primary:hover {
1841
+ --tw-border-opacity: 1;
1842
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1843
+ }
1844
+ }
1845
+ .radio-color-primary {
1846
+ --chkbg: var(--p);
1847
+ --tw-border-opacity: 1;
1848
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1849
+ }
1850
+ .radio-color-primary:focus-visible {
1851
+ outline-color: var(--fallback-p,oklch(var(--p)/1));
1852
+ }
1853
+ .radio-color-primary:checked,.radio-color-primary[aria-checked="true"] {
1854
+ --tw-border-opacity: 1;
1855
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1856
+ --tw-bg-opacity: 1;
1857
+ background-color: var(--fallback-p,oklch(var(--p)/var(--tw-bg-opacity)));
1858
+ --tw-text-opacity: 1;
1859
+ color: var(--fallback-pc,oklch(var(--pc)/var(--tw-text-opacity)));
1860
+ }
1861
+ @media (hover:hover) {
1862
+
1863
+ .radio-color-secondary:hover {
1864
+ --tw-border-opacity: 1;
1865
+ border-color: var(--fallback-s,oklch(var(--s)/var(--tw-border-opacity)));
1866
+ }
1867
+ }
1868
+ .radio-color-secondary {
1869
+ --chkbg: var(--s);
1870
+ --tw-border-opacity: 1;
1871
+ border-color: var(--fallback-s,oklch(var(--s)/var(--tw-border-opacity)));
1872
+ }
1873
+ .radio-color-secondary:focus-visible {
1874
+ outline-color: var(--fallback-s,oklch(var(--s)/1));
1875
+ }
1876
+ .radio-color-secondary:checked,.radio-color-secondary[aria-checked="true"] {
1877
+ --tw-border-opacity: 1;
1878
+ border-color: var(--fallback-s,oklch(var(--s)/var(--tw-border-opacity)));
1879
+ --tw-bg-opacity: 1;
1880
+ background-color: var(--fallback-s,oklch(var(--s)/var(--tw-bg-opacity)));
1881
+ --tw-text-opacity: 1;
1882
+ color: var(--fallback-sc,oklch(var(--sc)/var(--tw-text-opacity)));
1883
+ }
1884
+ @media (hover:hover) {
1885
+
1886
+ .radio-color-accent:hover {
1887
+ --tw-border-opacity: 1;
1888
+ border-color: var(--fallback-a,oklch(var(--a)/var(--tw-border-opacity)));
1889
+ }
1890
+ }
1891
+ .radio-color-accent {
1892
+ --chkbg: var(--a);
1893
+ --tw-border-opacity: 1;
1894
+ border-color: var(--fallback-a,oklch(var(--a)/var(--tw-border-opacity)));
1895
+ }
1896
+ .radio-color-accent:focus-visible {
1897
+ outline-color: var(--fallback-a,oklch(var(--a)/1));
1898
+ }
1899
+ .radio-color-accent:checked,.radio-color-accent[aria-checked="true"] {
1900
+ --tw-border-opacity: 1;
1901
+ border-color: var(--fallback-a,oklch(var(--a)/var(--tw-border-opacity)));
1902
+ --tw-bg-opacity: 1;
1903
+ background-color: var(--fallback-a,oklch(var(--a)/var(--tw-bg-opacity)));
1904
+ --tw-text-opacity: 1;
1905
+ color: var(--fallback-ac,oklch(var(--ac)/var(--tw-text-opacity)));
1906
+ }
1907
+ @media (hover:hover) {
1908
+
1909
+ .radio-color-success:hover {
1910
+ --tw-border-opacity: 1;
1911
+ border-color: var(--fallback-su,oklch(var(--su)/var(--tw-border-opacity)));
1912
+ }
1913
+ }
1914
+ .radio-color-success {
1915
+ --chkbg: var(--su);
1916
+ --tw-border-opacity: 1;
1917
+ border-color: var(--fallback-su,oklch(var(--su)/var(--tw-border-opacity)));
1918
+ }
1919
+ .radio-color-success:focus-visible {
1920
+ outline-color: var(--fallback-su,oklch(var(--su)/1));
1921
+ }
1922
+ .radio-color-success:checked,.radio-color-success[aria-checked="true"] {
1923
+ --tw-border-opacity: 1;
1924
+ border-color: var(--fallback-su,oklch(var(--su)/var(--tw-border-opacity)));
1925
+ --tw-bg-opacity: 1;
1926
+ background-color: var(--fallback-su,oklch(var(--su)/var(--tw-bg-opacity)));
1927
+ --tw-text-opacity: 1;
1928
+ color: var(--fallback-suc,oklch(var(--suc)/var(--tw-text-opacity)));
1929
+ }
1930
+ @media (hover:hover) {
1931
+
1932
+ .radio-color-warning:hover {
1933
+ --tw-border-opacity: 1;
1934
+ border-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-border-opacity)));
1935
+ }
1936
+ }
1937
+ .radio-color-warning {
1938
+ --chkbg: var(--wa);
1939
+ --tw-border-opacity: 1;
1940
+ border-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-border-opacity)));
1941
+ }
1942
+ .radio-color-warning:focus-visible {
1943
+ outline-color: var(--fallback-wa,oklch(var(--wa)/1));
1944
+ }
1945
+ .radio-color-warning:checked,.radio-color-warning[aria-checked="true"] {
1946
+ --tw-border-opacity: 1;
1947
+ border-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-border-opacity)));
1948
+ --tw-bg-opacity: 1;
1949
+ background-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-bg-opacity)));
1950
+ --tw-text-opacity: 1;
1951
+ color: var(--fallback-wac,oklch(var(--wac)/var(--tw-text-opacity)));
1952
+ }
1953
+ @media (hover:hover) {
1954
+
1955
+ .radio-color-info:hover {
1956
+ --tw-border-opacity: 1;
1957
+ border-color: var(--fallback-in,oklch(var(--in)/var(--tw-border-opacity)));
1958
+ }
1959
+ }
1960
+ .radio-color-info {
1961
+ --chkbg: var(--in);
1962
+ --tw-border-opacity: 1;
1963
+ border-color: var(--fallback-in,oklch(var(--in)/var(--tw-border-opacity)));
1964
+ }
1965
+ .radio-color-info:focus-visible {
1966
+ outline-color: var(--fallback-in,oklch(var(--in)/1));
1967
+ }
1968
+ .radio-color-info:checked,.radio-color-info[aria-checked="true"] {
1969
+ --tw-border-opacity: 1;
1970
+ border-color: var(--fallback-in,oklch(var(--in)/var(--tw-border-opacity)));
1971
+ --tw-bg-opacity: 1;
1972
+ background-color: var(--fallback-in,oklch(var(--in)/var(--tw-bg-opacity)));
1973
+ --tw-text-opacity: 1;
1974
+ color: var(--fallback-inc,oklch(var(--inc)/var(--tw-text-opacity)));
1975
+ }
1976
+ @media (hover:hover) {
1977
+
1978
+ .radio-color-error:hover {
1979
+ --tw-border-opacity: 1;
1980
+ border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity)));
1981
+ }
1982
+ }
1983
+ .radio-color-error {
1984
+ --chkbg: var(--er);
1985
+ --tw-border-opacity: 1;
1986
+ border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity)));
1987
+ }
1988
+ .radio-color-error:focus-visible {
1989
+ outline-color: var(--fallback-er,oklch(var(--er)/1));
1990
+ }
1991
+ .radio-color-error:checked,.radio-color-error[aria-checked="true"] {
1992
+ --tw-border-opacity: 1;
1993
+ border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity)));
1994
+ --tw-bg-opacity: 1;
1995
+ background-color: var(--fallback-er,oklch(var(--er)/var(--tw-bg-opacity)));
1996
+ --tw-text-opacity: 1;
1997
+ color: var(--fallback-erc,oklch(var(--erc)/var(--tw-text-opacity)));
1998
+ }
1999
+ [type="radio"].radio-size-xs {
2000
+ height: 1rem;
2001
+ width: 1rem;
2002
+ }
2003
+ [type="radio"].radio-size-sm {
2004
+ height: 1.25rem;
2005
+ width: 1.25rem;
2006
+ }
2007
+ [type="radio"].radio-size-md {
2008
+ height: 1.5rem;
2009
+ width: 1.5rem;
2010
+ }
2011
+ [type="radio"].radio-size-lg {
2012
+ height: 2rem;
2013
+ width: 2rem;
2014
+ }
1810
2015
  .text-box-size-xs {
1811
2016
  height: 1.5rem;
1812
2017
  padding-left: 0.5rem;
@@ -1 +1,3 @@
1
1
  export type SizeType = 'xs' | 'sm' | 'md' | 'lg';
2
+ export type ColorType = 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'info' | 'error';
3
+ export type PositionType = 'left' | 'right';
@@ -1,4 +1,4 @@
1
- import { SizeType } from '../../../types';
1
+ import type { SizeType } from '../../../types';
2
2
  export interface AvatarType {
3
3
  src: string;
4
4
  size?: SizeType;
@@ -1,11 +1,17 @@
1
- import type { ErrorType, SizeType } from '../../../types';
2
- export interface CheckboxType extends ErrorType {
1
+ import type { ColorType, ErrorType, PositionType, SizeType } from '../../../types';
2
+ export interface CheckboxItemType {
3
+ label?: string;
4
+ checked?: boolean;
5
+ value: string | number;
6
+ }
7
+ export interface CheckboxType extends CheckboxItemType, ErrorType {
3
8
  name: string;
4
9
  label?: string;
5
10
  checked?: boolean;
6
- position?: 'left' | 'right';
7
- color?: 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'info' | 'error';
11
+ position?: PositionType;
12
+ color?: ColorType;
8
13
  size?: SizeType;
9
14
  disabled?: boolean;
15
+ onChange?: (value: CheckboxItemType) => void;
10
16
  }
11
17
  export type CheckboxRef = HTMLInputElement;
@@ -1,3 +1,4 @@
1
1
  export type * from './checkbox.types';
2
2
  export type * from './dropdown.types';
3
+ export type * from './radio.types';
3
4
  export type * from './text-box.types';
@@ -0,0 +1,20 @@
1
+ import type { ColorType, ErrorType, PositionType, SizeType } from '../../../types';
2
+ export interface RadioItemType {
3
+ label?: string;
4
+ checked?: boolean;
5
+ value?: string | number;
6
+ }
7
+ export interface RadioType extends RadioItemType, ErrorType {
8
+ name: string;
9
+ label?: string;
10
+ checked?: boolean;
11
+ position?: PositionType;
12
+ color?: ColorType;
13
+ size?: SizeType;
14
+ disabled?: boolean;
15
+ onChange?: (value: RadioItemType) => void;
16
+ }
17
+ export type RadioRef = HTMLInputElement;
18
+ export interface RadioListType extends RadioType {
19
+ options: Omit<RadioType, 'name'>[];
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import cls from 'classnames';
4
- const Checkbox = forwardRef(({ name, label, isError, checked, disabled, error, position = 'left', color, size = 'md', ...otherProps }, ref) => {
5
- const checkbox = () => (_jsx("input", { id: name, name: name, "data-testid": name, ref: ref, type: 'checkbox', checked: checked, className: cls('checkbox', {
4
+ const Checkbox = forwardRef(({ name, label, isError, disabled, error, position = 'left', color, size = 'md', checked, value, onChange, ...otherProps }, ref) => {
5
+ const handleChange = (e) => {
6
+ onChange?.({
7
+ isChecked: e.target.checked,
8
+ value,
9
+ label
10
+ });
11
+ };
12
+ const checkbox = () => (_jsx("input", { id: name, name: name, "data-testid": name, ref: ref, type: 'checkbox', className: cls('checkbox', {
6
13
  [`checkbox-color-${color}`]: color,
7
14
  [`checkbox-size-${size}`]: size
8
- }), disabled: disabled, ...otherProps }));
15
+ }), disabled: disabled, checked: checked, onChange: handleChange, ...otherProps }));
9
16
  return (_jsxs(_Fragment, { children: [_jsxs("label", { className: cls('label', {
10
17
  'cursor-pointer': !disabled,
11
18
  'cursor-not-allowed': disabled
@@ -1,3 +1,5 @@
1
1
  export * from '../../ui/forms/checkbox';
2
2
  export * from '../../ui/forms/dropdown';
3
+ export * from '../../ui/forms/radio';
4
+ export * from '../../ui/forms/radio-list';
3
5
  export * from '../../ui/forms/text-box';
@@ -1,3 +1,5 @@
1
1
  export * from '../../ui/forms/checkbox';
2
2
  export * from '../../ui/forms/dropdown';
3
+ export * from '../../ui/forms/radio';
4
+ export * from '../../ui/forms/radio-list';
3
5
  export * from '../../ui/forms/text-box';
@@ -0,0 +1,2 @@
1
+ import Radio from './radio.component';
2
+ export { Radio };
@@ -0,0 +1,2 @@
1
+ import Radio from './radio.component';
2
+ export { Radio };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { RadioType } from '../../../types';
3
+ declare const Radio: React.ForwardRefExoticComponent<RadioType & React.RefAttributes<HTMLInputElement>>;
4
+ export default Radio;
@@ -0,0 +1,21 @@
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) => {
5
+ const handleChange = (e) => {
6
+ onChange?.({
7
+ isChecked: e.target.checked,
8
+ value,
9
+ label
10
+ });
11
+ };
12
+ const radio = () => (_jsx("input", { ref: ref, id: name, name: name, "data-testid": name, type: 'radio', className: cls('radio', {
13
+ [`radio-color-${color}`]: color,
14
+ [`radio-size-${size}`]: size
15
+ }), 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 })] }));
20
+ });
21
+ export default Radio;
@@ -0,0 +1,2 @@
1
+ import RadioList from './radio-list.component';
2
+ export { RadioList };
@@ -0,0 +1,2 @@
1
+ import RadioList from './radio-list.component';
2
+ export { RadioList };
@@ -0,0 +1,3 @@
1
+ import type { RadioListType } from '../../../types';
2
+ declare const RadioList: ({ name, options, isError, error, value, ...otherOptions }: RadioListType) => import("react/jsx-runtime").JSX.Element | undefined;
3
+ export default RadioList;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Radio } from '../../../ui/forms';
3
+ const RadioList = ({ name, options, isError, error, value, ...otherOptions }) => {
4
+ if (!options || options.length === 0) {
5
+ return;
6
+ }
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 })] }));
8
+ };
9
+ export default RadioList;
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "framework design",
11
11
  "design system"
12
12
  ],
13
- "version": "0.2.0",
13
+ "version": "0.3.0",
14
14
  "homepage": "https://github.com/creativecodeco/ui",
15
15
  "author": {
16
16
  "name": "John Toro",