@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.
- package/CHANGELOG.md +36 -0
- package/README.md +34 -14
- package/dist/components/accordion.d.ts +29 -10
- package/dist/components/accordion.js +38 -37
- package/dist/components/alert-dialog.d.ts +60 -24
- package/dist/components/alert-dialog.js +69 -72
- package/dist/components/alert.d.ts +27 -15
- package/dist/components/alert.js +29 -31
- package/dist/components/aspect-ratio.d.ts +8 -4
- package/dist/components/aspect-ratio.js +7 -5
- package/dist/components/avatar.d.ts +17 -6
- package/dist/components/avatar.js +19 -17
- package/dist/components/badge.d.ts +21 -14
- package/dist/components/badge.js +19 -22
- package/dist/components/breadcrumb.d.ts +35 -12
- package/dist/components/breadcrumb.js +48 -54
- package/dist/components/button-group.d.ts +29 -14
- package/dist/components/button-group.js +27 -32
- package/dist/components/button.d.ts +35 -25
- package/dist/components/button.js +50 -48
- package/dist/components/calendar.d.ts +24 -9
- package/dist/components/calendar.js +92 -98
- package/dist/components/card.d.ts +34 -10
- package/dist/components/card.js +39 -37
- package/dist/components/carousel.d.ts +55 -24
- package/dist/components/carousel.js +113 -130
- package/dist/components/chart.d.ts +72 -36
- package/dist/components/chart.js +154 -166
- package/dist/components/checkbox-cards.d.ts +15 -8
- package/dist/components/checkbox-cards.js +22 -25
- package/dist/components/checkbox-group.d.ts +16 -8
- package/dist/components/checkbox-group.js +19 -19
- package/dist/components/checkbox.d.ts +9 -4
- package/dist/components/checkbox.js +14 -14
- package/dist/components/collapsible.d.ts +14 -6
- package/dist/components/collapsible.js +18 -16
- package/dist/components/command.d.ts +55 -23
- package/dist/components/command.js +70 -85
- package/dist/components/context-menu.d.ts +72 -22
- package/dist/components/context-menu.js +88 -109
- package/dist/components/dialog.d.ts +53 -22
- package/dist/components/dialog.js +71 -85
- package/dist/components/drawer.d.ts +60 -28
- package/dist/components/drawer.js +59 -67
- package/dist/components/dropdown-menu.d.ts +73 -22
- package/dist/components/dropdown-menu.js +95 -112
- package/dist/components/empty.d.ts +37 -15
- package/dist/components/empty.js +43 -45
- package/dist/components/field.d.ts +63 -25
- package/dist/components/field.js +88 -104
- package/dist/components/form.d.ts +37 -15
- package/dist/components/form.js +65 -70
- package/dist/components/hover-card.d.ts +21 -7
- package/dist/components/hover-card.js +24 -24
- package/dist/components/input-group.d.ts +53 -28
- package/dist/components/input-group.js +63 -77
- package/dist/components/input-number.d.ts +28 -7
- package/dist/components/input-number.js +55 -59
- package/dist/components/input-otp.d.ts +24 -10
- package/dist/components/input-otp.js +33 -37
- package/dist/components/input-password.d.ts +12 -5
- package/dist/components/input-password.js +31 -32
- package/dist/components/input-search.d.ts +18 -8
- package/dist/components/input-search.js +43 -41
- package/dist/components/input.d.ts +10 -4
- package/dist/components/input.js +9 -7
- package/dist/components/item.d.ts +69 -32
- package/dist/components/item.js +89 -92
- package/dist/components/kbd.d.ts +13 -5
- package/dist/components/kbd.js +13 -11
- package/dist/components/label.d.ts +9 -4
- package/dist/components/label.js +9 -7
- package/dist/components/menubar.d.ts +80 -23
- package/dist/components/menubar.js +97 -118
- package/dist/components/native-select.d.ts +16 -6
- package/dist/components/native-select.js +25 -26
- package/dist/components/navigation-menu.d.ts +36 -12
- package/dist/components/navigation-menu.js +60 -75
- package/dist/components/pagination.d.ts +35 -14
- package/dist/components/pagination.js +54 -69
- package/dist/components/popover.d.ts +24 -8
- package/dist/components/popover.js +28 -28
- package/dist/components/progress-circle.d.ts +106 -88
- package/dist/components/progress-circle.js +106 -138
- package/dist/components/progress.d.ts +10 -4
- package/dist/components/progress.js +14 -14
- package/dist/components/radio-cards.d.ts +10 -4
- package/dist/components/radio-cards.js +22 -23
- package/dist/components/radio-group.d.ts +13 -5
- package/dist/components/radio-group.js +18 -16
- package/dist/components/radio.d.ts +12 -5
- package/dist/components/radio.js +10 -8
- package/dist/components/resizable.d.ts +18 -7
- package/dist/components/resizable.js +22 -22
- package/dist/components/scroll-area.d.ts +33 -20
- package/dist/components/scroll-area.js +84 -88
- package/dist/components/select.d.ts +50 -16
- package/dist/components/select.js +77 -96
- package/dist/components/separator.d.ts +29 -19
- package/dist/components/separator.js +36 -34
- package/dist/components/sheet.d.ts +62 -29
- package/dist/components/sheet.js +79 -100
- package/dist/components/sidebar.d.ts +160 -66
- package/dist/components/sidebar.js +294 -336
- package/dist/components/skeleton.d.ts +9 -4
- package/dist/components/skeleton.js +8 -6
- package/dist/components/slider.d.ts +13 -4
- package/dist/components/slider.js +34 -40
- package/dist/components/sonner.d.ts +10 -7
- package/dist/components/sonner.js +16 -14
- package/dist/components/spinner.d.ts +12 -5
- package/dist/components/spinner.js +33 -35
- package/dist/components/switch.d.ts +9 -4
- package/dist/components/switch.js +13 -11
- package/dist/components/table.d.ts +37 -11
- package/dist/components/table.js +47 -45
- package/dist/components/tabs.d.ts +21 -7
- package/dist/components/tabs.js +24 -22
- package/dist/components/textarea.d.ts +9 -4
- package/dist/components/textarea.js +8 -6
- package/dist/components/toggle-group.d.ts +24 -9
- package/dist/components/toggle-group.js +41 -42
- package/dist/components/toggle.d.ts +25 -17
- package/dist/components/toggle.js +30 -28
- package/dist/components/tooltip.d.ts +24 -8
- package/dist/components/tooltip.js +29 -32
- package/dist/hooks/use-animated-value.d.ts +4 -1
- package/dist/hooks/use-animated-value.js +57 -36
- package/dist/hooks/use-copy-to-clipboard.d.ts +11 -5
- package/dist/hooks/use-copy-to-clipboard.js +39 -20
- package/dist/hooks/use-is-mobile.d.ts +4 -1
- package/dist/hooks/use-is-mobile.js +21 -1
- package/dist/hooks/use-media-query.d.ts +4 -1
- package/dist/hooks/use-media-query.js +45 -18
- package/dist/hooks/use-mutation-observer.d.ts +6 -2
- package/dist/hooks/use-mutation-observer.js +34 -16
- package/dist/hooks/use-pagination.d.ts +22 -14
- package/dist/hooks/use-pagination.js +100 -49
- package/dist/index.d.ts +69 -130
- package/dist/index.js +11 -11
- package/dist/primitives/checkbox-group.d.ts +105 -83
- package/dist/primitives/checkbox-group.js +111 -84
- package/dist/primitives/input-number.d.ts +51 -40
- package/dist/primitives/input-number.js +483 -350
- package/dist/primitives/input.d.ts +48 -42
- package/dist/primitives/input.js +65 -43
- package/dist/primitives/progress-circle.d.ts +79 -48
- package/dist/primitives/progress-circle.js +154 -105
- package/package.json +6 -7
|
@@ -1,99 +1,126 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback } from "react";
|
|
3
3
|
import { createContextScope } from "@radix-ui/react-context";
|
|
4
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
5
|
+
import { createCheckboxScope } from "@radix-ui/react-checkbox";
|
|
4
6
|
import { useDirection } from "@radix-ui/react-direction";
|
|
5
|
-
import
|
|
7
|
+
import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
|
|
8
|
+
import { createRovingFocusGroupScope } from "@radix-ui/react-roving-focus";
|
|
6
9
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
7
|
-
|
|
10
|
+
//#region src/primitives/checkbox-group.tsx
|
|
8
11
|
const CHECKBOX_GROUP_NAME = "CheckboxGroup";
|
|
9
|
-
const [createCheckboxGroupContext, createCheckboxGroupScope] = createContextScope(CHECKBOX_GROUP_NAME, [
|
|
10
|
-
createRovingFocusGroupScope,
|
|
11
|
-
createCheckboxScope
|
|
12
|
-
]);
|
|
12
|
+
const [createCheckboxGroupContext, createCheckboxGroupScope] = createContextScope(CHECKBOX_GROUP_NAME, [createRovingFocusGroupScope, createCheckboxScope]);
|
|
13
13
|
const useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
14
14
|
const useCheckboxScope = createCheckboxScope();
|
|
15
15
|
const [CheckboxGroupContextProvider, useCheckboxGroupContext] = createCheckboxGroupContext(CHECKBOX_GROUP_NAME);
|
|
16
|
+
/**
|
|
17
|
+
* CheckboxGroup component that manages a group of checkboxes with roving focus
|
|
18
|
+
*/
|
|
16
19
|
function CheckboxGroup({ __scopeCheckboxGroup, defaultValue, dir, disabled = false, loop = true, name, onValueChange, orientation, required = false, value: valueProperty, ...props }) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
20
|
+
/**
|
|
21
|
+
* Scope for the RovingFocusGroup component
|
|
22
|
+
*/
|
|
23
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeCheckboxGroup);
|
|
24
|
+
/**
|
|
25
|
+
* Direction for layout and navigation
|
|
26
|
+
*/
|
|
27
|
+
const direction = useDirection(dir);
|
|
28
|
+
/**
|
|
29
|
+
* State for managing selected checkbox values
|
|
30
|
+
*/
|
|
31
|
+
const [value = [], setValue] = useControllableState({
|
|
32
|
+
defaultProp: defaultValue,
|
|
33
|
+
onChange: onValueChange,
|
|
34
|
+
prop: valueProperty
|
|
35
|
+
});
|
|
36
|
+
return /* @__PURE__ */ jsx(CheckboxGroupContextProvider, {
|
|
37
|
+
disabled,
|
|
38
|
+
name,
|
|
39
|
+
required,
|
|
40
|
+
scope: __scopeCheckboxGroup,
|
|
41
|
+
value,
|
|
42
|
+
onItemCheck: useCallback((itemValue) => {
|
|
43
|
+
setValue((previousValue) => [...previousValue ?? [], itemValue]);
|
|
44
|
+
}, [setValue]),
|
|
45
|
+
onItemUncheck: useCallback((itemValue) => {
|
|
46
|
+
setValue((previousValue) => {
|
|
47
|
+
const currentValue = previousValue ?? [];
|
|
48
|
+
if (required && currentValue.length === 1 && currentValue[0] === itemValue) return currentValue;
|
|
49
|
+
return currentValue.filter((inputValue) => inputValue !== itemValue);
|
|
50
|
+
});
|
|
51
|
+
}, [setValue, required]),
|
|
52
|
+
children: /* @__PURE__ */ jsx(RovingFocusGroup.Root, {
|
|
53
|
+
asChild: true,
|
|
54
|
+
...rovingFocusGroupScope,
|
|
55
|
+
dir: direction,
|
|
56
|
+
loop,
|
|
57
|
+
orientation,
|
|
58
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
59
|
+
"data-disabled": disabled ? "" : void 0,
|
|
60
|
+
dir: direction,
|
|
61
|
+
role: "group",
|
|
62
|
+
...props
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
});
|
|
64
66
|
}
|
|
65
67
|
const ITEM_NAME = "CheckboxGroupItem";
|
|
68
|
+
/**
|
|
69
|
+
* Individual checkbox item within a CheckboxGroup
|
|
70
|
+
*/
|
|
66
71
|
function CheckboxGroupItem({ __scopeCheckboxGroup, disabled, ...props }) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Context values from the parent CheckboxGroup
|
|
74
|
+
*/
|
|
75
|
+
const context = useCheckboxGroupContext(ITEM_NAME, __scopeCheckboxGroup);
|
|
76
|
+
/**
|
|
77
|
+
* Combined disabled state from both context and props
|
|
78
|
+
*/
|
|
79
|
+
const isDisabled = context.disabled || disabled;
|
|
80
|
+
/**
|
|
81
|
+
* Scope for the RovingFocusGroup component
|
|
82
|
+
*/
|
|
83
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeCheckboxGroup);
|
|
84
|
+
/**
|
|
85
|
+
* Scope for the Checkbox component
|
|
86
|
+
*/
|
|
87
|
+
const checkboxScope = useCheckboxScope(__scopeCheckboxGroup);
|
|
88
|
+
/**
|
|
89
|
+
* Whether this checkbox is currently checked
|
|
90
|
+
*/
|
|
91
|
+
const checked = context.value?.includes(props.value);
|
|
92
|
+
return /* @__PURE__ */ jsx(RovingFocusGroup.Item, {
|
|
93
|
+
asChild: true,
|
|
94
|
+
...rovingFocusGroupScope,
|
|
95
|
+
active: checked,
|
|
96
|
+
focusable: !isDisabled,
|
|
97
|
+
children: /* @__PURE__ */ jsx(CheckboxPrimitive.Root, {
|
|
98
|
+
"aria-label": props.value,
|
|
99
|
+
checked,
|
|
100
|
+
disabled: isDisabled,
|
|
101
|
+
name: context.name,
|
|
102
|
+
required: context.required,
|
|
103
|
+
...checkboxScope,
|
|
104
|
+
...props,
|
|
105
|
+
onCheckedChange: (checkedState) => {
|
|
106
|
+
if (checkedState) context.onItemCheck(props.value);
|
|
107
|
+
else context.onItemUncheck(props.value);
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
});
|
|
91
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Visual indicator component for a CheckboxGroupItem
|
|
114
|
+
*/
|
|
92
115
|
function CheckboxGroupIndicator({ __scopeCheckboxGroup, ...props }) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Scope for the Checkbox component
|
|
118
|
+
*/
|
|
119
|
+
const checkboxScope = useCheckboxScope(__scopeCheckboxGroup);
|
|
120
|
+
return /* @__PURE__ */ jsx(CheckboxPrimitive.Indicator, {
|
|
121
|
+
...checkboxScope,
|
|
122
|
+
...props
|
|
123
|
+
});
|
|
98
124
|
}
|
|
99
|
-
|
|
125
|
+
//#endregion
|
|
126
|
+
export { CheckboxGroup, CheckboxGroup as Root, CheckboxGroupIndicator, CheckboxGroupIndicator as Indicator, CheckboxGroupItem, CheckboxGroupItem as Item, createCheckboxGroupScope };
|
|
@@ -1,62 +1,73 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
1
|
+
import { Field as InputField, Input } from "./input.js";
|
|
2
|
+
import { ComponentProps, JSX } from "react";
|
|
3
|
+
import * as _$_radix_ui_react_context0 from "@radix-ui/react-context";
|
|
4
|
+
import { Scope } from "@radix-ui/react-context";
|
|
5
|
+
|
|
6
|
+
//#region src/primitives/input-number.d.ts
|
|
4
7
|
/**
|
|
5
8
|
* Props that include an optional scope for the InputNumber component.
|
|
6
9
|
*/
|
|
7
10
|
type ScopedProps<P> = P & {
|
|
8
|
-
|
|
9
|
-
__scopeInputNumber?: Scope;
|
|
11
|
+
/** Optional scope for the InputNumber component context */__scopeInputNumber?: Scope;
|
|
10
12
|
};
|
|
11
|
-
declare const createInputNumberScope:
|
|
13
|
+
declare const createInputNumberScope: _$_radix_ui_react_context0.CreateScope;
|
|
12
14
|
/**
|
|
13
15
|
* Props for the main InputNumber component.
|
|
14
16
|
*/
|
|
15
|
-
interface InputNumberProps extends ComponentProps<typeof
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
17
|
+
interface InputNumberProps extends ComponentProps<typeof Input> {
|
|
18
|
+
/** Accessible label for the decrement button */
|
|
19
|
+
ariaDecrementLabel?: string;
|
|
20
|
+
/** Accessible label for the increment button */
|
|
21
|
+
ariaIncrementLabel?: string;
|
|
22
|
+
/** Initial value when uncontrolled */
|
|
23
|
+
defaultValue?: number;
|
|
24
|
+
/** Options for number formatting */
|
|
25
|
+
formatOptions?: Intl.NumberFormatOptions;
|
|
26
|
+
/** Unique identifier for the input */
|
|
27
|
+
id?: string;
|
|
28
|
+
/** Locale used for number formatting */
|
|
29
|
+
locale?: string;
|
|
30
|
+
/** Maximum allowed value */
|
|
31
|
+
max?: number;
|
|
32
|
+
/** Minimum allowed value */
|
|
33
|
+
min?: number;
|
|
34
|
+
/** Handler called when the value changes */
|
|
35
|
+
onChange?: (value?: number) => void;
|
|
36
|
+
/** Step value for increments/decrements */
|
|
37
|
+
step?: number;
|
|
38
|
+
/** Current value when controlled */
|
|
39
|
+
value?: number;
|
|
38
40
|
}
|
|
39
41
|
declare function InputNumber(numberInputProps: ScopedProps<InputNumberProps>): JSX.Element;
|
|
40
42
|
/**
|
|
41
43
|
* Defines the props for the `InputNumberField` component.
|
|
42
44
|
*/
|
|
43
|
-
type InputNumberFieldProps = Omit<ComponentProps<typeof
|
|
44
|
-
declare function InputNumberField({
|
|
45
|
+
type InputNumberFieldProps = Omit<ComponentProps<typeof InputField>, "defaultValue" | "disabled" | "id" | "max" | "min" | "onChange" | "prefix" | "readOnly" | "step" | "value">;
|
|
46
|
+
declare function InputNumberField({
|
|
47
|
+
__scopeInputNumber,
|
|
48
|
+
onBlur,
|
|
49
|
+
onKeyDown,
|
|
50
|
+
...props
|
|
51
|
+
}: ScopedProps<InputNumberFieldProps>): JSX.Element;
|
|
45
52
|
/**
|
|
46
53
|
* Props for the NumberStepperButton component.
|
|
47
54
|
*/
|
|
48
55
|
interface NumberStepperButtonProps extends ComponentProps<"button"> {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
/**
|
|
57
|
+
* The operation to perform when the button is pressed.
|
|
58
|
+
* - `'increment'`: Increases the value.
|
|
59
|
+
* - `'decrement'`: Decreases the value.
|
|
60
|
+
*/
|
|
61
|
+
operation: "decrement" | "increment";
|
|
55
62
|
}
|
|
56
|
-
declare function NumberStepperButton({
|
|
63
|
+
declare function NumberStepperButton({
|
|
64
|
+
__scopeInputNumber,
|
|
65
|
+
operation,
|
|
66
|
+
...props
|
|
67
|
+
}: ScopedProps<NumberStepperButtonProps>): JSX.Element;
|
|
57
68
|
type InputNumberIncrementButtonProps = Omit<ComponentProps<typeof NumberStepperButton>, "operation">;
|
|
58
69
|
declare function InputNumberIncrementButton(props: InputNumberIncrementButtonProps): JSX.Element;
|
|
59
70
|
type InputNumberDecrementButtonProps = Omit<ComponentProps<typeof NumberStepperButton>, "operation">;
|
|
60
71
|
declare function InputNumberDecrementButton(props: InputNumberDecrementButtonProps): JSX.Element;
|
|
61
|
-
|
|
62
|
-
export type
|
|
72
|
+
//#endregion
|
|
73
|
+
export { InputNumberDecrementButton as DecrementButton, InputNumberDecrementButton, InputNumberField as Field, InputNumberField, InputNumberIncrementButton as IncrementButton, InputNumberIncrementButton, InputNumber, InputNumber as Root, type InputNumberDecrementButtonProps, type InputNumberFieldProps, type InputNumberIncrementButtonProps, type InputNumberProps, createInputNumberScope };
|