@creativecodeco/ui 0.1.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.
Files changed (45) hide show
  1. package/lib/index.d.ts +1 -1
  2. package/lib/index.js +0 -1
  3. package/lib/theme/css/checkbox.css +47 -0
  4. package/lib/theme/css/main.css +2 -0
  5. package/lib/theme/css/radio.css +47 -0
  6. package/lib/theme/main.css +578 -1
  7. package/lib/types/helpers/controller.types.d.ts +5 -5
  8. package/lib/types/ui/base/constants.types.d.ts +2 -0
  9. package/lib/types/ui/base/error.types.d.ts +4 -0
  10. package/lib/types/ui/base/index.d.ts +1 -0
  11. package/lib/types/ui/components/avatar.types.d.ts +1 -1
  12. package/lib/types/ui/forms/checkbox.types.d.ts +17 -0
  13. package/lib/types/ui/forms/checkbox.types.js +1 -0
  14. package/lib/types/ui/forms/{drop-down.types.d.ts → dropdown.types.d.ts} +3 -3
  15. package/lib/types/ui/forms/dropdown.types.js +1 -0
  16. package/lib/types/ui/forms/index.d.ts +4 -3
  17. package/lib/types/ui/forms/radio.types.d.ts +20 -0
  18. package/lib/types/ui/forms/radio.types.js +1 -0
  19. package/lib/types/ui/forms/text-box.types.d.ts +2 -4
  20. package/lib/ui/components/avatar/avatar.component.js +2 -2
  21. package/lib/ui/forms/checkbox/checkbox.component.d.ts +4 -0
  22. package/lib/ui/forms/checkbox/checkbox.component.js +21 -0
  23. package/lib/ui/forms/checkbox/index.d.ts +2 -0
  24. package/lib/ui/forms/checkbox/index.js +2 -0
  25. package/lib/ui/forms/dropdown/dropdown.component.d.ts +4 -0
  26. package/lib/ui/forms/{drop-down/drop-down.component.js → dropdown/dropdown.component.js} +2 -2
  27. package/lib/ui/forms/dropdown/index.d.ts +2 -0
  28. package/lib/ui/forms/dropdown/index.js +2 -0
  29. package/lib/ui/forms/index.d.ts +4 -1
  30. package/lib/ui/forms/index.js +4 -1
  31. package/lib/ui/forms/radio/index.d.ts +2 -0
  32. package/lib/ui/forms/radio/index.js +2 -0
  33. package/lib/ui/forms/radio/radio.component.d.ts +4 -0
  34. package/lib/ui/forms/radio/radio.component.js +21 -0
  35. package/lib/ui/forms/radio-list/index.d.ts +2 -0
  36. package/lib/ui/forms/radio-list/index.js +2 -0
  37. package/lib/ui/forms/radio-list/radio-list.component.d.ts +3 -0
  38. package/lib/ui/forms/radio-list/radio-list.component.js +9 -0
  39. package/lib/utils/string.utils.d.ts +26 -0
  40. package/lib/utils/string.utils.js +37 -0
  41. package/package.json +14 -14
  42. package/lib/ui/forms/drop-down/drop-down.component.d.ts +0 -4
  43. package/lib/ui/forms/drop-down/index.d.ts +0 -2
  44. package/lib/ui/forms/drop-down/index.js +0 -2
  45. /package/lib/types/ui/{forms/drop-down.types.js → base/error.types.js} +0 -0
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';
@@ -0,0 +1,47 @@
1
+ .checkbox-color {
2
+ &-primary {
3
+ @apply checkbox-primary;
4
+ }
5
+
6
+ &-secondary {
7
+ @apply checkbox-secondary;
8
+ }
9
+
10
+ &-accent {
11
+ @apply checkbox-accent;
12
+ }
13
+
14
+ &-success {
15
+ @apply checkbox-success;
16
+ }
17
+
18
+ &-warning {
19
+ @apply checkbox-warning;
20
+ }
21
+
22
+ &-info {
23
+ @apply checkbox-info;
24
+ }
25
+
26
+ &-error {
27
+ @apply checkbox-error;
28
+ }
29
+ }
30
+
31
+ .checkbox-size {
32
+ &-xs {
33
+ @apply checkbox-xs;
34
+ }
35
+
36
+ &-sm {
37
+ @apply checkbox-sm;
38
+ }
39
+
40
+ &-md {
41
+ @apply checkbox-md;
42
+ }
43
+
44
+ &-lg {
45
+ @apply checkbox-lg;
46
+ }
47
+ }
@@ -3,4 +3,6 @@
3
3
  @import 'tailwindcss/utilities';
4
4
 
5
5
  @import './avatar.css';
