@fluentui/react-infobutton 9.0.0-beta.7 → 9.0.0-beta.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.json +2309 -1
  2. package/CHANGELOG.md +787 -2
  3. package/dist/index.d.ts +75 -5
  4. package/lib/InfoButton.js +0 -1
  5. package/lib/InfoButton.js.map +1 -1
  6. package/lib/InfoLabel.js +1 -0
  7. package/lib/InfoLabel.js.map +1 -0
  8. package/lib/components/InfoButton/DefaultInfoButtonIcons.js +3 -4
  9. package/lib/components/InfoButton/DefaultInfoButtonIcons.js.map +1 -1
  10. package/lib/components/InfoButton/InfoButton.js +5 -7
  11. package/lib/components/InfoButton/InfoButton.js.map +1 -1
  12. package/lib/components/InfoButton/InfoButton.types.js +1 -2
  13. package/lib/components/InfoButton/InfoButton.types.js.map +1 -1
  14. package/lib/components/InfoButton/index.js +1 -2
  15. package/lib/components/InfoButton/index.js.map +1 -1
  16. package/lib/components/InfoButton/renderInfoButton.js +12 -16
  17. package/lib/components/InfoButton/renderInfoButton.js.map +1 -1
  18. package/lib/components/InfoButton/useInfoButton.js +68 -50
  19. package/lib/components/InfoButton/useInfoButton.js.map +1 -1
  20. package/lib/components/InfoButton/{useInfoButtonStyles.js → useInfoButtonStyles.styles.js} +10 -9
  21. package/lib/components/InfoButton/useInfoButtonStyles.styles.js.map +1 -0
  22. package/lib/components/InfoLabel/InfoLabel.js +12 -0
  23. package/lib/components/InfoLabel/InfoLabel.js.map +1 -0
  24. package/lib/components/InfoLabel/InfoLabel.types.js +1 -0
  25. package/lib/components/InfoLabel/InfoLabel.types.js.map +1 -0
  26. package/lib/components/InfoLabel/index.js +5 -0
  27. package/lib/components/InfoLabel/index.js.map +1 -0
  28. package/lib/components/InfoLabel/renderInfoLabel.js +13 -0
  29. package/lib/components/InfoLabel/renderInfoLabel.js.map +1 -0
  30. package/lib/components/InfoLabel/useInfoLabel.js +77 -0
  31. package/lib/components/InfoLabel/useInfoLabel.js.map +1 -0
  32. package/lib/components/InfoLabel/useInfoLabelStyles.styles.js +43 -0
  33. package/lib/components/InfoLabel/useInfoLabelStyles.styles.js.map +1 -0
  34. package/lib/index.js +1 -1
  35. package/lib/index.js.map +1 -1
  36. package/lib-commonjs/InfoButton.js +3 -5
  37. package/lib-commonjs/InfoButton.js.map +1 -1
  38. package/lib-commonjs/InfoLabel.js +6 -0
  39. package/lib-commonjs/InfoLabel.js.map +1 -0
  40. package/lib-commonjs/components/InfoButton/DefaultInfoButtonIcons.js +22 -8
  41. package/lib-commonjs/components/InfoButton/DefaultInfoButtonIcons.js.map +1 -1
  42. package/lib-commonjs/components/InfoButton/InfoButton.js +17 -16
  43. package/lib-commonjs/components/InfoButton/InfoButton.js.map +1 -1
  44. package/lib-commonjs/components/InfoButton/InfoButton.types.js +1 -3
  45. package/lib-commonjs/components/InfoButton/InfoButton.types.js.map +1 -1
  46. package/lib-commonjs/components/InfoButton/index.js +7 -9
  47. package/lib-commonjs/components/InfoButton/index.js.map +1 -1
  48. package/lib-commonjs/components/InfoButton/renderInfoButton.js +20 -23
  49. package/lib-commonjs/components/InfoButton/renderInfoButton.js.map +1 -1
  50. package/lib-commonjs/components/InfoButton/useInfoButton.js +79 -65
  51. package/lib-commonjs/components/InfoButton/useInfoButton.js.map +1 -1
  52. package/lib-commonjs/components/InfoButton/useInfoButtonStyles.styles.js +346 -0
  53. package/lib-commonjs/components/InfoButton/useInfoButtonStyles.styles.js.map +1 -0
  54. package/lib-commonjs/components/InfoLabel/InfoLabel.js +21 -0
  55. package/lib-commonjs/components/InfoLabel/InfoLabel.js.map +1 -0
  56. package/lib-commonjs/components/InfoLabel/InfoLabel.types.js +4 -0
  57. package/lib-commonjs/components/InfoLabel/InfoLabel.types.js.map +1 -0
  58. package/lib-commonjs/components/InfoLabel/index.js +10 -0
  59. package/lib-commonjs/components/InfoLabel/index.js.map +1 -0
  60. package/lib-commonjs/components/InfoLabel/renderInfoLabel.js +21 -0
  61. package/lib-commonjs/components/InfoLabel/renderInfoLabel.js.map +1 -0
  62. package/lib-commonjs/components/InfoLabel/useInfoLabel.js +80 -0
  63. package/lib-commonjs/components/InfoLabel/useInfoLabel.js.map +1 -0
  64. package/lib-commonjs/components/InfoLabel/useInfoLabelStyles.styles.js +66 -0
  65. package/lib-commonjs/components/InfoLabel/useInfoLabelStyles.styles.js.map +1 -0
  66. package/lib-commonjs/index.js +40 -34
  67. package/lib-commonjs/index.js.map +1 -1
  68. package/package.json +22 -16
  69. package/lib/components/InfoButton/useInfoButtonStyles.js.map +0 -1
  70. package/lib-commonjs/components/InfoButton/useInfoButtonStyles.js +0 -160
  71. package/lib-commonjs/components/InfoButton/useInfoButtonStyles.js.map +0 -1
