@creativecodeco/ui 0.1.0 → 0.2.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 (30) hide show
  1. package/lib/theme/css/checkbox.css +47 -0
  2. package/lib/theme/css/main.css +1 -0
  3. package/lib/theme/main.css +373 -1
  4. package/lib/types/helpers/controller.types.d.ts +5 -5
  5. package/lib/types/ui/base/error.types.d.ts +4 -0
  6. package/lib/types/ui/base/index.d.ts +1 -0
  7. package/lib/types/ui/forms/checkbox.types.d.ts +11 -0
  8. package/lib/types/ui/forms/checkbox.types.js +1 -0
  9. package/lib/types/ui/forms/{drop-down.types.d.ts → dropdown.types.d.ts} +3 -3
  10. package/lib/types/ui/forms/dropdown.types.js +1 -0
  11. package/lib/types/ui/forms/index.d.ts +3 -3
  12. package/lib/types/ui/forms/text-box.types.d.ts +2 -4
  13. package/lib/ui/components/avatar/avatar.component.js +2 -2
  14. package/lib/ui/forms/checkbox/checkbox.component.d.ts +4 -0
  15. package/lib/ui/forms/checkbox/checkbox.component.js +14 -0
  16. package/lib/ui/forms/checkbox/index.d.ts +2 -0
  17. package/lib/ui/forms/checkbox/index.js +2 -0
  18. package/lib/ui/forms/dropdown/dropdown.component.d.ts +4 -0
  19. package/lib/ui/forms/{drop-down/drop-down.component.js → dropdown/dropdown.component.js} +2 -2
  20. package/lib/ui/forms/dropdown/index.d.ts +2 -0
  21. package/lib/ui/forms/dropdown/index.js +2 -0
  22. package/lib/ui/forms/index.d.ts +2 -1
  23. package/lib/ui/forms/index.js +2 -1
  24. package/lib/utils/string.utils.d.ts +26 -0
  25. package/lib/utils/string.utils.js +37 -0
  26. package/package.json +14 -14
  27. package/lib/ui/forms/drop-down/drop-down.component.d.ts +0 -4
  28. package/lib/ui/forms/drop-down/index.d.ts +0 -2
  29. package/lib/ui/forms/drop-down/index.js +0 -2
  30. /package/lib/types/ui/{forms/drop-down.types.js → base/error.types.js} +0 -0
@@ -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,5 @@
3
3
  @import 'tailwindcss/utilities';
4
4
 
5
5
  @import './avatar.css';
6
+ @import './checkbox.css';
6
7
  @import './text-box.css';
@@ -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,27 @@ html {
657
657
  --tw-text-opacity: 1;
658
658
  color: var(--fallback-nc,oklch(var(--nc)/var(--tw-text-opacity)));
659
659
  }
660
+
661
+ .table tr.hover:hover,
662
+ .table tr.hover:nth-child(even):hover {
663
+ --tw-bg-opacity: 1;
664
+ background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity)));
665
+ }
666
+ }
667
+ .checkbox {
668
+ flex-shrink: 0;
669
+ --chkbg: var(--fallback-bc,oklch(var(--bc)/1));
670
+ --chkfg: var(--fallback-b1,oklch(var(--b1)/1));
671
+ height: 1.5rem;
672
+ width: 1.5rem;
673
+ cursor: pointer;
674
+ -webkit-appearance: none;
675
+ -moz-appearance: none;
676
+ appearance: none;
677
+ border-radius: var(--rounded-btn, 0.5rem);
678
+ border-width: 1px;
679
+ border-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-border-opacity)));
680
+ --tw-border-opacity: 0.2;
660
681
  }
661
682
  .dropdown {
662
683
  position: relative;
@@ -729,6 +750,15 @@ html {
729
750
  opacity: 1;
730
751
  }
731
752
 
753
+ .btm-nav > *.\!disabled:hover {
754
+ pointer-events: none !important;
755
+ --tw-border-opacity: 0 !important;
756
+ background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity))) !important;
757
+ --tw-bg-opacity: 0.1 !important;
758
+ color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))) !important;
759
+ --tw-text-opacity: 0.2 !important;
760
+ }
761
+
732
762
  .btm-nav > *.disabled:hover,
