@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,99 +1,126 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { Indicator, Root, createCheckboxScope } from "@radix-ui/react-checkbox";
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 { Item, Root as react_roving_focus_Root, createRovingFocusGroupScope } from "@radix-ui/react-roving-focus";
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
- import { useCallback } from "react";
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
- const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeCheckboxGroup);
18
- const direction = useDirection(dir);
19
- const [value = [], setValue] = useControllableState({
20
- defaultProp: defaultValue,
21
- onChange: onValueChange,
22
- prop: valueProperty
23
- });
24
- const handleItemCheck = useCallback((itemValue)=>{
25
- setValue((previousValue)=>[
26
- ...previousValue ?? [],
27
- itemValue
28
- ]);
29
- }, [
30
- setValue
31
- ]);
32
- const handleItemUncheck = useCallback((itemValue)=>{
33
- setValue((previousValue)=>{
34
- const currentValue = previousValue ?? [];
35
- if (required && 1 === currentValue.length && currentValue[0] === itemValue) return currentValue;
36
- return currentValue.filter((inputValue)=>inputValue !== itemValue);
37
- });
38
- }, [
39
- setValue,
40
- required
41
- ]);
42
- return /*#__PURE__*/ jsx(CheckboxGroupContextProvider, {
43
- disabled: disabled,
44
- name: name,
45
- required: required,
46
- scope: __scopeCheckboxGroup,
47
- value: value,
48
- onItemCheck: handleItemCheck,
49
- onItemUncheck: handleItemUncheck,
50
- children: /*#__PURE__*/ jsx(react_roving_focus_Root, {
51
- asChild: true,
52
- ...rovingFocusGroupScope,
53
- dir: direction,
54
- loop: loop,
55
- orientation: orientation,
56
- children: /*#__PURE__*/ jsx("div", {
57
- "data-disabled": disabled ? "" : void 0,
58
- dir: direction,
59
- role: "group",
60
- ...props
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
- const context = useCheckboxGroupContext(ITEM_NAME, __scopeCheckboxGroup);
68
- const isDisabled = context.disabled || disabled;
69
- const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeCheckboxGroup);
70
- const checkboxScope = useCheckboxScope(__scopeCheckboxGroup);
71
- const checked = context.value?.includes(props.value);
72
- return /*#__PURE__*/ jsx(Item, {
73
- asChild: true,
74
- ...rovingFocusGroupScope,
75
- active: checked,
76
- focusable: !isDisabled,
77
- children: /*#__PURE__*/ jsx(Root, {
78
- "aria-label": props.value,
79
- checked: checked,
80
- disabled: isDisabled,
81
- name: context.name,
82
- required: context.required,
83
- ...checkboxScope,
84
- ...props,
85
- onCheckedChange: (checkedState)=>{
86
- if (checkedState) context.onItemCheck(props.value);
87
- else context.onItemUncheck(props.value);
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
- const checkboxScope = useCheckboxScope(__scopeCheckboxGroup);
94
- return /*#__PURE__*/ jsx(Indicator, {
95
- ...checkboxScope,
96
- ...props
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
- export { CheckboxGroup, CheckboxGroupIndicator, CheckboxGroupItem, CheckboxGroupIndicator as Indicator, CheckboxGroupItem as Item, CheckboxGroup as Root, createCheckboxGroupScope };
125
+ //#endregion
126
+ export { CheckboxGroup, CheckboxGroup as Root, CheckboxGroupIndicator, CheckboxGroupIndicator as Indicator, CheckboxGroupItem, CheckboxGroupItem as Item, createCheckboxGroupScope };
@@ -1,62 +1,73 @@
1
- import type { Scope } from "@radix-ui/react-context";
2
- import type { ComponentProps, JSX } from "react";
3
- import * as InputPrimitive from "./input";
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
- /** Optional scope for the InputNumber component context */
9
- __scopeInputNumber?: Scope;
11
+ /** Optional scope for the InputNumber component context */__scopeInputNumber?: Scope;
10
12
  };
11
- declare const createInputNumberScope: import("@radix-ui/react-context").CreateScope;
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 InputPrimitive.Root> {
16
- /** Accessible label for the decrement button */
17
- ariaDecrementLabel?: string;
18
- /** Accessible label for the increment button */
19
- ariaIncrementLabel?: string;
20
- /** Initial value when uncontrolled */
21
- defaultValue?: number;
22
- /** Options for number formatting */
23
- formatOptions?: Intl.NumberFormatOptions;
24
- /** Unique identifier for the input */
25
- id?: string;
26
- /** Locale used for number formatting */
27
- locale?: string;
28
- /** Maximum allowed value */
29
- max?: number;
30
- /** Minimum allowed value */
31
- min?: number;
32
- /** Handler called when the value changes */
33
- onChange?: (value?: number) => void;
34
- /** Step value for increments/decrements */
35
- step?: number;
36
- /** Current value when controlled */
37
- value?: number;
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 InputPrimitive.Field>, "defaultValue" | "disabled" | "id" | "max" | "min" | "onChange" | "prefix" | "readOnly" | "step" | "value">;
44
- declare function InputNumberField({ __scopeInputNumber, onBlur, onKeyDown, ...props }: ScopedProps<InputNumberFieldProps>): JSX.Element;
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
- * The operation to perform when the button is pressed.
51
- * - `'increment'`: Increases the value.
52
- * - `'decrement'`: Decreases the value.
53
- */
54
- operation: "decrement" | "increment";
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({ __scopeInputNumber, operation, ...props }: ScopedProps<NumberStepperButtonProps>): JSX.Element;
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
- export { createInputNumberScope, InputNumberDecrementButton as DecrementButton, InputNumberField as Field, InputNumberIncrementButton as IncrementButton, InputNumber, InputNumberDecrementButton, InputNumberField, InputNumberIncrementButton, InputNumber as Root, };
62
- export type { InputNumberDecrementButtonProps, InputNumberFieldProps, InputNumberIncrementButtonProps, InputNumberProps, };
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 };