@techsio/storybook-better-a11y 0.0.9 → 0.0.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Details.d.ts","sourceRoot":"","sources":["../../../src/components/Report/Details.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAU/D,OAAO,KAAK,EAAsB,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAyHhF,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,qBAAqB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,OAAO,GAAI,sDAAsD,YAAY,sBAiDzF,CAAC"}
1
+ {"version":3,"file":"Details.d.ts","sourceRoot":"","sources":["../../../src/components/Report/Details.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AASxE,OAAO,KAAK,EAAsB,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAyHhF,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,qBAAqB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,OAAO,GAAI,sDAAsD,YAAY,sBA+CzF,CAAC"}
package/dist/manager.js CHANGED
@@ -5,7 +5,6 @@ import { AccessibilityIcon, CheckIcon, ChevronSmallDownIcon, CollapseIcon, CopyI
5
5
  import { convert, styled, themes, useTheme } from "storybook/theming";
6
6
  import { STORY_CHANGED, STORY_FINISHED, STORY_HOT_UPDATED, STORY_RENDER_PHASE_CHANGED } from "storybook/internal/core-events";
7
7
  import { HIGHLIGHT, REMOVE_HIGHLIGHT, SCROLL_INTO_VIEW } from "storybook/highlight";
8
- import { Content, List, Root, Trigger } from "@radix-ui/react-tabs";
9
8
  import { EVENTS, STATUS_TYPE_ID_COMPONENT_TEST, filters, filterDefs, DOCUMENTATION_DISCREPANCY_LINK, ADDON_ID, STATUS_TYPE_ID_A11Y, PANEL_ID } from "./100.js";
10
9
  const RuleType = {
11
10
  VIOLATION: 'violations',
@@ -1012,7 +1011,7 @@ const Columns = styled.div({
1012
1011
  gridTemplateColumns: '50% 50%'
1013
1012
  }
1014
1013
  });
1015
- const Details_Content = styled.div(({ theme, side })=>({
1014
+ const Content = styled.div(({ theme, side })=>({
1016
1015
  display: 'left' === side ? 'flex' : 'none',
1017
1016
  flexDirection: 'column',
1018
1017
  gap: 15,
@@ -1069,49 +1068,44 @@ const CopyButton = ({ onClick })=>{
1069
1068
  onClick: handleClick
1070
1069
  }, copied ? /*#__PURE__*/ react.createElement(CheckIcon, null) : /*#__PURE__*/ react.createElement(CopyIcon, null), " ", copied ? 'Copied' : 'Copy link');
1071
1070
  };
1072
- const Details = ({ id, item, type, selection, handleSelectionChange })=>/*#__PURE__*/ react.createElement(Wrapper, {
1071
+ const Details = ({ id, item, type, selection, handleSelectionChange })=>{
1072
+ const selectedNode = useMemo(()=>{
1073
+ const selectedIndex = item.nodes.findIndex((_, index)=>`${type}.${item.id}.${index + 1}` === selection);
1074
+ return item.nodes[-1 === selectedIndex ? 0 : selectedIndex];
1075
+ }, [
1076
+ item.id,
1077
+ item.nodes,
1078
+ selection,
1079
+ type
1080
+ ]);
1081
+ return /*#__PURE__*/ react.createElement(Wrapper, {
1073
1082
  id: id
1074
1083
  }, /*#__PURE__*/ react.createElement(Info, null, /*#__PURE__*/ react.createElement(RuleId, null, item.id), /*#__PURE__*/ react.createElement(Description, null, getFriendlySummaryForAxeResult(item), ' ', /*#__PURE__*/ react.createElement(Link, {
1075
1084
  href: item.helpUrl,
1076
1085
  target: "_blank",
1077
1086
  rel: "noopener noreferrer",
1078
1087
  withArrow: true
1079
- }, "Learn how to resolve this violation"))), /*#__PURE__*/ react.createElement(Root, {
1080
- defaultValue: selection,
1081
- orientation: "vertical",
1082
- value: selection,
1083
- onValueChange: handleSelectionChange,
1084
- asChild: true
1085
- }, /*#__PURE__*/ react.createElement(Columns, null, /*#__PURE__*/ react.createElement(List, {
1088
+ }, "Learn how to resolve this violation"))), /*#__PURE__*/ react.createElement(Columns, null, /*#__PURE__*/ react.createElement("div", {
1086
1089
  "aria-label": type
1087
1090
  }, item.nodes.map((node, index)=>{
1088
1091
  const key = `${type}.${item.id}.${index + 1}`;
1092
+ const isActive = selection === key;
1089
1093
  return /*#__PURE__*/ react.createElement(Fragment, {
1090
1094
  key: key
1091
- }, /*#__PURE__*/ react.createElement(Trigger, {
1092
- value: key,
1093
- asChild: true
1094
1095
  }, /*#__PURE__*/ react.createElement(Item, {
1095
1096
  ariaLabel: false,
1096
1097
  variant: "ghost",
1097
1098
  size: "medium",
1098
- id: key
1099
- }, index + 1, ". ", node.html)), /*#__PURE__*/ react.createElement(Content, {
1100
- value: key,
1101
- asChild: true
1102
- }, /*#__PURE__*/ react.createElement(Details_Content, {
1099
+ id: key,
1100
+ "data-state": isActive ? 'active' : 'inactive',
1101
+ onClick: ()=>handleSelectionChange(key)
1102
+ }, index + 1, ". ", node.html), isActive ? /*#__PURE__*/ react.createElement(Content, {
1103
1103
  side: "left"
1104
- }, getContent(node))));
1105
- })), item.nodes.map((node, index)=>{
1106
- const key = `${type}.${item.id}.${index + 1}`;
1107
- return /*#__PURE__*/ react.createElement(Content, {
1108
- key: key,
1109
- value: key,
1110
- asChild: true
1111
- }, /*#__PURE__*/ react.createElement(Details_Content, {
1112
- side: "right"
1113
- }, getContent(node)));
1114
- }))));
1104
+ }, getContent(node)) : null);
1105
+ })), /*#__PURE__*/ react.createElement(Content, {
1106
+ side: "right"
1107
+ }, selectedNode ? getContent(selectedNode) : null)));
1108
+ };
1115
1109
  function getContent(node) {
1116
1110
  const { handleCopyLink, handleJumpToElement } = useA11yContext();
1117
1111
  const { any, all, none, html, target } = node;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techsio/storybook-better-a11y",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Storybook Accessibility addon with APCA (WCAG 3) support",
5
5
  "keywords": [
6
6
  "storybook",
@@ -55,7 +55,6 @@
55
55
  "@semantic-release/github": "^12.0.2",
56
56
  "@semantic-release/npm": "^13.1.2",
57
57
  "@semantic-release/release-notes-generator": "^14.1.0",
58
- "@radix-ui/react-tabs": "^1.0.4",
59
58
  "@storybook/icons": "^2.0.1",
60
59
  "rsbuild-plugin-publint": "^0.3.3",
61
60
  "react": "^18.2.0",
@@ -65,7 +64,6 @@
65
64
  "vitest-axe": "^0.1.0"
66
65
  },
67
66
  "peerDependencies": {
68
- "@radix-ui/react-tabs": ">=1.0.0",
69
67
  "@storybook/icons": ">=2.0.0",
70
68
  "react": ">=18.0.0",
71
69
  "react-dom": ">=18.0.0",