@@ -0,0 +1,77 @@
1
+ import * as React from 'react';
2
+ import { Label } from '@fluentui/react-label';
3
+ import { mergeCallbacks, useEventCallback, useId, slot } from '@fluentui/react-utilities';
4
+ import { InfoButton } from '../InfoButton/InfoButton';
5
+ /**
6
+ * Create the state required to render InfoLabel.
7
+ *
8
+ * The returned state can be modified with hooks such as useInfoLabelStyles_unstable,
9
+ * before being passed to renderInfoLabel_unstable.
10
+ *
11
+ * @param props - props from this instance of InfoLabel
12
+ * @param ref - reference to label element of InfoLabel
13
+ */ export const useInfoLabel_unstable = (props, ref)=>{
14
+ const { root: rootShorthand, label: labelShorthand, infoButton: infoButtonShorthand, info, size, className, style, ...labelProps } = props;
15
+ const baseId = useId('infolabel-');
16
+ const [open, setOpen] = React.useState(false);
17
+ const root = slot.always(rootShorthand, {
18
+ defaultProps: {
19
+ className,
20
+ style
21
+ },
22
+ elementType: 'span'
23
+ });
24
+ const label = slot.always(labelShorthand, {
25
+ defaultProps: {
26
+ id: baseId + '__label',
27
+ ref,
28
+ size,
29
+ ...labelProps
30
+ },
31
+ elementType: Label
32
+ });
33
+ const infoButton = slot.optional(infoButtonShorthand, {
34
+ renderByDefault: !!info,
35
+ defaultProps: {
36
+ id: baseId + '__infoButton',
37
+ size,
38
+ info
39
+ },
40
+ elementType: InfoButton
41
+ });
42
+ const infoButtonPopover = slot.always(infoButton === null || infoButton === void 0 ? void 0 : infoButton.popover, {
43
+ elementType: 'div'
44
+ });
45
+ infoButtonPopover.onOpenChange = useEventCallback(mergeCallbacks(infoButtonPopover.onOpenChange, (e, data)=>{
46
+ setOpen(data.open);
47
+ }));
48
+ if (infoButton) {
49
+ var _infoButton, _arialabelledby;
50
+ infoButton.popover = infoButtonPopover;
51
+ infoButton.info = slot.optional(infoButton === null || infoButton === void 0 ? void 0 : infoButton.info, {
52
+ defaultProps: {
53
+ id: baseId + '__info'
54
+ },
55
+ elementType: 'div'
56
+ });
57
+ var _;
58
+ (_ = (_infoButton = infoButton)[_arialabelledby = 'aria-labelledby']) !== null && _ !== void 0 ? _ : _infoButton[_arialabelledby] = `${label.id} ${infoButton.id}`;
59
+ if (open) {
60
+ var _infoButton_info;
61
+ var _root, _ariaowns;
62
+ var _1;
63
+ (_1 = (_root = root)[_ariaowns = 'aria-owns']) !== null && _1 !== void 0 ? _1 : _root[_ariaowns] = (_infoButton_info = infoButton.info) === null || _infoButton_info === void 0 ? void 0 : _infoButton_info.id;
64
+ }
65
+ }
66
+ return {
67
+ size,
68
+ components: {
69
+ root: 'span',
70
+ label: Label,
71
+ infoButton: InfoButton
72
+ },
73
+ root,
74
+ label,
75
+ infoButton
76
+ };
77
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useInfoLabel.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { Label } from '@fluentui/react-label';\nimport { mergeCallbacks, useEventCallback, useId, slot } from '@fluentui/react-utilities';\nimport { InfoButton } from '../InfoButton/InfoButton';\nimport type { InfoLabelProps, InfoLabelState } from './InfoLabel.types';\n\n/**\n * Create the state required to render InfoLabel.\n *\n * The returned state can be modified with hooks such as useInfoLabelStyles_unstable,\n * before being passed to renderInfoLabel_unstable.\n *\n * @param props - props from this instance of InfoLabel\n * @param ref - reference to label element of InfoLabel\n */\nexport const useInfoLabel_unstable = (props: InfoLabelProps, ref: React.Ref<HTMLLabelElement>): InfoLabelState => {\n const {\n root: rootShorthand,\n label: labelShorthand,\n infoButton: infoButtonShorthand,\n info,\n size,\n className,\n style,\n ...labelProps\n } = props;\n const baseId = useId('infolabel-');\n const [open, setOpen] = React.useState(false);\n\n const root = slot.always(rootShorthand, {\n defaultProps: {\n className,\n style,\n },\n elementType: 'span',\n });\n\n const label = slot.always(labelShorthand, {\n defaultProps: {\n id: baseId + '__label',\n ref,\n size,\n ...labelProps,\n },\n elementType: Label,\n });\n\n const infoButton = slot.optional(infoButtonShorthand, {\n renderByDefault: !!info,\n defaultProps: {\n id: baseId + '__infoButton',\n size,\n info,\n },\n elementType: InfoButton,\n });\n\n const infoButtonPopover = slot.always(infoButton?.popover, {\n elementType: 'div',\n });\n infoButtonPopover.onOpenChange = useEventCallback(\n mergeCallbacks(infoButtonPopover.onOpenChange, (e, data) => {\n setOpen(data.open);\n }),\n );\n\n if (infoButton) {\n infoButton.popover = infoButtonPopover;\n infoButton.info = slot.optional(infoButton?.info, {\n defaultProps: {\n id: baseId + '__info',\n },\n elementType: 'div',\n });\n\n infoButton['aria-labelledby'] ??= `${label.id} ${infoButton.id}`;\n\n if (open) {\n root['aria-owns'] ??= infoButton.info?.id;\n }\n }\n\n return {\n size,\n components: {\n root: 'span',\n label: Label,\n infoButton: InfoButton,\n },\n root,\n label,\n infoButton,\n };\n};\n"],"names":["React","Label","mergeCallbacks","useEventCallback","useId","slot","InfoButton","useInfoLabel_unstable","props","ref","root","rootShorthand","label","labelShorthand","infoButton","infoButtonShorthand","info","size","className","style","labelProps","baseId","open","setOpen","useState","always","defaultProps","elementType","id","optional","renderByDefault","infoButtonPopover","popover","onOpenChange","e","data","components"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,KAAK,QAAQ,wBAAwB;AAC9C,SAASC,cAAc,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,IAAI,QAAQ,4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AAK,CAAC,EAAEF,MAAMgB,EAAE,CAAC,CAAC,EAAEd,WAAWc,EAAE,CAAC,CAAC;QAEhE,IAAIN,MAAM;gBACcR;gBAAtBJ,OAAK;;YAALA,OAAAA,QAAAA,KAAI,CAAC,YAAA,YAAY,mCAAjBA,KAAI,CAAC,UAAY,IAAKI,mBAAAA,WAAWE,IAAI,cAAfF,uCAAAA,iBAAiBc,EAAE;QAC3C;IACF;IAEA,OAAO;QACLX;QACAmB,YAAY;YACV1B,MAAM;YACNE,OAAOX;YACPa,YAAYR;QACd;QACAI;QACAE;QACAE;IACF;AACF,EAAE"}
@@ -0,0 +1,43 @@
1
+ import { tokens } from '@fluentui/react-theme';
2
+ import { __styles, mergeClasses } from '@griffel/react';
3
+ export const infoLabelClassNames = {
4
+ root: 'fui-InfoLabel',
5
+ label: 'fui-InfoLabel__label',
6
+ infoButton: 'fui-InfoLabel__infoButton'
7
+ };
8
+ const useLabelStyles = /*#__PURE__*/__styles({
9
+ base: {
10
+ ha4doy: "f12kltsn",
11
+ Bceei9c: "fpo1scq",
12
+ sj55zd: "f1ym3bx4"
13
+ }
14
+ }, {
15
+ d: [".f12kltsn{vertical-align:top;}", ".fpo1scq{cursor:inherit;}", ".f1ym3bx4{color:inherit;}"]
16
+ });
17
+ const useInfoButtonStyles = /*#__PURE__*/__styles({
18
+ base: {
19
+ ha4doy: "f12kltsn",
20
+ B6of3ja: "f1bmzb36",
21
+ jrapky: "f1nyzk09"
22
+ },
23
+ large: {
24
+ B6of3ja: "fkrn0sh",
25
+ jrapky: "fmxx68s"
26
+ }
27
+ }, {
28
+ d: [".f12kltsn{vertical-align:top;}", ".f1bmzb36{margin-top:calc(0px - var(--spacingVerticalXXS));}", ".f1nyzk09{margin-bottom:calc(0px - var(--spacingVerticalXXS));}", ".fkrn0sh{margin-top:-1px;}", ".fmxx68s{margin-bottom:-1px;}"]
29
+ });
30
+ /**
31
+ * Apply styling to the InfoLabel slots based on the state
32
+ */
33
+ export const useInfoLabelStyles_unstable = state => {
34
+ state.root.className = mergeClasses(infoLabelClassNames.root, state.root.className);
35
+ const labelStyles = useLabelStyles();
36
+ state.label.className = mergeClasses(infoLabelClassNames.label, labelStyles.base, state.label.className);
37
+ const infoButtonStyles = useInfoButtonStyles();
38
+ if (state.infoButton) {
39
+ state.infoButton.className = mergeClasses(infoLabelClassNames.infoButton, infoButtonStyles.base, state.size === 'large' && infoButtonStyles.large, state.infoButton.className);
40
+ }
41
+ return state;
42
+ };
43
+ //# sourceMappingURL=useInfoLabelStyles.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["tokens","__styles","mergeClasses","infoLabelClassNames","root","label","infoButton","useLabelStyles","base","ha4doy","Bceei9c","sj55zd","d","useInfoButtonStyles","B6of3ja","jrapky","large","useInfoLabelStyles_unstable","state","className","labelStyles","infoButtonStyles","size"],"sources":["useInfoLabelStyles.styles.js"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nexport const infoLabelClassNames = {\n root: 'fui-InfoLabel',\n label: 'fui-InfoLabel__label',\n infoButton: 'fui-InfoLabel__infoButton'\n};\nconst useLabelStyles = makeStyles({\n base: {\n verticalAlign: 'top',\n cursor: 'inherit',\n color: 'inherit'\n }\n});\nconst useInfoButtonStyles = makeStyles({\n base: {\n verticalAlign: 'top',\n // Negative margin to align with the text\n marginTop: `calc(0px - ${tokens.spacingVerticalXXS})`,\n marginBottom: `calc(0px - ${tokens.spacingVerticalXXS})`\n },\n large: {\n // Negative margin to align with the text\n marginTop: '-1px',\n marginBottom: '-1px'\n }\n});\n/**\n * Apply styling to the InfoLabel slots based on the state\n */ export const useInfoLabelStyles_unstable = (state)=>{\n state.root.className = mergeClasses(infoLabelClassNames.root, state.root.className);\n const labelStyles = useLabelStyles();\n state.label.className = mergeClasses(infoLabelClassNames.label, labelStyles.base, state.label.className);\n const infoButtonStyles = useInfoButtonStyles();\n if (state.infoButton) {\n state.infoButton.className = mergeClasses(infoLabelClassNames.infoButton, infoButtonStyles.base, state.size === 'large' && infoButtonStyles.large, state.infoButton.className);\n }\n return state;\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAAAC,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,OAAO,MAAMC,mBAAmB,GAAG;EAC/BC,IAAI,EAAE,eAAe;EACrBC,KAAK,EAAE,sBAAsB;EAC7BC,UAAU,EAAE;AAChB,CAAC;AACD,MAAMC,cAAc,gBAAGN,QAAA;EAAAO,IAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,CAMtB,CAAC;AACF,MAAMC,mBAAmB,gBAAGZ,QAAA;EAAAO,IAAA;IAAAC,MAAA;IAAAK,OAAA;IAAAC,MAAA;EAAA;EAAAC,KAAA;IAAAF,OAAA;IAAAC,MAAA;EAAA;AAAA;EAAAH,CAAA;AAAA,CAY3B,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMK,2BAA2B,GAAIC,KAAK,IAAG;EACpDA,KAAK,CAACd,IAAI,CAACe,SAAS,GAAGjB,YAAY,CAACC,mBAAmB,CAACC,IAAI,EAAEc,KAAK,CAACd,IAAI,CAACe,SAAS,CAAC;EACnF,MAAMC,WAAW,GAAGb,cAAc,CAAC,CAAC;EACpCW,KAAK,CAACb,KAAK,CAACc,SAAS,GAAGjB,YAAY,CAACC,mBAAmB,CAACE,KAAK,EAAEe,WAAW,CAACZ,IAAI,EAAEU,KAAK,CAACb,KAAK,CAACc,SAAS,CAAC;EACxG,MAAME,gBAAgB,GAAGR,mBAAmB,CAAC,CAAC;EAC9C,IAAIK,KAAK,CAACZ,UAAU,EAAE;IAClBY,KAAK,CAACZ,UAAU,CAACa,SAAS,GAAGjB,YAAY,CAACC,mBAAmB,CAACG,UAAU,EAAEe,gBAAgB,CAACb,IAAI,EAAEU,KAAK,CAACI,IAAI,KAAK,OAAO,IAAID,gBAAgB,CAACL,KAAK,EAAEE,KAAK,CAACZ,UAAU,CAACa,SAAS,CAAC;EAClL;EACA,OAAOD,KAAK;AAChB,CAAC"}
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export { InfoButton, infoButtonClassNames, renderInfoButton_unstable, useInfoButtonStyles_unstable, useInfoButton_unstable } from './InfoButton';
2
- //# sourceMappingURL=index.js.map
2
+ export { InfoLabel, infoLabelClassNames, renderInfoLabel_unstable, useInfoLabelStyles_unstable, useInfoLabel_unstable } from './InfoLabel';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,yBAAyB,EACzBC,4BAA4B,EAC5BC,sBAAsB,QACjB,cAAc","names":["InfoButton","infoButtonClassNames","renderInfoButton_unstable","useInfoButtonStyles_unstable","useInfoButton_unstable"],"sourceRoot":"../src/","sources":["packages/react-components/react-infobutton/src/index.ts"],"sourcesContent":["export {\n InfoButton,\n infoButtonClassNames,\n renderInfoButton_unstable,\n useInfoButtonStyles_unstable,\n useInfoButton_unstable,\n} from './InfoButton';\nexport type { InfoButtonProps, InfoButtonSlots, InfoButtonState } from './InfoButton';\n"]}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export {\n InfoButton,\n infoButtonClassNames,\n renderInfoButton_unstable,\n useInfoButtonStyles_unstable,\n useInfoButton_unstable,\n} from './InfoButton';\nexport type { InfoButtonProps, InfoButtonSlots, InfoButtonState } from './InfoButton';\nexport {\n InfoLabel,\n infoLabelClassNames,\n renderInfoLabel_unstable,\n useInfoLabelStyles_unstable,\n useInfoLabel_unstable,\n} from './InfoLabel';\nexport type { InfoLabelProps, InfoLabelSlots, InfoLabelState } from './InfoLabel';\n"],"names":["InfoButton","infoButtonClassNames","renderInfoButton_unstable","useInfoButtonStyles_unstable","useInfoButton_unstable","InfoLabel","infoLabelClassNames","renderInfoLabel_unstable","useInfoLabelStyles_unstable","useInfoLabel_unstable"],"mappings":"AAAA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,yBAAyB,EACzBC,4BAA4B,EAC5BC,sBAAsB,QACjB,eAAe;AAEtB,SACEC,SAAS,EACTC,mBAAmB,EACnBC,wBAAwB,EACxBC,2BAA2B,EAC3BC,qBAAqB,QAChB,cAAc"}
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- const tslib_1 = /*#__PURE__*/require("tslib");
7
- tslib_1.__exportStar(require("./components/InfoButton/index"), exports);
8
- //# sourceMappingURL=InfoButton.js.map
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./components/InfoButton/index"), exports);
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-infobutton/src/InfoButton.ts"],"sourcesContent":["export * from './components/InfoButton/index';\n"]}
1
+ {"version":3,"sources":["InfoButton.js"],"sourcesContent":["export * from './components/InfoButton/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./components/InfoLabel/index"), exports);
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["InfoLabel.js"],"sourcesContent":["export * from './components/InfoLabel/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
@@ -1,11 +1,25 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.DefaultInfoButtonIcon20 = exports.DefaultInfoButtonIcon16 = exports.DefaultInfoButtonIcon12 = void 0;
7
- const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
8
- exports.DefaultInfoButtonIcon12 = /*#__PURE__*/react_icons_1.bundleIcon(react_icons_1.Info12Filled, react_icons_1.Info12Regular);
9
- exports.DefaultInfoButtonIcon16 = /*#__PURE__*/react_icons_1.bundleIcon(react_icons_1.Info16Filled, react_icons_1.Info16Regular);
10
- exports.DefaultInfoButtonIcon20 = /*#__PURE__*/react_icons_1.bundleIcon(react_icons_1.Info20Filled, react_icons_1.Info20Regular);
11
- //# sourceMappingURL=DefaultInfoButtonIcons.js.map
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ DefaultInfoButtonIcon12: function() {
13
+ return DefaultInfoButtonIcon12;
14
+ },
15
+ DefaultInfoButtonIcon16: function() {
16
+ return DefaultInfoButtonIcon16;
17
+ },
18
+ DefaultInfoButtonIcon20: function() {
19
+ return DefaultInfoButtonIcon20;
20
+ }
21
+ });
22
+ const _reacticons = require("@fluentui/react-icons");
23
+ const DefaultInfoButtonIcon12 = (0, _reacticons.bundleIcon)(_reacticons.Info12Filled, _reacticons.Info12Regular);
24
+ const DefaultInfoButtonIcon16 = (0, _reacticons.bundleIcon)(_reacticons.Info16Filled, _reacticons.Info16Regular);
25
+ const DefaultInfoButtonIcon20 = (0, _reacticons.bundleIcon)(_reacticons.Info20Filled, _reacticons.Info20Regular);
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAA;AAUaA,+BAAuB,gBAAGC,wBAAU,CAACA,0BAAY,EAAEA,2BAAa,CAAC;AACjED,+BAAuB,gBAAGC,wBAAU,CAACA,0BAAY,EAAEA,2BAAa,CAAC;AACjED,+BAAuB,gBAAGC,wBAAU,CAACA,0BAAY,EAAEA,2BAAa,CAAC","names":["exports","react_icons_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-infobutton/src/components/InfoButton/DefaultInfoButtonIcons.tsx"],"sourcesContent":["import {\n Info12Regular,\n Info12Filled,\n Info16Regular,\n Info16Filled,\n Info20Regular,\n Info20Filled,\n bundleIcon,\n} from '@fluentui/react-icons';\n\nexport const DefaultInfoButtonIcon12 = bundleIcon(Info12Filled, Info12Regular);\nexport const DefaultInfoButtonIcon16 = bundleIcon(Info16Filled, Info16Regular);\nexport const DefaultInfoButtonIcon20 = bundleIcon(Info20Filled, Info20Regular);\n"]}
1
+ {"version":3,"sources":["DefaultInfoButtonIcons.js"],"sourcesContent":["import { Info12Regular, Info12Filled, Info16Regular, Info16Filled, Info20Regular, Info20Filled, bundleIcon } from '@fluentui/react-icons';\nexport const DefaultInfoButtonIcon12 = bundleIcon(Info12Filled, Info12Regular);\nexport const DefaultInfoButtonIcon16 = bundleIcon(Info16Filled, Info16Regular);\nexport const DefaultInfoButtonIcon20 = bundleIcon(Info20Filled, Info20Regular);\n"],"names":["DefaultInfoButtonIcon12","DefaultInfoButtonIcon16","DefaultInfoButtonIcon20","bundleIcon","Info12Filled","Info12Regular","Info16Filled","Info16Regular","Info20Filled","Info20Regular"],"mappings":";;;;;;;;;;;IACaA,uBAAuB;eAAvBA;;IACAC,uBAAuB;eAAvBA;;IACAC,uBAAuB;eAAvBA;;;4BAHqG;AAC3G,MAAMF,0BAA0BG,IAAAA,sBAAU,EAACC,wBAAY,EAAEC,yBAAa;AACtE,MAAMJ,0BAA0BE,IAAAA,sBAAU,EAACG,wBAAY,EAAEC,yBAAa;AACtE,MAAML,0BAA0BC,IAAAA,sBAAU,EAACK,wBAAY,EAAEC,yBAAa"}
@@ -1,20 +1,21 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.InfoButton = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const renderInfoButton_1 = /*#__PURE__*/require("./renderInfoButton");
9
- const useInfoButton_1 = /*#__PURE__*/require("./useInfoButton");
10
- const useInfoButtonStyles_1 = /*#__PURE__*/require("./useInfoButtonStyles");
11
- /**
12
- * InfoButtons provide a way to display additional information about a form field or an area in the UI.
13
- */
14
- exports.InfoButton = /*#__PURE__*/React.forwardRef((props, ref) => {
15
- const state = useInfoButton_1.useInfoButton_unstable(props, ref);
16
- useInfoButtonStyles_1.useInfoButtonStyles_unstable(state);
17
- return renderInfoButton_1.renderInfoButton_unstable(state);
5
+ Object.defineProperty(exports, "InfoButton", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return InfoButton;
9
+ }
18
10
  });
