@bunnix/components 0.9.0 → 0.9.2

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 (42) hide show
  1. package/@types/index.d.ts +134 -30
  2. package/README.md +2 -2
  3. package/package.json +1 -1
  4. package/src/components/AccordionGroup.mjs +2 -1
  5. package/src/components/Badge.mjs +18 -4
  6. package/src/components/Button.mjs +7 -9
  7. package/src/components/Card.mjs +37 -0
  8. package/src/components/Checkbox.mjs +5 -7
  9. package/src/components/CodeBlock.mjs +31 -0
  10. package/src/components/ComboBox.mjs +22 -14
  11. package/src/components/Container.mjs +8 -10
  12. package/src/components/DatePicker.mjs +13 -15
  13. package/src/components/Dialog.mjs +35 -4
  14. package/src/components/DropdownMenu.mjs +16 -14
  15. package/src/components/HStack.mjs +11 -3
  16. package/src/components/Icon.mjs +9 -5
  17. package/src/components/InputField.mjs +12 -4
  18. package/src/components/NavigationBar.mjs +55 -25
  19. package/src/components/PageHeader.mjs +11 -8
  20. package/src/components/PageSection.mjs +20 -10
  21. package/src/components/PopoverMenu.mjs +94 -50
  22. package/src/components/RadioCheckbox.mjs +5 -7
  23. package/src/components/SearchBox.mjs +12 -21
  24. package/src/components/Sidebar.mjs +142 -67
  25. package/src/components/Table.mjs +145 -96
  26. package/src/components/Text.mjs +52 -21
  27. package/src/components/TimePicker.mjs +13 -15
  28. package/src/components/ToastNotification.mjs +16 -13
  29. package/src/components/ToggleSwitch.mjs +5 -7
  30. package/src/components/VStack.mjs +7 -6
  31. package/src/index.mjs +2 -0
  32. package/src/styles/buttons.css +8 -0
  33. package/src/styles/colors.css +8 -0
  34. package/src/styles/controls.css +61 -0
  35. package/src/styles/layout.css +64 -5
  36. package/src/styles/media.css +11 -0
  37. package/src/styles/menu.css +39 -21
  38. package/src/styles/table.css +2 -2
  39. package/src/styles/typography.css +25 -0
  40. package/src/styles/variables.css +3 -0
  41. package/src/utils/iconUtils.mjs +10 -0
  42. package/src/utils/sizeUtils.mjs +87 -0
@@ -7,7 +7,7 @@
7
7
 
8
8
  .table th,
9
9
  .table td {
10
- padding: var(--base-padding);
10
+ padding: calc(var(--base-padding) * 0.8) var(--base-padding);
11
11
  vertical-align: middle;
12
12
  border-bottom: 1px solid var(--border-color);
13
13
  }
@@ -32,7 +32,7 @@
32
32
  border: 1px solid var(--border-color);
33
33
  border-radius: var(--base-radius);
34
34
  /* Ensure background colors don't bleed */
35
- overflow: hidden;
35
+ overflow: hidden;
36
36
  }
37
37
 
38
38
  /* Ensure border works with radius on table element */
@@ -71,6 +71,26 @@ h6 {
71
71
  font-size: 1.25rem;
72
72
  }
73
73
 
