@gridui/choice 0.0.0 → 1.0.2
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/index.js +8 -29
- package/dist/index.js.map +2 -2
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/shared/use-choice.ts
|
|
2
|
+
import { focusInvalidControl, useFormReset } from "@gridui/form";
|
|
2
3
|
import { changeDetails } from "@gridui/interaction";
|
|
3
|
-
import {
|
|
4
|
+
import { useImperativeHandle, useRef, useState } from "react";
|
|
4
5
|
var useChoice = (props) => {
|
|
5
6
|
const { checked, defaultChecked = false, onCheckedChange, readOnly, disabled, inputRef, form } = props;
|
|
6
7
|
const [
|
|
@@ -16,38 +17,16 @@ var useChoice = (props) => {
|
|
|
16
17
|
useImperativeHandle(inputRef, () => {
|
|
17
18
|
return input.current;
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return;
|
|
20
|
+
useFormReset(input, () => {
|
|
21
|
+
if (checked === void 0) {
|
|
22
|
+
setLocal(initial.current);
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
const reset = (event) => {
|
|
26
|
-
setTimeout(() => {
|
|
27
|
-
if (mounted && !event.defaultPrevented && checked === void 0) {
|
|
28
|
-
setLocal(initial.current);
|
|
29
|
-
}
|
|
30
|
-
}, 0);
|
|
31
|
-
};
|
|
32
|
-
owner.addEventListener("reset", reset);
|
|
33
|
-
return () => {
|
|
34
|
-
mounted = false;
|
|
35
|
-
owner.removeEventListener("reset", reset);
|
|
36
|
-
};
|
|
37
|
-
}, [
|
|
38
|
-
checked,
|
|
39
|
-
form
|
|
40
|
-
]);
|
|
24
|
+
}, form);
|
|
41
25
|
const current = checked ?? local;
|
|
42
26
|
const invalid = (event) => {
|
|
43
|
-
event
|
|
44
|
-
const owner = event.currentTarget.form;
|
|
45
|
-
const firstInvalid = owner && Array.from(owner.elements).find((element) => {
|
|
46
|
-
return "willValidate" in element && element.willValidate && element.matches(":invalid");
|
|
47
|
-
});
|
|
48
|
-
if (!owner || firstInvalid === event.currentTarget) {
|
|
27
|
+
focusInvalidControl(event, () => {
|
|
49
28
|
control.current?.focus();
|
|
50
|
-
}
|
|
29
|
+
});
|
|
51
30
|
};
|
|
52
31
|
const change = (next, event) => {
|
|
53
32
|
if (readOnly || disabled || input.current?.matches(":disabled")) {
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/shared/use-choice.ts", "../src/checkbox/style.ts", "../src/checkbox/checkbox.tsx", "../src/switch/style.ts", "../src/switch/switch.tsx", "../src/toggle-group/style.ts", "../src/toggle-group/toggle-group.tsx", "../src/toggle-group-item/style.ts", "../src/toggle-group-item/toggle-group-item.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Use Choice\n */\n\nimport { type ChangeDetails, changeDetails } from \"@gridui/interaction\";\nimport { type ComponentPropsWithRef, type Ref, type SyntheticEvent, useEffect, useImperativeHandle, useRef, useState } from \"react\";\n\nexport type ChoiceProps = Omit<ComponentPropsWithRef<\"button\">, \"children\" | \"onChange\" | \"defaultChecked\"> & {\n readonly checked?: boolean | undefined;\n readonly defaultChecked?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly required?: boolean | undefined;\n readonly uncheckedValue?: string | undefined;\n readonly inputRef?: Ref<HTMLInputElement> | undefined;\n readonly onCheckedChange?: ((checked: boolean, details: ChangeDetails) => void) | undefined;\n};\n\nexport const useChoice = (props: ChoiceProps) => {\n const { checked, defaultChecked = false, onCheckedChange, readOnly, disabled, inputRef, form } = props;\n const [\n local,\n setLocal,\n ] = useState(defaultChecked);\n const input = useRef<HTMLInputElement>(null);\n const control = useRef<HTMLButtonElement>(null);\n const initial = useRef(defaultChecked);\n useImperativeHandle(props.ref, () => {\n return control.current as HTMLButtonElement;\n });\n useImperativeHandle(inputRef, () => {\n return input.current as HTMLInputElement;\n });\n useEffect(() => {\n const owner = input.current?.form;\n if (!owner) {\n return;\n }\n let mounted = true;\n const reset = (event: Event) => {\n // Wait until React bubbling handlers can cancel the native reset.\n setTimeout(() => {\n if (mounted && !event.defaultPrevented && checked === undefined) {\n setLocal(initial.current);\n }\n }, 0);\n };\n owner.addEventListener(\"reset\", reset);\n return () => {\n mounted = false;\n owner.removeEventListener(\"reset\", reset);\n };\n }, [\n checked,\n form,\n ]);\n const current = checked ?? local;\n const invalid = (event: SyntheticEvent<HTMLInputElement>) => {\n event.preventDefault();\n const owner = event.currentTarget.form;\n const firstInvalid = owner && Array.from(owner.elements).find(element => {\n return \"willValidate\" in element && element.willValidate && element.matches(\":invalid\");\n });\n if (!owner || firstInvalid === event.currentTarget) {\n control.current?.focus();\n }\n };\n const change = (next: boolean, event: Event) => {\n if (readOnly || disabled || input.current?.matches(\":disabled\")) {\n return;\n }\n const details = changeDetails(event);\n onCheckedChange?.(next, details);\n if (!details.isCanceled && checked === undefined) {\n setLocal(next);\n }\n };\n return {\n current,\n input,\n control,\n change,\n invalid,\n };\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Checkbox\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const choiceStyles = cva(\"inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-control border border-control-border bg-background text-foreground align-middle data-[state=checked]:bg-accent-background data-[state=checked]:text-accent-foreground data-[state=indeterminate]:bg-accent-background data-[state=indeterminate]:text-accent-foreground data-disabled:cursor-not-allowed data-disabled:opacity-50 data-readonly:cursor-default aria-invalid:border-danger-foreground\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Checkbox\n * @description Checkbox\n */\n\nimport { type ChoiceProps, useChoice } from \"../shared/use-choice\";\nimport { choiceStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-checkbox\";\nimport { Check, Minus } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type CheckboxProps = ChoiceProps & {\n readonly indeterminate?: boolean | undefined;\n};\n\nexport const Checkbox: FC<CheckboxProps> = (props: CheckboxProps) => {\n const { className, indeterminate, inputRef, onCheckedChange, checked, defaultChecked,\n readOnly, uncheckedValue, name, value = \"on\", form, required, onClick, ...restProps } = props;\n const { current, input, control, change, invalid } = useChoice({\n ...props,\n inputRef,\n onCheckedChange,\n checked,\n defaultChecked,\n });\n return (<>\n <Primitive.Root\n {...restProps}\n ref={control}\n checked={indeterminate ? \"indeterminate\" : current}\n aria-required={required}\n aria-readonly={readOnly}\n data-readonly={readOnly ? \"\" : undefined}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n change(indeterminate ? true : !current, event.nativeEvent);\n }\n event.preventDefault();\n }}\n className={cn(choiceStyles(), className)}\n >\n <Primitive.Indicator>\n {indeterminate ? (<Minus\n size={16}\n aria-hidden=\"true\"\n />) : (<Check\n size={16}\n aria-hidden=\"true\"\n />)}\n </Primitive.Indicator>\n </Primitive.Root>\n <input\n ref={input}\n type=\"checkbox\"\n className=\"sr-only\"\n tabIndex={-1}\n aria-hidden=\"true\"\n name={name}\n value={value}\n form={form}\n required={required}\n disabled={props.disabled}\n checked={current}\n readOnly={readOnly}\n onInvalid={invalid}\n onChange={(event) => {\n change(event.target.checked, event.nativeEvent);\n }}\n />\n {!current && uncheckedValue !== undefined && (<input\n type=\"hidden\"\n name={name}\n form={form}\n value={uncheckedValue}\n disabled={props.disabled}\n />)}\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Switch\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const switchStyles = cva(\"gridui-switch inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-control border border-control-border bg-surface p-0.5 align-middle data-[state=checked]:bg-accent-background data-disabled:cursor-not-allowed data-disabled:opacity-50 data-readonly:cursor-default aria-invalid:border-danger-foreground\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Switch\n * @description Switch\n */\n\nimport { type ChoiceProps, useChoice } from \"../shared/use-choice\";\nimport { switchStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-switch\";\nimport type { FC } from \"react\";\n\nexport type SwitchProps = ChoiceProps;\n\nexport const Switch: FC<SwitchProps> = (props: SwitchProps) => {\n const { className, inputRef, onCheckedChange, checked, defaultChecked,\n readOnly, uncheckedValue, name, value = \"on\", form, required, onClick, ...restProps } = props;\n const { current, input, control, change, invalid } = useChoice({\n ...props,\n inputRef,\n onCheckedChange,\n checked,\n defaultChecked,\n });\n return (<>\n <Primitive.Root\n {...restProps}\n ref={control}\n checked={current}\n aria-required={required}\n aria-readonly={readOnly}\n data-readonly={readOnly ? \"\" : undefined}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n change(!current, event.nativeEvent);\n }\n event.preventDefault();\n }}\n className={cn(switchStyles(), className)}\n >\n <Primitive.Thumb\n className=\"gridui-switch-thumb\"\n />\n </Primitive.Root>\n <input\n ref={input}\n type=\"checkbox\"\n className=\"sr-only\"\n tabIndex={-1}\n aria-hidden=\"true\"\n name={name}\n value={value}\n form={form}\n required={required}\n disabled={props.disabled}\n checked={current}\n readOnly={readOnly}\n onInvalid={invalid}\n onChange={(event) => {\n change(event.target.checked, event.nativeEvent);\n }}\n />\n {!current && uncheckedValue !== undefined && (<input\n type=\"hidden\"\n name={name}\n form={form}\n value={uncheckedValue}\n disabled={props.disabled}\n />)}\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroup\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const toggleGroupStyles = cva(\"inline-flex max-w-full flex-wrap gap-px border border-border bg-border data-[orientation=vertical]:flex-col\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroup\n * @description Toggle Group\n */\n\nimport { toggleGroupStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-toggle-group\";\nimport { type ComponentPropsWithRef, type FC, useState } from \"react\";\n\nexport type ToggleGroupProps = Omit<ComponentPropsWithRef<typeof Primitive.Root>, \"type\" | \"value\" | \"defaultValue\" | \"onValueChange\" | \"loop\"> & {\n readonly multiple?: boolean | undefined;\n readonly value?: string[] | undefined;\n readonly defaultValue?: string[] | undefined;\n readonly onValueChange?: ((value: string[]) => void) | undefined;\n readonly loopFocus?: boolean | undefined;\n};\n\nexport const ToggleGroup: FC<ToggleGroupProps> = (props: ToggleGroupProps) => {\n const { className, multiple, value, defaultValue, onValueChange, loopFocus = true, ...restProps } = props;\n const [\n local,\n setLocal,\n ] = useState(defaultValue ?? []);\n return (<Primitive.Root\n {...restProps}\n loop={loopFocus}\n className={cn(toggleGroupStyles(), className)}\n type=\"multiple\"\n value={value ?? local}\n onValueChange={(next) => {\n const selected = multiple ? next : next.slice(-1);\n if (value === undefined) {\n setLocal(selected);\n }\n onValueChange?.(selected);\n }}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroupItem\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const toggleStyles = cva(\"min-h-11 cursor-pointer border-0 bg-background px-gridui-16 py-gridui-8 text-foreground type-ui hover:enabled:bg-surface-hover data-[state=on]:bg-accent-background data-[state=on]:text-accent-foreground data-[state=on]:hover:enabled:bg-accent-background data-disabled:cursor-not-allowed data-disabled:opacity-50\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroupItem\n * @description Toggle Group Item\n */\n\nimport { toggleStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-toggle-group\";\nimport { type ComponentPropsWithRef, type FC } from \"react\";\n\nexport type ToggleGroupItemProps = ComponentPropsWithRef<typeof Primitive.Item>;\n\nexport const ToggleGroupItem: FC<ToggleGroupItemProps> = (props: ToggleGroupItemProps) => {\n const { className, ...restProps } = props;\n return (<Primitive.Item\n {...restProps}\n className={cn(toggleStyles(), className)}\n />);\n};\n"],
|
|
5
|
-
"mappings": ";AAOA,SAA6B,qBAAqB;AAClD,SAAoE,
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Use Choice\n */\n\nimport { focusInvalidControl, useFormReset } from \"@gridui/form\";\nimport { type ChangeDetails, changeDetails } from \"@gridui/interaction\";\nimport { type ComponentPropsWithRef, type Ref, type SyntheticEvent, useImperativeHandle, useRef, useState } from \"react\";\n\nexport type ChoiceProps = Omit<ComponentPropsWithRef<\"button\">, \"children\" | \"onChange\" | \"defaultChecked\"> & {\n readonly checked?: boolean | undefined;\n readonly defaultChecked?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly required?: boolean | undefined;\n readonly uncheckedValue?: string | undefined;\n readonly inputRef?: Ref<HTMLInputElement> | undefined;\n readonly onCheckedChange?: ((checked: boolean, details: ChangeDetails) => void) | undefined;\n};\n\nexport const useChoice = (props: ChoiceProps) => {\n const { checked, defaultChecked = false, onCheckedChange, readOnly, disabled, inputRef, form } = props;\n const [\n local,\n setLocal,\n ] = useState(defaultChecked);\n const input = useRef<HTMLInputElement>(null);\n const control = useRef<HTMLButtonElement>(null);\n const initial = useRef(defaultChecked);\n useImperativeHandle(props.ref, () => {\n return control.current as HTMLButtonElement;\n });\n useImperativeHandle(inputRef, () => {\n return input.current as HTMLInputElement;\n });\n useFormReset(input, () => {\n if (checked === undefined) {\n setLocal(initial.current);\n }\n }, form);\n const current = checked ?? local;\n const invalid = (event: SyntheticEvent<HTMLInputElement>) => {\n focusInvalidControl(event, () => {\n control.current?.focus();\n });\n };\n const change = (next: boolean, event: Event) => {\n if (readOnly || disabled || input.current?.matches(\":disabled\")) {\n return;\n }\n const details = changeDetails(event);\n onCheckedChange?.(next, details);\n if (!details.isCanceled && checked === undefined) {\n setLocal(next);\n }\n };\n return {\n current,\n input,\n control,\n change,\n invalid,\n };\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Checkbox\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const choiceStyles = cva(\"inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-control border border-control-border bg-background text-foreground align-middle data-[state=checked]:bg-accent-background data-[state=checked]:text-accent-foreground data-[state=indeterminate]:bg-accent-background data-[state=indeterminate]:text-accent-foreground data-disabled:cursor-not-allowed data-disabled:opacity-50 data-readonly:cursor-default aria-invalid:border-danger-foreground\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Checkbox\n * @description Checkbox\n */\n\nimport { type ChoiceProps, useChoice } from \"../shared/use-choice\";\nimport { choiceStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-checkbox\";\nimport { Check, Minus } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type CheckboxProps = ChoiceProps & {\n readonly indeterminate?: boolean | undefined;\n};\n\nexport const Checkbox: FC<CheckboxProps> = (props: CheckboxProps) => {\n const { className, indeterminate, inputRef, onCheckedChange, checked, defaultChecked,\n readOnly, uncheckedValue, name, value = \"on\", form, required, onClick, ...restProps } = props;\n const { current, input, control, change, invalid } = useChoice({\n ...props,\n inputRef,\n onCheckedChange,\n checked,\n defaultChecked,\n });\n return (<>\n <Primitive.Root\n {...restProps}\n ref={control}\n checked={indeterminate ? \"indeterminate\" : current}\n aria-required={required}\n aria-readonly={readOnly}\n data-readonly={readOnly ? \"\" : undefined}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n change(indeterminate ? true : !current, event.nativeEvent);\n }\n event.preventDefault();\n }}\n className={cn(choiceStyles(), className)}\n >\n <Primitive.Indicator>\n {indeterminate ? (<Minus\n size={16}\n aria-hidden=\"true\"\n />) : (<Check\n size={16}\n aria-hidden=\"true\"\n />)}\n </Primitive.Indicator>\n </Primitive.Root>\n <input\n ref={input}\n type=\"checkbox\"\n className=\"sr-only\"\n tabIndex={-1}\n aria-hidden=\"true\"\n name={name}\n value={value}\n form={form}\n required={required}\n disabled={props.disabled}\n checked={current}\n readOnly={readOnly}\n onInvalid={invalid}\n onChange={(event) => {\n change(event.target.checked, event.nativeEvent);\n }}\n />\n {!current && uncheckedValue !== undefined && (<input\n type=\"hidden\"\n name={name}\n form={form}\n value={uncheckedValue}\n disabled={props.disabled}\n />)}\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Switch\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const switchStyles = cva(\"gridui-switch inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-control border border-control-border bg-surface p-0.5 align-middle data-[state=checked]:bg-accent-background data-disabled:cursor-not-allowed data-disabled:opacity-50 data-readonly:cursor-default aria-invalid:border-danger-foreground\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Switch\n * @description Switch\n */\n\nimport { type ChoiceProps, useChoice } from \"../shared/use-choice\";\nimport { switchStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-switch\";\nimport type { FC } from \"react\";\n\nexport type SwitchProps = ChoiceProps;\n\nexport const Switch: FC<SwitchProps> = (props: SwitchProps) => {\n const { className, inputRef, onCheckedChange, checked, defaultChecked,\n readOnly, uncheckedValue, name, value = \"on\", form, required, onClick, ...restProps } = props;\n const { current, input, control, change, invalid } = useChoice({\n ...props,\n inputRef,\n onCheckedChange,\n checked,\n defaultChecked,\n });\n return (<>\n <Primitive.Root\n {...restProps}\n ref={control}\n checked={current}\n aria-required={required}\n aria-readonly={readOnly}\n data-readonly={readOnly ? \"\" : undefined}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n change(!current, event.nativeEvent);\n }\n event.preventDefault();\n }}\n className={cn(switchStyles(), className)}\n >\n <Primitive.Thumb\n className=\"gridui-switch-thumb\"\n />\n </Primitive.Root>\n <input\n ref={input}\n type=\"checkbox\"\n className=\"sr-only\"\n tabIndex={-1}\n aria-hidden=\"true\"\n name={name}\n value={value}\n form={form}\n required={required}\n disabled={props.disabled}\n checked={current}\n readOnly={readOnly}\n onInvalid={invalid}\n onChange={(event) => {\n change(event.target.checked, event.nativeEvent);\n }}\n />\n {!current && uncheckedValue !== undefined && (<input\n type=\"hidden\"\n name={name}\n form={form}\n value={uncheckedValue}\n disabled={props.disabled}\n />)}\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroup\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const toggleGroupStyles = cva(\"inline-flex max-w-full flex-wrap gap-px border border-border bg-border data-[orientation=vertical]:flex-col\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroup\n * @description Toggle Group\n */\n\nimport { toggleGroupStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-toggle-group\";\nimport { type ComponentPropsWithRef, type FC, useState } from \"react\";\n\nexport type ToggleGroupProps = Omit<ComponentPropsWithRef<typeof Primitive.Root>, \"type\" | \"value\" | \"defaultValue\" | \"onValueChange\" | \"loop\"> & {\n readonly multiple?: boolean | undefined;\n readonly value?: string[] | undefined;\n readonly defaultValue?: string[] | undefined;\n readonly onValueChange?: ((value: string[]) => void) | undefined;\n readonly loopFocus?: boolean | undefined;\n};\n\nexport const ToggleGroup: FC<ToggleGroupProps> = (props: ToggleGroupProps) => {\n const { className, multiple, value, defaultValue, onValueChange, loopFocus = true, ...restProps } = props;\n const [\n local,\n setLocal,\n ] = useState(defaultValue ?? []);\n return (<Primitive.Root\n {...restProps}\n loop={loopFocus}\n className={cn(toggleGroupStyles(), className)}\n type=\"multiple\"\n value={value ?? local}\n onValueChange={(next) => {\n const selected = multiple ? next : next.slice(-1);\n if (value === undefined) {\n setLocal(selected);\n }\n onValueChange?.(selected);\n }}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroupItem\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const toggleStyles = cva(\"min-h-11 cursor-pointer border-0 bg-background px-gridui-16 py-gridui-8 text-foreground type-ui hover:enabled:bg-surface-hover data-[state=on]:bg-accent-background data-[state=on]:text-accent-foreground data-[state=on]:hover:enabled:bg-accent-background data-disabled:cursor-not-allowed data-disabled:opacity-50\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroupItem\n * @description Toggle Group Item\n */\n\nimport { toggleStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-toggle-group\";\nimport { type ComponentPropsWithRef, type FC } from \"react\";\n\nexport type ToggleGroupItemProps = ComponentPropsWithRef<typeof Primitive.Item>;\n\nexport const ToggleGroupItem: FC<ToggleGroupItemProps> = (props: ToggleGroupItemProps) => {\n const { className, ...restProps } = props;\n return (<Primitive.Item\n {...restProps}\n className={cn(toggleStyles(), className)}\n />);\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,qBAAqB,oBAAoB;AAClD,SAA6B,qBAAqB;AAClD,SAAoE,qBAAqB,QAAQ,gBAAgB;AAY1G,IAAM,YAAY,CAAC,UAAuB;AAC7C,QAAM,EAAE,SAAS,iBAAiB,OAAO,iBAAiB,UAAU,UAAU,UAAU,KAAK,IAAI;AACjG,QAAM;AAAA,IACF;AAAA,IACA;AAAA,EACJ,IAAI,SAAS,cAAc;AAC3B,QAAM,QAAQ,OAAyB,IAAI;AAC3C,QAAM,UAAU,OAA0B,IAAI;AAC9C,QAAM,UAAU,OAAO,cAAc;AACrC,sBAAoB,MAAM,KAAK,MAAM;AACjC,WAAO,QAAQ;AAAA,EACnB,CAAC;AACD,sBAAoB,UAAU,MAAM;AAChC,WAAO,MAAM;AAAA,EACjB,CAAC;AACD,eAAa,OAAO,MAAM;AACtB,QAAI,YAAY,QAAW;AACvB,eAAS,QAAQ,OAAO;AAAA,IA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|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/choice",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "GridUI React choice",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -26,21 +26,21 @@
|
|
|
26
26
|
"react-dom": "^19.2.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@gridui/
|
|
30
|
-
"@gridui/
|
|
31
|
-
"@gridui/
|
|
29
|
+
"@gridui/form": "^2.0.1",
|
|
30
|
+
"@gridui/interaction": "^1.1.1",
|
|
31
|
+
"@gridui/style-utils": "^2.1.3",
|
|
32
|
+
"@gridui/theme": "^2.2.1",
|
|
32
33
|
"@radix-ui/react-checkbox": "1.4.1",
|
|
33
34
|
"@radix-ui/react-switch": "1.4.1",
|
|
34
35
|
"@radix-ui/react-toggle-group": "1.2.1",
|
|
35
36
|
"class-variance-authority": "0.7.1",
|
|
36
|
-
"lucide-react": "1.
|
|
37
|
+
"lucide-react": "1.63.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@gridui-internal/configuration": "0.0.0",
|
|
40
|
-
"@gridui/tabs": "0.0.0",
|
|
40
|
+
"@gridui-internal/configuration": "0.0.0-internal",
|
|
41
41
|
"@jest/globals": "30.5.2",
|
|
42
42
|
"@types/jest": "30.0.0",
|
|
43
|
-
"@types/node": "26.6.
|
|
43
|
+
"@types/node": "26.6.6",
|
|
44
44
|
"@types/react": "19.3.0",
|
|
45
45
|
"@types/react-dom": "19.3.0",
|
|
46
46
|
"jest": "30.5.2",
|