@automattic/vip-design-system 2.12.7 → 2.13.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.
@@ -14,5 +14,6 @@ export interface CardProps {
14
14
  renderHeader?: (title?: string) => React.ReactNode;
15
15
  bodyStyles?: ThemeUIStyleObject;
16
16
  headerStyles?: ThemeUIStyleObject;
17
+ hideBody?: boolean;
17
18
  }
18
19
  export declare const Card: import("react").ForwardRefExoticComponent<CardProps & BoxProps & import("react").RefAttributes<HTMLElement>>;
@@ -1,4 +1,4 @@
1
- var _excluded = ["variant", "title", "renderHeader", "bodyStyles", "headerStyles", "children"];
1
+ var _excluded = ["variant", "title", "renderHeader", "bodyStyles", "headerStyles", "children", "hideBody"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
4
  /** @jsxImportSource theme-ui */
@@ -28,6 +28,8 @@ export var Card = /*#__PURE__*/forwardRef(function (_ref, ref) {
28
28
  bodyStyles = _ref.bodyStyles,
29
29
  headerStyles = _ref.headerStyles,
30
30
  children = _ref.children,
31
+ _ref$hideBody = _ref.hideBody,
32
+ hideBody = _ref$hideBody === void 0 ? false : _ref$hideBody,
31
33
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
32
34
  return _jsxs(Box, _extends({
33
35
  ref: ref,
@@ -42,7 +44,7 @@ export var Card = /*#__PURE__*/forwardRef(function (_ref, ref) {
42
44
  variant: "cards." + variant + ".header"
43
45
  }, headerStyles),
44
46
  children: title
45
- }), _jsx(Box, {
47
+ }), !hideBody && _jsx(Box, {
46
48
  className: "vip-card-body-component",
47
49
  sx: _extends({
48
50
  variant: "cards." + variant + ".children"
@@ -162,23 +162,6 @@ export var Menu = {
162
162
  href: "https://dashboard.wpvip.com/",
163
163
  children: "Slow Query"
164
164
  })]
165
- }), _jsxs(NavItem.MenuGroup, {
166
- label: "Clickable Parent Navigation Item",
167
- renderIcon: function renderIcon(size) {
168
- return _jsx(BiHistory, {
169
- size: size
170
- });
171
- },
172
- parentHref: "https://random-website.com/",
173
- children: [_jsx(NavItem.Menu, {
174
- as: CustomLink,
175
- href: "https://google.com/",
176
- children: "Test"
177
- }), _jsx(NavItem.Menu, {
178
- as: CustomLink,
179
- href: "https://wpvip.com/",
180
- children: "Item"
181
- })]
182
165
  }), _jsxs(NavItem.MenuGroup, {
183
166
  label: "Performance",
184
167
  renderIcon: function renderIcon(size) {
@@ -5,7 +5,6 @@ export interface NavItemGroupProps extends NavItemBaseProps {
5
5
  renderIcon?: NavItemRenderIconProp;
6
6
  activeChildren?: boolean;
7
7
  label: string;
8
- parentHref?: string;
9
8
  }
10
9
  export declare const IconContainer: ({ children }: {
11
10
  children: React.ReactNode;
@@ -21,8 +21,7 @@ var NavItemGroupBase = /*#__PURE__*/forwardRef(function (_ref, ref) {
21
21
  activeChildren = _ref.activeChildren,
22
22
  renderIcon = _ref.renderIcon,
23
23
  children = _ref.children,
24
- sx = _ref.sx,
25
- parentHref = _ref.parentHref;
24
+ sx = _ref.sx;
26
25
  var _useState = useState(active),
27
26
  isExpanded = _useState[0],
28
27
  setIsExpanded = _useState[1];
@@ -39,30 +38,16 @@ var NavItemGroupBase = /*#__PURE__*/forwardRef(function (_ref, ref) {
39
38
  onOpenChange: handleExpand,
40
39
  children: [_jsx(Collapsible.Trigger, {
41
40
  asChild: true,
42
- children: _jsxs("div", {
43
- role: "button",
44
- tabIndex: 0,
45
- "aria-haspopup": "true",
41
+ children: _jsxs("button", {
42
+ type: "button",
43
+ "aria-haspopup": true,
46
44
  "data-active": active || undefined,
47
45
  "data-open": isExpanded || undefined,
48
46
  "data-active-children": activeChildren || undefined,
49
47
  sx: _extends({}, navItemLinkVariantStyles(variant), navItemGroupTriggerStyles),
50
48
  children: [renderIcon ? _jsx(IconContainer, {
51
49
  children: renderIcon(NAV_ITEM_ICON_SIZE)
52
- }) : null, parentHref ? _jsx("a", {
53
- href: parentHref,
54
- sx: {
55
- textDecoration: 'none',
56
- color: 'inherit',
57
- '&:hover': {
58
- textDecoration: 'none'
59
- }
60
- },
61
- onClick: function onClick(e) {
62
- return e.stopPropagation();
63
- },
64
- children: label
65
- }) : label, _jsx(BiChevronDown, {
50
+ }) : null, label, _jsx(BiChevronDown, {
66
51
  "data-arrow-indicator": true,
67
52
  "aria-hidden": "true",
68
53
  size: NAV_ITEM_ICON_SIZE,
@@ -1,6 +1,12 @@
1
1
  /** @jsxImportSource theme-ui */
2
2
  import React from 'react';
3
3
  import { ThemeUIStyleObject } from 'theme-ui';
4
+ type ColorVariants = 'warning' | 'error' | 'alert' | 'success' | 'info';
5
+ type CollapsibleProps = {
6
+ collapsible?: boolean;
7
+ defaultOpen?: boolean;
8
+ ariaContentId?: string;
9
+ };
4
10
  export type NoticeProps = React.HTMLAttributes<HTMLDivElement> & {
5
11
  children: React.ReactNode;
6
12
  inline?: boolean;
@@ -9,8 +15,7 @@ export type NoticeProps = React.HTMLAttributes<HTMLDivElement> & {
9
15
  variant?: ColorVariants;
10
16
  headingVariant?: React.ElementType;
11
17
  className?: string;
12
- };
13
- type ColorVariants = 'warning' | 'error' | 'alert' | 'success' | 'info';
18
+ } & CollapsibleProps;
14
19
  export declare const Notice: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
15
20
  children: React.ReactNode;
16
21
  inline?: boolean | undefined;
@@ -19,5 +24,5 @@ export declare const Notice: React.ForwardRefExoticComponent<React.HTMLAttribute
19
24
  variant?: ColorVariants | undefined;
20
25
  headingVariant?: React.ElementType<any> | undefined;
21
26
  className?: string | undefined;
22
- } & React.RefAttributes<HTMLDivElement>>;
27
+ } & CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
23
28
  export {};
@@ -1,4 +1,4 @@
1
- var _excluded = ["children", "className", "headingVariant", "inline", "sx", "title", "variant"];
1
+ var _excluded = ["children", "className", "headingVariant", "inline", "sx", "title", "variant", "collapsible", "defaultOpen"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
4
  /** @jsxImportSource theme-ui */
@@ -6,13 +6,15 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
6
6
  /**
7
7
  * External dependencies
8
8
  */
9
+ import * as Collapsible from '@radix-ui/react-collapsible';
9
10
  import classNames from 'classnames';
10
- import React from 'react';
11
+ import React, { useState, useId } from 'react';
12
+ import { BiChevronDown, BiChevronUp } from 'react-icons/bi';
11
13
  import { MdError, MdWarning, MdCheckCircle, MdInfo } from 'react-icons/md';
12
14
  /**
13
15
  * Internal dependencies
14
16
  */
15
- import { Box, Flex, Heading, Card } from '../';
17
+ import { Box, Flex, Heading, Card, Button } from '../';
16
18
  import { jsx as _jsx } from "theme-ui/jsx-runtime";
17
19
  import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
18
20
  var NoticeIcon = function NoticeIcon(_ref) {
@@ -64,35 +66,143 @@ export var Notice = /*#__PURE__*/React.forwardRef(function (_ref2, forwardRef) {
64
66
  title = _ref2.title,
65
67
  _ref2$variant = _ref2.variant,
66
68
  variant = _ref2$variant === void 0 ? 'warning' : _ref2$variant,
69
+ _ref2$collapsible = _ref2.collapsible,
70
+ collapsible = _ref2$collapsible === void 0 ? false : _ref2$collapsible,
71
+ _ref2$defaultOpen = _ref2.defaultOpen,
72
+ defaultOpen = _ref2$defaultOpen === void 0 ? false : _ref2$defaultOpen,
67
73
  props = _objectWithoutPropertiesLoose(_ref2, _excluded);
68
- return _jsxs(Card, _extends({
69
- variant: "notice",
70
- sx: _extends({
71
- boxShadow: 'none',
72
- borderRadius: 2,
73
- bg: inline ? 'transparent' : "notice.background." + variant,
74
- color: "notice.text." + variant,
75
- fontSize: 2,
76
- p: {
77
- color: "notice.text." + variant,
78
- fontSize: 2
74
+ var _useState = useState(defaultOpen),
75
+ isExpanded = _useState[0],
76
+ setIsExpanded = _useState[1];
77
+ var handleExpand = function handleExpand(openValue) {
78
+ return setIsExpanded(openValue);
79
+ };
80
+ var ChevronIcon = isExpanded ? BiChevronUp : BiChevronDown;
81
+ var contentId = useId();
82
+ var iconColor = "notice.icon." + variant;
83
+ var textColor = "notice.text." + variant;
84
+ var baseCardSx = _extends({
85
+ boxShadow: 'none',
86
+ borderRadius: 2,
87
+ bg: inline || collapsible ? 'transparent' : "notice.background." + variant,
88
+ color: textColor,
89
+ fontSize: 2,
90
+ p: {
91
+ color: textColor,
92
+ fontSize: 2
93
+ },
94
+ a: {
95
+ color: "notice.link." + variant + ".default",
96
+ '&:visited': {
97
+ color: "notice.link." + variant + ".visited"
79
98
  },
80
- a: {
81
- color: "notice.link." + variant + ".default",
82
- '&:visited': {
83
- color: "notice.link." + variant + ".visited"
84
- },
85
- '&:active': {
86
- color: "notice.link." + variant + ".active"
87
- },
88
- '&:hover, &:focus': {
89
- color: "notice.link." + variant + ".hover"
90
- }
99
+ '&:active': {
100
+ color: "notice.link." + variant + ".active"
91
101
  },
92
- ul: {
93
- pl: 5
102
+ '&:hover, &:focus': {
103
+ color: "notice.link." + variant + ".hover"
94
104
  }
95
- }, sx),
105
+ },
106
+ ul: {
107
+ pl: 5
108
+ }
109
+ }, sx);
110
+ if (collapsible) {
111
+ var renderHeader = function renderHeader() {
112
+ return _jsx(Collapsible.Trigger, {
113
+ asChild: true,
114
+ "aria-expanded": isExpanded,
115
+ "aria-controls": contentId,
116
+ children: _jsxs(Button, {
117
+ variant: "text",
118
+ sx: {
119
+ border: 'none',
120
+ width: '100%',
121
+ display: 'flex',
122
+ alignItems: 'center',
123
+ justifyContent: 'space-between',
124
+ cursor: 'pointer',
125
+ bg: "notice.background." + variant,
126
+ '&:hover, &:focus': {
127
+ bg: "notice.background." + variant,
128
+ boxShadow: 'none',
129
+ transform: 'none',
130
+ border: 'none'
131
+ },
132
+ px: 3,
133
+ py: 2,
134
+ borderBottomLeftRadius: '0 !important',
135
+ borderBottomRightRadius: '0 !important'
136
+ },
137
+ children: [_jsxs(Flex, {
138
+ sx: {
139
+ alignItems: 'center',
140
+ gap: 2
141
+ },
142
+ children: [_jsx(NoticeIcon, {
143
+ color: iconColor,
144
+ variant: variant
145
+ }), _jsx(Heading, {
146
+ as: headingVariant,
147
+ id: contentId + "-heading",
148
+ sx: {
149
+ color: textColor,
150
+ fontSize: 2,
151
+ fontWeight: 'bold',
152
+ my: 2,
153
+ mx: 3
154
+ },
155
+ children: title
156
+ })]
157
+ }), _jsx(ChevronIcon, {
158
+ size: 32,
159
+ sx: {
160
+ color: 'icon.primary'
161
+ },
162
+ "data-arrow-indicator": true,
163
+ "aria-hidden": "true"
164
+ })]
165
+ })
166
+ });
167
+ };
168
+ return _jsx(Collapsible.Root, {
169
+ defaultOpen: defaultOpen,
170
+ onOpenChange: handleExpand,
171
+ "data-active": defaultOpen || undefined,
172
+ children: _jsx(Card, _extends({
173
+ variant: "notice",
174
+ hideBody: !isExpanded,
175
+ renderHeader: renderHeader,
176
+ bodyStyles: {
177
+ border: '2px solid',
178
+ borderColor: "notice.background." + variant,
179
+ borderTop: 'none',
180
+ borderBottomLeftRadius: 2,
181
+ borderBottomRightRadius: 2,
182
+ px: 4,
183
+ py: 3
184
+ },
185
+ sx: _extends({}, baseCardSx, {
186
+ border: 'none',
187
+ overflow: 'hidden'
188
+ }),
189
+ className: classNames('vip-notice-component', className)
190
+ }, props, {
191
+ ref: forwardRef,
192
+ children: _jsx(Collapsible.Content, {
193
+ id: contentId,
194
+ sx: {
195
+ mx: 2,
196
+ my: 2
197
+ },
198
+ children: children
199
+ })
200
+ }))
201
+ });
202
+ }
203
+ return _jsxs(Card, _extends({
204
+ variant: "notice",
205
+ sx: baseCardSx,
96
206
  className: classNames('vip-notice-component', className),
97
207
  ref: forwardRef
98
208
  }, props, {
@@ -116,7 +226,7 @@ export var Notice = /*#__PURE__*/React.forwardRef(function (_ref2, forwardRef) {
116
226
  flex: '1 100%' // we need this empty div to make the icon align to the bottom
117
227
  }
118
228
  }), _jsx(NoticeIcon, {
119
- color: "notice.icon." + variant,
229
+ color: iconColor,
120
230
  variant: variant
121
231
  })]
122
232
  })
@@ -124,7 +234,7 @@ export var Notice = /*#__PURE__*/React.forwardRef(function (_ref2, forwardRef) {
124
234
  children: [title && _jsx(Heading, {
125
235
  as: headingVariant,
126
236
  sx: {
127
- color: "notice.text." + variant,
237
+ color: textColor,
128
238
  mb: 0,
129
239
  fontSize: 2,
130
240
  fontWeight: 'bold'
@@ -16,6 +16,10 @@ declare const _default: {
16
16
  variant?: ("alert" | "error" | "success" | "warning" | "info") | undefined;
17
17
  headingVariant?: React.ElementType<any> | undefined;
18
18
  className?: string | undefined;
19
+ } & {
20
+ collapsible?: boolean | undefined;
21
+ defaultOpen?: boolean | undefined;
22
+ ariaContentId?: string | undefined;
19
23
  } & React.RefAttributes<HTMLDivElement>>;
20
24
  };
21
25
  export default _default;
@@ -144,11 +144,25 @@ export var Default = function Default() {
144
144
  href: "/?path=/story/avatar--default",
145
145
  children: "A link to Avatar"
146
146
  })]
147
+ }), _jsxs(Notice, {
148
+ variant: "success",
149
+ sx: {
150
+ mb: 4
151
+ },
152
+ title: "Collapsible Notice",
153
+ collapsible: true,
154
+ children: ["Bucket names in Amazon S3 are globally unique.", ' ', _jsx(Link, {
155
+ href: "/?path=/story/avatar--default",
156
+ children: "A link to Avatar"
157
+ })]
147
158
  }), _jsx(Notice, {
148
159
  variant: "info",
149
160
  sx: {
150
161
  mb: 4
151
162
  },
163
+ title: "Collapsible Notice Auto-Expanded",
164
+ collapsible: true,
165
+ defaultOpen: true,
152
166
  children: "Bucket names in Amazon S3 are globally unique."
153
167
  })]
154
168
  });
@@ -41,7 +41,7 @@
41
41
  "input": {
42
42
  "background": {
43
43
  "default": {
44
- "value": "#1b191800",
44
+ "value": "#13191e00",
45
45
  "type": "color",
46
46
  "description": "Use for input backgrounds"
47
47
  },
@@ -403,7 +403,7 @@
403
403
  "value": "#4c4948"
404
404
  },
405
405
  "disabled": {
406
- "value": "#00000000",
406
+ "value": "#13191e00",
407
407
  "type": "color"
408
408
  }
409
409
  },
@@ -439,7 +439,7 @@
439
439
  "ghost": {
440
440
  "background": {
441
441
  "default": {
442
- "value": "#00000000",
442
+ "value": "#13191e00",
443
443
  "type": "color"
444
444
  },
445
445
  "hover": {
@@ -620,6 +620,14 @@
620
620
  "success": {
621
621
  "type": "color",
622
622
  "value": "#00611e"
623
+ },
624
+ "neutral": {
625
+ "type": "color",
626
+ "value": "#ffffff"
627
+ },
628
+ "feature": {
629
+ "type": "color",
630
+ "value": "#ffffff"
623
631
  }
624
632
  },
625
633
  "text": {
@@ -638,6 +646,14 @@
638
646
  "success": {
639
647
  "type": "color",
640
648
  "value": "#d7efdf"
649
+ },
650
+ "neutral": {
651
+ "type": "color",
652
+ "value": "#e3e0df"
653
+ },
654
+ "feature": {
655
+ "type": "color",
656
+ "value": "#ffffff"
641
657
  }
642
658
  },
643
659
  "icon": {
@@ -656,6 +672,14 @@
656
672
  "success": {
657
673
  "type": "color",
658
674
  "value": "#40ba6f"
675
+ },
676
+ "neutral": {
677
+ "type": "color",
678
+ "value": "#827f7e"
679
+ },
680
+ "feature": {
681
+ "type": "color",
682
+ "value": "#8c00ffff"
659
683
  }
660
684
  },
661
685
  "accent": {
@@ -674,6 +698,14 @@
674
698
  "success": {
675
699
  "type": "color",
676
700
  "value": "#40ba6f"
701
+ },
702
+ "neutral": {
703
+ "type": "color",
704
+ "value": "#827f7e"
705
+ },
706
+ "feature": {
707
+ "type": "color",
708
+ "value": "#8c00ffff"
677
709
  }
678
710
  },
679
711
  "link": {
@@ -752,6 +784,25 @@
752
784
  "type": "color",
753
785
  "value": "#89daa0"
754
786
  }
787
+ },
788
+ "neutral": {
789
+ "default": {
790
+ "type": "color",
791
+ "value": "#e3e0df",
792
+ "description": "Use for text links"
793
+ },
794
+ "hover": {
795
+ "type": "color",
796
+ "value": "#9b9796"
797
+ },
798
+ "active": {
799
+ "type": "color",
800
+ "value": "#9b9796"
801
+ },
802
+ "visited": {
803
+ "type": "color",
804
+ "value": "#d7d4d3"
805
+ }
755
806
  }
756
807
  },
757
808
  "helper-text": {
@@ -3649,6 +3700,116 @@
3649
3700
  "value": "#000800",
3650
3701
  "type": "color"
3651
3702
  }
3703
+ },
3704
+ "purple": {
3705
+ "0": {
3706
+ "value": "#faf5ffff",
3707
+ "type": "color"
3708
+ },
3709
+ "3": {
3710
+ "value": "#f1e0ffff",
3711
+ "type": "color"
3712
+ },
3713
+ "7": {
3714
+ "value": "#e8ccffff",
3715
+ "type": "color"
3716
+ },
3717
+ "10": {
3718
+ "value": "#dfb8ffff",
3719
+ "type": "color"
3720
+ },
3721
+ "15": {
3722
+ "value": "#d5a3ffff",
3723
+ "type": "color"
3724
+ },
3725
+ "20": {
3726
+ "value": "#cc8fffff",
3727
+ "type": "color"
3728
+ },
3729
+ "25": {
3730
+ "value": "#c37affff",
3731
+ "type": "color"
3732
+ },
3733
+ "30": {
3734
+ "value": "#ba66ffff",
3735
+ "type": "color"
3736
+ },
3737
+ "35": {
3738
+ "value": "#b052ffff",
3739
+ "type": "color"
3740
+ },
3741
+ "40": {
3742
+ "value": "#a73dffff",
3743
+ "type": "color"
3744
+ },
3745
+ "45": {
3746
+ "value": "#9e29ffff",
3747
+ "type": "color"
3748
+ },
3749
+ "50": {
3750
+ "value": "#9514ffff",
3751
+ "type": "color"
3752
+ },
3753
+ "55": {
3754
+ "value": "#8c00ffff",
3755
+ "type": "color"
3756
+ },
3757
+ "60": {
3758
+ "value": "#8000ebff",
3759
+ "type": "color"
3760
+ },
3761
+ "65": {
3762
+ "value": "#7500d6ff",
3763
+ "type": "color"
3764
+ },
3765
+ "70": {
3766
+ "value": "#6a00c2ff",
3767
+ "type": "color"
3768
+ },
3769
+ "73": {
3770
+ "value": "#5f00adff",
3771
+ "type": "color"
3772
+ },
3773
+ "75": {
3774
+ "value": "#540099ff",
3775
+ "type": "color"
3776
+ },
3777
+ "78": {
3778
+ "value": "#490085ff",
3779
+ "type": "color"
3780
+ },
3781
+ "80": {
3782
+ "value": "#3d0070ff",
3783
+ "type": "color"
3784
+ },
3785
+ "83": {
3786
+ "value": "#32005cff",
3787
+ "type": "color"
3788
+ },
3789
+ "85": {
3790
+ "value": "#270047ff",
3791
+ "type": "color"
3792
+ },
3793
+ "88": {
3794
+ "value": "#1c0033ff",
3795
+ "type": "color"
3796
+ },
3797
+ "90": {
3798
+ "value": "#11001fff",
3799
+ "type": "color"
3800
+ },
3801
+ "93": {
3802
+ "value": "#06000aff",
3803
+ "type": "color"
3804
+ },
3805
+ "95": {
3806
+ "value": "#050008ff",
3807
+ "type": "color"
3808
+ },
3809
+ "100": {
3810
+ "value": "#050008ff",
3811
+ "type": "color"
3812
+ }
3652
3813
  }
3653
3814
  },
3654
3815
  "breakpoint": {