@sdxc/ui 2026.11.27 → 2026.11.29
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/README.md +265 -162
- package/dist/app/app-shell.d.ts +85 -50
- package/dist/app/app-shell.js +419 -222
- package/dist/app/auto-refresh.d.ts +68 -51
- package/dist/app/auto-refresh.js +193 -61
- package/dist/app/board.d.ts +40 -17
- package/dist/app/board.js +173 -88
- package/dist/app/chart.d.ts +10 -63
- package/dist/app/chart.js +22 -29
- package/dist/app/code-view.d.ts +12 -11
- package/dist/app/code-view.js +83 -19
- package/dist/app/command-palette.d.ts +61 -33
- package/dist/app/command-palette.js +178 -32
- package/dist/app/contribution-graph.d.ts +30 -14
- package/dist/app/contribution-graph.js +87 -26
- package/dist/app/danger-zone.d.ts +40 -35
- package/dist/app/danger-zone.js +177 -34
- package/dist/app/detail-sheet.d.ts +42 -51
- package/dist/app/detail-sheet.js +156 -37
- package/dist/app/diff.d.ts +6 -5
- package/dist/app/diff.js +9 -6
- package/dist/app/drop-zone.d.ts +3 -13
- package/dist/app/drop-zone.js +2 -2
- package/dist/app/editor-layout.d.ts +69 -47
- package/dist/app/editor-layout.js +256 -115
- package/dist/app/empty.d.ts +16 -12
- package/dist/app/empty.js +45 -19
- package/dist/app/file-trigger.d.ts +5 -13
- package/dist/app/file-trigger.js +3 -4
- package/dist/app/filter-bar.d.ts +182 -120
- package/dist/app/filter-bar.js +509 -161
- package/dist/app/filter-menu.d.ts +51 -33
- package/dist/app/filter-menu.js +105 -40
- package/dist/app/gantt.d.ts +67 -27
- package/dist/app/gantt.js +320 -163
- package/dist/app/grid-list.d.ts +2 -15
- package/dist/app/grid-list.js +3 -3
- package/dist/app/merge-box.d.ts +58 -52
- package/dist/app/merge-box.js +107 -46
- package/dist/app/mixins/optimistic-toggle-sync.d.ts +2 -2
- package/dist/app/mixins/optimistic-toggle-sync.js +3 -2
- package/dist/app/mixins/range-picker-keys.d.ts +1 -1
- package/dist/app/mixins/range-picker-keys.js +1 -1
- package/dist/app/mixins/save-bar-sync.d.ts +1 -1
- package/dist/app/mixins/save-bar-sync.js +3 -2
- package/dist/app/mixins/split-view.d.ts +3 -1
- package/dist/app/mixins/split-view.js +16 -8
- package/dist/app/optimistic-toggle.d.ts +65 -37
- package/dist/app/optimistic-toggle.js +38 -15
- package/dist/app/page-header.d.ts +80 -58
- package/dist/app/page-header.js +329 -154
- package/dist/app/profile-picker.d.ts +31 -24
- package/dist/app/profile-picker.js +134 -58
- package/dist/app/range-picker.d.ts +62 -59
- package/dist/app/range-picker.js +124 -37
- package/dist/app/review-thread.d.ts +69 -66
- package/dist/app/review-thread.js +203 -53
- package/dist/app/save-bar.d.ts +56 -27
- package/dist/app/save-bar.js +66 -14
- package/dist/app/selection-bar.d.ts +64 -66
- package/dist/app/selection-bar.js +157 -56
- package/dist/app/settings-layout.d.ts +65 -52
- package/dist/app/settings-layout.js +198 -71
- package/dist/app/settings-section.d.ts +86 -93
- package/dist/app/settings-section.js +297 -120
- package/dist/app/shortcut-list.d.ts +19 -8
- package/dist/app/shortcut-list.js +50 -9
- package/dist/app/sparkline.d.ts +14 -16
- package/dist/app/sparkline.js +20 -7
- package/dist/app/split-view.d.ts +66 -42
- package/dist/app/split-view.js +235 -128
- package/dist/app/stat-card.d.ts +16 -4
- package/dist/app/stat-card.js +57 -21
- package/dist/app/status-strip.d.ts +24 -25
- package/dist/app/status-strip.js +82 -25
- package/dist/app/tab-bar.d.ts +15 -7
- package/dist/app/tab-bar.js +74 -37
- package/dist/app/table.d.ts +37 -38
- package/dist/app/table.js +101 -45
- package/dist/app/view-options.d.ts +100 -76
- package/dist/app/view-options.js +263 -129
- package/dist/audio/media-tile.d.ts +33 -21
- package/dist/audio/media-tile.js +139 -79
- package/dist/audio/player-bar.d.ts +24 -43
- package/dist/audio/player-bar.js +183 -118
- package/dist/audio/queue-list.d.ts +40 -36
- package/dist/audio/queue-list.js +172 -73
- package/dist/audio/track-list.d.ts +53 -54
- package/dist/audio/track-list.js +127 -35
- package/dist/blog/archive-list.d.ts +158 -0
- package/dist/blog/archive-list.js +353 -0
- package/dist/blog/article-layout.d.ts +81 -0
- package/dist/blog/article-layout.js +211 -0
- package/dist/blog/author-card.d.ts +99 -0
- package/dist/blog/author-card.js +184 -0
- package/dist/blog/blog-masthead.d.ts +55 -0
- package/dist/blog/blog-masthead.js +143 -0
- package/dist/blog/index.d.ts +21 -0
- package/dist/blog/index.js +21 -0
- package/dist/blog/link-host.d.ts +47 -0
- package/dist/blog/link-host.js +61 -0
- package/dist/blog/newsletter-form.d.ts +66 -0
- package/dist/blog/newsletter-form.js +100 -0
- package/dist/blog/post-byline.d.ts +96 -0
- package/dist/blog/post-byline.js +180 -0
- package/dist/blog/post-entry.d.ts +153 -0
- package/dist/blog/post-entry.js +402 -0
- package/dist/blog/post-stream.d.ts +92 -0
- package/dist/blog/post-stream.js +163 -0
- package/dist/blog/series-nav.d.ts +144 -0
- package/dist/blog/series-nav.js +275 -0
- package/dist/blog/tag-cloud.d.ts +103 -0
- package/dist/blog/tag-cloud.js +138 -0
- package/dist/blog/tag-list.d.ts +91 -0
- package/dist/blog/tag-list.js +92 -0
- package/dist/blog/widget.d.ts +68 -0
- package/dist/blog/widget.js +61 -0
- package/dist/chat/activity.d.ts +47 -15
- package/dist/chat/activity.js +124 -46
- package/dist/chat/mention-menu.d.ts +6 -7
- package/dist/chat/mention-menu.js +4 -4
- package/dist/chat/message-group.d.ts +17 -4
- package/dist/chat/message-group.js +29 -6
- package/dist/color/color-field.d.ts +41 -68
- package/dist/color/color-field.js +21 -38
- package/dist/color/color-picker.d.ts +10 -61
- package/dist/color/color-picker.js +7 -15
- package/dist/color/color-swatch-picker.d.ts +0 -11
- package/dist/color/color-swatch-picker.js +2 -3
- package/dist/color/color-wheel.d.ts +3 -13
- package/dist/color/color-wheel.js +1 -2
- package/dist/commerce/cart-drawer.d.ts +41 -24
- package/dist/commerce/cart-drawer.js +129 -58
- package/dist/commerce/cart-line.d.ts +34 -19
- package/dist/commerce/cart-line.js +94 -28
- package/dist/commerce/checkout-layout.d.ts +23 -19
- package/dist/commerce/checkout-layout.js +53 -24
- package/dist/commerce/facet-filters.d.ts +57 -59
- package/dist/commerce/facet-filters.js +219 -129
- package/dist/commerce/item-options-dialog.d.ts +69 -40
- package/dist/commerce/item-options-dialog.js +231 -104
- package/dist/commerce/menu-item-card.d.ts +36 -20
- package/dist/commerce/menu-item-card.js +114 -61
- package/dist/commerce/option-group.d.ts +46 -27
- package/dist/commerce/option-group.js +123 -52
- package/dist/commerce/order-summary.d.ts +41 -26
- package/dist/commerce/order-summary.js +103 -49
- package/dist/commerce/order-tracker.d.ts +32 -16
- package/dist/commerce/order-tracker.js +91 -66
- package/dist/commerce/price.d.ts +41 -25
- package/dist/commerce/price.js +131 -68
- package/dist/commerce/product-card.d.ts +66 -36
- package/dist/commerce/product-card.js +215 -100
- package/dist/commerce/product-gallery.d.ts +72 -38
- package/dist/commerce/product-gallery.js +187 -82
- package/dist/commerce/promo-code.d.ts +73 -37
- package/dist/commerce/promo-code.js +172 -77
- package/dist/commerce/question-list.d.ts +43 -35
- package/dist/commerce/question-list.js +146 -72
- package/dist/commerce/shipping-estimate.d.ts +68 -33
- package/dist/commerce/shipping-estimate.js +149 -25
- package/dist/commerce/sort-select.d.ts +33 -22
- package/dist/commerce/sort-select.js +55 -26
- package/dist/commerce/variant-picker.d.ts +25 -23
- package/dist/commerce/variant-picker.js +103 -29
- package/dist/{docs → components}/anchor-heading.d.ts +1 -1
- package/dist/{docs → components}/anchor-heading.js +1 -1
- package/dist/components/autocomplete.d.ts +19 -21
- package/dist/components/autocomplete.js +57 -21
- package/dist/components/banner.d.ts +48 -37
- package/dist/components/banner.js +69 -27
- package/dist/components/button.d.ts +2 -18
- package/dist/components/button.js +4 -3
- package/dist/components/callout.d.ts +52 -0
- package/dist/components/callout.js +77 -0
- package/dist/components/checkbox.d.ts +3 -12
- package/dist/components/checkbox.js +1 -2
- package/dist/components/code-block.d.ts +110 -0
- package/dist/{docs → components}/code-block.js +92 -23
- package/dist/components/confirm.d.ts +63 -130
- package/dist/components/confirm.js +133 -52
- package/dist/{docs → components}/copy-button.d.ts +1 -1
- package/dist/{docs → components}/copy-button.js +3 -3
- package/dist/components/date-field.d.ts +40 -60
- package/dist/components/date-field.js +23 -36
- package/dist/components/date-picker.d.ts +11 -67
- package/dist/components/date-picker.js +4 -15
- package/dist/components/date-range-picker.d.ts +20 -91
- package/dist/components/date-range-picker.js +13 -27
- package/dist/components/dialog-dismiss.d.ts +1 -1
- package/dist/components/dialog-dismiss.js +1 -1
- package/dist/components/field-parts.d.ts +158 -0
- package/dist/components/field-parts.js +237 -0
- package/dist/components/filter-links.d.ts +107 -0
- package/dist/components/filter-links.js +120 -0
- package/dist/components/form.d.ts +3 -1
- package/dist/components/form.js +3 -1
- package/dist/components/index.d.ts +14 -7
- package/dist/components/index.js +14 -7
- package/dist/components/listbox.d.ts +0 -9
- package/dist/components/listbox.js +2 -2
- package/dist/components/media-grid.d.ts +15 -16
- package/dist/components/media-grid.js +75 -34
- package/dist/components/pager.d.ts +103 -0
- package/dist/components/pager.js +187 -0
- package/dist/components/property-list.d.ts +38 -39
- package/dist/components/property-list.js +149 -96
- package/dist/components/radio-group.d.ts +0 -11
- package/dist/components/radio-group.js +5 -6
- package/dist/components/range-calendar.d.ts +2 -14
- package/dist/components/range-calendar.js +2 -2
- package/dist/components/range-months.d.ts +12 -2
- package/dist/components/range-months.js +32 -16
- package/dist/components/rating-input.d.ts +14 -6
- package/dist/components/rating-input.js +26 -12
- package/dist/components/rating.d.ts +13 -8
- package/dist/components/rating.js +19 -5
- package/dist/components/review-card.d.ts +51 -26
- package/dist/components/review-card.js +173 -40
- package/dist/components/search-field.js +18 -8
- package/dist/components/section-bar.d.ts +23 -15
- package/dist/components/section-bar.js +59 -37
- package/dist/components/sidebar.d.ts +27 -0
- package/dist/components/sidebar.js +49 -20
- package/dist/{docs → components}/table-of-contents.d.ts +1 -1
- package/dist/{docs → components}/table-of-contents.js +3 -3
- package/dist/components/text-field.d.ts +54 -81
- package/dist/components/text-field.js +30 -44
- package/dist/components/time-field.d.ts +45 -65
- package/dist/components/time-field.js +23 -35
- package/dist/components/timeline.d.ts +80 -86
- package/dist/components/timeline.js +383 -170
- package/dist/components/typeset.d.ts +5 -0
- package/dist/components/typeset.js +17 -2
- package/dist/docs/code-tabs.d.ts +50 -24
- package/dist/docs/code-tabs.js +91 -25
- package/dist/docs/docs-feedback.d.ts +70 -27
- package/dist/docs/docs-feedback.js +156 -27
- package/dist/docs/docs-footer.d.ts +36 -22
- package/dist/docs/docs-footer.js +76 -23
- package/dist/docs/docs-hub.d.ts +103 -73
- package/dist/docs/docs-hub.js +333 -83
- package/dist/docs/docs-layout.d.ts +111 -42
- package/dist/docs/docs-layout.js +371 -97
- package/dist/docs/docs-nav-tools.d.ts +11 -7
- package/dist/docs/docs-nav-tools.js +4 -3
- package/dist/docs/docs-nav.d.ts +53 -17
- package/dist/docs/docs-nav.js +125 -14
- package/dist/docs/docs-not-found.d.ts +61 -35
- package/dist/docs/docs-not-found.js +198 -52
- package/dist/docs/docs-page-header.d.ts +47 -30
- package/dist/docs/docs-page-header.js +114 -31
- package/dist/docs/docs-pager.d.ts +43 -27
- package/dist/docs/docs-pager.js +73 -23
- package/dist/docs/file-tree.d.ts +16 -6
- package/dist/docs/file-tree.js +19 -4
- package/dist/docs/index.d.ts +0 -7
- package/dist/docs/index.js +0 -7
- package/dist/docs/install-command.d.ts +7 -6
- package/dist/docs/install-command.js +8 -10
- package/dist/docs/mixins/docs-nav-tools.js +1 -1
- package/dist/docs/next-steps.d.ts +56 -23
- package/dist/docs/next-steps.js +121 -35
- package/dist/docs/page-actions.d.ts +68 -46
- package/dist/docs/page-actions.js +129 -21
- package/dist/docs/steps.d.ts +14 -11
- package/dist/docs/steps.js +36 -18
- package/dist/docs/ui-label.d.ts +7 -6
- package/dist/docs/ui-label.js +21 -8
- package/dist/finance/ledger.d.ts +33 -29
- package/dist/finance/ledger.js +190 -43
- package/dist/finance/payment-card.d.ts +43 -31
- package/dist/finance/payment-card.js +170 -67
- package/dist/landing/author-band.d.ts +57 -54
- package/dist/landing/author-band.js +218 -64
- package/dist/landing/case-study.d.ts +57 -57
- package/dist/landing/case-study.js +148 -17
- package/dist/landing/changelog-strip.d.ts +56 -36
- package/dist/landing/changelog-strip.js +176 -68
- package/dist/landing/closing-cta.d.ts +21 -41
- package/dist/landing/closing-cta.js +13 -19
- package/dist/landing/code-stage.d.ts +55 -47
- package/dist/landing/code-stage.js +198 -67
- package/dist/landing/contributor-wall.d.ts +4 -4
- package/dist/landing/contributor-wall.js +4 -4
- package/dist/landing/curriculum.d.ts +74 -45
- package/dist/landing/curriculum.js +220 -62
- package/dist/landing/drawn-chart.d.ts +18 -10
- package/dist/landing/drawn-chart.js +57 -26
- package/dist/landing/episode-player.d.ts +69 -43
- package/dist/landing/episode-player.js +213 -48
- package/dist/landing/event-ticker.d.ts +13 -7
- package/dist/landing/event-ticker.js +67 -32
- package/dist/landing/fan-out-diagram.d.ts +19 -8
- package/dist/landing/fan-out-diagram.js +60 -19
- package/dist/landing/faq-band.d.ts +30 -48
- package/dist/landing/faq-band.js +37 -30
- package/dist/landing/feature-band.d.ts +48 -76
- package/dist/landing/feature-band.js +71 -49
- package/dist/landing/flow-diagram.d.ts +16 -8
- package/dist/landing/flow-diagram.js +50 -18
- package/dist/landing/install-tabs.d.ts +16 -14
- package/dist/landing/install-tabs.js +87 -39
- package/dist/landing/landing-header.d.ts +75 -66
- package/dist/landing/landing-header.js +284 -57
- package/dist/landing/landing-hero.d.ts +59 -87
- package/dist/landing/landing-hero.js +157 -128
- package/dist/landing/landing-section.d.ts +0 -9
- package/dist/landing/landing-section.js +1 -2
- package/dist/landing/logo-cloud.d.ts +26 -9
- package/dist/landing/logo-cloud.js +62 -18
- package/dist/landing/phone-fan.d.ts +15 -7
- package/dist/landing/phone-fan.js +60 -17
- package/dist/landing/price-list.d.ts +29 -22
- package/dist/landing/price-list.js +175 -77
- package/dist/landing/pricing-band.d.ts +46 -53
- package/dist/landing/pricing-band.js +167 -51
- package/dist/landing/product-frame.d.ts +44 -42
- package/dist/landing/product-frame.js +182 -85
- package/dist/landing/proof-strip.d.ts +7 -2
- package/dist/landing/proof-strip.js +7 -2
- package/dist/landing/rails.d.ts +1 -1
- package/dist/landing/rails.js +1 -1
- package/dist/landing/segmented-stage.d.ts +19 -8
- package/dist/landing/segmented-stage.js +60 -16
- package/dist/landing/sequence-diagram.d.ts +18 -8
- package/dist/landing/sequence-diagram.js +49 -18
- package/dist/landing/site-footer.d.ts +89 -68
- package/dist/landing/site-footer.js +344 -111
- package/dist/landing/site-header.d.ts +118 -80
- package/dist/landing/site-header.js +482 -67
- package/dist/landing/sponsor-wall.d.ts +34 -15
- package/dist/landing/sponsor-wall.js +111 -34
- package/dist/landing/stat-strip.d.ts +7 -9
- package/dist/landing/stat-strip.js +57 -22
- package/dist/landing/step-list.d.ts +18 -21
- package/dist/landing/step-list.js +132 -38
- package/dist/landing/tabbed-stage.d.ts +23 -15
- package/dist/landing/tabbed-stage.js +103 -21
- package/dist/landing/testimonial-band.d.ts +58 -61
- package/dist/landing/testimonial-band.js +209 -71
- package/dist/landing/typed-terminal.d.ts +9 -6
- package/dist/landing/typed-terminal.js +16 -5
- package/dist/landing/usage-estimate.d.ts +83 -74
- package/dist/landing/usage-estimate.js +254 -113
- package/dist/landing/utils/has-parts.d.ts +17 -0
- package/dist/landing/utils/has-parts.js +24 -0
- package/dist/map/map-canvas.d.ts +15 -16
- package/dist/map/map-canvas.js +40 -24
- package/dist/map/map.d.ts +42 -33
- package/dist/map/map.js +149 -38
- package/dist/mixins/aria-checked.d.ts +1 -4
- package/dist/mixins/aria-checked.js +1 -4
- package/dist/mixins/clear-field.d.ts +2 -4
- package/dist/mixins/clear-field.js +2 -4
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.js +2 -0
- package/dist/schedule/agenda.d.ts +69 -41
- package/dist/schedule/agenda.js +273 -134
- package/dist/schedule/day-strip.d.ts +38 -26
- package/dist/schedule/day-strip.js +119 -88
- package/dist/test/map.d.ts +1 -1
- package/dist/test/map.js +1 -6
- package/dist/test/reels.js +1 -1
- package/dist/test/stories.js +2 -2
- package/dist/travel/boarding-pass.d.ts +94 -70
- package/dist/travel/boarding-pass.js +341 -144
- package/dist/travel/car-offer.d.ts +109 -49
- package/dist/travel/car-offer.js +424 -64
- package/dist/travel/fare-options.d.ts +58 -34
- package/dist/travel/fare-options.js +210 -69
- package/dist/travel/flight-itinerary.d.ts +62 -55
- package/dist/travel/flight-itinerary.js +230 -55
- package/dist/travel/flight-option.d.ts +65 -33
- package/dist/travel/flight-option.js +250 -69
- package/dist/travel/flight-segment.d.ts +121 -70
- package/dist/travel/flight-segment.js +358 -96
- package/dist/travel/package-savings.d.ts +79 -39
- package/dist/travel/package-savings.js +309 -65
- package/dist/travel/price-breakdown.d.ts +30 -22
- package/dist/travel/price-breakdown.js +72 -17
- package/dist/travel/rating-breakdown.d.ts +25 -18
- package/dist/travel/rating-breakdown.js +60 -23
- package/dist/travel/seat-map.d.ts +29 -22
- package/dist/travel/seat-map.js +140 -78
- package/dist/travel/trip-timeline.d.ts +77 -39
- package/dist/travel/trip-timeline.js +316 -107
- package/dist/utils/eyebrow.d.ts +2 -2
- package/dist/utils/eyebrow.js +3 -3
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/video/episode-list.d.ts +22 -14
- package/dist/video/episode-list.js +89 -53
- package/dist/video/reel-feed.d.ts +21 -15
- package/dist/video/reel-feed.js +59 -24
- package/dist/video/story-viewer.d.ts +6 -5
- package/dist/video/story-viewer.js +84 -53
- package/dist/video/title-hero.d.ts +8 -8
- package/dist/video/title-hero.js +48 -34
- package/dist/video/video-card.d.ts +34 -20
- package/dist/video/video-card.js +119 -76
- package/dist/video/video-player.d.ts +17 -14
- package/dist/video/video-player.js +68 -30
- package/dist/video/video-shelf.d.ts +26 -14
- package/dist/video/video-shelf.js +88 -50
- package/package.json +4 -2
- package/dist/docs/callout.d.ts +0 -46
- package/dist/docs/callout.js +0 -61
- package/dist/docs/code-block.d.ts +0 -74
- package/dist/utils/field-parts.d.ts +0 -26
- package/dist/utils/field-parts.js +0 -12
- /package/dist/{docs/mixins → mixins}/copy-feedback.d.ts +0 -0
- /package/dist/{docs/mixins → mixins}/copy-feedback.js +0 -0
- /package/dist/{docs/mixins → mixins}/toc-spy.d.ts +0 -0
- /package/dist/{docs/mixins → mixins}/toc-spy.js +0 -0
- /package/dist/{docs/utils → utils}/reveal-in-scroller.d.ts +0 -0
- /package/dist/{docs/utils → utils}/reveal-in-scroller.js +0 -0
|
@@ -8,6 +8,7 @@ import { absolute, hstack, inlineFlex, insBs, insIe, relative, shrink } from "@s
|
|
|
8
8
|
import { overflowX } from "@sdxc/u/overflow";
|
|
9
9
|
import { bs, m, minIs, pi } from "@sdxc/u/size";
|
|
10
10
|
import { z } from "@sdxc/u/stacking";
|
|
11
|
+
import { when } from "@sdxc/u/state";
|
|
11
12
|
import { font, text, truncate } from "@sdxc/u/typography";
|
|
12
13
|
import { COPY_EXCLUDE_ATTRIBUTE } from "../mixins/copy-to-clipboard.js";
|
|
13
14
|
import { codeLines } from "../utils/code-lines.js";
|
|
@@ -50,27 +51,33 @@ const TOKEN_PALETTE = {
|
|
|
50
51
|
const FNV_OFFSET = 0x811c9dc5;
|
|
51
52
|
/** FNV-1a prime, which spreads each character through the hash. */
|
|
52
53
|
const FNV_PRIME = 0x01000193;
|
|
54
|
+
/** The marker attribute the card's layout selects its floating copy button by. */
|
|
55
|
+
const PART = "data-code-block-part";
|
|
53
56
|
/**
|
|
54
|
-
* Renders the card:
|
|
55
|
-
* the code, which scrolls sideways inside the card. Marked lines tint across the full
|
|
57
|
+
* Renders the card: the parts it holds (or a header naming the language with the copy button),
|
|
58
|
+
* then the code, which scrolls sideways inside the card. Marked lines tint across the full
|
|
56
59
|
* scroll width with a 2px bar whose width comes out of the line's padding, so no text moves.
|
|
57
60
|
*
|
|
58
61
|
* @param handle Runtime handle carrying the block's props.
|
|
59
62
|
* @returns The render function producing the card.
|
|
60
63
|
* @example
|
|
61
|
-
* <CodeBlock
|
|
64
|
+
* <CodeBlock language="ts" code={source} highlight={[4, 5]} labels={{ copy: t("copy"), copied: t("copied") }}>
|
|
65
|
+
* <CodeBlock.Header>
|
|
66
|
+
* <CodeBlock.Title>vite.config.ts</CodeBlock.Title>
|
|
67
|
+
* <CodeBlock.Copy />
|
|
68
|
+
* </CodeBlock.Header>
|
|
69
|
+
* </CodeBlock>
|
|
62
70
|
* @example
|
|
63
|
-
* <CodeBlock
|
|
71
|
+
* <CodeBlock language="sh" code={"$ npm add @sdxc/ui"} labels={labels} />
|
|
64
72
|
*/
|
|
65
73
|
export function CodeBlock(handle) {
|
|
66
74
|
return () => {
|
|
67
|
-
let { add, code, codeId, highlight, labels, language, lineNumbers = false, mix, remove,
|
|
68
|
-
let shell = isShell(language
|
|
75
|
+
let { add, children, code, codeId, highlight, labels, language, lineNumbers = false, mix, remove, tokens, ...rest } = handle.props;
|
|
76
|
+
let shell = isShell(language);
|
|
69
77
|
let lines = paintLines(code, language, tokens, shell, { add, highlight, remove });
|
|
70
78
|
let id = codeId ?? stableId(code);
|
|
71
|
-
let heading = title ?? (language && language !== "plain" ? language : undefined);
|
|
72
|
-
let copy = _jsx(CopyButton, { target: id, label: labels.copy, copiedLabel: labels.copied });
|
|
73
79
|
let digits = Math.max(2, String(lines.length).length);
|
|
80
|
+
handle.context.set({ codeId: id, labels, shell });
|
|
74
81
|
return (_jsxs("figure", { ...rest, "data-slot": "code-block", "data-language": language, mix: mergeMix([
|
|
75
82
|
relative(),
|
|
76
83
|
m(0),
|
|
@@ -79,12 +86,8 @@ export function CodeBlock(handle) {
|
|
|
79
86
|
border({ color: "neutral.border", width: 1, style: "solid" }),
|
|
80
87
|
bg("neutral.bg-tint"),
|
|
81
88
|
raw({ overflow: "hidden" }),
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
bs("2.5rem"),
|
|
85
|
-
pi(4, 1),
|
|
86
|
-
borderEdge("block-end", { color: "neutral.border", width: 1, style: "solid" }),
|
|
87
|
-
], children: [_jsxs("span", { mix: [hstack({ gap: 2, align: "center" }), minIs(0), fg("neutral")], children: [_jsx("span", { "data-slot": "code-block-icon", mix: [inlineFlex(), shrink(0)], children: _jsx(TitleIcon, { title: title, shell: shell }) }), _jsx("span", { mix: [minIs(0), truncate(), title && isPath(title) ? font("mono") : [], text("xs")], children: heading })] }), copy] })) : (_jsx("span", { mix: [absolute(), insBs("0.375rem"), insIe("0.375rem"), z(1)], children: copy })), _jsx("pre", { "data-not-typeset": "", "data-line-numbers": lineNumbers ? "" : undefined, mix: [
|
|
89
|
+
when(`&:has(> [${PART}=copy])`, raw({ "--ui-code-block-line-end": "3rem" })),
|
|
90
|
+
], mix), children: [children ?? _jsx(DefaultHeader, { language: language }), _jsx("pre", { "data-not-typeset": "", "data-line-numbers": lineNumbers ? "" : undefined, mix: [
|
|
88
91
|
m(0),
|
|
89
92
|
overflowX("auto"),
|
|
90
93
|
fg("neutral.emphasis"),
|
|
@@ -101,20 +104,88 @@ export function CodeBlock(handle) {
|
|
|
101
104
|
tabSize: 4,
|
|
102
105
|
overscrollBehaviorInline: "contain",
|
|
103
106
|
}),
|
|
104
|
-
], children: _jsx("code", { id: id, className: language ? `language-${language}` : undefined, mix: [lineRules(
|
|
107
|
+
], children: _jsx("code", { id: id, className: language ? `language-${language}` : undefined, mix: [lineRules(lineNumbers, digits)], children: renderLines(lines) }) })] }));
|
|
105
108
|
};
|
|
106
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* What a card with no parts draws: a header naming its language with the copy button, or the
|
|
112
|
+
* copy button floating over the code when the block names no language.
|
|
113
|
+
*
|
|
114
|
+
* @param handle Runtime handle carrying the block's language.
|
|
115
|
+
* @returns The render function producing the header or the floating button.
|
|
116
|
+
*/
|
|
117
|
+
function DefaultHeader(handle) {
|
|
118
|
+
return () => {
|
|
119
|
+
let { language } = handle.props;
|
|
120
|
+
if (!language || language === "plain")
|
|
121
|
+
return _jsx(CodeBlock.Copy, {});
|
|
122
|
+
return (_jsxs(CodeBlock.Header, { children: [_jsx(CodeBlock.Title, { children: language }), _jsx(CodeBlock.Copy, {})] }));
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The header row over the code, holding a {@link CodeBlock.Title} at its start and a
|
|
127
|
+
* {@link CodeBlock.Copy} at its end.
|
|
128
|
+
*
|
|
129
|
+
* @param handle Runtime handle carrying the host `<figcaption>`'s props.
|
|
130
|
+
* @returns The render function producing the header.
|
|
131
|
+
*/
|
|
132
|
+
CodeBlock.Header = function CodeBlockHeader(handle) {
|
|
133
|
+
return () => {
|
|
134
|
+
let { mix, ...rest } = handle.props;
|
|
135
|
+
handle.context.set({ inHeader: true });
|
|
136
|
+
return (_jsx("figcaption", { "data-slot": "code-block-header", ...rest, mix: mergeMix([
|
|
137
|
+
hstack({ gap: 2, align: "center", justify: "between" }),
|
|
138
|
+
bs("2.5rem"),
|
|
139
|
+
pi(4, 1),
|
|
140
|
+
borderEdge("block-end", { color: "neutral.border", width: 1, style: "solid" }),
|
|
141
|
+
], mix) }));
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* What the header reads as, after an icon for its kind: a file path in the mono face, or any
|
|
146
|
+
* other words (such as "Terminal") as written, truncated to one line.
|
|
147
|
+
*
|
|
148
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
149
|
+
* @returns The render function producing the title.
|
|
150
|
+
* @example <CodeBlock.Title>app/routes.ts</CodeBlock.Title>
|
|
151
|
+
*/
|
|
152
|
+
CodeBlock.Title = function CodeBlockTitle(handle) {
|
|
153
|
+
return () => {
|
|
154
|
+
let { children, mix, ...rest } = handle.props;
|
|
155
|
+
let context = handle.context.get(CodeBlock);
|
|
156
|
+
let title = typeof children === "string" ? children : undefined;
|
|
157
|
+
let shell = (context?.shell ?? false) || title?.trim().toLowerCase() === "terminal";
|
|
158
|
+
return (_jsxs("span", { "data-slot": "code-block-title", ...rest, mix: mergeMix([hstack({ gap: 2, align: "center" }), minIs(0), fg("neutral")], mix), children: [_jsx("span", { "data-slot": "code-block-icon", mix: [inlineFlex(), shrink(0)], children: _jsx(TitleIcon, { title: title, shell: shell }) }), _jsx("span", { mix: [minIs(0), truncate(), title && isPath(title) ? font("mono") : [], text("xs")], children: children })] }));
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* The copy button, which copies what a reader should paste: at a header's end, or floating over
|
|
163
|
+
* the code's top corner when written directly in the card.
|
|
164
|
+
*
|
|
165
|
+
* @param handle Runtime handle carrying the button box's props.
|
|
166
|
+
* @returns The render function producing the button.
|
|
167
|
+
*/
|
|
168
|
+
CodeBlock.Copy = function CodeBlockCopy(handle) {
|
|
169
|
+
return () => {
|
|
170
|
+
let { mix, ...rest } = handle.props;
|
|
171
|
+
let context = handle.context.get(CodeBlock);
|
|
172
|
+
let header = handle.context.get(CodeBlock.Header);
|
|
173
|
+
let labels = context?.labels;
|
|
174
|
+
return (_jsx("span", { "data-slot": "code-block-copy", ...rest, "data-code-block-part": "copy", mix: mergeMix(header ? [inlineFlex()] : [absolute(), insBs("0.375rem"), insIe("0.375rem"), z(1)], mix), children: _jsx(CopyButton, { target: context?.codeId ?? "", label: labels?.copy ?? "", copiedLabel: labels?.copied ?? "" }) }));
|
|
175
|
+
};
|
|
176
|
+
};
|
|
107
177
|
/**
|
|
108
178
|
* Every rule the lines follow, in one block so a marked line's padding, bar and tint
|
|
109
179
|
* resolve by specificity alone. The grid makes each line as wide as the longest one, so a
|
|
110
180
|
* tint runs the full scroll width, and drops the newlines between lines from layout while
|
|
111
181
|
* leaving them in the text a copy reads.
|
|
112
182
|
*
|
|
113
|
-
*
|
|
183
|
+
* Lines end on `--ui-code-block-line-end`, which a card with a floating copy button widens.
|
|
184
|
+
*
|
|
114
185
|
* @param lineNumbers Whether lines draw a gutter number.
|
|
115
186
|
* @param digits Digits the widest line number needs.
|
|
116
187
|
*/
|
|
117
|
-
function lineRules(
|
|
188
|
+
function lineRules(lineNumbers, digits) {
|
|
118
189
|
let markedInset = `calc(${LINE_INSET} - ${MARK_BAR})`;
|
|
119
190
|
let tint = (tone) => `color-mix(in oklab, var(--ui-${tone}-fg) 12%, transparent)`;
|
|
120
191
|
return raw({
|
|
@@ -129,7 +200,7 @@ function lineRules(hasHeader, lineNumbers, digits) {
|
|
|
129
200
|
position: "relative",
|
|
130
201
|
minBlockSize: "1lh",
|
|
131
202
|
paddingInlineStart: LINE_INSET,
|
|
132
|
-
paddingInlineEnd:
|
|
203
|
+
paddingInlineEnd: `var(--ui-code-block-line-end, ${LINE_INSET})`,
|
|
133
204
|
counterIncrement: "line",
|
|
134
205
|
},
|
|
135
206
|
"& > [data-mark]": {
|
|
@@ -197,11 +268,9 @@ function TitleIcon(handle) {
|
|
|
197
268
|
function isPath(title) {
|
|
198
269
|
return /[/.]/.test(title) && !/\s/.test(title);
|
|
199
270
|
}
|
|
200
|
-
/** Whether the block is a shell session, by its language
|
|
201
|
-
function isShell(language
|
|
202
|
-
|
|
203
|
-
return true;
|
|
204
|
-
return title?.trim().toLowerCase() === "terminal";
|
|
271
|
+
/** Whether the block is a shell session, by its language. */
|
|
272
|
+
function isShell(language) {
|
|
273
|
+
return Boolean(language && SHELL_LANGUAGES.has(language.toLowerCase()));
|
|
205
274
|
}
|
|
206
275
|
/**
|
|
207
276
|
* Splits the code into lines, each holding its runs and its mark. In a shell block a
|
|
@@ -1,155 +1,89 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* confirming control defaults to the semantic danger tone, and a
|
|
7
|
-
* type-to-confirm variant holds a big irreversible action until its name is typed.
|
|
2
|
+
* A confirmation prompt built from parts over {@link AlertDialog}: the root wires the
|
|
3
|
+
* heading and description ids and the panel's `id` into every control, a `.Form` turns
|
|
4
|
+
* confirming into a real submission, and a `.Phrase` holds a big irreversible action
|
|
5
|
+
* until its name is typed. The confirming control defaults to the danger tone.
|
|
8
6
|
*
|
|
9
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
10
8
|
* @copyright Sergio Xalambrí 2026
|
|
11
9
|
*/
|
|
12
|
-
import type { EntryComponent, Handle, Props as TagProps
|
|
10
|
+
import type { EntryComponent, Handle, Props as TagProps } from "remix/component";
|
|
13
11
|
import type { Button } from "./button.js";
|
|
14
12
|
import { AlertDialog } from "./alert-dialog.js";
|
|
15
13
|
/**
|
|
16
|
-
* Prop types for {@link Confirm}.
|
|
14
|
+
* Prop types for {@link Confirm} and its parts.
|
|
17
15
|
*/
|
|
18
16
|
export declare namespace Confirm {
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/** Styling for the confirming control, rendered through {@link AlertDialog.Action}. */
|
|
35
|
-
action?: TagProps<"button">["mix"];
|
|
36
|
-
/** Styling for the `<form>` wrapping the panel's content, rendered only in submit mode. */
|
|
37
|
-
form?: TagProps<"form">["mix"];
|
|
17
|
+
/** What the root shares with its parts. */
|
|
18
|
+
interface Context {
|
|
19
|
+
/** The panel's `id`, which Cancel and Action close. */
|
|
20
|
+
id: string;
|
|
21
|
+
color: Button.Color;
|
|
22
|
+
/** The id {@link Confirm.Title} takes, which names the panel. */
|
|
23
|
+
titleId: string;
|
|
24
|
+
/** The id {@link Confirm.Description} takes, which describes the panel. */
|
|
25
|
+
descriptionId: string;
|
|
26
|
+
/** The id the phrase field takes. */
|
|
27
|
+
phraseId: string;
|
|
28
|
+
}
|
|
29
|
+
/** What a {@link Confirm.Form} shares with the confirming control. */
|
|
30
|
+
interface FormContext {
|
|
31
|
+
submits: true;
|
|
38
32
|
}
|
|
39
33
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* the form's response is what ends the interruption.
|
|
34
|
+
* Every {@link AlertDialog} attribute, with a required `id` a trigger elsewhere targets
|
|
35
|
+
* through `commandfor`/`command="show-modal"`, plus the confirming control's colour.
|
|
43
36
|
*/
|
|
44
|
-
interface
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
interface Props extends Omit<AlertDialog.Props, "id"> {
|
|
38
|
+
id: string;
|
|
39
|
+
/** @default {@link DEFAULT_COLOR} */
|
|
40
|
+
color?: Button.Color;
|
|
41
|
+
}
|
|
42
|
+
/** Every native `<form>` attribute; `method` defaults to `"post"`, since a confirmed action changes state. */
|
|
43
|
+
interface FormProps extends Omit<TagProps<"form">, "method"> {
|
|
48
44
|
method?: "get" | "post";
|
|
49
|
-
/**
|
|
50
|
-
* Hidden inputs submitted along with the confirmation — a CSRF token,
|
|
51
|
-
* an intent discriminator, the id of the record being acted on. They
|
|
52
|
-
* render first inside the form, before the panel's own content.
|
|
53
|
-
*/
|
|
54
|
-
fields?: RemixNode;
|
|
55
45
|
}
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
* the team's name. Reserve it for deleting something large; on routine
|
|
59
|
-
* confirms it reads as melodrama.
|
|
60
|
-
*/
|
|
61
|
-
interface TypeToConfirm {
|
|
46
|
+
/** Every native `<input>` attribute's essentials for the phrase field, and its label as children. */
|
|
47
|
+
interface PhraseProps extends Omit<TagProps<"div">, "children"> {
|
|
62
48
|
/** The exact text that unlocks the confirming control, compared case-sensitively. */
|
|
63
49
|
value: string;
|
|
64
|
-
/**
|
|
65
|
-
label: RemixNode;
|
|
66
|
-
/** Name the typed text submits under in submit mode, so the server can check it again. */
|
|
50
|
+
/** Name the typed text submits under inside a {@link Confirm.Form}, so the server can check it again. */
|
|
67
51
|
name?: string;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* Props accepted by {@link Confirm}. `mix` styles the underlying
|
|
71
|
-
* {@link AlertDialog} host directly; style the composed header, title,
|
|
72
|
-
* description, footer, and controls individually through `parts` instead.
|
|
73
|
-
*/
|
|
74
|
-
interface Props extends Omit<AlertDialog.Props, "id" | "children" | "title"> {
|
|
75
|
-
/**
|
|
76
|
-
* Stable identifier the panel renders as its own `id`; a trigger
|
|
77
|
-
* elsewhere on the page targets it via `commandfor`/`command="show-modal"`,
|
|
78
|
-
* and the cancel and confirm controls point back at it automatically.
|
|
79
|
-
*/
|
|
80
|
-
id: string;
|
|
81
|
-
/** The panel's heading, rendered through {@link AlertDialog.Title}. */
|
|
82
|
-
title: RemixNode;
|
|
83
|
-
/**
|
|
84
|
-
* Supporting copy rendered through {@link AlertDialog.Description}
|
|
85
|
-
* beneath the title. Omit to render no description.
|
|
86
|
-
*/
|
|
87
|
-
description?: RemixNode;
|
|
88
|
-
/** Label for the confirming control, rendered through {@link AlertDialog.Action}. */
|
|
89
|
-
confirmLabel: RemixNode;
|
|
90
|
-
/** Label for the control that backs out without confirming, rendered through {@link AlertDialog.Cancel}. */
|
|
91
|
-
cancelLabel: RemixNode;
|
|
92
|
-
/** Semantic color for the confirming control. Defaults to {@link DEFAULT_COLOR}. */
|
|
93
|
-
color?: Button.Color;
|
|
94
|
-
/**
|
|
95
|
-
* Submission the confirming control performs. Omitting it leaves
|
|
96
|
-
* confirming as a close-only action for the page to react to; setting it
|
|
97
|
-
* submits a real form instead.
|
|
98
|
-
*/
|
|
99
|
-
form?: FormProps;
|
|
100
|
-
/**
|
|
101
|
-
* Holds the confirming control disabled until this phrase is typed. Without
|
|
102
|
-
* script the field's `pattern` blocks the submission instead.
|
|
103
|
-
*/
|
|
104
|
-
typeToConfirm?: TypeToConfirm;
|
|
105
|
-
/** Per-part styling for this wrapper's internally composed elements. */
|
|
106
|
-
parts?: PartsProps;
|
|
52
|
+
/** The field's label, such as `Type "acme" to confirm`. */
|
|
53
|
+
children: TagProps<"label">["children"];
|
|
107
54
|
}
|
|
108
55
|
}
|
|
109
56
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
57
|
+
* Renders the {@link AlertDialog} panel, named by its {@link Confirm.Title} and described by its
|
|
58
|
+
* {@link Confirm.Description} through generated ids. Focus opens on {@link Confirm.Cancel}, or on
|
|
59
|
+
* a {@link Confirm.Phrase} field, which comes first in the panel.
|
|
113
60
|
*
|
|
114
61
|
* @param handle Runtime handle carrying the panel's props and this instance's stable identifier.
|
|
115
|
-
* @returns The render function producing the
|
|
62
|
+
* @returns The render function producing the panel.
|
|
116
63
|
* @example
|
|
117
|
-
* <Button commandfor="confirm-delete" command="show-modal" color="danger">
|
|
118
|
-
* <Confirm
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* title={t("post.publishTitle")}
|
|
129
|
-
* confirmLabel={t("actions.publish")}
|
|
130
|
-
* cancelLabel={t("actions.cancel")}
|
|
131
|
-
* color="brand"
|
|
132
|
-
* />
|
|
133
|
-
* @example
|
|
134
|
-
* <Confirm
|
|
135
|
-
* id="revoke-session"
|
|
136
|
-
* title={t("session.revokeTitle")}
|
|
137
|
-
* confirmLabel={t("actions.revoke")}
|
|
138
|
-
* cancelLabel={t("actions.cancel")}
|
|
139
|
-
* form={{ action: revokeUrl, fields: <input type="hidden" name="csrf" value={token} /> }}
|
|
140
|
-
* />
|
|
141
|
-
* @example
|
|
142
|
-
* <Confirm
|
|
143
|
-
* id="delete-team"
|
|
144
|
-
* title="Delete team?"
|
|
145
|
-
* description="Acme, its 12 monitors and their history are deleted."
|
|
146
|
-
* confirmLabel="Delete team"
|
|
147
|
-
* cancelLabel="Cancel"
|
|
148
|
-
* typeToConfirm={{ value: "acme", label: 'Type "acme" to confirm', name: "confirmation" }}
|
|
149
|
-
* form={{ action: "/teams/acme/delete" }}
|
|
150
|
-
* />
|
|
64
|
+
* <Button commandfor="confirm-delete" command="show-modal" color="danger">Delete project</Button>
|
|
65
|
+
* <Confirm id="confirm-delete">
|
|
66
|
+
* <Confirm.Header>
|
|
67
|
+
* <Confirm.Title>Delete project?</Confirm.Title>
|
|
68
|
+
* <Confirm.Description>Its monitors and their history are deleted.</Confirm.Description>
|
|
69
|
+
* </Confirm.Header>
|
|
70
|
+
* <Confirm.Footer>
|
|
71
|
+
* <Confirm.Cancel>Cancel</Confirm.Cancel>
|
|
72
|
+
* <Confirm.Action>Delete</Confirm.Action>
|
|
73
|
+
* </Confirm.Footer>
|
|
74
|
+
* </Confirm>
|
|
151
75
|
*/
|
|
152
|
-
export declare function Confirm(handle: Handle<Confirm.Props>): () => import("remix/component").RemixElement;
|
|
76
|
+
export declare function Confirm(handle: Handle<Confirm.Props, Confirm.Context>): () => import("remix/component").RemixElement;
|
|
77
|
+
export declare namespace Confirm {
|
|
78
|
+
var Form: (handle: Handle<Confirm.FormProps, Confirm.FormContext>) => () => import("remix/component").RemixElement;
|
|
79
|
+
var Header: (handle: Handle<AlertDialog.HeaderProps>) => () => import("remix/component").RemixElement;
|
|
80
|
+
var Title: (handle: Handle<AlertDialog.TitleProps>) => () => import("remix/component").RemixElement;
|
|
81
|
+
var Description: (handle: Handle<AlertDialog.DescriptionProps>) => () => import("remix/component").RemixElement;
|
|
82
|
+
var Phrase: (handle: Handle<Confirm.PhraseProps>) => () => import("remix/component").RemixElement;
|
|
83
|
+
var Footer: (handle: Handle<AlertDialog.FooterProps>) => () => import("remix/component").RemixElement;
|
|
84
|
+
var Cancel: (handle: Handle<Omit<AlertDialog.CancelProps, "commandfor">>) => () => import("remix/component").RemixElement;
|
|
85
|
+
var Action: (handle: Handle<Omit<AlertDialog.ActionProps, "commandfor">>) => () => import("remix/component").RemixElement;
|
|
86
|
+
}
|
|
153
87
|
/**
|
|
154
88
|
* Props {@link ConfirmPhrase} serializes into the page for hydration, which is why they are
|
|
155
89
|
* a `type`: `SerializableProps` rejects an interface.
|
|
@@ -159,15 +93,14 @@ export type ConfirmPhraseProps = {
|
|
|
159
93
|
id: string;
|
|
160
94
|
/** The exact text that unlocks the confirming control. */
|
|
161
95
|
value: string;
|
|
162
|
-
label: RemixNode;
|
|
163
96
|
name?: string;
|
|
164
97
|
};
|
|
165
98
|
/**
|
|
166
|
-
* Client island: the
|
|
99
|
+
* Client island: the input a type-to-confirm prompt holds. It disables the dialog's
|
|
167
100
|
* confirming control until the typed text matches and clears itself when the dialog
|
|
168
101
|
* closes, so every opening starts locked; without script, `pattern` blocks the submit.
|
|
169
102
|
*
|
|
170
103
|
* @example
|
|
171
|
-
* <ConfirmPhrase id="delete-team-phrase" value="acme"
|
|
104
|
+
* <ConfirmPhrase id="delete-team-phrase" value="acme" />
|
|
172
105
|
*/
|
|
173
106
|
export declare const ConfirmPhrase: EntryComponent<ConfirmPhraseProps>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { mergeMix } from "@sdxc/u/general";
|
|
2
3
|
import { flex, flexCol, gap, vstack } from "@sdxc/u/layout";
|
|
3
4
|
import { clientEntry } from "remix/component";
|
|
4
5
|
import { confirmPhrase } from "../mixins/confirm-phrase.js";
|
|
@@ -7,69 +8,149 @@ import { Input } from "./input.js";
|
|
|
7
8
|
import { Label } from "./label.js";
|
|
8
9
|
/** Semantic color role {@link Confirm} falls back to when `color` is omitted. */
|
|
9
10
|
const DEFAULT_COLOR = "danger";
|
|
10
|
-
/** HTTP method a
|
|
11
|
+
/** HTTP method a {@link Confirm.Form} falls back to when `method` is omitted. */
|
|
11
12
|
const DEFAULT_METHOD = "post";
|
|
12
13
|
/**
|
|
13
|
-
* Column gap the
|
|
14
|
-
* panel's
|
|
15
|
-
* without this the header and footer would lose their spacing.
|
|
14
|
+
* Column gap the form re-declares, matching the panel's own child gap: the form becomes
|
|
15
|
+
* the panel's single child, so without it the header and footer would lose their spacing.
|
|
16
16
|
*/
|
|
17
17
|
const PANEL_GAP = 6;
|
|
18
18
|
/** Characters a `pattern` (compiled with the `v` flag) reads as syntax, escaped to match literally. */
|
|
19
19
|
const PATTERN_SYNTAX = /[\\^$.*+?()[\]{}|/]/g;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* Renders the {@link AlertDialog} panel, named by its {@link Confirm.Title} and described by its
|
|
22
|
+
* {@link Confirm.Description} through generated ids. Focus opens on {@link Confirm.Cancel}, or on
|
|
23
|
+
* a {@link Confirm.Phrase} field, which comes first in the panel.
|
|
24
24
|
*
|
|
25
25
|
* @param handle Runtime handle carrying the panel's props and this instance's stable identifier.
|
|
26
|
-
* @returns The render function producing the
|
|
26
|
+
* @returns The render function producing the panel.
|
|
27
27
|
* @example
|
|
28
|
-
* <Button commandfor="confirm-delete" command="show-modal" color="danger">
|
|
29
|
-
* <Confirm
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* title={t("post.publishTitle")}
|
|
40
|
-
* confirmLabel={t("actions.publish")}
|
|
41
|
-
* cancelLabel={t("actions.cancel")}
|
|
42
|
-
* color="brand"
|
|
43
|
-
* />
|
|
44
|
-
* @example
|
|
45
|
-
* <Confirm
|
|
46
|
-
* id="revoke-session"
|
|
47
|
-
* title={t("session.revokeTitle")}
|
|
48
|
-
* confirmLabel={t("actions.revoke")}
|
|
49
|
-
* cancelLabel={t("actions.cancel")}
|
|
50
|
-
* form={{ action: revokeUrl, fields: <input type="hidden" name="csrf" value={token} /> }}
|
|
51
|
-
* />
|
|
52
|
-
* @example
|
|
53
|
-
* <Confirm
|
|
54
|
-
* id="delete-team"
|
|
55
|
-
* title="Delete team?"
|
|
56
|
-
* description="Acme, its 12 monitors and their history are deleted."
|
|
57
|
-
* confirmLabel="Delete team"
|
|
58
|
-
* cancelLabel="Cancel"
|
|
59
|
-
* typeToConfirm={{ value: "acme", label: 'Type "acme" to confirm', name: "confirmation" }}
|
|
60
|
-
* form={{ action: "/teams/acme/delete" }}
|
|
61
|
-
* />
|
|
28
|
+
* <Button commandfor="confirm-delete" command="show-modal" color="danger">Delete project</Button>
|
|
29
|
+
* <Confirm id="confirm-delete">
|
|
30
|
+
* <Confirm.Header>
|
|
31
|
+
* <Confirm.Title>Delete project?</Confirm.Title>
|
|
32
|
+
* <Confirm.Description>Its monitors and their history are deleted.</Confirm.Description>
|
|
33
|
+
* </Confirm.Header>
|
|
34
|
+
* <Confirm.Footer>
|
|
35
|
+
* <Confirm.Cancel>Cancel</Confirm.Cancel>
|
|
36
|
+
* <Confirm.Action>Delete</Confirm.Action>
|
|
37
|
+
* </Confirm.Footer>
|
|
38
|
+
* </Confirm>
|
|
62
39
|
*/
|
|
63
40
|
export function Confirm(handle) {
|
|
64
41
|
return () => {
|
|
65
|
-
let { id,
|
|
66
|
-
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
42
|
+
let { id, color = DEFAULT_COLOR, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...rest } = handle.props;
|
|
67
43
|
let titleId = `${handle.id}-title`;
|
|
68
|
-
let descriptionId =
|
|
69
|
-
|
|
70
|
-
return (_jsx(AlertDialog, { ...rest, id: id, "aria-labelledby":
|
|
44
|
+
let descriptionId = `${handle.id}-description`;
|
|
45
|
+
handle.context.set({ id, color, titleId, descriptionId, phraseId: `${handle.id}-phrase` });
|
|
46
|
+
return (_jsx(AlertDialog, { ...rest, id: id, "aria-labelledby": ariaLabelledBy ?? titleId, "aria-describedby": ariaDescribedBy ?? descriptionId }));
|
|
71
47
|
};
|
|
72
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Turns confirming into a real submission: the panel's parts go inside, the confirming control
|
|
51
|
+
* becomes its submit button, and hidden inputs (a CSRF token, the record's id) go in as children.
|
|
52
|
+
*
|
|
53
|
+
* @param handle Runtime handle carrying the host `<form>`'s props.
|
|
54
|
+
* @returns The render function producing the form.
|
|
55
|
+
* @example
|
|
56
|
+
* <Confirm.Form action={revokeUrl}>
|
|
57
|
+
* <input type="hidden" name="csrf" value={token} />
|
|
58
|
+
* <Confirm.Header><Confirm.Title>Revoke this session?</Confirm.Title></Confirm.Header>
|
|
59
|
+
* <Confirm.Footer><Confirm.Cancel>Cancel</Confirm.Cancel><Confirm.Action>Revoke</Confirm.Action></Confirm.Footer>
|
|
60
|
+
* </Confirm.Form>
|
|
61
|
+
*/
|
|
62
|
+
Confirm.Form = function ConfirmForm(handle) {
|
|
63
|
+
return () => {
|
|
64
|
+
let { method = DEFAULT_METHOD, mix, ...rest } = handle.props;
|
|
65
|
+
handle.context.set({ submits: true });
|
|
66
|
+
return (_jsx("form", { "data-slot": "confirm-form", ...rest, method: method, mix: mergeMix([flex(), flexCol(), gap(PANEL_GAP)], mix) }));
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The column stacking the title and description.
|
|
71
|
+
*
|
|
72
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
73
|
+
* @returns The render function producing the header.
|
|
74
|
+
*/
|
|
75
|
+
Confirm.Header = function ConfirmHeader(handle) {
|
|
76
|
+
return () => _jsx(AlertDialog.Header, { ...handle.props });
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The panel's heading, which names it.
|
|
80
|
+
*
|
|
81
|
+
* @param handle Runtime handle carrying the heading's props.
|
|
82
|
+
* @returns The render function producing the heading.
|
|
83
|
+
*/
|
|
84
|
+
Confirm.Title = function ConfirmTitle(handle) {
|
|
85
|
+
return () => {
|
|
86
|
+
let context = handle.context.get(Confirm);
|
|
87
|
+
return _jsx(AlertDialog.Title, { id: context?.titleId, ...handle.props });
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The supporting copy under the title, which describes the panel.
|
|
92
|
+
*
|
|
93
|
+
* @param handle Runtime handle carrying the host `<p>`'s props.
|
|
94
|
+
* @returns The render function producing the description.
|
|
95
|
+
*/
|
|
96
|
+
Confirm.Description = function ConfirmDescription(handle) {
|
|
97
|
+
return () => {
|
|
98
|
+
let context = handle.context.get(Confirm);
|
|
99
|
+
return _jsx(AlertDialog.Description, { id: context?.descriptionId, ...handle.props });
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* The type-to-confirm field: its label, then an input that keeps the confirming control
|
|
104
|
+
* disabled until the phrase matches. Reserve it for deleting something large.
|
|
105
|
+
*
|
|
106
|
+
* @param handle Runtime handle carrying the wrapper's props, the phrase and the label.
|
|
107
|
+
* @returns The render function producing the field.
|
|
108
|
+
* @example <Confirm.Phrase value="acme" name="confirmation">Type "acme" to confirm</Confirm.Phrase>
|
|
109
|
+
*/
|
|
110
|
+
Confirm.Phrase = function ConfirmPhraseField(handle) {
|
|
111
|
+
return () => {
|
|
112
|
+
let { value, name, children, mix, ...rest } = handle.props;
|
|
113
|
+
let context = handle.context.get(Confirm);
|
|
114
|
+
let id = context?.phraseId ?? `${handle.id}-phrase`;
|
|
115
|
+
return (_jsxs("div", { "data-slot": "confirm-phrase", ...rest, mix: mergeMix([vstack({ gap: 1.5, align: "stretch" })], mix), children: [_jsx(Label, { htmlFor: id, children: children }), _jsx(ConfirmPhrase, { id: id, value: value, name: name })] }));
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* The end-aligned row holding Cancel, then the confirming control.
|
|
120
|
+
*
|
|
121
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
122
|
+
* @returns The render function producing the row.
|
|
123
|
+
*/
|
|
124
|
+
Confirm.Footer = function ConfirmFooter(handle) {
|
|
125
|
+
return () => _jsx(AlertDialog.Footer, { ...handle.props });
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Backs out without confirming, closing the panel. It takes focus when the panel opens, so
|
|
129
|
+
* Enter on a destructive prompt starts on the safe choice.
|
|
130
|
+
*
|
|
131
|
+
* @param handle Runtime handle carrying the button's props.
|
|
132
|
+
* @returns The render function producing the control.
|
|
133
|
+
*/
|
|
134
|
+
Confirm.Cancel = function ConfirmCancel(handle) {
|
|
135
|
+
return () => {
|
|
136
|
+
let context = handle.context.get(Confirm);
|
|
137
|
+
return (_jsx(AlertDialog.Cancel, { commandfor: context?.id ?? "", autofocus: true, ...handle.props }));
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* The confirming control in the root's colour: inside a {@link Confirm.Form} it submits the
|
|
142
|
+
* form, otherwise it closes the panel for the page to react to.
|
|
143
|
+
*
|
|
144
|
+
* @param handle Runtime handle carrying the button's props.
|
|
145
|
+
* @returns The render function producing the control.
|
|
146
|
+
*/
|
|
147
|
+
Confirm.Action = function ConfirmAction(handle) {
|
|
148
|
+
return () => {
|
|
149
|
+
let context = handle.context.get(Confirm);
|
|
150
|
+
let form = handle.context.get(Confirm.Form);
|
|
151
|
+
return (_jsx(AlertDialog.Action, { "data-confirm-action": "", type: form ? "submit" : undefined, commandfor: form ? undefined : context?.id, color: context?.color ?? DEFAULT_COLOR, ...handle.props }));
|
|
152
|
+
};
|
|
153
|
+
};
|
|
73
154
|
/**
|
|
74
155
|
* Turns a phrase into a `pattern` that matches only that phrase.
|
|
75
156
|
*
|
|
@@ -80,16 +161,16 @@ function escapePattern(value) {
|
|
|
80
161
|
return value.replace(PATTERN_SYNTAX, "\\$&");
|
|
81
162
|
}
|
|
82
163
|
/**
|
|
83
|
-
* Client island: the
|
|
164
|
+
* Client island: the input a type-to-confirm prompt holds. It disables the dialog's
|
|
84
165
|
* confirming control until the typed text matches and clears itself when the dialog
|
|
85
166
|
* closes, so every opening starts locked; without script, `pattern` blocks the submit.
|
|
86
167
|
*
|
|
87
168
|
* @example
|
|
88
|
-
* <ConfirmPhrase id="delete-team-phrase" value="acme"
|
|
169
|
+
* <ConfirmPhrase id="delete-team-phrase" value="acme" />
|
|
89
170
|
*/
|
|
90
171
|
export const ConfirmPhrase = clientEntry("@sdxc/ui/confirm#ConfirmPhrase", function ConfirmPhrase(handle) {
|
|
91
172
|
return () => {
|
|
92
|
-
let { id,
|
|
93
|
-
return (
|
|
173
|
+
let { id, name, value } = handle.props;
|
|
174
|
+
return (_jsx(Input, { id: id, name: name, required: true, autofocus: true, autocomplete: "off", spellcheck: false, pattern: escapePattern(value), mix: [confirmPhrase(value)] }));
|
|
94
175
|
};
|
|
95
176
|
});
|