@stainless-api/docs-ui 0.1.0-beta.26 → 0.1.0-beta.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +653 -683
- package/dist/mcp.cjs +326 -351
- package/dist/styles/primitives.css +0 -198
- package/package.json +4 -4
- package/src/components/index.ts +0 -1
- package/src/style.ts +0 -12
- package/src/styles/primitives.css +0 -198
- package/src/components/dropdown.tsx +0 -91
- package/src/components/scripts/dropdown.ts +0 -78
|
@@ -359,206 +359,8 @@
|
|
|
359
359
|
align-items: center;
|
|
360
360
|
gap: 0.5rem;
|
|
361
361
|
margin: 0;
|
|
362
|
-
height: var(--stldocs-button-size);
|
|
363
362
|
}
|
|
364
363
|
}
|
|
365
|
-
|
|
366
|
-
/* Dropdown component styles */
|
|
367
|
-
.stldocs-dropdown {
|
|
368
|
-
position: relative;
|
|
369
|
-
font-size: 0.85rem;
|
|
370
|
-
|
|
371
|
-
span {
|
|
372
|
-
display: flex;
|
|
373
|
-
align-items: center;
|
|
374
|
-
justify-content: center;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
.stldocs-dropdown-trigger {
|
|
379
|
-
display: flex;
|
|
380
|
-
align-items: center;
|
|
381
|
-
justify-content: space-between;
|
|
382
|
-
gap: 6px;
|
|
383
|
-
padding: 0.5rem;
|
|
384
|
-
|
|
385
|
-
.stldocs-icon {
|
|
386
|
-
margin: unset;
|
|
387
|
-
width: 16px;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
&:hover {
|
|
391
|
-
border-color: var(--stldocs-color-hairline-shade);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
.stldocs-dropdown-trigger-content {
|
|
396
|
-
display: flex;
|
|
397
|
-
align-items: center;
|
|
398
|
-
gap: 8px;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
.stldocs-dropdown-chevron {
|
|
402
|
-
margin-right: calc(-1 * var(--sl-button-icon-offset));
|
|
403
|
-
padding: 0;
|
|
404
|
-
opacity: 0.25;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
.stldocs-dropdown-chevron svg path {
|
|
408
|
-
stroke: var(--stldocs-color-text-secondary);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
.stldocs-dropdown-menu {
|
|
412
|
-
--stldocs-dropdown-menu-border-radius: 8px;
|
|
413
|
-
--stldocs-dropdown-menu-background-color: var(--stldocs-color-bg);
|
|
414
|
-
--stldocs-dropdown-menu-border-color: var(--stldocs-color-hairline);
|
|
415
|
-
|
|
416
|
-
position: absolute;
|
|
417
|
-
right: 0;
|
|
418
|
-
bottom: 100%;
|
|
419
|
-
z-index: var(--stldocs-z-index-theme-select);
|
|
420
|
-
background: var(--stldocs-dropdown-menu-background-color);
|
|
421
|
-
border: 1px solid var(--stldocs-dropdown-menu-border-color);
|
|
422
|
-
border-radius: var(--stldocs-dropdown-menu-border-radius);
|
|
423
|
-
margin-bottom: 4px;
|
|
424
|
-
padding: 0;
|
|
425
|
-
width: 100%;
|
|
426
|
-
min-width: 100px;
|
|
427
|
-
overflow: hidden;
|
|
428
|
-
display: none;
|
|
429
|
-
box-shadow: 0px 4px 4px -2px #00000014;
|
|
430
|
-
|
|
431
|
-
&.below {
|
|
432
|
-
margin-bottom: unset;
|
|
433
|
-
bottom: unset;
|
|
434
|
-
top: 100%;
|
|
435
|
-
margin-top: 4px;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
.stldocs-dropdown-menu.open {
|
|
440
|
-
display: block;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
.stldocs-dropdown-item {
|
|
444
|
-
display: flex;
|
|
445
|
-
align-items: center;
|
|
446
|
-
justify-content: space-between;
|
|
447
|
-
gap: 8px;
|
|
448
|
-
padding: 6px 10px;
|
|
449
|
-
cursor: pointer;
|
|
450
|
-
height: 32px;
|
|
451
|
-
|
|
452
|
-
div {
|
|
453
|
-
display: flex;
|
|
454
|
-
align-items: center;
|
|
455
|
-
gap: 8px;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
.lucide-check {
|
|
459
|
-
height: var(--stlodcs-font-size-body);
|
|
460
|
-
width: var(--stlodcs-font-size-body);
|
|
461
|
-
display: none;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
.stldocs-icon {
|
|
465
|
-
width: 16px;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
&.stldocs-dropdown-item-link {
|
|
469
|
-
padding: 0;
|
|
470
|
-
height: unset;
|
|
471
|
-
gap: 0;
|
|
472
|
-
|
|
473
|
-
a {
|
|
474
|
-
display: flex;
|
|
475
|
-
align-items: center;
|
|
476
|
-
justify-content: space-between;
|
|
477
|
-
gap: 8px;
|
|
478
|
-
padding: 6px 10px;
|
|
479
|
-
cursor: pointer;
|
|
480
|
-
height: 32px;
|
|
481
|
-
width: 100%;
|
|
482
|
-
text-decoration: none;
|
|
483
|
-
color: inherit;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
.stldocs-dropdown-item:hover {
|
|
489
|
-
background-color: var(--stldocs-color-bg-inline-code);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
.stldocs-dropdown-item.selected {
|
|
493
|
-
.lucide-check {
|
|
494
|
-
display: inline;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
@media (min-width: 50rem) {
|
|
499
|
-
.stldocs-dropdown-menu {
|
|
500
|
-
margin-bottom: unset;
|
|
501
|
-
bottom: unset;
|
|
502
|
-
top: 100%;
|
|
503
|
-
margin-top: 4px;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/* Intentionally not using the stldocs-root selector here, as buttons are sometimes outside the stldocs-root. */
|
|
509
|
-
.stldocs-button {
|
|
510
|
-
border-radius: var(--stldocs-button-border-radius);
|
|
511
|
-
display: flex;
|
|
512
|
-
padding: var(--stldocs-button-padding-y) var(--stldocs-button-padding-x);
|
|
513
|
-
justify-content: center;
|
|
514
|
-
align-items: center;
|
|
515
|
-
height: var(--stldocs-button-size);
|
|
516
|
-
cursor: pointer;
|
|
517
|
-
text-decoration: none;
|
|
518
|
-
text-wrap: nowrap;
|
|
519
|
-
font-weight: 500;
|
|
520
|
-
line-height: 150%;
|
|
521
|
-
font-size: var(--sl-text-sm);
|
|
522
|
-
|
|
523
|
-
span {
|
|
524
|
-
padding-left: var(--sl-button-icon-offset);
|
|
525
|
-
padding-right: var(--sl-button-icon-offset);
|
|
526
|
-
font-size: var(--sl-text-sm);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
&.stldocs-button-icon {
|
|
530
|
-
> svg {
|
|
531
|
-
margin: 0;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
.stldocs-button-icon {
|
|
537
|
-
> svg {
|
|
538
|
-
margin: 0;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
.stldocs-button-primary {
|
|
543
|
-
background-color: var(--stldocs-color-text);
|
|
544
|
-
color: var(--stldocs-color-text-invert);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
.stldocs-button-secondary {
|
|
548
|
-
background-color: var(--stldocs-color-bg-ui);
|
|
549
|
-
border: 1px solid var(--stldocs-color-hairline);
|
|
550
|
-
border-radius: var(--stldocs-button-border-radius);
|
|
551
|
-
font-weight: 400;
|
|
552
|
-
|
|
553
|
-
&:hover {
|
|
554
|
-
border-color: var(--stldocs-color-hairline-shade);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
.stldocs-button-tertiary {
|
|
559
|
-
border: none;
|
|
560
|
-
color: var(--stldocs-color-text-secondary);
|
|
561
|
-
background-color: transparent;
|
|
562
364
|
}
|
|
563
365
|
|
|
564
366
|
.stldocs-root .stldocs-expand-toggle {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stainless-api/docs-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.0-beta.
|
|
4
|
+
"version": "0.1.0-beta.28",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"htmlparser2": "^10.0.0",
|
|
25
25
|
"lucide-react": "^0.544.0",
|
|
26
26
|
"natural": "^8.0.1",
|
|
27
|
-
"@stainless-api/ui-primitives": "0.1.0-beta.
|
|
27
|
+
"@stainless-api/ui-primitives": "0.1.0-beta.21"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^24.4.0",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"react-dom": "^19.2.0",
|
|
37
37
|
"tsx": "^4.20.3",
|
|
38
38
|
"typescript": "5.9.3",
|
|
39
|
-
"@stainless/
|
|
40
|
-
"@stainless/
|
|
39
|
+
"@stainless/sdk-json": "^0.1.0-beta.0",
|
|
40
|
+
"@stainless/eslint-config": "0.1.0-beta.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "node build.js",
|
package/src/components/index.ts
CHANGED
package/src/style.ts
CHANGED
|
@@ -182,16 +182,4 @@ export default {
|
|
|
182
182
|
BreadcrumbsItem: 'stldocs-breadcrumbs-item',
|
|
183
183
|
BreadcrumbsLink: 'stldocs-breadcrumbs-link',
|
|
184
184
|
BreadcrumbsNonLink: 'stldocs-breadcrumbs-non-link',
|
|
185
|
-
|
|
186
|
-
Dropdown: 'stldocs-dropdown',
|
|
187
|
-
DropdownTrigger: 'stldocs-dropdown-trigger',
|
|
188
|
-
DropdownTriggerContent: 'stldocs-dropdown-trigger-content',
|
|
189
|
-
DropdownChevron: 'stldocs-dropdown-chevron',
|
|
190
|
-
DropdownMenu: 'stldocs-dropdown-menu',
|
|
191
|
-
DropdownItem: 'stldocs-dropdown-item',
|
|
192
|
-
DropdownItemLink: 'stldocs-dropdown-item-link',
|
|
193
|
-
|
|
194
|
-
Button: 'stldocs-button',
|
|
195
|
-
ButtonSecondary: 'stldocs-button-secondary',
|
|
196
|
-
ButtonIcon: 'stldocs-button-icon',
|
|
197
185
|
} as const;
|
|
@@ -359,206 +359,8 @@
|
|
|
359
359
|
align-items: center;
|
|
360
360
|
gap: 0.5rem;
|
|
361
361
|
margin: 0;
|
|
362
|
-
height: var(--stldocs-button-size);
|
|
363
362
|
}
|
|
364
363
|
}
|
|
365
|
-
|
|
366
|
-
/* Dropdown component styles */
|
|
367
|
-
.stldocs-dropdown {
|
|
368
|
-
position: relative;
|
|
369
|
-
font-size: 0.85rem;
|
|
370
|
-
|
|
371
|
-
span {
|
|
372
|
-
display: flex;
|
|
373
|
-
align-items: center;
|
|
374
|
-
justify-content: center;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
.stldocs-dropdown-trigger {
|
|
379
|
-
display: flex;
|
|
380
|
-
align-items: center;
|
|
381
|
-
justify-content: space-between;
|
|
382
|
-
gap: 6px;
|
|
383
|
-
padding: 0.5rem;
|
|
384
|
-
|
|
385
|
-
.stldocs-icon {
|
|
386
|
-
margin: unset;
|
|
387
|
-
width: 16px;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
&:hover {
|
|
391
|
-
border-color: var(--stldocs-color-hairline-shade);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
.stldocs-dropdown-trigger-content {
|
|
396
|
-
display: flex;
|
|
397
|
-
align-items: center;
|
|
398
|
-
gap: 8px;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
.stldocs-dropdown-chevron {
|
|
402
|
-
margin-right: calc(-1 * var(--sl-button-icon-offset));
|
|
403
|
-
padding: 0;
|
|
404
|
-
opacity: 0.25;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
.stldocs-dropdown-chevron svg path {
|
|
408
|
-
stroke: var(--stldocs-color-text-secondary);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
.stldocs-dropdown-menu {
|
|
412
|
-
--stldocs-dropdown-menu-border-radius: 8px;
|
|
413
|
-
--stldocs-dropdown-menu-background-color: var(--stldocs-color-bg);
|
|
414
|
-
--stldocs-dropdown-menu-border-color: var(--stldocs-color-hairline);
|
|
415
|
-
|
|
416
|
-
position: absolute;
|
|
417
|
-
right: 0;
|
|
418
|
-
bottom: 100%;
|
|
419
|
-
z-index: var(--stldocs-z-index-theme-select);
|
|
420
|
-
background: var(--stldocs-dropdown-menu-background-color);
|
|
421
|
-
border: 1px solid var(--stldocs-dropdown-menu-border-color);
|
|
422
|
-
border-radius: var(--stldocs-dropdown-menu-border-radius);
|
|
423
|
-
margin-bottom: 4px;
|
|
424
|
-
padding: 0;
|
|
425
|
-
width: 100%;
|
|
426
|
-
min-width: 100px;
|
|
427
|
-
overflow: hidden;
|
|
428
|
-
display: none;
|
|
429
|
-
box-shadow: 0px 4px 4px -2px #00000014;
|
|
430
|
-
|
|
431
|
-
&.below {
|
|
432
|
-
margin-bottom: unset;
|
|
433
|
-
bottom: unset;
|
|
434
|
-
top: 100%;
|
|
435
|
-
margin-top: 4px;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
.stldocs-dropdown-menu.open {
|
|
440
|
-
display: block;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
.stldocs-dropdown-item {
|
|
444
|
-
display: flex;
|
|
445
|
-
align-items: center;
|
|
446
|
-
justify-content: space-between;
|
|
447
|
-
gap: 8px;
|
|
448
|
-
padding: 6px 10px;
|
|
449
|
-
cursor: pointer;
|
|
450
|
-
height: 32px;
|
|
451
|
-
|
|
452
|
-
div {
|
|
453
|
-
display: flex;
|
|
454
|
-
align-items: center;
|
|
455
|
-
gap: 8px;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
.lucide-check {
|
|
459
|
-
height: var(--stlodcs-font-size-body);
|
|
460
|
-
width: var(--stlodcs-font-size-body);
|
|
461
|
-
display: none;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
.stldocs-icon {
|
|
465
|
-
width: 16px;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
&.stldocs-dropdown-item-link {
|
|
469
|
-
padding: 0;
|
|
470
|
-
height: unset;
|
|
471
|
-
gap: 0;
|
|
472
|
-
|
|
473
|
-
a {
|
|
474
|
-
display: flex;
|
|
475
|
-
align-items: center;
|
|
476
|
-
justify-content: space-between;
|
|
477
|
-
gap: 8px;
|
|
478
|
-
padding: 6px 10px;
|
|
479
|
-
cursor: pointer;
|
|
480
|
-
height: 32px;
|
|
481
|
-
width: 100%;
|
|
482
|
-
text-decoration: none;
|
|
483
|
-
color: inherit;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
.stldocs-dropdown-item:hover {
|
|
489
|
-
background-color: var(--stldocs-color-bg-inline-code);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
.stldocs-dropdown-item.selected {
|
|
493
|
-
.lucide-check {
|
|
494
|
-
display: inline;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
@media (min-width: 50rem) {
|
|
499
|
-
.stldocs-dropdown-menu {
|
|
500
|
-
margin-bottom: unset;
|
|
501
|
-
bottom: unset;
|
|
502
|
-
top: 100%;
|
|
503
|
-
margin-top: 4px;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/* Intentionally not using the stldocs-root selector here, as buttons are sometimes outside the stldocs-root. */
|
|
509
|
-
.stldocs-button {
|
|
510
|
-
border-radius: var(--stldocs-button-border-radius);
|
|
511
|
-
display: flex;
|
|
512
|
-
padding: var(--stldocs-button-padding-y) var(--stldocs-button-padding-x);
|
|
513
|
-
justify-content: center;
|
|
514
|
-
align-items: center;
|
|
515
|
-
height: var(--stldocs-button-size);
|
|
516
|
-
cursor: pointer;
|
|
517
|
-
text-decoration: none;
|
|
518
|
-
text-wrap: nowrap;
|
|
519
|
-
font-weight: 500;
|
|
520
|
-
line-height: 150%;
|
|
521
|
-
font-size: var(--sl-text-sm);
|
|
522
|
-
|
|
523
|
-
span {
|
|
524
|
-
padding-left: var(--sl-button-icon-offset);
|
|
525
|
-
padding-right: var(--sl-button-icon-offset);
|
|
526
|
-
font-size: var(--sl-text-sm);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
&.stldocs-button-icon {
|
|
530
|
-
> svg {
|
|
531
|
-
margin: 0;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
.stldocs-button-icon {
|
|
537
|
-
> svg {
|
|
538
|
-
margin: 0;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
.stldocs-button-primary {
|
|
543
|
-
background-color: var(--stldocs-color-text);
|
|
544
|
-
color: var(--stldocs-color-text-invert);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
.stldocs-button-secondary {
|
|
548
|
-
background-color: var(--stldocs-color-bg-ui);
|
|
549
|
-
border: 1px solid var(--stldocs-color-hairline);
|
|
550
|
-
border-radius: var(--stldocs-button-border-radius);
|
|
551
|
-
font-weight: 400;
|
|
552
|
-
|
|
553
|
-
&:hover {
|
|
554
|
-
border-color: var(--stldocs-color-hairline-shade);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
.stldocs-button-tertiary {
|
|
559
|
-
border: none;
|
|
560
|
-
color: var(--stldocs-color-text-secondary);
|
|
561
|
-
background-color: transparent;
|
|
562
364
|
}
|
|
563
365
|
|
|
564
366
|
.stldocs-root .stldocs-expand-toggle {
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import style from '../style';
|
|
3
|
-
import { ChevronsUpDown } from 'lucide-react';
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
export const Dropdown = ({ className, children, ...rest }: React.HTMLProps<HTMLDivElement>) => {
|
|
7
|
-
return (
|
|
8
|
-
<div {...rest} className={`${style.Dropdown} ${className ?? ''}`}>
|
|
9
|
-
{children}
|
|
10
|
-
</div>
|
|
11
|
-
);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const DropdownTrigger = ({
|
|
15
|
-
children,
|
|
16
|
-
withChevron,
|
|
17
|
-
className,
|
|
18
|
-
isIcon,
|
|
19
|
-
...rest
|
|
20
|
-
}: {
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
withChevron?: boolean;
|
|
23
|
-
isIcon?: boolean;
|
|
24
|
-
} & (React.HTMLProps<HTMLButtonElement> & {
|
|
25
|
-
type?: 'submit' | 'reset' | 'button';
|
|
26
|
-
})) => {
|
|
27
|
-
return (
|
|
28
|
-
<button
|
|
29
|
-
className={`${style.Button} ${style.ButtonSecondary} ${style.DropdownTrigger} ${isIcon ? style.ButtonIcon : ''} ${className ?? ''}`}
|
|
30
|
-
aria-haspopup="listbox"
|
|
31
|
-
{...rest}
|
|
32
|
-
>
|
|
33
|
-
<div className={style.DropdownTriggerContent}>{children}</div>
|
|
34
|
-
{withChevron && (
|
|
35
|
-
<span className={style.DropdownChevron}>
|
|
36
|
-
<ChevronsUpDown size={16} />
|
|
37
|
-
</span>
|
|
38
|
-
)}
|
|
39
|
-
</button>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const DropdownMenu = ({
|
|
44
|
-
position,
|
|
45
|
-
className,
|
|
46
|
-
children,
|
|
47
|
-
...rest
|
|
48
|
-
}: { position?: 'below' } & React.HTMLProps<HTMLUListElement>) => {
|
|
49
|
-
return (
|
|
50
|
-
<ul className={`${style.DropdownMenu} ${position ?? ''} ${className ?? ''}`} {...rest}>
|
|
51
|
-
{children}
|
|
52
|
-
</ul>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const DropdownItem = ({
|
|
57
|
-
children,
|
|
58
|
-
className,
|
|
59
|
-
value,
|
|
60
|
-
selected,
|
|
61
|
-
href,
|
|
62
|
-
}: React.HTMLProps<HTMLLIElement> & { value?: string; selected?: boolean; href?: string }) => {
|
|
63
|
-
const inner = (
|
|
64
|
-
<>
|
|
65
|
-
{children}
|
|
66
|
-
<svg
|
|
67
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
68
|
-
width="24"
|
|
69
|
-
height="24"
|
|
70
|
-
viewBox="0 0 24 24"
|
|
71
|
-
fill="none"
|
|
72
|
-
stroke="currentColor"
|
|
73
|
-
strokeWidth="2"
|
|
74
|
-
strokeLinecap="round"
|
|
75
|
-
strokeLinejoin="round"
|
|
76
|
-
className="lucide lucide-check-icon lucide-check"
|
|
77
|
-
>
|
|
78
|
-
<path d="M20 6 9 17l-5-5" />
|
|
79
|
-
</svg>
|
|
80
|
-
</>
|
|
81
|
-
);
|
|
82
|
-
return (
|
|
83
|
-
<li
|
|
84
|
-
className={clsx(style.DropdownItem, className, selected && 'selected', href && style.DropdownItemLink)}
|
|
85
|
-
role="option"
|
|
86
|
-
data-dropdown-value={value}
|
|
87
|
-
>
|
|
88
|
-
{href ? <a href={href}>{inner}</a> : inner}
|
|
89
|
-
</li>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export function initDropdown({
|
|
2
|
-
dropdownId,
|
|
3
|
-
onSelect,
|
|
4
|
-
isFixed,
|
|
5
|
-
}: {
|
|
6
|
-
dropdownId: string;
|
|
7
|
-
onSelect?: (value: string) => void;
|
|
8
|
-
isFixed?: boolean;
|
|
9
|
-
}) {
|
|
10
|
-
const dropdown = document.getElementById(dropdownId);
|
|
11
|
-
if (!dropdown) return;
|
|
12
|
-
|
|
13
|
-
const button = dropdown.querySelector('button');
|
|
14
|
-
const menu = dropdown.querySelector('.stldocs-dropdown-menu');
|
|
15
|
-
|
|
16
|
-
if (!button || !menu) return;
|
|
17
|
-
|
|
18
|
-
let isOpen = false;
|
|
19
|
-
|
|
20
|
-
function toggleDropdown() {
|
|
21
|
-
if (!button || !menu) return;
|
|
22
|
-
|
|
23
|
-
isOpen = !isOpen;
|
|
24
|
-
|
|
25
|
-
if (isOpen) {
|
|
26
|
-
if (isFixed) {
|
|
27
|
-
// Calculate position for fixed dropdown
|
|
28
|
-
const buttonRect = button.getBoundingClientRect();
|
|
29
|
-
(menu as HTMLElement).style.top = `${buttonRect.bottom}px`;
|
|
30
|
-
(menu as HTMLElement).style.left = `${buttonRect.left}px`;
|
|
31
|
-
}
|
|
32
|
-
menu.classList.add('open');
|
|
33
|
-
button.setAttribute('aria-expanded', 'true');
|
|
34
|
-
} else {
|
|
35
|
-
menu.classList.remove('open');
|
|
36
|
-
button.setAttribute('aria-expanded', 'false');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function closeDropdown() {
|
|
41
|
-
if (!button || !menu) return;
|
|
42
|
-
|
|
43
|
-
isOpen = false;
|
|
44
|
-
menu.classList.remove('open');
|
|
45
|
-
button.setAttribute('aria-expanded', 'false');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Toggle dropdown on button click
|
|
49
|
-
button.addEventListener('click', () => {
|
|
50
|
-
toggleDropdown();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Close dropdown when clicking outside
|
|
54
|
-
document.addEventListener('click', (e) => {
|
|
55
|
-
if (!dropdown.contains(e.target as Node)) {
|
|
56
|
-
closeDropdown();
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Close dropdown when pressing Escape
|
|
61
|
-
document.addEventListener('keydown', (e) => {
|
|
62
|
-
if (e.key === 'Escape' && isOpen) {
|
|
63
|
-
closeDropdown();
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Close dropdown when clicking on dropdown items
|
|
68
|
-
const dropdownItems = menu.querySelectorAll('.stldocs-dropdown-item');
|
|
69
|
-
dropdownItems.forEach((item) => {
|
|
70
|
-
item.addEventListener('click', () => {
|
|
71
|
-
closeDropdown();
|
|
72
|
-
const selectedValue = item.getAttribute('data-dropdown-value');
|
|
73
|
-
if (selectedValue && onSelect) {
|
|
74
|
-
onSelect(selectedValue);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|