@muraldevkit/ui-toolkit 4.70.3 → 4.71.0-dev-nBIF.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.
Files changed (42) hide show
  1. package/dist/cjs/components/button/MrlButton/MrlButton.js +8 -1
  2. package/dist/cjs/components/button/MrlButton/MrlButton.js.map +1 -1
  3. package/dist/cjs/contexts/MrlAnalyticsContext/MrlAnalyticsContext.js +54 -0
  4. package/dist/cjs/contexts/MrlAnalyticsContext/MrlAnalyticsContext.js.map +1 -0
  5. package/dist/cjs/hooks/useMrlAnalytics/useMrlAnalytics.js +69 -0
  6. package/dist/cjs/hooks/useMrlAnalytics/useMrlAnalytics.js.map +1 -0
  7. package/dist/cjs/index.js +6 -0
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/version.js +6 -0
  10. package/dist/cjs/version.js.map +1 -0
  11. package/dist/components/button/MrlButton/MrlButton.d.ts +5 -0
  12. package/dist/components/svg/config.d.ts +1 -1
  13. package/dist/contexts/MrlAnalyticsContext/MrlAnalyticsContext.d.ts +25 -0
  14. package/dist/contexts/MrlAnalyticsContext/index.d.ts +2 -0
  15. package/dist/contexts/MrlAnalyticsContext/types.d.ts +22 -0
  16. package/dist/contexts/index.d.ts +1 -0
  17. package/dist/esm/components/button/MrlButton/MrlButton.js +8 -1
  18. package/dist/esm/components/button/MrlButton/MrlButton.js.map +1 -1
  19. package/dist/esm/contexts/MrlAnalyticsContext/MrlAnalyticsContext.js +32 -0
  20. package/dist/esm/contexts/MrlAnalyticsContext/MrlAnalyticsContext.js.map +1 -0
  21. package/dist/esm/hooks/useMrlAnalytics/useMrlAnalytics.js +46 -0
  22. package/dist/esm/hooks/useMrlAnalytics/useMrlAnalytics.js.map +1 -0
  23. package/dist/esm/index.js +2 -0
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/version.js +4 -0
  26. package/dist/esm/version.js.map +1 -0
  27. package/dist/hooks/index.d.ts +1 -0
  28. package/dist/hooks/useMrlAnalytics/index.d.ts +1 -0
  29. package/dist/hooks/useMrlAnalytics/useMrlAnalytics.d.ts +21 -0
  30. package/dist/hooks/useMrlAnalytics/useMrlAnalyticsDemo.d.ts +8 -0
  31. package/dist/types/components/button/MrlButton/MrlButton.d.ts +5 -0
  32. package/dist/types/contexts/MrlAnalyticsContext/MrlAnalyticsContext.d.ts +25 -0
  33. package/dist/types/contexts/MrlAnalyticsContext/index.d.ts +2 -0
  34. package/dist/types/contexts/MrlAnalyticsContext/types.d.ts +22 -0
  35. package/dist/types/contexts/index.d.ts +1 -0
  36. package/dist/types/hooks/index.d.ts +1 -0
  37. package/dist/types/hooks/useMrlAnalytics/index.d.ts +1 -0
  38. package/dist/types/hooks/useMrlAnalytics/useMrlAnalytics.d.ts +21 -0
  39. package/dist/types/hooks/useMrlAnalytics/useMrlAnalyticsDemo.d.ts +8 -0
  40. package/dist/types/version.d.ts +1 -0
  41. package/dist/version.d.ts +1 -0
  42. package/package.json +2 -1
@@ -6,6 +6,7 @@ var classnames = require('classnames');
6
6
  var constants$1 = require('../constants.js');
7
7
  var helpers = require('../helpers.js');
8
8
  var constants = require('../../loader/constants.js');
9
+ var useMrlAnalytics = require('../../../hooks/useMrlAnalytics/useMrlAnalytics.js');
9
10
  var setAttributes = require('../../../utils/setAttributes/setAttributes.js');
10
11
  var MrlTooltip = require('../../tooltip/MrlTooltip/MrlTooltip.js');
11
12
  var MrlSpinner = require('../../loader/MrlSpinner/MrlSpinner.js');