6
+ @import './checkbox.css';
7
+ @import './radio.css';
6
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
+ }
@@ -1,5 +1,5 @@
1
1
  /*
2
- ! tailwindcss v3.4.0 | MIT License | https://tailwindcss.com
2
+ ! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
3
3
  *//*
4
4
  1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
5
5
  2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
@@ -657,6 +657,32 @@ html {
657
657
  --tw-text-opacity: 1;
658
658
  color: var(--fallback-nc,oklch(var(--nc)/var(--tw-text-opacity)));
659
659
  }
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
+
666
+ .table tr.hover:hover,
667
+ .table tr.hover:nth-child(even):hover {
668
+ --tw-bg-opacity: 1;
669
+ background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity)));
670
+ }
671
+ }
672
+ .checkbox {
673
+ flex-shrink: 0;
674
+ --chkbg: var(--fallback-bc,oklch(var(--bc)/1));
675
+ --chkfg: var(--fallback-b1,oklch(var(--b1)/1));
676
+ height: 1.5rem;
677
+ width: 1.5rem;
678
+ cursor: pointer;
679
+ -webkit-appearance: none;
680
+ -moz-appearance: none;
681
+ appearance: none;
682
+ border-radius: var(--rounded-btn, 0.5rem);
683
+ border-width: 1px;
684
+ border-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-border-opacity)));
685
+ --tw-border-opacity: 0.2;
660
686
  }
661
687
  .dropdown {
662
688
  position: relative;
@@ -729,6 +755,15 @@ html {
729
755
  opacity: 1;
730
756
  }
731
757
 
758
+ .btm-nav > *.\!disabled:hover {
759
+ pointer-events: none !important;
760
+ --tw-border-opacity: 0 !important;
761
+ background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity))) !important;
762
+ --tw-bg-opacity: 0.1 !important;
763
+ color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))) !important;
764
+ --tw-text-opacity: 0.2 !important;
765
+ }
766
+
732
767
  .btm-nav > *.disabled:hover,
733
768
  .btm-nav > *[disabled]:hover {
734
769
  pointer-events: none;
@@ -882,6 +917,13 @@ html {
882
917
  user-select: none;
883
918
  color: var(--fallback-bc,oklch(var(--bc)/0.3));
884
919
  }
920
+ .menu li.\!disabled {
921
+ cursor: not-allowed !important;
922
+ -webkit-user-select: none !important;
923
+ -moz-user-select: none !important;
924
+ user-select: none !important;
925
+ color: var(--fallback-bc,oklch(var(--bc)/0.3)) !important;
926
+ }
885
927
  .menu :where(li > .menu-dropdown:not(.menu-dropdown-show)) {
886
928
  display: none;
887
929
  }
@@ -896,6 +938,20 @@ html {
896
938
  :where(.menu li) .badge {
897
939
  justify-self: end;
898
940
  }
941
+ .radio {
942
+ flex-shrink: 0;
943
+ --chkbg: var(--bc);
944
+ height: 1.5rem;
945
+ width: 1.5rem;
946
+ cursor: pointer;
947
+ -webkit-appearance: none;
948
+ -moz-appearance: none;
949
+ appearance: none;
950
+ border-radius: 9999px;
951
+ border-width: 1px;
952
+ border-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-border-opacity)));
953
+ --tw-border-opacity: 0.2;
954
+ }
899
955
  .select {
900
956
  display: inline-flex;
901
957
  cursor: pointer;
@@ -928,6 +984,35 @@ html {
928
984
  .select[multiple] {
929
985
  height: auto;
930
986
  }
987
+ .table {
988
+ position: relative;
989
+ width: 100%;
990
+ border-radius: var(--rounded-box, 1rem);
991
+ text-align: left;
992
+ font-size: 0.875rem;
993
+ line-height: 1.25rem;
994
+ }
995
+ .table :where(.table-pin-rows thead tr) {
996
+ position: sticky;
997
+ top: 0px;
998
+ z-index: 1;
999
+ --tw-bg-opacity: 1;
1000
+ background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
1001
+ }
1002
+ .table :where(.table-pin-rows tfoot tr) {
1003
+ position: sticky;
1004
+ bottom: 0px;
1005
+ z-index: 1;
1006
+ --tw-bg-opacity: 1;
1007
+ background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
1008
+ }
1009
+ .table :where(.table-pin-cols tr th) {
1010
+ position: sticky;
1011
+ left: 0px;
1012
+ right: 0px;
1013
+ --tw-bg-opacity: 1;
1014
+ background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
1015
+ }
931
1016
  .avatar-group :where(.avatar) {
932
1017
  overflow: hidden;
933
1018
  border-radius: 9999px;
@@ -935,6 +1020,14 @@ html {
935
1020
  --tw-border-opacity: 1;
936
1021
  border-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-border-opacity)));
937
1022
  }
1023
+ .btm-nav > *.\!disabled {
1024
+ pointer-events: none !important;
1025
+ --tw-border-opacity: 0 !important;
1026
+ background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity))) !important;
1027
+ --tw-bg-opacity: 0.1 !important;
1028
+ color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))) !important;
1029
+ --tw-text-opacity: 0.2 !important;
1030
+ }
938
1031
  .btm-nav > *.disabled,
939
1032
  .btm-nav > *[disabled] {
940
1033
  pointer-events: none;
@@ -962,6 +1055,49 @@ html {
962
1055
  transform: scale(1);
963
1056
  }
964
1057
  }
1058
+ .checkbox:focus {
1059
+ box-shadow: none;
1060
+ }
1061
+ .checkbox:focus-visible {
1062
+ outline-style: solid;
1063
+ outline-width: 2px;
1064
+ outline-offset: 2px;
1065
+ outline-color: var(--fallback-bc,oklch(var(--bc)/1));
1066
+ }
1067
+ .checkbox:checked,
1068
+ .checkbox[checked="true"],
1069
+ .checkbox[aria-checked="true"] {
1070
+ background-repeat: no-repeat;
1071
+ animation: checkmark var(--animation-input, 0.2s) ease-out;
1072
+ background-color: var(--chkbg);
1073
+ background-image: linear-gradient(-45deg, transparent 65%, var(--chkbg) 65.99%),
1074
+ linear-gradient(45deg, transparent 75%, var(--chkbg) 75.99%),
1075
+ linear-gradient(-45deg, var(--chkbg) 40%, transparent 40.99%),
1076
+ linear-gradient(
1077
+ 45deg,
1078
+ var(--chkbg) 30%,
1079
+ var(--chkfg) 30.99%,
1080
+ var(--chkfg) 40%,
1081
+ transparent 40.99%
1082
+ ),
1083
+ linear-gradient(-45deg, var(--chkfg) 50%, var(--chkbg) 50.99%);
1084
+ }
1085
+ .checkbox:indeterminate {
1086
+ --tw-bg-opacity: 1;
1087
+ background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity)));
1088
+ background-repeat: no-repeat;
1089
+ animation: checkmark var(--animation-input, 0.2s) ease-out;
1090
+ background-image: linear-gradient(90deg, transparent 80%, var(--chkbg) 80%),
1091
+ linear-gradient(-90deg, transparent 80%, var(--chkbg) 80%),
1092
+ linear-gradient(0deg, var(--chkbg) 43%, var(--chkfg) 43%, var(--chkfg) 57%, var(--chkbg) 57%);
1093
+ }
1094
+ .checkbox:disabled {
1095
+ cursor: not-allowed;
1096
+ border-color: transparent;
1097
+ --tw-bg-opacity: 1;
1098
+ background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity)));
1099
+ opacity: 0.2;
1100
+ }
965
1101
  @keyframes checkmark {
966
1102
 
967
1103
  0% {
@@ -1180,6 +1316,45 @@ html {
1180
1316
  background-position-x: -115%;
1181
1317
  }
1182
1318
  }
1319
+ .radio:focus {
1320
+ box-shadow: none;
1321
+ }
1322
+ .radio:focus-visible {
1323
+ outline-style: solid;
1324
+ outline-width: 2px;
1325
+ outline-offset: 2px;
1326
+ outline-color: var(--fallback-bc,oklch(var(--bc)/1));
1327
+ }
1328
+ .radio:checked,
1329
+ .radio[aria-checked="true"] {
1330
+ --tw-bg-opacity: 1;
1331
+ background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity)));
1332
+ background-image: none;
1333
+ animation: radiomark var(--animation-input, 0.2s) ease-out;
1334
+ box-shadow: 0 0 0 4px var(--fallback-b1,oklch(var(--b1)/1)) inset,
1335
+ 0 0 0 4px var(--fallback-b1,oklch(var(--b1)/1)) inset;
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
+ }
1354
+ .radio:disabled {
1355
+ cursor: not-allowed;
1356
+ opacity: 0.2;
1357
+ }
1183
1358
  @keyframes radiomark {
1184
1359
 
1185
1360
  0% {
@@ -1259,6 +1434,35 @@ html {
1259
1434
  background-position: -50%;
1260
1435
  }
1261
1436
  }
1437
+ :is([dir="rtl"] .table) {
1438
+ text-align: right;
1439
+ }
1440
+ .table :where(th, td) {
1441
+ padding-left: 1rem;
1442
+ padding-right: 1rem;
1443
+ padding-top: 0.75rem;
1444
+ padding-bottom: 0.75rem;
1445
+ vertical-align: middle;
1446
+ }
1447
+ .table tr.active,
1448
+ .table tr.active:nth-child(even),
1449
+ .table-zebra tbody tr:nth-child(even) {
1450
+ --tw-bg-opacity: 1;
1451
+ background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity)));
1452
+ }
1453
+ .table :where(thead, tbody) :where(tr:not(:last-child)),
1454
+ .table :where(thead, tbody) :where(tr:first-child:last-child) {
1455
+ border-bottom-width: 1px;
1456
+ --tw-border-opacity: 1;
1457
+ border-bottom-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-border-opacity)));
1458
+ }
1459
+ .table :where(thead, tfoot) {
1460
+ white-space: nowrap;
1461
+ font-size: 0.75rem;
1462
+ line-height: 1rem;
1463
+ font-weight: 700;
1464
+ color: var(--fallback-bc,oklch(var(--bc)/0.6));
1465
+ }
1262
1466
  @keyframes toast-pop {
1263
1467
 
1264
1468
  0% {
@@ -1359,12 +1563,24 @@ html {
1359
1563
  .flex {
1360
1564
  display: flex;
1361
1565
  }
1566
+ .table {
1567
+ display: table;
1568
+ }
1362
1569
  .w-full {
1363
1570
  width: 100%;
1364
1571
  }
1572
+ .cursor-not-allowed {
1573
+ cursor: not-allowed;
1574
+ }
1365
1575
  .cursor-pointer {
1366
1576
  cursor: pointer;
1367
1577
  }
1578
+ .justify-start {
1579
+ justify-content: flex-start;
1580
+ }
1581
+ .gap-3 {
1582
+ gap: 0.75rem;
1583
+ }
1368
1584
  .\!rounded {
1369
1585
  border-radius: 0.25rem !important;
1370
1586
  }
@@ -1435,6 +1651,367 @@ html {
1435
1651
  --tw-ring-offset-width: 2px;
1436
1652
  --tw-ring-offset-color: var(--fallback-b1,oklch(var(--b1)/1));
1437
1653
  }
1654
+ @media (hover:hover) {
1655
+
1656
+ .checkbox-color-primary:hover {
1657
+ --tw-border-opacity: 1;
1658
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1659
+ }
1660
+ }
1661
+ .checkbox-color-primary {
1662
+ --chkbg: var(--fallback-p,oklch(var(--p)/1));
1663
+ --chkfg: var(--fallback-pc,oklch(var(--pc)/1));
1664
+ --tw-border-opacity: 1;
1665
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1666
+ }
1667
+ .checkbox-color-primary:focus-visible {
1668
+ outline-color: var(--fallback-p,oklch(var(--p)/1));
1669
+ }
1670
+ .checkbox-color-primary:checked,.checkbox-color-primary[checked="true"],.checkbox-color-primary[aria-checked="true"] {
1671
+ --tw-border-opacity: 1;
1672
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1673
+ --tw-bg-opacity: 1;
1674
+ background-color: var(--fallback-p,oklch(var(--p)/var(--tw-bg-opacity)));
1675
+ --tw-text-opacity: 1;
1676
+ color: var(--fallback-pc,oklch(var(--pc)/var(--tw-text-opacity)));
1677
+ }
1678
+ @media (hover:hover) {
1679
+
1680
+ .checkbox-color-secondary:hover {
1681
+ --tw-border-opacity: 1;
1682
+ border-color: var(--fallback-s,oklch(var(--s)/var(--tw-border-opacity)));
1683
+ }
1684
+ }
1685
+ .checkbox-color-secondary {
1686
+ --chkbg: var(--fallback-s,oklch(var(--s)/1));
1687
+ --chkfg: var(--fallback-sc,oklch(var(--sc)/1));
1688
+ --tw-border-opacity: 1;
1689
+ border-color: var(--fallback-s,oklch(var(--s)/var(--tw-border-opacity)));
1690
+ }
1691
+ .checkbox-color-secondary:focus-visible {
1692
+ outline-color: var(--fallback-s,oklch(var(--s)/1));
1693
+ }
1694
+ .checkbox-color-secondary:checked,.checkbox-color-secondary[checked="true"],.checkbox-color-secondary[aria-checked="true"] {
1695
+ --tw-border-opacity: 1;
1696
+ border-color: var(--fallback-s,oklch(var(--s)/var(--tw-border-opacity)));
1697
+ --tw-bg-opacity: 1;
1698
+ background-color: var(--fallback-s,oklch(var(--s)/var(--tw-bg-opacity)));
1699
+ --tw-text-opacity: 1;
1700
+ color: var(--fallback-sc,oklch(var(--sc)/var(--tw-text-opacity)));
1701
+ }
1702
+ @media (hover:hover) {
1703
+
1704
+ .checkbox-color-accent:hover {
1705
+ --tw-border-opacity: 1;
1706
+ border-color: var(--fallback-a,oklch(var(--a)/var(--tw-border-opacity)));
1707
+ }
1708
+ }
1709
+ .checkbox-color-accent {
1710
+ --chkbg: var(--fallback-a,oklch(var(--a)/1));
1711
+ --chkfg: var(--fallback-ac,oklch(var(--ac)/1));
1712
+ --tw-border-opacity: 1;
1713
+ border-color: var(--fallback-a,oklch(var(--a)/var(--tw-border-opacity)));
1714
+ }
1715
+ .checkbox-color-accent:focus-visible {
1716
+ outline-color: var(--fallback-a,oklch(var(--a)/1));
1717
+ }
1718
+ .checkbox-color-accent:checked,.checkbox-color-accent[checked="true"],.checkbox-color-accent[aria-checked="true"] {
1719
+ --tw-border-opacity: 1;
1720
+ border-color: var(--fallback-a,oklch(var(--a)/var(--tw-border-opacity)));
1721
+ --tw-bg-opacity: 1;
1722
+ background-color: var(--fallback-a,oklch(var(--a)/var(--tw-bg-opacity)));
1723
+ --tw-text-opacity: 1;
1724
+ color: var(--fallback-ac,oklch(var(--ac)/var(--tw-text-opacity)));
1725
+ }
1726
+ @media (hover:hover) {
1727
+
1728
+ .checkbox-color-success:hover {
1729
+ --tw-border-opacity: 1;
1730
+ border-color: var(--fallback-su,oklch(var(--su)/var(--tw-border-opacity)));
1731
+ }
1732
+ }
1733
+ .checkbox-color-success {
1734
+ --chkbg: var(--fallback-su,oklch(var(--su)/1));
1735
+ --chkfg: var(--fallback-suc,oklch(var(--suc)/1));
1736
+ --tw-border-opacity: 1;
1737
+ border-color: var(--fallback-su,oklch(var(--su)/var(--tw-border-opacity)));
1738
+ }
1739
+ .checkbox-color-success:focus-visible {
1740
+ outline-color: var(--fallback-su,oklch(var(--su)/1));
1741
+ }
1742
+ .checkbox-color-success:checked,.checkbox-color-success[checked="true"],.checkbox-color-success[aria-checked="true"] {
1743
+ --tw-border-opacity: 1;
1744
+ border-color: var(--fallback-su,oklch(var(--su)/var(--tw-border-opacity)));
1745
+ --tw-bg-opacity: 1;
1746
+ background-color: var(--fallback-su,oklch(var(--su)/var(--tw-bg-opacity)));
1747
+ --tw-text-opacity: 1;
1748
+ color: var(--fallback-suc,oklch(var(--suc)/var(--tw-text-opacity)));
1749
+ }
1750
+ @media (hover:hover) {
1751
+
1752
+ .checkbox-color-warning:hover {
1753
+ --tw-border-opacity: 1;
1754
+ border-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-border-opacity)));
1755
+ }
1756
+ }
1757
+ .checkbox-color-warning {
1758
+ --chkbg: var(--fallback-wa,oklch(var(--wa)/1));
1759
+ --chkfg: var(--fallback-wac,oklch(var(--wac)/1));
1760
+ --tw-border-opacity: 1;
1761
+ border-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-border-opacity)));
1762
+ }
1763
+ .checkbox-color-warning:focus-visible {
1764
+ outline-color: var(--fallback-wa,oklch(var(--wa)/1));
1765
+ }
1766
+ .checkbox-color-warning:checked,.checkbox-color-warning[checked="true"],.checkbox-color-warning[aria-checked="true"] {
1767
+ --tw-border-opacity: 1;
1768
+ border-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-border-opacity)));
1769
+ --tw-bg-opacity: 1;
1770
+ background-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-bg-opacity)));
1771
+ --tw-text-opacity: 1;
1772
+ color: var(--fallback-wac,oklch(var(--wac)/var(--tw-text-opacity)));
1773
+ }
1774
+ @media (hover:hover) {
1775
+
1776
+ .checkbox-color-info:hover {
1777
+ --tw-border-opacity: 1;
1778
+ border-color: var(--fallback-in,oklch(var(--in)/var(--tw-border-opacity)));
1779
+ }
1780
+ }
1781
+ .checkbox-color-info {
1782
+ --chkbg: var(--fallback-in,oklch(var(--in)/1));
1783
+ --chkfg: var(--fallback-inc,oklch(var(--inc)/1));
1784
+ --tw-border-opacity: 1;
1785
+ border-color: var(--fallback-in,oklch(var(--in)/var(--tw-border-opacity)));
1786
+ }
1787
+ .checkbox-color-info:focus-visible {
1788
+ outline-color: var(--fallback-in,oklch(var(--in)/1));
1789
+ }
1790
+ .checkbox-color-info:checked,.checkbox-color-info[checked="true"],.checkbox-color-info[aria-checked="true"] {
1791
+ --tw-border-opacity: 1;
1792
+ border-color: var(--fallback-in,oklch(var(--in)/var(--tw-border-opacity)));
1793
+ --tw-bg-opacity: 1;
1794
+ background-color: var(--fallback-in,oklch(var(--in)/var(--tw-bg-opacity)));
1795
+ --tw-text-opacity: 1;
1796
+ color: var(--fallback-inc,oklch(var(--inc)/var(--tw-text-opacity)));
1797
+ }
1798
+ @media (hover:hover) {
1799
+
1800
+ .checkbox-color-error:hover {
1801
+ --tw-border-opacity: 1;
1802
+ border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity)));
1803
+ }
1804
+ }
1805
+ .checkbox-color-error {
1806
+ --chkbg: var(--fallback-er,oklch(var(--er)/1));
1807
+ --chkfg: var(--fallback-erc,oklch(var(--erc)/1));
1808
+ --tw-border-opacity: 1;
1809
+ border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity)));
1810
+ }
1811
+ .checkbox-color-error:focus-visible {
1812
+ outline-color: var(--fallback-er,oklch(var(--er)/1));
1813
+ }
1814
+ .checkbox-color-error:checked,.checkbox-color-error[checked="true"],.checkbox-color-error[aria-checked="true"] {
1815
+ --tw-border-opacity: 1;
1816
+ border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity)));
1817
+ --tw-bg-opacity: 1;
1818
+ background-color: var(--fallback-er,oklch(var(--er)/var(--tw-bg-opacity)));
1819
+ --tw-text-opacity: 1;
1820
+ color: var(--fallback-erc,oklch(var(--erc)/var(--tw-text-opacity)));
1821
+ }
1822
+ [type="checkbox"].checkbox-size-xs {
1823
+ height: 1rem;
1824
+ width: 1rem;
1825
+ }
1826
+ [type="checkbox"].checkbox-size-sm {
1827
+ height: 1.25rem;
1828
+ width: 1.25rem;
1829
+ }
1830
+ [type="checkbox"].checkbox-size-md {
1831
+ height: 1.5rem;
1832
+ width: 1.5rem;
1833
+ }
1834
+ [type="checkbox"].checkbox-size-lg {
1835
+ height: 2rem;
1836
+ width: 2rem;
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
+ }
1438
2015
  .text-box-size-xs {
1439
2016
  height: 1.5rem;
1440
2017
  padding-left: 0.5rem;
@@ -1,12 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import type { FieldPath, FieldValues, ControllerProps as RHFControllerProps } from 'react-hook-form';
3
- import { DropDown, TextBox } from '../../ui/forms';
3
+ import { Dropdown, TextBox } from '../../ui/forms';
4
4
  type TextBoxType = {
5
5
  as: typeof TextBox;
6
6
  } & React.ComponentProps<typeof TextBox>;
7
- type DropDownType = {
8
- as: typeof DropDown;
9
- } & React.ComponentProps<typeof DropDown>;
10
- type Inputs = TextBoxType | DropDownType;
7
+ type DropdownType = {
8
+ as: typeof Dropdown;
9
+ } & React.ComponentProps<typeof Dropdown>;
10
+ type Inputs = TextBoxType | DropdownType;
11
11
  export type ControllerType<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Omit<RHFControllerProps<TFieldValues, TName>, 'render'> & Inputs;
12
12
  export {};
@@ -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';
@@ -0,0 +1,4 @@
1
+ export interface ErrorType {
2
+ isError?: boolean;
3
+ error?: string;
4
+ }
@@ -1 +1,2 @@
1
1
  export type * from './constants.types';
2
+ export type * from './error.types';
@@ -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;
@@ -0,0 +1,17 @@
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 {
8
+ name: string;
9
+ label?: string;
10
+ checked?: boolean;
11
+ position?: PositionType;
12
+ color?: ColorType;
13
+ size?: SizeType;
14
+ disabled?: boolean;
15
+ onChange?: (value: CheckboxItemType) => void;
16
+ }
17
+ export type CheckboxRef = HTMLInputElement;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { TextBoxType } from './text-box.types';
3
- export interface DropDownOption {
3
+ export interface DropdownOption {
4
4
  value: string | number;
5
5
  label: string;
6
6
  }
7
- export interface DropDownType extends TextBoxType {
8
- options?: DropDownOption[];
7
+ export interface DropdownType extends TextBoxType {
8
+ options?: DropdownOption[];
9
9
  onChange?: (option: React.ChangeEvent<HTMLInputElement>) => void;
10
10
  onTextChange?: (text?: string) => void;
11
11
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
- import { DropDownOption, DropDownType } from './drop-down.types';
2
- import { TextBoxType, TextBoxRef } from './text-box.types';
3
- export type { DropDownOption, DropDownType, TextBoxType, TextBoxRef };
1
+ export type * from './checkbox.types';
2
+ export type * from './dropdown.types';
3
+ export type * from './radio.types';
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,9 @@
1
1
  /// <reference types="react" />
2
2
  import type { IconType } from 'react-icons';
3
- import { SizeType } from '../../../types';
4
- export interface TextBoxType extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
3
+ import type { ErrorType, SizeType } from '../../../types';
4
+ export interface TextBoxType extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'>, ErrorType {
5
5
  name: string;
6
6
  label?: string;
7
- isError?: boolean;
8
- error?: string;
9
7
  disabled?: boolean;
10
8
  size?: SizeType;
11
9
  leftIcon?: IconType;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMemo } from 'react';
3
3
  import cls from 'classnames';
4
- import { getInitials } from '../../../utils';
4
+ import { getInitials, isValidUrl } from '../../../utils';
5
5
  const Avatar = ({ isOnline = false, ring = false, rounded = false, size = 'md', src, withStatus = false }) => {
6
- const isUri = useMemo(() => URL.canParse(src), [src]);
6
+ const isUri = useMemo(() => isValidUrl(src), [src]);
7
7
  const letters = useMemo(() => getInitials(src), [src, isUri]);
8
8
  return (_jsx("div", { "data-testid": 'avatar', className: cls('avatar', {
9
9
  online: withStatus && isOnline,
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { CheckboxType } from '../../../types';
3
+ declare const Checkbox: React.ForwardRefExoticComponent<CheckboxType & React.RefAttributes<HTMLInputElement>>;
4
+ export default Checkbox;
@@ -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 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', {
13
+ [`checkbox-color-${color}`]: color,
14
+ [`checkbox-size-${size}`]: size
15
+ }), 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 })] }));
20
+ });
21
+ export default Checkbox;
@@ -0,0 +1,2 @@
1
+ import Checkbox from './checkbox.component';
2
+ export { Checkbox };
@@ -0,0 +1,2 @@
1
+ import Checkbox from './checkbox.component';
2
+ export { Checkbox };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { DropdownType } from '../../../types';
3
+ declare const Dropdown: React.ForwardRefExoticComponent<DropdownType & React.RefAttributes<HTMLInputElement>>;
4
+ export default Dropdown;
@@ -3,7 +3,7 @@ import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'r
3
3
  import { FaSortDown } from 'react-icons/fa';
4
4
  import { useOnClickOutside } from 'usehooks-ts';
5
5
  import { TextBox } from '../../../ui/forms';
6
- const DropDown = forwardRef(({ name, options = [], disabled, onChange, onTextChange, value, ...otherProps }, ref) => {
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);
9
9
  const [valueFilter, setValueFilter] = useState();
@@ -50,4 +50,4 @@ const DropDown = forwardRef(({ name, options = [], disabled, onChange, onTextCha
50
50
  : options.filter(({ label }) => label.includes(valueFilter)), [valueFilter, options]);
51
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))) }))] }));
52
52
  });
53
- export default DropDown;
53
+ export default Dropdown;
@@ -0,0 +1,2 @@
1
+ import Dropdown from './dropdown.component';
2
+ export { Dropdown };
@@ -0,0 +1,2 @@
1
+ import Dropdown from './dropdown.component';
2
+ export { Dropdown };
@@ -1,2 +1,5 @@
1
- export * from '../../ui/forms/drop-down';
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';
2
5
  export * from '../../ui/forms/text-box';
@@ -1,2 +1,5 @@
1
- export * from '../../ui/forms/drop-down';
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';
2
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;
@@ -23,3 +23,29 @@
23
23
  * @public
24
24
  */