19
- exports.InfoButton.displayName = 'InfoButton';
20
- //# sourceMappingURL=InfoButton.js.map
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _renderInfoButton = require("./renderInfoButton");
14
+ const _useInfoButton = require("./useInfoButton");
15
+ const _useInfoButtonStylesstyles = require("./useInfoButtonStyles.styles");
16
+ const InfoButton = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
17
+ const state = (0, _useInfoButton.useInfoButton_unstable)(props, ref);
18
+ (0, _useInfoButtonStylesstyles.useInfoButtonStyles_unstable)(state);
19
+ return (0, _renderInfoButton.renderInfoButton_unstable)(state);
20
+ });
21
+ InfoButton.displayName = 'InfoButton';
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AAGA;;;AAGaA,kBAAU,gBAAyCC,KAAK,CAACC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EAC9F,MAAMC,KAAK,GAAGC,sCAAsB,CAACH,KAAK,EAAEC,GAAG,CAAC;EAEhDG,kDAA4B,CAACF,KAAK,CAAC;EACnC,OAAOG,4CAAyB,CAACH,KAAK,CAAC;AACzC,CAAC,CAAC;AAEFL,kBAAU,CAACS,WAAW,GAAG,YAAY","names":["exports","React","forwardRef","props","ref","state","useInfoButton_1","useInfoButtonStyles_1","renderInfoButton_1","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-infobutton/src/components/InfoButton/InfoButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { renderInfoButton_unstable } from './renderInfoButton';\nimport { useInfoButton_unstable } from './useInfoButton';\nimport { useInfoButtonStyles_unstable } from './useInfoButtonStyles';\nimport type { InfoButtonProps } from './InfoButton.types';\n\n/**\n * InfoButtons provide a way to display additional information about a form field or an area in the UI.\n */\nexport const InfoButton: ForwardRefComponent<InfoButtonProps> = React.forwardRef((props, ref) => {\n const state = useInfoButton_unstable(props, ref);\n\n useInfoButtonStyles_unstable(state);\n return renderInfoButton_unstable(state);\n});\n\nInfoButton.displayName = 'InfoButton';\n"]}
1
+ {"version":3,"sources":["InfoButton.js"],"sourcesContent":["import * as React from 'react';\nimport { renderInfoButton_unstable } from './renderInfoButton';\nimport { useInfoButton_unstable } from './useInfoButton';\nimport { useInfoButtonStyles_unstable } from './useInfoButtonStyles.styles';\n/**\n * InfoButtons provide a way to display additional information about a form field or an area in the UI.\n */ export const InfoButton = /*#__PURE__*/ React.forwardRef((props, ref)=>{\n const state = useInfoButton_unstable(props, ref);\n useInfoButtonStyles_unstable(state);\n return renderInfoButton_unstable(state);\n});\nInfoButton.displayName = 'InfoButton';\n"],"names":["InfoButton","React","forwardRef","props","ref","state","useInfoButton_unstable","useInfoButtonStyles_unstable","renderInfoButton_unstable","displayName"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;iEANM;kCACmB;+BACH;2CACM;AAGlC,MAAMA,aAAa,WAAW,GAAGC,OAAMC,UAAU,CAAC,CAACC,OAAOC;IACjE,MAAMC,QAAQC,IAAAA,qCAAsB,EAACH,OAAOC;IAC5CG,IAAAA,uDAA4B,EAACF;IAC7B,OAAOG,IAAAA,2CAAyB,EAACH;AACrC;AACAL,WAAWS,WAAW,GAAG"}
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- //# sourceMappingURL=InfoButton.types.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- const tslib_1 = /*#__PURE__*/require("tslib");
7
- tslib_1.__exportStar(require("./InfoButton"), exports);
8
- tslib_1.__exportStar(require("./InfoButton.types"), exports);
9
- tslib_1.__exportStar(require("./renderInfoButton"), exports);
10
- tslib_1.__exportStar(require("./useInfoButton"), exports);
11
- tslib_1.__exportStar(require("./useInfoButtonStyles"), exports);
12
- //# sourceMappingURL=index.js.map
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./InfoButton"), exports);
7
+ _export_star._(require("./InfoButton.types"), exports);
8
+ _export_star._(require("./renderInfoButton"), exports);
9
+ _export_star._(require("./useInfoButton"), exports);
10
+ _export_star._(require("./useInfoButtonStyles.styles"), exports);
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-infobutton/src/components/InfoButton/index.ts"],"sourcesContent":["export * from './InfoButton';\nexport * from './InfoButton.types';\nexport * from './renderInfoButton';\nexport * from './useInfoButton';\nexport * from './useInfoButtonStyles';\n"]}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export * from './InfoButton';\nexport * from './InfoButton.types';\nexport * from './renderInfoButton';\nexport * from './useInfoButton';\nexport * from './useInfoButtonStyles.styles';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA"}
@@ -1,27 +1,24 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.renderInfoButton_unstable = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
9
- const react_popover_1 = /*#__PURE__*/require("@fluentui/react-popover");
10
- /**
11
- * Render the final JSX of InfoButton
12
- */
13
- const renderInfoButton_unstable = state => {
14
- const {
15
- slots,
16
- slotProps
17
- } = react_utilities_1.getSlots(state);
18
- return React.createElement(slots.popover, {
19
- ...slotProps.popover
20
- }, React.createElement(react_popover_1.PopoverTrigger, null, React.createElement(slots.root, {
21
- ...slotProps.root
22
- })), React.createElement(slots.content, {
23
- ...slotProps.content
24
- }));
5
+ Object.defineProperty(exports, "renderInfoButton_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return renderInfoButton_unstable;
9
+ }
10
+ });
11
+ const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
12
+ const _reactutilities = require("@fluentui/react-utilities");
13
+ const _reactpopover = require("@fluentui/react-popover");
14
+ const renderInfoButton_unstable = (state)=>{
15
+ (0, _reactutilities.assertSlots)(state);
16
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(state.popover, {
17
+ children: [
18
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpopover.PopoverTrigger, {
19
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {})
20
+ }),
21
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(state.info, {})
22
+ ]
23
+ });
25
24
  };