@@ -33,7 +34,7 @@ function _interopNamespace(e) {
33
34
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
35
  var classnames__default = /*#__PURE__*/_interopDefault(classnames);
35
36
 
36
- var _excluded = ["attrs", "badge", "className", "disabled", "disableEvents", "icon", "iconPos", "kind", "loading", "loadingText", "onClick", "toggleAria", "toggleStyle", "text", "size", "state", "tooltip"];
37
+ var _excluded = ["attrs", "badge", "className", "disabled", "disableEvents", "icon", "iconPos", "kind", "loading", "loadingText", "onClick", "toggleAria", "toggleStyle", "text", "trackingId", "size", "state", "tooltip"];
37
38
  var MrlButton = /*#__PURE__*/React__namespace.forwardRef(function MrlButton(_ref, ref) {
38
39
  var attrs = _ref.attrs,
39
40
  badge = _ref.badge,
@@ -56,6 +57,7 @@ var MrlButton = /*#__PURE__*/React__namespace.forwardRef(function MrlButton(_ref
56
57
  toggleAria = _ref$toggleAria === void 0 ? constants$1.buttonDefaults.toggleAria : _ref$toggleAria,
57
58
  toggleStyle = _ref.toggleStyle,
58
59
  text = _ref.text,
60
+ trackingId = _ref.trackingId,
59
61
  _ref$size = _ref.size,
60
62
  size = _ref$size === void 0 ? constants$1.buttonDefaults.size : _ref$size,
61
63
  _ref$state = _ref.state,
@@ -66,6 +68,7 @@ var MrlButton = /*#__PURE__*/React__namespace.forwardRef(function MrlButton(_ref
66
68
  _React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
67
69
  isSelected = _React$useState2[0],
68
70
  setIsSelected = _React$useState2[1];
71
+ var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlButton', trackingId);
69
72
 
70
73
  /**
71
74
  * MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'
@@ -92,6 +95,10 @@ var MrlButton = /*#__PURE__*/React__namespace.forwardRef(function MrlButton(_ref
92
95
  if (helpers._isDisabled(state, loading) || disabled || disableEvents) {
93
96
  return;
94
97
  }
98
+ trackInteraction({
99
+ action: 'click',
100
+ variant: kind
101
+ });
95
102
  if (isToggleButton) {
96
103
  setIsSelected(prevIsSelected => !prevIsSelected);
97
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MrlButton.js","sources":["../../../../../src/components/button/MrlButton/MrlButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tallowedButtonValues,\n\tbuttonDefaults,\n\tMrlButtonKind,\n\tMrlButtonSize,\n\tToggleAria,\n\tIconPosition\n} from '../constants';\nimport { _isDisabled, _isSelected, _spinnerProps } from '../helpers';\nimport { MrlSpinner, MrlTooltipAnchor, MrlTooltipPosition, MrlTooltip } from '../../';\nimport { spinnerDefaults } from '../../loader/constants';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\n\nimport './MrlButton.global.scss';\n\nexport type MrlButtonState = (typeof allowedButtonValues.states)[number];\nexport type ToggleStyle = (typeof allowedButtonValues.toggleStyles)[number];\n\nexport interface TooltipConfig {\n\t/**\n\t * The text to display in the tooltip\n\t */\n\ttext: string;\n\t/**\n\t * The position of the tooltip relative to the button\n\t */\n\tposition?: MrlTooltipPosition;\n\n\t/**\n\t * The anchor of the tooltip relative to the button\n\t */\n\tanchor?: MrlTooltipAnchor;\n\n\t/**\n\t * The data-qa attribute for the tooltip\n\t */\n\tdataQa?: string;\n}\n\nexport interface MrlButtonProps\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tReact.ComponentProps<'button'> {\n\t/**\n\t * Applies additional HTML attributes to the button element.\n\t *\n\t * @deprecated\n\t */\n\tattrs?: AttrsObject;\n\t/**\n\t * Allow developers to add badge to buttons.\n\t */\n\tbadge?: React.ReactElement;\n\n\t/**\n\t * @deprecated - Use state=\"disabled\" or \"selected-disabled\" or \"skeleton\" instead.\n\t * Allow developers to change the disabled state based on user interactions.\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * Allows developers the ability to disable built in event listeners so they can manage user\n\t * interactions from the application.\n\t */\n\tdisableEvents?: boolean;\n\t/**\n\t * Allow developers to add icon to buttons.\n\t */\n\ticon?: React.ReactElement;\n\t/**\n\t * Allows developers to right-align an icon within a button.\n\t */\n\ticonPos?: IconPosition;\n\t/**\n\t * Changes the visual emphasis of the button.\n\t */\n\tkind?: MrlButtonKind;\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\t/**\n\t * Changes the size of the button so it can scale with its surrounding context.\n\t */\n\tsize?: MrlButtonSize;\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\t/**\n\t * The textual label describing the button's purpose/action.\n\t * Icon buttons require a text label to ensure accessibility.\n\t */\n\ttext: string;\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\n\t/**\n\t * Tooltip configuration for the button\n\t */\n\ttooltip?: TooltipConfig;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. The visual styles\n\t * are also impacted by the \"kind\" prop. Toggle buttons are only supported\n\t * when \"kind\" is set to either \"ghost\" or \"ghost-inverse\". Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\ttoggleStyle?: ToggleStyle;\n}\n\nexport const MrlButton = React.forwardRef<HTMLButtonElement, MrlButtonProps>(function MrlButton(\n\t{\n\t\tattrs,\n\t\tbadge,\n\t\tclassName,\n\t\tdisabled = buttonDefaults.disabled,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\ticonPos = buttonDefaults.iconPos,\n\t\tkind = buttonDefaults.kind,\n\t\tloading = false,\n\t\tloadingText = spinnerDefaults.text,\n\t\tonClick,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\ttooltip,\n\t\t...remainingProps\n\t}: MrlButtonProps,\n\tref\n) {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\t/**\n\t * MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && allowedButtonValues.toggleStyles.includes(toggleStyle);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\t/**\n\t * Handle onClick events\n\t *\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || disabled || disableEvents) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t}\n\n\tconst classNames = classnames(\n\t\t'mrlButton',\n\t\t`mrlButton--${size}`,\n\t\t`mrlButton--${kind}`,\n\t\tstate === 'skeleton' && `mrlButton--skeleton`,\n\t\t!icon && loading && `mrlButton--loading`,\n\t\tisToggleButton && `toggleStyle--${toggleStyle}`,\n\t\ticon && `mrlButton--icon-${iconPos}`,\n\t\tclassName,\n\t\tattrs?.class || attrs?.className\n\t);\n\n\tif (attrs && attrs.class) delete attrs.class;\n\tif (attrs && attrs.className) delete attrs.className;\n\n\tconst spinnerProps = _spinnerProps(kind, size);\n\tconst spinner = (\n\t\t<MrlSpinner kind={spinnerProps.kind} role=\"none\" size={spinnerProps.size} text={loadingText} />\n\t);\n\n\tconst attributes = setAttributes(attrs || {}, {\n\t\t'aria-disabled': _isDisabled(state, loading) || disabled,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\trole: 'button',\n\t\ttype: 'button'\n\t});\n\n\tconst renderButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\t{...remainingProps}\n\t\t\tclassName={classNames}\n\t\t\tref={ref}\n\t\t\tonClick={handleOnClick}\n\t\t>\n\t\t\t{loading ? spinner : icon}\n\t\t\t<span className=\"mrlButton-text\">{text}</span>\n\t\t\t{badge}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderButton()\n\t) : (\n\t\t<MrlTooltip\n\t\t\tposition={tooltip.position || 'bottom'}\n\t\t\tanchor={tooltip.anchor || 'center'}\n\t\t\ttext={tooltip.text}\n\t\t\tdataQa={tooltip.dataQa}\n\t\t>\n\t\t\t{renderButton()}\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlButton","React","forwardRef","_ref","ref","attrs","badge","className","_ref$disabled","disabled","buttonDefaults","_ref$disableEvents","disableEvents","icon","_ref$iconPos","iconPos","_ref$kind","kind","_ref$loading","loading","_ref$loadingText","loadingText","spinnerDefaults","text","onClick","_ref$toggleAria","toggleAria","toggleStyle","_ref$size","size","_ref$state","state","tooltip","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","isToggleButton","allowedButtonValues","toggleStyles","includes","useEffect","handleOnClick","e","stopPropagation","_isDisabled","prevIsSelected","classNames","classnames","concat","class","spinnerProps","_spinnerProps","spinner","createElement","MrlSpinner","role","attributes","setAttributes","_objectSpread","type","renderButton","_extends","MrlTooltip","position","anchor","dataQa"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8HO,IAAMA,SAAS,gBAAGC,gBAAK,CAACC,UAAU,CAAoC,SAASF,SAASA,CAAAG,IAAA,EAqB9FC,GAAG,EACF;AAAA,EAAA,IApBAC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IAAAC,aAAA,GAAAL,IAAA,CACTM,QAAQ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AAAA,IAAI,EAAE,QAAQ;AACdI,IAAAA,IAAI,EAAE;AAAQ,GAAA,CACd,CAAC;AAEF,EAAA,IAAMC,YAAY,GAAGA,mBACpBlE,gBAAA,CAAA2D,aAAA,CAAA,QAAA,EAAAQ,iCAAA,CAAA,EAAA,EACKL,UAAU,EACV9B,cAAc,EAAA;AAClB1B,IAAAA,SAAS,EAAE8C,UAAW;AACtBjD,IAAAA,GAAG,EAAEA,GAAI;AACToB,IAAAA,OAAO,EAAEwB;GAAc,CAAA,EAEtB7B,OAAO,GAAGwC,OAAO,GAAG9C,IAAI,eACzBZ,gBAAA,CAAA2D,aAAA,CAAA,MAAA,EAAA;AAAMrD,IAAAA,SAAS,EAAC;AAAgB,GAAA,EAAEgB,IAAW,CAAC,EAC7CjB,KACM,CACR;EAED,OAAO,CAAC0B,OAAO,GACdmC,YAAY,EAAE,gBAEdlE,gBAAA,CAAA2D,aAAA,CAACS,qBAAU,EAAA;AACVC,IAAAA,QAAQ,EAAEtC,OAAO,CAACsC,QAAQ,IAAI,QAAS;AACvCC,IAAAA,MAAM,EAAEvC,OAAO,CAACuC,MAAM,IAAI,QAAS;IACnChD,IAAI,EAAES,OAAO,CAACT,IAAK;IACnBiD,MAAM,EAAExC,OAAO,CAACwC;GAAO,EAEtBL,YAAY,EACF,CACZ;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"MrlButton.js","sources":["../../../../../src/components/button/MrlButton/MrlButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tallowedButtonValues,\n\tbuttonDefaults,\n\tMrlButtonKind,\n\tMrlButtonSize,\n\tToggleAria,\n\tIconPosition\n} from '../constants';\nimport { _isDisabled, _isSelected, _spinnerProps } from '../helpers';\nimport { MrlSpinner, MrlTooltipAnchor, MrlTooltipPosition, MrlTooltip } from '../../';\nimport { spinnerDefaults } from '../../loader/constants';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport './MrlButton.global.scss';\n\nexport type MrlButtonState = (typeof allowedButtonValues.states)[number];\nexport type ToggleStyle = (typeof allowedButtonValues.toggleStyles)[number];\n\nexport interface TooltipConfig {\n\t/**\n\t * The text to display in the tooltip\n\t */\n\ttext: string;\n\t/**\n\t * The position of the tooltip relative to the button\n\t */\n\tposition?: MrlTooltipPosition;\n\n\t/**\n\t * The anchor of the tooltip relative to the button\n\t */\n\tanchor?: MrlTooltipAnchor;\n\n\t/**\n\t * The data-qa attribute for the tooltip\n\t */\n\tdataQa?: string;\n}\n\nexport interface MrlButtonProps\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tReact.ComponentProps<'button'> {\n\t/**\n\t * Applies additional HTML attributes to the button element.\n\t *\n\t * @deprecated\n\t */\n\tattrs?: AttrsObject;\n\t/**\n\t * Allow developers to add badge to buttons.\n\t */\n\tbadge?: React.ReactElement;\n\n\t/**\n\t * @deprecated - Use state=\"disabled\" or \"selected-disabled\" or \"skeleton\" instead.\n\t * Allow developers to change the disabled state based on user interactions.\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * Allows developers the ability to disable built in event listeners so they can manage user\n\t * interactions from the application.\n\t */\n\tdisableEvents?: boolean;\n\t/**\n\t * Allow developers to add icon to buttons.\n\t */\n\ticon?: React.ReactElement;\n\t/**\n\t * Allows developers to right-align an icon within a button.\n\t */\n\ticonPos?: IconPosition;\n\t/**\n\t * Changes the visual emphasis of the button.\n\t */\n\tkind?: MrlButtonKind;\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\t/**\n\t * Changes the size of the button so it can scale with its surrounding context.\n\t */\n\tsize?: MrlButtonSize;\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\t/**\n\t * The textual label describing the button's purpose/action.\n\t * Icon buttons require a text label to ensure accessibility.\n\t */\n\ttext: string;\n\t/**\n\t * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'board-share-cta'). When omitted, the button emits no analytics.\n\t */\n\ttrackingId?: string;\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\n\t/**\n\t * Tooltip configuration for the button\n\t */\n\ttooltip?: TooltipConfig;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. The visual styles\n\t * are also impacted by the \"kind\" prop. Toggle buttons are only supported\n\t * when \"kind\" is set to either \"ghost\" or \"ghost-inverse\". Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\ttoggleStyle?: ToggleStyle;\n}\n\nexport const MrlButton = React.forwardRef<HTMLButtonElement, MrlButtonProps>(function MrlButton(\n\t{\n\t\tattrs,\n\t\tbadge,\n\t\tclassName,\n\t\tdisabled = buttonDefaults.disabled,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\ticonPos = buttonDefaults.iconPos,\n\t\tkind = buttonDefaults.kind,\n\t\tloading = false,\n\t\tloadingText = spinnerDefaults.text,\n\t\tonClick,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\ttrackingId,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\ttooltip,\n\t\t...remainingProps\n\t}: MrlButtonProps,\n\tref\n) {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlButton', trackingId);\n\n\t/**\n\t * MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && allowedButtonValues.toggleStyles.includes(toggleStyle);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\t/**\n\t * Handle onClick events\n\t *\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || disabled || disableEvents) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackInteraction({ action: 'click', variant: kind });\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t}\n\n\tconst classNames = classnames(\n\t\t'mrlButton',\n\t\t`mrlButton--${size}`,\n\t\t`mrlButton--${kind}`,\n\t\tstate === 'skeleton' && `mrlButton--skeleton`,\n\t\t!icon && loading && `mrlButton--loading`,\n\t\tisToggleButton && `toggleStyle--${toggleStyle}`,\n\t\ticon && `mrlButton--icon-${iconPos}`,\n\t\tclassName,\n\t\tattrs?.class || attrs?.className\n\t);\n\n\tif (attrs && attrs.class) delete attrs.class;\n\tif (attrs && attrs.className) delete attrs.className;\n\n\tconst spinnerProps = _spinnerProps(kind, size);\n\tconst spinner = (\n\t\t<MrlSpinner kind={spinnerProps.kind} role=\"none\" size={spinnerProps.size} text={loadingText} />\n\t);\n\n\tconst attributes = setAttributes(attrs || {}, {\n\t\t'aria-disabled': _isDisabled(state, loading) || disabled,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\trole: 'button',\n\t\ttype: 'button'\n\t});\n\n\tconst renderButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\t{...remainingProps}\n\t\t\tclassName={classNames}\n\t\t\tref={ref}\n\t\t\tonClick={handleOnClick}\n\t\t>\n\t\t\t{loading ? spinner : icon}\n\t\t\t<span className=\"mrlButton-text\">{text}</span>\n\t\t\t{badge}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderButton()\n\t) : (\n\t\t<MrlTooltip\n\t\t\tposition={tooltip.position || 'bottom'}\n\t\t\tanchor={tooltip.anchor || 'center'}\n\t\t\ttext={tooltip.text}\n\t\t\tdataQa={tooltip.dataQa}\n\t\t>\n\t\t\t{renderButton()}\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlButton","React","forwardRef","_ref","ref","attrs","badge","className","_ref$disabled","disabled","buttonDefaults","_ref$disableEvents","disableEvents","icon","_ref$iconPos","iconPos","_ref$kind","kind","_ref$loading","loading","_ref$loadingText","loadingText","spinnerDefaults","text","onClick","_ref$toggleAria","toggleAria","toggleStyle","trackingId","_ref$size","size","_ref$state","state","tooltip","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","isToggleButton","allowedButtonValues","toggleStyles","includes","useEffect","handleOnClick","e","stopPropagation","_isDisabled","action","variant","prevIsSelected","classNames","classnames","concat","class","spinnerProps","_spinnerProps","spinner","createElement","MrlSpinner","role","attributes","setAttributes","_objectSpread","type","renderButton","_extends","MrlTooltip","position","anchor","dataQa"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoIO,IAAMA,SAAS,gBAAGC,gBAAK,CAACC,UAAU,CAAoC,SAASF,SAASA,CAAAG,IAAA,EAsB9FC,GAAG,EACF;AAAA,EAAA,IArBAC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAC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 var index = require('../../utils/noop/index.js');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
25
+
26
+ /** Default is a no-op: components emit nothing until a consumer provides `track`. */
27
+ var initialContext = {
28
+ track: index.noop
29
+ };
30
+ var MrlAnalyticsContext = /*#__PURE__*/React.createContext(initialContext);
31
+ /**
32
+ * Injects the app's analytics transport into the toolkit. Wrap the app once;
33
+ * every instrumented Mrl* component below emits through the provided `track`.
34
+ *
35
+ * @param props - the provider props
36
+ * @param props.track - the transport that receives each MrlAnalyticsEvent (default no-op)
37
+ * @param props.children - the subtree that can emit analytics
38
+ * @returns the provider wrapping `children`
39
+ */
40
+ var MrlAnalyticsProvider = _ref => {
41
+ var track = _ref.track,
42
+ children = _ref.children;
43
+ // Stable identity so consumers don't re-render every child on each parent render.
44
+ var value = React__namespace.useMemo(() => ({
45
+ track: track !== null && track !== void 0 ? track : index.noop
46
+ }), [track]);
47
+ return /*#__PURE__*/React__namespace.createElement(MrlAnalyticsContext.Provider, {
48
+ value: value
49
+ }, children);
50
+ };
51
+
52
+ exports.MrlAnalyticsContext = MrlAnalyticsContext;
53
+ exports.MrlAnalyticsProvider = MrlAnalyticsProvider;
54
+ //# sourceMappingURL=MrlAnalyticsContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MrlAnalyticsContext.js","sources":["../../../../src/contexts/MrlAnalyticsContext/MrlAnalyticsContext.tsx"],"sourcesContent":["import * as React from 'react';\nimport { createContext } from 'react';\nimport { noop } from '../../utils';\nimport { MrlTrack } from './types';\n\nexport interface MrlAnalyticsContextProps {\n\ttrack: MrlTrack;\n}\n\n/** Default is a no-op: components emit nothing until a consumer provides `track`. */\nconst initialContext: MrlAnalyticsContextProps = {\n\ttrack: noop\n};\n\nexport const MrlAnalyticsContext = createContext<MrlAnalyticsContextProps>(initialContext);\n\nexport interface MrlAnalyticsProviderProps {\n\t/**\n\t * The transport the app injects. Receives a MrlAnalyticsEvent and forwards it\n\t * wherever the app tracks (in murally: a wrapper over trackWithSegment).\n\t * Omit it and the toolkit stays silent — safe for consumers with no analytics.\n\t */\n\ttrack?: MrlTrack;\n\tchildren: React.ReactNode;\n}\n\n/**\n * Injects the app's analytics transport into the toolkit. Wrap the app once;\n * every instrumented Mrl* component below emits through the provided `track`.\n *\n * @param props - the provider props\n * @param props.track - the transport that receives each MrlAnalyticsEvent (default no-op)\n * @param props.children - the subtree that can emit analytics\n * @returns the provider wrapping `children`\n */\nexport const MrlAnalyticsProvider = ({ track, children }: MrlAnalyticsProviderProps) => {\n\t// Stable identity so consumers don't re-render every child on each parent render.\n\tconst value = React.useMemo<MrlAnalyticsContextProps>(() => ({ track: track ?? noop }), [track]);\n\n\treturn <MrlAnalyticsContext.Provider value={value}>{children}</MrlAnalyticsContext.Provider>;\n};\n"],"names":["initialContext","track","noop","MrlAnalyticsContext","createContext","MrlAnalyticsProvider","_ref","children","value","React","useMemo","createElement","Provider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AASA;AACA,IAAMA,cAAwC,GAAG;AAChDC,EAAAA,KAAK,EAAEC;AACR,CAAC;IAEYC,mBAAmB,gBAAGC,mBAAa,CAA2BJ,cAAc;AAYzF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMK,oBAAoB,GAAGC,IAAA,IAAoD;AAAA,EAAA,IAAjDL,KAAK,GAAAK,IAAA,CAALL,KAAK;IAAEM,QAAQ,GAAAD,IAAA,CAARC,QAAQ;AACrD;AACA,EAAA,IAAMC,KAAK,GAAGC,gBAAK,CAACC,OAAO,CAA2B,OAAO;AAAET,IAAAA,KAAK,EAAEA,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,GAALA,KAAK,GAAIC;AAAK,GAAC,CAAC,EAAE,CAACD,KAAK,CAAC,CAAC;AAEhG,EAAA,oBAAOQ,gBAAA,CAAAE,aAAA,CAACR,mBAAmB,CAACS,QAAQ,EAAA;AAACJ,IAAAA,KAAK,EAAEA;AAAM,GAAA,EAAED,QAAuC,CAAC;AAC7F;;;;;"}
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var version = require('../../version.js');
5
+ var MrlAnalyticsContext = require('../../contexts/MrlAnalyticsContext/MrlAnalyticsContext.js');
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
26
+
27
+ /**
28
+ * Raw accessor for the analytics context.
29
+ *
30
+ * @returns the injected `track` transport (default no-op)
31
+ */
32
+ var useMrlAnalytics = () => React__namespace.useContext(MrlAnalyticsContext.MrlAnalyticsContext);
33
+ /**
34
+ * Component-facing helper. Binds component identity + trackingId once, then
35
+ * `emit({ action })` per interaction. No-ops entirely when trackingId is absent,
36
+ * so instrumentation is opt-in and attributable.
37
+ *
38
+ * @param component - the emitting component's name, e.g. 'MrlButton'
39
+ * @param trackingId - consumer-supplied, non-PII id; undefined disables emission
40
+ * @returns an `emit` callback that fires a single interaction per call
41
+ */
42
+ var useMrlTrackInteraction = (component, trackingId) => {
43
+ var _useMrlAnalytics = useMrlAnalytics(),
44
+ track = _useMrlAnalytics.track;
45
+ return React__namespace.useCallback(_ref => {
46
+ var action = _ref.action,
47
+ variant = _ref.variant,
48
+ metadata = _ref.metadata;
49
+ // opt-in: no id → no event (volume + PII guard)
50
+ if (!trackingId) return;
51
+ try {
52
+ track({
53
+ action,
54
+ component,
55
+ metadata,
56
+ toolkitVersion: version.TOOLKIT_VERSION,
57
+ trackingId,
58
+ variant
59
+ });
60
+ } catch (e) {
61
+ // Ensure errors don't break the app
62
+ return e;
63
+ }
64
+ }, [track, component, trackingId]);
65
+ };
66
+
67
+ exports.useMrlAnalytics = useMrlAnalytics;
68
+ exports.useMrlTrackInteraction = useMrlTrackInteraction;
69
+ //# sourceMappingURL=useMrlAnalytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMrlAnalytics.js","sources":["../../../../src/hooks/useMrlAnalytics/useMrlAnalytics.ts"],"sourcesContent":["import * as React from 'react';\nimport { MrlAnalyticsContext } from '../../contexts/MrlAnalyticsContext';\nimport { MrlAnalyticsEvent, MrlTrack } from '../../contexts/MrlAnalyticsContext/types';\nimport { TOOLKIT_VERSION } from '../../version';\n\n/**\n * Raw accessor for the analytics context.\n *\n * @returns the injected `track` transport (default no-op)\n */\nexport const useMrlAnalytics = (): { track: MrlTrack } => React.useContext(MrlAnalyticsContext);\n\ntype EmitArgs = Pick<MrlAnalyticsEvent, 'action' | 'variant' | 'metadata'>;\n\n/**\n * Component-facing helper. Binds component identity + trackingId once, then\n * `emit({ action })` per interaction. No-ops entirely when trackingId is absent,\n * so instrumentation is opt-in and attributable.\n *\n * @param component - the emitting component's name, e.g. 'MrlButton'\n * @param trackingId - consumer-supplied, non-PII id; undefined disables emission\n * @returns an `emit` callback that fires a single interaction per call\n */\nexport const useMrlTrackInteraction = (component: string, trackingId?: string) => {\n\tconst { track } = useMrlAnalytics();\n\n\treturn React.useCallback(\n\t\t({ action, variant, metadata }: EmitArgs) => {\n\t\t\t// opt-in: no id → no event (volume + PII guard)\n\t\t\tif (!trackingId) return;\n\t\t\ttry {\n\t\t\t\ttrack({\n\t\t\t\t\taction,\n\t\t\t\t\tcomponent,\n\t\t\t\t\tmetadata,\n\t\t\t\t\ttoolkitVersion: TOOLKIT_VERSION,\n\t\t\t\t\ttrackingId,\n\t\t\t\t\tvariant\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\t// Ensure errors don't break the app\n\t\t\t\treturn e;\n\t\t\t}\n\t\t},\n\t\t[track, component, trackingId]\n\t);\n};\n"],"names":["useMrlAnalytics","React","useContext","MrlAnalyticsContext","useMrlTrackInteraction","component","trackingId","_useMrlAnalytics","track","useCallback","_ref","action","variant","metadata","toolkitVersion","TOOLKIT_VERSION","e"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;AACA;AACA;AACA;AACA;AACO,IAAMA,eAAe,GAAGA,MAA2BC,gBAAK,CAACC,UAAU,CAACC,uCAAmB;AAI9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACaC,sBAAsB,GAAGA,CAACC,SAAiB,EAAEC,UAAmB,KAAK;AACjF,EAAA,IAAAC,gBAAA,GAAkBP,eAAe,EAAE;IAA3BQ,KAAK,GAAAD,gBAAA,CAALC,KAAK;AAEb,EAAA,OAAOP,gBAAK,CAACQ,WAAW,CACvBC,IAAA,IAA6C;AAAA,IAAA,IAA1CC,MAAM,GAAAD,IAAA,CAANC,MAAM;MAAEC,OAAO,GAAAF,IAAA,CAAPE,OAAO;MAAEC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;AAC3B;IACA,IAAI,CAACP,UAAU,EAAE;IACjB,IAAI;AACHE,MAAAA,KAAK,CAAC;QACLG,MAAM;QACNN,SAAS;QACTQ,QAAQ;AACRC,QAAAA,cAAc,EAAEC,uBAAe;QAC/BT,UAAU;AACVM,QAAAA;AACD,OAAC,CAAC;IACH,CAAC,CAAC,OAAOI,CAAC,EAAE;AACX;AACA,MAAA,OAAOA,CAAC;AACT,IAAA;EACD,CAAC,EACD,CAACR,KAAK,EAAEH,SAAS,EAAEC,UAAU,CAC9B,CAAC;AACF;;;;;"}
package/dist/cjs/index.js CHANGED
@@ -7,6 +7,7 @@ var MrlPortal = require('./components/portal/MrlPortal.js');
7
7
  var actions = require('./components/button/MrlProcessingButton/actions.js');
8
8
  var MrlMultiCreatableSelect = require('./components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.js');
9
9
  var MrlMultiSelect = require('./components/form/select/MrlMultiSelect/MrlMultiSelect.js');
10
+ var MrlAnalyticsContext = require('./contexts/MrlAnalyticsContext/MrlAnalyticsContext.js');
10
11
  var MrlAnimatedIconButton = require('./components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js');
11
12
  var MrlAvatar = require('./components/avatar/MrlAvatar/MrlAvatar.js');
12
13
  var MrlAvatarButton = require('./components/avatar/MrlAvatarButton/MrlAvatarButton.js');
@@ -143,6 +144,7 @@ var index$8 = require('./hooks/useBreakpoint/index.js');
143
144
  var index$9 = require('./hooks/useCoordinate/index.js');
144
145
  var index$a = require('./hooks/useElementDimensions/index.js');
145
146
  var index$b = require('./hooks/useHasFocusableDescendant/index.js');
147
+ var useMrlAnalytics = require('./hooks/useMrlAnalytics/useMrlAnalytics.js');
146
148
  var index$c = require('./hooks/useScrollbarInfo/index.js');
147
149
 
148
150
 
@@ -167,6 +169,8 @@ exports.MrlMultiCreatableSelect = MrlMultiCreatableSelect.MrlMultiCreatableSelec
167
169
  exports.MULTI_SELECT_CLASS_NAME_PREFIX = MrlMultiSelect.MULTI_SELECT_CLASS_NAME_PREFIX;
168
170
  exports.MULTI_SELECT_MENU_LIST_CLASS_NAME = MrlMultiSelect.MULTI_SELECT_MENU_LIST_CLASS_NAME;
169
171
  exports.MrlMultiSelect = MrlMultiSelect.MrlMultiSelect;
172
+ exports.MrlAnalyticsContext = MrlAnalyticsContext.MrlAnalyticsContext;
173
+ exports.MrlAnalyticsProvider = MrlAnalyticsContext.MrlAnalyticsProvider;
170
174
  exports.MrlAnimatedIconButton = MrlAnimatedIconButton.MrlAnimatedIconButton;
171
175
  exports.MrlAvatar = MrlAvatar.MrlAvatar;
172
176
  exports.defaultAvatarValues = MrlAvatar.defaultAvatarValues;
@@ -331,5 +335,7 @@ exports.useBreakpoint = index$8.useBreakpoint;
331
335
  exports.useCoordinate = index$9.useCoordinate;
332
336
  exports.useElementDimensions = index$a.useElementDimensions;
333
337
  exports.useHasFocusableDescendant = index$b.useHasFocusableDescendant;
338
+ exports.useMrlAnalytics = useMrlAnalytics.useMrlAnalytics;
339
+ exports.useMrlTrackInteraction = useMrlAnalytics.useMrlTrackInteraction;
334
340
  exports.useScrollbarInfo = index$c.useScrollbarInfo;
335
341
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ var TOOLKIT_VERSION = "4.71.0-dev-nBIF.1";
4
+
5
+ exports.TOOLKIT_VERSION = TOOLKIT_VERSION;
6
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.71.0-dev-nBIF.1\";"],"names":["TOOLKIT_VERSION"],"mappings":";;AAAO,IAAMA,eAAe,GAAG;;;;"}
@@ -81,6 +81,11 @@ export interface MrlButtonProps extends Omit<MrlComponentProps, 'style'>, React.
81
81
  * Icon buttons require a text label to ensure accessibility.
82
82
  */
83
83
  text: string;
84
+ /**
85
+ * Enables interaction tracking for this button. Provide a stable, non-PII id
86
+ * (e.g. 'board-share-cta'). When omitted, the button emits no analytics.
87
+ */
88
+ trackingId?: string;
84
89
  /**
85
90
  * Determines which aria setup to use for various toggle/selected styles.
86
91
  * pressed - use for an traditional “toggle button”
@@ -80,7 +80,7 @@ export declare const colorPictoStoryData: {
80
80
  export declare const animateStoryData: {
81
81
  args: {
82
82
  delay: number;
83
- state: "stop" | "play";
83
+ state: "play" | "stop";
84
84
  };
85
85
  argTypes: {
86
86
  delay: {
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { MrlTrack } from './types';
3
+ export interface MrlAnalyticsContextProps {
4
+ track: MrlTrack;
5
+ }
6
+ export declare const MrlAnalyticsContext: React.Context<MrlAnalyticsContextProps>;
7
+ export interface MrlAnalyticsProviderProps {
8
+ /**
9
+ * The transport the app injects. Receives a MrlAnalyticsEvent and forwards it
10
+ * wherever the app tracks (in murally: a wrapper over trackWithSegment).
11
+ * Omit it and the toolkit stays silent — safe for consumers with no analytics.
12
+ */
13
+ track?: MrlTrack;
14
+ children: React.ReactNode;
15
+ }
16
+ /**
17
+ * Injects the app's analytics transport into the toolkit. Wrap the app once;
18
+ * every instrumented Mrl* component below emits through the provided `track`.
19
+ *
20
+ * @param props - the provider props
21
+ * @param props.track - the transport that receives each MrlAnalyticsEvent (default no-op)
22
+ * @param props.children - the subtree that can emit analytics
23
+ * @returns the provider wrapping `children`
24
+ */
25
+ export declare const MrlAnalyticsProvider: ({ track, children }: MrlAnalyticsProviderProps) => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './MrlAnalyticsContext';
2
+ export * from './types';
@@ -0,0 +1,22 @@
1
+ /** Values allowed in analytics payloads. No free-text/PII — see MrlAnalyticsProvider docs. */
2
+ export type MrlAnalyticsValue = string | number | boolean;
3
+ /** The canonical interaction a Mrl* component emits. Transport-agnostic. */
4
+ export interface MrlAnalyticsEvent {
5
+ /** Component identity, e.g. 'MrlButton', 'MrlMenu', 'MrlModal'. Set by the component. */
6
+ component: string;
7
+ /** Interaction type, e.g. 'click' | 'open' | 'close' | 'select' | 'change'. Set by the component. */
8
+ action: string;
9
+ /** ui-toolkit version for internal tracking */
10
+ toolkitVersion: string;
11
+ /**
12
+ * Consumer-supplied attribution id. REQUIRED for an event to fire (opt-in).
13
+ * Must be a stable, non-PII identifier (e.g. 'board-share', not the user's name).
14
+ */
15
+ trackingId: string;
16
+ /** Non-PII component variant, e.g. button kind/size. Set by the component. */
17
+ variant?: string;
18
+ /** Curated, non-PII extra context. Never button labels, input values, etc. */
19
+ metadata?: Record<string, MrlAnalyticsValue>;
20
+ }
21
+ /** The one function the toolkit calls. The app decides what it does. */
22
+ export type MrlTrack = (event: MrlAnalyticsEvent) => void;
@@ -1 +1,2 @@
1
+ export * from './MrlAnalyticsContext';
1
2
  export * from './MrlTabContext';
@@ -4,11 +4,12 @@ import classnames from 'classnames';
4
4
  import { buttonDefaults, allowedButtonValues } from '../constants.js';
5
5
  import { _isSelected, _isDisabled, _spinnerProps } from '../helpers.js';
6
6
  import { spinnerDefaults } from '../../loader/constants.js';
7
+ import { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics/useMrlAnalytics.js';
7
8
  import { setAttributes } from '../../../utils/setAttributes/setAttributes.js';
8
9
  import { MrlTooltip } from '../../tooltip/MrlTooltip/MrlTooltip.js';
9
10
  import { MrlSpinner } from '../../loader/MrlSpinner/MrlSpinner.js';
10
11
 
11
- var _excluded = ["attrs", "badge", "className", "disabled", "disableEvents", "icon", "iconPos", "kind", "loading", "loadingText", "onClick", "toggleAria", "toggleStyle", "text", "size", "state", "tooltip"];
12
+ var _excluded = ["attrs", "badge", "className", "disabled", "disableEvents", "icon", "iconPos", "kind", "loading", "loadingText", "onClick", "toggleAria", "toggleStyle", "text", "trackingId", "size", "state", "tooltip"];
12
13
  var MrlButton = /*#__PURE__*/React.forwardRef(function MrlButton(_ref, ref) {
13
14
  var attrs = _ref.attrs,
14
15
  badge = _ref.badge,
@@ -31,6 +32,7 @@ var MrlButton = /*#__PURE__*/React.forwardRef(function MrlButton(_ref, ref) {
31
32
  toggleAria = _ref$toggleAria === void 0 ? buttonDefaults.toggleAria : _ref$toggleAria,
32
33
  toggleStyle = _ref.toggleStyle,
33
34
  text = _ref.text,
35
+ trackingId = _ref.trackingId,
34
36
  _ref$size = _ref.size,
35
37
  size = _ref$size === void 0 ? buttonDefaults.size : _ref$size,
36
38
  _ref$state = _ref.state,
@@ -41,6 +43,7 @@ var MrlButton = /*#__PURE__*/React.forwardRef(function MrlButton(_ref, ref) {
41
43
  _React$useState2 = _slicedToArray(_React$useState, 2),
42
44
  isSelected = _React$useState2[0],
43
45
  setIsSelected = _React$useState2[1];
46
+ var trackInteraction = useMrlTrackInteraction('MrlButton', trackingId);
44
47
 
45
48
  /**
46
49
  * MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'
@@ -67,6 +70,10 @@ var MrlButton = /*#__PURE__*/React.forwardRef(function MrlButton(_ref, ref) {
67
70
  if (_isDisabled(state, loading) || disabled || disableEvents) {
68
71
  return;
69
72
  }
73
+ trackInteraction({
74
+ action: 'click',
75
+ variant: kind
76
+ });
70
77
  if (isToggleButton) {
71
78
  setIsSelected(prevIsSelected => !prevIsSelected);
72
79
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MrlButton.js","sources":["../../../../../src/components/button/MrlButton/MrlButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tallowedButtonValues,\n\tbuttonDefaults,\n\tMrlButtonKind,\n\tMrlButtonSize,\n\tToggleAria,\n\tIconPosition\n} from '../constants';\nimport { _isDisabled, _isSelected, _spinnerProps } from '../helpers';\nimport { MrlSpinner, MrlTooltipAnchor, MrlTooltipPosition, MrlTooltip } from '../../';\nimport { spinnerDefaults } from '../../loader/constants';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\n\nimport './MrlButton.global.scss';\n\nexport type MrlButtonState = (typeof allowedButtonValues.states)[number];\nexport type ToggleStyle = (typeof allowedButtonValues.toggleStyles)[number];\n\nexport interface TooltipConfig {\n\t/**\n\t * The text to display in the tooltip\n\t */\n\ttext: string;\n\t/**\n\t * The position of the tooltip relative to the button\n\t */\n\tposition?: MrlTooltipPosition;\n\n\t/**\n\t * The anchor of the tooltip relative to the button\n\t */\n\tanchor?: MrlTooltipAnchor;\n\n\t/**\n\t * The data-qa attribute for the tooltip\n\t */\n\tdataQa?: string;\n}\n\nexport interface MrlButtonProps\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tReact.ComponentProps<'button'> {\n\t/**\n\t * Applies additional HTML attributes to the button element.\n\t *\n\t * @deprecated\n\t */\n\tattrs?: AttrsObject;\n\t/**\n\t * Allow developers to add badge to buttons.\n\t */\n\tbadge?: React.ReactElement;\n\n\t/**\n\t * @deprecated - Use state=\"disabled\" or \"selected-disabled\" or \"skeleton\" instead.\n\t * Allow developers to change the disabled state based on user interactions.\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * Allows developers the ability to disable built in event listeners so they can manage user\n\t * interactions from the application.\n\t */\n\tdisableEvents?: boolean;\n\t/**\n\t * Allow developers to add icon to buttons.\n\t */\n\ticon?: React.ReactElement;\n\t/**\n\t * Allows developers to right-align an icon within a button.\n\t */\n\ticonPos?: IconPosition;\n\t/**\n\t * Changes the visual emphasis of the button.\n\t */\n\tkind?: MrlButtonKind;\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\t/**\n\t * Changes the size of the button so it can scale with its surrounding context.\n\t */\n\tsize?: MrlButtonSize;\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\t/**\n\t * The textual label describing the button's purpose/action.\n\t * Icon buttons require a text label to ensure accessibility.\n\t */\n\ttext: string;\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\n\t/**\n\t * Tooltip configuration for the button\n\t */\n\ttooltip?: TooltipConfig;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. The visual styles\n\t * are also impacted by the \"kind\" prop. Toggle buttons are only supported\n\t * when \"kind\" is set to either \"ghost\" or \"ghost-inverse\". Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\ttoggleStyle?: ToggleStyle;\n}\n\nexport const MrlButton = React.forwardRef<HTMLButtonElement, MrlButtonProps>(function MrlButton(\n\t{\n\t\tattrs,\n\t\tbadge,\n\t\tclassName,\n\t\tdisabled = buttonDefaults.disabled,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\ticonPos = buttonDefaults.iconPos,\n\t\tkind = buttonDefaults.kind,\n\t\tloading = false,\n\t\tloadingText = spinnerDefaults.text,\n\t\tonClick,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\ttooltip,\n\t\t...remainingProps\n\t}: MrlButtonProps,\n\tref\n) {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\t/**\n\t * MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && allowedButtonValues.toggleStyles.includes(toggleStyle);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\t/**\n\t * Handle onClick events\n\t *\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || disabled || disableEvents) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t}\n\n\tconst classNames = classnames(\n\t\t'mrlButton',\n\t\t`mrlButton--${size}`,\n\t\t`mrlButton--${kind}`,\n\t\tstate === 'skeleton' && `mrlButton--skeleton`,\n\t\t!icon && loading && `mrlButton--loading`,\n\t\tisToggleButton && `toggleStyle--${toggleStyle}`,\n\t\ticon && `mrlButton--icon-${iconPos}`,\n\t\tclassName,\n\t\tattrs?.class || attrs?.className\n\t);\n\n\tif (attrs && attrs.class) delete attrs.class;\n\tif (attrs && attrs.className) delete attrs.className;\n\n\tconst spinnerProps = _spinnerProps(kind, size);\n\tconst spinner = (\n\t\t<MrlSpinner kind={spinnerProps.kind} role=\"none\" size={spinnerProps.size} text={loadingText} />\n\t);\n\n\tconst attributes = setAttributes(attrs || {}, {\n\t\t'aria-disabled': _isDisabled(state, loading) || disabled,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\trole: 'button',\n\t\ttype: 'button'\n\t});\n\n\tconst renderButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\t{...remainingProps}\n\t\t\tclassName={classNames}\n\t\t\tref={ref}\n\t\t\tonClick={handleOnClick}\n\t\t>\n\t\t\t{loading ? spinner : icon}\n\t\t\t<span className=\"mrlButton-text\">{text}</span>\n\t\t\t{badge}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderButton()\n\t) : (\n\t\t<MrlTooltip\n\t\t\tposition={tooltip.position || 'bottom'}\n\t\t\tanchor={tooltip.anchor || 'center'}\n\t\t\ttext={tooltip.text}\n\t\t\tdataQa={tooltip.dataQa}\n\t\t>\n\t\t\t{renderButton()}\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlButton","React","forwardRef","_ref","ref","attrs","badge","className","_ref$disabled","disabled","buttonDefaults","_ref$disableEvents","disableEvents","icon","_ref$iconPos","iconPos","_ref$kind","kind","_ref$loading","loading","_ref$loadingText","loadingText","spinnerDefaults","text","onClick","_ref$toggleAria","toggleAria","toggleStyle","_ref$size","size","_ref$state","state","tooltip","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","isToggleButton","allowedButtonValues","toggleStyles","includes","useEffect","handleOnClick","e","stopPropagation","_isDisabled","prevIsSelected","classNames","classnames","concat","class","spinnerProps","_spinnerProps","spinner","createElement","MrlSpinner","role","attributes","setAttributes","_objectSpread","type","renderButton","_extends","MrlTooltip","position","anchor","dataQa"],"mappings":";;;;;;;;;;;AA8HO,IAAMA,SAAS,gBAAGC,KAAK,CAACC,UAAU,CAAoC,SAASF,SAASA,CAAAG,IAAA,EAqB9FC,GAAG,EACF;AAAA,EAAA,IApBAC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IAAAC,aAAA,GAAAL,IAAA,CACTM,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGE,cAAc,CAACD,QAAQ,GAAAD,aAAA;IAAAG,kBAAA,GAAAR,IAAA,CAClCS,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,kBAAA;IACrBE,IAAI,GAAAV,IAAA,CAAJU,IAAI;IAAAC,YAAA,GAAAX,IAAA,CACJY,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAGJ,cAAc,CAACK,OAAO,GAAAD,YAAA;IAAAE,SAAA,GAAAb,IAAA,CAChCc,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAGN,cAAc,CAACO,IAAI,GAAAD,SAAA;IAAAE,YAAA,GAAAf,IAAA,CAC1BgB,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,YAAA;IAAAE,gBAAA,GAAAjB,IAAA,CACfkB,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAA,MAAA,GAAGE,eAAe,CAACC,IAAI,GAAAH,gBAAA;IAClCI,OAAO,GAAArB,IAAA,CAAPqB,OAAO;IAAAC,eAAA,GAAAtB,IAAA,CACPuB,UAAU;AAAVA,IAAAA,UAAU,GAAAD,eAAA,KAAA,MAAA,GAAGf,cAAc,CAACgB,UAA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,CAC9F;EAED,IAAM0C,UAAU,GAAGC,aAAa,CAAC3D,KAAK,IAAI,EAAE,EAAA4D,cAAA,CAAAA,cAAA,CAAA;AAC3C,IAAA,eAAe,EAAEd,WAAW,CAACpB,KAAK,EAAEZ,OAAO,CAAC,IAAIV;AAAQ,GAAA,EACpDkC,cAAc,IAAI;AAAE,IAAA,CAAA,OAAA,CAAAY,MAAA,CAAS7B,UAAU,CAAA,GAAKe,UAAU,IAAI;GAAO,CAAA,EAAA,EAAA,EAAA;AACrEqB,IAAAA,IAAI,EAAE,QAAQ;AACdI,IAAAA,IAAI,EAAE;AAAQ,GAAA,CACd,CAAC;AAEF,EAAA,IAAMC,YAAY,GAAGA,mBACpBlE,KAAA,CAAA2D,aAAA,CAAA,QAAA,EAAAQ,QAAA,CAAA,EAAA,EACKL,UAAU,EACV9B,cAAc,EAAA;AAClB1B,IAAAA,SAAS,EAAE8C,UAAW;AACtBjD,IAAAA,GAAG,EAAEA,GAAI;AACToB,IAAAA,OAAO,EAAEwB;GAAc,CAAA,EAEtB7B,OAAO,GAAGwC,OAAO,GAAG9C,IAAI,eACzBZ,KAAA,CAAA2D,aAAA,CAAA,MAAA,EAAA;AAAMrD,IAAAA,SAAS,EAAC;AAAgB,GAAA,EAAEgB,IAAW,CAAC,EAC7CjB,KACM,CACR;EAED,OAAO,CAAC0B,OAAO,GACdmC,YAAY,EAAE,gBAEdlE,KAAA,CAAA2D,aAAA,CAACS,UAAU,EAAA;AACVC,IAAAA,QAAQ,EAAEtC,OAAO,CAACsC,QAAQ,IAAI,QAAS;AACvCC,IAAAA,MAAM,EAAEvC,OAAO,CAACuC,MAAM,IAAI,QAAS;IACnChD,IAAI,EAAES,OAAO,CAACT,IAAK;IACnBiD,MAAM,EAAExC,OAAO,CAACwC;GAAO,EAEtBL,YAAY,EACF,CACZ;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"MrlButton.js","sources":["../../../../../src/components/button/MrlButton/MrlButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tallowedButtonValues,\n\tbuttonDefaults,\n\tMrlButtonKind,\n\tMrlButtonSize,\n\tToggleAria,\n\tIconPosition\n} from '../constants';\nimport { _isDisabled, _isSelected, _spinnerProps } from '../helpers';\nimport { MrlSpinner, MrlTooltipAnchor, MrlTooltipPosition, MrlTooltip } from '../../';\nimport { spinnerDefaults } from '../../loader/constants';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport './MrlButton.global.scss';\n\nexport type MrlButtonState = (typeof allowedButtonValues.states)[number];\nexport type ToggleStyle = (typeof allowedButtonValues.toggleStyles)[number];\n\nexport interface TooltipConfig {\n\t/**\n\t * The text to display in the tooltip\n\t */\n\ttext: string;\n\t/**\n\t * The position of the tooltip relative to the button\n\t */\n\tposition?: MrlTooltipPosition;\n\n\t/**\n\t * The anchor of the tooltip relative to the button\n\t */\n\tanchor?: MrlTooltipAnchor;\n\n\t/**\n\t * The data-qa attribute for the tooltip\n\t */\n\tdataQa?: string;\n}\n\nexport interface MrlButtonProps\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tReact.ComponentProps<'button'> {\n\t/**\n\t * Applies additional HTML attributes to the button element.\n\t *\n\t * @deprecated\n\t */\n\tattrs?: AttrsObject;\n\t/**\n\t * Allow developers to add badge to buttons.\n\t */\n\tbadge?: React.ReactElement;\n\n\t/**\n\t * @deprecated - Use state=\"disabled\" or \"selected-disabled\" or \"skeleton\" instead.\n\t * Allow developers to change the disabled state based on user interactions.\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * Allows developers the ability to disable built in event listeners so they can manage user\n\t * interactions from the application.\n\t */\n\tdisableEvents?: boolean;\n\t/**\n\t * Allow developers to add icon to buttons.\n\t */\n\ticon?: React.ReactElement;\n\t/**\n\t * Allows developers to right-align an icon within a button.\n\t */\n\ticonPos?: IconPosition;\n\t/**\n\t * Changes the visual emphasis of the button.\n\t */\n\tkind?: MrlButtonKind;\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\t/**\n\t * Changes the size of the button so it can scale with its surrounding context.\n\t */\n\tsize?: MrlButtonSize;\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\t/**\n\t * The textual label describing the button's purpose/action.\n\t * Icon buttons require a text label to ensure accessibility.\n\t */\n\ttext: string;\n\t/**\n\t * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'board-share-cta'). When omitted, the button emits no analytics.\n\t */\n\ttrackingId?: string;\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\n\t/**\n\t * Tooltip configuration for the button\n\t */\n\ttooltip?: TooltipConfig;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. The visual styles\n\t * are also impacted by the \"kind\" prop. Toggle buttons are only supported\n\t * when \"kind\" is set to either \"ghost\" or \"ghost-inverse\". Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\ttoggleStyle?: ToggleStyle;\n}\n\nexport const MrlButton = React.forwardRef<HTMLButtonElement, MrlButtonProps>(function MrlButton(\n\t{\n\t\tattrs,\n\t\tbadge,\n\t\tclassName,\n\t\tdisabled = buttonDefaults.disabled,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\ticonPos = buttonDefaults.iconPos,\n\t\tkind = buttonDefaults.kind,\n\t\tloading = false,\n\t\tloadingText = spinnerDefaults.text,\n\t\tonClick,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\ttrackingId,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\ttooltip,\n\t\t...remainingProps\n\t}: MrlButtonProps,\n\tref\n) {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlButton', trackingId);\n\n\t/**\n\t * MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && allowedButtonValues.toggleStyles.includes(toggleStyle);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\t/**\n\t * Handle onClick events\n\t *\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || disabled || disableEvents) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackInteraction({ action: 'click', variant: kind });\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t}\n\n\tconst classNames = classnames(\n\t\t'mrlButton',\n\t\t`mrlButton--${size}`,\n\t\t`mrlButton--${kind}`,\n\t\tstate === 'skeleton' && `mrlButton--skeleton`,\n\t\t!icon && loading && `mrlButton--loading`,\n\t\tisToggleButton && `toggleStyle--${toggleStyle}`,\n\t\ticon && `mrlButton--icon-${iconPos}`,\n\t\tclassName,\n\t\tattrs?.class || attrs?.className\n\t);\n\n\tif (attrs && attrs.class) delete attrs.class;\n\tif (attrs && attrs.className) delete attrs.className;\n\n\tconst spinnerProps = _spinnerProps(kind, size);\n\tconst spinner = (\n\t\t<MrlSpinner kind={spinnerProps.kind} role=\"none\" size={spinnerProps.size} text={loadingText} />\n\t);\n\n\tconst attributes = setAttributes(attrs || {}, {\n\t\t'aria-disabled': _isDisabled(state, loading) || disabled,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\trole: 'button',\n\t\ttype: 'button'\n\t});\n\n\tconst renderButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\t{...remainingProps}\n\t\t\tclassName={classNames}\n\t\t\tref={ref}\n\t\t\tonClick={handleOnClick}\n\t\t>\n\t\t\t{loading ? spinner : icon}\n\t\t\t<span className=\"mrlButton-text\">{text}</span>\n\t\t\t{badge}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderButton()\n\t) : (\n\t\t<MrlTooltip\n\t\t\tposition={tooltip.position || 'bottom'}\n\t\t\tanchor={tooltip.anchor || 'center'}\n\t\t\ttext={tooltip.text}\n\t\t\tdataQa={tooltip.dataQa}\n\t\t>\n\t\t\t{renderButton()}\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlButton","React","forwardRef","_ref","ref","attrs","badge","className","_ref$disabled","disabled","buttonDefaults","_ref$disableEvents","disableEvents","icon","_ref$iconPos","iconPos","_ref$kind","kind","_ref$loading","loading","_ref$loadingText","loadingText","spinnerDefaults","text","onClick","_ref$toggleAria","toggleAria","toggleStyle","trackingId","_ref$size","size","_ref$state","state","tooltip","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","isToggleButton","allowedButtonValues","toggleStyles","includes","useEffect","handleOnClick","e","stopPropagation","_isDisabled","action","variant","prevIsSelected","classNames","classnames","concat","class","spinnerProps","_spinnerProps","spinner","createElement","MrlSpinner","role","attributes","setAttributes","_objectSpread","type","renderButton","_extends","MrlTooltip","position","anchor","dataQa"],"mappings":";;;;;;;;;;;;AAoIO,IAAMA,SAAS,gBAAGC,KAAK,CAACC,UAAU,CAAoC,SAASF,SAASA,CAAAG,IAAA,EAsB9FC,GAAG,EACF;AAAA,EAAA,IArBAC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IAAAC,aAAA,GAAAL,IAAA,CACTM,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGE,cAAc,CAACD,QAAQ,GAAAD,aAAA;IAAAG,kBAAA,GAAAR,IAAA,CAClCS,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,kBAAA;IACrBE,IAAI,GAAAV,IAAA,CAAJU,IAAI;IAAAC,YAAA,GAAAX,IAAA,CACJY,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAGJ,cAAc,CAACK,OAAO,GAAAD,YAAA;IAAAE,SAAA,GAAAb,IAAA,CAChCc,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAGN,cAAc,CAACO,IAAI,GAAAD,SAAA;IAAAE,YAAA,GAAAf,IAAA,CAC1BgB,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,YAAA;IAAAE,gBAAA,GAAAjB,IAAA,CACfkB,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAA,MAAA,GAAGE,eAAe,CAACC,IAAI,GAAAH,gBAAA;IAClCI,OAAO,GAAArB,IAAA,CAAPqB,OAAO;IAAAC,eAAA,GAAAtB,IAAA,CACPuB,UAAU;AAAVA,IAAAA,UAAU,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,IAAI,QAAS;AACvCC,IAAAA,MAAM,EAAE3C,OAAO,CAAC2C,MAAM,IAAI,QAAS;IACnCrD,IAAI,EAAEU,OAAO,CAACV,IAAK;IACnBsD,MAAM,EAAE5C,OAAO,CAAC4C;GAAO,EAEtBL,YAAY,EACF,CACZ;AACF,CAAC;;;;"}
@@ -0,0 +1,32 @@
1
+ import * as React from 'react';
2
+ import { createContext } from 'react';
3
+ import { noop } from '../../utils/noop/index.js';
4
+
5
+ /** Default is a no-op: components emit nothing until a consumer provides `track`. */
6
+ var initialContext = {
7
+ track: noop
8
+ };
9
+ var MrlAnalyticsContext = /*#__PURE__*/createContext(initialContext);
10
+ /**
11
+ * Injects the app's analytics transport into the toolkit. Wrap the app once;
12
+ * every instrumented Mrl* component below emits through the provided `track`.
13
+ *
14
+ * @param props - the provider props
15
+ * @param props.track - the transport that receives each MrlAnalyticsEvent (default no-op)
16
+ * @param props.children - the subtree that can emit analytics
17
+ * @returns the provider wrapping `children`
18
+ */
19
+ var MrlAnalyticsProvider = _ref => {
20
+ var track = _ref.track,
21
+ children = _ref.children;
22
+ // Stable identity so consumers don't re-render every child on each parent render.
23
+ var value = React.useMemo(() => ({
24
+ track: track !== null && track !== void 0 ? track : noop
25
+ }), [track]);
26
+ return /*#__PURE__*/React.createElement(MrlAnalyticsContext.Provider, {
27
+ value: value
28
+ }, children);
29
+ };
30
+
31
+ export { MrlAnalyticsContext, MrlAnalyticsProvider };
32
+ //# sourceMappingURL=MrlAnalyticsContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MrlAnalyticsContext.js","sources":["../../../../src/contexts/MrlAnalyticsContext/MrlAnalyticsContext.tsx"],"sourcesContent":["import * as React from 'react';\nimport { createContext } from 'react';\nimport { noop } from '../../utils';\nimport { MrlTrack } from './types';\n\nexport interface MrlAnalyticsContextProps {\n\ttrack: MrlTrack;\n}\n\n/** Default is a no-op: components emit nothing until a consumer provides `track`. */\nconst initialContext: MrlAnalyticsContextProps = {\n\ttrack: noop\n};\n\nexport const MrlAnalyticsContext = createContext<MrlAnalyticsContextProps>(initialContext);\n\nexport interface MrlAnalyticsProviderProps {\n\t/**\n\t * The transport the app injects. Receives a MrlAnalyticsEvent and forwards it\n\t * wherever the app tracks (in murally: a wrapper over trackWithSegment).\n\t * Omit it and the toolkit stays silent — safe for consumers with no analytics.\n\t */\n\ttrack?: MrlTrack;\n\tchildren: React.ReactNode;\n}\n\n/**\n * Injects the app's analytics transport into the toolkit. Wrap the app once;\n * every instrumented Mrl* component below emits through the provided `track`.\n *\n * @param props - the provider props\n * @param props.track - the transport that receives each MrlAnalyticsEvent (default no-op)\n * @param props.children - the subtree that can emit analytics\n * @returns the provider wrapping `children`\n */\nexport const MrlAnalyticsProvider = ({ track, children }: MrlAnalyticsProviderProps) => {\n\t// Stable identity so consumers don't re-render every child on each parent render.\n\tconst value = React.useMemo<MrlAnalyticsContextProps>(() => ({ track: track ?? noop }), [track]);\n\n\treturn <MrlAnalyticsContext.Provider value={value}>{children}</MrlAnalyticsContext.Provider>;\n};\n"],"names":["initialContext","track","noop","MrlAnalyticsContext","createContext","MrlAnalyticsProvider","_ref","children","value","React","useMemo","createElement","Provider"],"mappings":";;;;AASA;AACA,IAAMA,cAAwC,GAAG;AAChDC,EAAAA,KAAK,EAAEC;AACR,CAAC;IAEYC,mBAAmB,gBAAGC,aAAa,CAA2BJ,cAAc;AAYzF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMK,oBAAoB,GAAGC,IAAA,IAAoD;AAAA,EAAA,IAAjDL,KAAK,GAAAK,IAAA,CAALL,KAAK;IAAEM,QAAQ,GAAAD,IAAA,CAARC,QAAQ;AACrD;AACA,EAAA,IAAMC,KAAK,GAAGC,KAAK,CAACC,OAAO,CAA2B,OAAO;AAAET,IAAAA,KAAK,EAAEA,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,GAALA,KAAK,GAAIC;AAAK,GAAC,CAAC,EAAE,CAACD,KAAK,CAAC,CAAC;AAEhG,EAAA,oBAAOQ,KAAA,CAAAE,aAAA,CAACR,mBAAmB,CAACS,QAAQ,EAAA;AAACJ,IAAAA,KAAK,EAAEA;AAAM,GAAA,EAAED,QAAuC,CAAC;AAC7F;;;;"}
@@ -0,0 +1,46 @@
1
+ import * as React from 'react';
2
+ import { TOOLKIT_VERSION } from '../../version.js';
3
+ import { MrlAnalyticsContext } from '../../contexts/MrlAnalyticsContext/MrlAnalyticsContext.js';
4
+
5
+ /**
6
+ * Raw accessor for the analytics context.
7
+ *
8
+ * @returns the injected `track` transport (default no-op)
9
+ */
10
+ var useMrlAnalytics = () => React.useContext(MrlAnalyticsContext);
11
+ /**
12
+ * Component-facing helper. Binds component identity + trackingId once, then
13
+ * `emit({ action })` per interaction. No-ops entirely when trackingId is absent,
14
+ * so instrumentation is opt-in and attributable.
15
+ *
16
+ * @param component - the emitting component's name, e.g. 'MrlButton'
17
+ * @param trackingId - consumer-supplied, non-PII id; undefined disables emission
18
+ * @returns an `emit` callback that fires a single interaction per call
19
+ */
20
+ var useMrlTrackInteraction = (component, trackingId) => {
21
+ var _useMrlAnalytics = useMrlAnalytics(),
22
+ track = _useMrlAnalytics.track;
23
+ return React.useCallback(_ref => {
24
+ var action = _ref.action,
25
+ variant = _ref.variant,
26
+ metadata = _ref.metadata;
27
+ // opt-in: no id → no event (volume + PII guard)
28
+ if (!trackingId) return;
29
+ try {
30
+ track({
31
+ action,
32
+ component,
33
+ metadata,
34
+ toolkitVersion: TOOLKIT_VERSION,
35
+ trackingId,
36
+ variant
37
+ });
38
+ } catch (e) {
39
+ // Ensure errors don't break the app
40
+ return e;
41
+ }
42
+ }, [track, component, trackingId]);
43
+ };
44
+
45
+ export { useMrlAnalytics, useMrlTrackInteraction };
46
+ //# sourceMappingURL=useMrlAnalytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMrlAnalytics.js","sources":["../../../../src/hooks/useMrlAnalytics/useMrlAnalytics.ts"],"sourcesContent":["import * as React from 'react';\nimport { MrlAnalyticsContext } from '../../contexts/MrlAnalyticsContext';\nimport { MrlAnalyticsEvent, MrlTrack } from '../../contexts/MrlAnalyticsContext/types';\nimport { TOOLKIT_VERSION } from '../../version';\n\n/**\n * Raw accessor for the analytics context.\n *\n * @returns the injected `track` transport (default no-op)\n */\nexport const useMrlAnalytics = (): { track: MrlTrack } => React.useContext(MrlAnalyticsContext);\n\ntype EmitArgs = Pick<MrlAnalyticsEvent, 'action' | 'variant' | 'metadata'>;\n\n/**\n * Component-facing helper. Binds component identity + trackingId once, then\n * `emit({ action })` per interaction. No-ops entirely when trackingId is absent,\n * so instrumentation is opt-in and attributable.\n *\n * @param component - the emitting component's name, e.g. 'MrlButton'\n * @param trackingId - consumer-supplied, non-PII id; undefined disables emission\n * @returns an `emit` callback that fires a single interaction per call\n */\nexport const useMrlTrackInteraction = (component: string, trackingId?: string) => {\n\tconst { track } = useMrlAnalytics();\n\n\treturn React.useCallback(\n\t\t({ action, variant, metadata }: EmitArgs) => {\n\t\t\t// opt-in: no id → no event (volume + PII guard)\n\t\t\tif (!trackingId) return;\n\t\t\ttry {\n\t\t\t\ttrack({\n\t\t\t\t\taction,\n\t\t\t\t\tcomponent,\n\t\t\t\t\tmetadata,\n\t\t\t\t\ttoolkitVersion: TOOLKIT_VERSION,\n\t\t\t\t\ttrackingId,\n\t\t\t\t\tvariant\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\t// Ensure errors don't break the app\n\t\t\t\treturn e;\n\t\t\t}\n\t\t},\n\t\t[track, component, trackingId]\n\t);\n};\n"],"names":["useMrlAnalytics","React","useContext","MrlAnalyticsContext","useMrlTrackInteraction","component","trackingId","_useMrlAnalytics","track","useCallback","_ref","action","variant","metadata","toolkitVersion","TOOLKIT_VERSION","e"],"mappings":";;;;AAKA;AACA;AACA;AACA;AACA;AACO,IAAMA,eAAe,GAAGA,MAA2BC,KAAK,CAACC,UAAU,CAACC,mBAAmB;AAI9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACaC,sBAAsB,GAAGA,CAACC,SAAiB,EAAEC,UAAmB,KAAK;AACjF,EAAA,IAAAC,gBAAA,GAAkBP,eAAe,EAAE;IAA3BQ,KAAK,GAAAD,gBAAA,CAALC,KAAK;AAEb,EAAA,OAAOP,KAAK,CAACQ,WAAW,CACvBC,IAAA,IAA6C;AAAA,IAAA,IAA1CC,MAAM,GAAAD,IAAA,CAANC,MAAM;MAAEC,OAAO,GAAAF,IAAA,CAAPE,OAAO;MAAEC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;AAC3B;IACA,IAAI,CAACP,UAAU,EAAE;IACjB,IAAI;AACHE,MAAAA,KAAK,CAAC;QACLG,MAAM;QACNN,SAAS;QACTQ,QAAQ;AACRC,QAAAA,cAAc,EAAEC,eAAe;QAC/BT,UAAU;AACVM,QAAAA;AACD,OAAC,CAAC;IACH,CAAC,CAAC,OAAOI,CAAC,EAAE;AACX;AACA,MAAA,OAAOA,CAAC;AACT,IAAA;EACD,CAAC,EACD,CAACR,KAAK,EAAEH,SAAS,EAAEC,UAAU,CAC9B,CAAC;AACF;;;;"}
package/dist/esm/index.js CHANGED
@@ -5,6 +5,7 @@ export { MRL_PORTAL_ID, MrlPortal } from './components/portal/MrlPortal.js';
5
5
  export { MRL_PROCESSING_BUTTON_ACTIONS, copyToClipboard } from './components/button/MrlProcessingButton/actions.js';
6
6
  export { MULTI_CREATABLE_SELECT_CLASS_NAME_PREFIX, MULTI_CREATABLE_SELECT_MENU_LIST_CLASS_NAME, MrlMultiCreatableSelect } from './components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.js';
7
7
  export { MULTI_SELECT_CLASS_NAME_PREFIX, MULTI_SELECT_MENU_LIST_CLASS_NAME, MrlMultiSelect } from './components/form/select/MrlMultiSelect/MrlMultiSelect.js';
8
+ export { MrlAnalyticsContext, MrlAnalyticsProvider } from './contexts/MrlAnalyticsContext/MrlAnalyticsContext.js';
8
9
  export { MrlAnimatedIconButton } from './components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js';
9
10
  export { MrlAvatar, defaultAvatarValues } from './components/avatar/MrlAvatar/MrlAvatar.js';
10
11
  export { MrlAvatarButton } from './components/avatar/MrlAvatarButton/MrlAvatarButton.js';
@@ -141,5 +142,6 @@ export { useBreakpoint } from './hooks/useBreakpoint/index.js';
141
142
  export { useCoordinate } from './hooks/useCoordinate/index.js';
142
143
  export { useElementDimensions } from './hooks/useElementDimensions/index.js';
143
144
  export { useHasFocusableDescendant } from './hooks/useHasFocusableDescendant/index.js';
145
+ export { useMrlAnalytics, useMrlTrackInteraction } from './hooks/useMrlAnalytics/useMrlAnalytics.js';
144
146
  export { useScrollbarInfo } from './hooks/useScrollbarInfo/index.js';
145
147
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,4 @@
1
+ var TOOLKIT_VERSION = "4.71.0-dev-nBIF.1";
2
+
3
+ export { TOOLKIT_VERSION };
4
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.71.0-dev-nBIF.1\";"],"names":["TOOLKIT_VERSION"],"mappings":"AAAO,IAAMA,eAAe,GAAG;;;;"}
@@ -1,4 +1,5 @@
1
1
  export * from './useCoordinate';
2
+ export * from './useMrlAnalytics';
2
3
  export * from './useBreakpoint';
3
4
  export * from './useElementDimensions';
4
5
  export * from './useHasFocusableDescendant';
@@ -0,0 +1 @@
1
+ export * from './useMrlAnalytics';
@@ -0,0 +1,21 @@
1
+ import { MrlAnalyticsEvent, MrlTrack } from '../../contexts/MrlAnalyticsContext/types';
2
+ /**
3
+ * Raw accessor for the analytics context.
4
+ *
5
+ * @returns the injected `track` transport (default no-op)
6
+ */
7
+ export declare const useMrlAnalytics: () => {
8
+ track: MrlTrack;
9
+ };
10
+ type EmitArgs = Pick<MrlAnalyticsEvent, 'action' | 'variant' | 'metadata'>;
11
+ /**
12
+ * Component-facing helper. Binds component identity + trackingId once, then
13
+ * `emit({ action })` per interaction. No-ops entirely when trackingId is absent,
14
+ * so instrumentation is opt-in and attributable.
15
+ *
16
+ * @param component - the emitting component's name, e.g. 'MrlButton'
17
+ * @param trackingId - consumer-supplied, non-PII id; undefined disables emission
18
+ * @returns an `emit` callback that fires a single interaction per call
19
+ */
20
+ export declare const useMrlTrackInteraction: (component: string, trackingId?: string) => ({ action, variant, metadata }: EmitArgs) => unknown;
21
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Demo for the useMrlAnalytics hooks. Injects a `track` transport that simply
3
+ * records the last emitted event so you can see the transport-agnostic
4
+ * `MrlAnalyticsEvent` the toolkit produces.
5
+ *
6
+ * @returns JSX.Element
7
+ */
8
+ export declare const UseMrlAnalyticsDemo: () => JSX.Element;
@@ -81,6 +81,11 @@ export interface MrlButtonProps extends Omit<MrlComponentProps, 'style'>, React.
81
81
  * Icon buttons require a text label to ensure accessibility.
82
82
  */
83
83
  text: string;
84
+ /**
85
+ * Enables interaction tracking for this button. Provide a stable, non-PII id
86
+ * (e.g. 'board-share-cta'). When omitted, the button emits no analytics.
87
+ */
88
+ trackingId?: string;
84
89
  /**
85
90
  * Determines which aria setup to use for various toggle/selected styles.
86
91
  * pressed - use for an traditional “toggle button”
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { MrlTrack } from './types';
3
+ export interface MrlAnalyticsContextProps {
4
+ track: MrlTrack;
5
+ }
6
+ export declare const MrlAnalyticsContext: React.Context<MrlAnalyticsContextProps>;
7
+ export interface MrlAnalyticsProviderProps {
8
+ /**
9
+ * The transport the app injects. Receives a MrlAnalyticsEvent and forwards it
10
+ * wherever the app tracks (in murally: a wrapper over trackWithSegment).
11
+ * Omit it and the toolkit stays silent — safe for consumers with no analytics.
12
+ */
13
+ track?: MrlTrack;
14
+ children: React.ReactNode;
15
+ }
16
+ /**
17
+ * Injects the app's analytics transport into the toolkit. Wrap the app once;
18
+ * every instrumented Mrl* component below emits through the provided `track`.
19
+ *
20
+ * @param props - the provider props
21
+ * @param props.track - the transport that receives each MrlAnalyticsEvent (default no-op)
22
+ * @param props.children - the subtree that can emit analytics
23
+ * @returns the provider wrapping `children`
24
+ */
25
+ export declare const MrlAnalyticsProvider: ({ track, children }: MrlAnalyticsProviderProps) => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './MrlAnalyticsContext';
2
+ export * from './types';
@@ -0,0 +1,22 @@
1
+ /** Values allowed in analytics payloads. No free-text/PII — see MrlAnalyticsProvider docs. */
2
+ export type MrlAnalyticsValue = string | number | boolean;
3
+ /** The canonical interaction a Mrl* component emits. Transport-agnostic. */
4
+ export interface MrlAnalyticsEvent {
5
+ /** Component identity, e.g. 'MrlButton', 'MrlMenu', 'MrlModal'. Set by the component. */
6
+ component: string;
7
+ /** Interaction type, e.g. 'click' | 'open' | 'close' | 'select' | 'change'. Set by the component. */
8
+ action: string;
9
+ /** ui-toolkit version for internal tracking */
10
+ toolkitVersion: string;
11
+ /**
12
+ * Consumer-supplied attribution id. REQUIRED for an event to fire (opt-in).
13
+ * Must be a stable, non-PII identifier (e.g. 'board-share', not the user's name).
14
+ */
15
+ trackingId: string;
16
+ /** Non-PII component variant, e.g. button kind/size. Set by the component. */
17
+ variant?: string;
18
+ /** Curated, non-PII extra context. Never button labels, input values, etc. */
19
+ metadata?: Record<string, MrlAnalyticsValue>;
20
+ }
21
+ /** The one function the toolkit calls. The app decides what it does. */
22
+ export type MrlTrack = (event: MrlAnalyticsEvent) => void;
@@ -1 +1,2 @@
1
+ export * from './MrlAnalyticsContext';
1
2
  export * from './MrlTabContext';
@@ -1,4 +1,5 @@
1
1
  export * from './useCoordinate';
2
+ export * from './useMrlAnalytics';
2
3
  export * from './useBreakpoint';
3
4
  export * from './useElementDimensions';
4
5
  export * from './useHasFocusableDescendant';
@@ -0,0 +1 @@
1
+ export * from './useMrlAnalytics';
@@ -0,0 +1,21 @@
1
+ import { MrlAnalyticsEvent, MrlTrack } from '../../contexts/MrlAnalyticsContext/types';
2
+ /**
3
+ * Raw accessor for the analytics context.
4
+ *
5
+ * @returns the injected `track` transport (default no-op)
6
+ */
7
+ export declare const useMrlAnalytics: () => {
8
+ track: MrlTrack;
9
+ };
10
+ type EmitArgs = Pick<MrlAnalyticsEvent, 'action' | 'variant' | 'metadata'>;
11
+ /**
12
+ * Component-facing helper. Binds component identity + trackingId once, then
13
+ * `emit({ action })` per interaction. No-ops entirely when trackingId is absent,
14
+ * so instrumentation is opt-in and attributable.
15
+ *
16
+ * @param component - the emitting component's name, e.g. 'MrlButton'
17
+ * @param trackingId - consumer-supplied, non-PII id; undefined disables emission
18
+ * @returns an `emit` callback that fires a single interaction per call
19
+ */
20
+ export declare const useMrlTrackInteraction: (component: string, trackingId?: string) => ({ action, variant, metadata }: EmitArgs) => unknown;
21
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Demo for the useMrlAnalytics hooks. Injects a `track` transport that simply
3
+ * records the last emitted event so you can see the transport-agnostic
4
+ * `MrlAnalyticsEvent` the toolkit produces.
5
+ *
6
+ * @returns JSX.Element
7
+ */
8
+ export declare const UseMrlAnalyticsDemo: () => JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const TOOLKIT_VERSION = "0.0.0-dev";
@@ -0,0 +1 @@
1
+ export declare const TOOLKIT_VERSION = "0.0.0-dev";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muraldevkit/ui-toolkit",
3
- "version": "4.70.3",
3
+ "version": "4.71.0-dev-nBIF.1",
4
4
  "description": "Mural's UI Toolkit",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -14,6 +14,7 @@
14
14
  ],
15
15
  "scripts": {
16
16
  "prebuild": "rimraf dist",
17
+ "prepack": "npm run build",
17
18
  "analyze": "ANALYZE=true rollup --config rollup.config.mjs",
18
19
  "build": "npm run build:js && npm run build:css && npm run build:types && npm run build:verify",
19
20
  "build:css": "webpack --mode=production",