@xyd-js/atlas 0.1.0-xyd.6 → 0.1.0-xyd.69

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 (55) hide show
  1. package/.storybook/index.css +1 -27
  2. package/.storybook/preview.ts +1 -2
  3. package/CHANGELOG.md +710 -0
  4. package/LICENSE +21 -0
  5. package/dist/Update-BMKoKdRb-COLbZvRj.js +4 -0
  6. package/dist/Update-BMKoKdRb-COLbZvRj.js.map +1 -0
  7. package/dist/index.css +43 -54
  8. package/dist/index.d.ts +30 -10
  9. package/dist/index.js +1 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/styles.css +89 -0
  12. package/dist/tokens.css +60 -0
  13. package/dist/xydPlugin.d.ts +5 -0
  14. package/dist/xydPlugin.js +2 -0
  15. package/dist/xydPlugin.js.map +1 -0
  16. package/index.ts +1 -2
  17. package/package.json +20 -21
  18. package/packages/xyd-plugin/SidebarItem.tsx +27 -0
  19. package/packages/xyd-plugin/index.ts +20 -0
  20. package/rollup.config.js +56 -12
  21. package/src/components/ApiRef/ApiRefItem/ApiRefItem.styles.tsx +95 -63
  22. package/src/components/ApiRef/ApiRefItem/ApiRefItem.tsx +511 -53
  23. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.styles.tsx +186 -143
  24. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.tsx +584 -76
  25. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.styles.tsx +19 -23
  26. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.tsx +39 -24
  27. package/src/components/Atlas/Atlas.styles.tsx +3 -5
  28. package/src/components/Atlas/Atlas.tsx +34 -21
  29. package/src/components/Atlas/AtlasContext.tsx +47 -0
  30. package/src/components/Atlas/AtlasDecorator.styles.ts +22 -0
  31. package/src/components/Atlas/AtlasDecorator.tsx +15 -0
  32. package/src/components/Atlas/AtlasLazy/AtlasLazy.styles.tsx +7 -8
  33. package/src/components/Atlas/AtlasLazy/AtlasLazy.tsx +4 -6
  34. package/src/components/Atlas/AtlasPrimary.tsx +21 -0
  35. package/src/components/Atlas/AtlasSecondary.tsx +148 -0
  36. package/src/components/Atlas/index.ts +6 -2
  37. package/src/components/Atlas/types.ts +11 -0
  38. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.styles.tsx +56 -65
  39. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.tsx +19 -28
  40. package/src/components/Code/index.ts +0 -4
  41. package/src/components/Icon/index.tsx +384 -0
  42. package/src/docs/AtlasExample/todo-app.uniform.json +1 -1
  43. package/src/styles/styles.css +89 -0
  44. package/src/styles/tokens.css +60 -0
  45. package/src/utils/mdx.ts +0 -29
  46. package/tsconfig.json +9 -2
  47. package/types.d.ts +22 -0
  48. package/src/components/Code/CodeCopy/CodeCopy.style.tsx +0 -21
  49. package/src/components/Code/CodeCopy/CodeCopy.tsx +0 -32
  50. package/src/components/Code/CodeCopy/index.ts +0 -7
  51. package/src/components/Code/CodeSample/CodeSample.styles.tsx +0 -134
  52. package/src/components/Code/CodeSample/CodeSample.tsx +0 -149
  53. package/src/components/Code/CodeSample/index.ts +0 -8
  54. package/src/components/Code/CodeSample/withLocalStored.tsx +0 -52
  55. package/src/components/Code/default-theme.ts +0 -266
@@ -1,104 +1,283 @@
1
- import React, {useState} from "react";
2
- import {DefinitionProperty} from "@xyd-js/uniform";
3
-
4
- import {MDXReference, mdxValue} from "@/utils/mdx"
5
- import {
6
- $ul,
7
- $li,
8
- $description,
9
- $dl,
10
- $propNameCode,
11
- $propTypeCode,
12
- $subProps,
13
- $propToggle,
14
- } from "./ApiRefProperties.styles";
1
+ import React, { useContext, useState } from "react";
2
+ import { DEFINED_DEFINITION_PROPERTY_TYPE, DefinitionProperty, DefinitionPropertyMeta } from "@xyd-js/uniform";
3
+
4
+ import * as cn from "./ApiRefProperties.styles";
5
+ import { AtlasContext, useBaseMatch } from "@/components/Atlas/AtlasContext";
6
+ import { Badge } from "@xyd-js/components/writer";
15
7
 