26
- exports.renderInfoButton_unstable = renderInfoButton_unstable;
27
- //# sourceMappingURL=renderInfoButton.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAIA;;;AAGO,MAAMA,yBAAyB,GAAIC,KAAsB,IAAI;EAClE,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGC,0BAAQ,CAAkBH,KAAK,CAAC;EAE7D,OACEI,oBAACH,KAAK,CAACI,OAAO;IAAA,GAAMH,SAAS,CAACG;EAAwB,GACpDD,oBAACE,8BAAc,QACbF,oBAACH,KAAK,CAACM,IAAI;IAAA,GAAKL,SAAS,CAACK;EAAI,EAAI,CACnB,EACjBH,oBAACH,KAAK,CAACO,OAAO;IAAA,GAAKN,SAAS,CAACM;EAAO,EAAI,CAC1B;AAEpB,CAAC;AAXYC,iCAAyB","names":["renderInfoButton_unstable","state","slots","slotProps","react_utilities_1","React","popover","react_popover_1","root","content","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-infobutton/src/components/InfoButton/renderInfoButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { PopoverTrigger } from '@fluentui/react-popover';\nimport type { PopoverProps } from '@fluentui/react-popover';\nimport type { InfoButtonState, InfoButtonSlots } from './InfoButton.types';\n\n/**\n * Render the final JSX of InfoButton\n */\nexport const renderInfoButton_unstable = (state: InfoButtonState) => {\n const { slots, slotProps } = getSlots<InfoButtonSlots>(state);\n\n return (\n <slots.popover {...(slotProps.popover as PopoverProps)}>\n <PopoverTrigger>\n <slots.root {...slotProps.root} />\n </PopoverTrigger>\n <slots.content {...slotProps.content} />\n </slots.popover>\n );\n};\n"]}
1
+ {"version":3,"sources":["renderInfoButton.js"],"sourcesContent":[" import { jsx as _jsx, jsxs as _jsxs } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport { assertSlots } from '@fluentui/react-utilities';\nimport { PopoverTrigger } from '@fluentui/react-popover';\n/**\n * Render the final JSX of InfoButton\n */ export const renderInfoButton_unstable = (state)=>{\n assertSlots(state);\n return /*#__PURE__*/ _jsxs(state.popover, {\n children: [\n /*#__PURE__*/ _jsx(PopoverTrigger, {\n children: /*#__PURE__*/ _jsx(state.root, {})\n }),\n /*#__PURE__*/ _jsx(state.info, {})\n ]\n });\n};\n"],"names":["renderInfoButton_unstable","state","assertSlots","_jsxs","popover","children","_jsx","PopoverTrigger","root","info"],"mappings":";;;;+BAKiBA;;;eAAAA;;;4BAL4B;gCACjB;8BACG;AAGpB,MAAMA,4BAA4B,CAACC;IAC1CC,IAAAA,2BAAW,EAACD;IACZ,OAAO,WAAW,GAAGE,IAAAA,gBAAK,EAACF,MAAMG,OAAO,EAAE;QACtCC,UAAU;YACN,WAAW,GAAGC,IAAAA,eAAI,EAACC,4BAAc,EAAE;gBAC/BF,UAAU,WAAW,GAAGC,IAAAA,eAAI,EAACL,MAAMO,IAAI,EAAE,CAAC;YAC9C;YACA,WAAW,GAAGF,IAAAA,eAAI,EAACL,MAAMQ,IAAI,EAAE,CAAC;SACnC;IACL;AACJ"}
@@ -1,73 +1,87 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.useInfoButton_unstable = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const DefaultInfoButtonIcons_1 = /*#__PURE__*/require("./DefaultInfoButtonIcons");
9
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
10
- const react_popover_1 = /*#__PURE__*/require("@fluentui/react-popover");
11
- const react_utilities_2 = /*#__PURE__*/require("@fluentui/react-utilities");
5
+ Object.defineProperty(exports, "useInfoButton_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useInfoButton_unstable;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _DefaultInfoButtonIcons = require("./DefaultInfoButtonIcons");
14
+ const _reactutilities = require("@fluentui/react-utilities");
15
+ const _reactpopover = require("@fluentui/react-popover");
12
16
  const infoButtonIconMap = {
13
- small: /*#__PURE__*/React.createElement(DefaultInfoButtonIcons_1.DefaultInfoButtonIcon12, null),
14
- medium: /*#__PURE__*/React.createElement(DefaultInfoButtonIcons_1.DefaultInfoButtonIcon16, null),
15
- large: /*#__PURE__*/React.createElement(DefaultInfoButtonIcons_1.DefaultInfoButtonIcon20, null)
17
+ small: /*#__PURE__*/ _react.createElement(_DefaultInfoButtonIcons.DefaultInfoButtonIcon12, null),
18
+ medium: /*#__PURE__*/ _react.createElement(_DefaultInfoButtonIcons.DefaultInfoButtonIcon16, null),
19
+ large: /*#__PURE__*/ _react.createElement(_DefaultInfoButtonIcons.DefaultInfoButtonIcon20, null)
16
20
  };
17
21
  const popoverSizeMap = {
18
- small: 'small',
19
- medium: 'small',
20
- large: 'medium'
22
+ small: 'small',
23
+ medium: 'small',
24
+ large: 'medium'
21
25
  };
22
- /**
23
- * Create the state required to render InfoButton.
24
- *
25
- * The returned state can be modified with hooks such as useInfoButtonStyles_unstable,
26
- * before being passed to renderInfoButton_unstable.
27
- *
28
- * @param props - props from this instance of InfoButton
29
- * @param ref - reference to root HTMLElement of InfoButton
30
- */
31
- const useInfoButton_unstable = (props, ref) => {
32
- const {
33
- size = 'medium'
34
- } = props;
35
- const state = {
36
- size,
37
- components: {
38
- root: 'button',
39
- popover: react_popover_1.Popover,
40
- content: react_popover_1.PopoverSurface
41
- },
42
- root: react_utilities_1.getNativeElementProps('button', {
43
- children: infoButtonIconMap[size],
44
- type: 'button',
45
- ...props,
46
- ref
47
- }),
48
- popover: react_utilities_1.resolveShorthand(props.popover, {
49
- required: true,
50
- defaultProps: {
51
- positioning: 'above-start',
52
- size: popoverSizeMap[size],
53
- withArrow: true
54
- }
55
- }),
56
- content: react_utilities_1.resolveShorthand(props.content, {
57
- required: true,
58
- defaultProps: {
59
- role: 'note'
60
- }
61
- })
62
- };
63
- const [popoverOpen, setPopoverOpen] = react_utilities_2.useControllableState({
64
- state: state.popover.open,
65
- defaultState: state.popover.defaultOpen,
66
- initialState: false
67
- });
68
- state.popover.open = popoverOpen;
69
- state.popover.onOpenChange = react_utilities_1.mergeCallbacks(state.popover.onOpenChange, (e, data) => setPopoverOpen(data.open));
70
- return state;
26
+ const useInfoButton_unstable = (props, ref)=>{
27
+ const { size = 'medium', inline = true } = props;
28
+ const state = {
29
+ inline,
30
+ size,
31
+ components: {
32
+ root: 'button',
33
+ popover: _reactpopover.Popover,
34
+ info: _reactpopover.PopoverSurface
35
+ },
36
+ root: _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('button', {
37
+ children: infoButtonIconMap[size],
38
+ type: 'button',
39
+ 'aria-label': 'information',
40
+ ...props,
41
+ // FIXME:
42
+ // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLButtonElement`
43
+ // but since it would be a breaking change to fix it, we are casting ref to it's proper type
44
+ ref: ref
45
+ }), {
46
+ elementType: 'button'
47
+ }),
48
+ popover: _reactutilities.slot.always(props.popover, {
49
+ defaultProps: {
50
+ inline,
51
+ positioning: 'above-start',
52
+ size: popoverSizeMap[size],
53
+ withArrow: true
54
+ },
55
+ elementType: _reactpopover.Popover
56
+ }),
57
+ info: _reactutilities.slot.always(props.info, {
58
+ defaultProps: {
59
+ role: 'note',
60
+ tabIndex: -1
61
+ },
62
+ elementType: _reactpopover.PopoverSurface
63
+ })
64
+ };
65
+ const [popoverOpen, setPopoverOpen] = (0, _reactutilities.useControllableState)({
66
+ state: state.popover.open,
67
+ defaultState: state.popover.defaultOpen,
68
+ initialState: false
69
+ });
70
+ state.popover.open = popoverOpen;
71
+ state.popover.onOpenChange = (0, _reactutilities.mergeCallbacks)(state.popover.onOpenChange, (e, data)=>setPopoverOpen(data.open));
72
+ const focusOutRef = _react.useCallback((el)=>{
73
+ if (!el) {
74
+ return;
75
+ }
76
+ el.addEventListener('focusout', (e)=>{
77
+ const nextFocused = e.relatedTarget;
78
+ if ((0, _reactutilities.isHTMLElement)(nextFocused) && !(0, _reactutilities.elementContains)(el, nextFocused)) {
79
+ setPopoverOpen(false);
80
+ }
81
+ });
82
+ }, [
83
+ setPopoverOpen
84
+ ]);
85
+ state.info.ref = (0, _reactutilities.useMergedRefs)(state.info.ref, focusOutRef);
86
+ return state;
71
87
  };
72
- exports.useInfoButton_unstable = useInfoButton_unstable;
73
- //# sourceMappingURL=useInfoButton.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAIA,MAAMA,iBAAiB,GAAG;EACxBC,KAAK,eAAEC,oBAACC,gDAAuB,OAAG;EAClCC,MAAM,eAAEF,oBAACC,gDAAuB,OAAG;EACnCE,KAAK,eAAEH,oBAACC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AACC,CAAC,EAAEC,IAAI,KAAKR,cAAc,CAACQ,IAAI,CAACN,IAAI,CAAC,CAAC;EAE/G,OAAOjB,KAAK;AACd,CAAC;AA5CYwB,8BAAsB","names":["infoButtonIconMap","small","React","DefaultInfoButtonIcons_1","medium","large","popoverSizeMap","useInfoButton_unstable","props","ref","size","state","components","root","popover","react_popover_1","content","react_utilities_1","children","type","required","defaultProps","positioning","withArrow","role","popoverOpen","setPopoverOpen","react_utilities_2","open","defaultState","defaultOpen","initialState","onOpenChange","e","data","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-infobutton/src/components/InfoButton/useInfoButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { DefaultInfoButtonIcon12, DefaultInfoButtonIcon16, DefaultInfoButtonIcon20 } from './DefaultInfoButtonIcons';\nimport { getNativeElementProps, mergeCallbacks, resolveShorthand } from '@fluentui/react-utilities';\nimport { Popover, PopoverSurface } from '@fluentui/react-popover';\nimport { useControllableState } from '@fluentui/react-utilities';\nimport type { InfoButtonProps, InfoButtonState } from './InfoButton.types';\nimport type { PopoverProps } from '@fluentui/react-popover';\n\nconst infoButtonIconMap = {\n small: <DefaultInfoButtonIcon12 />,\n medium: <DefaultInfoButtonIcon16 />,\n large: <DefaultInfoButtonIcon20 />,\n} as const;\n\nconst popoverSizeMap = {\n small: 'small',\n medium: 'small',\n large: 'medium',\n} as const;\n\n/**\n * Create the state required to render InfoButton.\n *\n * The returned state can be modified with hooks such as useInfoButtonStyles_unstable,\n * before being passed to renderInfoButton_unstable.\n *\n * @param props - props from this instance of InfoButton\n * @param ref - reference to root HTMLElement of InfoButton\n */\nexport const useInfoButton_unstable = (props: InfoButtonProps, ref: React.Ref<HTMLElement>): InfoButtonState => {\n const { size = 'medium' } = props;\n\n const state: InfoButtonState = {\n size,\n\n components: {\n root: 'button',\n popover: Popover as React.FC<Partial<PopoverProps>>,\n content: PopoverSurface,\n },\n\n root: getNativeElementProps('button', {\n children: infoButtonIconMap[size],\n type: 'button',\n ...props,\n ref,\n }),\n popover: resolveShorthand(props.popover, {\n required: true,\n defaultProps: {\n positioning: 'above-start',\n size: popoverSizeMap[size],\n withArrow: true,\n },\n }),\n content: resolveShorthand(props.content, {\n required: true,\n defaultProps: {\n role: 'note',\n },\n }),\n };\n\n const [popoverOpen, setPopoverOpen] = useControllableState({\n state: state.popover.open,\n defaultState: state.popover.defaultOpen,\n initialState: false,\n });\n\n state.popover.open = popoverOpen;\n state.popover.onOpenChange = mergeCallbacks(state.popover.onOpenChange, (e, data) => setPopoverOpen(data.open));\n\n return state;\n};\n"]}
1
+ {"version":3,"sources":["useInfoButton.js"],"sourcesContent":["import * as React from 'react';\nimport { DefaultInfoButtonIcon12, DefaultInfoButtonIcon16, DefaultInfoButtonIcon20 } from './DefaultInfoButtonIcons';\nimport { getIntrinsicElementProps, mergeCallbacks, useControllableState, slot, useMergedRefs, isHTMLElement, elementContains } from '@fluentui/react-utilities';\nimport { Popover, PopoverSurface } from '@fluentui/react-popover';\nconst infoButtonIconMap = {\n small: /*#__PURE__*/ React.createElement(DefaultInfoButtonIcon12, null),\n medium: /*#__PURE__*/ React.createElement(DefaultInfoButtonIcon16, null),\n large: /*#__PURE__*/ React.createElement(DefaultInfoButtonIcon20, null)\n};\nconst popoverSizeMap = {\n small: 'small',\n medium: 'small',\n large: 'medium'\n};\n/**\n * Create the state required to render InfoButton.\n *\n * The returned state can be modified with hooks such as useInfoButtonStyles_unstable,\n * before being passed to renderInfoButton_unstable.\n *\n * @param props - props from this instance of InfoButton\n * @param ref - reference to root HTMLElement of InfoButton\n */ export const useInfoButton_unstable = (props, ref)=>{\n const { size = 'medium', inline = true } = props;\n const state = {\n inline,\n size,\n components: {\n root: 'button',\n popover: Popover,\n info: PopoverSurface\n },\n root: slot.always(getIntrinsicElementProps('button', {\n children: infoButtonIconMap[size],\n type: 'button',\n 'aria-label': 'information',\n ...props,\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLButtonElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: ref\n }), {\n elementType: 'button'\n }),\n popover: slot.always(props.popover, {\n defaultProps: {\n inline,\n positioning: 'above-start',\n size: popoverSizeMap[size],\n withArrow: true\n },\n elementType: Popover\n }),\n info: slot.always(props.info, {\n defaultProps: {\n role: 'note',\n tabIndex: -1\n },\n elementType: PopoverSurface\n })\n };\n const [popoverOpen, setPopoverOpen] = useControllableState({\n state: state.popover.open,\n defaultState: state.popover.defaultOpen,\n initialState: false\n });\n state.popover.open = popoverOpen;\n state.popover.onOpenChange = mergeCallbacks(state.popover.onOpenChange, (e, data)=>setPopoverOpen(data.open));\n const focusOutRef = React.useCallback((el)=>{\n if (!el) {\n return;\n }\n el.addEventListener('focusout', (e)=>{\n const nextFocused = e.relatedTarget;\n if (isHTMLElement(nextFocused) && !elementContains(el, nextFocused)) {\n setPopoverOpen(false);\n }\n });\n }, [\n setPopoverOpen\n ]);\n state.info.ref = useMergedRefs(state.info.ref, focusOutRef);\n return state;\n};\n"],"names":["useInfoButton_unstable","infoButtonIconMap","small","React","createElement","DefaultInfoButtonIcon12","medium","DefaultInfoButtonIcon16","large","DefaultInfoButtonIcon20","popoverSizeMap","props","ref","size","inline","state","components","root","popover","Popover","info","PopoverSurface","slot","always","getIntrinsicElementProps","children","type","elementType","defaultProps","positioning","withArrow","role","tabIndex","popoverOpen","setPopoverOpen","useControllableState","open","defaultState","defaultOpen","initialState","onOpenChange","mergeCallbacks","e","data","focusOutRef","useCallback","el","addEventListener","nextFocused","relatedTarget","isHTMLElement","elementContains","useMergedRefs"],"mappings":";;;;+BAsBiBA;;;eAAAA;;;;iEAtBM;wCACmE;gCAC0C;8BAC5F;AACxC,MAAMC,oBAAoB;IACtBC,OAAO,WAAW,GAAGC,OAAMC,aAAa,CAACC,+CAAuB,EAAE;IAClEC,QAAQ,WAAW,GAAGH,OAAMC,aAAa,CAACG,+CAAuB,EAAE;IACnEC,OAAO,WAAW,GAAGL,OAAMC,aAAa,CAACK,+C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