25
25
  export declare function getInitials(name: string): string;
26
+ /**
27
+ * Checks whether the provided string is a valid URL.
28
+ *
29
+ * @param uri - The string to be checked as a URL.
30
+ * @returns A boolean indicating whether the provided string is a valid URL.
31
+ *
32
+ * @remarks
33
+ * This function uses the URL constructor to validate whether the input is a well-formed URL.
34
+ * It returns true if the URL is valid and false otherwise.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Example 1:
39
+ * const url1 = "https://www.example.com";
40
+ * const isValid1 = isValidUrl(url1);
41
+ * console.log(isValid1); // Output: true
42
+ *
43
+ * // Example 2:
44
+ * const url2 = "not_a_valid_url";
45
+ * const isValid2 = isValidUrl(url2);
46
+ * console.log(isValid2); // Output: false
47
+ * ```
48
+ *
49
+ * @public
50
+ */
51
+ export declare function isValidUrl(uri?: string): boolean;
@@ -36,3 +36,40 @@ export function getInitials(name) {
36
36
  .map(getCharAt)
37
37
  .join('');
38
38
  }
39
+ /**
40
+ * Checks whether the provided string is a valid URL.
41
+ *
42
+ * @param uri - The string to be checked as a URL.
43
+ * @returns A boolean indicating whether the provided string is a valid URL.
44
+ *
45
+ * @remarks
46
+ * This function uses the URL constructor to validate whether the input is a well-formed URL.
47
+ * It returns true if the URL is valid and false otherwise.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * // Example 1:
52
+ * const url1 = "https://www.example.com";
53
+ * const isValid1 = isValidUrl(url1);
54
+ * console.log(isValid1); // Output: true
55
+ *
56
+ * // Example 2:
57
+ * const url2 = "not_a_valid_url";
58
+ * const isValid2 = isValidUrl(url2);
59
+ * console.log(isValid2); // Output: false
60
+ * ```
61
+ *
62
+ * @public
63
+ */
64
+ export function isValidUrl(uri) {
65
+ if (!uri) {
66
+ return false;
67
+ }
68
+ try {
69
+ new URL(uri);
70
+ return true;
71
+ }
72
+ catch (ignored) {
73
+ return false;
74
+ }
75
+ }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "framework design",
11
11
  "design system"
