@zendeskgarden/react-typography 9.0.0-next.6 → 9.0.0-next.8

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.
Files changed (37) hide show
  1. package/dist/esm/elements/Blockquote.js +34 -0
  2. package/dist/esm/elements/Code.js +43 -0
  3. package/dist/esm/elements/CodeBlock.js +102 -0
  4. package/dist/esm/elements/Ellipsis.js +50 -0
  5. package/dist/esm/elements/LG.js +43 -0
  6. package/dist/esm/elements/MD.js +43 -0
  7. package/dist/esm/elements/Paragraph.js +34 -0
  8. package/dist/esm/elements/SM.js +43 -0
  9. package/dist/esm/elements/XL.js +42 -0
  10. package/dist/esm/elements/XXL.js +42 -0
  11. package/dist/esm/elements/XXXL.js +42 -0
  12. package/dist/esm/elements/lists/OrderedList.js +53 -0
  13. package/dist/esm/elements/lists/OrderedListItem.js +34 -0
  14. package/dist/esm/elements/lists/UnorderedList.js +53 -0
  15. package/dist/esm/elements/lists/UnorderedListItem.js +34 -0
  16. package/dist/esm/elements/span/Icon.js +25 -0
  17. package/dist/esm/elements/span/Span.js +49 -0
  18. package/dist/esm/elements/span/StartIcon.js +27 -0
  19. package/dist/esm/index.js +20 -0
  20. package/dist/esm/styled/StyledBlockquote.js +23 -0
  21. package/dist/esm/styled/StyledCode.js +34 -0
  22. package/dist/esm/styled/StyledCodeBlock.js +27 -0
  23. package/dist/esm/styled/StyledCodeBlockContainer.js +24 -0
  24. package/dist/esm/styled/StyledCodeBlockLine.js +74 -0
  25. package/dist/esm/styled/StyledCodeBlockToken.js +44 -0
  26. package/dist/esm/styled/StyledEllipsis.js +22 -0
  27. package/dist/esm/styled/StyledFont.js +67 -0
  28. package/dist/esm/styled/StyledIcon.js +35 -0
  29. package/dist/esm/styled/StyledList.js +37 -0
  30. package/dist/esm/styled/StyledListItem.js +48 -0
  31. package/dist/esm/styled/StyledParagraph.js +23 -0
  32. package/dist/esm/types/index.js +14 -0
  33. package/dist/esm/utils/useOrderedListContext.js +18 -0
  34. package/dist/esm/utils/useUnorderedListContext.js +18 -0
  35. package/dist/index.cjs.js +39 -55
  36. package/package.json +5 -5
  37. package/dist/index.esm.js +0 -769
