orcs-design-system 3.0.0 → 3.0.2

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.
@@ -117,6 +117,7 @@ export var tooltipWithLinkExample = function tooltipWithLinkExample() {
117
117
  small: true,
118
118
  target: "_blank"
119
119
  }, "link to TeamForm")),
120
+ arialLabel: "Link to TeamForm",
120
121
  direction: "right",
121
122
  variant: "tooltip",
122
123
  enableSelectAll: false
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["children", "direction", "width", "textAlign", "text", "inlineBlock", "theme", "variant", "enableSelectAll"];
5
- import React, { useState } from "react";
4
+ var _excluded = ["children", "direction", "width", "textAlign", "text", "inlineBlock", "theme", "variant", "enableSelectAll", "tabIndex"];
5
+ import React, { useId, useMemo, useState } from "react";
6
6
  import PropTypes from "prop-types";
7
7
  import styled, { css, ThemeProvider } from "styled-components";
8
8
  import { space, layout } from "styled-system";
@@ -10,16 +10,17 @@ import { keys } from "lodash";
10
10
  import Icon from "../Icon";
11
11
  import { themeGet } from "@styled-system/theme-get";
12
12
  import { useKeepInView, directions } from "../../hooks/keepInView";
13
+ import useIsVisible from "../../hooks/isVisible";
13
14
  var Container = styled.div.withConfig({
14
15
  displayName: "Popover__Container",
15
16
  componentId: "sc-1bwoak-0"
16
17
  })(["", " ", " display:", ";position:relative;&:hover,&:focus-within{.popoverText{opacity:1;z-index:100;visibility:visible;pointer-events:auto;}}"], space, layout, function (props) {
17
18
  return props.inlineBlock ? "inline-block !important" : "block !important";
18
19
  });
