@telefonica/mistica 16.59.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 +14 -2
- 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,370 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {assignInlineVars} from '@vanilla-extract/dynamic';
|
|
4
|
+
import {DialogRoot} from './dialog-context';
|
|
5
|
+
import ScreenSizeContextProvider from './screen-size-context-provider';
|
|
6
|
+
import {dimensions, getMisticaLinkComponent, NAVBAR_HEIGHT_MOBILE} from './theme';
|
|
7
|
+
import {getPlatform, isInsideNovumNativeApp} from './utils/platform';
|
|
8
|
+
import ThemeContext from './theme-context';
|
|
9
|
+
import {useIsomorphicLayoutEffect} from './hooks';
|
|
10
|
+
import TabFocus from './tab-focus';
|
|
11
|
+
import ModalContextProvider from './modal-context-provider';
|
|
12
|
+
import TooltipContextProvider from './tooltip-context-provider';
|
|
13
|
+
import {DocumentVisibilityProvider} from './utils/document-visibility';
|
|
14
|
+
import {AspectRatioSupportProvider} from './utils/aspect-ratio-support';
|
|
15
|
+
import {TrackingConfig} from './utils/analytics';
|
|
16
|
+
import {vars} from './skins/skin-contract.css';
|
|
17
|
+
import {fromHexToRgb} from './utils/color';
|
|
18
|
+
import {
|
|
19
|
+
defaultBorderRadiiConfig,
|
|
20
|
+
defaultSpacing,
|
|
21
|
+
defaultTextPresetsConfig,
|
|
22
|
+
defaultThemeVariantsConfig,
|
|
23
|
+
} from './skins/defaults';
|
|
24
|
+
import {isClientSide} from './utils/environment';
|
|
25
|
+
import {PACKAGE_VERSION} from './package-version';
|
|
26
|
+
import {SnackbarRoot} from './snackbar-context';
|
|
27
|
+
import {mapToWeight} from './text';
|
|
28
|
+
import * as mq from './media-queries.css';
|
|
29
|
+
import * as styles from './theme-context.css';
|
|
30
|
+
import {localeToLanguage} from './utils/locale';
|
|
31
|
+
|
|
32
|
+
import type {Colors, TextPresetsConfig} from './skins/types';
|
|
33
|
+
import type {Theme, ThemeConfig} from './theme';
|
|
34
|
+
import type {TextToken} from './text-tokens';
|
|
35
|
+
|
|
36
|
+
// Check there is only one version of mistica installed in the page.
|
|
37
|
+
if (process.env.NODE_ENV !== 'production' && isClientSide()) {
|
|
38
|
+
// @ts-expect-error __mistica_version__ does not exist in window
|
|
39
|
+
if (window['__mistica_version__'] && window['__mistica_version__'] !== PACKAGE_VERSION) {
|
|
40
|
+
throw new Error(`There is more than one version of @telefonica/mistica running on the same page`);
|
|
41
|
+
} else {
|
|
42
|
+
// @ts-expect-error __mistica_version__ does not exist in window
|
|
43
|
+
window['__mistica_version__'] = PACKAGE_VERSION;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const darkModeMedia = '(prefers-color-scheme: dark)';
|
|
48
|
+
export const useIsOsDarkModeEnabled = (): boolean => {
|
|
49
|
+
const [isDarkMode, setIsDarkMode] = React.useState(false);
|
|
50
|
+
|
|
51
|
+
useIsomorphicLayoutEffect(() => {
|
|
52
|
+
if (!window.matchMedia) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const mq = window.matchMedia(darkModeMedia);
|
|
57
|
+
|
|
58
|
+
const listener = () => {
|
|
59
|
+
setIsDarkMode(mq.matches);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
mq.addEventListener('change', listener);
|
|
63
|
+
listener();
|
|
64
|
+
|
|
65
|
+
return () => {
|
|
66
|
+
mq.removeEventListener('change', listener);
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
return isDarkMode;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
type Props = {
|
|
74
|
+
theme: ThemeConfig;
|
|
75
|
+
as?: string;
|
|
76
|
+
withoutStyles?: boolean;
|
|
77
|
+
children?: React.ReactNode;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const useDefaultHrefDecorator = () => {
|
|
81
|
+
return (href: string) => href;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const sanitizeDimensions = (dimensions: ThemeConfig['dimensions']): Partial<Theme['dimensions']> => {
|
|
85
|
+
return {
|
|
86
|
+
headerMobileHeight:
|
|
87
|
+
dimensions?.headerMobileHeight === 'mistica'
|
|
88
|
+
? NAVBAR_HEIGHT_MOBILE
|
|
89
|
+
: dimensions?.headerMobileHeight,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const SetupStackingContext = () => {
|
|
94
|
+
const ref = React.useRef<HTMLDivElement>(null);
|
|
95
|
+
const [hasContentIsolation, setHasContentIsolation] = React.useState(false);
|
|
96
|
+
const [isFirstRender, setIsFirstRender] = React.useState(true);
|
|
97
|
+
|
|
98
|
+
useIsomorphicLayoutEffect(() => {
|
|
99
|
+
if (isFirstRender) {
|
|
100
|
+
// Given that we don't render the extra div in server side, we skip creating it in the first client
|
|
101
|
+
// render in order to avoid hydration issues
|
|
102
|
+
setIsFirstRender(false);
|
|
103
|
+
} else {
|
|
104
|
+
// Set isolation: isolate to the parent of the provider. This way, we avoid content inside portals
|
|
105
|
+
// from being rendered under content that is inside the provider (in case it has z-index defined).
|
|
106
|
+
const root = ref.current?.parentElement;
|
|
107
|
+
if (root) {
|
|
108
|
+
root.style.isolation = 'isolate';
|
|
109
|
+
setHasContentIsolation(true);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, [isFirstRender]);
|
|
113
|
+
|
|
114
|
+
// Don't render the div in server side, because effects are not executed in there and it makes the div useless
|
|
115
|
+
if (hasContentIsolation || !isClientSide() || isFirstRender) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
return <div ref={ref} style={{display: 'none'}} />;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
type TextPresetsVars = {
|
|
122
|
+
[key in keyof TextPresetsConfig]: {
|
|
123
|
+
weight: string;
|
|
124
|
+
size: string;
|
|
125
|
+
lineHeight: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Define the same colors in css variables as rgb components, to allow applying alpha aftherwards. See utils/color.tsx
|
|
130
|
+
const makeRawColors = (colors: Colors): Colors =>
|
|
131
|
+
Object.fromEntries(
|
|
132
|
+
Object.entries(colors).map(([colorName, colorValue]) => {
|
|
133
|
+
let rawColorValue = '';
|
|
134
|
+
if (colorValue.startsWith('#')) {
|
|
135
|
+
const [r, g, b] = fromHexToRgb(colorValue);
|
|
136
|
+
rawColorValue = `${r}, ${g}, ${b}`;
|
|
137
|
+
}
|
|
138
|
+
return [colorName, rawColorValue];
|
|
139
|
+
})
|
|
140
|
+
) as Colors;
|
|
141
|
+
|
|
142
|
+
const ThemeContextProvider = ({theme, children, as, withoutStyles = false}: Props): JSX.Element => {
|
|
143
|
+
const isOsDarkModeEnabled = useIsOsDarkModeEnabled();
|
|
144
|
+
|
|
145
|
+
const colorScheme = theme.colorScheme ?? 'auto';
|
|
146
|
+
const lightColors: Colors = theme.skin.colors;
|
|
147
|
+
const darkColors: Colors = {...theme.skin.colors, ...theme.skin.darkModeColors};
|
|
148
|
+
const isDarkModeEnabled = (colorScheme === 'auto' && isOsDarkModeEnabled) || colorScheme === 'dark';
|
|
149
|
+
const colors: Colors = isDarkModeEnabled ? darkColors : lightColors;
|
|
150
|
+
|
|
151
|
+
const language = localeToLanguage(theme.i18n.locale);
|
|
152
|
+
|
|
153
|
+
const translate = React.useCallback(
|
|
154
|
+
(token: TextToken | string, ...params: Array<string | number>): string => {
|
|
155
|
+
const text = typeof token === 'string' ? token : token[language] || token.en;
|
|
156
|
+
if (!params.length) {
|
|
157
|
+
return text;
|
|
158
|
+
}
|
|
159
|
+
// replace token parameters: 1$s, 2$s, 3$s, etc.
|
|
160
|
+
return text.replace(/\d+\$s/g, (substr) => {
|
|
161
|
+
return String(params[parseInt(substr) - 1] ?? substr);
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
[language]
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const contextTheme = React.useMemo((): Theme => {
|
|
168
|
+
const platformOverrides = {
|
|
169
|
+
platform: getPlatform(),
|
|
170
|
+
insideNovumNativeApp: isInsideNovumNativeApp(),
|
|
171
|
+
...theme.platformOverrides,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const textTokenValues = Object.entries(defaultTextPresetsConfig).map(([token, defaultConfig]) => {
|
|
175
|
+
return {
|
|
176
|
+
[token]: {...defaultConfig, ...theme.skin.textPresets?.[token as keyof TextPresetsConfig]},
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const textPresets = Object.assign({}, ...textTokenValues) as TextPresetsConfig;
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
skinName: theme.skin.name,
|
|
184
|
+
i18n: {
|
|
185
|
+
...theme.i18n,
|
|
186
|
+
},
|
|
187
|
+
platformOverrides,
|
|
188
|
+
texts: {
|
|
189
|
+
...theme.texts,
|
|
190
|
+
},
|
|
191
|
+
analytics: {
|
|
192
|
+
logEvent: () => Promise.resolve(),
|
|
193
|
+
eventFormat: 'universal-analytics',
|
|
194
|
+
...theme.analytics,
|
|
195
|
+
},
|
|
196
|
+
colorValues: colors,
|
|
197
|
+
dimensions: {
|
|
198
|
+
...dimensions,
|
|
199
|
+
...sanitizeDimensions(theme.dimensions),
|
|
200
|
+
},
|
|
201
|
+
borderRadii: theme.skin.borderRadii ?? defaultBorderRadiiConfig,
|
|
202
|
+
textPresets,
|
|
203
|
+
spacing: theme.skin.spacing ?? defaultSpacing,
|
|
204
|
+
themeVariants: theme.skin.themeVariants ?? defaultThemeVariantsConfig,
|
|
205
|
+
Link: getMisticaLinkComponent(theme.Link),
|
|
206
|
+
isDarkMode: isDarkModeEnabled,
|
|
207
|
+
isIos: getPlatform(platformOverrides) === 'ios',
|
|
208
|
+
useHrefDecorator: theme.useHrefDecorator ?? useDefaultHrefDecorator,
|
|
209
|
+
t: translate,
|
|
210
|
+
preventCopyInFormFields: theme.preventCopyInFormFields ?? false,
|
|
211
|
+
};
|
|
212
|
+
}, [colors, theme, isDarkModeEnabled, translate]);
|
|
213
|
+
|
|
214
|
+
const textPresetsVars = React.useMemo(() => {
|
|
215
|
+
// Get an object mapping textPresets tokens to objects containing the token's weight
|
|
216
|
+
// For example, {title1: {weight: '700'}}
|
|
217
|
+
const tokenValues = Object.entries(contextTheme.textPresets).map(([token, config]) => {
|
|
218
|
+
// Map light/regular/medium/bold to valid css fontWeight values
|
|
219
|
+
return {
|
|
220
|
+
[token]: {
|
|
221
|
+
...(config.weight && {weight: String(mapToWeight[config.weight])}),
|
|
222
|
+
...(config.size && {size: `${config.size.desktop}px`}),
|
|
223
|
+
...(config.lineHeight && {lineHeight: `${config.lineHeight.desktop}px`}),
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
return Object.assign({}, ...tokenValues) as TextPresetsVars;
|
|
229
|
+
}, [contextTheme]);
|
|
230
|
+
|
|
231
|
+
const textPresetsResponsiveVars = React.useMemo(() => {
|
|
232
|
+
const tokenValues = Object.entries(contextTheme.textPresets).map(([token, config]) => {
|
|
233
|
+
return {
|
|
234
|
+
[token]: {
|
|
235
|
+
...(config.weight && {weight: String(mapToWeight[config.weight])}),
|
|
236
|
+
// Use mobile values for size/lineHeight
|
|
237
|
+
...(config.size && {size: `${config.size.mobile}px`}),
|
|
238
|
+
...(config.lineHeight && {lineHeight: `${config.lineHeight.mobile}px`}),
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
return Object.assign({}, ...tokenValues) as TextPresetsVars;
|
|
244
|
+
}, [contextTheme]);
|
|
245
|
+
|
|
246
|
+
const spacingDesktopVars = React.useMemo(() => {
|
|
247
|
+
const tokenValues = Object.entries(contextTheme.spacing).map(([token, values]) => {
|
|
248
|
+
return {
|
|
249
|
+
[token]: {
|
|
250
|
+
...('top' in values && {top: `${values.top.desktop}px`}),
|
|
251
|
+
...('right' in values && {right: `${values.right.desktop}px`}),
|
|
252
|
+
...('bottom' in values && {bottom: `${values.bottom.desktop}px`}),
|
|
253
|
+
...('left' in values && {left: `${values.left.desktop}px`}),
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
return Object.assign({}, ...tokenValues) as typeof vars.spacing;
|
|
258
|
+
}, [contextTheme]);
|
|
259
|
+
|
|
260
|
+
const spacingMobileVars = React.useMemo(() => {
|
|
261
|
+
const tokenValues = Object.entries(contextTheme.spacing).map(([token, values]) => {
|
|
262
|
+
return {
|
|
263
|
+
[token]: {
|
|
264
|
+
...('top' in values && {top: `${values.top.mobile}px`}),
|
|
265
|
+
...('right' in values && {right: `${values.right.mobile}px`}),
|
|
266
|
+
...('bottom' in values && {bottom: `${values.bottom.mobile}px`}),
|
|
267
|
+
...('left' in values && {left: `${values.left.mobile}px`}),
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
return Object.assign({}, ...tokenValues) as typeof vars.spacing;
|
|
272
|
+
}, [contextTheme]);
|
|
273
|
+
|
|
274
|
+
const renderStyles = (selector: string) => {
|
|
275
|
+
if (withoutStyles || (process.env.NODE_ENV === 'test' && !process.env.SSR_TEST)) {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const lightRawColors = makeRawColors(lightColors);
|
|
280
|
+
const darkRawColors = makeRawColors(darkColors);
|
|
281
|
+
|
|
282
|
+
const [defaultColors, defaultRawColors] =
|
|
283
|
+
colorScheme === 'auto' || colorScheme === 'light'
|
|
284
|
+
? [lightColors, lightRawColors]
|
|
285
|
+
: [darkColors, darkRawColors];
|
|
286
|
+
|
|
287
|
+
const darkModeMediaQuery =
|
|
288
|
+
colorScheme === 'auto'
|
|
289
|
+
? `@media (prefers-color-scheme: dark) {
|
|
290
|
+
${selector} {
|
|
291
|
+
${assignInlineVars(vars.colors, darkColors)};
|
|
292
|
+
${assignInlineVars(vars.rawColors, darkRawColors)}
|
|
293
|
+
}
|
|
294
|
+
}`
|
|
295
|
+
: '';
|
|
296
|
+
|
|
297
|
+
return (
|
|
298
|
+
<style>
|
|
299
|
+
{`
|
|
300
|
+
${selector} {
|
|
301
|
+
${assignInlineVars(vars, {
|
|
302
|
+
colors: defaultColors,
|
|
303
|
+
rawColors: defaultRawColors,
|
|
304
|
+
textPresets: textPresetsVars,
|
|
305
|
+
borderRadii: theme.skin.borderRadii ?? defaultBorderRadiiConfig,
|
|
306
|
+
spacing: spacingDesktopVars,
|
|
307
|
+
})}
|
|
308
|
+
}
|
|
309
|
+
@media ${mq.tabletOrSmaller} {
|
|
310
|
+
${selector} {
|
|
311
|
+
${assignInlineVars(vars.textPresets, textPresetsResponsiveVars)}
|
|
312
|
+
${assignInlineVars(vars.spacing, spacingMobileVars)}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
${darkModeMediaQuery}
|
|
316
|
+
`}
|
|
317
|
+
</style>
|
|
318
|
+
);
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
return (
|
|
322
|
+
<>
|
|
323
|
+
<TabFocus disabled={!theme.enableTabFocus}>
|
|
324
|
+
<ModalContextProvider>
|
|
325
|
+
<TooltipContextProvider>
|
|
326
|
+
<ThemeContext.Provider value={contextTheme}>
|
|
327
|
+
<TrackingConfig eventFormat={contextTheme.analytics.eventFormat}>
|
|
328
|
+
<AspectRatioSupportProvider>
|
|
329
|
+
<DocumentVisibilityProvider>
|
|
330
|
+
<ScreenSizeContextProvider>
|
|
331
|
+
<DialogRoot>
|
|
332
|
+
<SnackbarRoot>
|
|
333
|
+
{as ? (
|
|
334
|
+
<>
|
|
335
|
+
{renderStyles(`.${styles.themeVars}`)}
|
|
336
|
+
{React.createElement(
|
|
337
|
+
as,
|
|
338
|
+
{
|
|
339
|
+
style: {
|
|
340
|
+
isolation: 'isolate',
|
|
341
|
+
},
|
|
342
|
+
className: withoutStyles
|
|
343
|
+
? undefined
|
|
344
|
+
: styles.themeVars,
|
|
345
|
+
},
|
|
346
|
+
children
|
|
347
|
+
)}
|
|
348
|
+
</>
|
|
349
|
+
) : (
|
|
350
|
+
<>
|
|
351
|
+
{renderStyles(':root')}
|
|
352
|
+
{children}
|
|
353
|
+
</>
|
|
354
|
+
)}
|
|
355
|
+
</SnackbarRoot>
|
|
356
|
+
</DialogRoot>
|
|
357
|
+
</ScreenSizeContextProvider>
|
|
358
|
+
</DocumentVisibilityProvider>
|
|
359
|
+
</AspectRatioSupportProvider>
|
|
360
|
+
</TrackingConfig>
|
|
361
|
+
</ThemeContext.Provider>
|
|
362
|
+
</TooltipContextProvider>
|
|
363
|
+
</ModalContextProvider>
|
|
364
|
+
</TabFocus>
|
|
365
|
+
{!as && <SetupStackingContext />}
|
|
366
|
+
</>
|
|
367
|
+
);
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export default ThemeContextProvider;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
export type NonDeprecatedVariant = 'default' | 'brand' | 'negative' | 'alternative' | 'media';
|
|
5
|
+
|
|
6
|
+
export type Variant =
|
|
7
|
+
| 'default'
|
|
8
|
+
| 'brand'
|
|
9
|
+
| 'negative'
|
|
10
|
+
| 'alternative'
|
|
11
|
+
| 'media'
|
|
12
|
+
/** @deprecated use 'brand' instead */
|
|
13
|
+
| 'inverse';
|
|
14
|
+
|
|
15
|
+
export const normalizeVariant = <T extends Variant>(variant: T): T extends 'inverse' ? 'brand' : T => {
|
|
16
|
+
if (variant === 'inverse') {
|
|
17
|
+
return 'brand' as T extends 'inverse' ? 'brand' : T;
|
|
18
|
+
}
|
|
19
|
+
return variant as T extends 'inverse' ? 'brand' : T;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const ThemeVariantContext = React.createContext<Variant>('default');
|
|
23
|
+
|
|
24
|
+
type ThemeVariantProps = {
|
|
25
|
+
/** @deprecated Use variant = 'brand' instead */
|
|
26
|
+
isInverse?: boolean;
|
|
27
|
+
variant?: Variant;
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const ThemeVariant = ({isInverse, variant, children}: ThemeVariantProps): JSX.Element => (
|
|
32
|
+
<ThemeVariantContext.Provider value={variant ?? (isInverse ? 'brand' : 'default')}>
|
|
33
|
+
{children}
|
|
34
|
+
</ThemeVariantContext.Provider>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export const useThemeVariant = (): NonDeprecatedVariant =>
|
|
38
|
+
normalizeVariant(React.useContext(ThemeVariantContext));
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated use `useThemeVariant` instead
|
|
42
|
+
*/
|
|
43
|
+
export const useIsInverseVariant = (): boolean => useThemeVariant() === 'brand';
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated use `useThemeVariant` instead
|
|
47
|
+
*/
|
|
48
|
+
export const useIsInverseOrMediaVariant = (): boolean => {
|
|
49
|
+
const variant = useThemeVariant();
|
|
50
|
+
return variant === 'brand' || variant === 'media';
|
|
51
|
+
};
|
package/src/theme.tsx
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import type {RegionCode} from './utils/region-code';
|
|
4
|
+
import type {Locale} from './utils/locale';
|
|
5
|
+
import type {
|
|
6
|
+
BorderRadiiConfig,
|
|
7
|
+
Colors,
|
|
8
|
+
Skin,
|
|
9
|
+
SkinName,
|
|
10
|
+
SpacingConfig,
|
|
11
|
+
TextPresetsConfig,
|
|
12
|
+
ThemeVariantsConfig,
|
|
13
|
+
} from './skins/types';
|
|
14
|
+
import type {TrackingEvent} from './utils/types';
|
|
15
|
+
import type {Dictionary, TextToken} from './text-tokens';
|
|
16
|
+
|
|
17
|
+
export const NAVBAR_HEIGHT_MOBILE = 56;
|
|
18
|
+
export const NAVBAR_HEIGHT_DESKTOP = 80;
|
|
19
|
+
export const NAVBAR_HEIGHT_DESKTOP_LARGE = 2 * NAVBAR_HEIGHT_DESKTOP;
|
|
20
|
+
|
|
21
|
+
export const dimensions = {
|
|
22
|
+
headerMobileHeight: NAVBAR_HEIGHT_MOBILE,
|
|
23
|
+
headerDesktopHeight: NAVBAR_HEIGHT_DESKTOP,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* https://reactrouter.com/en/main/components/link
|
|
28
|
+
* https://nextjs.org/docs/app/api-reference/components/link
|
|
29
|
+
*/
|
|
30
|
+
type LinkComponent = React.ComponentType<{
|
|
31
|
+
style?: React.CSSProperties;
|
|
32
|
+
className?: string;
|
|
33
|
+
'aria-label'?: string;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
role?: string;
|
|
36
|
+
'data-testid'?: string;
|
|
37
|
+
'aria-checked'?: React.AnchorHTMLAttributes<HTMLAnchorElement>['aria-checked'];
|
|
38
|
+
'aria-controls'?: string;
|
|
39
|
+
'aria-expanded'?: React.AnchorHTMLAttributes<HTMLAnchorElement>['aria-expanded'];
|
|
40
|
+
'aria-hidden'?: React.AnchorHTMLAttributes<HTMLAnchorElement>['aria-hidden'];
|
|
41
|
+
'aria-selected'?: React.AnchorHTMLAttributes<HTMLAnchorElement>['aria-selected'];
|
|
42
|
+
tabIndex?: number;
|
|
43
|
+
innerRef?: React.RefObject<HTMLAnchorElement>;
|
|
44
|
+
to:
|
|
45
|
+
| string
|
|
46
|
+
| {
|
|
47
|
+
pathname?: string;
|
|
48
|
+
search?: string;
|
|
49
|
+
state?: unknown;
|
|
50
|
+
hash?: string;
|
|
51
|
+
key?: string;
|
|
52
|
+
};
|
|
53
|
+
replace?: boolean;
|
|
54
|
+
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
|
55
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLAnchorElement>;
|
|
56
|
+
children: React.ReactNode;
|
|
57
|
+
target?: string;
|
|
58
|
+
}>;
|
|
59
|
+
|
|
60
|
+
const AnchorLink: LinkComponent = ({to, innerRef, ...props}) => (
|
|
61
|
+
<a ref={innerRef} href={typeof to === 'string' ? to : to?.pathname} {...props}>
|
|
62
|
+
{props.children}
|
|
63
|
+
</a>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const getReactRouter5Link = (ReactRouterLink: React.ComponentType<any>): LinkComponent => ReactRouterLink;
|
|
67
|
+
|
|
68
|
+
const getReactRouter6Link =
|
|
69
|
+
(ReactRouterLink: React.ComponentType<any>): LinkComponent =>
|
|
70
|
+
({innerRef, ...props}) => <ReactRouterLink ref={innerRef} {...props} />;
|
|
71
|
+
|
|
72
|
+
const getNext12Link =
|
|
73
|
+
(NextLink: React.ComponentType<any>): LinkComponent =>
|
|
74
|
+
({to, innerRef, children, ...props}) => (
|
|
75
|
+
<NextLink href={to}>
|
|
76
|
+
<a ref={innerRef} {...props}>
|
|
77
|
+
{children}
|
|
78
|
+
</a>
|
|
79
|
+
</NextLink>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const getNext13Or14Link =
|
|
83
|
+
(NextLink: React.ComponentType<any>): LinkComponent =>
|
|
84
|
+
({to, innerRef, children, ...props}) => (
|
|
85
|
+
<NextLink href={to} ref={innerRef} {...props}>
|
|
86
|
+
{children}
|
|
87
|
+
</NextLink>
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
export const getMisticaLinkComponent = (Link?: ThemeConfig['Link']): LinkComponent => {
|
|
91
|
+
if (!Link) {
|
|
92
|
+
return AnchorLink;
|
|
93
|
+
}
|
|
94
|
+
// the $$typeof check is because components like forwardRefs are objects
|
|
95
|
+
// see https://github.com/facebook/react/blob/main/packages/shared/isValidElementType.js
|
|
96
|
+
if (typeof Link === 'function' || (Link as any).$$typeof) {
|
|
97
|
+
return Link as LinkComponent;
|
|
98
|
+
}
|
|
99
|
+
switch (Link.type) {
|
|
100
|
+
case 'ReactRouter5':
|
|
101
|
+
// webapp, flow-frontend
|
|
102
|
+
return getReactRouter5Link(Link.Component);
|
|
103
|
+
case 'ReactRouter6':
|
|
104
|
+
// nt_core
|
|
105
|
+
return getReactRouter6Link(Link.Component);
|
|
106
|
+
case 'Next12':
|
|
107
|
+
// zeus-web
|
|
108
|
+
return getNext12Link(Link.Component);
|
|
109
|
+
case 'Next13':
|
|
110
|
+
case 'Next14':
|
|
111
|
+
// hello-world-web, global-checkout-webview
|
|
112
|
+
return getNext13Or14Link(Link.Component);
|
|
113
|
+
default:
|
|
114
|
+
const exhaustiveCheck: never = Link.type;
|
|
115
|
+
throw new Error(`Invalid Link type: ${exhaustiveCheck}`);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type ColorScheme = 'dark' | 'light' | 'auto';
|
|
120
|
+
export type EventFormat = 'universal-analytics' | 'google-analytics-4';
|
|
121
|
+
|
|
122
|
+
// This is the type expected by ThemeContextProvider theme prop.
|
|
123
|
+
// This config is provided by the user of the lib
|
|
124
|
+
export type ThemeConfig = Readonly<{
|
|
125
|
+
skin: Readonly<Skin>;
|
|
126
|
+
colorScheme?: ColorScheme; // light by default. TODO: Change to auto by default in next major version
|
|
127
|
+
i18n: Readonly<{
|
|
128
|
+
locale: Locale;
|
|
129
|
+
phoneNumberFormattingRegionCode: RegionCode;
|
|
130
|
+
}>;
|
|
131
|
+
platformOverrides?: Readonly<{
|
|
132
|
+
platform?: 'ios' | 'android' | 'desktop';
|
|
133
|
+
insideNovumNativeApp?: boolean;
|
|
134
|
+
userAgent?: string;
|
|
135
|
+
}>;
|
|
136
|
+
texts?: Partial<Dictionary>;
|
|
137
|
+
analytics?: Readonly<{
|
|
138
|
+
logEvent: (trackingEvent: TrackingEvent) => Promise<void>;
|
|
139
|
+
eventFormat?: EventFormat;
|
|
140
|
+
}>;
|
|
141
|
+
dimensions?: Readonly<{headerMobileHeight: number | 'mistica'}>;
|
|
142
|
+
Link?:
|
|
143
|
+
| LinkComponent
|
|
144
|
+
| {
|
|
145
|
+
type: 'ReactRouter5' | 'ReactRouter6' | 'Next12' | 'Next13' | 'Next14';
|
|
146
|
+
Component: React.ComponentType<any>;
|
|
147
|
+
};
|
|
148
|
+
useHrefDecorator?: () => (href: string) => string;
|
|
149
|
+
/** @deprecated Better use default browser behavior for :focus-visible */
|
|
150
|
+
enableTabFocus?: boolean;
|
|
151
|
+
preventCopyInFormFields?: boolean;
|
|
152
|
+
}>;
|
|
153
|
+
|
|
154
|
+
// This is the lib INTERNAL context
|
|
155
|
+
export type Theme = {
|
|
156
|
+
skinName: SkinName;
|
|
157
|
+
i18n: {
|
|
158
|
+
locale: Locale;
|
|
159
|
+
phoneNumberFormattingRegionCode: RegionCode;
|
|
160
|
+
};
|
|
161
|
+
platformOverrides: {
|
|
162
|
+
platform?: 'ios' | 'android' | 'desktop';
|
|
163
|
+
insideNovumNativeApp?: boolean;
|
|
164
|
+
userAgent?: string;
|
|
165
|
+
};
|
|
166
|
+
texts: Partial<Dictionary>;
|
|
167
|
+
analytics: {
|
|
168
|
+
logEvent: (trackingEvent: TrackingEvent) => Promise<void>;
|
|
169
|
+
eventFormat: EventFormat;
|
|
170
|
+
};
|
|
171
|
+
// TODO: rename this props to navigationBarHeight (or something similar) in next major
|
|
172
|
+
dimensions: {headerMobileHeight: number; headerDesktopHeight: number};
|
|
173
|
+
colorValues: Colors;
|
|
174
|
+
borderRadii: BorderRadiiConfig;
|
|
175
|
+
textPresets: TextPresetsConfig;
|
|
176
|
+
spacing: SpacingConfig;
|
|
177
|
+
themeVariants: ThemeVariantsConfig;
|
|
178
|
+
Link: LinkComponent;
|
|
179
|
+
isDarkMode: boolean;
|
|
180
|
+
isIos: boolean;
|
|
181
|
+
useHrefDecorator: () => (href: string) => string;
|
|
182
|
+
t: (token: TextToken | string, ...params: Array<string | number>) => string;
|
|
183
|
+
preventCopyInFormFields: boolean;
|
|
184
|
+
};
|