@codefast/ui 0.3.11-canary.1 → 0.3.11

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 (149) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +34 -14
  3. package/dist/components/accordion.d.ts +29 -10
  4. package/dist/components/accordion.js +38 -37
  5. package/dist/components/alert-dialog.d.ts +60 -24
  6. package/dist/components/alert-dialog.js +69 -72
  7. package/dist/components/alert.d.ts +27 -15
  8. package/dist/components/alert.js +29 -31
  9. package/dist/components/aspect-ratio.d.ts +8 -4
  10. package/dist/components/aspect-ratio.js +7 -5
  11. package/dist/components/avatar.d.ts +17 -6
  12. package/dist/components/avatar.js +19 -17
  13. package/dist/components/badge.d.ts +21 -14
  14. package/dist/components/badge.js +19 -22
  15. package/dist/components/breadcrumb.d.ts +35 -12
  16. package/dist/components/breadcrumb.js +48 -54
  17. package/dist/components/button-group.d.ts +29 -14
  18. package/dist/components/button-group.js +27 -32
  19. package/dist/components/button.d.ts +35 -25
  20. package/dist/components/button.js +50 -48
  21. package/dist/components/calendar.d.ts +24 -9
  22. package/dist/components/calendar.js +92 -98
  23. package/dist/components/card.d.ts +34 -10
  24. package/dist/components/card.js +39 -37
  25. package/dist/components/carousel.d.ts +55 -24
  26. package/dist/components/carousel.js +113 -130
  27. package/dist/components/chart.d.ts +72 -36
  28. package/dist/components/chart.js +154 -166
  29. package/dist/components/checkbox-cards.d.ts +15 -8
  30. package/dist/components/checkbox-cards.js +22 -25
  31. package/dist/components/checkbox-group.d.ts +16 -8
  32. package/dist/components/checkbox-group.js +19 -19
  33. package/dist/components/checkbox.d.ts +9 -4
  34. package/dist/components/checkbox.js +14 -14
  35. package/dist/components/collapsible.d.ts +14 -6
  36. package/dist/components/collapsible.js +18 -16
  37. package/dist/components/command.d.ts +55 -23
  38. package/dist/components/command.js +70 -85
  39. package/dist/components/context-menu.d.ts +72 -22
  40. package/dist/components/context-menu.js +88 -109
  41. package/dist/components/dialog.d.ts +53 -22
  42. package/dist/components/dialog.js +71 -85
  43. package/dist/components/drawer.d.ts +60 -28
  44. package/dist/components/drawer.js +59 -67
  45. package/dist/components/dropdown-menu.d.ts +73 -22
  46. package/dist/components/dropdown-menu.js +95 -112
  47. package/dist/components/empty.d.ts +37 -15
  48. package/dist/components/empty.js +43 -45
  49. package/dist/components/field.d.ts +63 -25
  50. package/dist/components/field.js +88 -104
  51. package/dist/components/form.d.ts +37 -15
  52. package/dist/components/form.js +65 -70
  53. package/dist/components/hover-card.d.ts +21 -7
  54. package/dist/components/hover-card.js +24 -24
  55. package/dist/components/input-group.d.ts +53 -28
  56. package/dist/components/input-group.js +63 -77
  57. package/dist/components/input-number.d.ts +28 -7
  58. package/dist/components/input-number.js +55 -59
  59. package/dist/components/input-otp.d.ts +24 -10
  60. package/dist/components/input-otp.js +33 -37
  61. package/dist/components/input-password.d.ts +12 -5
  62. package/dist/components/input-password.js +31 -32
  63. package/dist/components/input-search.d.ts +18 -8
  64. package/dist/components/input-search.js +43 -41
  65. package/dist/components/input.d.ts +10 -4
  66. package/dist/components/input.js +9 -7
  67. package/dist/components/item.d.ts +69 -32
  68. package/dist/components/item.js +89 -92
  69. package/dist/components/kbd.d.ts +13 -5
  70. package/dist/components/kbd.js +13 -11
  71. package/dist/components/label.d.ts +9 -4
  72. package/dist/components/label.js +9 -7
  73. package/dist/components/menubar.d.ts +80 -23
  74. package/dist/components/menubar.js +97 -118
  75. package/dist/components/native-select.d.ts +16 -6
  76. package/dist/components/native-select.js +25 -26
  77. package/dist/components/navigation-menu.d.ts +36 -12
  78. package/dist/components/navigation-menu.js +60 -75
  79. package/dist/components/pagination.d.ts +35 -14
  80. package/dist/components/pagination.js +54 -69
  81. package/dist/components/popover.d.ts +24 -8
  82. package/dist/components/popover.js +28 -28
  83. package/dist/components/progress-circle.d.ts +106 -88
  84. package/dist/components/progress-circle.js +106 -138
  85. package/dist/components/progress.d.ts +10 -4
  86. package/dist/components/progress.js +14 -14
  87. package/dist/components/radio-cards.d.ts +10 -4
  88. package/dist/components/radio-cards.js +22 -23
  89. package/dist/components/radio-group.d.ts +13 -5
  90. package/dist/components/radio-group.js +18 -16
  91. package/dist/components/radio.d.ts +12 -5
  92. package/dist/components/radio.js +10 -8
  93. package/dist/components/resizable.d.ts +18 -7
  94. package/dist/components/resizable.js +22 -22
  95. package/dist/components/scroll-area.d.ts +33 -20
  96. package/dist/components/scroll-area.js +84 -88
  97. package/dist/components/select.d.ts +50 -16
  98. package/dist/components/select.js +77 -96
  99. package/dist/components/separator.d.ts +29 -19
  100. package/dist/components/separator.js +36 -34
  101. package/dist/components/sheet.d.ts +62 -29
  102. package/dist/components/sheet.js +79 -100
  103. package/dist/components/sidebar.d.ts +160 -66
  104. package/dist/components/sidebar.js +294 -336
  105. package/dist/components/skeleton.d.ts +9 -4
  106. package/dist/components/skeleton.js +8 -6
  107. package/dist/components/slider.d.ts +13 -4
  108. package/dist/components/slider.js +34 -40
  109. package/dist/components/sonner.d.ts +10 -7
  110. package/dist/components/sonner.js +16 -14
  111. package/dist/components/spinner.d.ts +12 -5
  112. package/dist/components/spinner.js +33 -35
  113. package/dist/components/switch.d.ts +9 -4
  114. package/dist/components/switch.js +13 -11
  115. package/dist/components/table.d.ts +37 -11
  116. package/dist/components/table.js +47 -45
  117. package/dist/components/tabs.d.ts +21 -7
  118. package/dist/components/tabs.js +24 -22
  119. package/dist/components/textarea.d.ts +9 -4
  120. package/dist/components/textarea.js +8 -6
  121. package/dist/components/toggle-group.d.ts +24 -9
  122. package/dist/components/toggle-group.js +41 -42
  123. package/dist/components/toggle.d.ts +25 -17
  124. package/dist/components/toggle.js +30 -28
  125. package/dist/components/tooltip.d.ts +24 -8
  126. package/dist/components/tooltip.js +29 -32
  127. package/dist/hooks/use-animated-value.d.ts +4 -1
  128. package/dist/hooks/use-animated-value.js +57 -36
  129. package/dist/hooks/use-copy-to-clipboard.d.ts +11 -5
  130. package/dist/hooks/use-copy-to-clipboard.js +39 -20
  131. package/dist/hooks/use-is-mobile.d.ts +4 -1
  132. package/dist/hooks/use-is-mobile.js +21 -1
  133. package/dist/hooks/use-media-query.d.ts +4 -1
  134. package/dist/hooks/use-media-query.js +45 -18
  135. package/dist/hooks/use-mutation-observer.d.ts +6 -2
  136. package/dist/hooks/use-mutation-observer.js +34 -16
  137. package/dist/hooks/use-pagination.d.ts +22 -14
  138. package/dist/hooks/use-pagination.js +100 -49
  139. package/dist/index.d.ts +69 -130
  140. package/dist/index.js +11 -11
  141. package/dist/primitives/checkbox-group.d.ts +105 -83
  142. package/dist/primitives/checkbox-group.js +111 -84
  143. package/dist/primitives/input-number.d.ts +51 -40
  144. package/dist/primitives/input-number.js +483 -350
  145. package/dist/primitives/input.d.ts +48 -42
  146. package/dist/primitives/input.js +65 -43
  147. package/dist/primitives/progress-circle.d.ts +79 -48
  148. package/dist/primitives/progress-circle.js +154 -105
  149. package/package.json +6 -7
