@spaced-out/ui-design-system 0.1.123 → 0.1.125

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.
@@ -92,6 +92,8 @@ storysource
92
92
  superrover
93
93
  sharad
94
94
  kushwah
95
+ bhatiarush
96
+ Swatantramishra
95
97
  Syowa
96
98
  systemjs
97
99
  tablist
@@ -22,7 +22,7 @@ jobs:
22
22
  - name: Check Permissions
23
23
  id: check-permissions
24
24
  env:
25
- ALLOWED_USERS: superrover, Anant-Raj, ashwini-sensehq, vish-sah, VishalBarnawal, sanskar-s, VivekJangid, sharad-kushwah, Swatantramishra1
25
+ ALLOWED_USERS: superrover, Anant-Raj, ashwini-sensehq, vish-sah, VishalBarnawal, sanskar-s, VivekJangid, sharad-kushwah, Swatantramishra1, bhatiarush27
26
26
  if: ${{ !contains(env.ALLOWED_USERS, github.actor) }}
27
27
  run: |
28
28
  echo "You don't have correct permissions to do this release"
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.125](https://github.com/spaced-out/ui-design-system/compare/v0.1.124...v0.1.125) (2024-08-29)
6
+
7
+
8
+ ### Features
9
+
10
+ * rating component ([#258](https://github.com/spaced-out/ui-design-system/issues/258)) ([450caa5](https://github.com/spaced-out/ui-design-system/commit/450caa523c55b5cf3e4635064f63b3e4eec19a8e))
11
+
12
+ ### [0.1.124](https://github.com/spaced-out/ui-design-system/compare/v0.1.123...v0.1.124) (2024-08-27)
13
+
14
+
15
+ ### Features
16
+
17
+ * github pages release access ([#256](https://github.com/spaced-out/ui-design-system/issues/256)) ([f7e4e47](https://github.com/spaced-out/ui-design-system/commit/f7e4e474aed55ccff84835feed20caeb477b9d83))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * side menu link accesibility ([#259](https://github.com/spaced-out/ui-design-system/issues/259)) ([3c06c7b](https://github.com/spaced-out/ui-design-system/commit/3c06c7bcedfc6545cddad96e60dbcde5ec05c9dc))
23
+
5
24
  ### [0.1.123](https://github.com/spaced-out/ui-design-system/compare/v0.1.122...v0.1.123) (2024-08-26)
6
25
 
7
26
 
@@ -1,4 +1,4 @@
1
1
  // @flow strict
2
2
 
3
- export type {ChipProps} from './Chip';
3
+ export type {ChipProps, ChipSemanticType} from './Chip';
4
4
  export {Chip, CHIP_SEMANTIC} from './Chip';
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Rating = exports.RATING_SIZE = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _invariant = _interopRequireDefault(require("invariant"));
9
+ var _lodash = require("lodash");
10
+ var _classify = require("../../utils/classify");
11
+ var _rating = require("../../utils/rating");
12
+ var _Button = require("../Button");
13
+ var _Chip = require("../Chip");
14
+ var _ConditionalWrapper = require("../ConditionalWrapper");
15
+ var _Icon = require("../Icon");
16
+ var _Text = require("../Text");
17
+ var _RatingModule = _interopRequireDefault(require("./Rating.module.css"));
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ const RATING_SIZE = Object.freeze({
23
+ small: 'small',
24
+ medium: 'medium'
25
+ });
26
+ exports.RATING_SIZE = RATING_SIZE;
27
+ const Rating = /*#__PURE__*/React.forwardRef((_ref, ref) => {
28
+ let {
29
+ size = 'medium',
30
+ start = 0,
31
+ end = 5,
32
+ quiet,
33
+ rating = 0,
34
+ labels = _rating.RATINGS,
35
+ onChange,
36
+ readOnly,
37
+ hideLabel,
38
+ iconName = 'star',
39
+ iconColor = _Text.TEXT_COLORS.favorite,
40
+ chipSemantic = _Chip.CHIP_SEMANTIC.warning,
41
+ classNames
42
+ } = _ref;
43
+ const [hoverIcon, setHoverIcon] = React.useState(-1);
44
+ const chipText = (0, _rating.getRatingLabel)(rating - start, labels);
45
+ const totalIcons = end - start;
46
+ (0, _invariant.default)(totalIcons, JSON.stringify(_rating.RATING_ERRORS.INVALID_RANGE));
47
+ (0, _invariant.default)((0, _lodash.isUndefined)(labels) || (0, _lodash.isArray)(labels) && labels.length, JSON.stringify(_rating.RATING_ERRORS.INVALID_RATING_LABELS));
48
+ return /*#__PURE__*/React.createElement("div", {
49
+ "data-testid": "Rating",
50
+ ref: ref,
51
+ className: (0, _classify.classify)(_RatingModule.default.ratingContainer, classNames?.wrapper)
52
+ }, /*#__PURE__*/React.createElement("div", {
53
+ className: _RatingModule.default.stars
54
+ }, Array.from({
55
+ length: totalIcons
56
+ }).map((_, index) => {
57
+ const isHovering = hoverIcon > -1;
58
+ const iconCount = index + 1;
59
+ const iconType = (isHovering ? iconCount <= hoverIcon : iconCount <= rating - start) ? 'solid' : 'regular';
60
+ return /*#__PURE__*/React.createElement(_ConditionalWrapper.ConditionalWrapper, {
61
+ key: iconCount,
62
+ condition: !readOnly,
63
+ wrapper: children => /*#__PURE__*/React.createElement(_Button.UnstyledButton, {
64
+ onKeyDown: e => {
65
+ if (e.key === 'Enter') {
66
+ onChange?.(start + iconCount, e);
67
+ }
68
+ },
69
+ onFocus: () => !quiet && setHoverIcon(iconCount),
70
+ className: (0, _classify.classify)(_RatingModule.default.button, classNames?.button),
71
+ onClick: e => onChange?.(start + iconCount, e),
72
+ onMouseEnter: () => !quiet && setHoverIcon(iconCount),
73
+ onMouseLeave: () => !quiet && setHoverIcon(-1)
74
+ }, children)
75
+ }, /*#__PURE__*/React.createElement(_Icon.Icon, {
76
+ size: size,
77
+ name: iconName,
78
+ type: iconType,
79
+ color: iconColor,
80
+ className: (0, _classify.classify)(_RatingModule.default.icon, classNames?.icon)
81
+ }));
82
+ })), !hideLabel &&
83
+ /*#__PURE__*/
84
+ // $FlowFixMe[incompatible-type]
85
+ React.createElement(_Chip.Chip, {
86
+ size: size,
87
+ semantic: chipSemantic
88
+ }, chipText));
89
+ });
90
+ exports.Rating = Rating;
@@ -0,0 +1,133 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+ import invariant from 'invariant';
5
+ import {isArray, isUndefined} from 'lodash';
6
+
7
+ import type {ColorTypes} from '../../types/typography';
8
+ import {classify} from '../../utils/classify';
9
+ import {getRatingLabel, RATING_ERRORS, RATINGS} from '../../utils/rating';
10
+ import {UnstyledButton} from '../Button';
11
+ import type {ChipSemanticType} from '../Chip';
12
+ import {Chip, CHIP_SEMANTIC} from '../Chip';
13
+ import {ConditionalWrapper} from '../ConditionalWrapper';
14
+ import {Icon} from '../Icon';
15
+ import {TEXT_COLORS} from '../Text';
16
+
17
+ import css from './Rating.module.css';
18
+
19
+
20
+ export const RATING_SIZE = Object.freeze({
21
+ small: 'small',
22
+ medium: 'medium',
23
+ });
24
+
25
+ type ClassNames = $ReadOnly<{wrapper?: string, icon?: string, button?: string}>;
26
+ type RatingSize = $Values<typeof RATING_SIZE>;
27
+
28
+ export type RatingProps = {
29
+ size?: RatingSize,
30
+ start?: number,
31
+ end?: number,
32
+ quiet?: boolean,
33
+ rating?: number,
34
+ labels?: Array<string>,
35
+ iconColor?: ColorTypes,
36
+ onChange?: (rating: number, ?SyntheticEvent<HTMLElement>) => mixed,
37
+ readOnly?: boolean,
38
+ hideLabel?: boolean,
39
+ iconName?: string,
40
+ classNames?: ClassNames,
41
+ chipSemantic?: ChipSemanticType,
42
+ };
43
+
44
+ export const Rating: React$AbstractComponent<RatingProps, HTMLDivElement> =
45
+ React.forwardRef<RatingProps, HTMLDivElement>(
46
+ (
47
+ {
48
+ size = 'medium',
49
+ start = 0,
50
+ end = 5,
51
+ quiet,
52
+ rating = 0,
53
+ labels = RATINGS,
54
+ onChange,
55
+ readOnly,
56
+ hideLabel,
57
+ iconName = 'star',
58
+ iconColor = TEXT_COLORS.favorite,
59
+ chipSemantic = CHIP_SEMANTIC.warning,
60
+ classNames,
61
+ }: RatingProps,
62
+ ref,
63
+ ): React.Node => {
64
+ const [hoverIcon, setHoverIcon] = React.useState<number>(-1);
65
+ const chipText = getRatingLabel(rating - start, labels);
66
+ const totalIcons = end - start;
67
+
68
+ invariant(totalIcons, JSON.stringify(RATING_ERRORS.INVALID_RANGE));
69
+ invariant(
70
+ isUndefined(labels) || (isArray(labels) && labels.length),
71
+ JSON.stringify(RATING_ERRORS.INVALID_RATING_LABELS),
72
+ );
73
+
74
+ return (
75
+ <div
76
+ data-testid="Rating"
77
+ ref={ref}
78
+ className={classify(css.ratingContainer, classNames?.wrapper)}
79
+ >
80
+ <div className={css.stars}>
81
+ {Array.from({length: totalIcons}).map((_, index) => {
82
+ const isHovering = hoverIcon > -1;
83
+ const iconCount = index + 1;
84
+ const iconType = (
85
+ isHovering
86
+ ? iconCount <= hoverIcon
87
+ : iconCount <= rating - start
88
+ )
89
+ ? 'solid'
90
+ : 'regular';
91
+
92
+ return (
93
+ <ConditionalWrapper
94
+ key={iconCount}
95
+ condition={!readOnly}
96
+ wrapper={(children) => (
97
+ <UnstyledButton
98
+ onKeyDown={(e) => {
99
+ if (e.key === 'Enter') {
100
+ onChange?.(start + iconCount, e);
101
+ }
102
+ }}
103
+ onFocus={() => !quiet && setHoverIcon(iconCount)}
104
+ className={classify(css.button, classNames?.button)}
105
+ onClick={(e) => onChange?.(start + iconCount, e)}
106
+ onMouseEnter={() => !quiet && setHoverIcon(iconCount)}
107
+ onMouseLeave={() => !quiet && setHoverIcon(-1)}
108
+ >
109
+ {children}
110
+ </UnstyledButton>
111
+ )}
112
+ >
113
+ <Icon
114
+ size={size}
115
+ name={iconName}
116
+ type={iconType}
117
+ color={iconColor}
118
+ className={classify(css.icon, classNames?.icon)}
119
+ />
120
+ </ConditionalWrapper>
121
+ );
122
+ })}
123
+ </div>
124
+ {!hideLabel && (
125
+ // $FlowFixMe[incompatible-type]
126
+ <Chip size={size} semantic={chipSemantic}>
127
+ {chipText}
128
+ </Chip>
129
+ )}
130
+ </div>
131
+ );
132
+ },
133
+ );
@@ -0,0 +1,41 @@
1
+ @value (
2
+ spaceNone,
3
+ spaceXSmall,
4
+ spaceXXSmall
5
+ ) from '../../styles/variables/_space.css';
6
+ @value (
7
+ colorFocusPrimary
8
+ ) from '../../styles/variables/_color.css';
9
+ @value (
10
+ borderRadiusXSmall,
11
+ borderWidthNone,
12
+ borderWidthTertiary
13
+ ) from '../../styles/variables/_border.css';
14
+
15
+ .ratingContainer {
16
+ width: fit-content;
17
+ display: flex;
18
+ align-items: center;
19
+ gap: spaceXSmall;
20
+ margin: spaceXXSmall spaceXSmall;
21
+ }
22
+
23
+ .stars {
24
+ display: flex;
25
+ }
26
+
27
+ .icon {
28
+ composes: motionEaseInEaseOut from '../../styles/animation.module.css';
29
+ margin: spaceNone spaceXXSmall;
30
+ }
31
+
32
+ .button {
33
+ border-radius: borderRadiusXSmall;
34
+ outline: none;
35
+ cursor: pointer;
36
+ }
37
+
38
+ .button:focus {
39
+ box-shadow: borderWidthNone borderWidthNone borderWidthNone
40
+ borderWidthTertiary colorFocusPrimary;
41
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _Rating = require("./Rating");
7
+ Object.keys(_Rating).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Rating[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Rating[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './Rating';
@@ -205,10 +205,12 @@ const SideMenuLink = /*#__PURE__*/React.forwardRef((_ref, ref) => {
205
205
  condition: to !== undefined,
206
206
  wrapper: children => /*#__PURE__*/React.createElement(_Link.Link, {
207
207
  to: to,
208
- tabIndex: -1,
208
+ tabIndex: disabled ? -1 : 0,
209
209
  linkComponent: LinkComponent,
210
- onClick: e => e.preventDefault(),
211
- className: _SideMenuLinkModule.default.linkComponent
210
+ className: (0, _classify.default)(_SideMenuLinkModule.default.linkComponent, {
211
+ [_SideMenuLinkModule.default.closed]: !opened
212
+ }),
213
+ onClick: onChangeHandler
212
214
  }, children)
213
215
  }, /*#__PURE__*/React.createElement(_ConditionalWrapper.ConditionalWrapper, {
214
216
  condition: Boolean(!opened && !inActive),
@@ -224,7 +226,7 @@ const SideMenuLink = /*#__PURE__*/React.forwardRef((_ref, ref) => {
224
226
  }, classNames?.wrapper),
225
227
  onClick: onChangeHandler,
226
228
  ref: ref,
227
- tabIndex: disabled ? -1 : tabIndex,
229
+ tabIndex: disabled || to !== undefined ? -1 : tabIndex,
228
230
  disabled: disabled,
229
231
  key: pageNameKey
230
232
  }), pageNameKey && MENU_NAME_LIST[pageNameKey] ? /*#__PURE__*/React.createElement(_Icon.Icon, {
@@ -232,10 +232,12 @@ export const SideMenuLink: React$AbstractComponent<
232
232
  wrapper={(children) => (
233
233
  <Link
234
234
  to={to}
235
- tabIndex={-1}
235
+ tabIndex={disabled ? -1 : 0}
236
236
  linkComponent={LinkComponent}
237
- onClick={(e) => e.preventDefault()}
238
- className={css.linkComponent}
237
+ className={classify(css.linkComponent, {
238
+ [css.closed]: !opened,
239
+ })}
240
+ onClick={onChangeHandler}
239
241
  >
240
242
  {children}
241
243
  </Link>
@@ -263,7 +265,7 @@ export const SideMenuLink: React$AbstractComponent<
263
265
  )}
264
266
  onClick={onChangeHandler}
265
267
  ref={ref}
266
- tabIndex={disabled ? -1 : tabIndex}
268
+ tabIndex={disabled || to !== undefined ? -1 : tabIndex}
267
269
  disabled={disabled}
268
270
  key={pageNameKey}
269
271
  >
@@ -68,6 +68,19 @@
68
68
  text-decoration: none;
69
69
  }
70
70
 
71
+ .linkComponent.closed {
72
+ width: size32;
73
+ min-width: size32;
74
+ justify-content: center;
75
+ }
76
+
77
+ .linkComponent:focus-visible {
78
+ border-radius: borderRadiusSmall;
79
+ outline: none;
80
+ box-shadow: borderWidthNone borderWidthNone borderWidthNone
81
+ borderWidthTertiary colorFocusPrimary;
82
+ }
83
+
71
84
  .linkWrapper.selected {
72
85
  background: colorSideMenuBackgroundSelected;
73
86
  color: colorTextInversePrimary;
@@ -113,6 +113,17 @@ Object.keys(_mergeRefs).forEach(function (key) {
113
113
  }
114
114
  });
115
115
  });
116
+ var _rating = require("./rating");
117
+ Object.keys(_rating).forEach(function (key) {
118
+ if (key === "default" || key === "__esModule") return;
119
+ if (key in exports && exports[key] === _rating[key]) return;
120
+ Object.defineProperty(exports, key, {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _rating[key];
124
+ }
125
+ });
126
+ });
116
127
  var _string = require("./string");
117
128
  Object.keys(_string).forEach(function (key) {
118
129
  if (key === "default" || key === "__esModule") return;
@@ -10,5 +10,6 @@ export * from './helpers';
10
10
  export * from './makeClassNameComponent';
11
11
  export * from './menu';
12
12
  export * from './merge-refs';
13
+ export * from './rating';
13
14
  export * from './string';
14
15
  export * from './tokens';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _rating = require("./rating");
7
+ Object.keys(_rating).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _rating[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _rating[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './rating';
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getRatingLabel = exports.RATING_ERRORS = exports.RATINGS = void 0;
7
+
8
+ const RATING_ERRORS = Object.freeze({
9
+ INVALID_RANGE: {
10
+ type: 'INVALID_RANGE',
11
+ description: 'Given rating\'s stop value cannot come before the start value.'
12
+ },
13
+ INVALID_RATING_LABELS: {
14
+ type: 'INVALID_RATING_LABELS',
15
+ description: 'Given rating labels are invalid.'
16
+ }
17
+ });
18
+ exports.RATING_ERRORS = RATING_ERRORS;
19
+ const RATINGS = ['Not-Qualified', 'Proficient', 'Silver', 'Gold', 'Platinum', 'Diamond'];
20
+ exports.RATINGS = RATINGS;
21
+ const getRatingLabel = (rating, labels) => {
22
+ if (rating <= 0) {
23
+ return labels[0];
24
+ } else if (rating >= labels.length) {
25
+ return labels.slice(-1)[0];
26
+ } else {
27
+ return labels[rating];
28
+ }
29
+ };
30
+ exports.getRatingLabel = getRatingLabel;
@@ -0,0 +1,35 @@
1
+ // @flow strict
2
+
3
+ export const RATING_ERRORS = Object.freeze({
4
+ INVALID_RANGE: {
5
+ type: 'INVALID_RANGE',
6
+ description:
7
+ 'Given rating\'s stop value cannot come before the start value.',
8
+ },
9
+ INVALID_RATING_LABELS: {
10
+ type: 'INVALID_RATING_LABELS',
11
+ description: 'Given rating labels are invalid.',
12
+ },
13
+ });
14
+
15
+ export const RATINGS: Array<string> = [
16
+ 'Not-Qualified',
17
+ 'Proficient',
18
+ 'Silver',
19
+ 'Gold',
20
+ 'Platinum',
21
+ 'Diamond',
22
+ ];
23
+
24
+ export const getRatingLabel = (
25
+ rating: number,
26
+ labels: Array<string>,
27
+ ): string => {
28
+ if (rating <= 0) {
29
+ return labels[0];
30
+ } else if (rating >= labels.length) {
31
+ return labels.slice(-1)[0];
32
+ } else {
33
+ return labels[rating];
34
+ }
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.123",
3
+ "version": "0.1.125",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {