@fluentui/react-button 0.0.0-nightly-20230317-1454.1 → 0.0.0-nightly-20230322-0439.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/.swcrc +2 -11
- package/CHANGELOG.json +86 -17
- package/CHANGELOG.md +29 -11
- package/lib/Button.js +1 -1
- package/lib/CompoundButton.js +1 -1
- package/lib/MenuButton.js +1 -1
- package/lib/SplitButton.js +1 -1
- package/lib/ToggleButton.js +1 -1
- package/lib/components/Button/Button.js +6 -6
- package/lib/components/Button/index.js +4 -4
- package/lib/components/Button/renderButton.js +3 -3
- package/lib/components/Button/useButton.js +13 -13
- package/lib/components/Button/useButton.js.map +1 -1
- package/lib/components/Button/useButtonStyles.js +14 -14
- package/lib/components/CompoundButton/CompoundButton.js +6 -6
- package/lib/components/CompoundButton/index.js +5 -5
- package/lib/components/CompoundButton/renderCompoundButton.js +3 -3
- package/lib/components/CompoundButton/useCompoundButton.js +9 -8
- package/lib/components/CompoundButton/useCompoundButton.js.map +1 -1
- package/lib/components/CompoundButton/useCompoundButtonStyles.js +7 -7
- package/lib/components/MenuButton/MenuButton.js +6 -6
- package/lib/components/MenuButton/index.js +5 -5
- package/lib/components/MenuButton/renderMenuButton.js +3 -3
- package/lib/components/MenuButton/renderMenuButton.js.map +1 -1
- package/lib/components/MenuButton/useMenuButton.js +9 -8
- package/lib/components/MenuButton/useMenuButton.js.map +1 -1
- package/lib/components/MenuButton/useMenuButtonStyles.js +10 -10
- package/lib/components/SplitButton/SplitButton.js +6 -6
- package/lib/components/SplitButton/index.js +5 -5
- package/lib/components/SplitButton/renderSplitButton.js +2 -2
- package/lib/components/SplitButton/useSplitButton.js +14 -14
- package/lib/components/SplitButton/useSplitButtonStyles.js +6 -6
- package/lib/components/ToggleButton/ToggleButton.js +6 -6
- package/lib/components/ToggleButton/index.js +5 -5
- package/lib/components/ToggleButton/renderToggleButton.js +1 -1
- package/lib/components/ToggleButton/useToggleButton.js +3 -3
- package/lib/components/ToggleButton/useToggleButtonStyles.js +9 -9
- package/lib/contexts/ButtonContext.js +3 -2
- package/lib/contexts/ButtonContext.js.map +1 -1
- package/lib/contexts/index.js +1 -1
- package/lib/index.js +7 -7
- package/lib/utils/index.js +1 -1
- package/lib/utils/useToggleState.js +4 -4
- package/lib-commonjs/Button.js.map +1 -1
- package/lib-commonjs/CompoundButton.js.map +1 -1
- package/lib-commonjs/MenuButton.js.map +1 -1
- package/lib-commonjs/SplitButton.js.map +1 -1
- package/lib-commonjs/ToggleButton.js.map +1 -1
- package/lib-commonjs/components/Button/Button.js +1 -1
- package/lib-commonjs/components/Button/Button.js.map +1 -1
- package/lib-commonjs/components/Button/index.js.map +1 -1
- package/lib-commonjs/components/Button/renderButton.js +1 -1
- package/lib-commonjs/components/Button/renderButton.js.map +1 -1
- package/lib-commonjs/components/Button/useButton.js +5 -5
- package/lib-commonjs/components/Button/useButton.js.map +1 -1
- package/lib-commonjs/components/Button/useButtonStyles.js +10 -10
- package/lib-commonjs/components/Button/useButtonStyles.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/CompoundButton.js +1 -1
- package/lib-commonjs/components/CompoundButton/CompoundButton.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/index.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/renderCompoundButton.js +1 -1
- package/lib-commonjs/components/CompoundButton/renderCompoundButton.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/useCompoundButton.js +6 -5
- package/lib-commonjs/components/CompoundButton/useCompoundButton.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/useCompoundButtonStyles.js +4 -4
- package/lib-commonjs/components/CompoundButton/useCompoundButtonStyles.js.map +1 -1
- package/lib-commonjs/components/MenuButton/MenuButton.js +1 -1
- package/lib-commonjs/components/MenuButton/MenuButton.js.map +1 -1
- package/lib-commonjs/components/MenuButton/index.js.map +1 -1
- package/lib-commonjs/components/MenuButton/renderMenuButton.js +1 -1
- package/lib-commonjs/components/MenuButton/renderMenuButton.js.map +1 -1
- package/lib-commonjs/components/MenuButton/useMenuButton.js +5 -4
- package/lib-commonjs/components/MenuButton/useMenuButton.js.map +1 -1
- package/lib-commonjs/components/MenuButton/useMenuButtonStyles.js +6 -6
- package/lib-commonjs/components/MenuButton/useMenuButtonStyles.js.map +1 -1
- package/lib-commonjs/components/SplitButton/SplitButton.js +1 -1
- package/lib-commonjs/components/SplitButton/SplitButton.js.map +1 -1
- package/lib-commonjs/components/SplitButton/index.js.map +1 -1
- package/lib-commonjs/components/SplitButton/renderSplitButton.js.map +1 -1
- package/lib-commonjs/components/SplitButton/useSplitButton.js +7 -7
- package/lib-commonjs/components/SplitButton/useSplitButton.js.map +1 -1
- package/lib-commonjs/components/SplitButton/useSplitButtonStyles.js +3 -3
- package/lib-commonjs/components/SplitButton/useSplitButtonStyles.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/ToggleButton.js +1 -1
- package/lib-commonjs/components/ToggleButton/ToggleButton.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/index.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/renderToggleButton.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/useToggleButton.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/useToggleButtonStyles.js +4 -4
- package/lib-commonjs/components/ToggleButton/useToggleButtonStyles.js.map +1 -1
- package/lib-commonjs/contexts/ButtonContext.js +2 -1
- package/lib-commonjs/contexts/ButtonContext.js.map +1 -1
- package/lib-commonjs/contexts/index.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/useToggleState.js +2 -2
- package/lib-commonjs/utils/useToggleState.js.map +1 -1
- package/package.json +10 -9
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","getSlots","renderMenuButton_unstable","state","slots","slotProps","icon","iconOnly","createElement","root","children","menuIcon"],"sources":["../../../src/components/MenuButton/renderMenuButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { MenuButtonSlots, MenuButtonState } from './MenuButton.types';\n\n/**\n * Renders a MenuButton component by passing the state defined props to the appropriate slots.\n */\nexport const renderMenuButton_unstable = (state: MenuButtonState) => {\n const { slots, slotProps } = getSlots<MenuButtonSlots>(state);\n const { icon, iconOnly } = state;\n\n return (\n <slots.root {...slotProps.root}>\n {slots.icon && <slots.icon {...slotProps.icon} />}\n {!iconOnly && slotProps.root.children}\n {(!iconOnly || !icon?.children) && slots.menuIcon && <slots.menuIcon {...slotProps.menuIcon} />}\n </slots.root>\n );\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,QAAQ,QAAQ;AAGzB;;;AAGA,OAAO,MAAMC,yBAAA,GAA6BC,KAAA,IAA2B;EACnE,MAAM;IAAEC,KAAA;IAAOC;EAAS,CAAE,GAAGJ,QAAA,CAA0BE,KAAA;EACvD,MAAM;IAAEG,IAAA;IAAMC;EAAQ,CAAE,GAAGJ,KAAA;EAE3B,oBACEH,KAAA,CAAAQ,aAAA,CAACJ,KAAA,CAAMK,IAAI,EAAKJ,SAAA,CAAUI,IAAI,EAC3BL,KAAA,CAAME,IAAI,iBAAIN,KAAA,CAAAQ,aAAA,CAACJ,KAAA,CAAME,IAAI,EAAKD,SAAA,CAAUC,IAAI,GAC5C,CAACC,QAAA,IAAYF,SAAA,CAAUI,IAAI,CAACC,QAAQ,EACpC,CAAC,CAACH,QAAA,IAAY,
|
1
|
+
{"version":3,"names":["React","getSlots","renderMenuButton_unstable","state","slots","slotProps","icon","iconOnly","createElement","root","children","menuIcon"],"sources":["../../../src/components/MenuButton/renderMenuButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { MenuButtonSlots, MenuButtonState } from './MenuButton.types';\n\n/**\n * Renders a MenuButton component by passing the state defined props to the appropriate slots.\n */\nexport const renderMenuButton_unstable = (state: MenuButtonState) => {\n const { slots, slotProps } = getSlots<MenuButtonSlots>(state);\n const { icon, iconOnly } = state;\n\n return (\n <slots.root {...slotProps.root}>\n {slots.icon && <slots.icon {...slotProps.icon} />}\n {!iconOnly && slotProps.root.children}\n {(!iconOnly || !icon?.children) && slots.menuIcon && <slots.menuIcon {...slotProps.menuIcon} />}\n </slots.root>\n );\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,QAAQ,QAAQ;AAGzB;;;AAGA,OAAO,MAAMC,yBAAA,GAA6BC,KAAA,IAA2B;EACnE,MAAM;IAAEC,KAAA;IAAOC;EAAS,CAAE,GAAGJ,QAAA,CAA0BE,KAAA;EACvD,MAAM;IAAEG,IAAA;IAAMC;EAAQ,CAAE,GAAGJ,KAAA;EAE3B,oBACEH,KAAA,CAAAQ,aAAA,CAACJ,KAAA,CAAMK,IAAI,EAAKJ,SAAA,CAAUI,IAAI,EAC3BL,KAAA,CAAME,IAAI,iBAAIN,KAAA,CAAAQ,aAAA,CAACJ,KAAA,CAAME,IAAI,EAAKD,SAAA,CAAUC,IAAI,GAC5C,CAACC,QAAA,IAAYF,SAAA,CAAUI,IAAI,CAACC,QAAQ,EACpC,CAAC,CAACH,QAAA,IAAY,EAACD,IAAA,aAAAA,IAAA,uBAAAA,IAAA,CAAMI,QAAQ,CAAD,KAAMN,KAAA,CAAMO,QAAQ,iBAAIX,KAAA,CAAAQ,aAAA,CAACJ,KAAA,CAAMO,QAAQ,EAAKN,SAAA,CAAUM,QAAQ;AAGjG"}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { ChevronDownRegular } from
|
3
|
-
import { resolveShorthand } from
|
4
|
-
import { useButton_unstable } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { ChevronDownRegular } from '@fluentui/react-icons';
|
3
|
+
import { resolveShorthand } from '@fluentui/react-utilities';
|
4
|
+
import { useButton_unstable } from '../Button/index';
|
5
5
|
/**
|
6
6
|
* Given user props, returns the final state for a MenuButton.
|
7
7
|
*/
|
@@ -10,7 +10,8 @@ export const useMenuButton_unstable = ({
|
|
10
10
|
...props
|
11
11
|
}, ref) => {
|
12
12
|
const buttonState = useButton_unstable(props, ref);
|
13
|
-
|
13
|
+
var _props_ariaexpanded;
|
14
|
+
buttonState.root['aria-expanded'] = (_props_ariaexpanded = props['aria-expanded']) !== null && _props_ariaexpanded !== void 0 ? _props_ariaexpanded : false;
|
14
15
|
return {
|
15
16
|
// Button state
|
16
17
|
...buttonState,
|
@@ -18,9 +19,9 @@ export const useMenuButton_unstable = ({
|
|
18
19
|
iconOnly: Boolean(!props.children),
|
19
20
|
// Slots definition
|
20
21
|
components: {
|
21
|
-
root:
|
22
|
-
icon:
|
23
|
-
menuIcon:
|
22
|
+
root: 'button',
|
23
|
+
icon: 'span',
|
24
|
+
menuIcon: 'span'
|
24
25
|
},
|
25
26
|
menuIcon: resolveShorthand(menuIcon, {
|
26
27
|
defaultProps: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","ChevronDownRegular","resolveShorthand","useButton_unstable","useMenuButton_unstable","menuIcon","props","ref","buttonState","root","iconOnly","Boolean","children","components","icon","defaultProps","createElement","required"],"sources":["../../../src/components/MenuButton/useMenuButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular } from '@fluentui/react-icons';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { useButton_unstable } from '../Button/index';\nimport type { MenuButtonProps, MenuButtonState } from './MenuButton.types';\n\n/**\n * Given user props, returns the final state for a MenuButton.\n */\nexport const useMenuButton_unstable = (\n { menuIcon, ...props }: MenuButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n): MenuButtonState => {\n const buttonState = useButton_unstable(props, ref);\n buttonState.root['aria-expanded'] = props['aria-expanded'] ?? false;\n\n return {\n // Button state\n ...buttonState,\n\n // State calculated from a set of props\n iconOnly: Boolean(!props.children),\n\n // Slots definition\n components: {\n root: 'button',\n icon: 'span',\n menuIcon: 'span',\n },\n\n menuIcon: resolveShorthand(menuIcon, {\n defaultProps: {\n children: <ChevronDownRegular />,\n },\n required: true,\n }),\n };\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,kBAAkB,QAAQ;AACnC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAGnC;;;AAGA,OAAO,MAAMC,sBAAA,GAAyBA,CACpC;EAAEC,QAAA;EAAU,GAAGC;AAAA,CAAwB,EACvCC,GAAA,KACoB;EACpB,MAAMC,WAAA,GAAcL,kBAAA,CAAmBG,KAAA,EAAOC,GAAA;
|
1
|
+
{"version":3,"names":["React","ChevronDownRegular","resolveShorthand","useButton_unstable","useMenuButton_unstable","menuIcon","props","ref","buttonState","_props_ariaexpanded","root","iconOnly","Boolean","children","components","icon","defaultProps","createElement","required"],"sources":["../../../src/components/MenuButton/useMenuButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular } from '@fluentui/react-icons';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { useButton_unstable } from '../Button/index';\nimport type { MenuButtonProps, MenuButtonState } from './MenuButton.types';\n\n/**\n * Given user props, returns the final state for a MenuButton.\n */\nexport const useMenuButton_unstable = (\n { menuIcon, ...props }: MenuButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n): MenuButtonState => {\n const buttonState = useButton_unstable(props, ref);\n buttonState.root['aria-expanded'] = props['aria-expanded'] ?? false;\n\n return {\n // Button state\n ...buttonState,\n\n // State calculated from a set of props\n iconOnly: Boolean(!props.children),\n\n // Slots definition\n components: {\n root: 'button',\n icon: 'span',\n menuIcon: 'span',\n },\n\n menuIcon: resolveShorthand(menuIcon, {\n defaultProps: {\n children: <ChevronDownRegular />,\n },\n required: true,\n }),\n };\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,kBAAkB,QAAQ;AACnC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAGnC;;;AAGA,OAAO,MAAMC,sBAAA,GAAyBA,CACpC;EAAEC,QAAA;EAAU,GAAGC;AAAA,CAAwB,EACvCC,GAAA,KACoB;EACpB,MAAMC,WAAA,GAAcL,kBAAA,CAAmBG,KAAA,EAAOC,GAAA;MACVE,mBAAA;EAApCD,WAAA,CAAYE,IAAI,CAAC,gBAAgB,GAAG,CAAAD,mBAAA,GAAAH,KAAK,CAAC,gBAAgB,cAAtBG,mBAAA,cAAAA,mBAAA,GAA0B,KAAK;EAEnE,OAAO;IACL;IACA,GAAGD,WAAW;IAEd;IACAG,QAAA,EAAUC,OAAA,CAAQ,CAACN,KAAA,CAAMO,QAAQ;IAEjC;IACAC,UAAA,EAAY;MACVJ,IAAA,EAAM;MACNK,IAAA,EAAM;MACNV,QAAA,EAAU;IACZ;IAEAA,QAAA,EAAUH,gBAAA,CAAiBG,QAAA,EAAU;MACnCW,YAAA,EAAc;QACZH,QAAA,eAAUb,KAAA,CAAAiB,aAAA,CAAChB,kBAAA;MACb;MACAiB,QAAA,EAAU;IACZ;EACF;AACF"}
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { iconFilledClassName, iconRegularClassName } from
|
2
|
-
import { tokens } from
|
3
|
-
import { mergeClasses, __styles, shorthands } from
|
4
|
-
import { useButtonStyles_unstable } from
|
1
|
+
import { iconFilledClassName, iconRegularClassName } from '@fluentui/react-icons';
|
2
|
+
import { tokens } from '@fluentui/react-theme';
|
3
|
+
import { mergeClasses, __styles, shorthands } from '@griffel/react';
|
4
|
+
import { useButtonStyles_unstable } from '../Button/useButtonStyles';
|
5
5
|
export const menuButtonClassNames = {
|
6
|
-
root:
|
7
|
-
icon:
|
8
|
-
menuIcon:
|
6
|
+
root: 'fui-MenuButton',
|
7
|
+
icon: 'fui-MenuButton__icon',
|
8
|
+
menuIcon: 'fui-MenuButton__menuIcon'
|
9
9
|
};
|
10
10
|
const useRootExpandedStyles = /*#__PURE__*/__styles({
|
11
11
|
base: {
|
@@ -94,16 +94,16 @@ export const useMenuButtonStyles_unstable = state => {
|
|
94
94
|
const rootExpandedStyles = useRootExpandedStyles();
|
95
95
|
const iconExpandedStyles = useIconExpandedStyles();
|
96
96
|
const menuIconStyles = useMenuIconStyles();
|
97
|
-
state.root.className = mergeClasses(menuButtonClassNames.root, state.root[
|
97
|
+
state.root.className = mergeClasses(menuButtonClassNames.root, state.root['aria-expanded'] && rootExpandedStyles.base, state.root['aria-expanded'] && rootExpandedStyles[state.appearance], state.root.className);
|
98
98
|
if (state.icon) {
|
99
|
-
state.icon.className = mergeClasses(menuButtonClassNames.icon, state.root[
|
99
|
+
state.icon.className = mergeClasses(menuButtonClassNames.icon, state.root['aria-expanded'] && iconExpandedStyles[state.appearance], state.icon.className);
|
100
100
|
}
|
101
101
|
if (state.menuIcon) {
|
102
102
|
state.menuIcon.className = mergeClasses(menuButtonClassNames.menuIcon, menuIconStyles.base, menuIconStyles[state.size], !state.iconOnly && menuIconStyles.notIconOnly, state.menuIcon.className);
|
103
103
|
}
|
104
104
|
useButtonStyles_unstable({
|
105
105
|
...state,
|
106
|
-
iconPosition:
|
106
|
+
iconPosition: 'before'
|
107
107
|
});
|
108
108
|
return state;
|
109
109
|
};
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { renderSplitButton_unstable } from
|
3
|
-
import { useSplitButton_unstable } from
|
4
|
-
import { useSplitButtonStyles_unstable } from
|
5
|
-
import { useCustomStyleHooks_unstable } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { renderSplitButton_unstable } from './renderSplitButton';
|
3
|
+
import { useSplitButton_unstable } from './useSplitButton';
|
4
|
+
import { useSplitButtonStyles_unstable } from './useSplitButtonStyles';
|
5
|
+
import { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';
|
6
6
|
/**
|
7
7
|
* SplitButtons are a grouping of two interactive surfaces where interacting with the first one triggers a primary
|
8
8
|
* action, while interacting with the second one opens a menu with secondary actions.
|
@@ -18,5 +18,5 @@ export const SplitButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
18
18
|
// Casting is required due to lack of distributive union to support unions on @types/react
|
19
19
|
});
|
20
20
|
|
21
|
-
SplitButton.displayName =
|
21
|
+
SplitButton.displayName = 'SplitButton';
|
22
22
|
//# sourceMappingURL=SplitButton.js.map
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from
|
2
|
-
export * from
|
3
|
-
export * from
|
4
|
-
export * from
|
5
|
-
export { splitButtonClassNames, useSplitButtonStyles_unstable } from
|
1
|
+
export * from './SplitButton';
|
2
|
+
export * from './SplitButton.types';
|
3
|
+
export * from './renderSplitButton';
|
4
|
+
export * from './useSplitButton';
|
5
|
+
export { splitButtonClassNames, useSplitButtonStyles_unstable } from './useSplitButtonStyles';
|
6
6
|
//# sourceMappingURL=index.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { getSlots } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { getSlots } from '@fluentui/react-utilities';
|
3
3
|
/**
|
4
4
|
* Renders a SplitButton component by passing the state defined props to the appropriate slots.
|
5
5
|
*/
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { getNativeElementProps, resolveShorthand, useId } from
|
3
|
-
import { Button } from
|
4
|
-
import { MenuButton } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';
|
3
|
+
import { Button } from '../Button/Button';
|
4
|
+
import { MenuButton } from '../MenuButton/MenuButton';
|
5
5
|
/**
|
6
6
|
* Given user props, defines default props for the SplitButton and returns processed state.
|
7
7
|
* @param props - User provided props to the SplitButton component.
|
@@ -9,19 +9,19 @@ import { MenuButton } from "../MenuButton/MenuButton";
|
|
9
9
|
*/
|
10
10
|
export const useSplitButton_unstable = (props, ref) => {
|
11
11
|
const {
|
12
|
-
appearance =
|
12
|
+
appearance = 'secondary',
|
13
13
|
children,
|
14
14
|
disabled = false,
|
15
15
|
disabledFocusable = false,
|
16
16
|
icon,
|
17
|
-
iconPosition =
|
17
|
+
iconPosition = 'before',
|
18
18
|
menuButton,
|
19
19
|
menuIcon,
|
20
20
|
primaryActionButton,
|
21
|
-
shape =
|
22
|
-
size =
|
21
|
+
shape = 'rounded',
|
22
|
+
size = 'medium'
|
23
23
|
} = props;
|
24
|
-
const baseId = useId(
|
24
|
+
const baseId = useId('splitButton-');
|
25
25
|
const menuButtonShorthand = resolveShorthand(menuButton, {
|
26
26
|
defaultProps: {
|
27
27
|
appearance,
|
@@ -41,7 +41,7 @@ export const useSplitButton_unstable = (props, ref) => {
|
|
41
41
|
disabledFocusable,
|
42
42
|
icon,
|
43
43
|
iconPosition,
|
44
|
-
id: baseId +
|
44
|
+
id: baseId + '__primaryActionButton',
|
45
45
|
shape,
|
46
46
|
size
|
47
47
|
},
|
@@ -49,8 +49,8 @@ export const useSplitButton_unstable = (props, ref) => {
|
|
49
49
|
});
|
50
50
|
// Resolve menu button's aria-labelledby to be labelled by the primary action button if not a label was not provided
|
51
51
|
// by the user.
|
52
|
-
if (menuButtonShorthand && primaryActionButtonShorthand && !menuButtonShorthand[
|
53
|
-
menuButtonShorthand[
|
52
|
+
if (menuButtonShorthand && primaryActionButtonShorthand && !menuButtonShorthand['aria-label'] && !menuButtonShorthand['aria-labelledby']) {
|
53
|
+
menuButtonShorthand['aria-labelledby'] = primaryActionButtonShorthand.id;
|
54
54
|
}
|
55
55
|
return {
|
56
56
|
// Props passed at the top-level
|
@@ -62,11 +62,11 @@ export const useSplitButton_unstable = (props, ref) => {
|
|
62
62
|
size,
|
63
63
|
// Slots definition
|
64
64
|
components: {
|
65
|
-
root:
|
65
|
+
root: 'div',
|
66
66
|
menuButton: MenuButton,
|
67
67
|
primaryActionButton: Button
|
68
68
|
},
|
69
|
-
root: getNativeElementProps(
|
69
|
+
root: getNativeElementProps('div', {
|
70
70
|
ref,
|
71
71
|
...props
|
72
72
|
}),
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { __styles, mergeClasses } from
|
2
|
-
import { createCustomFocusIndicatorStyle } from
|
3
|
-
import { tokens } from
|
1
|
+
import { __styles, mergeClasses } from '@griffel/react';
|
2
|
+
import { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';
|
3
|
+
import { tokens } from '@fluentui/react-theme';
|
4
4
|
export const splitButtonClassNames = {
|
5
|
-
root:
|
6
|
-
menuButton:
|
7
|
-
primaryActionButton:
|
5
|
+
root: 'fui-SplitButton',
|
6
|
+
menuButton: 'fui-SplitButton__menuButton',
|
7
|
+
primaryActionButton: 'fui-SplitButton__primaryActionButton'
|
8
8
|
};
|
9
9
|
const useFocusStyles = /*#__PURE__*/__styles({
|
10
10
|
primaryActionButton: {
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { renderToggleButton_unstable } from
|
3
|
-
import { useToggleButton_unstable } from
|
4
|
-
import { useToggleButtonStyles_unstable } from
|
5
|
-
import { useCustomStyleHooks_unstable } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { renderToggleButton_unstable } from './renderToggleButton';
|
3
|
+
import { useToggleButton_unstable } from './useToggleButton';
|
4
|
+
import { useToggleButtonStyles_unstable } from './useToggleButtonStyles';
|
5
|
+
import { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';
|
6
6
|
/**
|
7
7
|
* ToggleButtons are buttons that toggle between two defined states when triggered.
|
8
8
|
*/
|
@@ -17,5 +17,5 @@ export const ToggleButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
17
17
|
// Casting is required due to lack of distributive union to support unions on @types/react
|
18
18
|
});
|
19
19
|
|
20
|
-
ToggleButton.displayName =
|
20
|
+
ToggleButton.displayName = 'ToggleButton';
|
21
21
|
//# sourceMappingURL=ToggleButton.js.map
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from
|
2
|
-
export * from
|
3
|
-
export * from
|
4
|
-
export * from
|
5
|
-
export { toggleButtonClassNames, useToggleButtonStyles_unstable } from
|
1
|
+
export * from './ToggleButton';
|
2
|
+
export * from './ToggleButton.types';
|
3
|
+
export * from './renderToggleButton';
|
4
|
+
export * from './useToggleButton';
|
5
|
+
export { toggleButtonClassNames, useToggleButtonStyles_unstable } from './useToggleButtonStyles';
|
6
6
|
//# sourceMappingURL=index.js.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export { renderButton_unstable as renderToggleButton_unstable } from
|
1
|
+
export { renderButton_unstable as renderToggleButton_unstable } from '../Button/renderButton';
|
2
2
|
//# sourceMappingURL=renderToggleButton.js.map
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { useToggleState } from
|
3
|
-
import { useButton_unstable } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useToggleState } from '../../utils/useToggleState';
|
3
|
+
import { useButton_unstable } from '../Button/useButton';
|
4
4
|
/**
|
5
5
|
* Given user props, defines default props for the ToggleButton, calls useButtonState and useChecked, and returns
|
6
6
|
* processed state.
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { iconFilledClassName, iconRegularClassName } from
|
2
|
-
import { createCustomFocusIndicatorStyle } from
|
3
|
-
import { tokens } from
|
4
|
-
import { shorthands, mergeClasses, __styles } from
|
5
|
-
import { useButtonStyles_unstable } from
|
1
|
+
import { iconFilledClassName, iconRegularClassName } from '@fluentui/react-icons';
|
2
|
+
import { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';
|
3
|
+
import { tokens } from '@fluentui/react-theme';
|
4
|
+
import { shorthands, mergeClasses, __styles } from '@griffel/react';
|
5
|
+
import { useButtonStyles_unstable } from '../Button/useButtonStyles';
|
6
6
|
export const toggleButtonClassNames = {
|
7
|
-
root:
|
8
|
-
icon:
|
7
|
+
root: 'fui-ToggleButton',
|
8
|
+
icon: 'fui-ToggleButton__icon'
|
9
9
|
};
|
10
10
|
const useRootCheckedStyles = /*#__PURE__*/__styles({
|
11
11
|
base: {
|
@@ -370,7 +370,7 @@ export const useToggleButtonStyles_unstable = state => {
|
|
370
370
|
} = state;
|
371
371
|
state.root.className = mergeClasses(toggleButtonClassNames.root,
|
372
372
|
// Primary high contrast styles
|
373
|
-
appearance ===
|
373
|
+
appearance === 'primary' && primaryHighContrastStyles.base, appearance === 'primary' && (disabled || disabledFocusable) && primaryHighContrastStyles.disabled,
|
374
374
|
// Checked styles
|
375
375
|
checked && rootCheckedStyles.base, checked && rootCheckedStyles.highContrast, appearance && checked && rootCheckedStyles[appearance],
|
376
376
|
// Disabled styles
|
@@ -378,7 +378,7 @@ export const useToggleButtonStyles_unstable = state => {
|
|
378
378
|
// User provided class name
|
379
379
|
state.root.className);
|
380
380
|
if (state.icon) {
|
381
|
-
state.icon.className = mergeClasses(toggleButtonClassNames.icon, (appearance ===
|
381
|
+
state.icon.className = mergeClasses(toggleButtonClassNames.icon, (appearance === 'subtle' || appearance === 'transparent') && iconCheckedStyles.subtleOrTransparent, state.icon.className);
|
382
382
|
}
|
383
383
|
useButtonStyles_unstable(state);
|
384
384
|
return state;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import * as React from
|
1
|
+
import * as React from 'react';
|
2
2
|
const buttonContext = /*#__PURE__*/React.createContext(undefined);
|
3
3
|
const buttonContextDefaultValue = {};
|
4
4
|
/**
|
@@ -6,9 +6,10 @@ const buttonContextDefaultValue = {};
|
|
6
6
|
* Internal context provider used to update default values between internal components
|
7
7
|
*/
|
8
8
|
export const ButtonContextProvider = buttonContext.Provider;
|
9
|
+
var _React_useContext;
|
9
10
|
/**
|
10
11
|
* @internal
|
11
12
|
* Internal context hook used to update default values between internal components
|
12
13
|
*/
|
13
|
-
export const useButtonContext = () => React.useContext(buttonContext)
|
14
|
+
export const useButtonContext = () => (_React_useContext = React.useContext(buttonContext)) !== null && _React_useContext !== void 0 ? _React_useContext : buttonContextDefaultValue;
|
14
15
|
//# sourceMappingURL=ButtonContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","buttonContext","createContext","undefined","buttonContextDefaultValue","ButtonContextProvider","Provider","useButtonContext","useContext"],"sources":["../../src/contexts/ButtonContext.ts"],"sourcesContent":["import * as React from 'react';\nimport { ButtonSize } from '../components/Button/Button.types';\n\nconst buttonContext = React.createContext<ButtonContextValue | undefined>(undefined);\n\n/**\n * @internal\n * Internal context value used to update default values between internal components\n */\nexport interface ButtonContextValue {\n size?: ButtonSize;\n}\n\nconst buttonContextDefaultValue: ButtonContextValue = {};\n\n/**\n * @internal\n * Internal context provider used to update default values between internal components\n */\nexport const ButtonContextProvider = buttonContext.Provider;\n\n/**\n * @internal\n * Internal context hook used to update default values between internal components\n */\nexport const useButtonContext = () => React.useContext(buttonContext) ?? buttonContextDefaultValue;\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAGvB,MAAMC,aAAA,gBAAgBD,KAAA,CAAME,aAAa,CAAiCC,SAAA;AAU1E,MAAMC,yBAAA,GAAgD,CAAC;AAEvD;;;;AAIA,OAAO,MAAMC,qBAAA,GAAwBJ,aAAA,CAAcK,QAAQ;
|
1
|
+
{"version":3,"names":["React","buttonContext","createContext","undefined","buttonContextDefaultValue","ButtonContextProvider","Provider","_React_useContext","useButtonContext","useContext"],"sources":["../../src/contexts/ButtonContext.ts"],"sourcesContent":["import * as React from 'react';\nimport { ButtonSize } from '../components/Button/Button.types';\n\nconst buttonContext = React.createContext<ButtonContextValue | undefined>(undefined);\n\n/**\n * @internal\n * Internal context value used to update default values between internal components\n */\nexport interface ButtonContextValue {\n size?: ButtonSize;\n}\n\nconst buttonContextDefaultValue: ButtonContextValue = {};\n\n/**\n * @internal\n * Internal context provider used to update default values between internal components\n */\nexport const ButtonContextProvider = buttonContext.Provider;\n\n/**\n * @internal\n * Internal context hook used to update default values between internal components\n */\nexport const useButtonContext = () => React.useContext(buttonContext) ?? buttonContextDefaultValue;\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAGvB,MAAMC,aAAA,gBAAgBD,KAAA,CAAME,aAAa,CAAiCC,SAAA;AAU1E,MAAMC,yBAAA,GAAgD,CAAC;AAEvD;;;;AAIA,OAAO,MAAMC,qBAAA,GAAwBJ,aAAA,CAAcK,QAAQ;IAMrBC,iBAAA;AAJtC;;;;AAIA,OAAO,MAAMC,gBAAA,GAAmBA,CAAA,KAAM,CAAAD,iBAAA,GAAAP,KAAA,CAAMS,UAAU,CAACR,aAAA,eAAjBM,iBAAA,cAAAA,iBAAA,GAAmCH,yBAAyB"}
|
package/lib/contexts/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from
|
1
|
+
export * from './ButtonContext';
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
export { Button, buttonClassNames, renderButton_unstable, useButtonStyles_unstable, useButton_unstable } from
|
2
|
-
export { CompoundButton, compoundButtonClassNames, renderCompoundButton_unstable, useCompoundButtonStyles_unstable, useCompoundButton_unstable } from
|
3
|
-
export { MenuButton, menuButtonClassNames, renderMenuButton_unstable, useMenuButtonStyles_unstable, useMenuButton_unstable } from
|
4
|
-
export { SplitButton, renderSplitButton_unstable, splitButtonClassNames, useSplitButtonStyles_unstable, useSplitButton_unstable } from
|
5
|
-
export { ToggleButton, renderToggleButton_unstable, toggleButtonClassNames, useToggleButtonStyles_unstable, useToggleButton_unstable } from
|
6
|
-
export { useToggleState } from
|
7
|
-
export { ButtonContextProvider, useButtonContext } from
|
1
|
+
export { Button, buttonClassNames, renderButton_unstable, useButtonStyles_unstable, useButton_unstable } from './Button';
|
2
|
+
export { CompoundButton, compoundButtonClassNames, renderCompoundButton_unstable, useCompoundButtonStyles_unstable, useCompoundButton_unstable } from './CompoundButton';
|
3
|
+
export { MenuButton, menuButtonClassNames, renderMenuButton_unstable, useMenuButtonStyles_unstable, useMenuButton_unstable } from './MenuButton';
|
4
|
+
export { SplitButton, renderSplitButton_unstable, splitButtonClassNames, useSplitButtonStyles_unstable, useSplitButton_unstable } from './SplitButton';
|
5
|
+
export { ToggleButton, renderToggleButton_unstable, toggleButtonClassNames, useToggleButtonStyles_unstable, useToggleButton_unstable } from './ToggleButton';
|
6
|
+
export { useToggleState } from './utils/index';
|
7
|
+
export { ButtonContextProvider, useButtonContext } from './contexts/index';
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/lib/utils/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from
|
1
|
+
export * from './useToggleState';
|
2
2
|
//# sourceMappingURL=index.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { mergeCallbacks, useControllableState, useEventCallback } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { mergeCallbacks, useControllableState, useEventCallback } from '@fluentui/react-utilities';
|
3
3
|
export function useToggleState(props, state) {
|
4
4
|
const {
|
5
5
|
checked,
|
@@ -16,7 +16,7 @@ export function useToggleState(props, state) {
|
|
16
16
|
defaultState: defaultChecked,
|
17
17
|
initialState: false
|
18
18
|
});
|
19
|
-
const isCheckboxTypeRole = role ===
|
19
|
+
const isCheckboxTypeRole = role === 'menuitemcheckbox' || role === 'checkbox';
|
20
20
|
const onToggleClick = React.useCallback(ev => {
|
21
21
|
if (!disabled && !disabledFocusable) {
|
22
22
|
if (ev.defaultPrevented) {
|
@@ -30,7 +30,7 @@ export function useToggleState(props, state) {
|
|
30
30
|
checked: checkedValue,
|
31
31
|
root: {
|
32
32
|
...state.root,
|
33
|
-
[isCheckboxTypeRole ?
|
33
|
+
[isCheckboxTypeRole ? 'aria-checked' : 'aria-pressed']: checkedValue,
|
34
34
|
onClick: useEventCallback(mergeCallbacks(onClick, onToggleClick))
|
35
35
|
}
|
36
36
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../lib/Button.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../lib/Button.js"],"sourcesContent":["export * from './components/Button/index';\n//# sourceMappingURL=Button.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,kCAAkC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../lib/CompoundButton.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../lib/CompoundButton.js"],"sourcesContent":["export * from './components/CompoundButton/index';\n//# sourceMappingURL=CompoundButton.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,0CAA0C"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../lib/MenuButton.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../lib/MenuButton.js"],"sourcesContent":["export * from './components/MenuButton/index';\n//# sourceMappingURL=MenuButton.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,sCAAsC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../lib/SplitButton.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../lib/SplitButton.js"],"sourcesContent":["export * from './components/SplitButton/index';\n//# sourceMappingURL=SplitButton.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,uCAAuC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../lib/ToggleButton.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../lib/ToggleButton.js"],"sourcesContent":["export * from './components/ToggleButton/index';\n//# sourceMappingURL=ToggleButton.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,wCAAwC"}
|
@@ -20,6 +20,6 @@ const Button = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
|
20
20
|
return (0, _renderButton.renderButton_unstable)(state);
|
21
21
|
// Casting is required due to lack of distributive union to support unions on @types/react
|
22
22
|
});
|
23
|
-
Button.displayName =
|
23
|
+
Button.displayName = 'Button'; //# sourceMappingURL=Button.js.map
|
24
24
|
|
25
25
|
//# sourceMappingURL=Button.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Button/Button.js"],"sourcesContent":["import * as React from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Button/Button.js"],"sourcesContent":["import * as React from 'react';\nimport { renderButton_unstable } from './renderButton';\nimport { useButton_unstable } from './useButton';\nimport { useButtonStyles_unstable } from './useButtonStyles';\nimport { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';\n/**\n * Buttons give people a way to trigger an action.\n */\nexport const Button = /*#__PURE__*/React.forwardRef((props, ref) => {\n const state = useButton_unstable(props, ref);\n useButtonStyles_unstable(state);\n const {\n useButtonStyles_unstable: useCustomStyles\n } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n return renderButton_unstable(state);\n // Casting is required due to lack of distributive union to support unions on @types/react\n});\n\nButton.displayName = 'Button';\n//# sourceMappingURL=Button.js.map"],"names":["Button","React","forwardRef","props","ref","state","useButton_unstable","useButtonStyles_unstable","useCustomStyles","useCustomStyleHooks_unstable","renderButton_unstable","displayName"],"mappings":";;;;+BAQaA;;aAAAA;;;6DARU;8BACe;2BACH;iCACM;qCACI;AAItC,MAAMA,SAAS,WAAW,GAAEC,OAAMC,UAAU,CAAC,CAACC,OAAOC,MAAQ;IAClE,MAAMC,QAAQC,IAAAA,6BAAkB,EAACH,OAAOC;IACxCG,IAAAA,yCAAwB,EAACF;IACzB,MAAM,EACJE,0BAA0BC,gBAAe,EAC1C,GAAGC,IAAAA,iDAA4B;IAChCD,gBAAgBH;IAChB,OAAOK,IAAAA,mCAAqB,EAACL;AAC7B,0FAA0F;AAC5F;AAEAL,OAAOW,WAAW,GAAG,UACrB,kCAAkC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Button/index.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Button/index.js"],"sourcesContent":["export * from './Button';\nexport * from './renderButton';\nexport * from './useButton';\nexport { buttonClassNames, useButtonStyles_unstable } from './useButtonStyles';\n//# sourceMappingURL=index.js.map"],"names":["buttonClassNames","useButtonStyles_unstable"],"mappings":";;;;;;;;;;;IAGSA,gBAAgB,MAAhBA,iCAAgB;IAAEC,wBAAwB,MAAxBA,yCAAwB;;;oBAHrC;oBACA;oBACA;iCAC6C;CAC3D,iCAAiC"}
|
@@ -12,7 +12,7 @@ const _reactUtilities = require("@fluentui/react-utilities");
|
|
12
12
|
const renderButton_unstable = (state)=>{
|
13
13
|
const { slots , slotProps } = (0, _reactUtilities.getSlots)(state);
|
14
14
|
const { iconOnly , iconPosition } = state;
|
15
|
-
return /*#__PURE__*/ _react.createElement(slots.root, slotProps.root, iconPosition !==
|
15
|
+
return /*#__PURE__*/ _react.createElement(slots.root, slotProps.root, iconPosition !== 'after' && slots.icon && /*#__PURE__*/ _react.createElement(slots.icon, slotProps.icon), !iconOnly && state.root.children, iconPosition === 'after' && slots.icon && /*#__PURE__*/ _react.createElement(slots.icon, slotProps.icon));
|
16
16
|
}; //# sourceMappingURL=renderButton.js.map
|
17
17
|
|
18
18
|
//# sourceMappingURL=renderButton.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Button/renderButton.js"],"sourcesContent":["import * as React from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Button/renderButton.js"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\n/**\n * Renders a Button component by passing the state defined props to the appropriate slots.\n */\nexport const renderButton_unstable = state => {\n const {\n slots,\n slotProps\n } = getSlots(state);\n const {\n iconOnly,\n iconPosition\n } = state;\n return /*#__PURE__*/React.createElement(slots.root, slotProps.root, iconPosition !== 'after' && slots.icon && /*#__PURE__*/React.createElement(slots.icon, slotProps.icon), !iconOnly && state.root.children, iconPosition === 'after' && slots.icon && /*#__PURE__*/React.createElement(slots.icon, slotProps.icon));\n};\n//# sourceMappingURL=renderButton.js.map"],"names":["renderButton_unstable","state","slots","slotProps","getSlots","iconOnly","iconPosition","React","createElement","root","icon","children"],"mappings":";;;;+BAKaA;;aAAAA;;;6DALU;gCACE;AAIlB,MAAMA,wBAAwBC,CAAAA,QAAS;IAC5C,MAAM,EACJC,MAAK,EACLC,UAAS,EACV,GAAGC,IAAAA,wBAAQ,EAACH;IACb,MAAM,EACJI,SAAQ,EACRC,aAAY,EACb,GAAGL;IACJ,OAAO,WAAW,GAAEM,OAAMC,aAAa,CAACN,MAAMO,IAAI,EAAEN,UAAUM,IAAI,EAAEH,iBAAiB,WAAWJ,MAAMQ,IAAI,IAAI,WAAW,GAAEH,OAAMC,aAAa,CAACN,MAAMQ,IAAI,EAAEP,UAAUO,IAAI,GAAG,CAACL,YAAYJ,MAAMQ,IAAI,CAACE,QAAQ,EAAEL,iBAAiB,WAAWJ,MAAMQ,IAAI,IAAI,WAAW,GAAEH,OAAMC,aAAa,CAACN,MAAMQ,IAAI,EAAEP,UAAUO,IAAI;AACrT,GACA,wCAAwC"}
|
@@ -13,7 +13,7 @@ const _reactUtilities = require("@fluentui/react-utilities");
|
|
13
13
|
const _buttonContext = require("../../contexts/ButtonContext");
|
14
14
|
const useButton_unstable = (props, ref)=>{
|
15
15
|
const { size: contextSize } = (0, _buttonContext.useButtonContext)();
|
16
|
-
const { appearance =
|
16
|
+
const { appearance ='secondary' , as ='button' , disabled =false , disabledFocusable =false , icon , iconPosition ='before' , shape ='rounded' , size =contextSize !== null && contextSize !== void 0 ? contextSize : 'medium' } = props;
|
17
17
|
const iconShorthand = (0, _reactUtilities.resolveShorthand)(icon);
|
18
18
|
return {
|
19
19
|
// Props passed at the top-level
|
@@ -24,17 +24,17 @@ const useButton_unstable = (props, ref)=>{
|
|
24
24
|
shape,
|
25
25
|
size,
|
26
26
|
// State calculated from a set of props
|
27
|
-
iconOnly: Boolean(iconShorthand
|
27
|
+
iconOnly: Boolean((iconShorthand === null || iconShorthand === void 0 ? void 0 : iconShorthand.children) && !props.children),
|
28
28
|
// Slots definition
|
29
29
|
components: {
|
30
|
-
root:
|
31
|
-
icon:
|
30
|
+
root: 'button',
|
31
|
+
icon: 'span'
|
32
32
|
},
|
33
33
|
root: (0, _reactUtilities.getNativeElementProps)(as, (0, _reactAria.useARIAButtonShorthand)(props, {
|
34
34
|
required: true,
|
35
35
|
defaultProps: {
|
36
36
|
ref: ref,
|
37
|
-
type:
|
37
|
+
type: 'button'
|
38
38
|
}
|
39
39
|
})),
|
40
40
|
icon: iconShorthand
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Button/useButton.js"],"sourcesContent":["import * as React from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Button/useButton.js"],"sourcesContent":["import * as React from 'react';\nimport { useARIAButtonShorthand } from '@fluentui/react-aria';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\nimport { useButtonContext } from '../../contexts/ButtonContext';\n/**\n * Given user props, defines default props for the Button, calls useButtonState, and returns processed state.\n * @param props - User provided props to the Button component.\n * @param ref - User provided ref to be passed to the Button component.\n */\nexport const useButton_unstable = (props, ref) => {\n const {\n size: contextSize\n } = useButtonContext();\n const {\n appearance = 'secondary',\n as = 'button',\n disabled = false,\n disabledFocusable = false,\n icon,\n iconPosition = 'before',\n shape = 'rounded',\n size = contextSize !== null && contextSize !== void 0 ? contextSize : 'medium'\n } = props;\n const iconShorthand = resolveShorthand(icon);\n return {\n // Props passed at the top-level\n appearance,\n disabled,\n disabledFocusable,\n iconPosition,\n shape,\n size,\n // State calculated from a set of props\n iconOnly: Boolean((iconShorthand === null || iconShorthand === void 0 ? void 0 : iconShorthand.children) && !props.children),\n // Slots definition\n components: {\n root: 'button',\n icon: 'span'\n },\n root: getNativeElementProps(as, useARIAButtonShorthand(props, {\n required: true,\n defaultProps: {\n ref: ref,\n type: 'button'\n }\n })),\n icon: iconShorthand\n };\n};\n//# sourceMappingURL=useButton.js.map"],"names":["useButton_unstable","props","ref","size","contextSize","useButtonContext","appearance","as","disabled","disabledFocusable","icon","iconPosition","shape","iconShorthand","resolveShorthand","iconOnly","Boolean","children","components","root","getNativeElementProps","useARIAButtonShorthand","required","defaultProps","type"],"mappings":";;;;+BASaA;;aAAAA;;;6DATU;2BACgB;gCACiB;+BACvB;AAM1B,MAAMA,qBAAqB,CAACC,OAAOC,MAAQ;IAChD,MAAM,EACJC,MAAMC,YAAW,EAClB,GAAGC,IAAAA,+BAAgB;IACpB,MAAM,EACJC,YAAa,YAAW,EACxBC,IAAK,SAAQ,EACbC,UAAW,KAAK,CAAA,EAChBC,mBAAoB,KAAK,CAAA,EACzBC,KAAI,EACJC,cAAe,SAAQ,EACvBC,OAAQ,UAAS,EACjBT,MAAOC,gBAAgB,IAAI,IAAIA,gBAAgB,KAAK,IAAIA,cAAc,QAAQ,CAAA,EAC/E,GAAGH;IACJ,MAAMY,gBAAgBC,IAAAA,gCAAgB,EAACJ;IACvC,OAAO;QACL,gCAAgC;QAChCJ;QACAE;QACAC;QACAE;QACAC;QACAT;QACA,uCAAuC;QACvCY,UAAUC,QAAQ,AAACH,CAAAA,kBAAkB,IAAI,IAAIA,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAcI,QAAQ,AAAD,KAAM,CAAChB,MAAMgB,QAAQ;QAC3H,mBAAmB;QACnBC,YAAY;YACVC,MAAM;YACNT,MAAM;QACR;QACAS,MAAMC,IAAAA,qCAAqB,EAACb,IAAIc,IAAAA,iCAAsB,EAACpB,OAAO;YAC5DqB,UAAU,IAAI;YACdC,cAAc;gBACZrB,KAAKA;gBACLsB,MAAM;YACR;QACF;QACAd,MAAMG;IACR;AACF,GACA,qCAAqC"}
|
@@ -14,15 +14,15 @@ _export(exports, {
|
|
14
14
|
});
|
15
15
|
const _react = require("@griffel/react");
|
16
16
|
const buttonClassNames = {
|
17
|
-
root:
|
18
|
-
icon:
|
17
|
+
root: 'fui-Button',
|
18
|
+
icon: 'fui-Button__icon'
|
19
19
|
};
|
20
|
-
const iconSpacingVar =
|
21
|
-
const buttonSpacingSmall =
|
22
|
-
const buttonSpacingSmallWithIcon =
|
23
|
-
const buttonSpacingMedium =
|
24
|
-
const buttonSpacingLarge =
|
25
|
-
const buttonSpacingLargeWithIcon =
|
20
|
+
const iconSpacingVar = '--fui-Button__icon--spacing';
|
21
|
+
const buttonSpacingSmall = '3px';
|
22
|
+
const buttonSpacingSmallWithIcon = '1px';
|
23
|
+
const buttonSpacingMedium = '5px';
|
24
|
+
const buttonSpacingLarge = '8px';
|
25
|
+
const buttonSpacingLargeWithIcon = '7px';
|
26
26
|
const useRootBaseClassName = /*#__PURE__*/ (0, _react["__resetStyles"])("rsawnvh", "r1eny37h", [
|
27
27
|
".rsawnvh{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;box-sizing:border-box;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;text-decoration-line:none;vertical-align:middle;margin:0;overflow:hidden;background-color:var(--colorNeutralBackground1);color:var(--colorNeutralForeground1);border:var(--strokeWidthThin) solid var(--colorNeutralStroke1);font-family:var(--fontFamilyBase);outline-style:none;padding:5px var(--spacingHorizontalM);min-width:96px;border-radius:var(--borderRadiusMedium);font-size:var(--fontSizeBase300);font-weight:var(--fontWeightSemibold);line-height:var(--lineHeightBase300);transition-duration:var(--durationFaster);transition-property:background,border,color;transition-timing-function:var(--curveEasyEase);}",
|
28
28
|
".rsawnvh:hover{background-color:var(--colorNeutralBackground1Hover);border-color:var(--colorNeutralStroke1Hover);color:var(--colorNeutralForeground1Hover);cursor:pointer;}",
|
@@ -1136,9 +1136,9 @@ const useButtonStyles_unstable = (state)=>{
|
|
1136
1136
|
const rootIconOnlyStyles = useRootIconOnlyStyles();
|
1137
1137
|
const iconStyles = useIconStyles();
|
1138
1138
|
const { appearance , disabled , disabledFocusable , icon , iconOnly , iconPosition , shape , size } = state;
|
1139
|
-
state.root.className = (0, _react.mergeClasses)(buttonClassNames.root, rootBaseClassName, appearance && rootStyles[appearance], rootStyles[size], icon && size ===
|
1139
|
+
state.root.className = (0, _react.mergeClasses)(buttonClassNames.root, rootBaseClassName, appearance && rootStyles[appearance], rootStyles[size], icon && size === 'small' && rootStyles.smallWithIcon, icon && size === 'large' && rootStyles.largeWithIcon, rootStyles[shape], // Disabled styles
|
1140
1140
|
(disabled || disabledFocusable) && rootDisabledStyles.base, (disabled || disabledFocusable) && rootDisabledStyles.highContrast, appearance && (disabled || disabledFocusable) && rootDisabledStyles[appearance], // Focus styles
|
1141
|
-
appearance ===
|
1141
|
+
appearance === 'primary' && rootFocusStyles.primary, rootFocusStyles[size], rootFocusStyles[shape], // Icon-only styles
|
1142
1142
|
iconOnly && rootIconOnlyStyles[size], // User provided class name
|
1143
1143
|
state.root.className);
|
1144
1144
|
if (state.icon) {
|