@@ -1,129 +1,178 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { createContextScope } from "@radix-ui/react-context";
4
3
  import { useId, useMemo } from "react";
4
+ import { createContextScope } from "@radix-ui/react-context";
5
+ //#region src/primitives/progress-circle.tsx
5
6
  const PROGRESS_CIRCLE_PROVIDER_NAME = "ProgressCircleProvider";
6
7
  const [createProgressCircleContext, createProgressCircleScope] = createContextScope(PROGRESS_CIRCLE_PROVIDER_NAME);
7
8
  const [ProgressCircleContextProvider, useProgressCircleContext] = createProgressCircleContext(PROGRESS_CIRCLE_PROVIDER_NAME);
9
+ /**
10
+ * Provides context for the ProgressCircle component
11
+ *
12
+ * Manages calculations for rendering the circular progress indicator,
13
+ * including value clamping, sizing, thresholds, and indeterminate state.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <ProgressCircleProvider
18
+ * value={75}
19
+ * min={0}
20
+ * max={100}
21
+ * size={64}
22
+ * thresholds={[
23
+ * { value: 30, color: 'red', background: 'pink' },
24
+ * { value: 70, color: 'yellow', background: 'lightyellow' },
25
+ * { value: 100, color: 'green', background: 'lightgreen' }
26
+ * ]}
27
+ * >
28
+ * <ProgressCircleSVG>
29
+ * <ProgressCircleIndicator />
30
+ * <ProgressCircleTrack />
31
+ * </ProgressCircleSVG>
32
+ * <ProgressCircleValue />
33
+ * </ProgressCircleProvider>
34
+ * ```
35
+ */
8
36
  function ProgressCircleProvider({ __scopeProgressCircle, children, formatValue, id: propertyId, max = 100, min = 0, size = 48, startAngle = -90, strokeWidth = 4, thresholds, value }) {
9
- const uniqueId = useId();
10
- const id = propertyId ?? uniqueId;
11
- const validSize = Math.max(0, size);
12
- const validStrokeWidth = Math.max(0, strokeWidth);
13
- const validStartAngle = startAngle % 360;
14
- let validMin = min;
15
- let validMax = max;
16
- if (validMin > validMax) [validMin, validMax] = [
17
- validMax,
18
- validMin
19
- ];
20
- const isIndeterminate = null == value;
21
- const clampedValue = isIndeterminate ? void 0 : clamp(validMin, validMax, value);
22
- const range = validMax - validMin;
23
- const percentage = void 0 !== clampedValue && range > 0 ? (clampedValue - validMin) / range * 100 : 0;
24
- const valueText = void 0 !== clampedValue && formatValue ? formatValue(clampedValue) : `${Math.round(percentage).toString()}%`;
25
- const sortedThresholds = useMemo(()=>thresholds && thresholds.length > 0 ? [
26
- ...thresholds
27
- ].toSorted((a, b)=>a.value - b.value) : [], [
28
- thresholds
29
- ]);
30
- const threshold = useMemo(()=>{
31
- if (void 0 === clampedValue) return;
32
- for (const sortedThreshold of sortedThresholds)if (clampedValue <= sortedThreshold.value) return sortedThreshold;
33
- return sortedThresholds.at(-1);
34
- }, [
35
- sortedThresholds,
36
- clampedValue
37
- ]);
38
- const center = validSize / 2;
39
- const radius = Math.max(0, center - validStrokeWidth / 2);
40
- const circumference = 2 * Math.PI * radius;
41
- const strokeDashoffset = circumference - percentage / 100 * circumference;
42
- const rotationTransform = `rotate(${validStartAngle.toString()}, 0, 0)`;
43
- return /*#__PURE__*/ jsx(ProgressCircleContextProvider, {
44
- center: center,
45
- circumference: circumference,
46
- clampedValue: clampedValue,
47
- id: id,
48
- max: validMax,
49
- min: validMin,
50
- radius: radius,
51
- rotationTransform: rotationTransform,
52
- scope: __scopeProgressCircle,
53
- size: validSize,
54
- strokeDashoffset: strokeDashoffset,
55
- strokeWidth: validStrokeWidth,
56
- threshold: threshold,
57
- value: value ?? 0,
58
- valueText: valueText,
59
- children: children
60
- });
37
+ const uniqueId = useId();
38
+ const id = propertyId ?? uniqueId;
39
+ const validSize = Math.max(0, size);
40
+ const validStrokeWidth = Math.max(0, strokeWidth);
41
+ const validStartAngle = startAngle % 360;
42
+ let validMin = min;
43
+ let validMax = max;
44
+ if (validMin > validMax) [validMin, validMax] = [validMax, validMin];
45
+ const clampedValue = value === null || value === void 0 ? void 0 : clamp(validMin, validMax, value);
46
+ const range = validMax - validMin;
47
+ const percentage = clampedValue !== void 0 && range > 0 ? (clampedValue - validMin) / range * 100 : 0;
48
+ const valueText = clampedValue !== void 0 && formatValue ? formatValue(clampedValue) : `${Math.round(percentage).toString()}%`;
49
+ const sortedThresholds = useMemo(() => thresholds && thresholds.length > 0 ? [...thresholds].toSorted((a, b) => a.value - b.value) : [], [thresholds]);
50
+ const threshold = useMemo(() => {
51
+ if (clampedValue === void 0) return;
52
+ for (const sortedThreshold of sortedThresholds) if (clampedValue <= sortedThreshold.value) return sortedThreshold;
53
+ return sortedThresholds.at(-1);
54
+ }, [sortedThresholds, clampedValue]);
55
+ const center = validSize / 2;
56
+ const radius = Math.max(0, center - validStrokeWidth / 2);
57
+ const circumference = 2 * Math.PI * radius;
58
+ const strokeDashoffset = circumference - percentage / 100 * circumference;
59
+ const rotationTransform = `rotate(${validStartAngle.toString()}, 0, 0)`;
60
+ return /* @__PURE__ */ jsx(ProgressCircleContextProvider, {
61
+ center,
62
+ circumference,
63
+ clampedValue,
64
+ id,
65
+ max: validMax,
66
+ min: validMin,
67
+ radius,
68
+ rotationTransform,
69
+ scope: __scopeProgressCircle,
70
+ size: validSize,
71
+ strokeDashoffset,
72
+ strokeWidth: validStrokeWidth,
73
+ threshold,
74
+ value: value ?? 0,
75
+ valueText,
76
+ children
77
+ });
61
78
  }
