@ciromaciel/auth-react 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4482,6 +4482,8 @@ const UPGRADE_THRESHOLD = 0.8;
4482
4482
  * @property {string} [id] - Stable key
4483
4483
  * @property {string} label - The row's text
4484
4484
  * @property {Function} [icon] - A Tabler icon component
4485
+ * @property {string} [description] - One line under the label, saying what the action does
4486
+ * @property {'danger'} [tone] - For what cannot be undone: red label and icon
4485
4487
  * @property {Function} onClick
4486
4488
  *
4487
4489
  * @typedef {Object} UserInformationPlan
@@ -4508,6 +4510,7 @@ const UPGRADE_THRESHOLD = 0.8;
4508
4510
  * @param {Function} [props.onAccountClick]
4509
4511
  * @param {Function} [props.onBillingClick]
4510
4512
  * @param {UserInformationItem[]} [props.items] - The panel's own rows, shown in their own group
4513
+ * @param {string} [props.itemsLabel] - A title for that group ("Seus dados"); without it, none
4511
4514
  * @param {UserInformationPlan} [props.plan] - The plan strip; omitted, the strip is not drawn
4512
4515
  * @param {UserInformationOrganization} [props.organization] - Where the person is acting
4513
4516
  * @param {boolean} [props.branded=true] - The footer: "Protegido por Auth" and the terms link
@@ -4523,6 +4526,7 @@ function UserInformation({
4523
4526
  onAccountClick,
4524
4527
  onBillingClick,
4525
4528
  items = [],
4529
+ itemsLabel,
4526
4530
  plan,
4527
4531
  organization,
4528
4532
  branded = true,
@@ -4620,6 +4624,7 @@ function UserInformation({
4620
4624
  hasDivider: !organization?.name && !plan
4621
4625
  }), panelRows.length > 0 && /*#__PURE__*/jsxRuntime.jsx(RowGroup, {
4622
4626
  rows: panelRows,
4627
+ label: itemsLabel,
4623
4628
  hasDivider: true
4624
4629
  }), signOut && /*#__PURE__*/jsxRuntime.jsx(RowGroup, {
4625
4630
  rows: [{
@@ -4791,24 +4796,59 @@ function ContextStrip({
4791
4796
  }
4792
4797
  function RowGroup({
4793
4798
  rows,
4799
+ label,
4794
4800
  hasDivider
4795
4801
  }) {
4796
- return /*#__PURE__*/jsxRuntime.jsx(core.Stack, {
4802
+ return /*#__PURE__*/jsxRuntime.jsxs(core.Stack, {
4797
4803
  gap: 0,
4798
4804
  p: 6,
4805
+ role: label ? 'group' : undefined,
4806
+ "aria-label": label || undefined,
4799
4807
  style: hasDivider ? {
4800
4808
  borderTop: '1px solid var(--mantine-color-gray-2)'
4801
4809
  } : undefined,
4802
- children: rows.map(row => /*#__PURE__*/jsxRuntime.jsx(Row, {
4810
+ children: [label && /*#__PURE__*/jsxRuntime.jsx(core.Text, {
4811
+ "aria-hidden": true,
4812
+ fz: 11,
4813
+ fw: 800,
4814
+ tt: "uppercase",
4815
+ lts: "1.5px",
4816
+ c: "gray.4",
4817
+ px: 10,
4818
+ pt: 6,
4819
+ pb: 2,
4820
+ children: label
4821
+ }), rows.map(row => /*#__PURE__*/jsxRuntime.jsx(Row, {
4803
4822
  ...row
4804
- }, row.id || row.label))
4823
+ }, row.id || row.label))]
4805
4824
  });
4806
4825
  }
4826
+
4827
+ /*
4828
+ * A panel's row may carry a line saying what it does and, for what cannot be
4829
+ * undone, the danger tone — still as data, so every card keeps one shape. The
4830
+ * History needed both: "Apagar tudo" looked exactly like "Exportar".
4831
+ */
4832
+ const ROW_TONES = {
4833
+ default: {
4834
+ text: 'gray.9',
4835
+ icon: 'var(--mantine-color-gray-5)',
4836
+ hover: 'var(--mantine-color-gray-1)'
4837
+ },
4838
+ danger: {
4839
+ text: 'red.8',
4840
+ icon: 'var(--mantine-color-red-8)',
4841
+ hover: 'var(--mantine-color-red-0)'
4842
+ }
4843
+ };
4807
4844
  function Row({
4808
4845
  label,
4846
+ description,
4847
+ tone,
4809
4848
  icon: Icon,
4810
4849
  onClick
4811
4850
  }) {
4851
+ const look = ROW_TONES[tone] || ROW_TONES.default;
4812
4852
  return /*#__PURE__*/jsxRuntime.jsxs(core.UnstyledButton, {
4813
4853
  role: "menuitem",
4814
4854
  onClick: onClick,
@@ -4817,7 +4857,7 @@ function Row({
4817
4857
  w: "100%",
4818
4858
  style: {
4819
4859
  display: 'flex',
4820
- alignItems: 'center',
4860
+ alignItems: description ? 'flex-start' : 'center',
4821
4861
  gap: 10,
4822
4862
  borderRadius: 0
4823
4863
  }
@@ -4825,23 +4865,35 @@ function Row({
4825
4865
  * Hover and keyboard focus share the same surface: a row reached
4826
4866
  * with the arrows must look exactly like the one under the mouse.
4827
4867
  */,
4828
- onMouseEnter: event => event.currentTarget.style.background = 'var(--mantine-color-gray-1)',
4868
+ onMouseEnter: event => event.currentTarget.style.background = look.hover,
4829
4869
  onMouseLeave: event => event.currentTarget.style.background = 'transparent',
4830
- onFocus: event => event.currentTarget.style.background = 'var(--mantine-color-gray-1)',
4870
+ onFocus: event => event.currentTarget.style.background = look.hover,
4831
4871
  onBlur: event => event.currentTarget.style.background = 'transparent',
4832
4872
  children: [Icon && /*#__PURE__*/jsxRuntime.jsx(Icon, {
4833
4873
  size: 16,
4834
4874
  stroke: 1.5,
4835
4875
  style: {
4836
4876
  flex: 'none',
4837
- color: 'var(--mantine-color-gray-5)'
4877
+ color: look.icon,
4878
+ marginTop: description ? 1 : 0
4838
4879
  }
4839
- }), /*#__PURE__*/jsxRuntime.jsx(core.Text, {
4840
- fz: 12,
4841
- fw: 500,
4842
- c: "gray.9",
4843
- truncate: "end",
4844
- children: label
4880
+ }), /*#__PURE__*/jsxRuntime.jsxs(core.Box, {
4881
+ style: {
4882
+ minWidth: 0
4883
+ },
4884
+ children: [/*#__PURE__*/jsxRuntime.jsx(core.Text, {
4885
+ fz: 12,
4886
+ fw: 500,
4887
+ c: look.text,
4888
+ truncate: "end",
4889
+ children: label
4890
+ }), description && /*#__PURE__*/jsxRuntime.jsx(core.Text, {
4891
+ fz: 12,
4892
+ fw: 500,
4893
+ c: "gray.5",
4894
+ lh: 1.4,
4895
+ children: description
4896
+ })]
4845
4897
  })]
4846
4898
  });
4847
4899
  }