@xyd-js/atlas 0.1.0-build.173

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 (68) hide show
  1. package/.babelrc +6 -0
  2. package/.storybook/index.css +6 -0
  3. package/.storybook/main.ts +19 -0
  4. package/.storybook/preview.ts +17 -0
  5. package/.storybook/public/fonts/fustat-ext-500.woff2 +0 -0
  6. package/.storybook/public/fonts/fustat-ext-600.woff2 +0 -0
  7. package/.storybook/public/fonts/fustat-ext-700.woff2 +0 -0
  8. package/.storybook/public/fonts/fustat-regular.woff2 +0 -0
  9. package/CHANGELOG.md +1984 -0
  10. package/LICENSE +21 -0
  11. package/README.md +3 -0
  12. package/declarations.d.ts +4 -0
  13. package/dist/VideoGuide-C0K9fFar-Dk2lkn4r.js +4 -0
  14. package/dist/VideoGuide-C0K9fFar-Dk2lkn4r.js.map +1 -0
  15. package/dist/VideoGuide-CJYkuLst-Dk2lkn4r.js +4 -0
  16. package/dist/VideoGuide-CJYkuLst-Dk2lkn4r.js.map +1 -0
  17. package/dist/index.css +48 -0
  18. package/dist/index.d.ts +38 -0
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/styles.css +104 -0
  22. package/dist/tokens.css +60 -0
  23. package/dist/xydPlugin.d.ts +5 -0
  24. package/dist/xydPlugin.js +2 -0
  25. package/dist/xydPlugin.js.map +1 -0
  26. package/index.ts +2 -0
  27. package/package.json +68 -0
  28. package/packages/xyd-plugin/SidebarItem.tsx +27 -0
  29. package/packages/xyd-plugin/index.ts +20 -0
  30. package/postcss.config.cjs +5 -0
  31. package/rollup.config.js +120 -0
  32. package/src/components/ApiRef/ApiRefItem/ApiRefItem.styles.tsx +110 -0
  33. package/src/components/ApiRef/ApiRefItem/ApiRefItem.tsx +557 -0
  34. package/src/components/ApiRef/ApiRefItem/index.ts +7 -0
  35. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.styles.tsx +202 -0
  36. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.tsx +665 -0
  37. package/src/components/ApiRef/ApiRefProperties/index.ts +7 -0
  38. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.styles.tsx +28 -0
  39. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.tsx +69 -0
  40. package/src/components/ApiRef/ApiRefSamples/index.ts +7 -0
  41. package/src/components/ApiRef/index.ts +5 -0
  42. package/src/components/Atlas/Atlas.styles.tsx +5 -0
  43. package/src/components/Atlas/Atlas.tsx +43 -0
  44. package/src/components/Atlas/AtlasContext.tsx +47 -0
  45. package/src/components/Atlas/AtlasDecorator.styles.ts +22 -0
  46. package/src/components/Atlas/AtlasDecorator.tsx +15 -0
  47. package/src/components/Atlas/AtlasLazy/AtlasLazy.styles.tsx +9 -0
  48. package/src/components/Atlas/AtlasLazy/AtlasLazy.tsx +42 -0
  49. package/src/components/Atlas/AtlasLazy/hooks.ts +29 -0
  50. package/src/components/Atlas/AtlasLazy/index.ts +7 -0
  51. package/src/components/Atlas/AtlasPrimary.tsx +21 -0
  52. package/src/components/Atlas/AtlasSecondary.tsx +148 -0
  53. package/src/components/Atlas/index.ts +7 -0
  54. package/src/components/Atlas/types.ts +11 -0
  55. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.styles.tsx +58 -0
  56. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.tsx +97 -0
  57. package/src/components/Code/CodeSampleButtons/index.ts +7 -0
  58. package/src/components/Code/index.ts +2 -0
  59. package/src/components/Icon/index.tsx +386 -0
  60. package/src/docs/AtlasExample/AtlasExample.stories.tsx +47 -0
  61. package/src/docs/AtlasExample/todo-app.uniform.json +625 -0
  62. package/src/docs/AtlasExample/uniform-to-references.ts +101 -0
  63. package/src/styles/styles.css +104 -0
  64. package/src/styles/tokens.css +60 -0
  65. package/src/utils/mdx.ts +2 -0
  66. package/tsconfig.json +51 -0
  67. package/types.d.ts +22 -0
  68. package/vite.config.ts +25 -0