79
+ /**
80
+ * Root component for the progress circle
81
+ *
82
+ * Serves as a wrapper for other progress circle components.
83
+ */
62
84
  function ProgressCircle({ __scopeProgressCircle, ...props }) {
63
- return /*#__PURE__*/ jsx("div", {
64
- ...props
65
- });
85
+ return /* @__PURE__ */ jsx("div", { ...props });
66
86
  }
67
87
  const PROGRESS_CIRCLE_SVG_NAME = "ProgressCircleSVG";
88
+ /**
89
+ * SVG container for the progress circle
90
+ *
91
+ * Renders the SVG with accessibility attributes and supports indeterminate state.
92
+ */
68
93
  function ProgressCircleSVG({ __scopeProgressCircle, ...props }) {
69
- const { clampedValue, id, max, min, size, valueText } = useProgressCircleContext(PROGRESS_CIRCLE_SVG_NAME, __scopeProgressCircle);
70
- return /*#__PURE__*/ jsx("svg", {
71
- "aria-label": "Progress",
72
- "aria-valuemax": max,
73
- "aria-valuemin": min,
74
- "aria-valuenow": clampedValue,
75
- "aria-valuetext": void 0 === clampedValue ? void 0 : valueText,
76
- height: size,
77
- id: id,
78
- role: "progressbar",
79
- viewBox: `0 0 ${size.toString()} ${size.toString()}`,
80
- width: size,
81
- ...props
82
- });
94
+ const { clampedValue, id, max, min, size, valueText } = useProgressCircleContext(PROGRESS_CIRCLE_SVG_NAME, __scopeProgressCircle);
95
+ return /* @__PURE__ */ jsx("svg", {
96
+ "aria-label": "Progress",
97
+ "aria-valuemax": max,
98
+ "aria-valuemin": min,
99
+ "aria-valuenow": clampedValue,
100
+ "aria-valuetext": clampedValue === void 0 ? void 0 : valueText,
101
+ height: size,
102
+ id,
103
+ role: "progressbar",
104
+ viewBox: `0 0 ${size.toString()} ${size.toString()}`,
105
+ width: size,
106
+ ...props
107
+ });
83
108
  }