package/dist/index.esm.js DELETED
@@ -1,769 +0,0 @@
1
- /**
2
- * Copyright Zendesk, Inc.
3
- *
4
- * Use of this source code is governed under the Apache License, Version 2.0
5
- * found at http://www.apache.org/licenses/LICENSE-2.0.
6
- */
7
-
8
- import React, { Children, forwardRef, useRef, useMemo, createContext, useContext } from 'react';
9
- import PropTypes from 'prop-types';
10
- import styled, { css } from 'styled-components';
11
- import { retrieveComponentStyles, DEFAULT_THEME, getColorV8, focusStyles, getLineHeight } from '@zendeskgarden/react-theming';
12
- import { hideVisually, math } from 'polished';
13
- import Highlight, { Prism } from 'prism-react-renderer';
14
- import { useScrollRegion } from '@zendeskgarden/container-scrollregion';
15
-
16
- function _extends() {
17
- _extends = Object.assign ? Object.assign.bind() : function (target) {
18
- for (var i = 1; i < arguments.length; i++) {
19
- var source = arguments[i];
20
- for (var key in source) {
21
- if (Object.prototype.hasOwnProperty.call(source, key)) {
22
- target[key] = source[key];
23
- }
24
- }
25
- }
26
- return target;
27
- };
28
- return _extends.apply(this, arguments);
29
- }
30
-
31
- const HUE = ['grey', 'red', 'green', 'yellow'];
32
- const SIZE = ['small', 'medium', 'large'];
33
- const INHERIT_SIZE = ['inherit', ...SIZE];
34
- const TYPE_ORDERED_LIST = ['decimal', 'decimal-leading-zero', 'lower-alpha', 'lower-roman', 'upper-alpha', 'upper-roman'];
35
- const TYPE_UNORDERED_LIST = ['circle', 'disc', 'square'];
36
- const LANGUAGES = ['markup', 'bash', 'clike', 'c', 'cpp', 'css', 'javascript', 'jsx', 'coffeescript', 'actionscript', 'css-extr', 'diff', 'git', 'go', 'graphql', 'handlebars', 'json', 'less', 'makefile', 'markdown', 'objectivec', 'ocaml', 'python', 'reason', 'sass', 'scss', 'sql', 'stylus', 'tsx', 'typescript', 'wasm', 'yaml'];
37
-
38
- const COMPONENT_ID$9 = 'typography.font';
39
- [...SIZE, 'extralarge', '2xlarge', '3xlarge'];
40
- const THEME_SIZES = {
41
- small: 'sm',
42
- medium: 'md',
43
- large: 'lg',
44
- extralarge: 'xl',
45
- '2xlarge': 'xxl',
46
- '3xlarge': 'xxxl'
47
- };
48
- const fontStyles = props => {
49
- const monospace = props.isMonospace && ['inherit', 'small', 'medium', 'large'].indexOf(props.size) !== -1;
50
- const fontFamily = monospace && props.theme.fonts.mono;
51
- const direction = props.theme.rtl ? 'rtl' : 'ltr';
52
- let fontSize;
53
- let fontWeight;
54
- let lineHeight;
55
- let color;
56
- if (monospace) {
57
- if (props.size === 'inherit') {
58
- fontSize = 'calc(1em - 1px)';
59
- lineHeight = 'normal';
60
- } else {
61
- const themeSize = THEME_SIZES[props.size];
62
- fontSize = math(`${props.theme.fontSizes[themeSize]} - 1px`);
63
- lineHeight = math(`${props.theme.lineHeights[themeSize]} - 1px`);
64
- }
65
- } else if (props.size !== 'inherit') {
66
- const themeSize = THEME_SIZES[props.size];
67
- fontSize = props.theme.fontSizes[themeSize];
68
- lineHeight = props.theme.lineHeights[themeSize];
69
- }
70
- if (props.isBold === true) {
71
- fontWeight = props.theme.fontWeights.semibold;
72
- } else if (props.isBold === false || props.size !== 'inherit') {
73
- fontWeight = props.theme.fontWeights.regular;
74
- }
75
- if (props.hue) {
76
- const shade = props.hue === 'yellow' ? 700 : 600;
77
- color = getColorV8(props.hue, shade, props.theme);
78
- }
79
- return css(["line-height:", ";color:", ";font-family:", ";font-size:", ";font-weight:", ";direction:", ";"], lineHeight, color, fontFamily, fontSize, fontWeight, direction);
80
- };
81
- const StyledFont = styled.div.attrs({
82
- 'data-garden-id': COMPONENT_ID$9,
83
- 'data-garden-version': '9.0.0-next.6'
84
- }).withConfig({
85
- displayName: "StyledFont",
86
- componentId: "sc-1iildbo-0"
87
- })(["", ";&[hidden]{display:inline;", ";}", ";"], props => !props.hidden && fontStyles(props), hideVisually(), props => retrieveComponentStyles(COMPONENT_ID$9, props));
88
- StyledFont.defaultProps = {
89
- theme: DEFAULT_THEME,
90
- size: 'inherit'
91
- };
92
-
93
- const COMPONENT_ID$8 = 'typography.blockquote';
94
- const StyledBlockquote = styled.blockquote.attrs({
95
- 'data-garden-id': COMPONENT_ID$8,
96
- 'data-garden-version': '9.0.0-next.6'
97
- }).withConfig({
98
- displayName: "StyledBlockquote",
99
- componentId: "sc-1tt3ye0-0"
100
- })(["margin:0;border-", ":", " solid;border-color:", ";padding:0;padding-", ":", "px;direction:", ";& + &,p + &{margin-top:", ";}", ";"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.shadowWidths.sm, props => getColorV8('neutralHue', 400, props.theme), props => props.theme.rtl ? 'right' : 'left', props => props.theme.space.base * 4, props => props.theme.rtl ? 'rtl' : 'ltr', props => props.theme.lineHeights[THEME_SIZES[props.size]], props => retrieveComponentStyles(COMPONENT_ID$8, props));
101
- StyledBlockquote.defaultProps = {
102
- theme: DEFAULT_THEME
103
- };
104
-
105
- const COMPONENT_ID$7 = 'typography.code';
106
- const colorStyles$3 = props => {
107
- const hue = props.hue || 'neutralHue';
108
- const backgroundColor = getColorV8(hue, 200, props.theme);
109
- const shade = hue === 'yellow' ? 800 : 700;
110
- const foregroundColor = getColorV8(hue, shade, props.theme);
111
- return css(["background-color:", ";color:", ";a &{color:inherit;}"], backgroundColor, foregroundColor);
112
- };
113
- const StyledCode = styled(StyledFont).attrs({
114
- 'data-garden-id': COMPONENT_ID$7,
115
- 'data-garden-version': '9.0.0-next.6',
116
- as: 'code'
117
- }).withConfig({
118
- displayName: "StyledCode",
119
- componentId: "sc-l8yvmf-0"
120
- })(["border-radius:", ";padding:1.5px;", ";", ";"], props => props.theme.borderRadii.sm, props => colorStyles$3(props), props => retrieveComponentStyles(COMPONENT_ID$7, props));
121
- StyledCode.defaultProps = {
122
- theme: DEFAULT_THEME,
123
- isMonospace: true,
124
- hue: 'neutralHue',
125
- size: 'inherit'
126
- };
127
-
128
- const COMPONENT_ID$6 = 'typography.codeblock';
129
- const colorStyles$2 = props => {
130
- const backgroundColor = getColorV8('neutralHue', props.isLight ? 100 : 1000, props.theme);
131
- const foregroundColor = props.isLight ? getColorV8('foreground', 600 , props.theme) : getColorV8('neutralHue', 300, props.theme);
132
- return css(["background-color:", ";color:", ";"], backgroundColor, foregroundColor);
133
- };
134
- const StyledCodeBlock = styled.pre.attrs({
135
- 'data-garden-id': COMPONENT_ID$6,
136
- 'data-garden-version': '9.0.0-next.6'
137
- }).withConfig({
138
- displayName: "StyledCodeBlock",
139
- componentId: "sc-5wky57-0"
140
- })(["display:table;margin:0;padding:", "px;box-sizing:border-box;width:100%;direction:ltr;white-space:pre;counter-reset:linenumber;", ";", ";"], props => props.theme.space.base * 3, props => colorStyles$2(props), props => retrieveComponentStyles(COMPONENT_ID$6, props));
141
- StyledCodeBlock.defaultProps = {
142
- theme: DEFAULT_THEME
143
- };
144
-
145
- const COMPONENT_ID$5 = 'typography.codeblock_container';
146
- const StyledCodeBlockContainer = styled.div.attrs({
147
- 'data-garden-id': COMPONENT_ID$5,
148
- 'data-garden-version': '9.0.0-next.6'
149
- }).withConfig({
150
- displayName: "StyledCodeBlockContainer",
151
- componentId: "sc-14zgbfw-0"
152
- })(["transition:box-shadow 0.1s ease-in-out;overflow:auto;", " ", ";"], props => focusStyles({
153
- theme: props.theme
154
- }), props => retrieveComponentStyles(COMPONENT_ID$5, props));
155
- StyledCodeBlockContainer.defaultProps = {
156
- theme: DEFAULT_THEME
157
- };
158
-
159
- const COMPONENT_ID$4 = 'typography.codeblock_code';
160
- const colorStyles$1 = props => {
161
- let backgroundColor;
162
- if (props.diff) {
163
- let hue;
164
- switch (props.diff) {
165
- case 'hunk':
166
- hue = 'royal';
167
- break;
168
- case 'add':
169
- hue = 'lime';
170
- break;
171
- case 'delete':
172
- hue = 'crimson';
173
- break;
174
- case 'change':
175
- hue = 'lemon';
176
- break;
177
- }
178
- backgroundColor = getColorV8(hue, 400, props.theme, 0.2);
179
- } else if (props.isHighlighted) {
180
- const hue = props.isLight ? props.theme.palette.black : props.theme.palette.white;
181
- backgroundColor = getColorV8(hue, 600, props.theme, 0.1);
182
- }
183
- return css(["background-color:", ";"], backgroundColor);
184
- };
185
- const lineNumberStyles = props => {
186
- const color = getColorV8('neutralHue', props.isLight ? 600 : 500, props.theme);
187
- let padding;
188
- if (props.language && props.language === 'diff') {
189
- padding = 0;
190
- } else if (props.size === 'small') {
191
- padding = props.theme.space.base * 4;
192
- } else if (props.size === 'large') {
193
- padding = props.theme.space.base * 7;
194
- } else {
195
- padding = props.theme.space.base * 6;
196
- }
197
- return `
198
- &::before {
199
- display: table-cell;
200
- padding-right: ${padding}px;
201
- width: 1px;
202
- text-align: right;
203
- color: ${color};
204
- content: counter(linenumber);
205
- counter-increment: linenumber;
206
- }
207
- `;
208
- };
209
- const StyledCodeBlockLine = styled(StyledFont).attrs({
210
- 'data-garden-id': COMPONENT_ID$4,
211
- 'data-garden-version': '9.0.0-next.6',
212
- as: 'code',
213
- isMonospace: true
214
- }).withConfig({
215
- displayName: "StyledCodeBlockLine",
216
- componentId: "sc-1goay17-0"
217
- })(["display:table-row;height:", ";direction:ltr;", ";", ";&::after{display:inline-block;width:", "px;content:'';}", ";"], props => props.theme.lineHeights[THEME_SIZES[props.size]], props => colorStyles$1(props), props => props.isNumbered && lineNumberStyles(props), props => props.theme.space.base * 3, props => retrieveComponentStyles(COMPONENT_ID$4, props));
218
- StyledCodeBlockLine.defaultProps = {
219
- theme: DEFAULT_THEME
220
- };
221
-
222
- const COMPONENT_ID$3 = 'typography.codeblock_token';
223
- const colorStyles = props => {
224
- const palette = props.theme.palette;
225
- const colors = {
226
- boolean: props.isLight ? palette.royal[600] : palette.azure[400],
227
- builtin: palette.teal[400],
228
- comment: props.isLight ? palette.lime[600] : palette.mint[400],
229
- constant: props.isLight ? palette.azure[400] : palette.blue[500],
230
- coord: props.isLight ? palette.purple[600] : palette.blue[200],
231
- deleted: props.isLight ? palette.red[700] : palette.red[200],
232
- diff: props.isLight ? palette.yellow[800] : palette.yellow[200],
233
- function: props.isLight ? palette.orange['M600'] : palette.yellow[300],
234
- inserted: props.isLight ? palette.green[700] : palette.green[200],
235
- keyword: palette.fuschia['M400'],
236
- name: props.isLight ? palette.crimson[400] : palette.blue[300],
237
- number: props.isLight ? palette.green[600] : palette.green[300],
238
- punctuation: props.isLight ? palette.red[800] : palette.grey[600],
239
- regex: palette.red[400],
240
- value: props.isLight ? palette.red[700] : palette.crimson['M400']
241
- };
242
- return css(["&.builtin,&.class-name,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script){color:", ";}&.doctype,&.prolog,&.tag.punctuation:not(.attr-value):not(.script):not(.spread){color:", ";}&.attribute.value,&.attr-value,&.atrule,&.cdata,&.string,&.url.content{color:", ";}&.constant,&.interpolation-punctuation{color:", ";}&.attr-name,&.attr-value.spread,&.environment,&.interpolation,&.parameter,&.property,&.property-access,&.variable{color:", ";}&.parameter.punctuation,&.attr-name + .attr-value.punctuation{color:inherit;}&.regex{color:", ";}&.boolean,&.bold:not(.diff),&.entity,&.important,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script):not(.class-name){color:", ";}&.number,&.unit{color:", ";}&.assign-left,&.function,&.selector:not(.attribute){color:", ";}&.atrule.rule,&.keyword{color:", ";}&.blockquote,&.comment,&.shebang{color:", ";}", ".language-css &&.plain{color:", ";}", ".language-diff &&.coord{color:", ";}", ".language-diff &&.deleted{color:", ";}", ".language-diff &&.diff{color:", ";}", ".language-diff &&.inserted{color:", ";}"], colors.builtin, colors.punctuation, colors.value, colors.constant, colors.name, colors.regex, colors.boolean, colors.number, colors.function, colors.keyword, colors.comment, StyledCodeBlock, colors.value, StyledCodeBlock, colors.coord, StyledCodeBlock, colors.deleted, StyledCodeBlock, colors.diff, StyledCodeBlock, colors.inserted);
243
- };
244
- const StyledCodeBlockToken = styled.span.attrs({
245
- 'data-garden-id': COMPONENT_ID$3,
246
- 'data-garden-version': '9.0.0-next.6'
247
- }).withConfig({
248
- displayName: "StyledCodeBlockToken",
249
- componentId: "sc-1hkshdq-0"
250
- })(["display:inline-block;&.bold:not(.diff){font-weight:", ";}&.coord{padding-left:0.75em;}&.italic{font-style:italic;}&.prefix{width:2em;text-align:center;}", ";", ";"], props => props.theme.fontWeights.semibold, props => colorStyles(props), props => retrieveComponentStyles(COMPONENT_ID$3, props));
251
- StyledCodeBlockToken.defaultProps = {
252
- theme: DEFAULT_THEME
253
- };
254
-
255
- const COMPONENT_ID$2 = 'typography.ellipsis';
256
- const StyledEllipsis = styled.div.attrs({
257
- 'data-garden-id': COMPONENT_ID$2,
258
- 'data-garden-version': '9.0.0-next.6'
259
- }).withConfig({
260
- displayName: "StyledEllipsis",
261
- componentId: "sc-1u4uqmy-0"
262
- })(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;direction:", ";", ";"], props => props.theme.rtl ? 'rtl' : 'ltr', props => retrieveComponentStyles(COMPONENT_ID$2, props));
263
- StyledEllipsis.defaultProps = {
264
- theme: DEFAULT_THEME
265
- };
266
-
267
- const COMPONENT_ID$1 = 'typography.icon';
268
- const sizeStyles = props => {
269
- const margin = props.isStart && `${props.theme.space.base * 2}px`;
270
- const size = props.theme.iconSizes.md;
271
- return css(["margin-", ":", ";width:", ";height:", ";"], props.theme.rtl ? 'left' : 'right', margin, size, size);
272
- };
273
- const StyledIcon = styled(_ref => {
274
- let {
275
- children,
276
- isStart,
277
- ...props
278
- } = _ref;
279
- return React.cloneElement(Children.only(children), props);
280
- }).attrs({
281
- 'data-garden-id': COMPONENT_ID$1,
282
- 'data-garden-version': '9.0.0-next.6'
283
- }).withConfig({
284
- displayName: "StyledIcon",
285
- componentId: "sc-10rfb5b-0"
286
- })(["position:relative;top:-1px;vertical-align:middle;", ";", ";"], props => sizeStyles(props), props => retrieveComponentStyles(COMPONENT_ID$1, props));
287
- StyledIcon.defaultProps = {
288
- theme: DEFAULT_THEME
289
- };
290
-
291
- const listStyles = props => {
292
- const rtl = props.theme.rtl;
293
- return css(["direction:", ";margin:0;margin-", ":24px;padding:0;list-style-position:outside;list-style-type:", ";"], rtl ? 'rtl' : 'ltr', rtl ? 'right' : 'left', props.listType);
294
- };
295
- const ORDERED_ID$1 = 'typography.ordered_list';
296
- const StyledOrderedList = styled.ol.attrs({
297
- 'data-garden-id': ORDERED_ID$1,
298
- 'data-garden-version': '9.0.0-next.6'
299
- }).withConfig({
300
- displayName: "StyledList__StyledOrderedList",
301
- componentId: "sc-jdbsfi-0"
302
- })(["", ";", ";"], props => listStyles(props), props => retrieveComponentStyles(ORDERED_ID$1, props));
303
- StyledOrderedList.defaultProps = {
304
- theme: DEFAULT_THEME
305
- };
306
- const UNORDERED_ID$1 = 'typography.unordered_list';
307
- const StyledUnorderedList = styled.ul.attrs({
308
- 'data-garden-id': UNORDERED_ID$1,
309
- 'data-garden-version': '9.0.0-next.6'
310
- }).withConfig({
311
- displayName: "StyledList__StyledUnorderedList",
312
- componentId: "sc-jdbsfi-1"
313
- })(["", ";", ";"], props => listStyles(props), props => retrieveComponentStyles(UNORDERED_ID$1, props));
314
- StyledUnorderedList.defaultProps = {
315
- theme: DEFAULT_THEME
316
- };
317
-
318
- const listItemPaddingStyles = props => {
319
- const base = props.theme.space.base;
320
- const paddingTop = props.space === 'large' ? `${base * 2}px` : `${base}px`;
321
- return css(["padding-top:", ";", " > &:first-child,", " > &:first-child{padding-top:0;}", " ", " > &:first-child,", " ", " > &:first-child,", " ", " > &:first-child,", " ", " > &:first-child{padding-top:", ";}"], paddingTop, StyledOrderedList, StyledUnorderedList, StyledOrderedList, StyledOrderedList, StyledOrderedList, StyledUnorderedList, StyledUnorderedList, StyledUnorderedList, StyledUnorderedList, StyledUnorderedList, paddingTop);
322
- };
323
- const listItemStyles = props => {
324
- return css(["line-height:", ";", ";"], getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), props.space !== 'small' && listItemPaddingStyles(props));
325
- };
326
- const ORDERED_ID = 'typography.ordered_list_item';
327
- const StyledOrderedListItem = styled(StyledFont).attrs({
328
- 'data-garden-id': ORDERED_ID,
329
- 'data-garden-version': '9.0.0-next.6',
330
- as: 'li'
331
- }).withConfig({
332
- displayName: "StyledListItem__StyledOrderedListItem",
333
- componentId: "sc-9rsipg-0"
334
- })(["margin-", ":", ";padding-", ":", ";", ";", ";"], props => props.theme.rtl ? 'right' : 'left', props => math(`${props.theme.space.base} * -1px`), props => props.theme.rtl ? 'right' : 'left', props => math(`${props.theme.space.base} * 1px`), props => listItemStyles(props), props => retrieveComponentStyles(ORDERED_ID, props));
335
- StyledOrderedListItem.defaultProps = {
336
- space: 'medium',
337
- theme: DEFAULT_THEME
338
- };
339
- const UNORDERED_ID = 'typography.unordered_list_item';
340
- const StyledUnorderedListItem = styled(StyledFont).attrs({
341
- 'data-garden-id': UNORDERED_ID,
342
- 'data-garden-version': '9.0.0-next.6',
343
- as: 'li'
344
- }).withConfig({
345
- displayName: "StyledListItem__StyledUnorderedListItem",
346
- componentId: "sc-9rsipg-1"
347
- })(["", ";", ";"], props => listItemStyles(props), props => retrieveComponentStyles(UNORDERED_ID, props));
348
- StyledUnorderedListItem.defaultProps = {
349
- space: 'medium',
350
- theme: DEFAULT_THEME
351
- };
352
-
353
- const COMPONENT_ID = 'typography.paragraph';
354
- const StyledParagraph = styled.p.attrs({
355
- 'data-garden-id': COMPONENT_ID,
356
- 'data-garden-version': '9.0.0-next.6'
357
- }).withConfig({
358
- displayName: "StyledParagraph",
359
- componentId: "sc-zkuftz-0"
360
- })(["margin:0;padding:0;direction:", ";& + &,blockquote + &{margin-top:", ";}", ";"], props => props.theme.rtl ? 'rtl' : 'ltr', props => props.theme.lineHeights[THEME_SIZES[props.size]], props => retrieveComponentStyles(COMPONENT_ID, props));
361
- StyledParagraph.defaultProps = {
362
- theme: DEFAULT_THEME
363
- };
364
-
365
- const SM = forwardRef((_ref, ref) => {
366
- let {
367
- tag,
368
- ...other
369
- } = _ref;
370
- return React.createElement(StyledFont, _extends({
371
- as: tag,
372
- ref: ref,
373
- size: "small"
374
- }, other));
375
- });
376
- SM.displayName = 'SM';
377
- SM.propTypes = {
378
- tag: PropTypes.any,
379
- isBold: PropTypes.bool,
380
- isMonospace: PropTypes.bool
381
- };
382
- SM.defaultProps = {
383
- tag: 'div'
384
- };
385
-
386
- const MD = forwardRef((_ref, ref) => {
387
- let {
388
- tag,
389
- ...other
390
- } = _ref;
391
- return React.createElement(StyledFont, _extends({
392
- as: tag,
393
- ref: ref,
394
- size: "medium"
395
- }, other));
396
- });
397
- MD.displayName = 'MD';
398
- MD.propTypes = {
399
- tag: PropTypes.any,
400
- isBold: PropTypes.bool,
401
- isMonospace: PropTypes.bool
402
- };
403
- MD.defaultProps = {
404
- tag: 'div'
405
- };
406
-
407
- const LG = forwardRef((_ref, ref) => {
408
- let {
409
- tag,
410
- ...other
411
- } = _ref;
412
- return React.createElement(StyledFont, _extends({
413
- as: tag,
414
- ref: ref,
415
- size: "large"
416
- }, other));
417
- });
418
- LG.displayName = 'LG';
419
- LG.propTypes = {
420
- tag: PropTypes.any,
421
- isBold: PropTypes.bool,
422
- isMonospace: PropTypes.bool
423
- };
424
- LG.defaultProps = {
425
- tag: 'div'
426
- };
427
-
428
- const XL = forwardRef((_ref, ref) => {
429
- let {
430
- tag,
431
- ...other
432
- } = _ref;
433
- return React.createElement(StyledFont, _extends({
434
- as: tag,
435
- ref: ref,
436
- size: "extralarge"
437
- }, other));
438
- });
439
- XL.displayName = 'XL';
440
- XL.propTypes = {
441
- tag: PropTypes.any,
442
- isBold: PropTypes.bool
443
- };
444
- XL.defaultProps = {
445
- tag: 'div'
446
- };
447
-
448
- const XXL = forwardRef((_ref, ref) => {
449
- let {
450
- tag,
451
- ...other
452
- } = _ref;
453
- return React.createElement(StyledFont, _extends({
454
- as: tag,
455
- ref: ref,
456
- size: "2xlarge"
457
- }, other));
458
- });
459
- XXL.displayName = 'XXL';
460
- XXL.propTypes = {
461
- tag: PropTypes.any,
462
- isBold: PropTypes.bool
463
- };
464
- XXL.defaultProps = {
465
- tag: 'div'
466
- };
467
-
468
- const XXXL = forwardRef((_ref, ref) => {
469
- let {
470
- tag,
471
- ...other
472
- } = _ref;
473
- return React.createElement(StyledFont, _extends({
474
- as: tag,
475
- ref: ref,
476
- size: "3xlarge"
477
- }, other));
478
- });
479
- XXXL.displayName = 'XXXL';
480
- XXXL.propTypes = {
481
- tag: PropTypes.any,
482
- isBold: PropTypes.bool
483
- };
484
- XXXL.defaultProps = {
485
- tag: 'div'
486
- };
487
-
488
- const Blockquote = forwardRef((props, ref) => React.createElement(StyledBlockquote, _extends({
489
- ref: ref
490
- }, props)));
491
- Blockquote.displayName = 'Blockquote';
492
- Blockquote.propTypes = {
493
- size: PropTypes.oneOf(SIZE)
494
- };
495
- Blockquote.defaultProps = {
496
- size: 'medium'
497
- };
498
-
499
- const Code = forwardRef((_ref, ref) => {
500
- let {
501
- hue,
502
- ...other
503
- } = _ref;
504
- return React.createElement(StyledCode, _extends({
505
- ref: ref,
506
- hue: hue
507
- }, other));
508
- });
509
- Code.displayName = 'Code';
510
- Code.propTypes = {
511
- hue: PropTypes.oneOf(HUE),
512
- size: PropTypes.oneOf(INHERIT_SIZE)
513
- };
514
- Code.defaultProps = {
515
- hue: 'grey',
516
- size: 'inherit'
517
- };
518
-
519
- const CodeBlock = React.forwardRef((_ref, ref) => {
520
- let {
521
- children,
522
- containerProps,
523
- highlightLines,
524
- isLight,
525
- isNumbered,
526
- language,
527
- size,
528
- ...other
529
- } = _ref;
530
- const containerRef = useRef(null);
531
- const code = Array.isArray(children) ? children[0] : children;
532
- const dependency = useMemo(() => [size, children], [size, children]);
533
- const containerTabIndex = useScrollRegion({
534
- containerRef,
535
- dependency
536
- });
537
- const getDiff = line => {
538
- let retVal;
539
- if (language === 'diff') {
540
- const token = line.find(value => !(value.empty || value.content === ''));
541
- if (token) {
542
- if (token.types.includes('deleted')) {
543
- retVal = 'delete';
544
- } else if (token.types.includes('inserted')) {
545
- retVal = 'add';
546
- } else if (token.types.includes('coord')) {
547
- retVal = 'hunk';
548
- } else if (token.types.includes('diff')) {
549
- retVal = 'change';
550
- }
551
- }
552
- }
553
- return retVal;
554
- };
555
- return React.createElement(StyledCodeBlockContainer, _extends({}, containerProps, {
556
- ref: containerRef,
557
- tabIndex: containerTabIndex
558
- }), React.createElement(Highlight, {
559
- Prism: Prism,
560
- code: code ? code.trim() : '',
561
- language: LANGUAGES.includes(language) ? language : 'tsx'
562
- }, _ref2 => {
563
- let {
564
- className,
565
- tokens,
566
- getLineProps,
567
- getTokenProps
568
- } = _ref2;
569
- return React.createElement(StyledCodeBlock, _extends({
570
- className: className,
571
- ref: ref,
572
- isLight: isLight
573
- }, other), tokens.map((line, index) => React.createElement(StyledCodeBlockLine, _extends({}, getLineProps({
574
- line
575
- }), {
576
- key: index,
577
- language: language,
578
- isHighlighted: highlightLines && highlightLines.includes(index + 1),
579
- isLight: isLight,
580
- isNumbered: isNumbered,
581
- diff: getDiff(line),
582
- size: size
583
- }), line.map((token, tokenKey) => React.createElement(StyledCodeBlockToken, _extends({}, getTokenProps({
584
- token
585
- }), {
586
- key: tokenKey,
587
- isLight: isLight
588
- }), token.empty ? '\n' : token.content)))));
589
- }));
590
- });
591
- CodeBlock.displayName = 'CodeBlock';
592
- CodeBlock.defaultProps = {
593
- language: 'tsx',
594
- size: 'medium'
595
- };
596
-
597
- const Ellipsis = forwardRef((_ref, ref) => {
598
- let {
599
- children,
600
- title,
601
- tag,
602
- ...other
603
- } = _ref;
604
- let textContent = undefined;
605
- if (title !== undefined) {
606
- textContent = title;
607
- } else if (typeof children === 'string') {
608
- textContent = children;
609
- }
610
- return React.createElement(StyledEllipsis, _extends({
611
- as: tag,
612
- ref: ref,
613
- title: textContent
614
- }, other), children);
615
- });
616
- Ellipsis.displayName = 'Ellipsis';
617
- Ellipsis.propTypes = {
618
- title: PropTypes.string,
619
- tag: PropTypes.any
620
- };
621
- Ellipsis.defaultProps = {
622
- tag: 'div'
623
- };
624
-
625
- const Paragraph = forwardRef((props, ref) => React.createElement(StyledParagraph, _extends({
626
- ref: ref
627
- }, props)));
628
- Paragraph.displayName = 'Paragraph';
629
- Paragraph.propTypes = {
630
- size: PropTypes.oneOf(SIZE)
631
- };
632
- Paragraph.defaultProps = {
633
- size: 'medium'
634
- };
635
-
636
- const OrderedListContext = createContext(undefined);
637
- const useOrderedListContext = () => {
638
- const listContext = useContext(OrderedListContext);
639
- if (!listContext) {
640
- throw new Error('This component must be rendered within an `OrderedList` component.');
641
- }
642
- return listContext;
643
- };
644
-
645
- const OrderedListItem = forwardRef((props, ref) => {
646
- const {
647
- size
648
- } = useOrderedListContext();
649
- return React.createElement(StyledOrderedListItem, _extends({
650
- ref: ref,
651
- space: size
652
- }, props));
653
- });
654
- OrderedListItem.displayName = 'OrderedList.Item';
655
- const Item$1 = OrderedListItem;
656
-
657
- const OrderedListComponent = React.forwardRef((_ref, ref) => {
658
- let {
659
- size,
660
- type,
661
- ...other
662
- } = _ref;
663
- const value = useMemo(() => ({
664
- size: size
665
- }), [size]);
666
- return React.createElement(OrderedListContext.Provider, {
667
- value: value
668
- }, React.createElement(StyledOrderedList, _extends({
669
- ref: ref,
670
- listType: type
671
- }, other)));
672
- });
673
- OrderedListComponent.displayName = 'OrderedList';
674
- OrderedListComponent.propTypes = {
675
- size: PropTypes.oneOf(SIZE),
676
- type: PropTypes.oneOf(TYPE_ORDERED_LIST)
677
- };
678
- OrderedListComponent.defaultProps = {
679
- size: 'medium',
680
- type: 'decimal'
681
- };
682
- const OrderedList = OrderedListComponent;
683
- OrderedList.Item = Item$1;
684
-
685
- const UnorderedListContext = createContext(undefined);
686
- const useUnorderedListContext = () => {
687
- const listContext = useContext(UnorderedListContext);
688
- if (!listContext) {
689
- throw new Error('This component must be rendered within an `UnorderedList` component.');
690
- }
691
- return listContext;
692
- };
693
-
694
- const UnorderedListItem = forwardRef((props, ref) => {
695
- const {
696
- size
697
- } = useUnorderedListContext();
698
- return React.createElement(StyledUnorderedListItem, _extends({
699
- ref: ref,
700
- space: size
701
- }, props));
702
- });
703
- UnorderedListItem.displayName = 'UnorderedList.Item';
704
- const Item = UnorderedListItem;
705
-
706
- const UnorderedListComponent = forwardRef((_ref, ref) => {
707
- let {
708
- size,
709
- type,
710
- ...other
711
- } = _ref;
712
- const value = useMemo(() => ({
713
- size: size
714
- }), [size]);
715
- return React.createElement(UnorderedListContext.Provider, {
716
- value: value
717
- }, React.createElement(StyledUnorderedList, _extends({
718
- ref: ref,
719
- listType: type
720
- }, other)));
721
- });
722
- UnorderedListComponent.displayName = 'UnorderedList';
723
- UnorderedListComponent.propTypes = {
724
- size: PropTypes.oneOf(SIZE),
725
- type: PropTypes.oneOf(TYPE_UNORDERED_LIST)
726
- };
727
- UnorderedListComponent.defaultProps = {
728
- size: 'medium',
729
- type: 'disc'
730
- };
731
- const UnorderedList = UnorderedListComponent;
732
- UnorderedList.Item = Item;
733
-
734
- const StartIconComponent = props => React.createElement(StyledIcon, _extends({
735
- isStart: true
736
- }, props));
737
- StartIconComponent.displayName = 'Span.StartIcon';
738
- const StartIcon = StartIconComponent;
739
-
740
- const IconComponent = props => React.createElement(StyledIcon, props);
741
- IconComponent.displayName = 'Span.Icon';
742
- const Icon = IconComponent;
743
-
744
- const SpanComponent = forwardRef((_ref, ref) => {
745
- let {
746
- tag,
747
- ...other
748
- } = _ref;
749
- return React.createElement(StyledFont, _extends({
750
- as: tag,
751
- ref: ref,
752
- size: "inherit"
753
- }, other));
754
- });
755
- SpanComponent.displayName = 'Span';
756
- SpanComponent.propTypes = {
757
- tag: PropTypes.any,
758
- isBold: PropTypes.bool,
759
- isMonospace: PropTypes.bool,
760
- hue: PropTypes.string
761
- };
762
- SpanComponent.defaultProps = {
763
- tag: 'span'
764
- };
765
- const Span = SpanComponent;
766
- Span.Icon = Icon;
767
- Span.StartIcon = StartIcon;
768
-
769
- export { Blockquote, Code, CodeBlock, Ellipsis, LG, MD, OrderedList, Paragraph, SM, Span, UnorderedList, XL, XXL, XXXL };