@senvenli/react 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +32 -2
- package/dist/action/button-group.d.ts +26 -0
- package/dist/action/button-group.js +12 -0
- package/dist/action/button-group.js.map +1 -0
- package/dist/action/button.d.ts +42 -0
- package/dist/action/button.js +58 -0
- package/dist/action/button.js.map +1 -0
- package/dist/action/close-button.d.ts +12 -0
- package/dist/action/close-button.js +13 -0
- package/dist/action/close-button.js.map +1 -0
- package/dist/action/copy-button.d.ts +21 -0
- package/dist/action/copy-button.js +38 -0
- package/dist/action/copy-button.js.map +1 -0
- package/dist/action/fab.d.ts +29 -0
- package/dist/action/fab.js +57 -0
- package/dist/action/fab.js.map +1 -0
- package/dist/action/files.d.ts +70 -0
- package/dist/action/files.js +156 -0
- package/dist/action/files.js.map +1 -0
- package/dist/action/index.d.ts +23 -0
- package/dist/action/index.js +16 -0
- package/dist/action/index.js.map +1 -0
- package/dist/action/language-names.d.ts +19 -0
- package/dist/action/language-names.js +79 -0
- package/dist/action/language-names.js.map +1 -0
- package/dist/action/language-switcher.d.ts +57 -0
- package/dist/action/language-switcher.js +53 -0
- package/dist/action/language-switcher.js.map +1 -0
- package/dist/action/link-button.d.ts +57 -0
- package/dist/action/link-button.js +48 -0
- package/dist/action/link-button.js.map +1 -0
- package/dist/action/link.d.ts +24 -0
- package/dist/action/link.js +18 -0
- package/dist/action/link.js.map +1 -0
- package/dist/action/pressable.d.ts +40 -0
- package/dist/action/pressable.js +65 -0
- package/dist/action/pressable.js.map +1 -0
- package/dist/action/styles.d.ts +60 -0
- package/dist/action/styles.js +109 -0
- package/dist/action/styles.js.map +1 -0
- package/dist/action/theme-script.d.ts +12 -0
- package/dist/action/theme-script.js +23 -0
- package/dist/action/theme-script.js.map +1 -0
- package/dist/action/theme-switcher.d.ts +43 -0
- package/dist/action/theme-switcher.js +260 -0
- package/dist/action/theme-switcher.js.map +1 -0
- package/dist/action/theme-toggle.d.ts +43 -0
- package/dist/action/theme-toggle.js +259 -0
- package/dist/action/theme-toggle.js.map +1 -0
- package/dist/action/toggle.d.ts +44 -0
- package/dist/action/toggle.js +28 -0
- package/dist/action/toggle.js.map +1 -0
- package/dist/action/touch-target.d.ts +9 -0
- package/dist/action/touch-target.js +14 -0
- package/dist/action/touch-target.js.map +1 -0
- package/dist/charts/axis-width.d.ts +186 -0
- package/dist/charts/axis-width.js +1262 -0
- package/dist/charts/axis-width.js.map +1 -0
- package/dist/charts/bar-public.d.ts +16 -0
- package/dist/charts/bar-public.js +16 -0
- package/dist/charts/bar-public.js.map +1 -0
- package/dist/charts/chart-parts.d.ts +136 -0
- package/dist/charts/chart-parts.js +160 -0
- package/dist/charts/chart-parts.js.map +1 -0
- package/dist/charts/core-charts.d.ts +157 -0
- package/dist/charts/core-charts.js +505 -0
- package/dist/charts/core-charts.js.map +1 -0
- package/dist/charts/index.d.ts +12 -0
- package/dist/charts/index.js +8 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/charts/list-charts.d.ts +124 -0
- package/dist/charts/list-charts.js +308 -0
- package/dist/charts/list-charts.js.map +1 -0
- package/dist/charts/more-charts.d.ts +138 -0
- package/dist/charts/more-charts.js +284 -0
- package/dist/charts/more-charts.js.map +1 -0
- package/dist/charts/report-charts.d.ts +138 -0
- package/dist/charts/report-charts.js +370 -0
- package/dist/charts/report-charts.js.map +1 -0
- package/dist/charts/value-tick.d.ts +178 -0
- package/dist/charts/value-tick.js +240 -0
- package/dist/charts/value-tick.js.map +1 -0
- package/dist/collection/data-table-url-hook.d.ts +34 -0
- package/dist/collection/data-table-url-hook.js +70 -0
- package/dist/collection/data-table-url-hook.js.map +1 -0
- package/dist/collection/data-table-url.d.ts +30 -0
- package/dist/collection/data-table-url.js +48 -0
- package/dist/collection/data-table-url.js.map +1 -0
- package/dist/collection/data-table.d.ts +112 -0
- package/dist/collection/data-table.js +188 -0
- package/dist/collection/data-table.js.map +1 -0
- package/dist/collection/grid-list-public.d.ts +18 -0
- package/dist/collection/grid-list-public.js +19 -0
- package/dist/collection/grid-list-public.js.map +1 -0
- package/dist/collection/grid-list.d.ts +73 -0
- package/dist/collection/grid-list.js +46 -0
- package/dist/collection/grid-list.js.map +1 -0
- package/dist/collection/index.d.ts +14 -0
- package/dist/collection/index.js +8 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/list.d.ts +61 -0
- package/dist/collection/list.js +38 -0
- package/dist/collection/list.js.map +1 -0
- package/dist/collection/selection-checkbox.d.ts +5 -0
- package/dist/collection/selection-checkbox.js +13 -0
- package/dist/collection/selection-checkbox.js.map +1 -0
- package/dist/collection/table.d.ts +91 -0
- package/dist/collection/table.js +183 -0
- package/dist/collection/table.js.map +1 -0
- package/dist/collection/tree.d.ts +31 -0
- package/dist/collection/tree.js +22 -0
- package/dist/collection/tree.js.map +1 -0
- package/dist/color/color.d.ts +87 -0
- package/dist/color/color.js +200 -0
- package/dist/color/color.js.map +1 -0
- package/dist/color/contrast.d.ts +34 -0
- package/dist/color/contrast.js +44 -0
- package/dist/color/contrast.js.map +1 -0
- package/dist/color/index.d.ts +4 -0
- package/dist/color/index.js +5 -0
- package/dist/color/index.js.map +1 -0
- package/dist/date/calendar.d.ts +71 -0
- package/dist/date/calendar.js +291 -0
- package/dist/date/calendar.js.map +1 -0
- package/dist/date/fields.d.ts +174 -0
- package/dist/date/fields.js +250 -0
- package/dist/date/fields.js.map +1 -0
- package/dist/date/index.d.ts +7 -0
- package/dist/date/index.js +6 -0
- package/dist/date/index.js.map +1 -0
- package/dist/date/month-grid.d.ts +31 -0
- package/dist/date/month-grid.js +115 -0
- package/dist/date/month-grid.js.map +1 -0
- package/dist/date/pickers.d.ts +118 -0
- package/dist/date/pickers.js +176 -0
- package/dist/date/pickers.js.map +1 -0
- package/dist/date/public.d.ts +25 -0
- package/dist/date/public.js +24 -0
- package/dist/date/public.js.map +1 -0
- package/dist/date/segments.d.ts +153 -0
- package/dist/date/segments.js +433 -0
- package/dist/date/segments.js.map +1 -0
- package/dist/defaults.d.ts +74 -0
- package/dist/defaults.js +100 -0
- package/dist/defaults.js.map +1 -0
- package/dist/density.d.ts +2 -0
- package/dist/density.js +2 -0
- package/dist/density.js.map +1 -0
- package/dist/display/avatar.d.ts +29 -0
- package/dist/display/avatar.js +71 -0
- package/dist/display/avatar.js.map +1 -0
- package/dist/display/badge.d.ts +65 -0
- package/dist/display/badge.js +99 -0
- package/dist/display/badge.js.map +1 -0
- package/dist/display/card.d.ts +72 -0
- package/dist/display/card.js +91 -0
- package/dist/display/card.js.map +1 -0
- package/dist/display/carousel.d.ts +47 -0
- package/dist/display/carousel.js +214 -0
- package/dist/display/carousel.js.map +1 -0
- package/dist/display/description-list.d.ts +25 -0
- package/dist/display/description-list.js +36 -0
- package/dist/display/description-list.js.map +1 -0
- package/dist/display/icon-aliases.d.ts +1 -0
- package/dist/display/icon-aliases.js +259 -0
- package/dist/display/icon-aliases.js.map +1 -0
- package/dist/display/icon-names.d.ts +4 -0
- package/dist/display/icon-names.js +2 -0
- package/dist/display/icon-names.js.map +1 -0
- package/dist/display/icon.d.ts +51 -0
- package/dist/display/icon.js +96 -0
- package/dist/display/icon.js.map +1 -0
- package/dist/display/image-crop.d.ts +106 -0
- package/dist/display/image-crop.js +117 -0
- package/dist/display/image-crop.js.map +1 -0
- package/dist/display/image-cropper.d.ts +68 -0
- package/dist/display/image-cropper.js +284 -0
- package/dist/display/image-cropper.js.map +1 -0
- package/dist/display/image-viewer.d.ts +54 -0
- package/dist/display/image-viewer.js +84 -0
- package/dist/display/image-viewer.js.map +1 -0
- package/dist/display/image.d.ts +26 -0
- package/dist/display/image.js +17 -0
- package/dist/display/image.js.map +1 -0
- package/dist/display/index.d.ts +29 -0
- package/dist/display/index.js +16 -0
- package/dist/display/index.js.map +1 -0
- package/dist/display/iso-chip.d.ts +19 -0
- package/dist/display/iso-chip.js +21 -0
- package/dist/display/iso-chip.js.map +1 -0
- package/dist/display/kbd.d.ts +11 -0
- package/dist/display/kbd.js +33 -0
- package/dist/display/kbd.js.map +1 -0
- package/dist/display/lozenge.d.ts +30 -0
- package/dist/display/lozenge.js +55 -0
- package/dist/display/lozenge.js.map +1 -0
- package/dist/display/scroll-area.d.ts +29 -0
- package/dist/display/scroll-area.js +95 -0
- package/dist/display/scroll-area.js.map +1 -0
- package/dist/display/separator.d.ts +13 -0
- package/dist/display/separator.js +24 -0
- package/dist/display/separator.js.map +1 -0
- package/dist/display/stat.d.ts +35 -0
- package/dist/display/stat.js +41 -0
- package/dist/display/stat.js.map +1 -0
- package/dist/display/timeline.d.ts +44 -0
- package/dist/display/timeline.js +111 -0
- package/dist/display/timeline.js.map +1 -0
- package/dist/display/typography.d.ts +37 -0
- package/dist/display/typography.js +53 -0
- package/dist/display/typography.js.map +1 -0
- package/dist/display/visually-hidden.d.ts +14 -0
- package/dist/display/visually-hidden.js +10 -0
- package/dist/display/visually-hidden.js.map +1 -0
- package/dist/feedback/banner.d.ts +46 -0
- package/dist/feedback/banner.js +157 -0
- package/dist/feedback/banner.js.map +1 -0
- package/dist/feedback/cooldown.d.ts +17 -0
- package/dist/feedback/cooldown.js +59 -0
- package/dist/feedback/cooldown.js.map +1 -0
- package/dist/feedback/empty-state.d.ts +35 -0
- package/dist/feedback/empty-state.js +39 -0
- package/dist/feedback/empty-state.js.map +1 -0
- package/dist/feedback/index.d.ts +12 -0
- package/dist/feedback/index.js +11 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/feedback/meter.d.ts +33 -0
- package/dist/feedback/meter.js +42 -0
- package/dist/feedback/meter.js.map +1 -0
- package/dist/feedback/motion.d.ts +9 -0
- package/dist/feedback/motion.js +57 -0
- package/dist/feedback/motion.js.map +1 -0
- package/dist/feedback/progress.d.ts +39 -0
- package/dist/feedback/progress.js +68 -0
- package/dist/feedback/progress.js.map +1 -0
- package/dist/feedback/skeleton.d.ts +48 -0
- package/dist/feedback/skeleton.js +61 -0
- package/dist/feedback/skeleton.js.map +1 -0
- package/dist/feedback/spinner.d.ts +19 -0
- package/dist/feedback/spinner.js +29 -0
- package/dist/feedback/spinner.js.map +1 -0
- package/dist/feedback/status-dot.d.ts +23 -0
- package/dist/feedback/status-dot.js +37 -0
- package/dist/feedback/status-dot.js.map +1 -0
- package/dist/form/countries.d.ts +34 -0
- package/dist/form/countries.js +273 -0
- package/dist/form/countries.js.map +1 -0
- package/dist/form/data-attributes.d.ts +11 -0
- package/dist/form/data-attributes.js +22 -0
- package/dist/form/data-attributes.js.map +1 -0
- package/dist/form/field-parts.d.ts +113 -0
- package/dist/form/field-parts.js +178 -0
- package/dist/form/field-parts.js.map +1 -0
- package/dist/form/field.d.ts +36 -0
- package/dist/form/field.js +65 -0
- package/dist/form/field.js.map +1 -0
- package/dist/form/files.d.ts +70 -0
- package/dist/form/files.js +156 -0
- package/dist/form/files.js.map +1 -0
- package/dist/form/form.d.ts +40 -0
- package/dist/form/form.js +74 -0
- package/dist/form/form.js.map +1 -0
- package/dist/form/image-crop.d.ts +106 -0
- package/dist/form/image-crop.js +117 -0
- package/dist/form/image-crop.js.map +1 -0
- package/dist/form/image-cropper.d.ts +68 -0
- package/dist/form/image-cropper.js +284 -0
- package/dist/form/image-cropper.js.map +1 -0
- package/dist/form/index.d.ts +24 -0
- package/dist/form/index.js +15 -0
- package/dist/form/index.js.map +1 -0
- package/dist/form/input-group.d.ts +63 -0
- package/dist/form/input-group.js +63 -0
- package/dist/form/input-group.js.map +1 -0
- package/dist/form/input-otp.d.ts +35 -0
- package/dist/form/input-otp.js +83 -0
- package/dist/form/input-otp.js.map +1 -0
- package/dist/form/input.d.ts +36 -0
- package/dist/form/input.js +41 -0
- package/dist/form/input.js.map +1 -0
- package/dist/form/number-field.d.ts +84 -0
- package/dist/form/number-field.js +81 -0
- package/dist/form/number-field.js.map +1 -0
- package/dist/form/otp-field.d.ts +37 -0
- package/dist/form/otp-field.js +116 -0
- package/dist/form/otp-field.js.map +1 -0
- package/dist/form/password-field.d.ts +61 -0
- package/dist/form/password-field.js +61 -0
- package/dist/form/password-field.js.map +1 -0
- package/dist/form/phone-field.d.ts +104 -0
- package/dist/form/phone-field.js +275 -0
- package/dist/form/phone-field.js.map +1 -0
- package/dist/form/phone-paste.d.ts +24 -0
- package/dist/form/phone-paste.js +40 -0
- package/dist/form/phone-paste.js.map +1 -0
- package/dist/form/phone.d.ts +159 -0
- package/dist/form/phone.js +309 -0
- package/dist/form/phone.js.map +1 -0
- package/dist/form/search-field.d.ts +29 -0
- package/dist/form/search-field.js +23 -0
- package/dist/form/search-field.js.map +1 -0
- package/dist/form/styles.d.ts +31 -0
- package/dist/form/styles.js +43 -0
- package/dist/form/styles.js.map +1 -0
- package/dist/form/text-area.d.ts +70 -0
- package/dist/form/text-area.js +93 -0
- package/dist/form/text-area.js.map +1 -0
- package/dist/form/text-field.d.ts +131 -0
- package/dist/form/text-field.js +59 -0
- package/dist/form/text-field.js.map +1 -0
- package/dist/form/validation.d.ts +145 -0
- package/dist/form/validation.js +136 -0
- package/dist/form/validation.js.map +1 -0
- package/dist/i18n.d.ts +438 -0
- package/dist/i18n.js +948 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/intl-locale.d.ts +30 -0
- package/dist/intl-locale.js +83 -0
- package/dist/intl-locale.js.map +1 -0
- package/dist/layers.d.ts +32 -0
- package/dist/layers.js +33 -0
- package/dist/layers.js.map +1 -0
- package/dist/layout/auth-form-layout.d.ts +71 -0
- package/dist/layout/auth-form-layout.js +61 -0
- package/dist/layout/auth-form-layout.js.map +1 -0
- package/dist/layout/auth-layout.d.ts +59 -0
- package/dist/layout/auth-layout.js +26 -0
- package/dist/layout/auth-layout.js.map +1 -0
- package/dist/layout/box.d.ts +26 -0
- package/dist/layout/box.js +16 -0
- package/dist/layout/box.js.map +1 -0
- package/dist/layout/grid.d.ts +27 -0
- package/dist/layout/grid.js +26 -0
- package/dist/layout/grid.js.map +1 -0
- package/dist/layout/index.d.ts +16 -0
- package/dist/layout/index.js +12 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/pressable.d.ts +40 -0
- package/dist/layout/pressable.js +65 -0
- package/dist/layout/pressable.js.map +1 -0
- package/dist/layout/reset-sent-card.d.ts +39 -0
- package/dist/layout/reset-sent-card.js +22 -0
- package/dist/layout/reset-sent-card.js.map +1 -0
- package/dist/layout/scroll-area.d.ts +29 -0
- package/dist/layout/scroll-area.js +95 -0
- package/dist/layout/scroll-area.js.map +1 -0
- package/dist/layout/section.d.ts +41 -0
- package/dist/layout/section.js +22 -0
- package/dist/layout/section.js.map +1 -0
- package/dist/layout/split.d.ts +50 -0
- package/dist/layout/split.js +35 -0
- package/dist/layout/split.js.map +1 -0
- package/dist/layout/stack.d.ts +44 -0
- package/dist/layout/stack.js +36 -0
- package/dist/layout/stack.js.map +1 -0
- package/dist/layout/tokens.d.ts +33 -0
- package/dist/layout/tokens.js +85 -0
- package/dist/layout/tokens.js.map +1 -0
- package/dist/layout/toolbar.d.ts +37 -0
- package/dist/layout/toolbar.js +334 -0
- package/dist/layout/toolbar.js.map +1 -0
- package/dist/navigate-context.d.ts +12 -0
- package/dist/navigate-context.js +13 -0
- package/dist/navigate-context.js.map +1 -0
- package/dist/navigation/accordion.d.ts +40 -0
- package/dist/navigation/accordion.js +33 -0
- package/dist/navigation/accordion.js.map +1 -0
- package/dist/navigation/bottom-nav.d.ts +29 -0
- package/dist/navigation/bottom-nav.js +48 -0
- package/dist/navigation/bottom-nav.js.map +1 -0
- package/dist/navigation/brand-link-context.d.ts +8 -0
- package/dist/navigation/brand-link-context.js +9 -0
- package/dist/navigation/brand-link-context.js.map +1 -0
- package/dist/navigation/breadcrumbs.d.ts +36 -0
- package/dist/navigation/breadcrumbs.js +51 -0
- package/dist/navigation/breadcrumbs.js.map +1 -0
- package/dist/navigation/dock.d.ts +27 -0
- package/dist/navigation/dock.js +47 -0
- package/dist/navigation/dock.js.map +1 -0
- package/dist/navigation/footer.d.ts +43 -0
- package/dist/navigation/footer.js +43 -0
- package/dist/navigation/footer.js.map +1 -0
- package/dist/navigation/index.d.ts +22 -0
- package/dist/navigation/index.js +17 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/navigation/language-names.d.ts +19 -0
- package/dist/navigation/language-names.js +79 -0
- package/dist/navigation/language-names.js.map +1 -0
- package/dist/navigation/language-switcher.d.ts +55 -0
- package/dist/navigation/language-switcher.js +53 -0
- package/dist/navigation/language-switcher.js.map +1 -0
- package/dist/navigation/nav-panel.d.ts +18 -0
- package/dist/navigation/nav-panel.js +51 -0
- package/dist/navigation/nav-panel.js.map +1 -0
- package/dist/navigation/navbar.d.ts +73 -0
- package/dist/navigation/navbar.js +64 -0
- package/dist/navigation/navbar.js.map +1 -0
- package/dist/navigation/page-header.d.ts +37 -0
- package/dist/navigation/page-header.js +50 -0
- package/dist/navigation/page-header.js.map +1 -0
- package/dist/navigation/pagination.d.ts +25 -0
- package/dist/navigation/pagination.js +51 -0
- package/dist/navigation/pagination.js.map +1 -0
- package/dist/navigation/panel-header.d.ts +37 -0
- package/dist/navigation/panel-header.js +50 -0
- package/dist/navigation/panel-header.js.map +1 -0
- package/dist/navigation/sidebar-script.d.ts +12 -0
- package/dist/navigation/sidebar-script.js +20 -0
- package/dist/navigation/sidebar-script.js.map +1 -0
- package/dist/navigation/sidebar.d.ts +149 -0
- package/dist/navigation/sidebar.js +332 -0
- package/dist/navigation/sidebar.js.map +1 -0
- package/dist/navigation/skip-link.d.ts +12 -0
- package/dist/navigation/skip-link.js +30 -0
- package/dist/navigation/skip-link.js.map +1 -0
- package/dist/navigation/stepper.d.ts +50 -0
- package/dist/navigation/stepper.js +96 -0
- package/dist/navigation/stepper.js.map +1 -0
- package/dist/navigation/tabs.d.ts +84 -0
- package/dist/navigation/tabs.js +118 -0
- package/dist/navigation/tabs.js.map +1 -0
- package/dist/navigation/toolbar.d.ts +37 -0
- package/dist/navigation/toolbar.js +334 -0
- package/dist/navigation/toolbar.js.map +1 -0
- package/dist/overlay/alert-dialog.d.ts +63 -0
- package/dist/overlay/alert-dialog.js +76 -0
- package/dist/overlay/alert-dialog.js.map +1 -0
- package/dist/overlay/command-palette.d.ts +53 -0
- package/dist/overlay/command-palette.js +130 -0
- package/dist/overlay/command-palette.js.map +1 -0
- package/dist/overlay/command.d.ts +53 -0
- package/dist/overlay/command.js +129 -0
- package/dist/overlay/command.js.map +1 -0
- package/dist/overlay/context-menu.d.ts +29 -0
- package/dist/overlay/context-menu.js +58 -0
- package/dist/overlay/context-menu.js.map +1 -0
- package/dist/overlay/dialog.d.ts +162 -0
- package/dist/overlay/dialog.js +174 -0
- package/dist/overlay/dialog.js.map +1 -0
- package/dist/overlay/drawer.d.ts +41 -0
- package/dist/overlay/drawer.js +114 -0
- package/dist/overlay/drawer.js.map +1 -0
- package/dist/overlay/floating.d.ts +142 -0
- package/dist/overlay/floating.js +226 -0
- package/dist/overlay/floating.js.map +1 -0
- package/dist/overlay/hover-card.d.ts +19 -0
- package/dist/overlay/hover-card.js +31 -0
- package/dist/overlay/hover-card.js.map +1 -0
- package/dist/overlay/index.d.ts +18 -0
- package/dist/overlay/index.js +12 -0
- package/dist/overlay/index.js.map +1 -0
- package/dist/overlay/overlay-base.d.ts +105 -0
- package/dist/overlay/overlay-base.js +250 -0
- package/dist/overlay/overlay-base.js.map +1 -0
- package/dist/overlay/overlay.d.ts +299 -0
- package/dist/overlay/overlay.js +558 -0
- package/dist/overlay/overlay.js.map +1 -0
- package/dist/overlay/toast.d.ts +58 -0
- package/dist/overlay/toast.js +145 -0
- package/dist/overlay/toast.js.map +1 -0
- package/dist/provider.d.ts +26 -0
- package/dist/provider.js +30 -0
- package/dist/provider.js.map +1 -0
- package/dist/selection/autocomplete.d.ts +54 -0
- package/dist/selection/autocomplete.js +122 -0
- package/dist/selection/autocomplete.js.map +1 -0
- package/dist/selection/checkbox.d.ts +56 -0
- package/dist/selection/checkbox.js +49 -0
- package/dist/selection/checkbox.js.map +1 -0
- package/dist/selection/choice-size.d.ts +26 -0
- package/dist/selection/choice-size.js +50 -0
- package/dist/selection/choice-size.js.map +1 -0
- package/dist/selection/choice-text.d.ts +21 -0
- package/dist/selection/choice-text.js +33 -0
- package/dist/selection/choice-text.js.map +1 -0
- package/dist/selection/combobox.d.ts +173 -0
- package/dist/selection/combobox.js +410 -0
- package/dist/selection/combobox.js.map +1 -0
- package/dist/selection/index.d.ts +20 -0
- package/dist/selection/index.js +13 -0
- package/dist/selection/index.js.map +1 -0
- package/dist/selection/list-box.d.ts +30 -0
- package/dist/selection/list-box.js +16 -0
- package/dist/selection/list-box.js.map +1 -0
- package/dist/selection/listbox.d.ts +44 -0
- package/dist/selection/listbox.js +49 -0
- package/dist/selection/listbox.js.map +1 -0
- package/dist/selection/match.d.ts +20 -0
- package/dist/selection/match.js +57 -0
- package/dist/selection/match.js.map +1 -0
- package/dist/selection/multi-select.d.ts +72 -0
- package/dist/selection/multi-select.js +138 -0
- package/dist/selection/multi-select.js.map +1 -0
- package/dist/selection/radio-card.d.ts +31 -0
- package/dist/selection/radio-card.js +29 -0
- package/dist/selection/radio-card.js.map +1 -0
- package/dist/selection/radio.d.ts +72 -0
- package/dist/selection/radio.js +64 -0
- package/dist/selection/radio.js.map +1 -0
- package/dist/selection/select-public.d.ts +19 -0
- package/dist/selection/select-public.js +24 -0
- package/dist/selection/select-public.js.map +1 -0
- package/dist/selection/select.d.ts +72 -0
- package/dist/selection/select.js +69 -0
- package/dist/selection/select.js.map +1 -0
- package/dist/selection/slider.d.ts +16 -0
- package/dist/selection/slider.js +44 -0
- package/dist/selection/slider.js.map +1 -0
- package/dist/selection/styles.d.ts +26 -0
- package/dist/selection/styles.js +78 -0
- package/dist/selection/styles.js.map +1 -0
- package/dist/selection/switch.d.ts +24 -0
- package/dist/selection/switch.js +27 -0
- package/dist/selection/switch.js.map +1 -0
- package/dist/selection/tag-group.d.ts +38 -0
- package/dist/selection/tag-group.js +45 -0
- package/dist/selection/tag-group.js.map +1 -0
- package/dist/tone.d.ts +6 -0
- package/dist/tone.js +2 -0
- package/dist/tone.js.map +1 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +42 -0
- package/dist/utils.js.map +1 -0
- package/manifest/component.full.schema.json +391 -0
- package/manifest/component.schema.json +279 -0
- package/manifests/accordion.json +299 -0
- package/manifests/alert-dialog.json +261 -0
- package/manifests/area-chart.json +338 -0
- package/manifests/autocomplete.json +299 -0
- package/manifests/avatar.json +253 -0
- package/manifests/badge.json +288 -0
- package/manifests/banner.json +185 -0
- package/manifests/bar-chart.json +454 -0
- package/manifests/bar-list.json +262 -0
- package/manifests/bottom-nav.json +139 -0
- package/manifests/box.json +3450 -0
- package/manifests/breadcrumbs.json +199 -0
- package/manifests/button-group.json +2294 -0
- package/manifests/button.json +1211 -0
- package/manifests/calendar-heatmap.json +218 -0
- package/manifests/calendar.json +299 -0
- package/manifests/card.json +308 -0
- package/manifests/carousel.json +263 -0
- package/manifests/chart-parts.json +309 -0
- package/manifests/checkbox.json +998 -0
- package/manifests/close-button.json +1000 -0
- package/manifests/color-field.json +276 -0
- package/manifests/color-picker.json +161 -0
- package/manifests/color-swatch-picker.json +220 -0
- package/manifests/color-swatch.json +140 -0
- package/manifests/combobox.json +581 -0
- package/manifests/command.json +275 -0
- package/manifests/composed-chart.json +287 -0
- package/manifests/context-menu.json +148 -0
- package/manifests/copy-button.json +192 -0
- package/manifests/data-table.json +334 -0
- package/manifests/date-field.json +302 -0
- package/manifests/date-picker.json +472 -0
- package/manifests/description-list.json +201 -0
- package/manifests/dialog.json +322 -0
- package/manifests/donut-chart.json +264 -0
- package/manifests/drawer.json +211 -0
- package/manifests/empty-state.json +185 -0
- package/manifests/fab.json +172 -0
- package/manifests/field.json +209 -0
- package/manifests/file-upload.json +791 -0
- package/manifests/form.json +829 -0
- package/manifests/funnel-chart.json +223 -0
- package/manifests/gauge-chart.json +252 -0
- package/manifests/grid-list.json +335 -0
- package/manifests/grid.json +3482 -0
- package/manifests/heading.json +183 -0
- package/manifests/heatmap.json +265 -0
- package/manifests/hover-card.json +172 -0
- package/manifests/icon.json +201 -0
- package/manifests/image-cropper.json +295 -0
- package/manifests/image-viewer.json +198 -0
- package/manifests/image.json +193 -0
- package/manifests/index.json +2035 -0
- package/manifests/input-group.json +3571 -0
- package/manifests/input.json +1557 -0
- package/manifests/kbd.json +98 -0
- package/manifests/language-switcher.json +274 -0
- package/manifests/line-chart.json +342 -0
- package/manifests/link.json +867 -0
- package/manifests/list-box.json +213 -0
- package/manifests/menu.json +453 -0
- package/manifests/meter.json +145 -0
- package/manifests/navbar.json +281 -0
- package/manifests/otp-field.json +1029 -0
- package/manifests/page-header.json +164 -0
- package/manifests/pagination.json +181 -0
- package/manifests/popover.json +205 -0
- package/manifests/pressable.json +367 -0
- package/manifests/progress.json +282 -0
- package/manifests/radar-chart.json +229 -0
- package/manifests/radial-chart.json +195 -0
- package/manifests/radio.json +975 -0
- package/manifests/scatter-chart.json +277 -0
- package/manifests/scroll-area.json +127 -0
- package/manifests/section.json +169 -0
- package/manifests/select.json +474 -0
- package/manifests/separator.json +119 -0
- package/manifests/sidebar.json +584 -0
- package/manifests/skeleton.json +235 -0
- package/manifests/skip-link.json +89 -0
- package/manifests/slider.json +706 -0
- package/manifests/sparkline.json +208 -0
- package/manifests/spinner.json +105 -0
- package/manifests/split.json +6618 -0
- package/manifests/stack.json +3541 -0
- package/manifests/stat.json +192 -0
- package/manifests/stepper.json +279 -0
- package/manifests/switch.json +205 -0
- package/manifests/table.json +375 -0
- package/manifests/tabs.json +438 -0
- package/manifests/tag-group.json +264 -0
- package/manifests/text-area.json +1136 -0
- package/manifests/text.json +244 -0
- package/manifests/theme-switcher.json +152 -0
- package/manifests/time-field.json +284 -0
- package/manifests/timeline.json +196 -0
- package/manifests/toast.json +87 -0
- package/manifests/toggle-button.json +1489 -0
- package/manifests/toolbar.json +145 -0
- package/manifests/tooltip.json +181 -0
- package/manifests/tracker.json +192 -0
- package/manifests/tree.json +245 -0
- package/manifests/visually-hidden.json +114 -0
- package/package.json +117 -3
- package/styles/base.css +56 -0
- package/styles/theme.css +154 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useLocale } from "react-aria-components";
|
|
4
|
+
import { useMotionSetting } from "../defaults.js";
|
|
5
|
+
/** True when the user asked for reduced motion; follows changes. */
|
|
6
|
+
function readReduced() {
|
|
7
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
8
|
+
}
|
|
9
|
+
/** True when motion should be reduced: the device asks for it, or the app's motion setting in effect is reduce/none. */
|
|
10
|
+
export function usePrefersReducedMotion() {
|
|
11
|
+
const setting = useMotionSetting();
|
|
12
|
+
// Read on the first render, so no animation starts and is cancelled a moment later.
|
|
13
|
+
const [reduced, setReduced] = React.useState(readReduced);
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function")
|
|
16
|
+
return;
|
|
17
|
+
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
18
|
+
const update = () => setReduced(media.matches);
|
|
19
|
+
if (typeof media.addEventListener === "function") {
|
|
20
|
+
media.addEventListener("change", update);
|
|
21
|
+
return () => media.removeEventListener("change", update);
|
|
22
|
+
}
|
|
23
|
+
// Older Safari only has the deprecated listener API.
|
|
24
|
+
media.addListener?.(update);
|
|
25
|
+
return () => media.removeListener?.(update);
|
|
26
|
+
}, []);
|
|
27
|
+
return reduced || setting !== "auto";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A looping animation through the Web Animations API, so the design system
|
|
31
|
+
* needs no global keyframes; it does not run under reduced motion (or where
|
|
32
|
+
* the API does not exist).
|
|
33
|
+
*/
|
|
34
|
+
export function useLoop(ref, keyframes, duration, enabled, easing = "ease-in-out") {
|
|
35
|
+
const reduced = usePrefersReducedMotion();
|
|
36
|
+
// A locale switch can flip the page direction under a mounted loop; restart it so it re-reads the CSS direction.
|
|
37
|
+
// A dir set some other way (a parent effect, no locale change) is only picked up on the next restart.
|
|
38
|
+
const { direction: localeDirection } = useLocale();
|
|
39
|
+
// Keyframes may depend on the element's own CSS direction, the same source the rtl: variants use.
|
|
40
|
+
const build = React.useRef(keyframes);
|
|
41
|
+
build.current = keyframes;
|
|
42
|
+
const frames = typeof keyframes === "function" ? "fn" : JSON.stringify(keyframes);
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
const element = ref.current;
|
|
45
|
+
if (!enabled || reduced || !element || typeof element.animate !== "function")
|
|
46
|
+
return;
|
|
47
|
+
const computed = getComputedStyle(element).direction;
|
|
48
|
+
// Environments without layout (jsdom) leave direction unresolved; the nearest dir attribute is the same answer.
|
|
49
|
+
const direction = (computed === "rtl" || computed === "ltr" ? computed : element.closest("[dir]")?.getAttribute("dir")) === "rtl" ? "rtl" : "ltr";
|
|
50
|
+
const source = build.current;
|
|
51
|
+
const list = typeof source === "function" ? source(direction) : source;
|
|
52
|
+
const animation = element.animate(list, { duration, iterations: Infinity, easing });
|
|
53
|
+
return () => animation.cancel();
|
|
54
|
+
}, [ref, frames, duration, enabled, reduced, easing, localeDirection]);
|
|
55
|
+
return reduced;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.js","sourceRoot":"","sources":["../../src/feedback/motion.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,oEAAoE;AACpE,SAAS,WAAW;IAClB,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,IAAI,MAAM,CAAC,UA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,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IACvE,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { useLocale } from \"react-aria-components\";\n\nimport { useMotionSetting } from \"../defaults\";\n\n/** True when the user asked for reduced motion; follows changes. */\nfunction readReduced() {\n return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" && window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n}\n\n/** True when motion should be reduced: the device asks for it, or the app's motion setting in effect is reduce/none. */\nexport function usePrefersReducedMotion() {\n const setting = useMotionSetting();\n // Read on the first render, so no animation starts and is cancelled a moment later.\n const [reduced, setReduced] = React.useState(readReduced);\n React.useEffect(() => {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") return;\n const media = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n const update = () => setReduced(media.matches);\n if (typeof media.addEventListener === \"function\") {\n media.addEventListener(\"change\", update);\n return () => media.removeEventListener(\"change\", update);\n }\n // Older Safari only has the deprecated listener API.\n media.addListener?.(update);\n return () => media.removeListener?.(update);\n }, []);\n return reduced || setting !== \"auto\";\n}\n\n/**\n * A looping animation through the Web Animations API, so the design system\n * needs no global keyframes; it does not run under reduced motion (or where\n * the API does not exist).\n */\nexport function useLoop(\n ref: React.RefObject<HTMLElement | null>,\n keyframes: Keyframe[] | ((direction: \"ltr\" | \"rtl\") => Keyframe[]),\n duration: number,\n enabled: boolean,\n easing: \"ease-in-out\" | \"linear\" = \"ease-in-out\",\n) {\n const reduced = usePrefersReducedMotion();\n // A locale switch can flip the page direction under a mounted loop; restart it so it re-reads the CSS direction.\n // A dir set some other way (a parent effect, no locale change) is only picked up on the next restart.\n const { direction: localeDirection } = useLocale();\n // Keyframes may depend on the element's own CSS direction, the same source the rtl: variants use.\n const build = React.useRef(keyframes);\n build.current = keyframes;\n const frames = typeof keyframes === \"function\" ? \"fn\" : JSON.stringify(keyframes);\n React.useEffect(() => {\n const element = ref.current;\n if (!enabled || reduced || !element || typeof element.animate !== \"function\") return;\n const computed = getComputedStyle(element).direction;\n // Environments without layout (jsdom) leave direction unresolved; the nearest dir attribute is the same answer.\n const direction = (computed === \"rtl\" || computed === \"ltr\" ? computed : element.closest(\"[dir]\")?.getAttribute(\"dir\")) === \"rtl\" ? \"rtl\" : \"ltr\";\n const source = build.current;\n const list = typeof source === \"function\" ? source(direction) : source;\n const animation = element.animate(list, { duration, iterations: Infinity, easing });\n return () => animation.cancel();\n }, [ref, frames, duration, enabled, reduced, easing, localeDirection]);\n return reduced;\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type WithMotion } from "../defaults.js";
|
|
3
|
+
import type { Tone } from "../tone.js";
|
|
4
|
+
export type ProgressTone = Extract<Tone, "brand" | "success" | "danger">;
|
|
5
|
+
export type ProgressBarProps = {
|
|
6
|
+
/** What is in progress ("Importing contacts"). */
|
|
7
|
+
label: React.ReactNode;
|
|
8
|
+
value?: number;
|
|
9
|
+
minValue?: number;
|
|
10
|
+
maxValue?: number;
|
|
11
|
+
/** Real units where they exist ("142 / 220", "3 / 5 steps"); defaults to the percentage. */
|
|
12
|
+
valueLabel?: React.ReactNode;
|
|
13
|
+
/** A task of unknown length: a 30% segment sweeps across. */
|
|
14
|
+
isIndeterminate?: boolean;
|
|
15
|
+
/** `success` / `danger` for a finished or failed task; pair it with a word in `valueLabel`. */
|
|
16
|
+
tone?: ProgressTone;
|
|
17
|
+
/** `medium` (4px, default); `large` (8px) for onboarding. */
|
|
18
|
+
size?: "medium" | "large";
|
|
19
|
+
};
|
|
20
|
+
export type ProgressCircleSize = "small" | "medium" | "large";
|
|
21
|
+
export type ProgressCircleProps = {
|
|
22
|
+
value?: number;
|
|
23
|
+
minValue?: number;
|
|
24
|
+
maxValue?: number;
|
|
25
|
+
/** 20px (no value text; give the value in adjacent text or a Tooltip), 48px, 80px. */
|
|
26
|
+
size?: ProgressCircleSize;
|
|
27
|
+
/** A visible label under the ring, or `aria-label` when there is none. */
|
|
28
|
+
label?: React.ReactNode;
|
|
29
|
+
"aria-label"?: string;
|
|
30
|
+
isIndeterminate?: boolean;
|
|
31
|
+
/** A ratio that is a measurement (doluluk, kota), not progress: announced as a meter. */
|
|
32
|
+
isMeasurement?: boolean;
|
|
33
|
+
tone?: ProgressTone;
|
|
34
|
+
valueLabel?: string;
|
|
35
|
+
};
|
|
36
|
+
/** ProgressBar in a circle, for places with no width to spare. */
|
|
37
|
+
export declare function ProgressCircle({ value, minValue, maxValue, size, label, "aria-label": ariaLabel, isIndeterminate, isMeasurement, tone, valueLabel, }: ProgressCircleProps): React.JSX.Element;
|
|
38
|
+
/** ProgressBar with its own `motion` (auto, reduce or none); see ProgressBarBody for the component itself. */
|
|
39
|
+
export declare function ProgressBar({ motion, ...props }: ProgressBarProps & WithMotion): React.JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Label, Meter as AriaMeter, ProgressBar as AriaProgressBar } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { MotionScope } from "../defaults.js";
|
|
7
|
+
import { LABEL } from "../form/styles.js";
|
|
8
|
+
import { useLoop } from "./motion.js";
|
|
9
|
+
const FILL = {
|
|
10
|
+
brand: "bg-ds-background-brand-bold",
|
|
11
|
+
success: "bg-ds-background-success-bold",
|
|
12
|
+
danger: "bg-ds-background-danger-bold",
|
|
13
|
+
};
|
|
14
|
+
const STROKE = {
|
|
15
|
+
brand: "stroke-ds-background-brand-bold",
|
|
16
|
+
success: "stroke-ds-background-success-bold",
|
|
17
|
+
danger: "stroke-ds-background-danger-bold",
|
|
18
|
+
};
|
|
19
|
+
/** The sweeping segment of an indeterminate bar (Web Animations, so no global keyframes; off under reduced motion). */
|
|
20
|
+
function Sweep({ tone }) {
|
|
21
|
+
const ref = React.useRef(null);
|
|
22
|
+
// The segment is 30% of the track, so translate percentages are of the segment: it starts fully off
|
|
23
|
+
// the start edge (-100%) and leaves fully past the end edge (100 / 30 ≈ 333%); mirrored in RTL.
|
|
24
|
+
useLoop(ref, (direction) => direction === "rtl"
|
|
25
|
+
? [{ transform: "translateX(100%)" }, { transform: "translateX(-333%)" }]
|
|
26
|
+
: [{ transform: "translateX(-100%)" }, { transform: "translateX(333%)" }], 1400, true);
|
|
27
|
+
return _jsx("span", { ref: ref, "data-slot": "progress-bar-sweep", className: cn("absolute inset-y-0 start-0 w-[30%] rounded-ds-full", FILL[tone]) });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* How far a known task has gone, or that an unknown-length one is running.
|
|
31
|
+
* Show it only for tasks over ~1s; shorter waits get a Spinner or nothing.
|
|
32
|
+
*/
|
|
33
|
+
function ProgressBarBody({ label, value = 0, minValue = 0, maxValue = 100, valueLabel, isIndeterminate, tone = "brand", size = "medium", }) {
|
|
34
|
+
return (_jsx(AriaProgressBar, { value: value, minValue: minValue, maxValue: maxValue, isIndeterminate: isIndeterminate, valueLabel: typeof valueLabel === "string" ? valueLabel : undefined, "data-slot": "progress-bar", "data-tone": tone, className: "flex min-w-0 flex-col gap-ds-075", children: ({ percentage, valueText }) => (_jsxs(_Fragment, { children: [_jsxs("div", { "data-slot": "progress-bar-head", className: "flex items-baseline justify-between gap-ds-200", children: [_jsx(Label, { "data-slot": "progress-bar-label", className: LABEL, children: label }), !isIndeterminate && (_jsx("span", { "data-slot": "progress-bar-value", className: cn("text-body-small tabular-nums", tone === "danger" ? "text-ds-text-danger" : tone === "success" ? "text-ds-text-success" : "text-ds-text-subtlest"), children: valueLabel ?? valueText }))] }), _jsx("div", { "data-slot": "progress-bar-track", className: cn("relative w-full overflow-hidden rounded-ds-full bg-ds-background-neutral", size === "large" ? "h-2" : "h-1"), children: isIndeterminate ? (_jsx(Sweep, { tone: tone })) : (_jsx("span", { "data-slot": "progress-bar-fill", className: cn("absolute inset-y-0 start-0 rounded-ds-full transition-[width] duration-(--ds-duration-medium) ease-ds-standard motion-reduce:transition-none", FILL[tone]), style: { width: `${percentage ?? 0}%` } })) })] })) }));
|
|
35
|
+
}
|
|
36
|
+
const CIRCLE = {
|
|
37
|
+
small: { box: 20, stroke: 3, text: "" },
|
|
38
|
+
medium: { box: 48, stroke: 4, text: "text-body-small font-medium" },
|
|
39
|
+
large: { box: 80, stroke: 6, text: "text-metric-small" },
|
|
40
|
+
};
|
|
41
|
+
/** ProgressBar in a circle, for places with no width to spare. */
|
|
42
|
+
export function ProgressCircle({ value = 0, minValue = 0, maxValue = 100, size = "medium", label, "aria-label": ariaLabel, isIndeterminate, isMeasurement, tone = "brand", valueLabel, }) {
|
|
43
|
+
const spec = CIRCLE[size];
|
|
44
|
+
const radius = (spec.box - spec.stroke) / 2;
|
|
45
|
+
const circumference = 2 * Math.PI * radius;
|
|
46
|
+
const spinRef = React.useRef(null);
|
|
47
|
+
useLoop(spinRef, [{ transform: "rotate(0deg)" }, { transform: "rotate(360deg)" }], 1000, Boolean(isIndeterminate), "linear");
|
|
48
|
+
const ring = ({ percentage, valueText }) => (_jsxs(_Fragment, { children: [_jsxs("span", { ref: spinRef, className: "relative grid place-items-center", style: { width: spec.box, height: spec.box }, children: [_jsxs("svg", { "aria-hidden": "true", width: spec.box, height: spec.box, viewBox: `0 0 ${spec.box} ${spec.box}`, className: "-rotate-90 rtl:scale-y-[-1]", children: [_jsx("circle", { cx: spec.box / 2, cy: spec.box / 2, r: radius, fill: "none", strokeWidth: spec.stroke, className: "stroke-ds-background-neutral-pressed" }), _jsx("circle", { "data-slot": "progress-circle-arc", cx: spec.box / 2, cy: spec.box / 2, r: radius, fill: "none", strokeWidth: spec.stroke, strokeLinecap: "round", strokeDasharray: circumference, strokeDashoffset: circumference * (1 - (isIndeterminate ? 0.25 : (percentage ?? 0) / 100)),
|
|
49
|
+
// A round cap would still draw a dot at 0%.
|
|
50
|
+
strokeOpacity: !isIndeterminate && (percentage ?? 0) === 0 ? 0 : 1, className: cn(STROKE[tone], "transition-[stroke-dashoffset] duration-(--ds-duration-medium) ease-ds-standard motion-reduce:transition-none") })] }), size !== "small" && !isIndeterminate && (_jsx("span", { "aria-hidden": "true", "data-slot": "progress-circle-value", className: cn("absolute tabular-nums text-ds-text", spec.text), children: valueLabel ?? valueText }))] }), label && _jsx(Label, { "data-slot": "progress-circle-label", className: "text-body-small text-ds-text-subtlest", children: label })] }));
|
|
51
|
+
const common = {
|
|
52
|
+
value,
|
|
53
|
+
minValue,
|
|
54
|
+
maxValue,
|
|
55
|
+
"aria-label": label ? undefined : ariaLabel,
|
|
56
|
+
valueLabel,
|
|
57
|
+
"data-slot": "progress-circle",
|
|
58
|
+
"data-size": size,
|
|
59
|
+
className: "inline-flex flex-col items-center gap-ds-075",
|
|
60
|
+
};
|
|
61
|
+
// A measurement (doluluk, kota) is a meter with the same look; progress is a progressbar.
|
|
62
|
+
return isMeasurement && !isIndeterminate ? (_jsx(AriaMeter, { ...common, children: ring })) : (_jsx(AriaProgressBar, { ...common, isIndeterminate: isIndeterminate, children: ring }));
|
|
63
|
+
}
|
|
64
|
+
/** ProgressBar with its own `motion` (auto, reduce or none); see ProgressBarBody for the component itself. */
|
|
65
|
+
export function ProgressBar({ motion, ...props }) {
|
|
66
|
+
return (_jsx(MotionScope, { motion: motion, children: _jsx(ProgressBarBody, { ...props }) }));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/feedback/progress.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uB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AAoC,EAAE,IAAI,CAAC,IAAI,CAAC,YACtH,UAAU,IAAI,SAAS,GACnB,CACR,IACI,EACN,KAAK,IAAI,KAAC,KAAK,iBAAW,uBAAuB,EAAC,SAAS,EAAC,uCAAuC,YAAE,KAAK,GAAS,IACnH,CACJ,CAAC;IACF,MAAM,MAAM,GAAG;QACb,KAAK;QACL,QAAQ;QACR,QAAQ;QACR,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC3C,UAAU;QACV,WAAW,EAAE,iBAAiB;QAC9B,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,8CAA8C;KAC1D,CAAC;IACF,0FAA0F;IAC1F,OAAO,aAAa,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CACzC,KAAC,SAAS,OAAK,MAAM,YAAG,IAAI,GAAa,CAC1C,CAAC,CAAC,CAAC,CACF,KAAC,eAAe,OAAK,MAAM,EAAE,eAAe,EAAE,eAAe,YAAG,IAAI,GAAmB,CACxF,CAAC;AACJ,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,EAAiC;IAC7E,OAAO,CACL,KAAC,WAAW,IAAC,MAAM,EAAE,MAAM,YACzB,KAAC,eAAe,OAAM,KAA0B,GAAI,GACxC,CACf,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Label, Meter as AriaMeter, ProgressBar as AriaProgressBar } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { MotionScope, type WithMotion } from \"../defaults\";\nimport type { Tone } from \"../tone\";\nimport { LABEL } from \"../form/styles\";\nimport { useLoop } from \"./motion\";\n\nexport type ProgressTone = Extract<Tone, \"brand\" | \"success\" | \"danger\">;\n\nconst FILL: Record<ProgressTone, string> = {\n brand: \"bg-ds-background-brand-bold\",\n success: \"bg-ds-background-success-bold\",\n danger: \"bg-ds-background-danger-bold\",\n};\n\nconst STROKE: Record<ProgressTone, string> = {\n brand: \"stroke-ds-background-brand-bold\",\n success: \"stroke-ds-background-success-bold\",\n danger: \"stroke-ds-background-danger-bold\",\n};\n\nexport type ProgressBarProps = {\n /** What is in progress (\"Importing contacts\"). */\n label: React.ReactNode;\n value?: number;\n minValue?: number;\n maxValue?: number;\n /** Real units where they exist (\"142 / 220\", \"3 / 5 steps\"); defaults to the percentage. */\n valueLabel?: React.ReactNode;\n /** A task of unknown length: a 30% segment sweeps across. */\n isIndeterminate?: boolean;\n /** `success` / `danger` for a finished or failed task; pair it with a word in `valueLabel`. */\n tone?: ProgressTone;\n /** `medium` (4px, default); `large` (8px) for onboarding. */\n size?: \"medium\" | \"large\";\n};\n\n/** The sweeping segment of an indeterminate bar (Web Animations, so no global keyframes; off under reduced motion). */\nfunction Sweep({ tone }: { tone: ProgressTone }) {\n const ref = React.useRef<HTMLSpanElement>(null);\n // The segment is 30% of the track, so translate percentages are of the segment: it starts fully off\n // the start edge (-100%) and leaves fully past the end edge (100 / 30 ≈ 333%); mirrored in RTL.\n useLoop(\n ref,\n (direction) =>\n direction === \"rtl\"\n ? [{ transform: \"translateX(100%)\" }, { transform: \"translateX(-333%)\" }]\n : [{ transform: \"translateX(-100%)\" }, { transform: \"translateX(333%)\" }],\n 1400,\n true,\n );\n return <span ref={ref} data-slot=\"progress-bar-sweep\" className={cn(\"absolute inset-y-0 start-0 w-[30%] rounded-ds-full\", FILL[tone])} />;\n}\n\n/**\n * How far a known task has gone, or that an unknown-length one is running.\n * Show it only for tasks over ~1s; shorter waits get a Spinner or nothing.\n */\nfunction ProgressBarBody({\n label, value = 0, minValue = 0, maxValue = 100, valueLabel, isIndeterminate, tone = \"brand\", size = \"medium\",\n}: ProgressBarProps) {\n return (\n <AriaProgressBar\n value={value}\n minValue={minValue}\n maxValue={maxValue}\n isIndeterminate={isIndeterminate}\n valueLabel={typeof valueLabel === \"string\" ? valueLabel : undefined}\n data-slot=\"progress-bar\"\n data-tone={tone}\n className=\"flex min-w-0 flex-col gap-ds-075\"\n >\n {({ percentage, valueText }) => (\n <>\n <div data-slot=\"progress-bar-head\" className=\"flex items-baseline justify-between gap-ds-200\">\n <Label data-slot=\"progress-bar-label\" className={LABEL}>{label}</Label>\n {!isIndeterminate && (\n <span\n data-slot=\"progress-bar-value\"\n className={cn(\n \"text-body-small tabular-nums\",\n tone === \"danger\" ? \"text-ds-text-danger\" : tone === \"success\" ? \"text-ds-text-success\" : \"text-ds-text-subtlest\",\n )}\n >\n {valueLabel ?? valueText}\n </span>\n )}\n </div>\n <div\n data-slot=\"progress-bar-track\"\n className={cn(\"relative w-full overflow-hidden rounded-ds-full bg-ds-background-neutral\", size === \"large\" ? \"h-2\" : \"h-1\")}\n >\n {isIndeterminate ? (\n <Sweep tone={tone} />\n ) : (\n <span\n data-slot=\"progress-bar-fill\"\n className={cn(\"absolute inset-y-0 start-0 rounded-ds-full transition-[width] duration-(--ds-duration-medium) ease-ds-standard motion-reduce:transition-none\", FILL[tone])}\n style={{ width: `${percentage ?? 0}%` }}\n />\n )}\n </div>\n </>\n )}\n </AriaProgressBar>\n );\n}\n\nexport type ProgressCircleSize = \"small\" | \"medium\" | \"large\";\n\nconst CIRCLE: Record<ProgressCircleSize, { box: number; stroke: number; text: string }> = {\n small: { box: 20, stroke: 3, text: \"\" },\n medium: { box: 48, stroke: 4, text: \"text-body-small font-medium\" },\n large: { box: 80, stroke: 6, text: \"text-metric-small\" },\n};\n\nexport type ProgressCircleProps = {\n value?: number;\n minValue?: number;\n maxValue?: number;\n /** 20px (no value text; give the value in adjacent text or a Tooltip), 48px, 80px. */\n size?: ProgressCircleSize;\n /** A visible label under the ring, or `aria-label` when there is none. */\n label?: React.ReactNode;\n \"aria-label\"?: string;\n isIndeterminate?: boolean;\n /** A ratio that is a measurement (doluluk, kota), not progress: announced as a meter. */\n isMeasurement?: boolean;\n tone?: ProgressTone;\n valueLabel?: string;\n};\n\n/** ProgressBar in a circle, for places with no width to spare. */\nexport function ProgressCircle({\n value = 0, minValue = 0, maxValue = 100, size = \"medium\", label, \"aria-label\": ariaLabel, isIndeterminate, isMeasurement, tone = \"brand\", valueLabel,\n}: ProgressCircleProps) {\n const spec = CIRCLE[size];\n const radius = (spec.box - spec.stroke) / 2;\n const circumference = 2 * Math.PI * radius;\n const spinRef = React.useRef<HTMLSpanElement>(null);\n useLoop(spinRef, [{ transform: \"rotate(0deg)\" }, { transform: \"rotate(360deg)\" }], 1000, Boolean(isIndeterminate), \"linear\");\n const ring = ({ percentage, valueText }: { percentage?: number; valueText?: string }) => (\n <>\n <span ref={spinRef} className=\"relative grid place-items-center\" style={{ width: spec.box, height: spec.box }}>\n <svg aria-hidden=\"true\" width={spec.box} height={spec.box} viewBox={`0 0 ${spec.box} ${spec.box}`} className=\"-rotate-90 rtl:scale-y-[-1]\">\n <circle cx={spec.box / 2} cy={spec.box / 2} r={radius} fill=\"none\" strokeWidth={spec.stroke} className=\"stroke-ds-background-neutral-pressed\" />\n <circle\n data-slot=\"progress-circle-arc\"\n cx={spec.box / 2}\n cy={spec.box / 2}\n r={radius}\n fill=\"none\"\n strokeWidth={spec.stroke}\n strokeLinecap=\"round\"\n strokeDasharray={circumference}\n strokeDashoffset={circumference * (1 - (isIndeterminate ? 0.25 : (percentage ?? 0) / 100))}\n // A round cap would still draw a dot at 0%.\n strokeOpacity={!isIndeterminate && (percentage ?? 0) === 0 ? 0 : 1}\n className={cn(STROKE[tone], \"transition-[stroke-dashoffset] duration-(--ds-duration-medium) ease-ds-standard motion-reduce:transition-none\")}\n />\n </svg>\n {/* The value sits in the ring from 48px up; below it moves to adjacent text. */}\n {size !== \"small\" && !isIndeterminate && (\n <span aria-hidden=\"true\" data-slot=\"progress-circle-value\" className={cn(\"absolute tabular-nums text-ds-text\", spec.text)}>\n {valueLabel ?? valueText}\n </span>\n )}\n </span>\n {label && <Label data-slot=\"progress-circle-label\" className=\"text-body-small text-ds-text-subtlest\">{label}</Label>}\n </>\n );\n const common = {\n value,\n minValue,\n maxValue,\n \"aria-label\": label ? undefined : ariaLabel,\n valueLabel,\n \"data-slot\": \"progress-circle\",\n \"data-size\": size,\n className: \"inline-flex flex-col items-center gap-ds-075\",\n };\n // A measurement (doluluk, kota) is a meter with the same look; progress is a progressbar.\n return isMeasurement && !isIndeterminate ? (\n <AriaMeter {...common}>{ring}</AriaMeter>\n ) : (\n <AriaProgressBar {...common} isIndeterminate={isIndeterminate}>{ring}</AriaProgressBar>\n );\n}\n\n/** ProgressBar with its own `motion` (auto, reduce or none); see ProgressBarBody for the component itself. */\nexport function ProgressBar({ motion, ...props }: ProgressBarProps & WithMotion) {\n return (\n <MotionScope motion={motion}>\n <ProgressBarBody {...(props as ProgressBarProps)} />\n </MotionScope>\n );\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type WithMotion } from "../defaults.js";
|
|
3
|
+
declare const RADIUS: {
|
|
4
|
+
readonly none: "rounded-none";
|
|
5
|
+
readonly small: "rounded-ds-small";
|
|
6
|
+
readonly medium: "rounded-ds-medium";
|
|
7
|
+
readonly large: "rounded-ds-large";
|
|
8
|
+
readonly full: "rounded-ds-full";
|
|
9
|
+
};
|
|
10
|
+
type Common = {
|
|
11
|
+
/** Shows the children instead of the shape once the data is there. */
|
|
12
|
+
isLoaded?: boolean;
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
/** Milliseconds before the shape appears (default 300); the space is held meanwhile. */
|
|
15
|
+
delay?: number;
|
|
16
|
+
};
|
|
17
|
+
export type SkeletonProps = Common & {
|
|
18
|
+
/**
|
|
19
|
+
* `rectangle` (default): a block of `width` × `height`; `text`: `lines` of text, the last one shorter;
|
|
20
|
+
* `circle`: an avatar of `size` px.
|
|
21
|
+
*/
|
|
22
|
+
variant?: "rectangle" | "text" | "circle";
|
|
23
|
+
/** `text`: the number of 12px lines (default 2). */
|
|
24
|
+
lines?: number;
|
|
25
|
+
/** `circle`: the diameter in px (default 32, a list avatar). */
|
|
26
|
+
size?: number;
|
|
27
|
+
/** CSS width ("60%", 240); default full width. */
|
|
28
|
+
width?: number | string;
|
|
29
|
+
/** CSS height; default 12px (a text line). */
|
|
30
|
+
height?: number | string;
|
|
31
|
+
/** The radius of what it replaces: `medium` for a button, `large` for a card photo. */
|
|
32
|
+
radius?: keyof typeof RADIUS;
|
|
33
|
+
/** Aspect ratio for photos ("16/9"). */
|
|
34
|
+
aspectRatio?: string;
|
|
35
|
+
};
|
|
36
|
+
export type SkeletonGroupProps = {
|
|
37
|
+
/** What is loading ("Loading orders"); the region's name while busy. */
|
|
38
|
+
label: string;
|
|
39
|
+
/** The region's name once loaded ("Orders"); none by default. */
|
|
40
|
+
loadedLabel?: string;
|
|
41
|
+
isLoading: boolean;
|
|
42
|
+
children: React.ReactNode;
|
|
43
|
+
};
|
|
44
|
+
/** The loading region: `aria-busy` with a label while loading, so screen readers wait for the real content. */
|
|
45
|
+
export declare function SkeletonGroup({ label, loadedLabel, isLoading, children }: SkeletonGroupProps): React.JSX.Element;
|
|
46
|
+
/** Skeleton with its own `motion` (auto, reduce or none); see SkeletonBody for the component itself. */
|
|
47
|
+
export declare function Skeleton({ motion, ...props }: SkeletonProps & WithMotion): React.JSX.Element;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../utils.js";
|
|
5
|
+
import { MotionScope } from "../defaults.js";
|
|
6
|
+
import { useLoop } from "./motion.js";
|
|
7
|
+
/** The design's rule: fast responses should not flash, so shapes appear after 300ms. */
|
|
8
|
+
function useShowAfter(delay) {
|
|
9
|
+
const [visible, setVisible] = React.useState(delay <= 0);
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
if (delay <= 0) {
|
|
12
|
+
setVisible(true);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const timer = window.setTimeout(() => setVisible(true), delay);
|
|
16
|
+
return () => window.clearTimeout(timer);
|
|
17
|
+
}, [delay]);
|
|
18
|
+
return visible;
|
|
19
|
+
}
|
|
20
|
+
const RADIUS = {
|
|
21
|
+
none: "rounded-none",
|
|
22
|
+
small: "rounded-ds-small",
|
|
23
|
+
medium: "rounded-ds-medium",
|
|
24
|
+
large: "rounded-ds-large",
|
|
25
|
+
full: "rounded-ds-full",
|
|
26
|
+
};
|
|
27
|
+
function Shape({ className, style, delay = 300 }) {
|
|
28
|
+
const ref = React.useRef(null);
|
|
29
|
+
const visible = useShowAfter(delay);
|
|
30
|
+
// A soft 1.6s shimmer; static under reduced motion.
|
|
31
|
+
useLoop(ref, [{ opacity: 1 }, { opacity: 0.55 }, { opacity: 1 }], 1600, visible);
|
|
32
|
+
return (_jsx("span", { ref: ref, "aria-hidden": "true", "data-slot": "skeleton", "data-visible": visible || undefined, className: cn("block bg-ds-background-neutral", visible ? "opacity-100" : "opacity-0", className), style: style }));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Holds the shape of content while it loads, so the layout does not jump
|
|
36
|
+
* when data arrives. Mirror the real layout; mark the loading region with
|
|
37
|
+
* `aria-busy` and a label (SkeletonGroup does both).
|
|
38
|
+
*/
|
|
39
|
+
function SkeletonBody({ isLoaded, children, delay, variant = "rectangle", lines = 2, size = 32, width, height = 12, radius = "small", aspectRatio }) {
|
|
40
|
+
if (isLoaded)
|
|
41
|
+
return _jsx(_Fragment, { children: children });
|
|
42
|
+
if (variant === "text")
|
|
43
|
+
return _jsx(TextLines, { delay: delay, lines: lines });
|
|
44
|
+
if (variant === "circle")
|
|
45
|
+
return _jsx(Shape, { delay: delay, className: "shrink-0 rounded-ds-full", style: { width: size, height: size } });
|
|
46
|
+
return _jsx(Shape, { delay: delay, className: RADIUS[radius], style: { width: width ?? "100%", height: aspectRatio ? undefined : height, aspectRatio } });
|
|
47
|
+
}
|
|
48
|
+
/** Lines of text: 12px each, the last one shorter, as text is. */
|
|
49
|
+
function TextLines({ delay, lines }) {
|
|
50
|
+
return (_jsx("span", { "data-slot": "skeleton-text", className: "flex flex-col gap-ds-075", children: Array.from({ length: lines }, (_, index) => (_jsx(Shape, { delay: delay, className: "h-3 rounded-ds-small", style: { width: index === lines - 1 && lines > 1 ? "60%" : "100%" } }, index))) }));
|
|
51
|
+
}
|
|
52
|
+
/** The loading region: `aria-busy` with a label while loading, so screen readers wait for the real content. */
|
|
53
|
+
export function SkeletonGroup({ label, loadedLabel, isLoading, children }) {
|
|
54
|
+
const name = isLoading ? label : loadedLabel;
|
|
55
|
+
return (_jsx("div", { role: name ? "group" : undefined, "aria-label": name, "aria-busy": isLoading || undefined, "data-slot": "skeleton-group", children: children }));
|
|
56
|
+
}
|
|
57
|
+
/** Skeleton with its own `motion` (auto, reduce or none); see SkeletonBody for the component itself. */
|
|
58
|
+
export function Skeleton({ motion, ...props }) {
|
|
59
|
+
return (_jsx(MotionScope, { motion: motion, children: _jsx(SkeletonBody, { ...props }) }));
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton.js","sourceRoot":"","sources":["../../src/feedback/skeleton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAmB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,wFAAwF;AACxF,SAAS,YAAY,CAAC,KAAa;IACjC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IACzD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf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C1I,CAAC,GACG,CACR,CAAC;AACJ,CAAC;AAWD,+GAA+G;AAC/G,MAAM,UAAU,aAAa,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAsB;IAC3F,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC;IAC7C,OAAO,CACL,cAAK,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,gBAAc,IAAI,eAAa,SAAS,IAAI,SAAS,eAAY,gBAAgB,YACnH,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,EAA8B;IACvE,OAAO,CACL,KAAC,WAAW,IAAC,MAAM,EAAE,MAAM,YACzB,KAAC,YAAY,OAAM,KAAuB,GAAI,GAClC,CACf,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"../utils\";\nimport { MotionScope, type WithMotion } from \"../defaults\";\nimport { useLoop } from \"./motion\";\n\n/** The design's rule: fast responses should not flash, so shapes appear after 300ms. */\nfunction useShowAfter(delay: number) {\n const [visible, setVisible] = React.useState(delay <= 0);\n React.useEffect(() => {\n if (delay <= 0) {\n setVisible(true);\n return;\n }\n const timer = window.setTimeout(() => setVisible(true), delay);\n return () => window.clearTimeout(timer);\n }, [delay]);\n return visible;\n}\n\nconst RADIUS = {\n none: \"rounded-none\",\n small: \"rounded-ds-small\",\n medium: \"rounded-ds-medium\",\n large: \"rounded-ds-large\",\n full: \"rounded-ds-full\",\n} as const;\n\ntype Common = {\n /** Shows the children instead of the shape once the data is there. */\n isLoaded?: boolean;\n children?: React.ReactNode;\n /** Milliseconds before the shape appears (default 300); the space is held meanwhile. */\n delay?: number;\n};\n\nexport type SkeletonProps = Common & {\n /**\n * `rectangle` (default): a block of `width` × `height`; `text`: `lines` of text, the last one shorter;\n * `circle`: an avatar of `size` px.\n */\n variant?: \"rectangle\" | \"text\" | \"circle\";\n /** `text`: the number of 12px lines (default 2). */\n lines?: number;\n /** `circle`: the diameter in px (default 32, a list avatar). */\n size?: number;\n /** CSS width (\"60%\", 240); default full width. */\n width?: number | string;\n /** CSS height; default 12px (a text line). */\n height?: number | string;\n /** The radius of what it replaces: `medium` for a button, `large` for a card photo. */\n radius?: keyof typeof RADIUS;\n /** Aspect ratio for photos (\"16/9\"). */\n aspectRatio?: string;\n};\n\nfunction Shape({ className, style, delay = 300 }: { className: string; style?: React.CSSProperties; delay?: number }) {\n const ref = React.useRef<HTMLSpanElement>(null);\n const visible = useShowAfter(delay);\n // A soft 1.6s shimmer; static under reduced motion.\n useLoop(ref, [{ opacity: 1 }, { opacity: 0.55 }, { opacity: 1 }], 1600, visible);\n return (\n <span\n ref={ref}\n aria-hidden=\"true\"\n data-slot=\"skeleton\"\n data-visible={visible || undefined}\n className={cn(\"block bg-ds-background-neutral\", visible ? \"opacity-100\" : \"opacity-0\", className)}\n style={style}\n />\n );\n}\n\n/**\n * Holds the shape of content while it loads, so the layout does not jump\n * when data arrives. Mirror the real layout; mark the loading region with\n * `aria-busy` and a label (SkeletonGroup does both).\n */\nfunction SkeletonBody({ isLoaded, children, delay, variant = \"rectangle\", lines = 2, size = 32, width, height = 12, radius = \"small\", aspectRatio }: SkeletonProps) {\n if (isLoaded) return <>{children}</>;\n if (variant === \"text\") return <TextLines delay={delay} lines={lines} />;\n if (variant === \"circle\") return <Shape delay={delay} className=\"shrink-0 rounded-ds-full\" style={{ width: size, height: size }} />;\n return <Shape delay={delay} className={RADIUS[radius]} style={{ width: width ?? \"100%\", height: aspectRatio ? undefined : height, aspectRatio }} />;\n}\n\n/** Lines of text: 12px each, the last one shorter, as text is. */\nfunction TextLines({ delay, lines }: { delay?: number; lines: number }) {\n return (\n <span data-slot=\"skeleton-text\" className=\"flex flex-col gap-ds-075\">\n {Array.from({ length: lines }, (_, index) => (\n <Shape key={index} delay={delay} className=\"h-3 rounded-ds-small\" style={{ width: index === lines - 1 && lines > 1 ? \"60%\" : \"100%\" }} />\n ))}\n </span>\n );\n}\n\nexport type SkeletonGroupProps = {\n /** What is loading (\"Loading orders\"); the region's name while busy. */\n label: string;\n /** The region's name once loaded (\"Orders\"); none by default. */\n loadedLabel?: string;\n isLoading: boolean;\n children: React.ReactNode;\n};\n\n/** The loading region: `aria-busy` with a label while loading, so screen readers wait for the real content. */\nexport function SkeletonGroup({ label, loadedLabel, isLoading, children }: SkeletonGroupProps) {\n const name = isLoading ? label : loadedLabel;\n return (\n <div role={name ? \"group\" : undefined} aria-label={name} aria-busy={isLoading || undefined} data-slot=\"skeleton-group\">\n {children}\n </div>\n );\n}\n\n/** Skeleton with its own `motion` (auto, reduce or none); see SkeletonBody for the component itself. */\nexport function Skeleton({ motion, ...props }: SkeletonProps & WithMotion) {\n return (\n <MotionScope motion={motion}>\n <SkeletonBody {...(props as SkeletonProps)} />\n </MotionScope>\n );\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type SpinnerSize = "small" | "medium" | "large";
|
|
3
|
+
export type SpinnerProps = {
|
|
4
|
+
size?: SpinnerSize;
|
|
5
|
+
/**
|
|
6
|
+
* What is happening ("Checking availability"). Omit when visible text
|
|
7
|
+
* next to it says it, and pass `isDecorative`; otherwise "Loading…".
|
|
8
|
+
*/
|
|
9
|
+
"aria-label"?: string;
|
|
10
|
+
/** Visible text already says it (a pending button): hidden from assistive tech. */
|
|
11
|
+
isDecorative?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* "Working" for waits under a few seconds where the result appears in place:
|
|
15
|
+
* a 2px ring with one open quarter, 700ms per turn. Under reduced motion it
|
|
16
|
+
* stops and the label carries the state. Over ~1s with a known length use
|
|
17
|
+
* ProgressBar; loading a layout, Skeleton.
|
|
18
|
+
*/
|
|
19
|
+
export declare function Spinner({ size, "aria-label": ariaLabel, isDecorative }: SpinnerProps): React.JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useLocale } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { loadingLabel } from "../i18n.js";
|
|
7
|
+
const SIZE = {
|
|
8
|
+
// 12px inline, 14px in buttons (takes the label colour), 24px for regions (brand).
|
|
9
|
+
small: "size-3 text-ds-icon-subtle",
|
|
10
|
+
medium: "size-3.5 text-current",
|
|
11
|
+
large: "size-6 text-ds-icon-brand",
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* "Working" for waits under a few seconds where the result appears in place:
|
|
15
|
+
* a 2px ring with one open quarter, 700ms per turn. Under reduced motion it
|
|
16
|
+
* stops and the label carries the state. Over ~1s with a known length use
|
|
17
|
+
* ProgressBar; loading a layout, Skeleton.
|
|
18
|
+
*/
|
|
19
|
+
export function Spinner({ size = "medium", "aria-label": ariaLabel, isDecorative }) {
|
|
20
|
+
const { locale } = useLocale();
|
|
21
|
+
const ring = (_jsx("span", { "aria-hidden": "true", "data-slot": "spinner-ring", className: cn("inline-block shrink-0 rounded-ds-full border-2 border-current border-e-transparent", "animate-spin [animation-duration:700ms] motion-reduce:animate-none", SIZE[size]) }));
|
|
22
|
+
if (isDecorative)
|
|
23
|
+
return _jsx("span", { "data-slot": "spinner", className: "inline-flex", children: ring });
|
|
24
|
+
const name = ariaLabel ?? loadingLabel(locale);
|
|
25
|
+
return (
|
|
26
|
+
// The words are the content, not an aria-label too, so screen readers say them once.
|
|
27
|
+
_jsxs("span", { role: "status", "data-slot": "spinner", className: "inline-flex", children: [ring, _jsx("span", { className: "sr-only", children: name })] }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../src/feedback/spinner.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIvC,MAAM,IAAI,GAAgC;IACxC,mFAAmF;IACnF,KAAK,EAAE,4BAA4B;IACnC,MAAM,EAAE,uBAAuB;IAC/B,KAAK,EAAE,2BAA2B;CACnC,CAAC;AAaF;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,IAAI,GAAG,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAgB;IAC9F,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,CACX,8BACc,MAAM,eACR,cAAc,EACxB,SAAS,EAAE,EAAE,CACX,oFAAoF,EACpF,oEAAoE,EACpE,IAAI,CAAC,IAAI,CAAC,CACX,GACD,CACH,CAAC;IACF,IAAI,YAAY;QAAE,OAAO,4BAAgB,SAAS,EAAC,SAAS,EAAC,aAAa,YAAE,IAAI,GAAQ,CAAC;IACzF,MAAM,IAAI,GAAG,SAAS,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO;IACL,qFAAqF;IACrF,gBAAM,IAAI,EAAC,QAAQ,eAAW,SAAS,EAAC,SAAS,EAAC,aAAa,aAC5D,IAAI,EACL,eAAM,SAAS,EAAC,SAAS,YAAE,IAAI,GAAQ,IAClC,CACR,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { loadingLabel } from \"../i18n\";\n\nexport type SpinnerSize = \"small\" | \"medium\" | \"large\";\n\nconst SIZE: Record<SpinnerSize, string> = {\n // 12px inline, 14px in buttons (takes the label colour), 24px for regions (brand).\n small: \"size-3 text-ds-icon-subtle\",\n medium: \"size-3.5 text-current\",\n large: \"size-6 text-ds-icon-brand\",\n};\n\nexport type SpinnerProps = {\n size?: SpinnerSize;\n /**\n * What is happening (\"Checking availability\"). Omit when visible text\n * next to it says it, and pass `isDecorative`; otherwise \"Loading…\".\n */\n \"aria-label\"?: string;\n /** Visible text already says it (a pending button): hidden from assistive tech. */\n isDecorative?: boolean;\n};\n\n/**\n * \"Working\" for waits under a few seconds where the result appears in place:\n * a 2px ring with one open quarter, 700ms per turn. Under reduced motion it\n * stops and the label carries the state. Over ~1s with a known length use\n * ProgressBar; loading a layout, Skeleton.\n */\nexport function Spinner({ size = \"medium\", \"aria-label\": ariaLabel, isDecorative }: SpinnerProps) {\n const { locale } = useLocale();\n const ring = (\n <span\n aria-hidden=\"true\"\n data-slot=\"spinner-ring\"\n className={cn(\n \"inline-block shrink-0 rounded-ds-full border-2 border-current border-e-transparent\",\n \"animate-spin [animation-duration:700ms] motion-reduce:animate-none\",\n SIZE[size],\n )}\n />\n );\n if (isDecorative) return <span data-slot=\"spinner\" className=\"inline-flex\">{ring}</span>;\n const name = ariaLabel ?? loadingLabel(locale);\n return (\n // The words are the content, not an aria-label too, so screen readers say them once.\n <span role=\"status\" data-slot=\"spinner\" className=\"inline-flex\">\n {ring}\n <span className=\"sr-only\">{name}</span>\n </span>\n );\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type StatusDotTone = "neutral" | "information" | "success" | "warning" | "danger";
|
|
3
|
+
type Base = {
|
|
4
|
+
tone?: StatusDotTone;
|
|
5
|
+
/** A 3px halo for a state that is active right now (connected, syncing). */
|
|
6
|
+
isLive?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type StatusDotProps = Base & ({
|
|
9
|
+
/** The word: the colour never carries the state alone. */
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
"aria-label"?: never;
|
|
12
|
+
} | {
|
|
13
|
+
children?: never;
|
|
14
|
+
/** Only where a visible word is impossible (a dense table cell with its own column header). */
|
|
15
|
+
"aria-label": string;
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* A live system or connection state as an 8px dot and a word: integration
|
|
19
|
+
* online, GPS signal, sync. For a record's status (order, invoice) use
|
|
20
|
+
* Lozenge.
|
|
21
|
+
*/
|
|
22
|
+
export declare function StatusDot({ tone, isLive, children, "aria-label": ariaLabel }: StatusDotProps): React.JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
const DOT = {
|
|
5
|
+
neutral: "bg-ds-icon-subtle",
|
|
6
|
+
information: "bg-ds-icon-information",
|
|
7
|
+
success: "bg-ds-icon-success",
|
|
8
|
+
warning: "bg-ds-icon-warning",
|
|
9
|
+
danger: "bg-ds-icon-danger",
|
|
10
|
+
};
|
|
11
|
+
// The halo sits in the tone's status background.
|
|
12
|
+
const HALO = {
|
|
13
|
+
neutral: "ring-ds-background-neutral",
|
|
14
|
+
information: "ring-ds-background-information",
|
|
15
|
+
success: "ring-ds-background-success",
|
|
16
|
+
warning: "ring-ds-background-warning",
|
|
17
|
+
danger: "ring-ds-background-danger",
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A live system or connection state as an 8px dot and a word: integration
|
|
21
|
+
* online, GPS signal, sync. For a record's status (order, invoice) use
|
|
22
|
+
* Lozenge.
|
|
23
|
+
*/
|
|
24
|
+
export function StatusDot({ tone = "neutral", isLive, children, "aria-label": ariaLabel }) {
|
|
25
|
+
// null, false and "" are no word either.
|
|
26
|
+
const hasWord = children != null && children !== false && children !== "";
|
|
27
|
+
const dot = (_jsx("span", { "data-slot": "status-dot-mark", "aria-hidden": true, className: cn("size-ds-100 shrink-0 rounded-ds-full", DOT[tone], isLive && cn("ring-3", HALO[tone])) }));
|
|
28
|
+
if (!hasWord) {
|
|
29
|
+
return (
|
|
30
|
+
// Named image with a label; without one it only decorates, never an unnamed image.
|
|
31
|
+
_jsx("span", { role: ariaLabel ? "img" : undefined, "aria-label": ariaLabel, "aria-hidden": ariaLabel ? undefined : true, "data-slot": "status-dot", "data-tone": tone, "data-live": isLive || undefined, className: "inline-flex items-center", children: dot }));
|
|
32
|
+
}
|
|
33
|
+
return (
|
|
34
|
+
// The halo is a shadow and takes no space, so a live dot gets the wider gap to keep the word clear of it.
|
|
35
|
+
_jsxs("span", { "data-slot": "status-dot", "data-tone": tone, "data-live": isLive || undefined, className: cn("inline-flex items-center text-body text-ds-text", isLive ? "gap-ds-100" : "gap-ds-075"), children: [dot, _jsx("span", { "data-slot": "status-dot-label", children: children })] }));
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=status-dot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-dot.js","sourceRoot":"","sources":["../../src/feedback/status-dot.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAI9B,MAAM,GAAG,GAAkC;IACzC,OAAO,EAAE,mBAAmB;IAC5B,WAAW,EAAE,wBAAwB;IACrC,OAAO,EAAE,oBAAoB;IAC7B,OAAO,EAAE,oBAAoB;IAC7B,MAAM,EAAE,mBAAmB;CAC5B,CAAC;AACF,iDAAiD;AACjD,MAAM,IAAI,GAAkC;IAC1C,OAAO,EAAE,4BAA4B;IACrC,WAAW,EAAE,gCAAgC;IAC7C,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,4BAA4B;IACrC,MAAM,EAAE,2BAA2B;CACpC,CAAC;AAsBF;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAkB;IACvG,yCAAyC;IACzC,MAAM,OAAO,GAAG,QAAQ,IAAI,IAAI,IAAI,QAAQ,KAAK,KAAK,IAAI,QAAQ,KAAK,EAAE,CAAC;IAC1E,MAAM,GAAG,GAAG,CACV,4BACY,iBAAiB,uBAE3B,SAAS,EAAE,EAAE,CAAC,sCAAsC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,IAAI,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GACpG,CACH,CAAC;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;QACL,mFAAmF;QACnF,eAAM,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,gBAAc,SAAS,iBAAe,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,eAAY,YAAY,eAAY,IAAI,eAAa,MAAM,IAAI,SAAS,EAAE,SAAS,EAAC,0BAA0B,YACtN,GAAG,GACC,CACR,CAAC;IACJ,CAAC;IACD,OAAO;IACL,0GAA0G;IAC1G,6BAAgB,YAAY,eAAY,IAAI,eAAa,MAAM,IAAI,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,iDAAiD,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,aACjL,GAAG,EACJ,4BAAgB,kBAAkB,YAAE,QAAQ,GAAQ,IAC/C,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport { cn } from \"../utils\";\n\nexport type StatusDotTone = \"neutral\" | \"information\" | \"success\" | \"warning\" | \"danger\";\n\nconst DOT: Record<StatusDotTone, string> = {\n neutral: \"bg-ds-icon-subtle\",\n information: \"bg-ds-icon-information\",\n success: \"bg-ds-icon-success\",\n warning: \"bg-ds-icon-warning\",\n danger: \"bg-ds-icon-danger\",\n};\n// The halo sits in the tone's status background.\nconst HALO: Record<StatusDotTone, string> = {\n neutral: \"ring-ds-background-neutral\",\n information: \"ring-ds-background-information\",\n success: \"ring-ds-background-success\",\n warning: \"ring-ds-background-warning\",\n danger: \"ring-ds-background-danger\",\n};\n\ntype Base = {\n tone?: StatusDotTone;\n /** A 3px halo for a state that is active right now (connected, syncing). */\n isLive?: boolean;\n};\n\nexport type StatusDotProps = Base &\n (\n | {\n /** The word: the colour never carries the state alone. */\n children: React.ReactNode;\n \"aria-label\"?: never;\n }\n | {\n children?: never;\n /** Only where a visible word is impossible (a dense table cell with its own column header). */\n \"aria-label\": string;\n }\n );\n\n/**\n * A live system or connection state as an 8px dot and a word: integration\n * online, GPS signal, sync. For a record's status (order, invoice) use\n * Lozenge.\n */\nexport function StatusDot({ tone = \"neutral\", isLive, children, \"aria-label\": ariaLabel }: StatusDotProps) {\n // null, false and \"\" are no word either.\n const hasWord = children != null && children !== false && children !== \"\";\n const dot = (\n <span\n data-slot=\"status-dot-mark\"\n aria-hidden\n className={cn(\"size-ds-100 shrink-0 rounded-ds-full\", DOT[tone], isLive && cn(\"ring-3\", HALO[tone]))}\n />\n );\n if (!hasWord) {\n return (\n // Named image with a label; without one it only decorates, never an unnamed image.\n <span role={ariaLabel ? \"img\" : undefined} aria-label={ariaLabel} aria-hidden={ariaLabel ? undefined : true} data-slot=\"status-dot\" data-tone={tone} data-live={isLive || undefined} className=\"inline-flex items-center\">\n {dot}\n </span>\n );\n }\n return (\n // The halo is a shadow and takes no space, so a live dot gets the wider gap to keep the word clear of it.\n <span data-slot=\"status-dot\" data-tone={tone} data-live={isLive || undefined} className={cn(\"inline-flex items-center text-body text-ds-text\", isLive ? \"gap-ds-100\" : \"gap-ds-075\")}>\n {dot}\n <span data-slot=\"status-dot-label\">{children}</span>\n </span>\n );\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface Country {
|
|
2
|
+
/** ISO 3166-1 alpha-2 code, stored as the field value. */
|
|
3
|
+
code: string;
|
|
4
|
+
/** English display name. */
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const COUNTRIES: readonly Country[];
|
|
8
|
+
/** Look up a country by its ISO alpha-2 code (case-insensitive). */
|
|
9
|
+
export declare function countryByCode(code: string | null | undefined): Country | undefined;
|
|
10
|
+
/** Display name for a code, falling back to the raw value if unknown. */
|
|
11
|
+
export declare function countryName(code: string | null | undefined): string;
|
|
12
|
+
/** Look up a country by its English name (case-insensitive). */
|
|
13
|
+
export declare function countryByName(name: string | null | undefined): Country | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* ISO 3166-1 alpha-2 → international dialling code, without the leading plus.
|
|
16
|
+
*
|
|
17
|
+
* Kept beside `COUNTRIES` and keyed by the same codes so a phone-country picker
|
|
18
|
+
* can offer the whole list rather than a curated handful — and beside rather
|
|
19
|
+
* than inside, because `Country` is the shape address dropdowns bind to. A
|
|
20
|
+
* country is not a phone number, and merging the two would put a dialling code
|
|
21
|
+
* in every form that only ever wanted a name.
|
|
22
|
+
*
|
|
23
|
+
* This is the dialling code only. How a national number is *grouped*, and how
|
|
24
|
+
* long it may be, is separate data that differs per country; an app that knows
|
|
25
|
+
* those shapes for the markets it serves keeps them, and everything else falls
|
|
26
|
+
* back to digits in threes. Offering a country is not the same as claiming to
|
|
27
|
+
* validate its numbers.
|
|
28
|
+
*
|
|
29
|
+
* Where countries share a code — the NANP on +1, Kazakhstan and Russia on +7 —
|
|
30
|
+
* the value is simply repeated. This map answers "what do I dial for this
|
|
31
|
+
* country", which is the question a picker asks. It does not answer the
|
|
32
|
+
* reverse, and inverting it would silently lose entries.
|
|
33
|
+
*/
|
|
34
|
+
export declare const DIAL_CODES: Readonly<Record<string, string>>;
|