84
109
  const PROGRESS_CIRCLE_TRACK_NAME = "ProgressCircleTrack";
110
+ /**
111
+ * Background circle for the progress indicator
112
+ *
113
+ * Renders the static track of the progress circle.
114
+ */
85
115
  function ProgressCircleTrack({ __scopeProgressCircle, ...props }) {
86
- const { center, radius, strokeWidth, threshold } = useProgressCircleContext(PROGRESS_CIRCLE_TRACK_NAME, __scopeProgressCircle);
87
- return /*#__PURE__*/ jsx("circle", {
88
- cx: center,
89
- cy: center,
90
- fill: "transparent",
91
- r: radius,
92
- stroke: threshold?.background ?? "currentColor",
93
- strokeWidth: strokeWidth,
94
- ...props
95
- });
116
+ const { center, radius, strokeWidth, threshold } = useProgressCircleContext(PROGRESS_CIRCLE_TRACK_NAME, __scopeProgressCircle);
117
+ return /* @__PURE__ */ jsx("circle", {
118
+ cx: center,
119
+ cy: center,
120
+ fill: "transparent",
121
+ r: radius,
122
+ stroke: threshold?.background ?? "currentColor",
123
+ strokeWidth,
124
+ ...props
125
+ });
96
126
  }
97
127
  const PROGRESS_CIRCLE_INDICATOR_NAME = "ProgressCircleIndicator";
