@nextui-org/button
Advanced tools
Comparing version 0.0.0-dev-v2-20230326032643 to 0.0.0-dev-v2-20230326122446
@@ -32,5 +32,4 @@ "use strict"; | ||
var import_react = require("react"); | ||
var import_button = require("@react-aria/button"); | ||
var import_focus = require("@react-aria/focus"); | ||
var import_utils = require("@react-aria/utils"); | ||
var import_focus2 = require("@react-aria/focus"); | ||
var import_utils3 = require("@react-aria/utils"); | ||
var import_drip = require("@nextui-org/drip"); | ||
@@ -41,2 +40,75 @@ var import_dom_utils = require("@nextui-org/dom-utils"); | ||
// src/use-aria-button.ts | ||
var import_utils = require("@react-aria/utils"); | ||
var import_utils2 = require("@react-aria/utils"); | ||
var import_focus = require("@react-aria/focus"); | ||
var import_interactions = require("@react-aria/interactions"); | ||
function useButton(props, ref) { | ||
let { | ||
elementType = "button", | ||
isDisabled, | ||
onPress, | ||
onPressStart, | ||
onPressEnd, | ||
onPressChange, | ||
preventFocusOnPress, | ||
allowFocusWhenDisabled, | ||
onClick: deprecatedOnClick, | ||
href, | ||
target, | ||
rel, | ||
type = "button" | ||
} = props; | ||
let additionalProps; | ||
if (elementType === "button") { | ||
additionalProps = { | ||
type, | ||
disabled: isDisabled | ||
}; | ||
} else { | ||
additionalProps = { | ||
role: "button", | ||
tabIndex: isDisabled ? void 0 : 0, | ||
href: elementType === "a" && isDisabled ? void 0 : href, | ||
target: elementType === "a" ? target : void 0, | ||
type: elementType === "input" ? type : void 0, | ||
disabled: elementType === "input" ? isDisabled : void 0, | ||
"aria-disabled": !isDisabled || elementType === "input" ? void 0 : isDisabled, | ||
rel: elementType === "a" ? rel : void 0 | ||
}; | ||
} | ||
let { pressProps, isPressed } = (0, import_interactions.usePress)({ | ||
onPressStart, | ||
onPressEnd, | ||
onPressChange, | ||
onPress, | ||
isDisabled, | ||
preventFocusOnPress, | ||
ref | ||
}); | ||
let { focusableProps } = (0, import_focus.useFocusable)(props, ref); | ||
if (allowFocusWhenDisabled) { | ||
focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex; | ||
} | ||
let buttonProps = (0, import_utils2.mergeProps)( | ||
focusableProps, | ||
pressProps, | ||
(0, import_utils.filterDOMProps)(props, { labelable: true }) | ||
); | ||
return { | ||
isPressed, | ||
buttonProps: (0, import_utils2.mergeProps)(additionalProps, buttonProps, { | ||
"aria-haspopup": props["aria-haspopup"], | ||
"aria-expanded": props["aria-expanded"], | ||
"aria-controls": props["aria-controls"], | ||
"aria-pressed": props["aria-pressed"], | ||
onClick: (e) => { | ||
if (deprecatedOnClick) { | ||
deprecatedOnClick(e); | ||
} | ||
} | ||
}) | ||
}; | ||
} | ||
// src/button-group-context.ts | ||
@@ -50,3 +122,3 @@ var import_shared_utils = require("@nextui-org/shared-utils"); | ||
// src/use-button.ts | ||
function useButton(props) { | ||
function useButton2(props) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i; | ||
@@ -78,3 +150,3 @@ const groupContext = useButtonGroupContext(); | ||
const domRef = (0, import_dom_utils.useDOMRef)(ref); | ||
const { isFocusVisible, isFocused, focusProps } = (0, import_focus.useFocusRing)({ | ||
const { isFocusVisible, isFocused, focusProps } = (0, import_focus2.useFocusRing)({ | ||
autoFocus | ||
@@ -116,3 +188,3 @@ }); | ||
}; | ||
const { buttonProps: ariaButtonProps } = (0, import_button.useButton)( | ||
const { buttonProps: ariaButtonProps } = useButton( | ||
{ | ||
@@ -132,3 +204,3 @@ elementType: as, | ||
"data-focused": (0, import_shared_utils2.dataAttr)(isFocused), | ||
...(0, import_utils.mergeProps)(ariaButtonProps, focusProps, otherProps) | ||
...(0, import_utils3.mergeProps)(ariaButtonProps, focusProps, otherProps) | ||
}), | ||
@@ -170,3 +242,3 @@ [ariaButtonProps, focusProps, otherProps] | ||
getButtonProps | ||
} = useButton({ | ||
} = useButton2({ | ||
ref, | ||
@@ -173,0 +245,0 @@ ...props |
@@ -25,3 +25,3 @@ "use strict"; | ||
ButtonGroup: () => button_group_default, | ||
useButton: () => useButton, | ||
useButton: () => useButton2, | ||
useButtonGroup: () => useButtonGroup | ||
@@ -38,5 +38,4 @@ }); | ||
var import_react = require("react"); | ||
var import_button = require("@react-aria/button"); | ||
var import_focus = require("@react-aria/focus"); | ||
var import_utils = require("@react-aria/utils"); | ||
var import_focus2 = require("@react-aria/focus"); | ||
var import_utils3 = require("@react-aria/utils"); | ||
var import_drip = require("@nextui-org/drip"); | ||
@@ -47,2 +46,75 @@ var import_dom_utils = require("@nextui-org/dom-utils"); | ||
// src/use-aria-button.ts | ||
var import_utils = require("@react-aria/utils"); | ||
var import_utils2 = require("@react-aria/utils"); | ||
var import_focus = require("@react-aria/focus"); | ||
var import_interactions = require("@react-aria/interactions"); | ||
function useButton(props, ref) { | ||
let { | ||
elementType = "button", | ||
isDisabled, | ||
onPress, | ||
onPressStart, | ||
onPressEnd, | ||
onPressChange, | ||
preventFocusOnPress, | ||
allowFocusWhenDisabled, | ||
onClick: deprecatedOnClick, | ||
href, | ||
target, | ||
rel, | ||
type = "button" | ||
} = props; | ||
let additionalProps; | ||
if (elementType === "button") { | ||
additionalProps = { | ||
type, | ||
disabled: isDisabled | ||
}; | ||
} else { | ||
additionalProps = { | ||
role: "button", | ||
tabIndex: isDisabled ? void 0 : 0, | ||
href: elementType === "a" && isDisabled ? void 0 : href, | ||
target: elementType === "a" ? target : void 0, | ||
type: elementType === "input" ? type : void 0, | ||
disabled: elementType === "input" ? isDisabled : void 0, | ||
"aria-disabled": !isDisabled || elementType === "input" ? void 0 : isDisabled, | ||
rel: elementType === "a" ? rel : void 0 | ||
}; | ||
} | ||
let { pressProps, isPressed } = (0, import_interactions.usePress)({ | ||
onPressStart, | ||
onPressEnd, | ||
onPressChange, | ||
onPress, | ||
isDisabled, | ||
preventFocusOnPress, | ||
ref | ||
}); | ||
let { focusableProps } = (0, import_focus.useFocusable)(props, ref); | ||
if (allowFocusWhenDisabled) { | ||
focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex; | ||
} | ||
let buttonProps = (0, import_utils2.mergeProps)( | ||
focusableProps, | ||
pressProps, | ||
(0, import_utils.filterDOMProps)(props, { labelable: true }) | ||
); | ||
return { | ||
isPressed, | ||
buttonProps: (0, import_utils2.mergeProps)(additionalProps, buttonProps, { | ||
"aria-haspopup": props["aria-haspopup"], | ||
"aria-expanded": props["aria-expanded"], | ||
"aria-controls": props["aria-controls"], | ||
"aria-pressed": props["aria-pressed"], | ||
onClick: (e) => { | ||
if (deprecatedOnClick) { | ||
deprecatedOnClick(e); | ||
} | ||
} | ||
}) | ||
}; | ||
} | ||
// src/button-group-context.ts | ||
@@ -56,3 +128,3 @@ var import_shared_utils = require("@nextui-org/shared-utils"); | ||
// src/use-button.ts | ||
function useButton(props) { | ||
function useButton2(props) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i; | ||
@@ -84,3 +156,3 @@ const groupContext = useButtonGroupContext(); | ||
const domRef = (0, import_dom_utils.useDOMRef)(ref); | ||
const { isFocusVisible, isFocused, focusProps } = (0, import_focus.useFocusRing)({ | ||
const { isFocusVisible, isFocused, focusProps } = (0, import_focus2.useFocusRing)({ | ||
autoFocus | ||
@@ -122,3 +194,3 @@ }); | ||
}; | ||
const { buttonProps: ariaButtonProps } = (0, import_button.useButton)( | ||
const { buttonProps: ariaButtonProps } = useButton( | ||
{ | ||
@@ -138,3 +210,3 @@ elementType: as, | ||
"data-focused": (0, import_shared_utils2.dataAttr)(isFocused), | ||
...(0, import_utils.mergeProps)(ariaButtonProps, focusProps, otherProps) | ||
...(0, import_utils3.mergeProps)(ariaButtonProps, focusProps, otherProps) | ||
}), | ||
@@ -176,3 +248,3 @@ [ariaButtonProps, focusProps, otherProps] | ||
getButtonProps | ||
} = useButton({ | ||
} = useButton2({ | ||
ref, | ||
@@ -179,0 +251,0 @@ ...props |
@@ -23,3 +23,3 @@ "use strict"; | ||
__export(use_button_exports, { | ||
useButton: () => useButton | ||
useButton: () => useButton2 | ||
}); | ||
@@ -29,5 +29,4 @@ module.exports = __toCommonJS(use_button_exports); | ||
var import_react = require("react"); | ||
var import_button = require("@react-aria/button"); | ||
var import_focus = require("@react-aria/focus"); | ||
var import_utils = require("@react-aria/utils"); | ||
var import_focus2 = require("@react-aria/focus"); | ||
var import_utils3 = require("@react-aria/utils"); | ||
var import_drip = require("@nextui-org/drip"); | ||
@@ -38,2 +37,75 @@ var import_dom_utils = require("@nextui-org/dom-utils"); | ||
// src/use-aria-button.ts | ||
var import_utils = require("@react-aria/utils"); | ||
var import_utils2 = require("@react-aria/utils"); | ||
var import_focus = require("@react-aria/focus"); | ||
var import_interactions = require("@react-aria/interactions"); | ||
function useButton(props, ref) { | ||
let { | ||
elementType = "button", | ||
isDisabled, | ||
onPress, | ||
onPressStart, | ||
onPressEnd, | ||
onPressChange, | ||
preventFocusOnPress, | ||
allowFocusWhenDisabled, | ||
onClick: deprecatedOnClick, | ||
href, | ||
target, | ||
rel, | ||
type = "button" | ||
} = props; | ||
let additionalProps; | ||
if (elementType === "button") { | ||
additionalProps = { | ||
type, | ||
disabled: isDisabled | ||
}; | ||
} else { | ||
additionalProps = { | ||
role: "button", | ||
tabIndex: isDisabled ? void 0 : 0, | ||
href: elementType === "a" && isDisabled ? void 0 : href, | ||
target: elementType === "a" ? target : void 0, | ||
type: elementType === "input" ? type : void 0, | ||
disabled: elementType === "input" ? isDisabled : void 0, | ||
"aria-disabled": !isDisabled || elementType === "input" ? void 0 : isDisabled, | ||
rel: elementType === "a" ? rel : void 0 | ||
}; | ||
} | ||
let { pressProps, isPressed } = (0, import_interactions.usePress)({ | ||
onPressStart, | ||
onPressEnd, | ||
onPressChange, | ||
onPress, | ||
isDisabled, | ||
preventFocusOnPress, | ||
ref | ||
}); | ||
let { focusableProps } = (0, import_focus.useFocusable)(props, ref); | ||
if (allowFocusWhenDisabled) { | ||
focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex; | ||
} | ||
let buttonProps = (0, import_utils2.mergeProps)( | ||
focusableProps, | ||
pressProps, | ||
(0, import_utils.filterDOMProps)(props, { labelable: true }) | ||
); | ||
return { | ||
isPressed, | ||
buttonProps: (0, import_utils2.mergeProps)(additionalProps, buttonProps, { | ||
"aria-haspopup": props["aria-haspopup"], | ||
"aria-expanded": props["aria-expanded"], | ||
"aria-controls": props["aria-controls"], | ||
"aria-pressed": props["aria-pressed"], | ||
onClick: (e) => { | ||
if (deprecatedOnClick) { | ||
deprecatedOnClick(e); | ||
} | ||
} | ||
}) | ||
}; | ||
} | ||
// src/button-group-context.ts | ||
@@ -47,3 +119,3 @@ var import_shared_utils = require("@nextui-org/shared-utils"); | ||
// src/use-button.ts | ||
function useButton(props) { | ||
function useButton2(props) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i; | ||
@@ -75,3 +147,3 @@ const groupContext = useButtonGroupContext(); | ||
const domRef = (0, import_dom_utils.useDOMRef)(ref); | ||
const { isFocusVisible, isFocused, focusProps } = (0, import_focus.useFocusRing)({ | ||
const { isFocusVisible, isFocused, focusProps } = (0, import_focus2.useFocusRing)({ | ||
autoFocus | ||
@@ -113,3 +185,3 @@ }); | ||
}; | ||
const { buttonProps: ariaButtonProps } = (0, import_button.useButton)( | ||
const { buttonProps: ariaButtonProps } = useButton( | ||
{ | ||
@@ -129,3 +201,3 @@ elementType: as, | ||
"data-focused": (0, import_shared_utils2.dataAttr)(isFocused), | ||
...(0, import_utils.mergeProps)(ariaButtonProps, focusProps, otherProps) | ||
...(0, import_utils3.mergeProps)(ariaButtonProps, focusProps, otherProps) | ||
}), | ||
@@ -132,0 +204,0 @@ [ariaButtonProps, focusProps, otherProps] |
{ | ||
"name": "@nextui-org/button", | ||
"version": "0.0.0-dev-v2-20230326032643", | ||
"version": "0.0.0-dev-v2-20230326122446", | ||
"description": "Buttons allow users to perform actions and choose with a single tap.", | ||
@@ -35,8 +35,8 @@ "keywords": [ | ||
"@react-aria/focus": "^3.11.0", | ||
"@nextui-org/system": "0.0.0-dev-v2-20230326032643", | ||
"@nextui-org/shared-utils": "0.0.0-dev-v2-20230326032643", | ||
"@nextui-org/dom-utils": "0.0.0-dev-v2-20230326032643", | ||
"@nextui-org/shared-utils": "0.0.0-dev-v2-20230326032643", | ||
"@nextui-org/system": "0.0.0-dev-v2-20230326032643", | ||
"@nextui-org/theme": "0.0.0-dev-v2-20230326032643", | ||
"@nextui-org/drip": "0.0.0-dev-v2-20230326032643", | ||
"@nextui-org/spinner": "0.0.0-dev-v2-20230326032643" | ||
"@nextui-org/spinner": "0.0.0-dev-v2-20230326032643", | ||
"@nextui-org/theme": "0.0.0-dev-v2-20230326032643" | ||
}, | ||
@@ -48,4 +48,4 @@ "devDependencies": { | ||
"react": "^18.0.0", | ||
"@nextui-org/shared-icons": "0.0.0-dev-v2-20230326032643", | ||
"@nextui-org/spinner": "0.0.0-dev-v2-20230326032643" | ||
"@nextui-org/spinner": "0.0.0-dev-v2-20230326032643", | ||
"@nextui-org/shared-icons": "0.0.0-dev-v2-20230326032643" | ||
}, | ||
@@ -52,0 +52,0 @@ "clean-package": "../../../clean-package.config.json", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
56757
30
1693