@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
|
@@ -11,101 +11,283 @@ const CONTAINER_NAME = "ui-usage-estimate";
|
|
|
11
11
|
/** Milliseconds of quiet after the last input before a live bill is re-requested. */
|
|
12
12
|
const DEFAULT_DELAY = 250;
|
|
13
13
|
/**
|
|
14
|
-
* A
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* A {@link UsageEstimate.Form} beside its {@link UsageEstimate.Sheet} on one card, side by
|
|
15
|
+
* side from 40rem; with no script a submit reloads the page on the new bill. For `live`, map
|
|
16
|
+
* {@link UsageEstimateLive} (`@sdxc/ui/landing/usage-estimate`) to re-price while typing.
|
|
17
17
|
*
|
|
18
18
|
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
19
19
|
* @returns The render function producing the calculator's markup.
|
|
20
20
|
* @example
|
|
21
|
-
* <UsageEstimate
|
|
22
|
-
* action="#pricing"
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* rows={[{ label: "Recorded hours", detail: "35 h × $0.36", amount: "$12.60" }]}
|
|
29
|
-
* total={{ label: "Per month", amount: "$12.60" }}
|
|
30
|
-
* />
|
|
31
|
-
* }
|
|
32
|
-
* />
|
|
21
|
+
* <UsageEstimate>
|
|
22
|
+
* <UsageEstimate.Form action="#pricing">
|
|
23
|
+
* <TextField label="Hours a month" type="number" name="hours" defaultValue="40" />
|
|
24
|
+
* <UsageEstimate.Submit>Estimate</UsageEstimate.Submit>
|
|
25
|
+
* </UsageEstimate.Form>
|
|
26
|
+
* <UsageEstimate.Sheet>{bill}</UsageEstimate.Sheet>
|
|
27
|
+
* </UsageEstimate>
|
|
33
28
|
* @example
|
|
34
|
-
* <UsageEstimate
|
|
35
|
-
* action="#pricing"
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* live={{ frame: "pricing-bill", src: "/?hours=40" }}
|
|
39
|
-
* />
|
|
29
|
+
* <UsageEstimate live={{ frame: "pricing-bill", src: "/?hours=40" }}>
|
|
30
|
+
* <UsageEstimate.Form action="#pricing">{fields}</UsageEstimate.Form>
|
|
31
|
+
* <UsageEstimate.Sheet />
|
|
32
|
+
* </UsageEstimate>
|
|
40
33
|
*/
|
|
41
34
|
export function UsageEstimate(handle) {
|
|
42
35
|
return () => {
|
|
43
|
-
let {
|
|
44
|
-
|
|
36
|
+
let { children, live, mix, ...rest } = handle.props;
|
|
37
|
+
handle.context.set({ live });
|
|
38
|
+
return (_jsx("div", { "data-slot": "usage-estimate", ...rest, mix: mergeMix([landingSurface(), container(CONTAINER_NAME)], mix), children: _jsx("div", { mix: [
|
|
45
39
|
raw({ display: "grid", gridTemplateColumns: "minmax(0, 1fr)" }),
|
|
46
40
|
at("40rem", CONTAINER_NAME, raw({ gridTemplateColumns: "minmax(0, 0.9fr) minmax(0, 1.1fr)" })),
|
|
47
|
-
], children:
|
|
48
|
-
raw({
|
|
49
|
-
display: "flex",
|
|
50
|
-
flexDirection: "column",
|
|
51
|
-
alignItems: "stretch",
|
|
52
|
-
gap: "1.25rem",
|
|
53
|
-
padding: "1.5rem",
|
|
54
|
-
}),
|
|
55
|
-
], children: [fields, _jsx(Button, { type: "submit", color: "neutral", variant: "surface", mix: [landingCtaChrome()], children: submitLabel }), live === undefined ? null : (_jsx(UsageEstimateLive, { frame: live.frame, delay: live.delay ?? DEFAULT_DELAY }))] }), _jsx("div", { "data-slot": "usage-estimate-sheet", mix: [
|
|
56
|
-
raw({
|
|
57
|
-
display: "grid",
|
|
58
|
-
padding: "1.5rem",
|
|
59
|
-
backgroundColor: "color-mix(in oklch, CanvasText 3%, transparent)",
|
|
60
|
-
borderStartEndRadius: "inherit",
|
|
61
|
-
borderEndEndRadius: "inherit",
|
|
62
|
-
borderEndStartRadius: "inherit",
|
|
63
|
-
boxShadow: "inset 0 1px 0 var(--ui-landing-hairline)",
|
|
64
|
-
}),
|
|
65
|
-
at("40rem", CONTAINER_NAME, raw({
|
|
66
|
-
borderEndStartRadius: "0",
|
|
67
|
-
boxShadow: "inset 1px 0 0 var(--ui-landing-hairline)",
|
|
68
|
-
})),
|
|
69
|
-
], children: live === undefined ? bill : _jsx(Frame, { name: live.frame, src: live.src }) })] }) }));
|
|
41
|
+
], children: children }) }));
|
|
70
42
|
};
|
|
71
43
|
}
|
|
72
44
|
/**
|
|
73
|
-
* The
|
|
74
|
-
*
|
|
75
|
-
* the
|
|
45
|
+
* The reader's numbers as a GET form: its controls, named as the page reads them from its
|
|
46
|
+
* query, and a {@link UsageEstimate.Submit}, 1.25rem apart. In a live calculator it also
|
|
47
|
+
* holds the island that re-prices the bill as the reader types.
|
|
76
48
|
*
|
|
77
|
-
* @param handle Runtime handle carrying the
|
|
49
|
+
* @param handle Runtime handle carrying the form's props.
|
|
50
|
+
* @returns The render function producing the form.
|
|
51
|
+
*/
|
|
52
|
+
UsageEstimate.Form = function UsageEstimateForm(handle) {
|
|
53
|
+
return () => {
|
|
54
|
+
let { children, mix, ...rest } = handle.props;
|
|
55
|
+
let live = handle.context.get(UsageEstimate)?.live;
|
|
56
|
+
return (_jsxs("form", { "data-slot": "usage-estimate-form", ...rest, method: "get", mix: mergeMix([
|
|
57
|
+
raw({
|
|
58
|
+
display: "flex",
|
|
59
|
+
flexDirection: "column",
|
|
60
|
+
alignItems: "stretch",
|
|
61
|
+
gap: "1.25rem",
|
|
62
|
+
padding: "1.5rem",
|
|
63
|
+
}),
|
|
64
|
+
], mix), children: [children, live === undefined ? null : (_jsx(UsageEstimateLive, { frame: live.frame, delay: live.delay ?? DEFAULT_DELAY }))] }));
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* The form's submit button, a neutral surface button in the landing CTA chrome.
|
|
69
|
+
*
|
|
70
|
+
* @param handle Runtime handle carrying the button's props.
|
|
71
|
+
* @returns The render function producing the button.
|
|
72
|
+
*/
|
|
73
|
+
UsageEstimate.Submit = function UsageEstimateSubmit(handle) {
|
|
74
|
+
return () => {
|
|
75
|
+
let { mix, ...rest } = handle.props;
|
|
76
|
+
return (_jsx(Button, { color: "neutral", variant: "surface", ...rest, type: "submit", mix: mergeMix([landingCtaChrome()], mix) }));
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* The tinted sheet the bill sits on, ruled from the form in `--ui-landing-hairline`. It shows
|
|
81
|
+
* the {@link UsageEstimate.Bill} written into it, or in a live calculator the bill frame.
|
|
82
|
+
*
|
|
83
|
+
* @param handle Runtime handle carrying the sheet's props.
|
|
84
|
+
* @returns The render function producing the sheet.
|
|
85
|
+
*/
|
|
86
|
+
UsageEstimate.Sheet = function UsageEstimateSheet(handle) {
|
|
87
|
+
return () => {
|
|
88
|
+
let { children, mix, ...rest } = handle.props;
|
|
89
|
+
let live = handle.context.get(UsageEstimate)?.live;
|
|
90
|
+
return (_jsx("div", { "data-slot": "usage-estimate-sheet", ...rest, mix: mergeMix([
|
|
91
|
+
raw({
|
|
92
|
+
display: "grid",
|
|
93
|
+
padding: "1.5rem",
|
|
94
|
+
backgroundColor: "color-mix(in oklch, CanvasText 3%, transparent)",
|
|
95
|
+
borderStartEndRadius: "inherit",
|
|
96
|
+
borderEndEndRadius: "inherit",
|
|
97
|
+
borderEndStartRadius: "inherit",
|
|
98
|
+
boxShadow: "inset 0 1px 0 var(--ui-landing-hairline)",
|
|
99
|
+
}),
|
|
100
|
+
at("40rem", CONTAINER_NAME, raw({
|
|
101
|
+
borderEndStartRadius: "0",
|
|
102
|
+
boxShadow: "inset 1px 0 0 var(--ui-landing-hairline)",
|
|
103
|
+
})),
|
|
104
|
+
], mix), children: live === undefined ? children : _jsx(Frame, { name: live.frame, src: live.src }) }));
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* The bill a calculator shows: its {@link UsageEstimate.Table}, then a
|
|
109
|
+
* {@link UsageEstimate.Footnote} and an {@link UsageEstimate.Action} at the sheet's foot. A
|
|
110
|
+
* live route returns it alone for the frame.
|
|
111
|
+
*
|
|
112
|
+
* @param handle Runtime handle carrying the bill's props.
|
|
78
113
|
* @returns The render function producing the bill.
|
|
79
114
|
* @example
|
|
80
|
-
* <UsageEstimate.Bill
|
|
115
|
+
* <UsageEstimate.Bill>
|
|
116
|
+
* <UsageEstimate.Table aria-label="Estimated monthly bill">
|
|
117
|
+
* <UsageEstimate.Lines>{lines}</UsageEstimate.Lines>
|
|
118
|
+
* <UsageEstimate.Total><UsageEstimate.Label>Per month</UsageEstimate.Label><UsageEstimate.Amount>$0.00</UsageEstimate.Amount></UsageEstimate.Total>
|
|
119
|
+
* </UsageEstimate.Table>
|
|
120
|
+
* <UsageEstimate.Footnote>Readers are free.</UsageEstimate.Footnote>
|
|
121
|
+
* </UsageEstimate.Bill>
|
|
81
122
|
*/
|
|
82
123
|
UsageEstimate.Bill = function UsageEstimateBill(handle) {
|
|
83
124
|
return () => {
|
|
84
|
-
let {
|
|
85
|
-
return (
|
|
125
|
+
let { mix, ...rest } = handle.props;
|
|
126
|
+
return (_jsx("div", { "data-slot": "usage-estimate-bill", ...rest, mix: mergeMix([raw({ display: "flex", flexDirection: "column", gap: "1rem", minBlockSize: "100%" })], mix) }));
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The bill's lines and total in a full-width column of tabular figures.
|
|
131
|
+
*
|
|
132
|
+
* @param handle Runtime handle carrying the table's props.
|
|
133
|
+
* @returns The render function producing the table.
|
|
134
|
+
*/
|
|
135
|
+
UsageEstimate.Table = function UsageEstimateTable(handle) {
|
|
136
|
+
return () => {
|
|
137
|
+
let { mix, ...rest } = handle.props;
|
|
138
|
+
return (_jsx("table", { "data-slot": "usage-estimate-table", ...rest, mix: mergeMix([
|
|
86
139
|
raw({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
140
|
+
inlineSize: "100%",
|
|
141
|
+
borderCollapse: "collapse",
|
|
142
|
+
fontVariantNumeric: "tabular-nums",
|
|
143
|
+
fontSize: "0.9375rem",
|
|
91
144
|
}),
|
|
92
|
-
],
|
|
93
|
-
raw({
|
|
94
|
-
inlineSize: "100%",
|
|
95
|
-
borderCollapse: "collapse",
|
|
96
|
-
fontVariantNumeric: "tabular-nums",
|
|
97
|
-
fontSize: "0.9375rem",
|
|
98
|
-
}),
|
|
99
|
-
], children: [_jsx("tbody", { children: rows.map((row) => (_jsx(BillRow, { row: row }))) }), _jsx("tfoot", { "aria-live": "polite", children: _jsx(BillRow, { row: total, total: true }) })] }), footnote === undefined ? null : (_jsx("p", { mix: [
|
|
100
|
-
raw({
|
|
101
|
-
margin: "0",
|
|
102
|
-
fontSize: "0.875rem",
|
|
103
|
-
color: "var(--ui-neutral-fg-muted)",
|
|
104
|
-
textWrap: "pretty",
|
|
105
|
-
}),
|
|
106
|
-
], children: footnote })), cta === undefined ? null : (_jsx("div", { mix: [raw({ display: "grid", marginBlockStart: "auto" })], children: cta }))] }));
|
|
145
|
+
], mix) }));
|
|
107
146
|
};
|
|
108
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* The bill's lines, in the order they add up.
|
|
150
|
+
*
|
|
151
|
+
* @param handle Runtime handle carrying the body's props.
|
|
152
|
+
* @returns The render function producing the table body.
|
|
153
|
+
*/
|
|
154
|
+
UsageEstimate.Lines = function UsageEstimateLines(handle) {
|
|
155
|
+
return () => _jsx("tbody", { "data-slot": "usage-estimate-lines", ...handle.props });
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* One line of the bill: a {@link UsageEstimate.Label} and its {@link UsageEstimate.Amount}.
|
|
159
|
+
*
|
|
160
|
+
* @param handle Runtime handle carrying the row's props.
|
|
161
|
+
* @returns The render function producing the row.
|
|
162
|
+
*/
|
|
163
|
+
UsageEstimate.Line = function UsageEstimateLine(handle) {
|
|
164
|
+
return () => _jsx("tr", { "data-slot": "usage-estimate-line", ...handle.props });
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* The sum, set larger under a rule spanning the table. It is a polite live region, so a
|
|
168
|
+
* re-priced bill is announced by its sum.
|
|
169
|
+
*
|
|
170
|
+
* @param handle Runtime handle carrying the row's props.
|
|
171
|
+
* @returns The render function producing the table foot and its row.
|
|
172
|
+
*/
|
|
173
|
+
UsageEstimate.Total = function UsageEstimateTotal(handle) {
|
|
174
|
+
return () => {
|
|
175
|
+
handle.context.set({ total: true });
|
|
176
|
+
return (_jsx("tfoot", { "aria-live": "polite", children: _jsx("tr", { "data-slot": "usage-estimate-total", "data-total": "", ...handle.props }) }));
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* What a line charges for, as the row's header cell, with an optional
|
|
181
|
+
* {@link UsageEstimate.Detail} under it; emphasised in the total.
|
|
182
|
+
*
|
|
183
|
+
* @param handle Runtime handle carrying the cell's props.
|
|
184
|
+
* @returns The render function producing the header cell.
|
|
185
|
+
*/
|
|
186
|
+
UsageEstimate.Label = function UsageEstimateLabel(handle) {
|
|
187
|
+
return () => {
|
|
188
|
+
let { mix, ...rest } = handle.props;
|
|
189
|
+
let total = isTotal(handle);
|
|
190
|
+
return (_jsx("th", { "data-slot": "usage-estimate-label", scope: "row", ...rest, mix: mergeMix([
|
|
191
|
+
billCell(total),
|
|
192
|
+
raw({
|
|
193
|
+
textAlign: "start",
|
|
194
|
+
fontWeight: total ? "600" : "400",
|
|
195
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
196
|
+
}),
|
|
197
|
+
], mix) }));
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* The arithmetic behind a line's amount, such as `35 h × $0.36`, in small mono under its label.
|
|
202
|
+
*
|
|
203
|
+
* @param handle Runtime handle carrying the span's props.
|
|
204
|
+
* @returns The render function producing the detail.
|
|
205
|
+
*/
|
|
206
|
+
UsageEstimate.Detail = function UsageEstimateDetail(handle) {
|
|
207
|
+
return () => {
|
|
208
|
+
let { mix, ...rest } = handle.props;
|
|
209
|
+
return (_jsx("span", { "data-slot": "usage-estimate-detail", ...rest, mix: mergeMix([
|
|
210
|
+
raw({
|
|
211
|
+
display: "block",
|
|
212
|
+
fontFamily: "var(--ui-font-mono)",
|
|
213
|
+
fontSize: "0.75rem",
|
|
214
|
+
fontWeight: "400",
|
|
215
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
216
|
+
}),
|
|
217
|
+
], mix) }));
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* The formatted amount, such as `$12.60`, pinned to the line's end; large in the total.
|
|
222
|
+
*
|
|
223
|
+
* @param handle Runtime handle carrying the cell's props.
|
|
224
|
+
* @returns The render function producing the amount cell.
|
|
225
|
+
*/
|
|
226
|
+
UsageEstimate.Amount = function UsageEstimateAmount(handle) {
|
|
227
|
+
return () => {
|
|
228
|
+
let { mix, ...rest } = handle.props;
|
|
229
|
+
let total = isTotal(handle);
|
|
230
|
+
return (_jsx("td", { "data-slot": "usage-estimate-amount", ...rest, mix: mergeMix([
|
|
231
|
+
billCell(total),
|
|
232
|
+
raw({
|
|
233
|
+
textAlign: "end",
|
|
234
|
+
whiteSpace: "nowrap",
|
|
235
|
+
paddingInlineStart: "1rem",
|
|
236
|
+
fontSize: total ? "1.75rem" : "inherit",
|
|
237
|
+
fontWeight: total ? "600" : "400",
|
|
238
|
+
letterSpacing: total ? "-0.02em" : "normal",
|
|
239
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
240
|
+
}),
|
|
241
|
+
], mix) }));
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* A muted line under the total, such as what the price leaves out.
|
|
246
|
+
*
|
|
247
|
+
* @param handle Runtime handle carrying the paragraph's props.
|
|
248
|
+
* @returns The render function producing the footnote.
|
|
249
|
+
*/
|
|
250
|
+
UsageEstimate.Footnote = function UsageEstimateFootnote(handle) {
|
|
251
|
+
return () => {
|
|
252
|
+
let { mix, ...rest } = handle.props;
|
|
253
|
+
return (_jsx("p", { "data-slot": "usage-estimate-footnote", ...rest, mix: mergeMix([
|
|
254
|
+
raw({
|
|
255
|
+
margin: "0",
|
|
256
|
+
fontSize: "0.875rem",
|
|
257
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
258
|
+
textWrap: "pretty",
|
|
259
|
+
}),
|
|
260
|
+
], mix) }));
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* The page's next step at the bill's foot, such as its primary CTA, stretched across the sheet.
|
|
265
|
+
*
|
|
266
|
+
* @param handle Runtime handle carrying the cell's props.
|
|
267
|
+
* @returns The render function producing the action cell.
|
|
268
|
+
*/
|
|
269
|
+
UsageEstimate.Action = function UsageEstimateAction(handle) {
|
|
270
|
+
return () => {
|
|
271
|
+
let { mix, ...rest } = handle.props;
|
|
272
|
+
return (_jsx("div", { "data-slot": "usage-estimate-action", ...rest, mix: mergeMix([raw({ display: "grid", marginBlockStart: "auto" })], mix) }));
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
/** Whether a cell sits in the {@link UsageEstimate.Total} row. */
|
|
276
|
+
function isTotal(handle) {
|
|
277
|
+
let context = handle.context.get(UsageEstimate.Total);
|
|
278
|
+
return context?.total === true;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* A bill cell's spacing on the shared baseline; the total's cells carry the rule, so it spans
|
|
282
|
+
* the table's full width.
|
|
283
|
+
*/
|
|
284
|
+
function billCell(total) {
|
|
285
|
+
return raw({
|
|
286
|
+
paddingBlock: total ? "0.875rem 0" : "0.5rem",
|
|
287
|
+
verticalAlign: "baseline",
|
|
288
|
+
borderBlockStart: total ? "1px solid var(--ui-neutral-border-strong)" : "0",
|
|
289
|
+
});
|
|
290
|
+
}
|
|
109
291
|
/**
|
|
110
292
|
* The island a live calculator places in its form: it reloads the named bill frame for the
|
|
111
293
|
* form's query as the reader types, and on submit, with the address following through
|
|
@@ -121,44 +303,3 @@ export const UsageEstimateLive = clientEntry("@sdxc/ui/landing/usage-estimate#Us
|
|
|
121
303
|
};
|
|
122
304
|
return () => (_jsx("span", { "data-slot": "usage-estimate-live", mix: [hidden(), usageEstimateLive({ reload, delay: handle.props.delay })] }));
|
|
123
305
|
});
|
|
124
|
-
/**
|
|
125
|
-
* One line of the bill: the label with its arithmetic under it, and the amount pinned to
|
|
126
|
-
* the end. The total's cells carry the rule, so it spans the table's full width.
|
|
127
|
-
*/
|
|
128
|
-
function BillRow(handle) {
|
|
129
|
-
return () => {
|
|
130
|
-
let { row, total = false } = handle.props;
|
|
131
|
-
let cell = raw({
|
|
132
|
-
paddingBlock: total ? "0.875rem 0" : "0.5rem",
|
|
133
|
-
verticalAlign: "baseline",
|
|
134
|
-
borderBlockStart: total ? "1px solid var(--ui-neutral-border-strong)" : "0",
|
|
135
|
-
});
|
|
136
|
-
return (_jsxs("tr", { "data-total": total ? "" : undefined, children: [_jsxs("th", { scope: "row", mix: [
|
|
137
|
-
cell,
|
|
138
|
-
raw({
|
|
139
|
-
textAlign: "start",
|
|
140
|
-
fontWeight: total ? "600" : "400",
|
|
141
|
-
color: "var(--ui-neutral-fg-emphasis)",
|
|
142
|
-
}),
|
|
143
|
-
], children: [row.label, row.detail === undefined ? null : (_jsx("span", { mix: [
|
|
144
|
-
raw({
|
|
145
|
-
display: "block",
|
|
146
|
-
fontFamily: "var(--ui-font-mono)",
|
|
147
|
-
fontSize: "0.75rem",
|
|
148
|
-
fontWeight: "400",
|
|
149
|
-
color: "var(--ui-neutral-fg-muted)",
|
|
150
|
-
}),
|
|
151
|
-
], children: row.detail }))] }), _jsx("td", { mix: [
|
|
152
|
-
cell,
|
|
153
|
-
raw({
|
|
154
|
-
textAlign: "end",
|
|
155
|
-
whiteSpace: "nowrap",
|
|
156
|
-
paddingInlineStart: "1rem",
|
|
157
|
-
fontSize: total ? "1.75rem" : "inherit",
|
|
158
|
-
fontWeight: total ? "600" : "400",
|
|
159
|
-
letterSpacing: total ? "-0.02em" : "normal",
|
|
160
|
-
color: "var(--ui-neutral-fg-emphasis)",
|
|
161
|
-
}),
|
|
162
|
-
], children: row.amount })] }));
|
|
163
|
-
};
|
|
164
|
-
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tells a compound root whether a caller wrote any part into it, so a root that wraps its
|
|
3
|
+
* optional parts in a row or a ruled line leaves that wrapper out entirely when none are
|
|
4
|
+
* given, instead of drawing an empty, bordered box.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { RemixNode } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Whether `children` holds anything to draw. `undefined`, `null`, booleans, empty strings and
|
|
12
|
+
* lists made only of those (such as a map over no items) count as nothing.
|
|
13
|
+
*
|
|
14
|
+
* @param children The parts a caller wrote.
|
|
15
|
+
* @returns `true` when at least one child would render.
|
|
16
|
+
*/
|
|
17
|
+
export declare function hasParts(children: RemixNode | undefined): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tells a compound root whether a caller wrote any part into it, so a root that wraps its
|
|
3
|
+
* optional parts in a row or a ruled line leaves that wrapper out entirely when none are
|
|
4
|
+
* given, instead of drawing an empty, bordered box.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Whether `children` holds anything to draw. `undefined`, `null`, booleans, empty strings and
|
|
11
|
+
* lists made only of those (such as a map over no items) count as nothing.
|
|
12
|
+
*
|
|
13
|
+
* @param children The parts a caller wrote.
|
|
14
|
+
* @returns `true` when at least one child would render.
|
|
15
|
+
*/
|
|
16
|
+
export function hasParts(children) {
|
|
17
|
+
if (children === undefined || children === null || typeof children === "boolean")
|
|
18
|
+
return false;
|
|
19
|
+
if (children === "")
|
|
20
|
+
return false;
|
|
21
|
+
if (Array.isArray(children))
|
|
22
|
+
return children.some((child) => hasParts(child));
|
|
23
|
+
return true;
|
|
24
|
+
}
|
package/dist/map/map-canvas.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A drawn map: a stage holding one SVG coordinate space, where
|
|
3
|
-
* markers and price pins all place by viewBox units. Pins are HTML links or buttons laid over
|
|
2
|
+
* A drawn map, as pieces a caller writes: a stage holding one SVG coordinate space, where art,
|
|
3
|
+
* routes, moving markers and price pins all place by viewBox units. Pins are HTML links or buttons laid over
|
|
4
4
|
* the art, so they stay crisp, focusable and at reading size at any stage width.
|
|
5
5
|
*
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
@@ -9,20 +9,19 @@
|
|
|
9
9
|
import type { EntryComponent, Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
10
|
/** Prop types for {@link MapCanvas} and its parts. */
|
|
11
11
|
export declare namespace MapCanvas {
|
|
12
|
-
/** Every native `<figure>` attribute, plus the coordinate space and the
|
|
13
|
-
interface Props extends
|
|
12
|
+
/** Every native `<figure>` attribute, plus the coordinate space and the map's name. */
|
|
13
|
+
interface Props extends TagProps<"figure"> {
|
|
14
14
|
/**
|
|
15
15
|
* The SVG viewBox every part places by; a non-zero origin crops into one area of the art.
|
|
16
16
|
* The stage keeps its aspect ratio.
|
|
17
17
|
* @default "0 0 400 300"
|
|
18
18
|
*/
|
|
19
19
|
viewBox?: string;
|
|
20
|
-
/** SVG children drawn under everything else: land, water, parks, roads. */
|
|
21
|
-
art?: RemixNode;
|
|
22
20
|
/** The map's accessible name, such as "Stays in Lisbon". */
|
|
23
21
|
label: string;
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
}
|
|
23
|
+
/** Every native `<svg>` attribute but its geometry; the children are the SVG art. */
|
|
24
|
+
interface ArtProps extends Omit<TagProps<"svg">, "viewBox" | "preserveAspectRatio"> {
|
|
26
25
|
}
|
|
27
26
|
/** The parsed viewBox the stage hands its parts. */
|
|
28
27
|
interface Context {
|
|
@@ -33,15 +32,13 @@ export declare namespace MapCanvas {
|
|
|
33
32
|
viewBox: string;
|
|
34
33
|
}
|
|
35
34
|
/** Every native `<button>` attribute but `children`, plus where the pin sits and what it says. */
|
|
36
|
-
interface PinProps extends Omit<TagProps<"button">, "
|
|
35
|
+
interface PinProps extends Omit<TagProps<"button">, "mix"> {
|
|
37
36
|
/** Mixins for the pin, which renders as either a link or a button. */
|
|
38
37
|
mix?: TagProps<"span">["mix"];
|
|
39
38
|
/** Horizontal position in viewBox units. */
|
|
40
39
|
x: number;
|
|
41
40
|
/** Vertical position in viewBox units. */
|
|
42
41
|
y: number;
|
|
43
|
-
/** The pill's content, such as a price or an icon; with text it names the pin. */
|
|
44
|
-
label: RemixNode;
|
|
45
42
|
/** Renders the pin as a link to this address instead of a button. */
|
|
46
43
|
href?: string;
|
|
47
44
|
/** Lights the pin as if pointed at, such as while its listing is hovered. */
|
|
@@ -77,17 +74,19 @@ export declare namespace MapCanvas {
|
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
/**
|
|
80
|
-
* Renders the stage at the full width of its parent and at the viewBox's aspect ratio,
|
|
81
|
-
*
|
|
82
|
-
* clipped, so the stage never widens the page.
|
|
77
|
+
* Renders the stage at the full width of its parent and at the viewBox's aspect ratio, with
|
|
78
|
+
* its parts over one another: `.Art` under everything, whatever order it comes in. Anything
|
|
79
|
+
* drawn past the viewBox is clipped, so the stage never widens the page.
|
|
83
80
|
*
|
|
84
81
|
* @example
|
|
85
|
-
* <MapCanvas label="Stays in Lisbon"
|
|
86
|
-
* <MapCanvas.
|
|
82
|
+
* <MapCanvas label="Stays in Lisbon">
|
|
83
|
+
* <MapCanvas.Art><rect width="400" height="300" fill="#e8efe3" /></MapCanvas.Art>
|
|
84
|
+
* <MapCanvas.Pin x={120} y={80} href="/stays/1" mapKey="1">$182</MapCanvas.Pin>
|
|
87
85
|
* </MapCanvas>
|
|
88
86
|
*/
|
|
89
87
|
export declare function MapCanvas(handle: Handle<MapCanvas.Props, MapCanvas.Context>): () => import("remix/component").RemixElement;
|
|
90
88
|
export declare namespace MapCanvas {
|
|
89
|
+
var Art: (handle: Handle<MapCanvas.ArtProps>) => () => import("remix/component").RemixElement;
|
|
91
90
|
var Route: (handle: Handle<MapCanvas.RouteProps>) => () => import("remix/component").RemixElement;
|
|
92
91
|
var Marker: (handle: Handle<MapCanvas.MarkerProps>) => () => import("remix/component").RemixElement;
|
|
93
92
|
var Pin: (handle: Handle<MapCanvas.PinProps>) => () => import("remix/component").RemixElement | null;
|
package/dist/map/map-canvas.js
CHANGED
|
@@ -41,21 +41,22 @@ function spaceOf(handle) {
|
|
|
41
41
|
return context ?? parseViewBox(DEFAULT_VIEW_BOX);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Renders the stage at the full width of its parent and at the viewBox's aspect ratio,
|
|
45
|
-
*
|
|
46
|
-
* clipped, so the stage never widens the page.
|
|
44
|
+
* Renders the stage at the full width of its parent and at the viewBox's aspect ratio, with
|
|
45
|
+
* its parts over one another: `.Art` under everything, whatever order it comes in. Anything
|
|
46
|
+
* drawn past the viewBox is clipped, so the stage never widens the page.
|
|
47
47
|
*
|
|
48
48
|
* @example
|
|
49
|
-
* <MapCanvas label="Stays in Lisbon"
|
|
50
|
-
* <MapCanvas.
|
|
49
|
+
* <MapCanvas label="Stays in Lisbon">
|
|
50
|
+
* <MapCanvas.Art><rect width="400" height="300" fill="#e8efe3" /></MapCanvas.Art>
|
|
51
|
+
* <MapCanvas.Pin x={120} y={80} href="/stays/1" mapKey="1">$182</MapCanvas.Pin>
|
|
51
52
|
* </MapCanvas>
|
|
52
53
|
*/
|
|
53
54
|
export function MapCanvas(handle) {
|
|
54
55
|
return () => {
|
|
55
|
-
let {
|
|
56
|
+
let { children, label, mix, viewBox, ...rest } = handle.props;
|
|
56
57
|
let space = parseViewBox(viewBox ?? DEFAULT_VIEW_BOX);
|
|
57
58
|
handle.context.set(space);
|
|
58
|
-
return (
|
|
59
|
+
return (_jsx("figure", { "aria-label": label, ...rest, "data-slot": "map-canvas", mix: mergeMix([
|
|
59
60
|
raw({
|
|
60
61
|
position: "relative",
|
|
61
62
|
isolation: "isolate",
|
|
@@ -67,17 +68,31 @@ export function MapCanvas(handle) {
|
|
|
67
68
|
borderRadius: "var(--ui-map-radius, 0.75rem)",
|
|
68
69
|
background: "var(--ui-map-ground, var(--ui-neutral-bg-tint))",
|
|
69
70
|
}),
|
|
70
|
-
], mix), children:
|
|
71
|
-
raw({
|
|
72
|
-
position: "absolute",
|
|
73
|
-
inset: "0",
|
|
74
|
-
inlineSize: "100%",
|
|
75
|
-
blockSize: "100%",
|
|
76
|
-
display: "block",
|
|
77
|
-
}),
|
|
78
|
-
], children: art }), children] }));
|
|
71
|
+
], mix), children: children }));
|
|
79
72
|
};
|
|
80
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* The art drawn under every other part, in the stage's viewBox units: land, water, parks,
|
|
76
|
+
* roads. It is hidden from assistive tech; the stage's `label` names the map.
|
|
77
|
+
*
|
|
78
|
+
* @example <MapCanvas.Art><path d="M0 200 Q200 150 400 220 V300 H0Z" fill="#cfe3f0" /></MapCanvas.Art>
|
|
79
|
+
*/
|
|
80
|
+
MapCanvas.Art = function MapCanvasArt(handle) {
|
|
81
|
+
return () => {
|
|
82
|
+
let { mix, ...rest } = handle.props;
|
|
83
|
+
let space = spaceOf(handle);
|
|
84
|
+
return (_jsx("svg", { "aria-hidden": "true", focusable: "false", ...rest, viewBox: space.viewBox, preserveAspectRatio: "none", "data-slot": "map-canvas-art", mix: mergeMix([
|
|
85
|
+
raw({
|
|
86
|
+
position: "absolute",
|
|
87
|
+
zIndex: "-1",
|
|
88
|
+
inset: "0",
|
|
89
|
+
inlineSize: "100%",
|
|
90
|
+
blockSize: "100%",
|
|
91
|
+
display: "block",
|
|
92
|
+
}),
|
|
93
|
+
], mix) }));
|
|
94
|
+
};
|
|
95
|
+
};
|
|
81
96
|
/**
|
|
82
97
|
* Draws a route over the art: the travelled share as a solid line, the rest dashed, both over a
|
|
83
98
|
* light casing that keeps the line legible on any art.
|
|
@@ -170,16 +185,17 @@ MapCanvas.Marker = function MapCanvasMarker(handle) {
|
|
|
170
185
|
};
|
|
171
186
|
};
|
|
172
187
|
/**
|
|
173
|
-
* One pin: a pill whose tail tips onto its point,
|
|
174
|
-
* (pass `popovertarget` or `commandfor` to open a card).
|
|
175
|
-
* lift it above its neighbours; a point outside the
|
|
188
|
+
* One pin: a pill whose tail tips onto its point, holding its children (a price, an icon), as a
|
|
189
|
+
* link with `href` or a button otherwise (pass `popovertarget` or `commandfor` to open a card).
|
|
190
|
+
* Pointing, focus and `data-highlighted` lift it above its neighbours; a point outside the
|
|
191
|
+
* viewBox renders nothing.
|
|
176
192
|
*
|
|
177
|
-
* @example <MapCanvas.Pin x={210} y={140}
|
|
178
|
-
* @example <MapCanvas.Pin x={90} y={60}
|
|
193
|
+
* @example <MapCanvas.Pin x={210} y={140} href="/stays/7" mapKey="7" current>$182</MapCanvas.Pin>
|
|
194
|
+
* @example <MapCanvas.Pin x={90} y={60} popovertarget="stay-3-card">Casa Rosa</MapCanvas.Pin>
|
|
179
195
|
*/
|
|
180
196
|
MapCanvas.Pin = function MapCanvasPin(handle) {
|
|
181
197
|
return () => {
|
|
182
|
-
let { current = false, highlighted = false, href,
|
|
198
|
+
let { children, current = false, highlighted = false, href, mapKey, mix, tone, x, y, ...rest } = handle.props;
|
|
183
199
|
let space = spaceOf(handle);
|
|
184
200
|
let left = ((x - space.minX) / space.width) * 100;
|
|
185
201
|
let top = ((y - space.minY) / space.height) * 100;
|
|
@@ -259,9 +275,9 @@ MapCanvas.Pin = function MapCanvasPin(handle) {
|
|
|
259
275
|
], mix),
|
|
260
276
|
};
|
|
261
277
|
if (href !== undefined) {
|
|
262
|
-
return (_jsx("a", { ...rest, ...shared, href: href, children:
|
|
278
|
+
return (_jsx("a", { ...rest, ...shared, href: href, children: children }));
|
|
263
279
|
}
|
|
264
|
-
return (_jsx("button", { type: "button", ...rest, ...shared, children:
|
|
280
|
+
return (_jsx("button", { type: "button", ...rest, ...shared, children: children }));
|
|
265
281
|
};
|
|
266
282
|
};
|
|
267
283
|
/**
|