128
+ /**
129
+ * Foreground circle showing progress
130
+ *
131
+ * Renders the dynamic progress indicator with stroke dash properties.
132
+ */
98
133
  function ProgressCircleIndicator({ __scopeProgressCircle, ...props }) {
99
- const { center, circumference, radius, rotationTransform, strokeDashoffset, strokeWidth, threshold } = useProgressCircleContext(PROGRESS_CIRCLE_INDICATOR_NAME, __scopeProgressCircle);
100
- return /*#__PURE__*/ jsx("circle", {
101
- cx: center,
102
- cy: center,
103
- fill: "transparent",
104
- r: radius,
105
- stroke: threshold?.color ?? "currentColor",
106
- strokeDasharray: circumference,
107
- strokeDashoffset: strokeDashoffset,
108
- strokeLinecap: "round",
109
- strokeWidth: strokeWidth,
110
- transform: rotationTransform,
111
- ...props
112
- });
134
+ const { center, circumference, radius, rotationTransform, strokeDashoffset, strokeWidth, threshold } = useProgressCircleContext(PROGRESS_CIRCLE_INDICATOR_NAME, __scopeProgressCircle);
135
+ return /* @__PURE__ */ jsx("circle", {
136
+ cx: center,
137
+ cy: center,
138
+ fill: "transparent",
139
+ r: radius,
140
+ stroke: threshold?.color ?? "currentColor",
141
+ strokeDasharray: circumference,
142
+ strokeDashoffset,
143
+ strokeLinecap: "round",
144
+ strokeWidth,
145
+ transform: rotationTransform,
146
+ ...props
147
+ });
113
148
  }
114
149
  const PROGRESS_CIRCLE_VALUE_NAME = "ProgressCircleValue";