74
+ .text-uppercase {
75
+ text-transform: uppercase;
76
+ }
77
+
78
+ .text-lowercase {
79
+ text-transform: lowercase;
80
+ }
81
+
82
+ .text-capitalize {
83
+ text-transform: capitalize;
84
+ }
85
+
86
+ .bold {
87
+ font-weight: var(--font-bold);
88
+ }
89
+
90
+ .semibold {
91
+ font-weight: var(--font-semibold);
92
+ }
93
+
74
94
  .font-inherit {
75
95
  font-weight: inherit;
76
96
  font-size: inherit;
@@ -85,6 +105,11 @@ h6 {
85
105
  white-space: pre-line;
86
106
  }
87
107
 
108
+ .no-selectable {
109
+ user-select: none;
110
+ -webkit-user-select: none;
111
+ }
112
+
88
113
  .label {
89
114
  display: block;
90
115
  font-size: var(--font-size);
@@ -18,6 +18,7 @@
18
18
 
19
19
  --border-color: #ccc;
20
20
  --background-color: #fff;
21
+ --background-color-rgb: 255, 255, 255;
21
22
  --alternate-background-color: #f5f5f5;
22
23
  --highlight-background-color: #e5e5e5;
23
24
 
@@ -42,6 +43,7 @@
42
43
 
43
44
  /* Typography */
44
45
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
46
+ --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
45
47
  --font-regular: 400;
46
48
  --font-bold: 600;
47
49
  --font-semibold: 500;
@@ -186,6 +188,7 @@
186
188
 
187
189
  --border-color: #333;
188
190
  --background-color: #000;
191
+ --background-color-rgb: 0, 0, 0;
189
192
  --alternate-background-color: #111;
190
193
  --highlight-background-color: #222;
191
194
 
@@ -0,0 +1,10 @@
1
+ export const resolveIconClass = (value) => {
2
+ if (typeof value !== "string") return "";
3
+ const raw = value.trim();
4
+ if (!raw) return "";
5
+ const parts = raw.split(/\s+/);
6
+ const hasIconClass = parts.some((part) => part.startsWith("icon-"));
7
+ if (hasIconClass) return raw;
8
+ parts[0] = `icon-${parts[0]}`;
9
+ return parts.join(" ");
10
+ };
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Standard size vocabulary for Bunnix components
3
+ * Supported values: xsmall | small | regular | large | xlarge
4
+ * Legacy aliases (xs, sm, md, lg, xl, default) are accepted for compatibility.
5
+ */
6
+
7
+ const sizeAliasMap = {
8
+ xsmall: "xsmall",
9
+ xs: "xsmall",
10
+ small: "small",
11
+ sm: "small",
12
+ regular: "regular",
13
+ md: "regular",
14
+ default: "regular",
15
+ large: "large",
16
+ lg: "large",
17
+ xlarge: "xlarge",
18
+ xl: "xlarge",
19
+ };
20
+
21
+ const sizeTokenMap = {
22
+ xsmall: "xs",
23
+ small: "sm",
24
+ regular: "md",
25
+ large: "lg",
26
+ xlarge: "xl",
27
+ };
28
+
29
+ const sizeOrder = ["xsmall", "small", "regular", "large", "xlarge"];
30
+
31
+ export function toSizeToken(value) {
32
+ const normalized = normalizeSize(value);
33
+ return sizeTokenMap[normalized];
34
+ }
35
+
36
+ /**
37
+ * Normalizes size values to standard vocabulary
38
+ * @param {string} value - The size value to normalize
39
+ * @returns {string} Normalized size value
40
+ */
41
+ export function normalizeSize(value) {
42
+ if (!value) return "regular";
43
+
44
+ // Map legacy values to standard ones
45
+ if (sizeAliasMap[value]) return sizeAliasMap[value];
46
+
47
+ // Validate against standard vocabulary
48
+ if (sizeOrder.includes(value)) return value;
49
+
50
+ // Fallback to medium if invalid
51
+ return "regular";
52
+ }
53
+
54
+ /**
55
+ * Clamps size values to component-specific ranges
56
+ * @param {string} size - The size value to clamp
57
+ * @param {Array<string>} supportedSizes - Array of supported sizes for this component
58
+ * @param {string} defaultSize - Default size if unsupported
59
+ * @returns {string} Clamped size value
60
+ */
61
+ export function clampSize(size, supportedSizes = sizeOrder, defaultSize = "regular") {
62
+ const normalized = normalizeSize(size);
63
+
64
+ // If component supports this size, return it
65
+ if (supportedSizes.includes(normalized)) return normalized;
66
+
67
+ // Prefer explicit default when unsupported (e.g., small -> regular)
68
+ if (supportedSizes.includes(defaultSize)) return defaultSize;
69
+
70
+ // Find closest supported size
71
+ const normalizedIndex = sizeOrder.indexOf(normalized);
72
+ const supportedIndices = supportedSizes.map((s) => sizeOrder.indexOf(s));
73
+
74
+ // Find the closest supported size
75
+ let closestSize = defaultSize;
76
+ let minDistance = Infinity;
77
+
78
+ for (const supportedIndex of supportedIndices) {
79
+ const distance = Math.abs(supportedIndex - normalizedIndex);
80
+ if (distance < minDistance) {
81
+ minDistance = distance;
82
+ closestSize = sizeOrder[supportedIndex];
83
+ }
84
+ }
85
+
86
+ return closestSize;
87
+ }