@cloudflare/component-page 10.1.21 → 11.0.1

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/lib/Heading.js CHANGED
@@ -103,8 +103,6 @@ function Heading(_ref5) {
103
103
 
104
104
  return /*#__PURE__*/_react.default.createElement(Heading, _extends({
105
105
  role: role
106
- }, props, {
107
- "data-source-file": "@cloudflare/component-page:src/Heading.tsx:104"
108
- }));
106
+ }, props));
109
107
  });
110
108
  }
package/lib/Page.js CHANGED
@@ -9,8 +9,6 @@ exports.default = void 0;
9
9
 
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
 
12
- var _reactRouterDom = require("react-router-dom");
13
-
14
12
  var _styleContainer = require("@cloudflare/style-container");
15
13
 
16
14
  var _elements = require("@cloudflare/elements");
@@ -31,6 +29,8 @@ var _componentButton = require("@cloudflare/component-button");
31
29
 
32
30
  var _componentTooltip = require("@cloudflare/component-tooltip");
33
31
 
32
+ var _utilCl1CompatRouter = require("@cloudflare/util-cl1-compat-router");
33
+
34
34
  var _excluded = ["title", "parentPageLabel", "description", "documentationLabel", "documentationHref", "centerHeader", "beta", "testId", "className", "sidebar", "type", "sidebarPosition", "autofocus", "control", "titleRef", "parentPageLabelRef", "children", "navigation", "onDocumentationButtonClick", "documentationAsButton"];
35
35
 
36
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -69,68 +69,55 @@ var PageHeader = function PageHeader(_ref) {
69
69
  var titlesCount = Math.min([title, description].filter(Boolean).length, 2);
70
70
  var isMobile = (0, _utilResponsive.useIsMobile)();
71
71
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, navigation && !isMobile && /*#__PURE__*/_react.default.createElement(_elements.Div, {
72
- mb: 4,
73
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:72"
72
+ mb: 4
74
73
  }, navigation), /*#__PURE__*/_react.default.createElement(_elements.Div, {
75
74
  display: control ? ['block', 'flex'] : 'block',
76
75
  justifyContent: "space-between",
77
- mb: headerVisible ? 3 : 0,
78
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:73"
76
+ mb: headerVisible ? 3 : 0
79
77
  }, /*#__PURE__*/_react.default.createElement(_elements.Header, {
80
- textAlign: centerHeader ? 'center' : undefined,
81
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:78"
78
+ textAlign: centerHeader ? 'center' : undefined
82
79
  }, parentPageLabel && /*#__PURE__*/_react.default.createElement(_elements.P, {
83
80
  my: 0,
84
81
  lineHeight: 1.5,
85
82
  color: "gray.3",
86
83
  fontWeight: 600,
87
- innerRef: parentPageLabelRef,
88
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:80"
84
+ innerRef: parentPageLabelRef
89
85
  }, parentPageLabel), title && /*#__PURE__*/_react.default.createElement(_elements.Div, {
90
86
  display: "flex",
91
- alignItems: "center",
92
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:91"
87
+ alignItems: "center"
93
88
  }, /*#__PURE__*/_react.default.createElement(_Heading.Heading, {
94
89
  mt: 0,
95
90
  mb: 2,
96
- innerRef: titleRef,
97
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:92"
91
+ innerRef: titleRef
98
92
  }, isMobile && navigation && /*#__PURE__*/_react.default.isValidElement(navigation) && /*#__PURE__*/_react.default.createElement(_componentLink.Link, {
99
93
  mr: 2,
100
- onClick: navigation.props.onClick,
101
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:94"
94
+ onClick: navigation.props.onClick
102
95
  }, /*#__PURE__*/_react.default.createElement(_componentIcon.Icon, {
103
- type: "backward",
104
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:95"
96
+ type: "backward"
105
97
  })), title), beta && /*#__PURE__*/_react.default.createElement(_componentLabel.Label, {
106
98
  hue: "orange",
107
99
  mx: 2,
108
- verticalAlign: "middle",
109
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:101"
100
+ verticalAlign: "middle"
110
101
  }, /*#__PURE__*/_react.default.createElement(_intlReact.Trans, {
111
102
  _: "Beta",
112
- id: "common.beta",
113
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:102"
103
+ id: "common.beta"
114
104
  }))), description && /*#__PURE__*/_react.default.createElement(_elements.P, {
115
105
  color: "gray.3",
116
106
  mt: 0,
117
107
  mb: documentationHref ? 2 : 3,
118
108
  lineHeight: 1.25,
119
109
  fontWeight: 400,
120
- wordBreak: "break-word",
121
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:108"
110
+ wordBreak: "break-word"
122
111
  }, description), documentationAsButton && !isMobile ? /*#__PURE__*/_react.default.createElement(_componentTooltip.Tooltip, {
123
112
  place: "right",
124
113
  message: /*#__PURE__*/_react.default.createElement(_intlReact.Trans, {
125
114
  id: "common.open_documentation",
126
- _: 'Open documentation',
127
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:123"
115
+ _: 'Open documentation'
128
116
  }),
129
117
  Component: _elements.Span,
130
118
  buttonProps: {
131
119
  width: 'fit-content'
132
- },
133
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:120"
120
+ }
134
121
  }, /*#__PURE__*/_react.default.createElement(_componentButton.Button, {
135
122
  type: "primary",
136
123
  borderRadius: '20vh',
@@ -139,23 +126,19 @@ var PageHeader = function PageHeader(_ref) {
139
126
  onClick: onDocumentationButtonClick,
140
127
  px: 3,
141
128
  py: 1,
142
- ariaLabel: "open documentation - ".concat(documentationLabel),
143
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:131"
129
+ ariaLabel: "open documentation - ".concat(documentationLabel)
144
130
  }, documentationLabel)) : documentationHref && /*#__PURE__*/_react.default.createElement(_componentLink.DocumentationLink, {
145
131
  fontSize: 2,
146
132
  iconSize: 14,
147
133
  mb: [3, 0],
148
134
  href: documentationHref,
149
- display: "inline-block",
150
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:146"
135
+ display: "inline-block"
151
136
  }, documentationLabel ? documentationLabel : /*#__PURE__*/_react.default.createElement(_intlReact.Trans, {
152
137
  id: "common.documentation",
153
- _: 'Documentation',
154
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:156"
138
+ _: 'Documentation'
155
139
  }))), control), /*#__PURE__*/_react.default.createElement(_Heading.Section, {
156
140
  level: titlesCount,
157
- offset: maxPageTitles - titlesCount,
158
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:164"
141
+ offset: maxPageTitles - titlesCount
159
142
  }, children));