12
12
  ],
13
- "version": "0.1.0",
13
+ "version": "0.3.0",
14
14
  "homepage": "https://github.com/creativecodeco/ui",
15
15
  "author": {
16
16
  "name": "John Toro",
@@ -48,16 +48,16 @@
48
48
  "usehooks-ts": "2.9.1"
49
49
  },
50
50
  "dependencies": {
51
- "postcss": "8.4.32",
51
+ "postcss": "8.4.33",
52
52
  "postcss-import": "16.0.0",
53
53
  "react": "18.2.0",
54
- "react-hook-form": "7.49.2",
55
- "tailwindcss": "3.4.0",
56
- "usehooks-ts": "2.9.1"
54
+ "react-hook-form": "7.49.3",
55
+ "tailwindcss": "3.4.1",
56
+ "usehooks-ts": "2.9.2"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@babel/core": "7.23.7",
60
- "@babel/preset-env": "7.23.7",
60
+ "@babel/preset-env": "7.23.8",
61
61
  "@babel/preset-react": "7.23.3",
62
62
  "@babel/preset-typescript": "7.23.3",
63
63
  "@jest/globals": "29.7.0",
@@ -69,17 +69,17 @@
69
69
  "@storybook/react": "7.6.7",
70
70
  "@storybook/react-webpack5": "7.6.7",
71
71
  "@storybook/test": "7.6.7",
72
- "@testing-library/dom": "9.3.3",
72
+ "@testing-library/dom": "9.3.4",
73
73
  "@testing-library/jest-dom": "6.2.0",
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.6",
78
- "@types/react": "18.2.46",
77
+ "@types/node": "20.10.8",
78
+ "@types/react": "18.2.47",
79
79
  "@types/react-dom": "18.2.18",
80
- "@typescript-eslint/eslint-plugin": "6.17.0",
80
+ "@typescript-eslint/eslint-plugin": "6.18.1",
81
81
  "autoprefixer": "10.4.16",
82
- "chromatic": "10.2.0",
82
+ "chromatic": "10.2.1",
83
83
  "classnames": "2.5.1",
84
84
  "cpx2": "7.0.1",
85
85
  "daisyui": "4.5.0",
@@ -90,9 +90,9 @@
90
90
  "eslint-config-standard-with-typescript": "43.0.0",
91
91
  "eslint-plugin-import": "2.29.1",
92
92
  "eslint-plugin-import-order": "2.1.4",
93
- "eslint-plugin-n": "16.6.1",
93
+ "eslint-plugin-n": "16.6.2",
94
94
  "eslint-plugin-node": "11.1.0",
95
- "eslint-plugin-prettier": "5.1.2",
95
+ "eslint-plugin-prettier": "5.1.3",
96
96
  "eslint-plugin-promise": "6.1.1",
97
97
  "eslint-plugin-react": "7.33.2",
98
98
  "eslint-plugin-standard": "5.0.0",
@@ -107,7 +107,7 @@
107
107
  "prettier": "3.1.1",
108
108
  "prop-types": "15.8.1",
109
109
  "react-dom": "18.2.0",
110
- "react-icons": "4.12.0",
110
+ "react-icons": "5.0.0",
111
111
  "storybook": "7.6.7",
112
112
  "storybook-addon-themes": "6.1.0",
113
113
  "string-width": "7.0.0",
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { DropDownType } from '../../../types';
3
- declare const DropDown: React.ForwardRefExoticComponent<DropDownType & React.RefAttributes<HTMLInputElement>>;
4
- export default DropDown;
@@ -1,2 +0,0 @@
1
- import DropDown from './drop-down.component';
2
- export { DropDown };
@@ -1,2 +0,0 @@
1
- import DropDown from './drop-down.component';
2
- export { DropDown };