150
+ /**
151
+ * Displays the current progress value
152
+ *
153
+ * Supports custom content or default value text rendering.
154
+ */
115
155
  function ProgressCircleValue({ __scopeProgressCircle, children, ...props }) {
116
- const { clampedValue, valueText } = useProgressCircleContext(PROGRESS_CIRCLE_VALUE_NAME, __scopeProgressCircle);
117
- if ("function" == typeof children) return children({
118
- value: clampedValue,
119
- valueText
120
- });
121
- return /*#__PURE__*/ jsx("div", {
122
- ...props,
123
- children: children ?? valueText
124
- });
156
+ const { clampedValue, valueText } = useProgressCircleContext(PROGRESS_CIRCLE_VALUE_NAME, __scopeProgressCircle);
157
+ if (typeof children === "function") return children({
158
+ value: clampedValue,
159
+ valueText
160
+ });
161
+ return /* @__PURE__ */ jsx("div", {
162
+ ...props,
163
+ children: children ?? valueText
164
+ });
125
165
  }
166
+ /**
167
+ * Clamps a value within a specified min/max range
168
+ *
169
+ * @param min - Minimum value
170
+ * @param max - Maximum value
171
+ * @param value - Value to clamp
172
+ * @returns Clamped value
173
+ */
126
174
  function clamp(min, max, value) {
127
- return Math.min(max, Math.max(min, value));
175
+ return Math.min(max, Math.max(min, value));
128
176
  }
129
- export { ProgressCircleIndicator as Indicator, ProgressCircle, ProgressCircleIndicator, ProgressCircleProvider, ProgressCircleSVG, ProgressCircleTrack, ProgressCircleValue, ProgressCircleProvider as Provider, ProgressCircle as Root, ProgressCircleSVG as SVG, ProgressCircleTrack as Track, ProgressCircleValue as Value, createProgressCircleScope };
177
+ //#endregion
178
+ export { ProgressCircleIndicator as Indicator, ProgressCircleIndicator, ProgressCircle, ProgressCircle as Root, ProgressCircleProvider, ProgressCircleProvider as Provider, ProgressCircleSVG, ProgressCircleSVG as SVG, ProgressCircleTrack, ProgressCircleTrack as Track, ProgressCircleValue, ProgressCircleValue as Value, createProgressCircleScope };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codefast/ui",
3
- "version": "0.3.11-canary.1",
3
+ "version": "0.3.11",
4
4
  "description": "Core UI components library built with React and Tailwind CSS",
5
5
  "keywords": [
6
6
  "components",
@@ -382,11 +382,9 @@
382
382
  "sonner": "^2.0.7",
383
383
  "tw-animate-css": "^1.4.0",
384
384
  "vaul": "^1.1.2",
385
- "@codefast/tailwind-variants": "0.3.11-canary.1"
385
+ "@codefast/tailwind-variants": "0.3.11"
386
386
  },
387
387
  "devDependencies": {
388
- "@rsbuild/plugin-react": "^1.4.6",
389
- "@rslib/core": "0.19.1",
390
388
  "@swc/core": "^1.15.21",
391
389
  "@swc/jest": "^0.2.39",
392
390
  "@tailwindcss/postcss": "^4.2.2",
@@ -403,8 +401,9 @@
403
401
  "postcss": "^8.5.8",
404
402
  "tailwindcss": "^4.2.2",
405
403
  "ts-node": "^10.9.2",
404
+ "tsdown": "^0.21.7",
406
405
  "typescript": "^6.0.2",
407
- "@codefast/typescript-config": "0.3.11-canary.1"
406
+ "@codefast/typescript-config": "0.3.11"
408
407
  },
409
408
  "peerDependencies": {
410
409
  "@types/react": "^19.0",
@@ -421,9 +420,9 @@
421
420
  }
422
421
  },
423
422
  "scripts": {
424
- "build": "rslib build",
423
+ "build": "tsdown",
425
424
  "clean": "rm -rf dist",
426
- "dev": "rslib build --watch",
425
+ "dev": "tsdown --watch --no-clean",
427
426
  "test": "jest",
428
427
  "test:coverage": "jest --coverage",
429
428
  "test:coverage:ci": "jest --coverage --ci",