733
763
  .btm-nav > *[disabled]:hover {
734
764
  pointer-events: none;
@@ -882,6 +912,13 @@ html {
882
912
  user-select: none;
883
913
  color: var(--fallback-bc,oklch(var(--bc)/0.3));
884
914
  }
915
+ .menu li.\!disabled {
916
+ cursor: not-allowed !important;
917
+ -webkit-user-select: none !important;
918
+ -moz-user-select: none !important;
919
+ user-select: none !important;
920
+ color: var(--fallback-bc,oklch(var(--bc)/0.3)) !important;
921
+ }
885
922
  .menu :where(li > .menu-dropdown:not(.menu-dropdown-show)) {
886
923
  display: none;
887
924
  }
@@ -896,6 +933,20 @@ html {
896
933
  :where(.menu li) .badge {
897
934
  justify-self: end;
898
935
  }
936
+ .radio {
937
+ flex-shrink: 0;
938
+ --chkbg: var(--bc);
939
+ height: 1.5rem;
940
+ width: 1.5rem;
941
+ cursor: pointer;
942
+ -webkit-appearance: none;
943
+ -moz-appearance: none;
944
+ appearance: none;
945
+ border-radius: 9999px;
946
+ border-width: 1px;
947
+ border-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-border-opacity)));
948
+ --tw-border-opacity: 0.2;
949
+ }
899
950
  .select {
900
951
  display: inline-flex;
901
952
  cursor: pointer;
@@ -928,6 +979,35 @@ html {
928
979
  .select[multiple] {
929
980
  height: auto;
930
981
  }
982
+ .table {
983
+ position: relative;
984
+ width: 100%;
985
+ border-radius: var(--rounded-box, 1rem);
986
+ text-align: left;
987
+ font-size: 0.875rem;
988
+ line-height: 1.25rem;
989
+ }
990
+ .table :where(.table-pin-rows thead tr) {
991
+ position: sticky;
992
+ top: 0px;
993
+ z-index: 1;
994
+ --tw-bg-opacity: 1;
995
+ background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
996
+ }
997
+ .table :where(.table-pin-rows tfoot tr) {
998
+ position: sticky;
999
+ bottom: 0px;
1000
+ z-index: 1;
1001
+ --tw-bg-opacity: 1;
1002
+ background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
1003
+ }
1004
+ .table :where(.table-pin-cols tr th) {
1005
+ position: sticky;
1006
+ left: 0px;
1007
+ right: 0px;
1008
+ --tw-bg-opacity: 1;
1009
+ background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
1010
+ }
931
1011
  .avatar-group :where(.avatar) {
932
1012
  overflow: hidden;
933
1013
  border-radius: 9999px;
@@ -935,6 +1015,14 @@ html {
935
1015
  --tw-border-opacity: 1;
936
1016
  border-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-border-opacity)));
937
1017
  }
1018
+ .btm-nav > *.\!disabled {
1019
+ pointer-events: none !important;
1020
+ --tw-border-opacity: 0 !important;
1021
+ background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity))) !important;
1022
+ --tw-bg-opacity: 0.1 !important;
1023
+ color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))) !important;
1024
+ --tw-text-opacity: 0.2 !important;
1025
+ }
938
1026
  .btm-nav > *.disabled,
939
1027
  .btm-nav > *[disabled] {
940
1028
  pointer-events: none;
@@ -962,6 +1050,49 @@ html {
962
1050
  transform: scale(1);
963
1051
  }
964
1052
  }
