@redocly/theme 0.33.3 → 0.74.2-pingfed.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.
@@ -148,7 +148,7 @@ const ButtonComponent = (props) => {
148
148
  props.icon ? react_1.default.createElement(StyledIcon, null, props.icon) : null,
149
149
  props.children));
150
150
  if (props.to) {
151
- return react_1.default.createElement(StyledButtonLink, { to: props.to }, button);
151
+ return (react_1.default.createElement(StyledButtonLink, { to: props.to, onClick: props.onClick }, button));
152
152
  }
153
153
  else {
154
154
  return button;
@@ -48,7 +48,7 @@ function CodeBlock({ lang, source, externalSource, header, dataTestId = 'source-
48
48
  }, [source, externalSource]);
49
49
  const { reportDialog, reportButton } = (0, Feedback_1.useReportDialog)();
50
50
  const controls = Object.assign(Object.assign({}, header === null || header === void 0 ? void 0 : header.controls), { report: ((_a = header === null || header === void 0 ? void 0 : header.controls) === null || _a === void 0 ? void 0 : _a.report)
51
- ? Object.assign(Object.assign({}, header.controls.report), { props: reportButton.props }) : { props: reportButton.props } });
51
+ ? Object.assign(Object.assign({}, header.controls.report), { props: Object.assign(Object.assign({}, reportButton.props), header.controls.report.props) }) : { props: reportButton.props } });
52
52
  if (controls.copy && !controls.copy.handleOutside) {
53
53
  controls.copy.data = sourceCode;
54
54
  }
@@ -47,7 +47,7 @@ function CopyButtonComponent({ data, type = 'icon', toasterPlacement = 'top', to
47
47
  onCopyClick === null || onCopyClick === void 0 ? void 0 : onCopyClick();
48
48
  };
49
49
  return (react_1.default.createElement(Tooltip_1.Tooltip, { className: "copy-button", tip: translate('theme.codeSnippet.copy.buttonText', toasterText || 'Copied!'), isOpen: tooltip.isOpened, placement: toasterPlacement },
50
- react_1.default.createElement(CodeBlock_1.CodeBlockControlButton, { onClick: () => copy(toasterDuration), "data-cy": dataTestId, asIcon: type === 'icon', title: translate('theme.codeSnippet.copy.tooltipText', tooltipText || 'Copy to clipboard'), "data-testid": dataTestId }, type === 'icon' ? (react_1.default.createElement(icons_1.CopyIcon, null)) : (translate('theme.codeSnippet.copy.toasterText', buttonText || 'Copy')))));
50
+ react_1.default.createElement(CodeBlock_1.CodeBlockControlButton, { onClick: () => copy(toasterDuration), type: "button", "data-cy": dataTestId, asIcon: type === 'icon', title: translate('theme.codeSnippet.copy.tooltipText', tooltipText || 'Copy to clipboard'), "data-testid": dataTestId }, type === 'icon' ? (react_1.default.createElement(icons_1.CopyIcon, null)) : (translate('theme.codeSnippet.copy.toasterText', buttonText || 'Copy')))));
51
51
  }
52
52
  exports.CopyButton = (0, react_1.memo)(CopyButtonComponent);
53
53
  //# sourceMappingURL=CopyButton.js.map
@@ -39,7 +39,7 @@ const TextContainer = styled_components_1.default.div `
39
39
  display: flex;
40
40
  flex-direction: column;
41
41
  gap: var(--spacing-unit);
42
- width: 100%;
42
+ flex: 1;
43
43
  `;
44
44
  const Heading = styled_components_1.default.div `
45
45
  letter-spacing: var(--admonition-heading-letter-spacing);
@@ -125,6 +125,7 @@ exports.SelectListItem = styled_components_1.default.li `
125
125
  padding: var(--select-list-item-vertical-padding) var(--select-list-item-horizontal-padding);
126
126
  overflow: hidden;
127
127
  text-overflow: ellipsis;
128
+ display: block;
128
129
  }
129
130
 