16
8
  export interface ApiRefPropertiesProps {
17
- properties: MDXReference<DefinitionProperty[]>
9
+ properties: DefinitionProperty[]
18
10
  }
19
11
 
20
- export function ApiRefProperties({properties}: ApiRefPropertiesProps) {
21
- return <ul className={$ul.host}>
12
+ // TODO: in the future configurable
13
+ const HIDE_INTERNAL = true
14
+
15
+ export function ApiRefProperties({ properties }: ApiRefPropertiesProps) {
16
+ return <ul className={cn.ApiRefPropertiesUlHost}>
22
17
  {
23
- properties?.map((property, i) => (
24
- <li className={$li.host} key={i}>
25
- <dl className={$dl.host}>
26
- <$PropName name="name" value={mdxValue(property.name)}/>
27
- <$PropType
28
- name="type"
29
- value={mdxValue(property.type)}
30
- href={propertyTypeHref(property)}
31
- />
32
- </dl>
33
- <div className={$description.host}>
34
- {property.children}
35
- </div>
18
+ filterProperties(properties)?.map((property, i) => {
19
+ const propName = property.name
20
+ const propValue = property.type
21
+ const propertyProperties = propProperties(property)
22
+ const description = property.ofProperty?.description || property.description || ""
23
+ const metaInfo = renderMetaInfo(property.meta)
24
+
25
+ return <li className={cn.ApiRefPropertiesLiHost} key={i}>
26
+ {
27
+ propName || propValue ?
28
+ <dl className={cn.ApiRefPropertiesDlHost}>
29
+ <PropName property={property} meta={property.meta || []} />
30
+ <PropType
31
+ property={property}
32
+ />
33
+ <PropMetaList
34
+ metas={property.meta || []}
35
+ />
36
+ </dl> : null
37
+ }
38
+
39
+ {
40
+ description || metaInfo ? <div className={cn.ApiRefPropertiesDescriptionHost}>
41
+ <>
42
+ <div>
43
+ {description}
44
+ </div>
45
+ <div>
46
+ {renderMetaInfo(property.meta)}
47
+ </div>
48
+ </>
49
+ </div> : null
50
+ }
51
+
36
52
  {
37
- property.properties ?
38
- <$SubProperties
39
- properties={property.properties as MDXReference<DefinitionProperty>[]}
53
+ propertyProperties?.length > 0 ?
54
+ <SubProperties
55
+ parent={property}
56
+ properties={propertyProperties}
40
57
  /> : null
41
58
  }
42
59
  </li>
43
- ))
60
+ })
44
61
  }
45
62
  </ul>
46
63
  }
47
64
 
48
- function $PropName({name, value}: { name: string, value: string }) {
49
- return <>
65
+
66
+ interface PropNameProps {
67
+ property: DefinitionProperty
68
+ meta: DefinitionPropertyMeta[]
69
+ parentChoiceType?: boolean
70
+ }
71
+
72
+ function PropName(props: PropNameProps) {
73
+ const value = props.property.name
74
+
75
+ if (!value) {
76
+ return null
77
+ }
78
+
79
+ return <atlas-apiref-propname>
50
80
  <dd>
51
- <code className={$propNameCode.host}>{value}</code>
81
+ <code
82
+ data-parent-choice-type={props.parentChoiceType ? "true" : undefined}
83
+ className={cn.ApiRefPropertiesPropNameCodeHost}
84
+ >{value}</code>
52
85
  </dd>
53
- </>
86
+ </atlas-apiref-propname>
54
87
  }
55
88
 
56
- function $PropType({name, value, href}: { name: string, value: string, href?: string }) {
57
- return <>
89
+ interface PropTypeProps {
90
+ property: DefinitionProperty
91
+ }
92
+
93
+ function PropType({ property }: PropTypeProps) {
94
+ const { Link = "a" } = useContext(AtlasContext)
95
+ const href = useSymbolLink(property)
96
+
97
+ const symbol = resolvePropertySymbol(property)
98
+
99
+ let propSymbol: string | React.ReactNode = symbol
100
+
101
+ if (!propSymbol) {
102
+ return null
103
+ }
104
+
105
+ if (href) {
106
+ propSymbol = <Link className={cn.ApiRefPropertiesPropTypeCodeLink} href={href}>{propSymbol}</Link>
107
+ }
108
+
109
+ return <atlas-apiref-proptype>
110
+ <dd>
111
+ <code className={cn.ApiRefPropertiesPropTypeCodeHost}>
112
+ {propSymbol}
113
+ </code>
114
+ </dd>
115
+ </atlas-apiref-proptype>
116
+ }
117
+
118
+ export interface PropMetaProps extends DefinitionPropertyMeta {
119
+ href?: string
120
+ }
121
+
122
+ function PropMeta(props: PropMetaProps) {
123
+ let valueText = props.value
124
+
125
+ switch (props.name) {
126
+ case "required":
127
+ valueText = "Required"
128
+ break
129
+ case "deprecated":
130
+ valueText = "Deprecated"
131
+ break
132
+ case "defaults":
133
+ valueText = `Defaults: ${props.value}`
134
+ break
135
+ case "nullable":
136
+ return null
137
+ case "enum-type":
138
+ return null
139
+ case "minimum":
140
+ return null
141
+ case "maximum":
142
+ return null
143
+ case "example":
144
+ return null
145
+ case "examples":
146
+ return null
147
+ case "internal":
148
+ return null
149
+ case "hasArguments":
150
+ return null
151
+ }
152
+
153
+ return <atlas-apiref-propmeta data-name={props.name} data-value={props.value}>
58
154
  <dd>
59
- <code className={$propTypeCode.host}>
155
+ <code>
60
156
  {
61
- href
62
- ? <a className={$propTypeCode.link} href={href}>{value}</a>
63
- : value
157
+ props.href
158
+ ? <a href={props.href}>{valueText}</a>
159
+ : valueText
64
160
  }
65
161
  </code>
66
162
  </dd>
163
+ </atlas-apiref-propmeta>
164
+ }
165
+
166
+ export interface PropMetaListProps {
167
+ metas: PropMetaProps[]
168
+ }
169
+
170
+ function PropMetaList({ metas }: PropMetaListProps) {
171
+ const order = { deprecated: 0, required: 1, defaults: 2 };
172
+
173
+ const sortedMetas = [...metas].sort((a, b) => {
174
+ return (order[a.name as keyof typeof order] ?? 3) - (order[b.name as keyof typeof order] ?? 3);
175
+ });
176
+
177
+ return <>
178
+ {
179
+ sortedMetas.map((meta, i) => (
180
+ <PropMeta
181
+ key={i}
182
+ {...meta}
183
+ />
184
+ ))
185
+ }
67
186
  </>
68
187
  }
69
188
 
70
- function $SubProperties({properties}: { properties: MDXReference<DefinitionProperty>[] }) {
189
+ interface SubPropertiesProps {
190
+ parent: DefinitionProperty
191
+
192
+ properties: DefinitionProperty[]
193
+ }
194
+
195
+ function SubProperties({ parent, properties }: SubPropertiesProps) {
71
196
  const [expanded, setExpanded] = useState(false)
72
197
 
198
+ // Get the actual properties to display
199
+ const foundProperties = filterProperties(properties || [])
200
+
201
+ const choiceType = isChoiceType(parent)
202
+ const noChildProps = function () {
203
+ if (parent?.type === DEFINED_DEFINITION_PROPERTY_TYPE.ENUM) {
204
+ return false
205
+ }
206
+
207
+ return foundProperties.every(prop => {
208
+ if (prop.ofProperty) {
209
+ return false
210
+ }
211
+
212
+ return !(prop.properties?.length ?? 0)
213
+ })
214
+ }()
215
+
216
+ if (choiceType && noChildProps) {
217
+ return null
218
+ }
219
+
220
+ const hasArguments = parent.meta?.some(m => m.name === 'hasArguments' && m.value === 'true')
221
+
73
222
  return <>
74
- <$PropToggle
223
+ {foundProperties?.length ? <PropToggle
224
+ choiceType={choiceType}
225
+ isArgument={hasArguments}
75
226
  onClick={() => setExpanded(!expanded)}
76
227
  isExpanded={expanded}
77
- />
228
+ /> : null}
78
229
 
79
230
  <div
80
- className={`${$subProps.host} ${expanded && $subProps.host$$expanded}`}
231
+ className={`${cn.ApiRefPropertiesSubPropsHost} ${expanded && cn.ApiRefPropertiesSubPropsHostExpanded}`}
81
232
  >
82
- <div className={$subProps.box}>
83
- <ul role="list" className={$subProps.ul}>
233
+ <div className={cn.ApiRefPropertiesSubPropsBox}>
234
+ <ul role="list" className={cn.ApiRefPropertiesSubPropsUl}>
84
235
  {
85
- properties?.map((prop, i) => {
86
- return <li className={$subProps.li} key={i}>
87
- <dl className={$dl.host}>
88
- <$PropName name="name" value={mdxValue(prop.name)}/>
89
- <$PropType
90
- name="type"
91
- value={mdxValue(prop.type)}
92
- href={propertyTypeHref(prop)}
93
- />
94
- </dl>
95
- <div className={$description.host}>
96
- {prop.children}
97
- </div>
236
+ foundProperties?.map((prop, i) => {
237
+ const propName = prop.name
238
+ const propValue = prop.type
239
+ const properties = propProperties(prop)
240
+ const description = prop.ofProperty?.description || prop.description || ""
241
+ const metaInfo = renderMetaInfo(prop.meta)
242
+
243
+ return <li className={cn.ApiRefPropertiesSubPropsLi} key={i}>
244
+ {
245
+ propName || propValue ?
246
+ <dl className={cn.ApiRefPropertiesDlHost}>
247
+ <PropName
248
+ property={prop}
249
+ meta={prop.meta || []}
250
+ parentChoiceType={choiceType || !!hasArguments}
251
+ />
252
+ <PropType
253
+ property={prop}
254
+ />
255
+ <PropMetaList
256
+ metas={prop.meta || []}
257
+ />
258
+ </dl> : null
259
+ }
260
+
261
+ {
262
+ description || metaInfo
263
+ ? <div className={cn.ApiRefPropertiesDescriptionHost}>
264
+ <>
265
+ <div>
266
+ {description}
267
+ </div>
268
+ <div>
269
+ {renderMetaInfo(prop.meta)}
270
+ </div>
271
+ </>
272
+ </div>
273
+ : null
274
+ }
98
275
  {
99
- prop.properties ?
100
- <$SubProperties
101
- properties={prop.properties as MDXReference<DefinitionProperty>[]}/> : null
276
+ properties?.length ?
277
+ <SubProperties
278
+ parent={prop}
279
+ properties={properties}
280
+ /> : null
102
281
  }
103
282
  </li>
104
283
  })
@@ -112,16 +291,28 @@ function $SubProperties({properties}: { properties: MDXReference<DefinitionPrope
112
291
 
113
292
  interface PropsToggleProps {
114
293
  isExpanded: boolean
294
+ choiceType: boolean
295
+ isArgument?: boolean
115
296
  onClick: () => void
116
297
  }
117
298
 
118
- function $PropToggle(props: PropsToggleProps) {
299
+ function PropToggle(
300
+ props: PropsToggleProps
301
+ ) {
302
+ let text = props.isExpanded ? 'Hide properties' : 'Show properties'
303
+
304
+ if (props.choiceType) {
305
+ text = props.isExpanded ? 'Hide possible types' : 'Show possible types'
306
+ } else if (props.isArgument) {
307
+ text = props.isExpanded ? 'Hide possible arguments' : 'Show possible arguments'
308
+ }
309
+
119
310
  return (
120
311
  <button
121
312
  aria-expanded={props.isExpanded}
122
313
  aria-controls="chat/object-usage_table"
123
314
  onClick={props.onClick}
124
- className={$propToggle.host}
315
+ className={cn.ApiRefPropertiesPropToggleHost}
125
316
  >
126
317
  <svg
127
318
  xmlns="http://www.w3.org/2000/svg"
@@ -140,18 +331,335 @@ function $PropToggle(props: PropsToggleProps) {
140
331
  clipRule="evenodd"
141
332
  />
142
333
  </svg>
143
- <span className={$propToggle.link}>{props.isExpanded ? 'Hide properties' : 'Show properties'}</span>
334
+ <span className={cn.ApiRefPropertiesPropToggleLink}>
335
+ {text}
336
+ </span>
144
337
  </button>
145
338
  )
146
339
  }
147
340
 
148
- function propertyTypeHref(property: MDXReference<DefinitionProperty>) {
149
- if (property?.context?.graphqlBuiltInType?.title === "true") { // graphqlBuiltInType should be a boolean
150
- return undefined
341
+ function isChoiceType(property: DefinitionProperty) {
342
+ if (property.ofProperty) {
343
+ return isChoiceType(property.ofProperty)
344
+ }
345
+
346
+ return [
347
+ DEFINED_DEFINITION_PROPERTY_TYPE.UNION,
348
+ DEFINED_DEFINITION_PROPERTY_TYPE.XOR,
349
+ DEFINED_DEFINITION_PROPERTY_TYPE.ENUM,
350
+ ].includes(property.type as DEFINED_DEFINITION_PROPERTY_TYPE)
351
+ }
352
+
353
+ function useSymbolLink(property: DefinitionProperty) {
354
+ const baseMatch = useBaseMatch()
355
+
356
+ if (!property?.symbolDef?.canonical?.length) {
357
+ return ""
358
+ }
359
+
360
+ let symbolLink = property.symbolDef.canonical
361
+
362
+ if (!Array.isArray(symbolLink)) { // TODO: support array of canonicals
363
+ if (!symbolLink.startsWith("/")) {
364
+ symbolLink = "/" + symbolLink
365
+ }
366
+
367
+ return `${baseMatch}${symbolLink}`;
368
+ } else {
369
+ console.warn("Multiple canonical links found for property", property.name, property.symbolDef.canonical)
370
+ }
371
+
372
+ return ""
373
+ }
374
+
375
+ function propProperties(prop: DefinitionProperty): DefinitionProperty[] {
376
+ if (prop.properties?.length) {
377
+ return prop.properties
378
+ }
379
+
380
+ if (prop.ofProperty) {
381
+ return propProperties(prop.ofProperty)
382
+ }
383
+
384
+ return []
385
+ }
386
+
387
+ function filterProperties(properties: DefinitionProperty[]): DefinitionProperty[] {
388
+ return properties.filter(property => {
389
+ if (property?.meta?.some(m => m.name === "internal" && m.value === "true")) {
390
+ if (HIDE_INTERNAL) {
391
+ return false
392
+ }
393
+ }
394
+
395
+ return true
396
+ })
397
+ }
398
+
399
+ function resolvePropertySymbol(property: DefinitionProperty): string {
400
+ function resolvePropertySymbolInner(property: DefinitionProperty) {
401
+ if (property?.ofProperty) {
402
+ switch (property.ofProperty.type) {
403
+ case DEFINED_DEFINITION_PROPERTY_TYPE.ARRAY: {
404
+ let ofOfSymbols: string[] = []
405
+
406
+ if (property.type) {
407
+ ofOfSymbols.push(property.type)
408
+ }
409
+
410
+ if (property.ofProperty.ofProperty) {
411
+ const symbol = groupSymbol(property.ofProperty.ofProperty)
412
+
413
+ if (symbol) {
414
+ ofOfSymbols.push(symbol)
415
+ }
416
+ }
417
+
418
+ const atomicDefinedSymbol = atomicDefinedPropertySymbol(property.ofProperty)
419
+ const ofPrefix = [
420
+ atomicDefinedSymbol,
421
+ "of"
422
+ ]
423
+
424
+ return [
425
+ [
426
+ ...ofPrefix,
427
+ ...ofOfSymbols
428
+ ].join(" ")
429
+ ]
430
+ }
431
+ case DEFINED_DEFINITION_PROPERTY_TYPE.UNION:
432
+ case DEFINED_DEFINITION_PROPERTY_TYPE.ENUM:
433
+ case DEFINED_DEFINITION_PROPERTY_TYPE.XOR: {
434
+ if (property.ofProperty.properties?.length) {
435
+ const atomicDefinedSymbol = atomicDefinedPropertySymbol(property)
436
+
437
+ if (atomicDefinedSymbol) {
438
+ const unionSymbol = groupSymbol({
439
+ name: "",
440
+ description: "",
441
+ type: DEFINED_DEFINITION_PROPERTY_TYPE.UNION,
442
+ properties: property.ofProperty.properties || [],
443
+ })
444
+
445
+ if (unionSymbol?.length && unionSymbol.includes("$$")) {
446
+ return [atomicDefinedSymbol]
447
+ }
448
+
449
+ return [
450
+ [
451
+ atomicDefinedSymbol,
452
+ "of",
453
+ unionSymbol
454
+ ].join(" ")
455
+ ]
456
+ }
457
+
458
+ return [
459
+ property.type,
460
+ groupSymbol(property.ofProperty)
461
+ ]
462
+ }
463
+
464
+ if (property.ofProperty?.ofProperty) {
465
+ return [property.ofProperty?.ofProperty?.type]
466
+ }
467
+
468
+ return []
469
+ }
470
+ default: {
471
+ if (!property.ofProperty.name) {
472
+ const defined = atomicDefinedPropertySymbol(property)
473
+ const symbol = atomicPropertySymbol(property)
474
+
475
+ if (symbol.startsWith("$$")) {
476
+ return [property.ofProperty.type]
477
+ }
478
+
479
+ const chains = [
480
+ symbol
481
+ ]
482
+
483
+ if (defined) {
484
+ chains.push("of")
485
+ }
486
+
487
+ chains.push(
488
+ groupSymbol(property.ofProperty)
489
+ )
490
+
491
+ return chains
492
+ }
493
+
494
+ return [
495
+ property.ofProperty.type
496
+ ]
497
+ }
498
+ }
499
+ }
500
+
501
+ switch (property.type) {
502
+ case DEFINED_DEFINITION_PROPERTY_TYPE.UNION, DEFINED_DEFINITION_PROPERTY_TYPE.XOR: {
503
+ if (property.properties?.length) {
504
+ const respMap = {}
505
+ let resp: string[] = []
506
+ for (const prop of property.properties) {
507
+ let symbols = resolvePropertySymbolInner(prop)
508
+
509
+ if (prop.ofProperty && symbols.length > 1) {
510
+ symbols = [[
511
+ symbols[0],
512
+ ...symbols.slice(1, symbols.length),
513
+ ].join("")]
514
+ }
515
+
516
+ resp.push(...symbols)
517
+ }
518
+
519
+ let hasOr = false // TODO: in the future better
520
+ for (const symbol of resp) {
521
+ if (symbol.trim() === "or") {
522
+ hasOr = true
523
+ break
524
+ }
525
+ respMap[symbol] = true
526
+ }
527
+
528
+ if (!hasOr) {
529
+ resp = Object.keys(respMap)
530
+ }
531
+
532
+ return [resp.join(" or ")]
533
+ }
534
+
535
+ break
536
+ }
537
+
538
+ case DEFINED_DEFINITION_PROPERTY_TYPE.ARRAY: {
539
+ return ["array"]
540
+ }
541
+
542
+ case DEFINED_DEFINITION_PROPERTY_TYPE.ENUM: {
543
+ return ["enum"]
544
+ }
545
+ }
546
+
547
+ if (property.type?.startsWith("$$")) {
548
+ return []
549
+ }
550
+
551
+ return [property.type]
552
+ }
553
+
554
+ const symbolsParts = resolvePropertySymbolInner(property)
555
+ if (nullableProperty(property)) {
556
+ if (symbolsParts.length) {
557
+ symbolsParts.push("or", "null")
558
+ } else {
559
+ symbolsParts.push("null")
560
+ }
561
+ }
562
+
563
+ return symbolsParts.join(" ")
564
+ }
565
+
566
+ function atomicDefinedPropertySymbol(property: DefinitionProperty): string {
567
+ switch (property.type) {
568
+ case DEFINED_DEFINITION_PROPERTY_TYPE.ARRAY: {
569
+ return "array"
570
+ }
571
+ case DEFINED_DEFINITION_PROPERTY_TYPE.UNION:
572
+ case DEFINED_DEFINITION_PROPERTY_TYPE.ENUM:
573
+ case DEFINED_DEFINITION_PROPERTY_TYPE.XOR: {
574
+ return ""
575
+ }
576
+
577
+ default: {
578
+ return ""
579
+ }
580
+ }
581
+ }
582
+
583
+ function groupSymbol(property: DefinitionProperty) {
584
+ const symbol = resolvePropertySymbol(property)
585
+ if (symbol?.startsWith("$$")) {
586
+ return ""
587
+ }
588
+
589
+ return symbol
590
+ }
591
+
592
+ function atomicPropertySymbol(property: DefinitionProperty): string {
593
+ const defined = atomicDefinedPropertySymbol(property)
594
+
595
+ if (!defined) {
596
+ return property.type
597
+ }
598
+
599
+ return defined
600
+ }
601
+
602
+ function nullableProperty(property: DefinitionProperty): boolean {
603
+ return property.meta?.some(m => m.name === "nullable" && m.value === "true") || false
604
+ }
605
+
606
+ function renderMetaInfo(meta: DefinitionPropertyMeta[] | undefined) {
607
+ if (!meta?.length) return null;
608
+
609
+ const minimum = meta.find(m => m.name === 'minimum')?.value;
610
+ const maximum = meta.find(m => m.name === 'maximum')?.value;
611
+ const example = meta.find(m => m.name === 'example')?.value;
612
+ const examples = meta.find(m => m.name === 'examples')?.value;
613
+
614
+ const rangeInfo: React.ReactNode[] = [];
615
+ if (minimum !== undefined && maximum !== undefined) {
616
+ rangeInfo.push(
617
+ <div>
618
+ Required range: <Badge>
619
+ {`${minimum} <= x <= ${maximum}`}
620
+ </Badge>
621
+ </div>
622
+ );
623
+ } else if (minimum !== undefined) {
624
+ rangeInfo.push(
625
+ <div>
626
+ Required range: <Badge>
627
+ {`x >= ${minimum}`}
628
+ </Badge>
629
+ </div>
630
+ );
631
+ } else if (maximum !== undefined) {
632
+ rangeInfo.push(
633
+ <div>
634
+ Required range: <Badge>
635
+ {`x <= ${maximum}`}
636
+ </Badge>
637
+ </div>
638
+ );
151
639
  }
152
640
 
153
- // TODO: FINISH SLUG
154
- return property.context?.graphqlTypeShort?.title
155
- ? `/docs/api/graphql/${property.context?.graphqlTypeShort?.title}-${mdxValue(property.context?.graphqlTypeFlat?.title)}`
156
- : undefined
641
+ const exampleInfo = example || examples ? <div part="examples">
642
+ <span>Examples:</span>
643
+ {
644
+ example ? <Badge>{`${example}`}</Badge> : null
645
+ }
646
+ {
647
+ Array.isArray(examples) && <div part="examples-list">
648
+ {examples.map((example, i) => (
649
+ <Badge key={`example-${i}`}>{`${example}`}</Badge>
650
+ ))}
651
+ </div>
652
+ }
653
+ </div> : null
654
+
655
+ if (!rangeInfo?.length && !exampleInfo) {
656
+ return null
657
+ }
658
+
659
+ return <atlas-apiref-meta-info className={cn.ApiRefPropertiesMetaInfoHost}>
660
+ {rangeInfo?.map((info, i) => (
661
+ <div key={`range-${i}`}>{info}</div>
662
+ ))}
663
+ {exampleInfo}
664
+ </atlas-apiref-meta-info>
157
665
  }