1053
+ .checkbox:focus {
1054
+ box-shadow: none;
1055
+ }
1056
+ .checkbox:focus-visible {
1057
+ outline-style: solid;
1058
+ outline-width: 2px;
1059
+ outline-offset: 2px;
1060
+ outline-color: var(--fallback-bc,oklch(var(--bc)/1));
1061
+ }
1062
+ .checkbox:checked,
1063
+ .checkbox[checked="true"],
1064
+ .checkbox[aria-checked="true"] {
1065
+ background-repeat: no-repeat;
1066
+ animation: checkmark var(--animation-input, 0.2s) ease-out;
1067
+ background-color: var(--chkbg);
1068
+ background-image: linear-gradient(-45deg, transparent 65%, var(--chkbg) 65.99%),
1069
+ linear-gradient(45deg, transparent 75%, var(--chkbg) 75.99%),
1070
+ linear-gradient(-45deg, var(--chkbg) 40%, transparent 40.99%),
1071
+ linear-gradient(
1072
+ 45deg,
1073
+ var(--chkbg) 30%,
1074
+ var(--chkfg) 30.99%,
1075
+ var(--chkfg) 40%,
1076
+ transparent 40.99%
1077
+ ),
1078
+ linear-gradient(-45deg, var(--chkfg) 50%, var(--chkbg) 50.99%);
1079
+ }
1080
+ .checkbox:indeterminate {
1081
+ --tw-bg-opacity: 1;
1082
+ background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity)));
1083
+ background-repeat: no-repeat;
1084
+ animation: checkmark var(--animation-input, 0.2s) ease-out;
1085
+ background-image: linear-gradient(90deg, transparent 80%, var(--chkbg) 80%),
1086
+ linear-gradient(-90deg, transparent 80%, var(--chkbg) 80%),
1087
+ linear-gradient(0deg, var(--chkbg) 43%, var(--chkfg) 43%, var(--chkfg) 57%, var(--chkbg) 57%);
1088
+ }
1089
+ .checkbox:disabled {
1090
+ cursor: not-allowed;
1091
+ border-color: transparent;
1092
+ --tw-bg-opacity: 1;
1093
+ background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity)));
1094
+ opacity: 0.2;
1095
+ }
965
1096
  @keyframes checkmark {
966
1097
 
967
1098
  0% {
@@ -1180,6 +1311,28 @@ html {
1180
1311
  background-position-x: -115%;
1181
1312
  }
1182
1313
  }
1314
+ .radio:focus {
1315
+ box-shadow: none;
1316
+ }
1317
+ .radio:focus-visible {
1318
+ outline-style: solid;
1319
+ outline-width: 2px;
1320
+ outline-offset: 2px;
1321
+ outline-color: var(--fallback-bc,oklch(var(--bc)/1));
1322
+ }
1323
+ .radio:checked,
1324
+ .radio[aria-checked="true"] {
1325
+ --tw-bg-opacity: 1;
1326
+ background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity)));
1327
+ background-image: none;
1328
+ animation: radiomark var(--animation-input, 0.2s) ease-out;
1329
+ box-shadow: 0 0 0 4px var(--fallback-b1,oklch(var(--b1)/1)) inset,
1330
+ 0 0 0 4px var(--fallback-b1,oklch(var(--b1)/1)) inset;
1331
+ }
1332
+ .radio:disabled {
1333
+ cursor: not-allowed;
1334
+ opacity: 0.2;
1335
+ }
1183
1336
  @keyframes radiomark {
1184
1337
 
1185
1338
  0% {
@@ -1259,6 +1412,35 @@ html {
1259
1412
  background-position: -50%;
1260
1413
  }
1261
1414
  }
1415
+ :is([dir="rtl"] .table) {
1416
+ text-align: right;
1417
+ }
1418
+ .table :where(th, td) {
1419
+ padding-left: 1rem;
1420
+ padding-right: 1rem;
1421
+ padding-top: 0.75rem;
1422
+ padding-bottom: 0.75rem;
1423
+ vertical-align: middle;
1424
+ }
1425
+ .table tr.active,
1426
+ .table tr.active:nth-child(even),
1427
+ .table-zebra tbody tr:nth-child(even) {
1428
+ --tw-bg-opacity: 1;
1429
+ background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity)));
1430
+ }
1431
+ .table :where(thead, tbody) :where(tr:not(:last-child)),
1432
+ .table :where(thead, tbody) :where(tr:first-child:last-child) {
1433
+ border-bottom-width: 1px;
1434
+ --tw-border-opacity: 1;
1435
+ border-bottom-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-border-opacity)));
1436
+ }
1437
+ .table :where(thead, tfoot) {
1438
+ white-space: nowrap;
1439
+ font-size: 0.75rem;
1440
+ line-height: 1rem;
1441
+ font-weight: 700;
1442
+ color: var(--fallback-bc,oklch(var(--bc)/0.6));
1443
+ }
1262
1444
  @keyframes toast-pop {
1263
1445
 
1264
1446
  0% {
@@ -1359,9 +1541,15 @@ html {
1359
1541
  .flex {
1360
1542
  display: flex;
1361
1543
  }
1544
+ .table {
1545
+ display: table;
1546
+ }
1362
1547
  .w-full {
1363
1548
  width: 100%;
1364
1549
  }
1550
+ .cursor-not-allowed {
1551
+ cursor: not-allowed;
1552
+ }
1365
1553
  .cursor-pointer {
1366
1554
  cursor: pointer;
1367
1555
  }
@@ -1435,6 +1623,190 @@ html {
1435
1623
  --tw-ring-offset-width: 2px;
1436
1624
  --tw-ring-offset-color: var(--fallback-b1,oklch(var(--b1)/1));
1437
1625
  }
1626
+ @media (hover:hover) {
1627
+
1628
+ .checkbox-color-primary:hover {
1629
+ --tw-border-opacity: 1;
1630
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1631
+ }
1632
+ }
1633
+ .checkbox-color-primary {
1634
+ --chkbg: var(--fallback-p,oklch(var(--p)/1));
1635
+ --chkfg: var(--fallback-pc,oklch(var(--pc)/1));
1636
+ --tw-border-opacity: 1;
1637
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1638
+ }
1639
+ .checkbox-color-primary:focus-visible {
1640
+ outline-color: var(--fallback-p,oklch(var(--p)/1));
1641
+ }
1642
+ .checkbox-color-primary:checked,.checkbox-color-primary[checked="true"],.checkbox-color-primary[aria-checked="true"] {
1643
+ --tw-border-opacity: 1;
1644
+ border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity)));
1645
+ --tw-bg-opacity: 1;
1646
+ background-color: var(--fallback-p,oklch(var(--p)/var(--tw-bg-opacity)));
1647
+ --tw-text-opacity: 1;
1648
+ color: var(--fallback-pc,oklch(var(--pc)/var(--tw-text-opacity)));
1649
+ }
1650
+ @media (hover:hover) {
1651
+
1652
+ .checkbox-color-secondary:hover {
1653
+ --tw-border-opacity: 1;
1654
+ border-color: var(--fallback-s,oklch(var(--s)/var(--tw-border-opacity)));
1655
+ }
1656
+ }
1657
+ .checkbox-color-secondary {
1658
+ --chkbg: var(--fallback-s,oklch(var(--s)/1));
1659
+ --chkfg: var(--fallback-sc,oklch(var(--sc)/1));
1660
+ --tw-border-opacity: 1;
1661
+ border-color: var(--fallback-s,oklch(var(--s)/var(--tw-border-opacity)));
1662
+ }
1663
+ .checkbox-color-secondary:focus-visible {
1664
+ outline-color: var(--fallback-s,oklch(var(--s)/1));
1665
+ }
1666
+ .checkbox-color-secondary:checked,.checkbox-color-secondary[checked="true"],.checkbox-color-secondary[aria-checked="true"] {
1667
+ --tw-border-opacity: 1;
1668
+ border-color: var(--fallback-s,oklch(var(--s)/var(--tw-border-opacity)));
1669
+ --tw-bg-opacity: 1;
1670
+ background-color: var(--fallback-s,oklch(var(--s)/var(--tw-bg-opacity)));
1671
+ --tw-text-opacity: 1;
1672
+ color: var(--fallback-sc,oklch(var(--sc)/var(--tw-text-opacity)));
1673
+ }
1674
+ @media (hover:hover) {
1675
+
1676
+ .checkbox-color-accent:hover {
1677
+ --tw-border-opacity: 1;
1678
+ border-color: var(--fallback-a,oklch(var(--a)/var(--tw-border-opacity)));
1679
+ }
1680
+ }
1681
+ .checkbox-color-accent {
1682
+ --chkbg: var(--fallback-a,oklch(var(--a)/1));
1683
+ --chkfg: var(--fallback-ac,oklch(var(--ac)/1));
1684
+ --tw-border-opacity: 1;
1685
+ border-color: var(--fallback-a,oklch(var(--a)/var(--tw-border-opacity)));
1686
+ }
1687
+ .checkbox-color-accent:focus-visible {
1688
+ outline-color: var(--fallback-a,oklch(var(--a)/1));
1689
+ }
1690
+ .checkbox-color-accent:checked,.checkbox-color-accent[checked="true"],.checkbox-color-accent[aria-checked="true"] {
1691
+ --tw-border-opacity: 1;
1692
+ border-color: var(--fallback-a,oklch(var(--a)/var(--tw-border-opacity)));
1693
+ --tw-bg-opacity: 1;
1694
+ background-color: var(--fallback-a,oklch(var(--a)/var(--tw-bg-opacity)));
1695
+ --tw-text-opacity: 1;
1696
+ color: var(--fallback-ac,oklch(var(--ac)/var(--tw-text-opacity)));
1697
+ }
1698
+ @media (hover:hover) {
1699
+
1700
+ .checkbox-color-success:hover {
1701
+ --tw-border-opacity: 1;
1702
+ border-color: var(--fallback-su,oklch(var(--su)/var(--tw-border-opacity)));
1703
+ }
1704
+ }
1705
+ .checkbox-color-success {
1706
+ --chkbg: var(--fallback-su,oklch(var(--su)/1));
1707
+ --chkfg: var(--fallback-suc,oklch(var(--suc)/1));
1708
+ --tw-border-opacity: 1;
1709
+ border-color: var(--fallback-su,oklch(var(--su)/var(--tw-border-opacity)));
1710
+ }
1711
+ .checkbox-color-success:focus-visible {
1712
+ outline-color: var(--fallback-su,oklch(var(--su)/1));
1713
+ }
1714
+ .checkbox-color-success:checked,.checkbox-color-success[checked="true"],.checkbox-color-success[aria-checked="true"] {
1715
+ --tw-border-opacity: 1;
1716
+ border-color: var(--fallback-su,oklch(var(--su)/var(--tw-border-opacity)));
1717
+ --tw-bg-opacity: 1;
1718
+ background-color: var(--fallback-su,oklch(var(--su)/var(--tw-bg-opacity)));
1719
+ --tw-text-opacity: 1;
1720
+ color: var(--fallback-suc,oklch(var(--suc)/var(--tw-text-opacity)));
1721
+ }
1722
+ @media (hover:hover) {
1723
+
1724
+ .checkbox-color-warning:hover {
1725
+ --tw-border-opacity: 1;
1726
+ border-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-border-opacity)));
1727
+ }
1728
+ }
1729
+ .checkbox-color-warning {
1730
+ --chkbg: var(--fallback-wa,oklch(var(--wa)/1));
1731
+ --chkfg: var(--fallback-wac,oklch(var(--wac)/1));
1732
+ --tw-border-opacity: 1;
1733
+ border-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-border-opacity)));
1734
+ }
1735
+ .checkbox-color-warning:focus-visible {
1736
+ outline-color: var(--fallback-wa,oklch(var(--wa)/1));
1737
+ }
1738
+ .checkbox-color-warning:checked,.checkbox-color-warning[checked="true"],.checkbox-color-warning[aria-checked="true"] {
1739
+ --tw-border-opacity: 1;
1740
+ border-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-border-opacity)));
1741
+ --tw-bg-opacity: 1;
1742
+ background-color: var(--fallback-wa,oklch(var(--wa)/var(--tw-bg-opacity)));
1743
+ --tw-text-opacity: 1;
1744
+ color: var(--fallback-wac,oklch(var(--wac)/var(--tw-text-opacity)));
1745
+ }
1746
+ @media (hover:hover) {
1747
+
1748
+ .checkbox-color-info:hover {
1749
+ --tw-border-opacity: 1;
1750
+ border-color: var(--fallback-in,oklch(var(--in)/var(--tw-border-opacity)));
1751
+ }
1752
+ }
1753
+ .checkbox-color-info {
1754
+ --chkbg: var(--fallback-in,oklch(var(--in)/1));
1755
+ --chkfg: var(--fallback-inc,oklch(var(--inc)/1));
1756
+ --tw-border-opacity: 1;
1757
+ border-color: var(--fallback-in,oklch(var(--in)/var(--tw-border-opacity)));
1758
+ }
1759
+ .checkbox-color-info:focus-visible {
1760
+ outline-color: var(--fallback-in,oklch(var(--in)/1));
1761
+ }
1762
+ .checkbox-color-info:checked,.checkbox-color-info[checked="true"],.checkbox-color-info[aria-checked="true"] {
1763
+ --tw-border-opacity: 1;
1764
+ border-color: var(--fallback-in,oklch(var(--in)/var(--tw-border-opacity)));
1765
+ --tw-bg-opacity: 1;
1766
+ background-color: var(--fallback-in,oklch(var(--in)/var(--tw-bg-opacity)));
1767
+ --tw-text-opacity: 1;
1768
+ color: var(--fallback-inc,oklch(var(--inc)/var(--tw-text-opacity)));
1769
+ }
1770
+ @media (hover:hover) {
1771
+
1772
+ .checkbox-color-error:hover {
1773
+ --tw-border-opacity: 1;
1774
+ border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity)));
1775
+ }
1776
+ }
1777
+ .checkbox-color-error {
1778
+ --chkbg: var(--fallback-er,oklch(var(--er)/1));
1779
+ --chkfg: var(--fallback-erc,oklch(var(--erc)/1));
1780
+ --tw-border-opacity: 1;
1781
+ border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity)));
1782
+ }
1783
+ .checkbox-color-error:focus-visible {
1784
+ outline-color: var(--fallback-er,oklch(var(--er)/1));
1785
+ }
1786
+ .checkbox-color-error:checked,.checkbox-color-error[checked="true"],.checkbox-color-error[aria-checked="true"] {
1787
+ --tw-border-opacity: 1;
1788
+ border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity)));
1789
+ --tw-bg-opacity: 1;
1790
+ background-color: var(--fallback-er,oklch(var(--er)/var(--tw-bg-opacity)));
1791
+ --tw-text-opacity: 1;
1792
+ color: var(--fallback-erc,oklch(var(--erc)/var(--tw-text-opacity)));
1793
+ }
1794
+ [type="checkbox"].checkbox-size-xs {
1795
+ height: 1rem;
1796
+ width: 1rem;
1797
+ }
1798
+ [type="checkbox"].checkbox-size-sm {
1799
+ height: 1.25rem;
1800
+ width: 1.25rem;
1801
+ }
1802
+ [type="checkbox"].checkbox-size-md {
1803
+ height: 1.5rem;
1804
+ width: 1.5rem;
1805
+ }
1806
+ [type="checkbox"].checkbox-size-lg {
1807
+ height: 2rem;
1808
+ width: 2rem;
1809
+ }
1438
1810
  .text-box-size-xs {
1439
1811
  height: 1.5rem;
1440
1812
  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 {};
@@ -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';
@@ -0,0 +1,11 @@
1
+ import type { ErrorType, SizeType } from '../../../types';
2
+ export interface CheckboxType extends ErrorType {
3
+ name: string;
4
+ label?: string;
5
+ checked?: boolean;
6
+ position?: 'left' | 'right';
7
+ color?: 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'info' | 'error';
8
+ size?: SizeType;
9
+ disabled?: boolean;
10
+ }
11
+ 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,3 @@
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 './text-box.types';
@@ -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,14 @@
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, 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', {
6
+ [`checkbox-color-${color}`]: color,
7
+ [`checkbox-size-${size}`]: size
8
+ }), disabled: disabled, ...otherProps }));
9
+ return (_jsxs(_Fragment, { children: [_jsxs("label", { className: cls('label', {
10
+ 'cursor-pointer': !disabled,
11
+ 'cursor-not-allowed': disabled
12
+ }), children: [position === 'left' && checkbox(), label && _jsx("span", { className: 'label-text', children: label }), position === 'right' && checkbox()] }), isError && _jsx("p", { className: 'text-red-500', children: error })] }));
13
+ });
14
+ 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,3 @@
1
- export * from '../../ui/forms/drop-down';
1
+ export * from '../../ui/forms/checkbox';
2
+ export * from '../../ui/forms/dropdown';
2
3
  export * from '../../ui/forms/text-box';
@@ -1,2 +1,3 @@
1
- export * from '../../ui/forms/drop-down';
1
+ export * from '../../ui/forms/checkbox';
2
+ export * from '../../ui/forms/dropdown';
2
3
  export * from '../../ui/forms/text-box';
@@ -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.2.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 };