160
143
  };
161
144
 
@@ -206,21 +189,23 @@ var Page = function Page(_ref2) {
206
189
  documentationAsButton = _ref2.documentationAsButton,
207
190
  props = _objectWithoutProperties(_ref2, _excluded);
208
191
 
209
- var location = (0, _reactRouterDom.useLocation)();
210
192
  var skipTargetRef = (0, _react.useRef)(null);
211
- var path = location === null || location === void 0 ? void 0 : location.pathname;
193
+
194
+ var _useLocation = (0, _utilCl1CompatRouter.useLocation)(),
195
+ pathname = _useLocation.pathname;
196
+
212
197
  (0, _react.useEffect)(function () {
213
198
  // If autofocus is enabled, then focus will move to the title block when
214
199
  // the page is navigated to (but not when the dash is first loaded)
215
200
  if (autofocus) {
216
201
  if (!firstPage) {
217
- firstPage = path;
218
- } else if (firstPage !== path || !firstLoad) {
202
+ firstPage = pathname;
203
+ } else if (firstPage !== pathname || !firstLoad) {
219
204
  focus(skipTargetRef.current);
220
205
  firstLoad = false;
221
206
  }
222
207
  }
223
- }, [path]);
208
+ }, [pathname]);
224
209
  var sidebarInside = sidebarPosition === 'inside';
225
210
  return /*#__PURE__*/_react.default.createElement(_elements.Main, _extends({
226
211
  "data-testid": testId,
@@ -228,25 +213,20 @@ var Page = function Page(_ref2) {
228
213
  display: sidebar && sidebarInside ? undefined : 'flex',
229
214
  py: 4,
230
215
  mb: 4
231
- }, props, {
232
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:237"
233
- }), /*#__PURE__*/_react.default.createElement(_elements.Div, {
216
+ }, props), /*#__PURE__*/_react.default.createElement(_elements.Div, {
234
217
  ml: "auto",
235
218
  mr: sidebar && !sidebarInside ? 0 : 'auto',
236
219
  display: sidebar && sidebarInside ? ['block', 'block', 'flex'] : undefined,
237
220
  width: type === 'unbounded' ? '100%' : '90%',
238
- maxWidth: maxWidthByType[type] || maxWidthByType.narrow,
239
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:245"
221
+ maxWidth: maxWidthByType[type] || maxWidthByType.narrow
240
222
  }, /*#__PURE__*/_react.default.createElement(_elements.Div, {
241
223
  width: sidebar && sidebarInside ? [1, 1, 2 / 3] : undefined,
242
224
  pr: sidebar && sidebarInside ? [0, 0, 3] : undefined,
243
- mt: 0,
244
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:254"
225
+ mt: 0
245
226
  }, /*#__PURE__*/_react.default.createElement("a", {
246
227
  id: "skipTarget",
247
228
  ref: skipTargetRef,
248
- tabIndex: -1,
249
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:259"
229
+ tabIndex: -1
250
230
  }), /*#__PURE__*/_react.default.createElement(PageHeader, {
251
231
  title: title,
252
232
  parentPageLabel: parentPageLabel,
@@ -261,13 +241,11 @@ var Page = function Page(_ref2) {
261
241
  parentPageLabelRef: parentPageLabelRef,
262
242
  navigation: navigation,
263
243
  onDocumentationButtonClick: onDocumentationButtonClick,
264
- documentationAsButton: documentationAsButton,
265
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:261"
244
+ documentationAsButton: documentationAsButton
266
245
  })), sidebar && sidebarInside && /*#__PURE__*/_react.default.createElement(_elements.Div, {
267
246
  width: [1, 1, 1 / 3],
268
247
  pl: [0, 0, 3],
269
- pt: [4, 4, 0],
270
- "data-source-file": "@cloudflare/component-page:src/Page.tsx:279"
248
+ pt: [4, 4, 0]
271
249
  }, sidebar)), !sidebarInside && sidebar);
272
250
  };
273
251