@@ -0,0 +1,665 @@
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";
7
+
8
+ export interface ApiRefPropertiesProps {
9
+ properties: DefinitionProperty[]
10
+ }
11
+
12
+ // TODO: in the future configurable
13
+ const HIDE_INTERNAL = true
14
+
15
+ export function ApiRefProperties({ properties }: ApiRefPropertiesProps) {
16
+ return <ul className={cn.ApiRefPropertiesUlHost}>
17
+ {
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
+
52
+ {
53
+ propertyProperties?.length > 0 ?
54
+ <SubProperties
55
+ parent={property}
56
+ properties={propertyProperties}
57
+ /> : null
58
+ }
59
+ </li>
60
+ })
61
+ }
62
+ </ul>
63
+ }
64
+
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>
80
+ <dd>
81
+ <code
82
+ data-parent-choice-type={props.parentChoiceType ? "true" : undefined}
83
+ className={cn.ApiRefPropertiesPropNameCodeHost}
84
+ >{value}</code>
85
+ </dd>
86
+ </atlas-apiref-propname>
87
+ }
88
+
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}>
154
+ <dd>
155
+ <code>
156
+ {
157
+ props.href
158
+ ? <a href={props.href}>{valueText}</a>
159
+ : valueText
160
+ }
161
+ </code>
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
+ }
186
+ </>
187
+ }
188
+
189
+ interface SubPropertiesProps {
190
+ parent: DefinitionProperty
191
+
192
+ properties: DefinitionProperty[]
193
+ }
194
+
195
+ function SubProperties({ parent, properties }: SubPropertiesProps) {
196
+ const [expanded, setExpanded] = useState(false)
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
+
222
+ return <>
223
+ {foundProperties?.length ? <PropToggle
224
+ choiceType={choiceType}
225
+ isArgument={hasArguments}
226
+ onClick={() => setExpanded(!expanded)}
227
+ isExpanded={expanded}
228
+ /> : null}
229
+
230
+ <div
231
+ className={`${cn.ApiRefPropertiesSubPropsHost} ${expanded && cn.ApiRefPropertiesSubPropsHostExpanded}`}
232
+ >
233
+ <div className={cn.ApiRefPropertiesSubPropsBox}>
234
+ <ul role="list" className={cn.ApiRefPropertiesSubPropsUl}>
235
+ {
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
+ }
275
+ {
276
+ properties?.length ?
277
+ <SubProperties
278
+ parent={prop}
279
+ properties={properties}
280
+ /> : null
281
+ }
282
+ </li>
283
+ })
284
+ }
285
+ </ul>
286
+ </div>
287
+ </div>
288
+ </>
289
+ }
290
+
291
+
292
+ interface PropsToggleProps {
293
+ isExpanded: boolean
294
+ choiceType: boolean
295
+ isArgument?: boolean
296
+ onClick: () => void
297
+ }
298
+
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
+
310
+ return (
311
+ <button
312
+ aria-expanded={props.isExpanded}
313
+ aria-controls="chat/object-usage_table"
314
+ onClick={props.onClick}
315
+ className={cn.ApiRefPropertiesPropToggleHost}
316
+ >
317
+ <svg
318
+ xmlns="http://www.w3.org/2000/svg"
319
+ width="1em"
320
+ height="1em"
321
+ fill="currentColor"
322
+ viewBox="0 0 24 24"
323
+ >
324
+ <path
325
+ fillRule="evenodd"
326
+ d={
327
+ props.isExpanded
328
+ ? "M12 8a1 1 0 0 1 .707.293l7 7a1 1 0 0 1-1.414 1.414L12 10.414l-6.293 6.293a1 1 0 0 1-1.414-1.414l7-7A1 1 0 0 1 12 8Z"
329
+ : "M4.293 8.293a1 1 0 0 1 1.414 0L12 14.586l6.293-6.293a1 1 0 1 1 1.414 1.414l-7 7a1 1 0 0 1-1.414 0l-7-7a1 1 0 0 1 0-1.414Z"
330
+ }
331
+ clipRule="evenodd"
332
+ />
333
+ </svg>
334
+ <span className={cn.ApiRefPropertiesPropToggleLink}>
335
+ {text}
336
+ </span>
337
+ </button>
338
+ )
339
+ }
340
+
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
+ );
639
+ }
640
+
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>
665
+ }
@@ -0,0 +1,7 @@
1
+ export {
2
+ ApiRefProperties
3
+ } from "./ApiRefProperties"
4
+
5
+ export type {
6
+ ApiRefPropertiesProps
7
+ } from "./ApiRefProperties"
@@ -0,0 +1,28 @@
1
+ import {css} from "@linaria/core";
2
+
3
+ export const ApiRefSamplesContainerHost = css`
4
+ height: fit-content;
5
+ display: flex;
6
+ gap: 32px;
7
+ flex-direction: column;
8
+ position: relative;
9
+ top: var(--sidebar-subheader-top, 12px);
10
+
11
+ @media (min-width: 1280px) {
12
+ position: sticky;
13
+ }
14
+
15
+ &:first-child {
16
+ margin-top: 0;
17
+ }
18
+
19
+ &:last-child {
20
+ margin-bottom: 0;
21
+ }
22
+ `;
23
+
24
+ export const ApiRefSamplesGroupHost = css`
25
+ gap: 10px;
26
+ display: flex;
27
+ flex-direction: column;
28
+ `;