@telefonica/mistica 16.60.0 → 16.61.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/css/mistica.css +1 -1
- package/dist/accordion.css-mistica.js +6 -6
- package/dist/align.css-mistica.js +1 -1
- package/dist/autocomplete.css-mistica.js +1 -1
- package/dist/avatar.css-mistica.js +1 -1
- package/dist/badge.css-mistica.js +1 -1
- package/dist/box.css-mistica.js +13 -13
- package/dist/boxed.css-mistica.js +24 -24
- package/dist/button-fixed-footer-layout.d.ts +2 -1
- package/dist/button-fixed-footer-layout.js +4 -3
- package/dist/button-group.css-mistica.js +1 -1
- package/dist/button-layout.css-mistica.js +14 -14
- package/dist/button.css-mistica.js +30 -30
- package/dist/callout.css-mistica.js +11 -11
- package/dist/card-internal.css-mistica.js +15 -15
- package/dist/carousel.css-mistica.js +8 -8
- package/dist/checkbox.css-mistica.js +11 -11
- package/dist/chip.css-mistica.js +15 -15
- package/dist/circle.css-mistica.js +1 -1
- package/dist/community/advanced-data-card.css-mistica.js +6 -6
- package/dist/community/blocks.css-mistica.js +1 -1
- package/dist/community/example-component.css-mistica.js +1 -1
- package/dist/counter.css-mistica.js +1 -1
- package/dist/cover-hero.css-mistica.js +2 -2
- package/dist/credit-card-number-field.css-mistica.js +3 -3
- package/dist/date-field.css-mistica.js +1 -1
- package/dist/date-time-picker.css-mistica.js +1 -1
- package/dist/dialog.css-mistica.js +4 -4
- package/dist/divider.css-mistica.js +5 -5
- package/dist/double-field.css-mistica.js +2 -2
- package/dist/drawer.css-mistica.js +1 -1
- package/dist/empty-state-card.css-mistica.js +1 -1
- package/dist/empty-state.css-mistica.js +5 -5
- package/dist/fade-in.css-mistica.js +1 -1
- package/dist/feedback.css-mistica.js +1 -1
- package/dist/file-upload.css-mistica.js +7 -7
- package/dist/fixed-footer-layout.css-mistica.js +2 -2
- package/dist/fixed-footer-layout.d.ts +6 -1
- package/dist/fixed-footer-layout.js +29 -28
- package/dist/form.css-mistica.js +1 -1
- package/dist/grid-layout.css-mistica.js +3 -3
- package/dist/grid.css-mistica.js +120 -120
- package/dist/header.css-mistica.js +1 -1
- package/dist/hero.css-mistica.js +2 -2
- package/dist/horizontal-scroll.css-mistica.js +1 -1
- package/dist/icon-button.css-mistica.js +53 -53
- package/dist/icons/icon-chevron.css-mistica.js +2 -2
- package/dist/icons/icon-error.css-mistica.js +1 -1
- package/dist/image.css-mistica.js +2 -2
- package/dist/image.js +8 -1
- package/dist/inline.css-mistica.js +9 -9
- package/dist/list.css-mistica.js +1 -1
- package/dist/loading-bar.css-mistica.js +1 -1
- package/dist/loading-screen.css-mistica.js +4 -4
- package/dist/logo.css-mistica.js +5 -5
- package/dist/menu.css-mistica.js +13 -13
- package/dist/mosaic.css-mistica.js +1 -1
- package/dist/navigation-bar.css-mistica.js +18 -18
- package/dist/navigation-breadcrumbs.css-mistica.js +1 -1
- package/dist/package-version.js +1 -1
- package/dist/pin-field.css-mistica.js +1 -1
- package/dist/popover.css-mistica.js +1 -1
- package/dist/progress-bar.css-mistica.js +6 -6
- package/dist/radio-button.css-mistica.js +19 -19
- package/dist/rating.css-mistica.js +2 -2
- package/dist/responsive-layout.css-mistica.js +6 -6
- package/dist/screen-reader-only.css-mistica.js +1 -1
- package/dist/select.css-mistica.js +15 -15
- package/dist/sheet-action-row.css-mistica.js +1 -1
- package/dist/sheet-common.css-mistica.js +1 -1
- package/dist/sheet-info.css-mistica.js +1 -1
- package/dist/skeletons.css-mistica.js +6 -6
- package/dist/skins/skin-contract.css-mistica.js +684 -684
- package/dist/skip-link.css-mistica.js +1 -1
- package/dist/slider.css-mistica.js +18 -18
- package/dist/snackbar.css-mistica.js +4 -4
- package/dist/spinner.css-mistica.js +1 -1
- package/dist/square.css-mistica.js +1 -1
- package/dist/stack.css-mistica.js +5 -5
- package/dist/stacking-group.css-mistica.js +1 -1
- package/dist/stepper.css-mistica.js +2 -2
- package/dist/switch-component.css-mistica.js +35 -35
- package/dist/table.css-mistica.js +9 -9
- package/dist/tabs.css-mistica.js +17 -17
- package/dist/tag.css-mistica.js +1 -1
- package/dist/text-field-base.css-mistica.js +15 -15
- package/dist/text-field-components.css-mistica.js +3 -3
- package/dist/text-link.css-mistica.js +6 -6
- package/dist/text.css-mistica.js +6 -6
- package/dist/theme-context.css-mistica.js +1 -1
- package/dist/timeline.css-mistica.js +9 -9
- package/dist/timer.css-mistica.js +6 -6
- package/dist/tooltip.css-mistica.js +1 -1
- package/dist/touchable.css-mistica.js +1 -1
- package/dist/utils/aspect-ratio-support.css-mistica.js +2 -2
- package/dist/video.css-mistica.js +1 -1
- package/dist/vivinho-loading-animation/vivinho-loading-animation.css-mistica.js +1 -1
- package/dist-es/accordion.css-mistica.js +6 -6
- package/dist-es/align.css-mistica.js +1 -1
- package/dist-es/autocomplete.css-mistica.js +1 -1
- package/dist-es/avatar.css-mistica.js +1 -1
- package/dist-es/badge.css-mistica.js +1 -1
- package/dist-es/box.css-mistica.js +13 -13
- package/dist-es/boxed.css-mistica.js +23 -23
- package/dist-es/button-fixed-footer-layout.js +12 -11
- package/dist-es/button-group.css-mistica.js +1 -1
- package/dist-es/button-layout.css-mistica.js +14 -14
- package/dist-es/button.css-mistica.js +30 -30
- package/dist-es/callout.css-mistica.js +11 -11
- package/dist-es/card-internal.css-mistica.js +15 -15
- package/dist-es/carousel.css-mistica.js +8 -8
- package/dist-es/checkbox.css-mistica.js +11 -11
- package/dist-es/chip.css-mistica.js +15 -15
- package/dist-es/circle.css-mistica.js +1 -1
- package/dist-es/community/advanced-data-card.css-mistica.js +6 -6
- package/dist-es/community/blocks.css-mistica.js +1 -1
- package/dist-es/community/example-component.css-mistica.js +1 -1
- package/dist-es/counter.css-mistica.js +1 -1
- package/dist-es/cover-hero.css-mistica.js +2 -2
- package/dist-es/credit-card-number-field.css-mistica.js +3 -3
- package/dist-es/date-field.css-mistica.js +1 -1
- package/dist-es/date-time-picker.css-mistica.js +1 -1
- package/dist-es/dialog.css-mistica.js +4 -4
- package/dist-es/divider.css-mistica.js +5 -5
- package/dist-es/double-field.css-mistica.js +2 -2
- package/dist-es/drawer.css-mistica.js +1 -1
- package/dist-es/empty-state-card.css-mistica.js +1 -1
- package/dist-es/empty-state.css-mistica.js +5 -5
- package/dist-es/fade-in.css-mistica.js +1 -1
- package/dist-es/feedback.css-mistica.js +1 -1
- package/dist-es/file-upload.css-mistica.js +7 -7
- package/dist-es/fixed-footer-layout.css-mistica.js +2 -2
- package/dist-es/fixed-footer-layout.js +57 -56
- package/dist-es/form.css-mistica.js +1 -1
- package/dist-es/grid-layout.css-mistica.js +3 -3
- package/dist-es/grid.css-mistica.js +120 -120
- package/dist-es/header.css-mistica.js +1 -1
- package/dist-es/hero.css-mistica.js +2 -2
- package/dist-es/horizontal-scroll.css-mistica.js +1 -1
- package/dist-es/icon-button.css-mistica.js +53 -53
- package/dist-es/icons/icon-chevron.css-mistica.js +2 -2
- package/dist-es/icons/icon-error.css-mistica.js +1 -1
- package/dist-es/image.css-mistica.js +2 -2
- package/dist-es/image.js +8 -1
- package/dist-es/inline.css-mistica.js +9 -9
- package/dist-es/list.css-mistica.js +1 -1
- package/dist-es/loading-bar.css-mistica.js +1 -1
- package/dist-es/loading-screen.css-mistica.js +4 -4
- package/dist-es/logo.css-mistica.js +5 -5
- package/dist-es/menu.css-mistica.js +13 -13
- package/dist-es/mosaic.css-mistica.js +1 -1
- package/dist-es/navigation-bar.css-mistica.js +18 -18
- package/dist-es/navigation-breadcrumbs.css-mistica.js +1 -1
- package/dist-es/package-version.js +1 -1
- package/dist-es/pin-field.css-mistica.js +1 -1
- package/dist-es/popover.css-mistica.js +1 -1
- package/dist-es/progress-bar.css-mistica.js +6 -6
- package/dist-es/radio-button.css-mistica.js +19 -19
- package/dist-es/rating.css-mistica.js +2 -2
- package/dist-es/responsive-layout.css-mistica.js +6 -6
- package/dist-es/screen-reader-only.css-mistica.js +1 -1
- package/dist-es/select.css-mistica.js +15 -15
- package/dist-es/sheet-action-row.css-mistica.js +1 -1
- package/dist-es/sheet-common.css-mistica.js +1 -1
- package/dist-es/sheet-info.css-mistica.js +1 -1
- package/dist-es/skeletons.css-mistica.js +6 -6
- package/dist-es/skins/skin-contract.css-mistica.js +684 -684
- package/dist-es/skip-link.css-mistica.js +1 -1
- package/dist-es/slider.css-mistica.js +18 -18
- package/dist-es/snackbar.css-mistica.js +4 -4
- package/dist-es/spinner.css-mistica.js +1 -1
- package/dist-es/square.css-mistica.js +1 -1
- package/dist-es/stack.css-mistica.js +5 -5
- package/dist-es/stacking-group.css-mistica.js +1 -1
- package/dist-es/stepper.css-mistica.js +2 -2
- package/dist-es/style.css +1 -1
- package/dist-es/switch-component.css-mistica.js +35 -35
- package/dist-es/table.css-mistica.js +9 -9
- package/dist-es/tabs.css-mistica.js +17 -17
- package/dist-es/tag.css-mistica.js +1 -1
- package/dist-es/text-field-base.css-mistica.js +15 -15
- package/dist-es/text-field-components.css-mistica.js +3 -3
- package/dist-es/text-link.css-mistica.js +6 -6
- package/dist-es/text.css-mistica.js +6 -6
- package/dist-es/theme-context.css-mistica.js +1 -1
- package/dist-es/timeline.css-mistica.js +9 -9
- package/dist-es/timer.css-mistica.js +6 -6
- package/dist-es/tooltip.css-mistica.js +1 -1
- package/dist-es/touchable.css-mistica.js +1 -1
- package/dist-es/utils/aspect-ratio-support.css-mistica.js +2 -2
- package/dist-es/video.css-mistica.js +1 -1
- package/dist-es/vivinho-loading-animation/vivinho-loading-animation.css-mistica.js +1 -1
- package/doc/llms.md +11 -0
- package/package.json +13 -1
- package/src/accordion.css.ts +121 -0
- package/src/accordion.tsx +366 -0
- package/src/align.css.ts +7 -0
- package/src/align.tsx +32 -0
- package/src/autocomplete.css.ts +62 -0
- package/src/autocomplete.tsx +239 -0
- package/src/avatar.css.ts +14 -0
- package/src/avatar.tsx +120 -0
- package/src/badge.css.ts +51 -0
- package/src/badge.tsx +79 -0
- package/src/box.css.ts +51 -0
- package/src/box.tsx +114 -0
- package/src/boxed.css.ts +132 -0
- package/src/boxed.tsx +153 -0
- package/src/button-fixed-footer-layout.tsx +65 -0
- package/src/button-group.css.ts +75 -0
- package/src/button-group.tsx +91 -0
- package/src/button-layout.css.ts +162 -0
- package/src/button-layout.tsx +91 -0
- package/src/button.css.ts +758 -0
- package/src/button.tsx +632 -0
- package/src/callout.css.ts +50 -0
- package/src/callout.tsx +147 -0
- package/src/card-cover.tsx +242 -0
- package/src/card-data.tsx +152 -0
- package/src/card-internal.css.ts +271 -0
- package/src/card-internal.tsx +1724 -0
- package/src/card-media.tsx +157 -0
- package/src/card-naked.tsx +63 -0
- package/src/carousel.css.ts +522 -0
- package/src/carousel.tsx +1300 -0
- package/src/checkbox.css.ts +94 -0
- package/src/checkbox.tsx +192 -0
- package/src/chip.css.ts +204 -0
- package/src/chip.tsx +191 -0
- package/src/circle.css.ts +14 -0
- package/src/circle.tsx +52 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-button-and-link-footer-image-false-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-button-and-link-footer-image-true-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-button-footer-image-false-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-button-footer-image-true-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-link-footer-image-false-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-link-footer-image-true-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-none-footer-image-false-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-none-footer-image-true-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-extras-0-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-extras-1-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-extras-3-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-extras-3-no-divider-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-inside-carousel-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-without-stacking-group-with-top-actions-and-too-long-title-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-highlighted-value-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-information-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-progress-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-progress-block-2-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-row-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-simple-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-value-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/advanced-data-card-screenshot-test.tsx +84 -0
- package/src/community/__screenshot_tests__/blocks-screenshot-test.tsx +72 -0
- package/src/community/__stories__/advanced-data-card-carousel-story.tsx +66 -0
- package/src/community/__stories__/advanced-data-card-story.tsx +158 -0
- package/src/community/__stories__/blocks-story.tsx +272 -0
- package/src/community/__stories__/example-component-story.tsx +15 -0
- package/src/community/__stories__/index-story.tsx +154 -0
- package/src/community/__type_tests__/advanced-data-card-type-test.tsx +40 -0
- package/src/community/advanced-data-card.css.ts +271 -0
- package/src/community/advanced-data-card.tsx +431 -0
- package/src/community/blocks.css.ts +12 -0
- package/src/community/blocks.tsx +290 -0
- package/src/community/example-component.css.ts +7 -0
- package/src/community/example-component.tsx +17 -0
- package/src/community/index.tsx +10 -0
- package/src/counter.css.ts +150 -0
- package/src/counter.tsx +215 -0
- package/src/cover-hero-media.tsx +39 -0
- package/src/cover-hero.css.ts +133 -0
- package/src/cover-hero.tsx +262 -0
- package/src/credit-card-expiration-field.tsx +187 -0
- package/src/credit-card-fields.tsx +56 -0
- package/src/credit-card-number-field.css.ts +47 -0
- package/src/credit-card-number-field.tsx +245 -0
- package/src/cvv-field.tsx +169 -0
- package/src/date-field.css.ts +14 -0
- package/src/date-field.tsx +130 -0
- package/src/date-time-field.tsx +141 -0
- package/src/date-time-picker.css.ts +126 -0
- package/src/date-time-picker.tsx +188 -0
- package/src/decimal-field.tsx +160 -0
- package/src/desktop-container-type-context.tsx +15 -0
- package/src/dialog-context.tsx +81 -0
- package/src/dialog.css.ts +155 -0
- package/src/dialog.tsx +423 -0
- package/src/divider.css.ts +10 -0
- package/src/divider.tsx +11 -0
- package/src/double-field.css.ts +33 -0
- package/src/double-field.tsx +71 -0
- package/src/drawer.css.ts +123 -0
- package/src/drawer.tsx +304 -0
- package/src/email-field.tsx +76 -0
- package/src/empty-state-card.css.ts +40 -0
- package/src/empty-state-card.tsx +92 -0
- package/src/empty-state.css.ts +119 -0
- package/src/empty-state.tsx +141 -0
- package/src/fade-in.css.ts +12 -0
- package/src/fade-in.tsx +40 -0
- package/src/feedback.css.ts +119 -0
- package/src/feedback.tsx +432 -0
- package/src/file-upload.css.ts +156 -0
- package/src/file-upload.tsx +612 -0
- package/src/fixed-footer-layout.css.ts +96 -0
- package/src/fixed-footer-layout.tsx +227 -0
- package/src/fixed-to-top.tsx +21 -0
- package/src/focus-trap.tsx +17 -0
- package/src/form-context.tsx +198 -0
- package/src/form.css.ts +5 -0
- package/src/form.tsx +287 -0
- package/src/grid-layout.css.ts +68 -0
- package/src/grid-layout.tsx +201 -0
- package/src/grid.css.ts +203 -0
- package/src/grid.tsx +241 -0
- package/src/header.css.ts +30 -0
- package/src/header.tsx +319 -0
- package/src/hero.css.ts +71 -0
- package/src/hero.tsx +318 -0
- package/src/hooks.tsx +313 -0
- package/src/horizontal-scroll.css.ts +43 -0
- package/src/horizontal-scroll.tsx +18 -0
- package/src/iban-field.tsx +218 -0
- package/src/icon-button.css.ts +561 -0
- package/src/icon-button.tsx +221 -0
- package/src/icons/__stories__/mistica-icons-story.tsx +192 -0
- package/src/icons/icon-amex.tsx +40 -0
- package/src/icons/icon-chevron.css.ts +23 -0
- package/src/icons/icon-chevron.tsx +150 -0
- package/src/icons/icon-cvv-amex.tsx +31 -0
- package/src/icons/icon-cvv-visa-mc.tsx +31 -0
- package/src/icons/icon-error.css.ts +27 -0
- package/src/icons/icon-error.tsx +207 -0
- package/src/icons/icon-info.tsx +86 -0
- package/src/icons/icon-mastercard.tsx +36 -0
- package/src/icons/icon-success-vivo-new.tsx +51 -0
- package/src/icons/icon-success-vivo.tsx +36 -0
- package/src/icons/icon-success.tsx +211 -0
- package/src/icons/icon-visa.tsx +32 -0
- package/src/image.css.ts +48 -0
- package/src/image.tsx +352 -0
- package/src/index.tsx +2466 -0
- package/src/inline.css.ts +131 -0
- package/src/inline.tsx +135 -0
- package/src/integer-field.tsx +93 -0
- package/src/list.css.ts +281 -0
- package/src/list.tsx +963 -0
- package/src/loading-bar.css.ts +69 -0
- package/src/loading-bar.tsx +25 -0
- package/src/loading-screen.css.ts +114 -0
- package/src/loading-screen.tsx +376 -0
- package/src/logo-blau-shell.tsx +30 -0
- package/src/logo-blau.tsx +60 -0
- package/src/logo-common.tsx +29 -0
- package/src/logo-esimflag-shell.tsx +30 -0
- package/src/logo-esimflag.tsx +56 -0
- package/src/logo-movistar-new-shell.tsx +30 -0
- package/src/logo-movistar-new.tsx +85 -0
- package/src/logo-movistar-shell.tsx +30 -0
- package/src/logo-movistar.tsx +63 -0
- package/src/logo-o2-new-shell.tsx +26 -0
- package/src/logo-o2-new.tsx +27 -0
- package/src/logo-o2-shell.tsx +26 -0
- package/src/logo-o2.tsx +27 -0
- package/src/logo-telefonica-shell.tsx +30 -0
- package/src/logo-telefonica.tsx +95 -0
- package/src/logo-tu-shell.tsx +26 -0
- package/src/logo-tu.tsx +28 -0
- package/src/logo-vivo-shell.tsx +30 -0
- package/src/logo-vivo.tsx +53 -0
- package/src/logo.css.ts +33 -0
- package/src/logo.tsx +313 -0
- package/src/master-detail-layout.tsx +28 -0
- package/src/maybe-dismissable.css.ts +37 -0
- package/src/maybe-dismissable.tsx +58 -0
- package/src/media-queries.css.ts +67 -0
- package/src/menu.css.ts +132 -0
- package/src/menu.tsx +468 -0
- package/src/meter.tsx +516 -0
- package/src/modal-context-provider.tsx +45 -0
- package/src/month-field.tsx +124 -0
- package/src/mosaic.css.ts +73 -0
- package/src/mosaic.tsx +205 -0
- package/src/navigation-bar.css.ts +558 -0
- package/src/navigation-bar.tsx +1637 -0
- package/src/navigation-breadcrumbs.css.ts +22 -0
- package/src/navigation-breadcrumbs.tsx +69 -0
- package/src/negative-box.tsx +15 -0
- package/src/nestable-context.tsx +139 -0
- package/src/overlay.tsx +86 -0
- package/src/overscroll-color-context.tsx +141 -0
- package/src/package-version.tsx +2 -0
- package/src/password-field.tsx +126 -0
- package/src/phone-number-field-lite.tsx +265 -0
- package/src/phone-number-field.tsx +171 -0
- package/src/pin-field.css.ts +90 -0
- package/src/pin-field.tsx +346 -0
- package/src/placeholder.tsx +41 -0
- package/src/popover.css.ts +8 -0
- package/src/popover.tsx +85 -0
- package/src/portal.tsx +43 -0
- package/src/progress-bar.css.ts +61 -0
- package/src/progress-bar.tsx +174 -0
- package/src/radio-button.css.ts +174 -0
- package/src/radio-button.tsx +322 -0
- package/src/rating.css.ts +128 -0
- package/src/rating.tsx +351 -0
- package/src/responsive-layout.css.ts +162 -0
- package/src/responsive-layout.tsx +106 -0
- package/src/screen-reader-only.css.ts +27 -0
- package/src/screen-reader-only.tsx +33 -0
- package/src/screen-size-context-provider.tsx +96 -0
- package/src/screen-size-context.tsx +23 -0
- package/src/search-field.tsx +126 -0
- package/src/select.css.ts +226 -0
- package/src/select.tsx +513 -0
- package/src/sheet-action-row.css.ts +33 -0
- package/src/sheet-actions-list.tsx +113 -0
- package/src/sheet-actions.tsx +95 -0
- package/src/sheet-common.css.ts +254 -0
- package/src/sheet-common.tsx +402 -0
- package/src/sheet-info.css.ts +19 -0
- package/src/sheet-info.tsx +127 -0
- package/src/sheet-native.tsx +189 -0
- package/src/sheet-radio-list.tsx +118 -0
- package/src/sheet-root.tsx +127 -0
- package/src/sheet-types.tsx +94 -0
- package/src/sheet-web.tsx +140 -0
- package/src/skeleton-base.tsx +38 -0
- package/src/skeletons.css.ts +56 -0
- package/src/skeletons.tsx +133 -0
- package/src/skins/blau.tsx +724 -0
- package/src/skins/constants.tsx +10 -0
- package/src/skins/defaults.tsx +104 -0
- package/src/skins/esimflag.tsx +728 -0
- package/src/skins/movistar-new.tsx +735 -0
- package/src/skins/movistar.tsx +740 -0
- package/src/skins/o2-new.tsx +731 -0
- package/src/skins/o2.tsx +727 -0
- package/src/skins/skin-contract.css.ts +380 -0
- package/src/skins/telefonica.tsx +768 -0
- package/src/skins/tu.tsx +741 -0
- package/src/skins/types/colors.tsx +286 -0
- package/src/skins/types/index.tsx +153 -0
- package/src/skins/utils.tsx +66 -0
- package/src/skins/vivo-new.tsx +745 -0
- package/src/skins/vivo.tsx +720 -0
- package/src/skip-link.css.ts +34 -0
- package/src/skip-link.tsx +52 -0
- package/src/slider.css.ts +181 -0
- package/src/slider.tsx +384 -0
- package/src/snackbar-context.tsx +98 -0
- package/src/snackbar-native.ts +37 -0
- package/src/snackbar.css.ts +176 -0
- package/src/snackbar.tsx +258 -0
- package/src/spinner.css.ts +66 -0
- package/src/spinner.tsx +136 -0
- package/src/sprinkles.css.ts +83 -0
- package/src/square.css.ts +15 -0
- package/src/square.tsx +55 -0
- package/src/stack.css.ts +44 -0
- package/src/stack.tsx +79 -0
- package/src/stacking-group.css.ts +15 -0
- package/src/stacking-group.tsx +82 -0
- package/src/stepper.css.ts +233 -0
- package/src/stepper.tsx +156 -0
- package/src/switch-component.css.ts +181 -0
- package/src/switch-component.tsx +187 -0
- package/src/tab-focus.tsx +68 -0
- package/src/table-actions-header.tsx +21 -0
- package/src/table-cell-text.tsx +35 -0
- package/src/table.css.ts +297 -0
- package/src/table.tsx +398 -0
- package/src/tabs.css.ts +212 -0
- package/src/tabs.tsx +263 -0
- package/src/tag.css.ts +42 -0
- package/src/tag.tsx +161 -0
- package/src/test-utils/environment/setup-ssr.tsx +10 -0
- package/src/test-utils/fail-test-on-console-error.tsx +22 -0
- package/src/test-utils/index.tsx +341 -0
- package/src/test-utils/setup-ssr-test-env.tsx +13 -0
- package/src/test-utils/ssr.tsx +197 -0
- package/src/text-field-base.css.ts +416 -0
- package/src/text-field-base.tsx +628 -0
- package/src/text-field-components.css.ts +165 -0
- package/src/text-field-components.tsx +230 -0
- package/src/text-field.tsx +118 -0
- package/src/text-link.css.ts +83 -0
- package/src/text-link.tsx +85 -0
- package/src/text-tokens.tsx +708 -0
- package/src/text.css.ts +60 -0
- package/src/text.tsx +516 -0
- package/src/theme-context-provider.tsx +370 -0
- package/src/theme-context.css.ts +3 -0
- package/src/theme-context.tsx +8 -0
- package/src/theme-variant-context.tsx +51 -0
- package/src/theme.tsx +184 -0
- package/src/time-field.tsx +99 -0
- package/src/timeline.css.ts +135 -0
- package/src/timeline.tsx +250 -0
- package/src/timer.css.ts +99 -0
- package/src/timer.tsx +420 -0
- package/src/title.tsx +119 -0
- package/src/tooltip-context-provider.tsx +57 -0
- package/src/tooltip.css.ts +106 -0
- package/src/tooltip.tsx +649 -0
- package/src/touchable.css.ts +56 -0
- package/src/touchable.tsx +355 -0
- package/src/types/font-face.d.ts +47 -0
- package/src/types/libs.d.ts +3 -0
- package/src/utils/__tests__/analytics-test.tsx +35 -0
- package/src/utils/__tests__/browser-test.tsx +28 -0
- package/src/utils/__tests__/dom-test.tsx +23 -0
- package/src/utils/__tests__/helpers-test.tsx +166 -0
- package/src/utils/analytics.tsx +28 -0
- package/src/utils/animation.tsx +201 -0
- package/src/utils/aspect-ratio-support.css.ts +28 -0
- package/src/utils/aspect-ratio-support.tsx +141 -0
- package/src/utils/browser.tsx +9 -0
- package/src/utils/color.tsx +46 -0
- package/src/utils/common.tsx +27 -0
- package/src/utils/credit-card.tsx +46 -0
- package/src/utils/css.tsx +25 -0
- package/src/utils/document-visibility.tsx +52 -0
- package/src/utils/dom.tsx +155 -0
- package/src/utils/environment.tsx +6 -0
- package/src/utils/headings.tsx +18 -0
- package/src/utils/helpers.tsx +182 -0
- package/src/utils/keys.tsx +8 -0
- package/src/utils/locale.tsx +27 -0
- package/src/utils/platform.tsx +94 -0
- package/src/utils/region-code.tsx +1 -0
- package/src/utils/renders-element.tsx +6 -0
- package/src/utils/time.tsx +22 -0
- package/src/utils/types.tsx +19 -0
- package/src/utils/utility-types.tsx +8 -0
- package/src/video.css.ts +11 -0
- package/src/video.tsx +355 -0
- package/src/vivinho-loading-animation/in-lottie.json +402 -0
- package/src/vivinho-loading-animation/index.tsx +90 -0
- package/src/vivinho-loading-animation/out-lottie.json +575 -0
- package/src/vivinho-loading-animation/pulse-lottie.json +551 -0
- package/src/vivinho-loading-animation/vivinho-loading-animation.css.ts +15 -0
- package/src/vivinho-loading-animation/wave-lottie.json +2829 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {useTheme} from './hooks';
|
|
4
|
+
import {vars} from './skins/skin-contract.css';
|
|
5
|
+
import * as styles from './progress-bar.css';
|
|
6
|
+
import {getPrefixedDataAttributes} from './utils/dom';
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
import Inline from './inline';
|
|
9
|
+
import * as tokens from './text-tokens';
|
|
10
|
+
import {useThemeVariant} from './theme-variant-context';
|
|
11
|
+
|
|
12
|
+
import type {DataAttributes} from './utils/types';
|
|
13
|
+
|
|
14
|
+
type ProgressBarProps = {
|
|
15
|
+
progressPercent: number;
|
|
16
|
+
color?: string;
|
|
17
|
+
children?: void;
|
|
18
|
+
'aria-label'?: string;
|
|
19
|
+
'aria-labelledby'?: string;
|
|
20
|
+
'aria-hidden'?: React.HTMLAttributes<HTMLDivElement>['aria-hidden'];
|
|
21
|
+
dataAttributes?: DataAttributes;
|
|
22
|
+
reverse?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const ProgressBar = ({
|
|
26
|
+
progressPercent,
|
|
27
|
+
color,
|
|
28
|
+
'aria-label': ariaLabel,
|
|
29
|
+
'aria-labelledby': ariaLabelledBy,
|
|
30
|
+
'aria-hidden': ariaHidden,
|
|
31
|
+
dataAttributes,
|
|
32
|
+
reverse = false,
|
|
33
|
+
}: ProgressBarProps): JSX.Element => {
|
|
34
|
+
const {texts, t} = useTheme();
|
|
35
|
+
const themeVariant = useThemeVariant();
|
|
36
|
+
const progressValue = Math.max(0, Math.min(100, progressPercent));
|
|
37
|
+
|
|
38
|
+
const getFormattedValueText = () => {
|
|
39
|
+
const completedText = texts.progressBarCompletedLabel || t(tokens.progressBarCompletedLabel);
|
|
40
|
+
|
|
41
|
+
return `${progressValue.toFixed(1)}% ${completedText}`;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const a11yProps =
|
|
45
|
+
ariaHidden && ariaHidden !== 'false'
|
|
46
|
+
? {'aria-hidden': ariaHidden}
|
|
47
|
+
: {
|
|
48
|
+
role: 'progressbar',
|
|
49
|
+
'aria-valuenow': progressValue,
|
|
50
|
+
'aria-valuemin': 0,
|
|
51
|
+
'aria-valuemax': 100,
|
|
52
|
+
'aria-valuetext': getFormattedValueText(),
|
|
53
|
+
'aria-label': ariaLabelledBy ? undefined : ariaLabel || texts.loading || t(tokens.loading),
|
|
54
|
+
'aria-labelledby': ariaLabelledBy,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div
|
|
59
|
+
{...getPrefixedDataAttributes(dataAttributes, 'ProgressBar')}
|
|
60
|
+
className={styles.barBackground[themeVariant]}
|
|
61
|
+
{...a11yProps}
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
className={classNames(styles.bar, reverse ? styles.inverse : styles.normal)}
|
|
65
|
+
style={{
|
|
66
|
+
maxWidth: `${progressValue}%`,
|
|
67
|
+
backgroundColor:
|
|
68
|
+
color ??
|
|
69
|
+
{
|
|
70
|
+
default: vars.colors.controlActivated,
|
|
71
|
+
alternative: vars.colors.controlActivated,
|
|
72
|
+
brand: vars.colors.controlActivatedBrand,
|
|
73
|
+
media: vars.colors.controlActivatedBrand,
|
|
74
|
+
negative: vars.colors.controlActivatedNegative,
|
|
75
|
+
}[themeVariant],
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
type ProgressBarSteppedProps = {
|
|
83
|
+
steps: number;
|
|
84
|
+
currentStep?: number;
|
|
85
|
+
color?: string;
|
|
86
|
+
dataAttributes?: DataAttributes;
|
|
87
|
+
'aria-label'?: string;
|
|
88
|
+
'aria-labelledby'?: string;
|
|
89
|
+
'aria-hidden'?: React.HTMLAttributes<HTMLDivElement>['aria-hidden'];
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const ProgressBarStepped = ({
|
|
93
|
+
steps,
|
|
94
|
+
currentStep = 0,
|
|
95
|
+
color,
|
|
96
|
+
dataAttributes,
|
|
97
|
+
'aria-label': ariaLabel,
|
|
98
|
+
'aria-labelledby': ariaLabelledBy,
|
|
99
|
+
'aria-hidden': ariaHidden,
|
|
100
|
+
}: ProgressBarSteppedProps): JSX.Element => {
|
|
101
|
+
const {texts, t} = useTheme();
|
|
102
|
+
const themeVariant = useThemeVariant();
|
|
103
|
+
|
|
104
|
+
const [step, setStep] = React.useState(Math.ceil(currentStep));
|
|
105
|
+
const [isBack, setIsBack] = React.useState(false);
|
|
106
|
+
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
const newStep = Math.ceil(currentStep);
|
|
109
|
+
if (step !== newStep) {
|
|
110
|
+
setIsBack(newStep < step);
|
|
111
|
+
setStep(newStep);
|
|
112
|
+
}
|
|
113
|
+
}, [currentStep, steps, step]);
|
|
114
|
+
|
|
115
|
+
const getFormattedValueText = () => {
|
|
116
|
+
const stepText = t(texts.progressBarStepLabel || tokens.progressBarStepLabel, step, steps);
|
|
117
|
+
return stepText;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const a11yProps =
|
|
121
|
+
ariaHidden && ariaHidden !== 'false'
|
|
122
|
+
? {'aria-hidden': ariaHidden}
|
|
123
|
+
: {
|
|
124
|
+
role: 'progressbar',
|
|
125
|
+
'aria-valuenow': step,
|
|
126
|
+
'aria-valuemin': 0,
|
|
127
|
+
'aria-valuemax': steps,
|
|
128
|
+
'aria-valuetext': getFormattedValueText(),
|
|
129
|
+
'aria-label': ariaLabelledBy ? undefined : ariaLabel,
|
|
130
|
+
'aria-labelledby': ariaLabelledBy,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<div
|
|
135
|
+
{...getPrefixedDataAttributes(dataAttributes, 'ProgressBarStepped')}
|
|
136
|
+
role="progressbar"
|
|
137
|
+
{...a11yProps}
|
|
138
|
+
className={styles.progressBarSteppedContainer}
|
|
139
|
+
>
|
|
140
|
+
<Inline space={8} fullWidth>
|
|
141
|
+
{Array.from({length: steps}, (_, index) => {
|
|
142
|
+
const isCurrent = index === step;
|
|
143
|
+
const isCompleted = index < step;
|
|
144
|
+
const hasAnimation = index === step - 1;
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<div key={index} className={styles.barBackground[themeVariant]} aria-hidden="true">
|
|
148
|
+
{(isCompleted || isCurrent) && (
|
|
149
|
+
<div
|
|
150
|
+
className={classNames(styles.bar, {
|
|
151
|
+
[styles.normal]: hasAnimation && !isBack,
|
|
152
|
+
[styles.inverse]: isCurrent && isBack,
|
|
153
|
+
})}
|
|
154
|
+
style={{
|
|
155
|
+
backgroundColor:
|
|
156
|
+
color ??
|
|
157
|
+
{
|
|
158
|
+
default: vars.colors.controlActivated,
|
|
159
|
+
alternative: vars.colors.controlActivated,
|
|
160
|
+
brand: vars.colors.controlActivatedBrand,
|
|
161
|
+
media: vars.colors.controlActivatedBrand,
|
|
162
|
+
negative: vars.colors.controlActivatedNegative,
|
|
163
|
+
}[themeVariant],
|
|
164
|
+
maxWidth: isCompleted || (hasAnimation && !isBack) ? '100%' : '0',
|
|
165
|
+
}}
|
|
166
|
+
/>
|
|
167
|
+
)}
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
})}
|
|
171
|
+
</Inline>
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import {style, styleVariants} from '@vanilla-extract/css';
|
|
2
|
+
import {vars} from './skins/skin-contract.css';
|
|
3
|
+
import {sprinkles} from './sprinkles.css';
|
|
4
|
+
|
|
5
|
+
const outerCircleBase = style([
|
|
6
|
+
sprinkles({
|
|
7
|
+
display: 'inline-flex',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
cursor: 'pointer',
|
|
11
|
+
flexShrink: 0,
|
|
12
|
+
borderRadius: '50%',
|
|
13
|
+
}),
|
|
14
|
+
{
|
|
15
|
+
width: 20,
|
|
16
|
+
height: 20,
|
|
17
|
+
verticalAlign: 'middle',
|
|
18
|
+
transition: 'background 0.3s, box-shadow 0.3s',
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
export const outerCircleVariants = styleVariants({
|
|
23
|
+
default: [
|
|
24
|
+
outerCircleBase,
|
|
25
|
+
{background: vars.colors.background, boxShadow: `inset 0 0 0 2px ${vars.colors.control}`},
|
|
26
|
+
],
|
|
27
|
+
ios: [
|
|
28
|
+
outerCircleBase,
|
|
29
|
+
{background: vars.colors.background, boxShadow: `inset 0 0 0 1px ${vars.colors.control}`},
|
|
30
|
+
],
|
|
31
|
+
checked: [
|
|
32
|
+
outerCircleBase,
|
|
33
|
+
{
|
|
34
|
+
boxShadow: `inset 0 0 0 2px ${vars.colors.controlActivated}`,
|
|
35
|
+
// using a gradient here to not fill until the circle edge, otherwise the radiobutton border looks strange
|
|
36
|
+
background: vars.colors.background,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
checkedIos: [
|
|
40
|
+
outerCircleBase,
|
|
41
|
+
{
|
|
42
|
+
boxShadow: `inset 0 0 0 5px ${vars.colors.controlActivated}`,
|
|
43
|
+
background: `radial-gradient(circle, ${vars.colors.iosControlKnob} 0%, ${vars.colors.iosControlKnob} 64%, transparent 64%, transparent 100%)`,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const overBrandOuterCircleVariants = styleVariants({
|
|
49
|
+
default: [
|
|
50
|
+
outerCircleBase,
|
|
51
|
+
{background: 'transparent', boxShadow: `inset 0 0 0 2px ${vars.colors.controlBrand}`},
|
|
52
|
+
],
|
|
53
|
+
ios: [
|
|
54
|
+
outerCircleBase,
|
|
55
|
+
{background: 'transparent', boxShadow: `inset 0 0 0 1px ${vars.colors.controlBrand}`},
|
|
56
|
+
],
|
|
57
|
+
checked: [
|
|
58
|
+
outerCircleBase,
|
|
59
|
+
{
|
|
60
|
+
boxShadow: `inset 0 0 0 2px ${vars.colors.controlActivatedBrand}`,
|
|
61
|
+
// using a gradient here to not fill until the circle edge, otherwise the radiobutton border looks strange
|
|
62
|
+
background: 'transparent',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
checkedIos: [
|
|
66
|
+
outerCircleBase,
|
|
67
|
+
{
|
|
68
|
+
boxShadow: `inset 0 0 0 5px ${vars.colors.controlActivatedBrand}`,
|
|
69
|
+
background: `radial-gradient(circle, ${vars.colors.controlKnobBrand} 0%, ${vars.colors.controlKnobBrand} 64%, transparent 64%, transparent 100%)`,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const overNegativeOuterCircleVariants = styleVariants({
|
|
75
|
+
default: [
|
|
76
|
+
outerCircleBase,
|
|
77
|
+
{background: 'transparent', boxShadow: `inset 0 0 0 2px ${vars.colors.controlBrand}`},
|
|
78
|
+
],
|
|
79
|
+
ios: [
|
|
80
|
+
outerCircleBase,
|
|
81
|
+
{background: 'transparent', boxShadow: `inset 0 0 0 1px ${vars.colors.controlBrand}`},
|
|
82
|
+
],
|
|
83
|
+
checked: [
|
|
84
|
+
outerCircleBase,
|
|
85
|
+
{
|
|
86
|
+
boxShadow: `inset 0 0 0 2px ${vars.colors.controlActivatedBrand}`,
|
|
87
|
+
// using a gradient here to not fill until the circle edge, otherwise the radiobutton border looks strange
|
|
88
|
+
background: 'transparent',
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
checkedIos: [
|
|
92
|
+
outerCircleBase,
|
|
93
|
+
{
|
|
94
|
+
boxShadow: `inset 0 0 0 5px ${vars.colors.controlActivatedBrand}`,
|
|
95
|
+
background: `radial-gradient(circle, ${vars.colors.controlKnobBrand} 0%, ${vars.colors.controlKnobBrand} 64%, transparent 64%, transparent 100%)`,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const innerCircleBase = style([
|
|
101
|
+
sprinkles({
|
|
102
|
+
display: 'flex',
|
|
103
|
+
borderRadius: '50%',
|
|
104
|
+
}),
|
|
105
|
+
{
|
|
106
|
+
height: 10,
|
|
107
|
+
width: 10,
|
|
108
|
+
opacity: 0,
|
|
109
|
+
transition: `transform 0.2s, opacity 0.2s`,
|
|
110
|
+
transform: 'scale(0)',
|
|
111
|
+
},
|
|
112
|
+
]);
|
|
113
|
+
|
|
114
|
+
export const innerCircleVariant = styleVariants({
|
|
115
|
+
default: [innerCircleBase],
|
|
116
|
+
checked: [
|
|
117
|
+
innerCircleBase,
|
|
118
|
+
sprinkles({
|
|
119
|
+
background: vars.colors.controlActivated,
|
|
120
|
+
}),
|
|
121
|
+
{
|
|
122
|
+
opacity: 1,
|
|
123
|
+
transform: 'none',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export const overBrandInnerCircleVariant = styleVariants({
|
|
129
|
+
default: [innerCircleBase],
|
|
130
|
+
checked: [
|
|
131
|
+
innerCircleBase,
|
|
132
|
+
sprinkles({
|
|
133
|
+
background: vars.colors.controlActivatedBrand,
|
|
134
|
+
}),
|
|
135
|
+
{
|
|
136
|
+
opacity: 1,
|
|
137
|
+
transform: 'none',
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
export const overNegativeInnerCircleVariant = styleVariants({
|
|
143
|
+
default: [innerCircleBase],
|
|
144
|
+
checked: [
|
|
145
|
+
innerCircleBase,
|
|
146
|
+
sprinkles({
|
|
147
|
+
background: vars.colors.controlActivatedNegative,
|
|
148
|
+
}),
|
|
149
|
+
{
|
|
150
|
+
opacity: 1,
|
|
151
|
+
transform: 'none',
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const radioButtonBase = style({
|
|
157
|
+
WebkitTapHighlightColor: 'transparent',
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
export const radioButton = style([
|
|
161
|
+
radioButtonBase,
|
|
162
|
+
{
|
|
163
|
+
cursor: 'pointer',
|
|
164
|
+
},
|
|
165
|
+
]);
|
|
166
|
+
|
|
167
|
+
export const radioButtonContainerDisabled = style([
|
|
168
|
+
radioButtonBase,
|
|
169
|
+
{
|
|
170
|
+
cursor: 'default',
|
|
171
|
+
},
|
|
172
|
+
]);
|
|
173
|
+
|
|
174
|
+
export const disabled = style({cursor: 'default', opacity: 0.5});
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {SPACE, LEFT, UP, DOWN, RIGHT} from './utils/keys';
|
|
4
|
+
import {useControlProps} from './form-context';
|
|
5
|
+
import {combineRefs} from './utils/common';
|
|
6
|
+
import {Text3} from './text';
|
|
7
|
+
import Inline from './inline';
|
|
8
|
+
import classnames from 'classnames';
|
|
9
|
+
import {useTheme} from './hooks';
|
|
10
|
+
import {getPrefixedDataAttributes} from './utils/dom';
|
|
11
|
+
import * as styles from './radio-button.css';
|
|
12
|
+
import {useThemeVariant} from './theme-variant-context';
|
|
13
|
+
|
|
14
|
+
import type {DataAttributes} from './utils/types';
|
|
15
|
+
|
|
16
|
+
type RadioContextType = {
|
|
17
|
+
id: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
selectedValue?: string | null;
|
|
20
|
+
focusableValue?: string | null;
|
|
21
|
+
select: (value: string) => void;
|
|
22
|
+
selectNext: () => void;
|
|
23
|
+
selectPrev: () => void;
|
|
24
|
+
};
|
|
25
|
+
const RadioContext = React.createContext<RadioContextType>({
|
|
26
|
+
id: '',
|
|
27
|
+
disabled: false,
|
|
28
|
+
selectedValue: null,
|
|
29
|
+
focusableValue: null,
|
|
30
|
+
select: () => {},
|
|
31
|
+
selectNext: () => {},
|
|
32
|
+
selectPrev: () => {},
|
|
33
|
+
});
|
|
34
|
+
export const useRadioContext = (): RadioContextType => React.useContext(RadioContext);
|
|
35
|
+
|
|
36
|
+
type PropsRender = {
|
|
37
|
+
value: string;
|
|
38
|
+
id?: string;
|
|
39
|
+
render: (renderProps: {
|
|
40
|
+
controlElement: React.ReactElement;
|
|
41
|
+
labelId: string;
|
|
42
|
+
disabled: boolean;
|
|
43
|
+
checked: boolean;
|
|
44
|
+
}) => React.ReactNode;
|
|
45
|
+
children?: undefined;
|
|
46
|
+
dataAttributes?: DataAttributes;
|
|
47
|
+
'aria-label'?: string;
|
|
48
|
+
'aria-labelledby'?: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type PropsChildren = {
|
|
52
|
+
value: string;
|
|
53
|
+
id?: string;
|
|
54
|
+
children?: React.ReactNode;
|
|
55
|
+
render?: undefined;
|
|
56
|
+
dataAttributes?: DataAttributes;
|
|
57
|
+
'aria-label'?: string;
|
|
58
|
+
'aria-labelledby'?: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const RadioButton = ({
|
|
62
|
+
value,
|
|
63
|
+
id,
|
|
64
|
+
dataAttributes,
|
|
65
|
+
'aria-labelledby': ariaLabelledby,
|
|
66
|
+
'aria-label': ariaLabel,
|
|
67
|
+
...rest
|
|
68
|
+
}: PropsRender | PropsChildren): JSX.Element => {
|
|
69
|
+
const {
|
|
70
|
+
id: groupId,
|
|
71
|
+
disabled,
|
|
72
|
+
selectedValue,
|
|
73
|
+
focusableValue,
|
|
74
|
+
select,
|
|
75
|
+
selectNext,
|
|
76
|
+
selectPrev,
|
|
77
|
+
} = useRadioContext();
|
|
78
|
+
const [isFirstRadio, setIsFirstRadio] = React.useState(false);
|
|
79
|
+
const reactId = React.useId();
|
|
80
|
+
const labelId = ariaLabelledby || reactId;
|
|
81
|
+
const ref = React.useRef<HTMLDivElement>(null);
|
|
82
|
+
const checked = value === selectedValue;
|
|
83
|
+
const {isIos} = useTheme();
|
|
84
|
+
const themeVariant = useThemeVariant();
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The radio will gain focus with tab navigation if:
|
|
88
|
+
* - it is not disabled
|
|
89
|
+
* - it is the currently selected radio -OR- it is the first radio in the group and no radio is selected
|
|
90
|
+
*/
|
|
91
|
+
const tabIndex = disabled
|
|
92
|
+
? undefined
|
|
93
|
+
: focusableValue === value || (isFirstRadio && !selectedValue)
|
|
94
|
+
? 0
|
|
95
|
+
: -1;
|
|
96
|
+
|
|
97
|
+
React.useEffect(() => {
|
|
98
|
+
const firstRadio = document.getElementById(groupId)?.querySelector('[role=radio]');
|
|
99
|
+
setIsFirstRadio(firstRadio === ref.current);
|
|
100
|
+
}, [groupId]);
|
|
101
|
+
|
|
102
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
103
|
+
switch (event.key) {
|
|
104
|
+
case SPACE:
|
|
105
|
+
select(value);
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
event.stopPropagation();
|
|
108
|
+
break;
|
|
109
|
+
case RIGHT:
|
|
110
|
+
case DOWN:
|
|
111
|
+
selectNext();
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
break;
|
|
115
|
+
case LEFT:
|
|
116
|
+
case UP:
|
|
117
|
+
selectPrev();
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
event.stopPropagation();
|
|
120
|
+
break;
|
|
121
|
+
default:
|
|
122
|
+
// do nothing
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const outerCircleVariant = isIos ? (checked ? 'checkedIos' : 'ios') : checked ? 'checked' : 'default';
|
|
127
|
+
const innerCircleVariant = checked ? 'checked' : 'default';
|
|
128
|
+
|
|
129
|
+
const radio = (
|
|
130
|
+
<div
|
|
131
|
+
className={classnames(
|
|
132
|
+
themeVariant === 'brand' || themeVariant === 'media'
|
|
133
|
+
? styles.overBrandOuterCircleVariants[outerCircleVariant]
|
|
134
|
+
: themeVariant === 'negative'
|
|
135
|
+
? styles.overNegativeOuterCircleVariants[outerCircleVariant]
|
|
136
|
+
: styles.outerCircleVariants[outerCircleVariant],
|
|
137
|
+
{
|
|
138
|
+
[styles.disabled]: disabled,
|
|
139
|
+
}
|
|
140
|
+
)}
|
|
141
|
+
>
|
|
142
|
+
{!isIos && (
|
|
143
|
+
<div
|
|
144
|
+
className={
|
|
145
|
+
themeVariant === 'brand' || themeVariant === 'media'
|
|
146
|
+
? styles.overBrandInnerCircleVariant[innerCircleVariant]
|
|
147
|
+
: themeVariant === 'negative'
|
|
148
|
+
? styles.overNegativeInnerCircleVariant[innerCircleVariant]
|
|
149
|
+
: styles.innerCircleVariant[innerCircleVariant]
|
|
150
|
+
}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<span
|
|
158
|
+
ref={ref}
|
|
159
|
+
id={id}
|
|
160
|
+
tabIndex={tabIndex}
|
|
161
|
+
role="radio"
|
|
162
|
+
data-value={value}
|
|
163
|
+
aria-checked={checked}
|
|
164
|
+
aria-disabled={disabled}
|
|
165
|
+
aria-label={ariaLabel}
|
|
166
|
+
aria-labelledby={ariaLabel ? undefined : labelId}
|
|
167
|
+
onClick={(e) => {
|
|
168
|
+
e.stopPropagation();
|
|
169
|
+
if (!disabled) {
|
|
170
|
+
select(value);
|
|
171
|
+
}
|
|
172
|
+
}}
|
|
173
|
+
onKeyDown={disabled ? undefined : handleKeyDown}
|
|
174
|
+
className={disabled ? styles.radioButtonContainerDisabled : styles.radioButton}
|
|
175
|
+
{...getPrefixedDataAttributes(dataAttributes, 'RadioButton')}
|
|
176
|
+
>
|
|
177
|
+
{rest.render ? (
|
|
178
|
+
rest.render({controlElement: radio, disabled: !!disabled, checked, labelId})
|
|
179
|
+
) : (
|
|
180
|
+
<Inline space={16}>
|
|
181
|
+
{/* Text3 wrapper added to have the same line-height and center checkbox with text and -2px to perfect pixel center icon */}
|
|
182
|
+
<Text3 regular as="div">
|
|
183
|
+
<div style={{position: 'relative', top: -2}}>{radio}</div>
|
|
184
|
+
</Text3>
|
|
185
|
+
<Text3 regular as="div" id={labelId}>
|
|
186
|
+
<span className={disabled ? styles.disabled : ''}>{rest.children}</span>
|
|
187
|
+
</Text3>
|
|
188
|
+
</Inline>
|
|
189
|
+
)}
|
|
190
|
+
</span>
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
type RadioGroupProps = {
|
|
195
|
+
name: string;
|
|
196
|
+
disabled?: boolean;
|
|
197
|
+
'aria-label'?: string;
|
|
198
|
+
'aria-labelledby'?: string;
|
|
199
|
+
children: React.ReactNode;
|
|
200
|
+
value?: string;
|
|
201
|
+
defaultValue?: string;
|
|
202
|
+
onChange?: (value: string) => void;
|
|
203
|
+
dataAttributes?: DataAttributes;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export const RadioGroup = (props: RadioGroupProps): JSX.Element => {
|
|
207
|
+
const {
|
|
208
|
+
value: valueContext,
|
|
209
|
+
defaultValue,
|
|
210
|
+
onChange: onChangeContext,
|
|
211
|
+
focusableRef,
|
|
212
|
+
disabled,
|
|
213
|
+
} = useControlProps({
|
|
214
|
+
name: props.name,
|
|
215
|
+
value: props.value,
|
|
216
|
+
defaultValue: props.defaultValue,
|
|
217
|
+
onChange: props.onChange,
|
|
218
|
+
disabled: props.disabled,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const id = React.useId();
|
|
222
|
+
|
|
223
|
+
const isControlledByParent = typeof valueContext !== 'undefined';
|
|
224
|
+
|
|
225
|
+
// This state is needed because the component should be able to work outside a Form context
|
|
226
|
+
const [value, setValue] = React.useState<string>(valueContext ?? defaultValue ?? '');
|
|
227
|
+
|
|
228
|
+
// Propagate context value to inner state
|
|
229
|
+
React.useEffect(() => {
|
|
230
|
+
if (valueContext !== undefined) {
|
|
231
|
+
setValue(valueContext);
|
|
232
|
+
}
|
|
233
|
+
}, [valueContext]);
|
|
234
|
+
|
|
235
|
+
const onChange = (value: string) => {
|
|
236
|
+
if (!isControlledByParent) {
|
|
237
|
+
setValue(value);
|
|
238
|
+
}
|
|
239
|
+
onChangeContext(value);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const [firstRadioValue, setFirstRadioValue] = React.useState<string | null>(null);
|
|
243
|
+
const ref = React.useRef<HTMLDivElement>(null);
|
|
244
|
+
|
|
245
|
+
const selectNext = () => {
|
|
246
|
+
if (ref.current) {
|
|
247
|
+
const checkedRadio: null | HTMLElement = ref.current.querySelector(
|
|
248
|
+
'[role=radio][aria-checked=true]'
|
|
249
|
+
);
|
|
250
|
+
const allRadios: Array<HTMLElement> = Array.from(ref.current.querySelectorAll('[role=radio]'));
|
|
251
|
+
if (allRadios.length === 0) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const index = checkedRadio ? allRadios.indexOf(checkedRadio) : 0;
|
|
255
|
+
const nextIndex = (index + 1) % allRadios.length;
|
|
256
|
+
const nextRadio = allRadios[nextIndex];
|
|
257
|
+
const value = nextRadio.dataset.value;
|
|
258
|
+
if (value) {
|
|
259
|
+
nextRadio.focus();
|
|
260
|
+
onChange(value);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const selectPrev = () => {
|
|
266
|
+
if (ref.current) {
|
|
267
|
+
const checkedRadio: null | HTMLElement = ref.current.querySelector(
|
|
268
|
+
'[role=radio][aria-checked=true]'
|
|
269
|
+
);
|
|
270
|
+
const allRadios: Array<HTMLElement> = Array.from(ref.current.querySelectorAll('[role=radio]'));
|
|
271
|
+
if (allRadios.length === 0) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const index = checkedRadio ? allRadios.indexOf(checkedRadio) : 0;
|
|
275
|
+
const prevIndex = (allRadios.length + index - 1) % allRadios.length;
|
|
276
|
+
const prevRadio = allRadios[prevIndex];
|
|
277
|
+
const value = prevRadio.dataset.value;
|
|
278
|
+
if (value) {
|
|
279
|
+
prevRadio.focus();
|
|
280
|
+
onChange(value);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
React.useEffect(() => {
|
|
286
|
+
if (ref.current) {
|
|
287
|
+
const radio: null | HTMLElement = ref.current.querySelector('[role=radio]');
|
|
288
|
+
if (radio) {
|
|
289
|
+
setFirstRadioValue(radio.dataset.value ?? null);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}, []);
|
|
293
|
+
|
|
294
|
+
const focusableValue = value ?? firstRadioValue ?? null;
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<div
|
|
298
|
+
ref={combineRefs(ref, focusableRef)}
|
|
299
|
+
id={id}
|
|
300
|
+
role="radiogroup"
|
|
301
|
+
aria-label={props['aria-label']}
|
|
302
|
+
aria-labelledby={props['aria-label'] ? undefined : props['aria-labelledby']}
|
|
303
|
+
{...getPrefixedDataAttributes(props.dataAttributes, 'RadioGroup')}
|
|
304
|
+
>
|
|
305
|
+
<RadioContext.Provider
|
|
306
|
+
value={{
|
|
307
|
+
id,
|
|
308
|
+
disabled,
|
|
309
|
+
selectedValue: value ?? defaultValue,
|
|
310
|
+
focusableValue,
|
|
311
|
+
select: onChange,
|
|
312
|
+
selectNext,
|
|
313
|
+
selectPrev,
|
|
314
|
+
}}
|
|
315
|
+
>
|
|
316
|
+
{props.children}
|
|
317
|
+
</RadioContext.Provider>
|
|
318
|
+
</div>
|
|
319
|
+
);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export default RadioButton;
|