@codefast/ui 0.3.16-canary.3 → 0.4.0-canary.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -0
- package/README.md +27 -16
- package/dist/components/accordion.d.mts +7 -22
- package/dist/components/accordion.mjs +26 -29
- package/dist/components/alert-dialog.d.mts +27 -26
- package/dist/components/alert-dialog.mjs +53 -45
- package/dist/components/alert.d.mts +12 -2
- package/dist/components/alert.mjs +15 -6
- package/dist/components/aspect-ratio.d.mts +2 -2
- package/dist/components/aspect-ratio.mjs +2 -3
- package/dist/components/avatar.d.mts +41 -5
- package/dist/components/avatar.mjs +40 -10
- package/dist/components/badge.mjs +4 -4
- package/dist/components/breadcrumb.d.mts +1 -0
- package/dist/components/breadcrumb.mjs +11 -10
- package/dist/components/button-group.d.mts +1 -1
- package/dist/components/button-group.mjs +6 -7
- package/dist/components/button.d.mts +0 -1
- package/dist/components/button.mjs +7 -7
- package/dist/components/calendar.d.mts +6 -2
- package/dist/components/calendar.mjs +39 -43
- package/dist/components/card.d.mts +4 -2
- package/dist/components/card.mjs +9 -9
- package/dist/components/carousel.d.mts +16 -4
- package/dist/components/carousel.mjs +25 -12
- package/dist/components/chart.d.mts +8 -3
- package/dist/components/chart.mjs +21 -15
- package/dist/components/checkbox-cards.mjs +6 -6
- package/dist/components/checkbox-group.mjs +6 -7
- package/dist/components/checkbox.d.mts +2 -2
- package/dist/components/checkbox.mjs +8 -9
- package/dist/components/collapsible.d.mts +4 -4
- package/dist/components/collapsible.mjs +4 -5
- package/dist/components/command.d.mts +11 -1
- package/dist/components/command.mjs +35 -32
- package/dist/components/context-menu.d.mts +22 -15
- package/dist/components/context-menu.mjs +44 -39
- package/dist/components/dialog.d.mts +19 -23
- package/dist/components/dialog.mjs +48 -47
- package/dist/components/direction.d.mts +24 -0
- package/dist/components/direction.mjs +18 -0
- package/dist/components/drawer.d.mts +2 -20
- package/dist/components/drawer.mjs +17 -25
- package/dist/components/dropdown-menu.d.mts +22 -15
- package/dist/components/dropdown-menu.mjs +41 -37
- package/dist/components/empty.mjs +5 -5
- package/dist/components/field.d.mts +1 -1
- package/dist/components/field.mjs +11 -12
- package/dist/components/form.d.mts +6 -7
- package/dist/components/form.mjs +6 -7
- package/dist/components/hover-card.d.mts +5 -5
- package/dist/components/hover-card.mjs +14 -12
- package/dist/components/input-group.d.mts +1 -1
- package/dist/components/input-group.mjs +12 -7
- package/dist/components/input-number.d.mts +3 -1
- package/dist/components/input-number.mjs +49 -27
- package/dist/components/input-otp.mjs +9 -7
- package/dist/components/input-password.mjs +1 -4
- package/dist/components/input-search.mjs +3 -5
- package/dist/components/input.mjs +1 -2
- package/dist/components/item.mjs +9 -9
- package/dist/components/kbd.mjs +1 -1
- package/dist/components/label.d.mts +2 -2
- package/dist/components/label.mjs +3 -4
- package/dist/components/menubar.d.mts +22 -16
- package/dist/components/menubar.mjs +54 -47
- package/dist/components/native-select.d.mts +5 -1
- package/dist/components/native-select.mjs +9 -6
- package/dist/components/navigation-menu.d.mts +30 -8
- package/dist/components/navigation-menu.mjs +33 -23
- package/dist/components/pagination.d.mts +6 -0
- package/dist/components/pagination.mjs +26 -11
- package/dist/components/popover.d.mts +40 -7
- package/dist/components/popover.mjs +46 -14
- package/dist/components/progress-circle.d.mts +1 -1
- package/dist/components/progress-circle.mjs +1 -2
- package/dist/components/progress.d.mts +2 -2
- package/dist/components/progress.mjs +5 -6
- package/dist/components/radio-cards.d.mts +3 -3
- package/dist/components/radio-cards.mjs +11 -11
- package/dist/components/radio-group.d.mts +3 -3
- package/dist/components/radio-group.mjs +9 -9
- package/dist/components/radio.mjs +2 -3
- package/dist/components/resizable.mjs +3 -8
- package/dist/components/scroll-area.d.mts +5 -5
- package/dist/components/scroll-area.mjs +13 -10
- package/dist/components/select.d.mts +14 -14
- package/dist/components/select.mjs +47 -47
- package/dist/components/separator.d.mts +2 -2
- package/dist/components/separator.mjs +3 -4
- package/dist/components/sheet.d.mts +13 -14
- package/dist/components/sheet.mjs +41 -39
- package/dist/components/sidebar.d.mts +2 -3
- package/dist/components/sidebar.mjs +46 -46
- package/dist/components/skeleton.mjs +1 -1
- package/dist/components/slider.d.mts +2 -2
- package/dist/components/slider.mjs +9 -11
- package/dist/components/sonner.mjs +11 -3
- package/dist/components/spinner.mjs +6 -7
- package/dist/components/switch.d.mts +5 -2
- package/dist/components/switch.mjs +7 -7
- package/dist/components/table.mjs +10 -10
- package/dist/components/tabs.d.mts +8 -5
- package/dist/components/tabs.mjs +18 -12
- package/dist/components/textarea.mjs +1 -1
- package/dist/components/toggle-group.d.mts +9 -6
- package/dist/components/toggle-group.mjs +19 -20
- package/dist/components/toggle.d.mts +2 -3
- package/dist/components/toggle.mjs +4 -6
- package/dist/components/tooltip.d.mts +7 -6
- package/dist/components/tooltip.mjs +19 -17
- package/dist/hooks/use-animated-value.mjs +0 -1
- package/dist/hooks/use-copy-to-clipboard.mjs +0 -1
- package/dist/hooks/use-is-mobile.mjs +0 -1
- package/dist/hooks/use-media-query.mjs +0 -1
- package/dist/hooks/use-mutation-observer.mjs +0 -1
- package/dist/hooks/use-pagination.mjs +0 -1
- package/dist/index.d.mts +15 -13
- package/dist/index.mjs +18 -16
- package/dist/primitives/checkbox-group.d.mts +9 -10
- package/dist/primitives/checkbox-group.mjs +14 -19
- package/dist/primitives/input-number.d.mts +3 -3
- package/dist/primitives/input-number.mjs +3 -5
- package/dist/primitives/input.d.mts +4 -4
- package/dist/primitives/input.mjs +2 -3
- package/dist/primitives/progress-circle.d.mts +3 -3
- package/dist/primitives/progress-circle.mjs +2 -3
- package/dist/variants/alert.d.mts +1 -1
- package/dist/variants/alert.mjs +3 -13
- package/dist/variants/badge.d.mts +6 -4
- package/dist/variants/badge.mjs +7 -34
- package/dist/variants/button-group.d.mts +2 -2
- package/dist/variants/button-group.mjs +3 -14
- package/dist/variants/button.d.mts +12 -10
- package/dist/variants/button.mjs +15 -57
- package/dist/variants/empty.d.mts +1 -1
- package/dist/variants/empty.mjs +2 -7
- package/dist/variants/field.d.mts +3 -3
- package/dist/variants/field.mjs +4 -22
- package/dist/variants/input-group.d.mts +9 -9
- package/dist/variants/input-group.mjs +11 -70
- package/dist/variants/input-number.d.mts +45 -0
- package/dist/variants/input-number.mjs +40 -0
- package/dist/variants/item.d.mts +5 -4
- package/dist/variants/item.mjs +9 -31
- package/dist/variants/navigation-menu.d.mts +1 -1
- package/dist/variants/navigation-menu.mjs +1 -5
- package/dist/variants/progress-circle.d.mts +1 -1
- package/dist/variants/progress-circle.mjs +1 -5
- package/dist/variants/scroll-area.d.mts +2 -2
- package/dist/variants/scroll-area.mjs +3 -8
- package/dist/variants/separator.mjs +6 -6
- package/dist/variants/sheet.d.mts +4 -4
- package/dist/variants/sheet.mjs +5 -38
- package/dist/variants/sidebar.d.mts +4 -4
- package/dist/variants/sidebar.mjs +6 -23
- package/dist/variants/tabs.d.mts +18 -0
- package/dist/variants/tabs.mjs +15 -0
- package/dist/variants/toggle.d.mts +4 -4
- package/dist/variants/toggle.mjs +9 -27
- package/package.json +27 -44
- package/src/components/accordion.tsx +26 -68
- package/src/components/alert-dialog.tsx +70 -86
- package/src/components/alert.tsx +27 -19
- package/src/components/aspect-ratio.tsx +1 -4
- package/src/components/avatar.tsx +99 -12
- package/src/components/badge.tsx +5 -8
- package/src/components/breadcrumb.tsx +18 -24
- package/src/components/button-group.tsx +10 -20
- package/src/components/button.tsx +8 -19
- package/src/components/calendar.tsx +77 -132
- package/src/components/card.tsx +16 -22
- package/src/components/carousel.tsx +40 -58
- package/src/components/chart.tsx +41 -92
- package/src/components/checkbox-cards.tsx +11 -30
- package/src/components/checkbox-group.tsx +6 -28
- package/src/components/checkbox.tsx +6 -26
- package/src/components/collapsible.tsx +1 -4
- package/src/components/command.tsx +52 -65
- package/src/components/context-menu.tsx +46 -125
- package/src/components/dialog.tsx +49 -101
- package/src/components/direction.tsx +32 -0
- package/src/components/drawer.tsx +17 -79
- package/src/components/dropdown-menu.tsx +39 -118
- package/src/components/empty.tsx +6 -20
- package/src/components/field.tsx +19 -52
- package/src/components/form.tsx +19 -61
- package/src/components/hover-card.tsx +4 -27
- package/src/components/input-group.tsx +13 -52
- package/src/components/input-number.tsx +55 -75
- package/src/components/input-otp.tsx +19 -38
- package/src/components/input-password.tsx +5 -29
- package/src/components/input-search.tsx +6 -23
- package/src/components/input.tsx +1 -17
- package/src/components/item.tsx +17 -31
- package/src/components/kbd.tsx +2 -14
- package/src/components/label.tsx +2 -10
- package/src/components/menubar.tsx +34 -125
- package/src/components/native-select.tsx +21 -30
- package/src/components/navigation-menu.tsx +34 -94
- package/src/components/pagination.tsx +28 -34
- package/src/components/popover.tsx +66 -35
- package/src/components/progress-circle.tsx +7 -25
- package/src/components/progress.tsx +3 -16
- package/src/components/radio-cards.tsx +8 -27
- package/src/components/radio-group.tsx +7 -27
- package/src/components/radio.tsx +3 -24
- package/src/components/resizable.tsx +5 -26
- package/src/components/scroll-area.tsx +12 -32
- package/src/components/select.tsx +37 -60
- package/src/components/separator.tsx +4 -18
- package/src/components/sheet.tsx +37 -74
- package/src/components/sidebar.tsx +47 -177
- package/src/components/skeleton.tsx +1 -3
- package/src/components/slider.tsx +7 -36
- package/src/components/sonner.tsx +16 -6
- package/src/components/spinner.tsx +6 -15
- package/src/components/switch.tsx +8 -30
- package/src/components/table.tsx +18 -35
- package/src/components/tabs.tsx +16 -34
- package/src/components/textarea.tsx +1 -15
- package/src/components/toggle-group.tsx +34 -38
- package/src/components/toggle.tsx +4 -13
- package/src/components/tooltip.tsx +11 -37
- package/src/css/foundation/base.css +74 -0
- package/src/css/foundation/motion.css +69 -0
- package/src/css/foundation/source.css +10 -0
- package/src/css/foundation/tokens.css +107 -0
- package/src/css/foundation/variants.css +121 -0
- package/src/css/preset.css +13 -214
- package/src/css/style.css +9 -1
- package/src/css/{amber.css → themes/amber.css} +29 -0
- package/src/css/{blue.css → themes/blue.css} +29 -0
- package/src/css/{cyan.css → themes/cyan.css} +29 -0
- package/src/css/{emerald.css → themes/emerald.css} +29 -0
- package/src/css/{fuchsia.css → themes/fuchsia.css} +29 -0
- package/src/css/{gray.css → themes/gray.css} +29 -0
- package/src/css/{green.css → themes/green.css} +29 -0
- package/src/css/{indigo.css → themes/indigo.css} +29 -0
- package/src/css/{lime.css → themes/lime.css} +29 -0
- package/src/css/{neutral.css → themes/neutral.css} +29 -0
- package/src/css/{orange.css → themes/orange.css} +29 -0
- package/src/css/{pink.css → themes/pink.css} +29 -0
- package/src/css/{purple.css → themes/purple.css} +29 -0
- package/src/css/{red.css → themes/red.css} +29 -0
- package/src/css/{rose.css → themes/rose.css} +29 -0
- package/src/css/{sky.css → themes/sky.css} +29 -0
- package/src/css/{slate.css → themes/slate.css} +29 -0
- package/src/css/{stone.css → themes/stone.css} +29 -0
- package/src/css/{teal.css → themes/teal.css} +29 -0
- package/src/css/{violet.css → themes/violet.css} +29 -0
- package/src/css/{yellow.css → themes/yellow.css} +29 -0
- package/src/css/{zinc.css → themes/zinc.css} +29 -0
- package/src/hooks/use-animated-value.ts +1 -7
- package/src/hooks/use-copy-to-clipboard.ts +1 -6
- package/src/hooks/use-is-mobile.ts +0 -2
- package/src/hooks/use-media-query.ts +0 -2
- package/src/hooks/use-mutation-observer.ts +0 -3
- package/src/hooks/use-pagination.ts +0 -2
- package/src/index.ts +39 -80
- package/src/primitives/checkbox-group.tsx +25 -39
- package/src/primitives/input-number.tsx +17 -63
- package/src/primitives/input.tsx +8 -24
- package/src/primitives/progress-circle.tsx +13 -43
- package/src/variants/alert.ts +3 -14
- package/src/variants/badge.ts +8 -35
- package/src/variants/button-group.ts +5 -18
- package/src/variants/button.ts +21 -58
- package/src/variants/empty.ts +2 -11
- package/src/variants/field.ts +6 -19
- package/src/variants/input-group.ts +12 -64
- package/src/variants/input-number.ts +65 -0
- package/src/variants/item.ts +10 -32
- package/src/variants/navigation-menu.ts +1 -8
- package/src/variants/progress-circle.ts +1 -2
- package/src/variants/scroll-area.ts +3 -9
- package/src/variants/separator.ts +6 -7
- package/src/variants/sheet.ts +6 -39
- package/src/variants/sidebar.ts +7 -27
- package/src/variants/tabs.ts +34 -0
- package/src/variants/toggle.ts +9 -28
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { composeEventHandlers } from "radix-ui/internal";
|
|
2
|
+
import { Context } from "radix-ui/internal";
|
|
3
|
+
import { useControllableState } from "radix-ui/internal";
|
|
2
4
|
import type {
|
|
3
5
|
ComponentProps,
|
|
4
6
|
FocusEventHandler,
|
|
@@ -9,10 +11,6 @@ import type {
|
|
|
9
11
|
PointerEventHandler,
|
|
10
12
|
RefObject,
|
|
11
13
|
} from "react";
|
|
12
|
-
|
|
13
|
-
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
14
|
-
import { createContextScope } from "@radix-ui/react-context";
|
|
15
|
-
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
16
14
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
17
15
|
|
|
18
16
|
import * as InputPrimitive from "#/primitives/input";
|
|
@@ -34,10 +32,10 @@ type ScopedProps<P> = P & {
|
|
|
34
32
|
/**
|
|
35
33
|
* Optional scope for the InputNumber component context
|
|
36
34
|
*/
|
|
37
|
-
__scopeInputNumber?: Scope;
|
|
35
|
+
__scopeInputNumber?: Context.Scope;
|
|
38
36
|
};
|
|
39
37
|
|
|
40
|
-
const [createInputNumberContext, createInputNumberScope] = createContextScope(NUMBER_INPUT_NAME, [
|
|
38
|
+
const [createInputNumberContext, createInputNumberScope] = Context.createContextScope(NUMBER_INPUT_NAME, [
|
|
41
39
|
createInputScope,
|
|
42
40
|
]);
|
|
43
41
|
const useInputScope = createInputScope();
|
|
@@ -232,7 +230,7 @@ function InputNumber(numberInputProps: ScopedProps<InputNumberProps>): JSX.Eleme
|
|
|
232
230
|
} = numberInputProps;
|
|
233
231
|
|
|
234
232
|
/**
|
|
235
|
-
* Scope for the input component
|
|
233
|
+
* Context.Scope for the input component
|
|
236
234
|
*/
|
|
237
235
|
const inputScope = useInputScope(__scopeInputNumber);
|
|
238
236
|
|
|
@@ -253,10 +251,7 @@ function InputNumber(numberInputProps: ScopedProps<InputNumberProps>): JSX.Eleme
|
|
|
253
251
|
/**
|
|
254
252
|
* Separators used for number formatting based on locale
|
|
255
253
|
*/
|
|
256
|
-
const { decimalSeparator, thousandSeparator } = useMemo(
|
|
257
|
-
() => getNumberFormatSeparators(locale),
|
|
258
|
-
[locale],
|
|
259
|
-
);
|
|
254
|
+
const { decimalSeparator, thousandSeparator } = useMemo(() => getNumberFormatSeparators(locale), [locale]);
|
|
260
255
|
|
|
261
256
|
/**
|
|
262
257
|
* Formats a number value into a string representation
|
|
@@ -295,11 +290,7 @@ function InputNumber(numberInputProps: ScopedProps<InputNumberProps>): JSX.Eleme
|
|
|
295
290
|
return Number.NaN;
|
|
296
291
|
}
|
|
297
292
|
|
|
298
|
-
const normalizedValue = normalizeInputValue(
|
|
299
|
-
cleanedValue,
|
|
300
|
-
thousandSeparator,
|
|
301
|
-
decimalSeparator,
|
|
302
|
-
);
|
|
293
|
+
const normalizedValue = normalizeInputValue(cleanedValue, thousandSeparator, decimalSeparator);
|
|
303
294
|
let parsedValue = Number.parseFloat(normalizedValue);
|
|
304
295
|
|
|
305
296
|
if (formatOptions.style === "percent") {
|
|
@@ -403,16 +394,7 @@ const NUMBER_INPUT_FIELD_NAME = "InputNumberField";
|
|
|
403
394
|
*/
|
|
404
395
|
type InputNumberFieldProps = Omit<
|
|
405
396
|
ComponentProps<typeof InputPrimitive.Field>,
|
|
406
|
-
| "
|
|
407
|
-
| "disabled"
|
|
408
|
-
| "id"
|
|
409
|
-
| "max"
|
|
410
|
-
| "min"
|
|
411
|
-
| "onChange"
|
|
412
|
-
| "prefix"
|
|
413
|
-
| "readOnly"
|
|
414
|
-
| "step"
|
|
415
|
-
| "value"
|
|
397
|
+
"defaultValue" | "disabled" | "id" | "max" | "min" | "onChange" | "prefix" | "readOnly" | "step" | "value"
|
|
416
398
|
>;
|
|
417
399
|
|
|
418
400
|
/**
|
|
@@ -595,10 +577,7 @@ function InputNumberField({
|
|
|
595
577
|
*/
|
|
596
578
|
const combinedKeyDownHandler = useCallback<KeyboardEventHandler<HTMLInputElement>>(
|
|
597
579
|
(event) => {
|
|
598
|
-
composeEventHandlers(
|
|
599
|
-
onKeyDown,
|
|
600
|
-
chain(handleKeyDownPrevent, handleKeyDown, handleKeyDownEnter),
|
|
601
|
-
)(event);
|
|
580
|
+
composeEventHandlers(onKeyDown, chain(handleKeyDownPrevent, handleKeyDown, handleKeyDownEnter))(event);
|
|
602
581
|
},
|
|
603
582
|
[onKeyDown, handleKeyDown, handleKeyDownEnter, handleKeyDownPrevent],
|
|
604
583
|
);
|
|
@@ -712,17 +691,8 @@ function NumberStepperButton({
|
|
|
712
691
|
...props
|
|
713
692
|
}: ScopedProps<NumberStepperButtonProps>): JSX.Element {
|
|
714
693
|
// Destructures relevant context values for the button functionality.
|
|
715
|
-
const {
|
|
716
|
-
|
|
717
|
-
ariaIncrementLabel,
|
|
718
|
-
disabled,
|
|
719
|
-
id,
|
|
720
|
-
max,
|
|
721
|
-
min,
|
|
722
|
-
onDecrement,
|
|
723
|
-
onIncrement,
|
|
724
|
-
value,
|
|
725
|
-
} = useInputNumberContext(NUMBER_STEPPER_BUTTON_NAME, __scopeInputNumber);
|
|
694
|
+
const { ariaDecrementLabel, ariaIncrementLabel, disabled, id, max, min, onDecrement, onIncrement, value } =
|
|
695
|
+
useInputNumberContext(NUMBER_STEPPER_BUTTON_NAME, __scopeInputNumber);
|
|
726
696
|
|
|
727
697
|
const isDisabled = useMemo(() => {
|
|
728
698
|
const atMin = min !== undefined && value !== undefined && value <= min;
|
|
@@ -829,10 +799,7 @@ function NumberStepperButton({
|
|
|
829
799
|
/**
|
|
830
800
|
* @since 0.3.16-canary.0
|
|
831
801
|
*/
|
|
832
|
-
type InputNumberIncrementButtonProps = Omit<
|
|
833
|
-
ComponentProps<typeof NumberStepperButton>,
|
|
834
|
-
"operation"
|
|
835
|
-
>;
|
|
802
|
+
type InputNumberIncrementButtonProps = Omit<ComponentProps<typeof NumberStepperButton>, "operation">;
|
|
836
803
|
|
|
837
804
|
/**
|
|
838
805
|
* @since 0.3.16-canary.0
|
|
@@ -848,10 +815,7 @@ function InputNumberIncrementButton(props: InputNumberIncrementButtonProps): JSX
|
|
|
848
815
|
/**
|
|
849
816
|
* @since 0.3.16-canary.0
|
|
850
817
|
*/
|
|
851
|
-
type InputNumberDecrementButtonProps = Omit<
|
|
852
|
-
ComponentProps<typeof NumberStepperButton>,
|
|
853
|
-
"operation"
|
|
854
|
-
>;
|
|
818
|
+
type InputNumberDecrementButtonProps = Omit<ComponentProps<typeof NumberStepperButton>, "operation">;
|
|
855
819
|
|
|
856
820
|
/**
|
|
857
821
|
* @since 0.3.16-canary.0
|
|
@@ -870,9 +834,7 @@ function InputNumberDecrementButton(props: InputNumberDecrementButtonProps): JSX
|
|
|
870
834
|
* @param callbacks - Array of callback functions that will be executed in order
|
|
871
835
|
* @returns A single function that executes all callbacks
|
|
872
836
|
*/
|
|
873
|
-
function chain<T extends Array<unknown>>(
|
|
874
|
-
...callbacks: Array<(...args: T) => void>
|
|
875
|
-
): (...args: T) => void {
|
|
837
|
+
function chain<T extends Array<unknown>>(...callbacks: Array<(...args: T) => void>): (...args: T) => void {
|
|
876
838
|
return (...args: T) => {
|
|
877
839
|
for (const callback of callbacks) {
|
|
878
840
|
callback(...args);
|
|
@@ -932,11 +894,7 @@ function getNumberFormatSeparators(locale?: string): NumberFormatSeparators {
|
|
|
932
894
|
* @param decimalSeparator - The decimal separator to convert to standard dot notation
|
|
933
895
|
* @returns Normalized string value ready for numeric conversion
|
|
934
896
|
*/
|
|
935
|
-
function normalizeInputValue(
|
|
936
|
-
value: string,
|
|
937
|
-
thousandSeparator: string,
|
|
938
|
-
decimalSeparator: string,
|
|
939
|
-
): string {
|
|
897
|
+
function normalizeInputValue(value: string, thousandSeparator: string, decimalSeparator: string): string {
|
|
940
898
|
return value
|
|
941
899
|
.replaceAll(new RegExp(`\\${thousandSeparator}`, "g"), "")
|
|
942
900
|
.replace(new RegExp(`\\${decimalSeparator}`), ".")
|
|
@@ -981,11 +939,7 @@ function isNumberKey(key: string): boolean {
|
|
|
981
939
|
* @param max - The maximum allowed value (defaults to Infinity)
|
|
982
940
|
* @returns The clamped value
|
|
983
941
|
*/
|
|
984
|
-
function clamp(
|
|
985
|
-
value: number,
|
|
986
|
-
min = Number.NEGATIVE_INFINITY,
|
|
987
|
-
max = Number.POSITIVE_INFINITY,
|
|
988
|
-
): number {
|
|
942
|
+
function clamp(value: number, min = Number.NEGATIVE_INFINITY, max = Number.POSITIVE_INFINITY): number {
|
|
989
943
|
return Math.min(Math.max(value, min), max);
|
|
990
944
|
}
|
|
991
945
|
|
package/src/primitives/input.tsx
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
JSX,
|
|
5
|
-
PointerEventHandler,
|
|
6
|
-
PropsWithChildren,
|
|
7
|
-
ReactNode,
|
|
8
|
-
RefObject,
|
|
9
|
-
} from "react";
|
|
10
|
-
|
|
11
|
-
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
12
|
-
import { createContextScope } from "@radix-ui/react-context";
|
|
1
|
+
import { useComposedRefs } from "radix-ui/internal";
|
|
2
|
+
import { Context } from "radix-ui/internal";
|
|
3
|
+
import type { ComponentProps, JSX, PointerEventHandler, PropsWithChildren, ReactNode, RefObject } from "react";
|
|
13
4
|
import { useRef } from "react";
|
|
14
5
|
|
|
15
6
|
/* -----------------------------------------------------------------------------
|
|
@@ -23,12 +14,12 @@ const INPUT_NAME = "Input";
|
|
|
23
14
|
*/
|
|
24
15
|
type ScopedProps<P> = P & {
|
|
25
16
|
/**
|
|
26
|
-
* Scope for the Input component context
|
|
17
|
+
* Context.Scope for the Input component context
|
|
27
18
|
*/
|
|
28
|
-
__scopeInput?: Scope;
|
|
19
|
+
__scopeInput?: Context.Scope;
|
|
29
20
|
};
|
|
30
21
|
|
|
31
|
-
const [createInputContext, createInputScope] = createContextScope(INPUT_NAME);
|
|
22
|
+
const [createInputContext, createInputScope] = Context.createContextScope(INPUT_NAME);
|
|
32
23
|
|
|
33
24
|
/**
|
|
34
25
|
* Context value for the Input component
|
|
@@ -181,12 +172,7 @@ function Input(inputProps: ScopedProps<InputProps>): JSX.Element {
|
|
|
181
172
|
};
|
|
182
173
|
|
|
183
174
|
return (
|
|
184
|
-
<InputContextProvider
|
|
185
|
-
disabled={disabled}
|
|
186
|
-
inputRef={inputRef}
|
|
187
|
-
readOnly={readOnly}
|
|
188
|
-
scope={__scopeInput}
|
|
189
|
-
>
|
|
175
|
+
<InputContextProvider disabled={disabled} inputRef={inputRef} readOnly={readOnly} scope={__scopeInput}>
|
|
190
176
|
<div
|
|
191
177
|
data-disabled={disabled}
|
|
192
178
|
data-readonly={readOnly}
|
|
@@ -229,9 +215,7 @@ function InputField({ __scopeInput, ...props }: ScopedProps<InputFieldProps>): J
|
|
|
229
215
|
*/
|
|
230
216
|
const composedInputRef = useComposedRefs(inputRef);
|
|
231
217
|
|
|
232
|
-
return
|
|
233
|
-
<input ref={composedInputRef} disabled={disabled} readOnly={readOnly} type="text" {...props} />
|
|
234
|
-
);
|
|
218
|
+
return <input ref={composedInputRef} disabled={disabled} readOnly={readOnly} type="text" {...props} />;
|
|
235
219
|
}
|
|
236
220
|
|
|
237
221
|
/* -----------------------------------------------------------------------------
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { Scope } from "@radix-ui/react-context";
|
|
1
|
+
import { Context } from "radix-ui/internal";
|
|
4
2
|
import type { ComponentProps, ReactNode } from "react";
|
|
5
|
-
|
|
6
|
-
import { createContextScope } from "@radix-ui/react-context";
|
|
7
3
|
import { useId, useMemo } from "react";
|
|
8
4
|
|
|
9
5
|
/* -----------------------------------------------------------------------------
|
|
@@ -12,7 +8,7 @@ import { useId, useMemo } from "react";
|
|
|
12
8
|
|
|
13
9
|
const PROGRESS_CIRCLE_PROVIDER_NAME = "ProgressCircleProvider";
|
|
14
10
|
|
|
15
|
-
type ScopedProps<P> = P & { __scopeProgressCircle?: Scope };
|
|
11
|
+
type ScopedProps<P> = P & { __scopeProgressCircle?: Context.Scope };
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
14
|
* Defines color thresholds based on progress values
|
|
@@ -109,9 +105,8 @@ interface ProgressCircleContextValue {
|
|
|
109
105
|
valueText: string;
|
|
110
106
|
}
|
|
111
107
|
|
|
112
|
-
const [createProgressCircleContext, createProgressCircleScope] =
|
|
113
|
-
PROGRESS_CIRCLE_PROVIDER_NAME
|
|
114
|
-
);
|
|
108
|
+
const [createProgressCircleContext, createProgressCircleScope] =
|
|
109
|
+
Context.createContextScope(PROGRESS_CIRCLE_PROVIDER_NAME);
|
|
115
110
|
|
|
116
111
|
const [ProgressCircleContextProvider, useProgressCircleContext] =
|
|
117
112
|
createProgressCircleContext<ProgressCircleContextValue>(PROGRESS_CIRCLE_PROVIDER_NAME);
|
|
@@ -237,19 +232,13 @@ function ProgressCircleProvider({
|
|
|
237
232
|
const isIndeterminate = value === null || value === undefined;
|
|
238
233
|
const clampedValue = isIndeterminate ? undefined : clamp(validMin, validMax, value);
|
|
239
234
|
const range = validMax - validMin;
|
|
240
|
-
const percentage =
|
|
241
|
-
clampedValue !== undefined && range > 0 ? ((clampedValue - validMin) / range) * 100 : 0;
|
|
235
|
+
const percentage = clampedValue !== undefined && range > 0 ? ((clampedValue - validMin) / range) * 100 : 0;
|
|
242
236
|
const valueText =
|
|
243
|
-
clampedValue !== undefined && formatValue
|
|
244
|
-
? formatValue(clampedValue)
|
|
245
|
-
: `${Math.round(percentage).toString()}%`;
|
|
237
|
+
clampedValue !== undefined && formatValue ? formatValue(clampedValue) : `${Math.round(percentage).toString()}%`;
|
|
246
238
|
|
|
247
239
|
// Sort thresholds by value
|
|
248
240
|
const sortedThresholds = useMemo(
|
|
249
|
-
() =>
|
|
250
|
-
thresholds && thresholds.length > 0
|
|
251
|
-
? [...thresholds].toSorted((a, b) => a.value - b.value)
|
|
252
|
-
: [],
|
|
241
|
+
() => (thresholds && thresholds.length > 0 ? [...thresholds].toSorted((a, b) => a.value - b.value) : []),
|
|
253
242
|
[thresholds],
|
|
254
243
|
);
|
|
255
244
|
|
|
@@ -314,10 +303,7 @@ type ProgressCircleProps = ComponentProps<"div">;
|
|
|
314
303
|
*
|
|
315
304
|
* @since 0.3.16-canary.0
|
|
316
305
|
*/
|
|
317
|
-
function ProgressCircle({
|
|
318
|
-
__scopeProgressCircle,
|
|
319
|
-
...props
|
|
320
|
-
}: ScopedProps<ProgressCircleProps>): ReactNode {
|
|
306
|
+
function ProgressCircle({ __scopeProgressCircle, ...props }: ScopedProps<ProgressCircleProps>): ReactNode {
|
|
321
307
|
return <div {...props} />;
|
|
322
308
|
}
|
|
323
309
|
|
|
@@ -339,10 +325,7 @@ type ProgressCircleSVGProps = ComponentProps<"svg">;
|
|
|
339
325
|
*
|
|
340
326
|
* @since 0.3.16-canary.0
|
|
341
327
|
*/
|
|
342
|
-
function ProgressCircleSVG({
|
|
343
|
-
__scopeProgressCircle,
|
|
344
|
-
...props
|
|
345
|
-
}: ScopedProps<ProgressCircleSVGProps>): ReactNode {
|
|
328
|
+
function ProgressCircleSVG({ __scopeProgressCircle, ...props }: ScopedProps<ProgressCircleSVGProps>): ReactNode {
|
|
346
329
|
const { clampedValue, id, max, min, size, valueText } = useProgressCircleContext(
|
|
347
330
|
PROGRESS_CIRCLE_SVG_NAME,
|
|
348
331
|
__scopeProgressCircle,
|
|
@@ -383,10 +366,7 @@ type ProgressCircleTrackProps = ComponentProps<"circle">;
|
|
|
383
366
|
*
|
|
384
367
|
* @since 0.3.16-canary.0
|
|
385
368
|
*/
|
|
386
|
-
function ProgressCircleTrack({
|
|
387
|
-
__scopeProgressCircle,
|
|
388
|
-
...props
|
|
389
|
-
}: ScopedProps<ProgressCircleTrackProps>): ReactNode {
|
|
369
|
+
function ProgressCircleTrack({ __scopeProgressCircle, ...props }: ScopedProps<ProgressCircleTrackProps>): ReactNode {
|
|
390
370
|
const { center, radius, strokeWidth, threshold } = useProgressCircleContext(
|
|
391
371
|
PROGRESS_CIRCLE_TRACK_NAME,
|
|
392
372
|
__scopeProgressCircle,
|
|
@@ -427,15 +407,8 @@ function ProgressCircleIndicator({
|
|
|
427
407
|
__scopeProgressCircle,
|
|
428
408
|
...props
|
|
429
409
|
}: ScopedProps<ProgressCircleIndicatorProps>): ReactNode {
|
|
430
|
-
const {
|
|
431
|
-
|
|
432
|
-
circumference,
|
|
433
|
-
radius,
|
|
434
|
-
rotationTransform,
|
|
435
|
-
strokeDashoffset,
|
|
436
|
-
strokeWidth,
|
|
437
|
-
threshold,
|
|
438
|
-
} = useProgressCircleContext(PROGRESS_CIRCLE_INDICATOR_NAME, __scopeProgressCircle);
|
|
410
|
+
const { center, circumference, radius, rotationTransform, strokeDashoffset, strokeWidth, threshold } =
|
|
411
|
+
useProgressCircleContext(PROGRESS_CIRCLE_INDICATOR_NAME, __scopeProgressCircle);
|
|
439
412
|
|
|
440
413
|
return (
|
|
441
414
|
<circle
|
|
@@ -479,10 +452,7 @@ function ProgressCircleValue({
|
|
|
479
452
|
children,
|
|
480
453
|
...props
|
|
481
454
|
}: ScopedProps<ProgressCircleValueProps>): ReactNode {
|
|
482
|
-
const { clampedValue, valueText } = useProgressCircleContext(
|
|
483
|
-
PROGRESS_CIRCLE_VALUE_NAME,
|
|
484
|
-
__scopeProgressCircle,
|
|
485
|
-
);
|
|
455
|
+
const { clampedValue, valueText } = useProgressCircleContext(PROGRESS_CIRCLE_VALUE_NAME, __scopeProgressCircle);
|
|
486
456
|
|
|
487
457
|
if (typeof children === "function") {
|
|
488
458
|
return children({ value: clampedValue, valueText });
|
package/src/variants/alert.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VariantProps } from "#/lib/utils";
|
|
2
|
-
|
|
3
2
|
import { tv } from "#/lib/utils";
|
|
4
3
|
|
|
5
4
|
/* -----------------------------------------------------------------------------
|
|
@@ -10,24 +9,14 @@ import { tv } from "#/lib/utils";
|
|
|
10
9
|
* @since 0.3.16-canary.0
|
|
11
10
|
*/
|
|
12
11
|
const alertVariants = tv({
|
|
13
|
-
base: [
|
|
14
|
-
"relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 px-4 py-3",
|
|
15
|
-
"rounded-xl border",
|
|
16
|
-
"bg-card text-sm",
|
|
17
|
-
"has-[>svg]:grid-cols-[--spacing(4)_1fr] has-[>svg]:gap-x-3",
|
|
18
|
-
"[&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
|
|
19
|
-
],
|
|
12
|
+
base: "group/alert relative grid w-full gap-0.5 rounded-lg border px-4 py-3 text-start text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pe-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",
|
|
20
13
|
defaultVariants: {
|
|
21
14
|
variant: "default",
|
|
22
15
|
},
|
|
23
16
|
variants: {
|
|
24
17
|
variant: {
|
|
25
|
-
default: "text-card-foreground",
|
|
26
|
-
destructive: [
|
|
27
|
-
"text-destructive",
|
|
28
|
-
"*:data-[slot=alert-description]:text-destructive/90",
|
|
29
|
-
"[&>svg]:text-current",
|
|
30
|
-
],
|
|
18
|
+
default: "bg-card text-card-foreground",
|
|
19
|
+
destructive: "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",
|
|
31
20
|
},
|
|
32
21
|
},
|
|
33
22
|
});
|
package/src/variants/badge.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VariantProps } from "#/lib/utils";
|
|
2
|
-
|
|
3
2
|
import { tv } from "#/lib/utils";
|
|
4
3
|
|
|
5
4
|
/* -----------------------------------------------------------------------------
|
|
@@ -10,45 +9,19 @@ import { tv } from "#/lib/utils";
|
|
|
10
9
|
* @since 0.3.16-canary.0
|
|
11
10
|
*/
|
|
12
11
|
const badgeVariants = tv({
|
|
13
|
-
base: [
|
|
14
|
-
"inline-flex w-fit shrink-0 items-center justify-center gap-2 px-1.5 py-0.5",
|
|
15
|
-
"rounded-md border outline-hidden",
|
|
16
|
-
"text-xs font-medium whitespace-nowrap",
|
|
17
|
-
"transition",
|
|
18
|
-
"focus-visible:ring-3 focus-visible:ring-ring/50",
|
|
19
|
-
"[&>svg]:size-3 [&>svg]:shrink-0",
|
|
20
|
-
],
|
|
12
|
+
base: "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
|
|
21
13
|
defaultVariants: {
|
|
22
14
|
variant: "default",
|
|
23
15
|
},
|
|
24
16
|
variants: {
|
|
25
17
|
variant: {
|
|
26
|
-
default: [
|
|
27
|
-
|
|
28
|
-
"bg-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
],
|
|
33
|
-
destructive: [
|
|
34
|
-
"border-transparent",
|
|
35
|
-
"bg-destructive text-white",
|
|
36
|
-
"focus-visible:ring-destructive/20",
|
|
37
|
-
"dark:bg-destructive/60",
|
|
38
|
-
"dark:focus-visible:ring-destructive/40",
|
|
39
|
-
"[a&]:hover:bg-destructive/90",
|
|
40
|
-
],
|
|
41
|
-
outline: [
|
|
42
|
-
"border-input",
|
|
43
|
-
"bg-background",
|
|
44
|
-
"focus-visible:border-ring",
|
|
45
|
-
"[a&]:hover:border-ring/60 [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
46
|
-
],
|
|
47
|
-
secondary: [
|
|
48
|
-
"border-transparent",
|
|
49
|
-
"bg-secondary text-secondary-foreground",
|
|
50
|
-
"[a&]:hover:bg-secondary/80",
|
|
51
|
-
],
|
|
18
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
19
|
+
destructive:
|
|
20
|
+
"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
|
21
|
+
ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
|
22
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
23
|
+
outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
|
24
|
+
secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
|
52
25
|
},
|
|
53
26
|
},
|
|
54
27
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VariantProps } from "#/lib/utils";
|
|
2
|
-
|
|
3
2
|
import { tv } from "#/lib/utils";
|
|
4
3
|
|
|
5
4
|
/* -----------------------------------------------------------------------------
|
|
@@ -10,28 +9,16 @@ import { tv } from "#/lib/utils";
|
|
|
10
9
|
* @since 0.3.16-canary.0
|
|
11
10
|
*/
|
|
12
11
|
const buttonGroupVariants = tv({
|
|
13
|
-
base: [
|
|
14
|
-
"flex w-fit items-stretch",
|
|
15
|
-
"has-[>[data-slot=button-group]]:gap-2",
|
|
16
|
-
"[&>*]:focus-visible:relative [&>*]:focus-visible:z-10",
|
|
17
|
-
"has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg",
|
|
18
|
-
"[&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit",
|
|
19
|
-
"[&>input]:flex-1",
|
|
20
|
-
],
|
|
12
|
+
base: "group/button-group flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-e-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
|
|
21
13
|
defaultVariants: {
|
|
22
14
|
orientation: "horizontal",
|
|
23
15
|
},
|
|
24
16
|
variants: {
|
|
25
17
|
orientation: {
|
|
26
|
-
horizontal:
|
|
27
|
-
"[&>*:not(:first-child)]:rounded-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
vertical: [
|
|
31
|
-
"flex-col",
|
|
32
|
-
"[&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0",
|
|
33
|
-
"[&>*:not(:last-child)]:rounded-b-none",
|
|
34
|
-
],
|
|
18
|
+
horizontal:
|
|
19
|
+
"[&>*:not(:first-child)]:rounded-s-none [&>*:not(:first-child)]:border-s-0 [&>*:not(:last-child)]:rounded-e-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-e-md!",
|
|
20
|
+
vertical:
|
|
21
|
+
"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-md!",
|
|
35
22
|
},
|
|
36
23
|
},
|
|
37
24
|
});
|
package/src/variants/button.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VariantProps } from "#/lib/utils";
|
|
2
|
-
|
|
3
2
|
import { tv } from "#/lib/utils";
|
|
4
3
|
|
|
5
4
|
/* -----------------------------------------------------------------------------
|
|
@@ -10,72 +9,36 @@ import { tv } from "#/lib/utils";
|
|
|
10
9
|
* @since 0.3.16-canary.0
|
|
11
10
|
*/
|
|
12
11
|
const buttonVariants = tv({
|
|
13
|
-
base: [
|
|
14
|
-
"inline-flex shrink-0 items-center justify-center gap-2",
|
|
15
|
-
"rounded-lg outline-hidden",
|
|
16
|
-
"text-sm font-medium whitespace-nowrap",
|
|
17
|
-
"transition duration-150 ease-snappy select-none",
|
|
18
|
-
"motion-reduce:transition-none motion-reduce:duration-0",
|
|
19
|
-
"active:not-disabled:translate-y-px",
|
|
20
|
-
"focus-visible:ring-3",
|
|
21
|
-
"disabled:opacity-50",
|
|
22
|
-
"[&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
23
|
-
],
|
|
12
|
+
base: "group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
24
13
|
defaultVariants: {
|
|
25
|
-
size: "
|
|
14
|
+
size: "default",
|
|
26
15
|
variant: "default",
|
|
27
16
|
},
|
|
28
17
|
variants: {
|
|
29
18
|
size: {
|
|
30
|
-
|
|
19
|
+
default:
|
|
20
|
+
"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2", // 36px
|
|
21
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3", // 24px
|
|
22
|
+
sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5", // 32px
|
|
23
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2", // 40px
|
|
24
|
+
|
|
31
25
|
icon: "size-9", // 36px
|
|
26
|
+
"icon-xs":
|
|
27
|
+
"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3", // 24px
|
|
28
|
+
"icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md", // 32px
|
|
32
29
|
"icon-lg": "size-10", // 40px
|
|
33
|
-
|
|
34
|
-
sm: ["h-8 px-3", "has-[>svg]:px-2.5"], // 32px
|
|
35
|
-
md: ["h-9 px-4", "has-[>svg]:px-3"], // 36px
|
|
36
|
-
lg: ["h-10 px-6", "has-[>svg]:px-4"], // 40px
|
|
37
30
|
},
|
|
38
31
|
variant: {
|
|
39
|
-
default:
|
|
40
|
-
|
|
41
|
-
"hover:
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"bg-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"dark:bg-destructive/60",
|
|
50
|
-
"dark:focus-visible:ring-destructive/40",
|
|
51
|
-
],
|
|
52
|
-
ghost: [
|
|
53
|
-
"hover:not-disabled:bg-secondary hover:not-disabled:text-secondary-foreground",
|
|
54
|
-
"focus-visible:ring-ring/50",
|
|
55
|
-
"dark:hover:not-disabled:bg-secondary/50",
|
|
56
|
-
],
|
|
57
|
-
link: [
|
|
58
|
-
"text-primary underline-offset-4",
|
|
59
|
-
"hover:not-disabled:underline",
|
|
60
|
-
"focus-visible:ring-ring/50",
|
|
61
|
-
],
|
|
62
|
-
outline: [
|
|
63
|
-
"border border-input shadow-xs",
|
|
64
|
-
"hover:not-disabled:border-ring/60 hover:not-disabled:bg-secondary hover:not-disabled:text-secondary-foreground",
|
|
65
|
-
"focus-visible:border-ring focus-visible:ring-ring/50",
|
|
66
|
-
"aria-invalid:border-destructive",
|
|
67
|
-
"focus-within:aria-invalid:ring-destructive/20",
|
|
68
|
-
"hover:not-disabled:aria-invalid:border-destructive/60",
|
|
69
|
-
"dark:bg-input/30",
|
|
70
|
-
"dark:hover:not-disabled:bg-input/50",
|
|
71
|
-
"dark:aria-invalid:border-destructive/70",
|
|
72
|
-
"dark:focus-within:aria-invalid:ring-destructive/40",
|
|
73
|
-
],
|
|
74
|
-
secondary: [
|
|
75
|
-
"bg-secondary text-secondary-foreground",
|
|
76
|
-
"hover:not-disabled:bg-secondary/80",
|
|
77
|
-
"focus-visible:ring-ring/50",
|
|
78
|
-
],
|
|
32
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
33
|
+
destructive:
|
|
34
|
+
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
35
|
+
ghost:
|
|
36
|
+
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
37
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
38
|
+
outline:
|
|
39
|
+
"border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
40
|
+
secondary:
|
|
41
|
+
"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
79
42
|
},
|
|
80
43
|
},
|
|
81
44
|
});
|
package/src/variants/empty.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VariantProps } from "#/lib/utils";
|
|
2
|
-
|
|
3
2
|
import { tv } from "#/lib/utils";
|
|
4
3
|
|
|
5
4
|
/* -----------------------------------------------------------------------------
|
|
@@ -10,22 +9,14 @@ import { tv } from "#/lib/utils";
|
|
|
10
9
|
* @since 0.3.16-canary.0
|
|
11
10
|
*/
|
|
12
11
|
const emptyMediaVariants = tv({
|
|
13
|
-
base: [
|
|
14
|
-
"mb-2 flex shrink-0 items-center justify-center",
|
|
15
|
-
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
16
|
-
],
|
|
12
|
+
base: "mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
17
13
|
defaultVariants: {
|
|
18
14
|
variant: "default",
|
|
19
15
|
},
|
|
20
16
|
variants: {
|
|
21
17
|
variant: {
|
|
22
18
|
default: "bg-transparent",
|
|
23
|
-
icon: [
|
|
24
|
-
"flex size-10 shrink-0 items-center justify-center",
|
|
25
|
-
"rounded-xl",
|
|
26
|
-
"bg-muted text-foreground",
|
|
27
|
-
"[&_svg:not([class*='size-'])]:size-6",
|
|
28
|
-
],
|
|
19
|
+
icon: "flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-6",
|
|
29
20
|
},
|
|
30
21
|
},
|
|
31
22
|
});
|
package/src/variants/field.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VariantProps } from "#/lib/utils";
|
|
2
|
-
|
|
3
2
|
import { tv } from "#/lib/utils";
|
|
4
3
|
|
|
5
4
|
/* -----------------------------------------------------------------------------
|
|
@@ -10,29 +9,17 @@ import { tv } from "#/lib/utils";
|
|
|
10
9
|
* @since 0.3.16-canary.0
|
|
11
10
|
*/
|
|
12
11
|
const fieldVariants = tv({
|
|
13
|
-
base:
|
|
12
|
+
base: "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
|
|
14
13
|
defaultVariants: {
|
|
15
14
|
orientation: "vertical",
|
|
16
15
|
},
|
|
17
16
|
variants: {
|
|
18
17
|
orientation: {
|
|
19
|
-
horizontal:
|
|
20
|
-
"flex-row items-center",
|
|
21
|
-
|
|
22
|
-
"[
|
|
23
|
-
|
|
24
|
-
],
|
|
25
|
-
responsive: [
|
|
26
|
-
"flex-col",
|
|
27
|
-
"@md/field-group:flex-row @md/field-group:items-center",
|
|
28
|
-
"@md/field-group:has-[>[data-slot=field-content]]:items-start",
|
|
29
|
-
"[&>*]:w-full",
|
|
30
|
-
"@md/field-group:[&>*]:w-auto",
|
|
31
|
-
"[&>.sr-only]:w-auto",
|
|
32
|
-
"@md/field-group:[&>[data-slot=field-label]]:flex-auto",
|
|
33
|
-
"@md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
34
|
-
],
|
|
35
|
-
vertical: ["flex-col", "[&>*]:w-full", "[&>.sr-only]:w-auto"],
|
|
18
|
+
horizontal:
|
|
19
|
+
"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
20
|
+
responsive:
|
|
21
|
+
"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
22
|
+
vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
|
|
36
23
|
},
|
|
37
24
|
},
|
|
38
25
|
});
|