19
- var TooltipControl = styled.div.withConfig({
20
+ var TooltipControl = styled.button.withConfig({
20
21
  displayName: "Popover__TooltipControl",
21
22
  componentId: "sc-1bwoak-1"
22
- })(["cursor:help;transition:", ";&:hover,&:focus{outline:0;color:", ";}"], function (props) {
23
+ })(["border:none;background:none;padding:0;cursor:help;font-size:1em;transition:", ";&:hover,&:focus{outline:0;color:", ";}"], function (props) {
23
24
  return themeGet("transition.transitionDefault")(props);
24
25
  }, function (props) {
25
26
  return themeGet("colors.primary")(props);
@@ -79,11 +80,18 @@ export default function Popover(_ref2) {
79
80
  variant = _ref2.variant,
80
81
  _ref2$enableSelectAll = _ref2.enableSelectAll,
81
82
  enableSelectAll = _ref2$enableSelectAll === void 0 ? true : _ref2$enableSelectAll,
83
+ _ref2$tabIndex = _ref2.tabIndex,
84
+ tabIndex = _ref2$tabIndex === void 0 ? 0 : _ref2$tabIndex,
82
85
  props = _objectWithoutProperties(_ref2, _excluded);
83
86
  var _useState = useState(direction),
84
87
  _useState2 = _slicedToArray(_useState, 2),
85
88
  inViewDirection = _useState2[0],
86
89
  setInViewDirection = _useState2[1];
90
+ var _useIsVisible = useIsVisible(),
91
+ _useIsVisible2 = _slicedToArray(_useIsVisible, 2),
92
+ isActive = _useIsVisible2[0],
93
+ tooltip = _useIsVisible2[1];
94
+ var toolTipId = useId();
87
95
  var _useKeepInView = useKeepInView({
88
96
  direction: direction,
89
97
  callback: setInViewDirection
@@ -91,6 +99,13 @@ export default function Popover(_ref2) {
91
99
  _useKeepInView2 = _slicedToArray(_useKeepInView, 2),
92
100
  ref = _useKeepInView2[0],
93
101
  setIsShown = _useKeepInView2[1];
102
+ var ariaLabel = useMemo(function () {
103
+ if (props.ariaLabel) {
104
+ return props.ariaLabel;
105
+ } else if (typeof text === "string") {
106
+ return text;
107
+ }
108
+ }, [props.ariaLabel, text]);
94
109
  var component = /*#__PURE__*/React.createElement(Container, _extends({
95
110
  inlineBlock: inlineBlock
96
111
  }, props, {
@@ -100,19 +115,27 @@ export default function Popover(_ref2) {
100
115
  onMouseLeave: function onMouseLeave() {
101
116
  return setIsShown(false);
102
117
  }
103
- }), !!text && /*#__PURE__*/React.createElement(Text, {
118
+ }), variant === "tooltip" && /*#__PURE__*/React.createElement(TooltipControl, {
119
+ tabIndex: tabIndex,
120
+ "aria-label": ariaLabel,
121
+ "aria-expanded": "".concat(isActive),
122
+ "aria-describedby": toolTipId
123
+ }, /*#__PURE__*/React.createElement(Icon, {
124
+ transform: "grow-4",
125
+ icon: ["fas", "question-circle"]
126
+ })), !!text && /*#__PURE__*/React.createElement(Text, {
104
127
  ref: ref,
128
+ role: "list",
105
129
  className: "popoverText",
106
130
  textAlign: textAlign,
107
131
  direction: inViewDirection,
108
132
  width: width,
109
133
  enableSelectAll: enableSelectAll
110
- }, text), variant === "tooltip" && /*#__PURE__*/React.createElement(TooltipControl, {
111
- tabIndex: "0"
112
- }, /*#__PURE__*/React.createElement(Icon, {
113
- transform: "grow-4",
114
- icon: ["fas", "question-circle"]
115
- })), children);
134
+ }, /*#__PURE__*/React.createElement("span", {
135
+ id: toolTipId,
136
+ role: "listitem",
137
+ ref: tooltip
138
+ }, text)), children);
116
139
  return theme ? /*#__PURE__*/React.createElement(ThemeProvider, {
117
140
  theme: theme
118
141
  }, component) : component;
@@ -135,7 +158,11 @@ Popover.propTypes = {
135
158
  /** Specifies the system design theme. */
136
159
  theme: PropTypes.object,
137
160
  /** Specifies whether enable select all behaviour */
138
- enableSelectAll: PropTypes.bool
161
+ enableSelectAll: PropTypes.bool,
162
+ /** Provide an aria-label if text is not a string */
163
+ ariaLabel: PropTypes.string,
164
+ /** Provide a tab index for accessibilty, defaults to 0 */
165
+ tabIndex: PropTypes.number
139
166
  };
140
167
  Popover.__docgenInfo = {
141
168
  "description": "This popover component is intended to be used to supplement buttons (or other elements) that require some helper text. It supports customisation of direction and width. This is so that you can ensure that the popover doesn't run off the screen, and that the width suits the amount of text in the popover.\n\nIf you don't specify a width, 200px is the default, but as a general guide try and keep widths somewhere between 150-250 if you are modifying. Make sure if setting width you include the unit you want it to use, e.g. pixels, %.",
@@ -153,6 +180,17 @@ Popover.__docgenInfo = {
153
180
  "required": false,
154
181
  "description": "Specifies whether enable select all behaviour"
155
182
  },
183
+ "tabIndex": {
184
+ "defaultValue": {
185
+ "value": "0",
186
+ "computed": false
187
+ },
188
+ "type": {
189
+ "name": "number"
190
+ },
191
+ "required": false,
192
+ "description": "Provide a tab index for accessibilty, defaults to 0"
193
+ },
156
194
  "children": {
157
195
  "type": {
158
196
  "name": "element"
@@ -224,6 +262,13 @@ Popover.__docgenInfo = {
224
262
  },
225
263
  "required": false,
226
264
  "description": "Specifies the system design theme."
265
+ },
266
+ "ariaLabel": {
267
+ "type": {
268
+ "name": "string"
269
+ },
270
+ "required": false,
271
+ "description": "Provide an aria-label if text is not a string"
227
272
  }
228
273
  }
229
274
  };
@@ -166,7 +166,7 @@ var SideNavItem = styled("button").attrs(function (props) {
166
166
  position: "relative",
167
167
  display: "flex",
168
168
  alignItems: "center",
169
- justifyContent: "flex-start",
169
+ justifyContent: "center",
170
170
  width: "100%",
171
171
  borderRadius: themeGet("radii.2")(props),
172
172
  transition: themeGet("transition.transitionDefault")(props),
@@ -249,7 +249,7 @@ var SideNavItemLink = styled("div").attrs(function (props) {
249
249
  position: "relative",
250
250
  display: "flex",
251
251
  alignItems: "center",
252
- justifyContent: "flex-start",
252
+ justifyContent: "center",
253
253
  width: "100%",
254
254
  transition: themeGet("transition.transitionDefault")(props),
255
255
  bg: "transparent",
@@ -3,7 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
4
  var _excluded = ["numberProps"];
5
5
  import React, { useMemo } from "react";
6
- import NumberFormat from "react-number-format";
6
+ import { NumericFormat } from "react-number-format";
7
7
  import PropTypes from "prop-types";
8
8
  import styled, { css } from "styled-components";
9
9
  import { space, layout, compose } from "styled-system";
@@ -82,7 +82,7 @@ var Input = styled("input").attrs(function (props) {
82
82
  displayName: "TextInput__Input",
83
83
  componentId: "shde0o-1"
84
84
  })(["", ""], InputStyle);
85
- var NumberInput = styled(NumberFormat).attrs(function (props) {
85
+ var NumberInput = styled(NumericFormat).attrs(function (props) {
86
86
  return {
87
87
  "data-testid": props["data-testid"] ? props["data-testid"] : null
88
88
  };
@@ -0,0 +1,22 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { useEffect, useRef, useState } from "react";
3
+ export default function useIsVisible() {
4
+ var _useState = useState(false),
5
+ _useState2 = _slicedToArray(_useState, 2),
6
+ isVisible = _useState2[0],
7
+ setIsVisible = _useState2[1];
8
+ var ref = useRef();
9
+ useEffect(function () {
10
+ if (!ref.current) return;
11
+ var interval = window.setInterval(function () {
12
+ var currentIsVisible = window.getComputedStyle(ref.current).visibility === "visible";
13
+ if (isVisible !== currentIsVisible) {
14
+ setIsVisible(currentIsVisible);
15
+ }
16
+ }, 250);
17
+ return function () {
18
+ clearInterval(interval);
19
+ };
20
+ }, [ref, isVisible]);
21
+ return [isVisible, ref];
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orcs-design-system",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Orchestrated's Design System, aka: ORCS",
5
5
  "keywords": [
6
6
  "design",
@@ -50,16 +50,16 @@
50
50
  "prop-types": "^15.6.2",
51
51
  "react-app-polyfill": "^2.0.0",
52
52
  "react-cool-onclickoutside": "^1.5.9",
53
- "react-dates": "^21.8.0",
54
53
  "react-docgen": "^5.3.0",
55
54
  "react-intersection-observer": "^9.4.3",
56
55
  "react-moment-proptypes": "^1.8.1",
57
- "react-number-format": "^4.4.1",
56
+ "react-number-format": "^5.3.0",
58
57
  "react-router": "^5.2.0",
59
58
  "react-router-dom": "^5.2.0",
60
59
  "react-select": "^5.7.4",
61
60
  "react-test-renderer": "^18.2.0",
62
- "styled-system": "^5.1.5"
61
+ "styled-system": "^5.1.5",
62
+ "react-dates": "^21.8.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@babel/cli": "^7.12.10",
@@ -77,31 +77,33 @@
77
77
  "@mdx-js/react": "^2.3.0",
78
78
  "@percy/cli": "^1.26.3",
79
79
  "@percy/storybook": "^4.3.6",
80
- "@storybook/addon-a11y": "^7.2.1",
81
- "@storybook/addon-actions": "^7.2.1",
82
- "@storybook/addon-docs": "^7.2.1",
80
+ "@storybook/addon-a11y": "^7.3.2",
81
+ "@storybook/addon-actions": "^7.3.2",
82
+ "@storybook/addon-docs": "^7.3.2",
83
83
  "@storybook/addon-knobs": "^7.0.2",
84
- "@storybook/addon-links": "^7.2.1",
85
- "@storybook/addon-mdx-gfm": "^7.2.1",
86
- "@storybook/addon-storyshots": "^7.2.1",
87
- "@storybook/addon-toolbars": "^7.2.1",
88
- "@storybook/addon-viewport": "^7.2.1",
89
- "@storybook/addons": "^7.2.1",
90
- "@storybook/api": "^7.2.1",
91
- "@storybook/blocks": "^7.2.1",
92
- "@storybook/components": "^7.2.1",
84
+ "@storybook/addon-links": "^7.3.2",
85
+ "@storybook/addon-mdx-gfm": "^7.3.2",
86
+ "@storybook/addon-storyshots": "^7.3.2",
87
+ "@storybook/addon-toolbars": "^7.3.2",
88
+ "@storybook/addon-viewport": "^7.3.2",
89
+ "@storybook/addons": "^7.3.2",
90
+ "@storybook/api": "^7.3.2",
91
+ "@storybook/blocks": "^7.3.2",
92
+ "@storybook/components": "^7.3.2",
93
+ "@storybook/core-events": "^7.3.2",
94
+ "@storybook/manager-api": "^7.3.2",
93
95
  "@storybook/mdx1-csf": "^1.0.0",
94
- "@storybook/preset-create-react-app": "^7.2.1",
95
- "@storybook/react": "^7.2.1",
96
- "@storybook/react-webpack5": "^7.2.1",
97
- "@storybook/storybook-deployer": "^2.8.16",
96
+ "@storybook/preset-create-react-app": "^7.3.2",
97
+ "@storybook/react": "^7.3.2",
98
+ "@storybook/react-webpack5": "^7.3.2",
99
+ "@storybook/storybook-deployer": "2.8.16",
98
100
  "@testing-library/jest-dom": "^5.11.6",
99
101
  "@testing-library/react": "^11.2.2",
100
102
  "@types/jest": "^26.0.19",
101
103
  "@types/styled-components": "^5.1.7",
102
104
  "audit-ci": "^6.1.2",
103
105
  "babel-core": "^7.0.0-bridge.0",
104
- "babel-eslint": "^8.2.5",
106
+ "babel-eslint": "^10.0.0",
105
107
  "babel-loader": "^8.1.0",
106
108
  "babel-plugin-react-docgen": "^4.1.0",
107
109
  "babel-plugin-styled-components": "^1.10.7",
@@ -120,11 +122,11 @@
120
122
  "identity-obj-proxy": "^3.0.0",
121
123
  "jest": "^26.6.3",
122
124
  "npm-run-all": "^4.1.5",
123
- "playroom": "^0.27.7",
125
+ "playroom": "^0.32.1",
124
126
  "prettier": "^2.2.1",
125
127
  "react": "^18.2.0",
126
128
  "react-dom": "^18.2.0",
127
- "storybook": "^7.2.1",
129
+ "storybook": "^7.3.2",
128
130
  "style-loader": "^2.0.0",
129
131
  "styled-components": "^5.2.1",
130
132
  "webpack": "^5.88.2",
@@ -135,6 +137,12 @@
135
137
  "react-dom": "^18.2.0",
136
138
  "styled-components": "^5.2.1"
137
139
  },
140
+ "overrides": {
141
+ "nth-check": "2.1.0",
142
+ "parse-url": "8.1.0",
143
+ "react-scripts": "5.0.1",
144
+ "remark-parse": "10.0.2"
145
+ },
138
146
  "browserslist": {
139
147
  "development": [
140
148
  "last 2 chrome versions",