130
131
  :hover {
package/lib/config.d.ts CHANGED
@@ -192,6 +192,34 @@ declare const gtmAnalyticsConfigSchema: {
192
192
  readonly additionalProperties: false;
193
193
  readonly required: readonly ["trackingId"];
194
194
  };
195
+ declare const productGoogleAnalyticsConfigSchema: {
196
+ readonly type: "object";
197
+ readonly properties: {
198
+ readonly includeInDevelopment: {
199
+ readonly type: "boolean";
200
+ };
201
+ readonly trackingId: {
202
+ readonly type: "string";
203
+ };
204
+ readonly conversionId: {
205
+ readonly type: "string";
206
+ };
207
+ readonly floodlightId: {
208
+ readonly type: "string";
209
+ };
210
+ readonly optimizeId: {
211
+ readonly type: "string";
212
+ };
213
+ readonly exclude: {
214
+ readonly type: "array";
215
+ readonly items: {
216
+ readonly type: "string";
217
+ };
218
+ };
219
+ };
220
+ readonly additionalProperties: false;
221
+ readonly required: readonly ["trackingId"];
222
+ };
195
223
  declare const googleAnalyticsConfigSchema: {
196
224
  readonly type: "object";
197
225
  readonly properties: {
@@ -228,6 +256,37 @@ declare const googleAnalyticsConfigSchema: {
228
256
  readonly cookieExpires: {
229
257
  readonly type: "number";
230
258
  };
259
+ readonly trackers: {
260
+ readonly type: "object";
261
+ readonly additionalProperties: {
262
+ readonly type: "object";
263
+ readonly properties: {
264
+ readonly includeInDevelopment: {
265
+ readonly type: "boolean";
266
+ };
267
+ readonly trackingId: {
268
+ readonly type: "string";
269
+ };
270
+ readonly conversionId: {
271
+ readonly type: "string";
272
+ };
273
+ readonly floodlightId: {
274
+ readonly type: "string";
275
+ };
276
+ readonly optimizeId: {
277
+ readonly type: "string";
278
+ };
279
+ readonly exclude: {
280
+ readonly type: "array";
281
+ readonly items: {
282
+ readonly type: "string";
283
+ };
284
+ };
285
+ };
286
+ readonly additionalProperties: false;
287
+ readonly required: readonly ["trackingId"];
288
+ };
289
+ };
231
290
  };
232
291
  readonly additionalProperties: false;
233
292
  readonly required: readonly ["trackingId"];
@@ -1585,6 +1644,37 @@ export declare const themeConfigSchema: {
1585
1644
  readonly cookieExpires: {
1586
1645
  readonly type: "number";
1587
1646
  };
1647
+ readonly trackers: {
1648
+ readonly type: "object";
1649
+ readonly additionalProperties: {
1650
+ readonly type: "object";
1651
+ readonly properties: {
1652
+ readonly includeInDevelopment: {
1653
+ readonly type: "boolean";
1654
+ };
1655
+ readonly trackingId: {
1656
+ readonly type: "string";
1657
+ };
1658
+ readonly conversionId: {
1659
+ readonly type: "string";
1660
+ };
1661
+ readonly floodlightId: {
1662
+ readonly type: "string";
1663
+ };
1664
+ readonly optimizeId: {
1665
+ readonly type: "string";
1666
+ };
1667
+ readonly exclude: {
1668
+ readonly type: "array";
1669
+ readonly items: {
1670
+ readonly type: "string";
1671
+ };
1672
+ };
1673
+ };
1674
+ readonly additionalProperties: false;
1675
+ readonly required: readonly ["trackingId"];
1676
+ };
1677
+ };
1588
1678
  };
1589
1679
  readonly additionalProperties: false;
1590
1680
  readonly required: readonly ["trackingId"];
@@ -2393,6 +2483,39 @@ export declare const productThemeOverrideSchema: {
2393
2483
  readonly additionalProperties: false;
2394
2484
  readonly default: {};
2395
2485
  };
2486
+ readonly analytics: {
2487
+ readonly type: "object";
2488
+ readonly properties: {
2489
+ readonly ga: {
2490
+ readonly type: "object";
2491
+ readonly properties: {
2492
+ readonly includeInDevelopment: {
2493
+ readonly type: "boolean";
2494
+ };
2495
+ readonly trackingId: {
2496
+ readonly type: "string";
2497
+ };
2498
+ readonly conversionId: {
2499
+ readonly type: "string";
2500
+ };
2501
+ readonly floodlightId: {
2502
+ readonly type: "string";
2503
+ };
2504
+ readonly optimizeId: {
2505
+ readonly type: "string";
2506
+ };
2507
+ readonly exclude: {
2508
+ readonly type: "array";
2509
+ readonly items: {
2510
+ readonly type: "string";
2511
+ };
2512
+ };
2513
+ };
2514
+ readonly additionalProperties: false;
2515
+ readonly required: readonly ["trackingId"];
2516
+ };
2517
+ };
2518
+ };
2396
2519
  };
2397
2520
  readonly additionalProperties: true;
2398
2521
  readonly default: {};
@@ -2420,7 +2543,12 @@ export type ThemeUIConfig = ThemeConfig & {
2420
2543
  };
2421
2544
  };
2422
2545
  export type ProductConfig = FromSchema<typeof productConfigSchema>;
2423
- export type ProductThemeOverrideConfig = Pick<ThemeUIConfig, 'logo' | 'navbar' | 'footer' | 'sidebar' | 'search' | 'codeSnippet' | 'breadcrumbs'>;
2546
+ export type ProductGoogleAnalyticsConfig = FromSchema<typeof productGoogleAnalyticsConfigSchema>;
2547
+ export type ProductThemeOverrideConfig = Pick<ThemeUIConfig, 'logo' | 'navbar' | 'footer' | 'sidebar' | 'search' | 'codeSnippet' | 'breadcrumbs'> & {
2548
+ analytics?: {
2549
+ ga?: ProductGoogleAnalyticsConfig;
2550
+ };
2551
+ };
2424
2552
  export type ProductUiConfig = ProductConfig & {
2425
2553
  slug: string;
2426
2554
  link: string;
package/lib/config.js CHANGED
@@ -173,6 +173,19 @@ const gtmAnalyticsConfigSchema = {
173
173
  additionalProperties: false,
174
174
  required: ['trackingId'],
175
175
  };
176
+ const productGoogleAnalyticsConfigSchema = {
177
+ type: 'object',
178
+ properties: {
179
+ includeInDevelopment: { type: 'boolean' },
180
+ trackingId: { type: 'string' },
181
+ conversionId: { type: 'string' },
182
+ floodlightId: { type: 'string' },
183
+ optimizeId: { type: 'string' },
184
+ exclude: { type: 'array', items: { type: 'string' } },
185
+ },
186
+ additionalProperties: false,
187
+ required: ['trackingId'],
188
+ };
176
189
  const googleAnalyticsConfigSchema = {
177
190
  type: 'object',
178
191
  properties: {
@@ -186,6 +199,11 @@ const googleAnalyticsConfigSchema = {
186
199
  optimizeId: { type: 'string' },
187
200
  anonymizeIp: { type: 'boolean' },
188
201
  cookieExpires: { type: 'number' },
202
+ // All enabled tracking configs
203
+ trackers: {
204
+ type: 'object',
205
+ additionalProperties: productGoogleAnalyticsConfigSchema,
206
+ },
189
207
  },
190
208
  additionalProperties: false,
191
209
  required: ['trackingId'],
@@ -607,6 +625,12 @@ exports.productThemeOverrideSchema = {
607
625
  search: exports.themeConfigSchema.properties.search,
608
626
  codeSnippet: exports.themeConfigSchema.properties.codeSnippet,
609
627
  breadcrumbs: exports.themeConfigSchema.properties.breadcrumbs,
628
+ analytics: {
629
+ type: 'object',
630
+ properties: {
631
+ ga: productGoogleAnalyticsConfigSchema,
632
+ },
633
+ },
610
634
  },
611
635
  additionalProperties: true,
612
636
  default: {},
@@ -8,7 +8,9 @@ function useThemeConfig(useProductConfig = true) {
8
8
  const themeConfig = (0, react_1.useContext)(exports.ThemeConfigContext) || {};
9
9
  const currentProduct = (0, hooks_1.useCurrentProduct)();
10
10
  const mergedTheme = useProductConfig && (currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.themeOverride)
11
- ? Object.assign(Object.assign({}, themeConfig), currentProduct.themeOverride) : themeConfig;
11
+ ? Object.assign(Object.assign(Object.assign({}, themeConfig), currentProduct.themeOverride), {
12
+ // Do not override analytics config from product
13
+ analytics: themeConfig.analytics }) : themeConfig;
12
14
  return mergedTheme;
13
15
  }
14
16
  exports.useThemeConfig = useThemeConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.33.3",
3
+ "version": "0.74.2-pingfed.1",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -23,7 +23,7 @@
23
23
  "prismjs": "^1.28.0",
24
24
  "react": "^17.0.0 || ^18.0.0",
25
25
  "react-dom": "^17.0.0 || ^18.0.0",
26
- "react-router-dom": "^6.10.0",
26
+ "react-router-dom": "^6.21.1",
27
27
  "styled-components": "^4.1.1 || ^5.3.11",
28
28
  "styled-system": "^5.1.5"
29
29
  },
@@ -65,7 +65,7 @@
65
65
  "lodash.throttle": "4.1.1",
66
66
  "npm-run-all": "4.1.5",
67
67
  "react-refresh": "0.14.0",
68
- "react-router-dom": "6.10.0",
68
+ "react-router-dom": "6.21.1",
69
69
  "storybook": "7.6.4",
70
70
  "storybook-addon-pseudo-states": "2.1.2",
71
71
  "storybook-design-token": "3.0.0-beta.6",
@@ -161,7 +161,11 @@ const ButtonComponent: React.FC<ButtonProps> = (props) => {
161
161
  );
162
162
 
163
163
  if (props.to) {
164
- return <StyledButtonLink to={props.to}>{button}</StyledButtonLink>;
164
+ return (
165
+ <StyledButtonLink to={props.to} onClick={props.onClick}>
166
+ {button}
167
+ </StyledButtonLink>
168
+ );
165
169
  } else {
166
170
  return button;
167
171
  }
@@ -82,7 +82,13 @@ export function CodeBlock({
82
82
  const controls = {
83
83
  ...header?.controls,
84
84
  report: header?.controls?.report
85
- ? { ...header.controls.report, props: reportButton.props }
85
+ ? {
86
+ ...header.controls.report,
87
+ props: {
88
+ ...reportButton.props,
89
+ ...header.controls.report.props,
90
+ },
91
+ }
86
92
  : { props: reportButton.props },
87
93
  };
88
94
 
@@ -60,6 +60,7 @@ function CopyButtonComponent({
60
60
  >
61
61
  <CodeBlockControlButton
62
62
  onClick={() => copy(toasterDuration)}
63
+ type="button"
63
64
  data-cy={dataTestId}
64
65
  asIcon={type === 'icon'}
65
66
  title={translate('theme.codeSnippet.copy.tooltipText', tooltipText || 'Copy to clipboard')}
@@ -64,7 +64,7 @@ const TextContainer = styled.div`
64
64
  display: flex;
65
65
  flex-direction: column;
66
66
  gap: var(--spacing-unit);
67
- width: 100%;
67
+ flex: 1;
68
68
  `;
69
69
 
70
70
  const Heading = styled.div<AdmonitionTypeProps>`
@@ -175,6 +175,7 @@ export const SelectListItem = styled.li<{ selected: boolean }>`
175
175
  padding: var(--select-list-item-vertical-padding) var(--select-list-item-horizontal-padding);
176
176
  overflow: hidden;
177
177
  text-overflow: ellipsis;
178
+ display: block;
178
179
  }
179
180
 
180
181
  :hover {
package/src/config.ts CHANGED
@@ -196,6 +196,21 @@ const gtmAnalyticsConfigSchema = {
196
196
  required: ['trackingId'],
197
197
  } as const;
198
198
 
199
+ const productGoogleAnalyticsConfigSchema = {
200
+ type: 'object',
201
+ properties: {
202
+ includeInDevelopment: { type: 'boolean' },
203
+ trackingId: { type: 'string' },
204
+
205
+ conversionId: { type: 'string' },
206
+ floodlightId: { type: 'string' },
207
+ optimizeId: { type: 'string' },
208
+ exclude: { type: 'array', items: { type: 'string' } },
209
+ },
210
+ additionalProperties: false,
211
+ required: ['trackingId'],
212
+ } as const;
213
+
199
214
  const googleAnalyticsConfigSchema = {
200
215
  type: 'object',
201
216
  properties: {
@@ -212,6 +227,12 @@ const googleAnalyticsConfigSchema = {
212
227
  optimizeId: { type: 'string' },
213
228
  anonymizeIp: { type: 'boolean' },
214
229
  cookieExpires: { type: 'number' },
230
+
231
+ // All enabled tracking configs
232
+ trackers: {
233
+ type: 'object',
234
+ additionalProperties: productGoogleAnalyticsConfigSchema,
235
+ },
215
236
  },
216
237
  additionalProperties: false,
217
238
  required: ['trackingId'],
@@ -698,6 +719,12 @@ export const productThemeOverrideSchema = {
698
719
  search: themeConfigSchema.properties.search,
699
720
  codeSnippet: themeConfigSchema.properties.codeSnippet,
700
721
  breadcrumbs: themeConfigSchema.properties.breadcrumbs,
722
+ analytics: {
723
+ type: 'object',
724
+ properties: {
725
+ ga: productGoogleAnalyticsConfigSchema,
726
+ },
727
+ },
701
728
  },
702
729
  additionalProperties: true,
703
730
  default: {},
@@ -729,10 +756,12 @@ export type ThemeUIConfig = ThemeConfig & {
729
756
  };
730
757
 
731
758
  export type ProductConfig = FromSchema<typeof productConfigSchema>;
759
+
760
+ export type ProductGoogleAnalyticsConfig = FromSchema<typeof productGoogleAnalyticsConfigSchema>;
732
761
  export type ProductThemeOverrideConfig = Pick<
733
762
  ThemeUIConfig,
734
763
  'logo' | 'navbar' | 'footer' | 'sidebar' | 'search' | 'codeSnippet' | 'breadcrumbs'
735
- >;
764
+ > & { analytics?: { ga?: ProductGoogleAnalyticsConfig } };
736
765
  export type ProductUiConfig = ProductConfig & {
737
766
  slug: string;
738
767
  link: string;
@@ -17,6 +17,8 @@ export function useThemeConfig<T extends Record<string, unknown>>(
17
17
  ? {
18
18
  ...themeConfig,
19
19
  ...currentProduct.themeOverride,
20
+ // Do not override analytics config from product
21
+ analytics: themeConfig.analytics,
20
22
  }
21
23
  : themeConfig;
22
24