@koobiq/react-primitives 0.0.1-beta.9 → 0.0.1
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/dist/behaviors/index.d.ts +9 -11
- package/dist/behaviors/useButton.d.ts +12 -10
- package/dist/behaviors/useButton.js +11 -22
- package/dist/behaviors/useCheckbox.d.ts +10 -45
- package/dist/behaviors/useCheckbox.js +15 -38
- package/dist/behaviors/useLink.d.ts +5 -9
- package/dist/behaviors/useLink.js +8 -17
- package/dist/behaviors/useNumberField.d.ts +1 -22
- package/dist/behaviors/useNumberField.js +2 -13
- package/dist/behaviors/useRadio.d.ts +8 -35
- package/dist/behaviors/useRadio.js +12 -16
- package/dist/behaviors/useRadioGroup.d.ts +2 -55
- package/dist/behaviors/useRadioGroup.js +1 -18
- package/dist/behaviors/useRadioGroupState.d.ts +2 -42
- package/dist/behaviors/useRadioGroupState.js +1 -16
- package/dist/behaviors/useSwitch.d.ts +316 -0
- package/dist/behaviors/useSwitch.js +33 -0
- package/dist/components/Button/Button.js +17 -13
- package/dist/components/Button/types.d.ts +10 -16
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.js +36 -19
- package/dist/components/Checkbox/types.d.ts +8 -8
- package/dist/components/Group/Group.js +7 -7
- package/dist/components/Group/types.d.ts +8 -8
- package/dist/components/Link/Link.js +21 -8
- package/dist/components/Link/types.d.ts +5 -5
- package/dist/components/NumberField/NumberField.d.ts +1 -1
- package/dist/components/NumberField/NumberField.js +9 -9
- package/dist/components/NumberField/types.d.ts +4 -4
- package/dist/components/Radio/Radio.d.ts +1 -1
- package/dist/components/Radio/Radio.js +20 -13
- package/dist/components/Radio/RadioContext.d.ts +2 -17
- package/dist/components/Radio/RadioGroup.d.ts +1 -1
- package/dist/components/Radio/RadioGroup.js +4 -4
- package/dist/components/Radio/types.d.ts +16 -14
- package/dist/components/Switch/Switch.d.ts +3 -0
- package/dist/components/{Toggle/Toggle.js → Switch/Switch.js} +19 -19
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/types.d.ts +18 -0
- package/dist/components/TextField/TextField.d.ts +2 -1
- package/dist/components/TextField/TextField.js +58 -57
- package/dist/components/TextField/types.d.ts +11 -8
- package/dist/components/Textarea/Textarea.d.ts +2 -4
- package/dist/components/Textarea/Textarea.js +6 -2
- package/dist/components/Textarea/types.d.ts +2 -1
- package/dist/components/index.d.ts +12 -12
- package/dist/index.d.ts +30 -15
- package/dist/index.js +38 -34
- package/package.json +32 -11
- package/dist/behaviors/useNumberFieldState.d.ts +0 -25
- package/dist/behaviors/useNumberFieldState.js +0 -13
- package/dist/behaviors/useTextField.d.ts +0 -19
- package/dist/behaviors/useTextField.js +0 -24
- package/dist/behaviors/useToggle.d.ts +0 -44
- package/dist/behaviors/useToggle.js +0 -54
- package/dist/components/Toggle/Toggle.d.ts +0 -3
- package/dist/components/Toggle/index.d.ts +0 -2
- package/dist/components/Toggle/types.d.ts +0 -18
- package/dist/types.d.ts +0 -8
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './Text
|
|
1
|
+
export * from './Text';
|
|
2
2
|
export * from './Group';
|
|
3
|
-
export * from './Button
|
|
4
|
-
export * from './Checkbox
|
|
5
|
-
export * from './Link
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './Radio
|
|
8
|
-
export * from './Label
|
|
9
|
-
export * from './Input
|
|
10
|
-
export * from './Textarea
|
|
11
|
-
export * from './ProgressBar
|
|
12
|
-
export * from './TextField
|
|
13
|
-
export * from './NumberField
|
|
3
|
+
export * from './Button';
|
|
4
|
+
export * from './Checkbox';
|
|
5
|
+
export * from './Link';
|
|
6
|
+
export * from './Switch';
|
|
7
|
+
export * from './Radio';
|
|
8
|
+
export * from './Label';
|
|
9
|
+
export * from './Input';
|
|
10
|
+
export * from './Textarea';
|
|
11
|
+
export * from './ProgressBar';
|
|
12
|
+
export * from './TextField';
|
|
13
|
+
export * from './NumberField';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export * from '
|
|
13
|
-
export * from '
|
|
14
|
-
export
|
|
15
|
-
export * from '
|
|
1
|
+
export { useToggleButtonGroup, useToggleButtonGroupItem, type AriaToggleButtonGroupProps, type AriaToggleButtonGroupItemProps, } from '@react-aria/button';
|
|
2
|
+
export * from '@react-stately/collections';
|
|
3
|
+
export * from '@react-stately/data';
|
|
4
|
+
export * from '@react-stately/tree';
|
|
5
|
+
export * from '@react-aria/visually-hidden';
|
|
6
|
+
export * from '@react-aria/separator';
|
|
7
|
+
export * from '@react-aria/overlays';
|
|
8
|
+
export { useOverlayTriggerState, type OverlayTriggerState, } from '@react-stately/overlays';
|
|
9
|
+
export * from '@react-aria/dialog';
|
|
10
|
+
export * from '@react-aria/listbox';
|
|
11
|
+
export * from '@react-stately/list';
|
|
12
|
+
export * from '@react-aria/select';
|
|
13
|
+
export * from '@react-stately/select';
|
|
14
|
+
export * from '@react-aria/menu';
|
|
15
|
+
export * from '@react-stately/menu';
|
|
16
|
+
export * from '@react-aria/toggle';
|
|
17
|
+
export * from '@react-stately/toggle';
|
|
18
|
+
export * from '@react-aria/tag';
|
|
19
|
+
export * from '@react-aria/tooltip';
|
|
20
|
+
export * from '@react-stately/tooltip';
|
|
21
|
+
export * from '@react-aria/datepicker';
|
|
22
|
+
export * from '@react-stately/datepicker';
|
|
23
|
+
export * from '@react-aria/table';
|
|
24
|
+
export * from '@react-stately/table';
|
|
25
|
+
export type { CalendarProps, CalendarAria, CalendarGridAria, CalendarCellAria, AriaCalendarProps, AriaCalendarCellProps, AriaCalendarGridProps, } from '@react-aria/calendar';
|
|
26
|
+
export { useCalendar, useCalendarCell, useCalendarGrid, } from '@react-aria/calendar';
|
|
27
|
+
export * from '@react-stately/calendar';
|
|
28
|
+
export * from './behaviors';
|
|
29
|
+
export * from './components';
|
|
30
|
+
export * from './utils';
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { useToggleButtonGroup, useToggleButtonGroupItem } from "@react-aria/button";
|
|
2
|
+
export * from "@react-stately/collections";
|
|
3
|
+
export * from "@react-stately/data";
|
|
4
|
+
export * from "@react-stately/tree";
|
|
5
|
+
export * from "@react-aria/visually-hidden";
|
|
6
|
+
export * from "@react-aria/separator";
|
|
7
|
+
export * from "@react-aria/overlays";
|
|
8
8
|
import { useOverlayTriggerState } from "@react-stately/overlays";
|
|
9
|
-
|
|
9
|
+
export * from "@react-aria/dialog";
|
|
10
|
+
export * from "@react-aria/listbox";
|
|
11
|
+
export * from "@react-stately/list";
|
|
12
|
+
export * from "@react-aria/select";
|
|
13
|
+
export * from "@react-stately/select";
|
|
14
|
+
export * from "@react-aria/menu";
|
|
15
|
+
export * from "@react-stately/menu";
|
|
16
|
+
export * from "@react-aria/toggle";
|
|
17
|
+
export * from "@react-stately/toggle";
|
|
18
|
+
export * from "@react-aria/tag";
|
|
19
|
+
export * from "@react-aria/tooltip";
|
|
20
|
+
export * from "@react-stately/tooltip";
|
|
21
|
+
export * from "@react-aria/datepicker";
|
|
22
|
+
export * from "@react-stately/datepicker";
|
|
23
|
+
export * from "@react-aria/table";
|
|
24
|
+
export * from "@react-stately/table";
|
|
25
|
+
import { useCalendar, useCalendarCell, useCalendarGrid } from "@react-aria/calendar";
|
|
26
|
+
export * from "@react-stately/calendar";
|
|
27
|
+
import { Provider, removeDataAttributes, useRenderProps } from "./utils/index.js";
|
|
10
28
|
import { useButton } from "./behaviors/useButton.js";
|
|
11
29
|
import { useCheckbox } from "./behaviors/useCheckbox.js";
|
|
12
30
|
import { useLink } from "./behaviors/useLink.js";
|
|
13
|
-
import {
|
|
14
|
-
import { useToggle } from "./behaviors/useToggle.js";
|
|
31
|
+
import { useSwitch } from "./behaviors/useSwitch.js";
|
|
15
32
|
import { useRadio } from "./behaviors/useRadio.js";
|
|
16
33
|
import { useRadioGroup } from "./behaviors/useRadioGroup.js";
|
|
17
34
|
import { useRadioGroupState } from "./behaviors/useRadioGroupState.js";
|
|
18
35
|
import { useProgressBar } from "./behaviors/useProgressBar.js";
|
|
19
36
|
import { useNumberField } from "./behaviors/useNumberField.js";
|
|
20
|
-
import { useNumberFieldState } from "./behaviors/useNumberFieldState.js";
|
|
21
37
|
import { Text } from "./components/Text/Text.js";
|
|
22
38
|
import { TextContext } from "./components/Text/TextContext.js";
|
|
23
39
|
import { Group } from "./components/Group/Group.js";
|
|
@@ -26,7 +42,7 @@ import { Button } from "./components/Button/Button.js";
|
|
|
26
42
|
import { ButtonContext } from "./components/Button/ButtonContext.js";
|
|
27
43
|
import { Checkbox } from "./components/Checkbox/Checkbox.js";
|
|
28
44
|
import { Link } from "./components/Link/Link.js";
|
|
29
|
-
import {
|
|
45
|
+
import { Switch } from "./components/Switch/Switch.js";
|
|
30
46
|
import { Radio } from "./components/Radio/Radio.js";
|
|
31
47
|
import { RadioGroup } from "./components/Radio/RadioGroup.js";
|
|
32
48
|
import { RadioContext } from "./components/Radio/RadioContext.js";
|
|
@@ -45,53 +61,41 @@ export {
|
|
|
45
61
|
Checkbox,
|
|
46
62
|
Group,
|
|
47
63
|
GroupContext,
|
|
48
|
-
I18nProvider,
|
|
49
64
|
Input,
|
|
50
65
|
InputContext,
|
|
51
|
-
Item,
|
|
52
66
|
Label,
|
|
53
67
|
LabelContext,
|
|
54
68
|
Link,
|
|
55
69
|
NumberField,
|
|
56
|
-
Overlay,
|
|
57
70
|
ProgressBar,
|
|
71
|
+
Provider,
|
|
58
72
|
Radio,
|
|
59
73
|
RadioContext,
|
|
60
74
|
RadioGroup,
|
|
61
|
-
|
|
75
|
+
Switch,
|
|
62
76
|
Text,
|
|
63
77
|
TextContext,
|
|
64
78
|
TextField,
|
|
65
79
|
Textarea,
|
|
66
80
|
TextareaContext,
|
|
67
|
-
|
|
81
|
+
removeDataAttributes,
|
|
68
82
|
useButton,
|
|
83
|
+
useCalendar,
|
|
84
|
+
useCalendarCell,
|
|
85
|
+
useCalendarGrid,
|
|
69
86
|
useCheckbox,
|
|
70
|
-
useDialog,
|
|
71
87
|
useGroupContext,
|
|
72
88
|
useInputContext,
|
|
73
89
|
useLink,
|
|
74
|
-
useListBox,
|
|
75
|
-
useListBoxSection,
|
|
76
|
-
useListState,
|
|
77
|
-
useLocale,
|
|
78
|
-
useLocalizedStringFormatter,
|
|
79
|
-
useModalOverlay,
|
|
80
90
|
useNumberField,
|
|
81
|
-
useNumberFieldState,
|
|
82
|
-
useOption,
|
|
83
|
-
useOverlayPosition,
|
|
84
|
-
useOverlayTrigger,
|
|
85
91
|
useOverlayTriggerState,
|
|
86
|
-
usePopover,
|
|
87
92
|
useProgressBar,
|
|
88
93
|
useRadio,
|
|
89
94
|
useRadioGroup,
|
|
90
95
|
useRadioGroupState,
|
|
91
|
-
|
|
96
|
+
useRenderProps,
|
|
97
|
+
useSwitch,
|
|
92
98
|
useTextareaContext,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
useTooltipTrigger,
|
|
96
|
-
useTooltipTriggerState
|
|
99
|
+
useToggleButtonGroup,
|
|
100
|
+
useToggleButtonGroupItem
|
|
97
101
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koobiq/react-primitives",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"main": "./dist/index.js",
|
|
5
6
|
"types": "./dist/index.d.ts",
|
|
6
7
|
"exports": {
|
|
@@ -9,6 +10,11 @@
|
|
|
9
10
|
"default": "./dist/index.js"
|
|
10
11
|
}
|
|
11
12
|
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"directory": "packages/primitives",
|
|
16
|
+
"url": "git+https://github.com/koobiq/react-components.git"
|
|
17
|
+
},
|
|
12
18
|
"type": "module",
|
|
13
19
|
"files": [
|
|
14
20
|
"dist"
|
|
@@ -19,27 +25,42 @@
|
|
|
19
25
|
"sideEffects": false,
|
|
20
26
|
"dependencies": {
|
|
21
27
|
"@react-aria/button": "^3.9.0",
|
|
28
|
+
"@react-aria/calendar": "^3.8.3",
|
|
22
29
|
"@react-aria/checkbox": "^3.14.0",
|
|
30
|
+
"@react-aria/datepicker": "^3.14.5",
|
|
23
31
|
"@react-aria/dialog": "^3.5.19",
|
|
24
|
-
"@react-aria/
|
|
25
|
-
"@react-aria/link": "^3.7.0",
|
|
32
|
+
"@react-aria/link": "^3.8.3",
|
|
26
33
|
"@react-aria/listbox": "^3.14.2",
|
|
34
|
+
"@react-aria/menu": "^3.18.2",
|
|
27
35
|
"@react-aria/numberfield": "^3.11.8",
|
|
28
|
-
"@react-aria/overlays": "^3.
|
|
36
|
+
"@react-aria/overlays": "^3.27.3",
|
|
29
37
|
"@react-aria/progress": "^3.4.17",
|
|
30
38
|
"@react-aria/radio": "^3.10.9",
|
|
31
|
-
"@react-aria/
|
|
39
|
+
"@react-aria/select": "^3.15.7",
|
|
40
|
+
"@react-aria/separator": "^3.4.8",
|
|
41
|
+
"@react-aria/switch": "^3.7.5",
|
|
42
|
+
"@react-aria/table": "^3.17.5",
|
|
43
|
+
"@react-aria/tag": "^3.6.0",
|
|
44
|
+
"@react-aria/textfield": "^3.17.5",
|
|
32
45
|
"@react-aria/toggle": "^3.10.10",
|
|
33
|
-
"@react-aria/tooltip": "^3.
|
|
46
|
+
"@react-aria/tooltip": "^3.8.5",
|
|
34
47
|
"@react-aria/visually-hidden": "^3.8.0",
|
|
35
|
-
"@react-stately/
|
|
48
|
+
"@react-stately/calendar": "^3.8.2",
|
|
49
|
+
"@react-stately/collections": "^3.12.5",
|
|
50
|
+
"@react-stately/data": "^3.13.0",
|
|
51
|
+
"@react-stately/datepicker": "^3.14.2",
|
|
36
52
|
"@react-stately/list": "^3.12.0",
|
|
53
|
+
"@react-stately/menu": "^3.9.3",
|
|
37
54
|
"@react-stately/numberfield": "^3.9.7",
|
|
38
|
-
"@react-stately/overlays": "^3.6.
|
|
55
|
+
"@react-stately/overlays": "^3.6.17",
|
|
39
56
|
"@react-stately/radio": "^3.10.8",
|
|
40
|
-
"@react-stately/
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
57
|
+
"@react-stately/select": "^3.6.14",
|
|
58
|
+
"@react-stately/table": "^3.14.3",
|
|
59
|
+
"@react-stately/toggle": "^3.7.0",
|
|
60
|
+
"@react-stately/tooltip": "^3.5.5",
|
|
61
|
+
"@react-stately/tree": "^3.8.9",
|
|
62
|
+
"@koobiq/logger": "0.0.1",
|
|
63
|
+
"@koobiq/react-core": "0.0.1"
|
|
43
64
|
},
|
|
44
65
|
"peerDependencies": {
|
|
45
66
|
"react": "18.x || 19.x",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ExtendableProps } from '@koobiq/react-core';
|
|
2
|
-
import type { NumberFieldStateOptions } from '@react-stately/numberfield';
|
|
3
|
-
export type UseNumberFieldStateProps = ExtendableProps<{
|
|
4
|
-
/**
|
|
5
|
-
* If `true`, the component is disabled.
|
|
6
|
-
* @default false
|
|
7
|
-
* */
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
/** It prevents the user from changing the value of the checkbox.
|
|
10
|
-
* @default false
|
|
11
|
-
*/
|
|
12
|
-
readonly?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* If `true`, the input element is required.
|
|
15
|
-
* @default false
|
|
16
|
-
* */
|
|
17
|
-
required?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* If `true`, the component will indicate an error.
|
|
20
|
-
* @default false
|
|
21
|
-
* */
|
|
22
|
-
error?: boolean;
|
|
23
|
-
}, Omit<NumberFieldStateOptions, 'isDisabled' | 'isReadOnly' | 'isRequired' | 'isInvalid'>>;
|
|
24
|
-
export declare function useNumberFieldState(props: UseNumberFieldStateProps): import("@react-stately/numberfield").NumberFieldState;
|
|
25
|
-
export type UseNumberFieldStateReturn = ReturnType<typeof useNumberFieldState>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useNumberFieldState as useNumberFieldState$1 } from "@react-stately/numberfield";
|
|
2
|
-
function useNumberFieldState(props) {
|
|
3
|
-
return useNumberFieldState$1({
|
|
4
|
-
...props,
|
|
5
|
-
isInvalid: props.error || false,
|
|
6
|
-
isReadOnly: props.readonly || false,
|
|
7
|
-
isDisabled: props.disabled || false,
|
|
8
|
-
isRequired: props.required || false
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
useNumberFieldState
|
|
13
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { RefObject } from 'react';
|
|
2
|
-
import type { AriaTextFieldOptions } from '@react-aria/textfield';
|
|
3
|
-
export type UseTextFieldProps = {
|
|
4
|
-
error?: boolean;
|
|
5
|
-
readonly?: boolean;
|
|
6
|
-
required?: boolean;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
inputElementType?: 'input' | 'textarea';
|
|
9
|
-
} & Omit<AriaTextFieldOptions<'input' | 'textarea'>, 'isDisabled' | 'isInvalid' | 'isRequired' | 'isReadOnly'>;
|
|
10
|
-
export declare function useTextField(props: UseTextFieldProps, ref: RefObject<HTMLInputElement | HTMLTextAreaElement | null>): {
|
|
11
|
-
inputProps: import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> | import("react").DetailedHTMLProps<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
|
|
12
|
-
labelProps: import("@react-types/shared").DOMAttributes | import("react").LabelHTMLAttributes<HTMLLabelElement>;
|
|
13
|
-
descriptionProps: import("@react-types/shared").DOMAttributes;
|
|
14
|
-
errorMessageProps: import("@react-types/shared").DOMAttributes;
|
|
15
|
-
validationErrors: string[];
|
|
16
|
-
validationDetails: ValidityState;
|
|
17
|
-
error: boolean;
|
|
18
|
-
};
|
|
19
|
-
export type UseTextFieldReturn = ReturnType<typeof useTextField>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useTextField as useTextField$1 } from "@react-aria/textfield";
|
|
3
|
-
function useTextField(props, ref) {
|
|
4
|
-
const { disabled, error, label, readonly, required, ...other } = props;
|
|
5
|
-
const { isInvalid, ...textFieldProps } = useTextField$1(
|
|
6
|
-
{
|
|
7
|
-
isDisabled: disabled,
|
|
8
|
-
isReadOnly: readonly,
|
|
9
|
-
isRequired: required,
|
|
10
|
-
isInvalid: error,
|
|
11
|
-
label,
|
|
12
|
-
errorMessage: error ? label : void 0,
|
|
13
|
-
...other
|
|
14
|
-
},
|
|
15
|
-
ref
|
|
16
|
-
);
|
|
17
|
-
return {
|
|
18
|
-
error: isInvalid,
|
|
19
|
-
...textFieldProps
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
useTextField
|
|
24
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { RefObject } from 'react';
|
|
2
|
-
import type { ExtendableProps } from '@koobiq/react-core';
|
|
3
|
-
import type { AriaToggleProps } from '@react-aria/toggle';
|
|
4
|
-
export type UseToggleProps = ExtendableProps<{
|
|
5
|
-
/**
|
|
6
|
-
* If `true`, the component will indicate an error.
|
|
7
|
-
* @default false
|
|
8
|
-
* */
|
|
9
|
-
error?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* If `true`, the component is checked.
|
|
12
|
-
* @default false
|
|
13
|
-
* */
|
|
14
|
-
checked?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* If `true`, the component is disabled.
|
|
17
|
-
* @default false
|
|
18
|
-
* */
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* If `true`, the input element is required.
|
|
22
|
-
* @default false
|
|
23
|
-
* */
|
|
24
|
-
required?: boolean;
|
|
25
|
-
/** The default checked state. Use when the component is not controlled. */
|
|
26
|
-
defaultChecked?: boolean;
|
|
27
|
-
/** Callback fired when the state is changed. */
|
|
28
|
-
onChange?: (checked: boolean) => void;
|
|
29
|
-
}, Omit<AriaToggleProps, 'isRequired' | 'isInvalid' | 'isReadOnly' | 'isSelected' | 'isDisabled' | 'defaultSelected' | 'onChange'>>;
|
|
30
|
-
export declare function useToggle(props: UseToggleProps, ref: RefObject<HTMLInputElement | null>): {
|
|
31
|
-
labelProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement> & import("react").LabelHTMLAttributes<HTMLLabelElement>;
|
|
32
|
-
inputProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement> & import("react").InputHTMLAttributes<HTMLInputElement> & {
|
|
33
|
-
ref: RefObject<HTMLInputElement | null>;
|
|
34
|
-
};
|
|
35
|
-
error: boolean;
|
|
36
|
-
pressed: boolean;
|
|
37
|
-
hovered: boolean;
|
|
38
|
-
focused: boolean;
|
|
39
|
-
checked: boolean;
|
|
40
|
-
disabled: boolean;
|
|
41
|
-
readonly: boolean;
|
|
42
|
-
focusVisible: boolean;
|
|
43
|
-
};
|
|
44
|
-
export type UseToggleReturn = ReturnType<typeof useToggle>;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useToggleState, useHover, useFocusRing, mergeProps } from "@koobiq/react-core";
|
|
3
|
-
import { useToggle as useToggle$1 } from "@react-aria/toggle";
|
|
4
|
-
function useToggle(props, ref) {
|
|
5
|
-
const { error, checked, disabled, required, defaultChecked, onChange } = props;
|
|
6
|
-
const state = useToggleState({
|
|
7
|
-
isSelected: checked,
|
|
8
|
-
defaultSelected: defaultChecked,
|
|
9
|
-
onChange
|
|
10
|
-
});
|
|
11
|
-
const { hoverProps, isHovered } = useHover({
|
|
12
|
-
isDisabled: disabled
|
|
13
|
-
});
|
|
14
|
-
const { focusProps, isFocused, isFocusVisible } = useFocusRing();
|
|
15
|
-
const {
|
|
16
|
-
labelProps: commonLabelProps,
|
|
17
|
-
inputProps: commonInputProps,
|
|
18
|
-
isInvalid,
|
|
19
|
-
isDisabled,
|
|
20
|
-
isSelected,
|
|
21
|
-
isReadOnly,
|
|
22
|
-
isPressed,
|
|
23
|
-
...other
|
|
24
|
-
} = useToggle$1(
|
|
25
|
-
{
|
|
26
|
-
...props,
|
|
27
|
-
isInvalid: error,
|
|
28
|
-
isDisabled: disabled,
|
|
29
|
-
isRequired: required
|
|
30
|
-
},
|
|
31
|
-
state,
|
|
32
|
-
ref
|
|
33
|
-
);
|
|
34
|
-
const labelProps = mergeProps(hoverProps, commonLabelProps);
|
|
35
|
-
const inputProps = mergeProps(focusProps, commonInputProps, {
|
|
36
|
-
ref
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
labelProps,
|
|
40
|
-
inputProps,
|
|
41
|
-
error: isInvalid,
|
|
42
|
-
pressed: isPressed,
|
|
43
|
-
hovered: isHovered,
|
|
44
|
-
focused: isFocused,
|
|
45
|
-
checked: isSelected,
|
|
46
|
-
disabled: isDisabled,
|
|
47
|
-
readonly: isReadOnly,
|
|
48
|
-
focusVisible: isFocusVisible,
|
|
49
|
-
...other
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
useToggle
|
|
54
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const Toggle: import("react").ForwardRefExoticComponent<Omit<import("../..").UseToggleProps, "inputRef" | keyof import("../../utils").RenderProps<import("./types").ToggleRenderProps>> & import("../../utils").RenderProps<import("./types").ToggleRenderProps> & {
|
|
2
|
-
inputRef?: import("react").RefObject<HTMLInputElement | null>;
|
|
3
|
-
} & import("react").RefAttributes<HTMLLabelElement>>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { RefObject } from 'react';
|
|
2
|
-
import type { ExtendableProps } from '@koobiq/react-core';
|
|
3
|
-
import type { UseToggleProps } from '../../behaviors';
|
|
4
|
-
import type { RenderProps } from '../../utils';
|
|
5
|
-
export type ToggleRenderProps = {
|
|
6
|
-
error?: boolean;
|
|
7
|
-
pressed?: boolean;
|
|
8
|
-
checked?: boolean;
|
|
9
|
-
hovered?: boolean;
|
|
10
|
-
focused?: boolean;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
focusVisible?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type ToggleBaseProps = RenderProps<ToggleRenderProps> & {
|
|
15
|
-
inputRef?: RefObject<HTMLInputElement | null>;
|
|
16
|
-
};
|
|
17
|
-
export type ToggleProps = ExtendableProps<ToggleBaseProps, UseToggleProps>;
|
|
18
|
-
export {};
|
package/dist/types.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ElementType } from 'react';
|
|
2
|
-
import type { AriaButtonOptions } from '@react-aria/button';
|
|
3
|
-
export type ButtonOptions = Omit<AriaButtonOptions<ElementType>, 'isDisabled'> & {
|
|
4
|
-
/** Whether the button is disabled. */
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
/** Handler that is called when the press is released over the target. */
|
|
7
|
-
onClick?: AriaButtonOptions<ElementType>['onPress'];
|
|
8
|
-
};
|