@telefonica/mistica 16.58.0-beta.2 → 16.59.0-beta.1
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-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/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 +31 -30
- 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-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/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 +33 -32
- 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 +35 -11
- package/doc/patterns.md +22 -20
- 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 +62 -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 +215 -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 +345 -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 +159 -0
- package/src/text-field-components.tsx +225 -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,34 @@
|
|
|
1
|
+
import {style} from '@vanilla-extract/css';
|
|
2
|
+
import {vars} from './skins/skin-contract.css';
|
|
3
|
+
import {sprinkles} from './sprinkles.css';
|
|
4
|
+
import {screenReaderOnlyStyles} from './screen-reader-only.css';
|
|
5
|
+
|
|
6
|
+
export const skipLinkContainer = style([
|
|
7
|
+
sprinkles({
|
|
8
|
+
background: vars.colors.backgroundContainer,
|
|
9
|
+
border: 'regular',
|
|
10
|
+
borderRadius: vars.borderRadii.container,
|
|
11
|
+
padding: 8,
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
top: 0,
|
|
14
|
+
left: 0,
|
|
15
|
+
}),
|
|
16
|
+
{
|
|
17
|
+
width: 'fit-content',
|
|
18
|
+
boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.2)',
|
|
19
|
+
opacity: 1,
|
|
20
|
+
transition: 'opacity 0.15s ease-in-out',
|
|
21
|
+
selectors: {
|
|
22
|
+
'&:not(:focus-within)': {
|
|
23
|
+
...screenReaderOnlyStyles,
|
|
24
|
+
opacity: 0,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
export const skipLinkList = style({
|
|
31
|
+
listStyle: 'none',
|
|
32
|
+
padding: 0,
|
|
33
|
+
margin: 0,
|
|
34
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {ButtonLink} from './button';
|
|
4
|
+
import * as styles from './skip-link.css';
|
|
5
|
+
import {useTheme} from './hooks';
|
|
6
|
+
import * as tokens from './text-tokens';
|
|
7
|
+
import {getPrefixedDataAttributes} from './utils/dom';
|
|
8
|
+
|
|
9
|
+
import type {DataAttributes} from './utils/types';
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
targetId: string;
|
|
13
|
+
'aria-label'?: string;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
dataAttributes?: DataAttributes;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const SkipLink = ({targetId, children, 'aria-label': ariaLabel, dataAttributes}: Props): JSX.Element => {
|
|
19
|
+
return (
|
|
20
|
+
<div className={styles.skipLinkContainer} {...getPrefixedDataAttributes(dataAttributes, 'SkipLink')}>
|
|
21
|
+
<ButtonLink aria-label={ariaLabel} href={`#${targetId}`} withChevron={false}>
|
|
22
|
+
{children}
|
|
23
|
+
</ButtonLink>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type SkipLinkNavProps = {
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
'aria-label'?: string;
|
|
31
|
+
dataAttributes?: DataAttributes;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const SkipLinkNav = ({
|
|
35
|
+
children,
|
|
36
|
+
'aria-label': ariaLabel,
|
|
37
|
+
dataAttributes,
|
|
38
|
+
}: SkipLinkNavProps): JSX.Element => {
|
|
39
|
+
const {texts, t} = useTheme();
|
|
40
|
+
const navLabel = ariaLabel || texts.skipLinkNavLabel || t(tokens.skipLinkNavLabel);
|
|
41
|
+
return (
|
|
42
|
+
<nav aria-label={navLabel} {...getPrefixedDataAttributes(dataAttributes, 'SkipLinkNav')}>
|
|
43
|
+
<ul className={styles.skipLinkList}>
|
|
44
|
+
{React.Children.map(children, (child) => (
|
|
45
|
+
<li>{child}</li>
|
|
46
|
+
))}
|
|
47
|
+
</ul>
|
|
48
|
+
</nav>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default SkipLink;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import {style, styleVariants} from '@vanilla-extract/css';
|
|
2
|
+
import {vars} from './skins/skin-contract.css';
|
|
3
|
+
import * as mq from './media-queries.css';
|
|
4
|
+
import {applyAlpha} from './utils/color';
|
|
5
|
+
import {sprinkles} from './sprinkles.css';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_THUMB_SIZE = 20;
|
|
8
|
+
const IOS_THUMB_SIZE = 28;
|
|
9
|
+
|
|
10
|
+
export const container = style([
|
|
11
|
+
sprinkles({
|
|
12
|
+
width: '100%',
|
|
13
|
+
position: 'relative',
|
|
14
|
+
display: 'flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
cursor: 'pointer',
|
|
17
|
+
}),
|
|
18
|
+
{
|
|
19
|
+
touchAction: 'none',
|
|
20
|
+
userSelect: 'none',
|
|
21
|
+
},
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
export const disabled = style({
|
|
25
|
+
opacity: 0.5,
|
|
26
|
+
pointerEvents: 'none',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const track = sprinkles({
|
|
30
|
+
width: '100%',
|
|
31
|
+
height: 4,
|
|
32
|
+
borderRadius: vars.borderRadii.bar,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const thumbContainer = style([
|
|
36
|
+
sprinkles({
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
display: 'flex',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
}),
|
|
42
|
+
{
|
|
43
|
+
top: '50%',
|
|
44
|
+
transform: 'translateY(-50%)',
|
|
45
|
+
WebkitTapHighlightColor: 'transparent',
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
const defaultThumbBase = style([
|
|
50
|
+
sprinkles({
|
|
51
|
+
width: DEFAULT_THUMB_SIZE,
|
|
52
|
+
height: DEFAULT_THUMB_SIZE,
|
|
53
|
+
borderRadius: '50%',
|
|
54
|
+
}),
|
|
55
|
+
{
|
|
56
|
+
transition: '0.3s cubic-bezier(0.215, 0.61, 0.355, 1)',
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
export const defaultThumb = styleVariants({
|
|
61
|
+
default: [defaultThumbBase, sprinkles({background: vars.colors.controlActivated})],
|
|
62
|
+
alternative: [defaultThumbBase, sprinkles({background: vars.colors.controlActivated})],
|
|
63
|
+
brand: [defaultThumbBase, sprinkles({background: vars.colors.controlActivatedBrand})],
|
|
64
|
+
media: [defaultThumbBase, sprinkles({background: vars.colors.controlActivatedBrand})],
|
|
65
|
+
negative: [defaultThumbBase, sprinkles({background: vars.colors.controlActivatedNegative})],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const iosThumb = style([
|
|
69
|
+
sprinkles({
|
|
70
|
+
background: vars.colors.iosControlKnob,
|
|
71
|
+
borderRadius: '50%',
|
|
72
|
+
}),
|
|
73
|
+
{
|
|
74
|
+
width: IOS_THUMB_SIZE,
|
|
75
|
+
height: IOS_THUMB_SIZE,
|
|
76
|
+
border: ' 0.5px solid rgba(0, 0, 0, 0.04)',
|
|
77
|
+
boxSizing: 'border-box',
|
|
78
|
+
boxShadow: '0px 0.5px 4px rgba(0, 0, 0, 0.12), 0px 6px 13px rgba(0, 0, 0, 0.12)',
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
export const thumbHover = styleVariants({
|
|
83
|
+
default: [
|
|
84
|
+
{
|
|
85
|
+
'@media': {
|
|
86
|
+
[mq.supportsHover]: {
|
|
87
|
+
boxShadow: `0 0 0 5px ${applyAlpha(vars.rawColors.controlActivated, 0.2)}`,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
alternative: [
|
|
93
|
+
{
|
|
94
|
+
'@media': {
|
|
95
|
+
[mq.supportsHover]: {
|
|
96
|
+
boxShadow: `0 0 0 5px ${applyAlpha(vars.rawColors.controlActivated, 0.2)}`,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
brand: [
|
|
102
|
+
{
|
|
103
|
+
'@media': {
|
|
104
|
+
[mq.supportsHover]: {
|
|
105
|
+
boxShadow: `0 0 0 5px ${applyAlpha(vars.rawColors.controlActivatedBrand, 0.2)}`,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
media: [
|
|
111
|
+
{
|
|
112
|
+
'@media': {
|
|
113
|
+
[mq.supportsHover]: {
|
|
114
|
+
boxShadow: `0 0 0 5px ${applyAlpha(vars.rawColors.controlActivatedBrand, 0.2)}`,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
negative: [
|
|
120
|
+
{
|
|
121
|
+
'@media': {
|
|
122
|
+
[mq.supportsHover]: {
|
|
123
|
+
boxShadow: `0 0 0 5px ${applyAlpha(vars.rawColors.controlActivatedNegative, 0.2)}`,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export const thumbActive = styleVariants({
|
|
131
|
+
default: [
|
|
132
|
+
{
|
|
133
|
+
boxShadow: `0 0 0 8px ${applyAlpha(vars.rawColors.controlActivated, 0.2)}`,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
alternative: [
|
|
137
|
+
{
|
|
138
|
+
boxShadow: `0 0 0 8px ${applyAlpha(vars.rawColors.controlActivated, 0.2)}`,
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
brand: [
|
|
142
|
+
{
|
|
143
|
+
boxShadow: `0 0 0 8px ${applyAlpha(vars.rawColors.controlActivatedBrand, 0.2)}`,
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
media: [
|
|
147
|
+
{
|
|
148
|
+
boxShadow: `0 0 0 8px ${applyAlpha(vars.rawColors.controlActivatedBrand, 0.2)}`,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
negative: [
|
|
152
|
+
{
|
|
153
|
+
boxShadow: `0 0 0 8px ${applyAlpha(vars.rawColors.controlActivatedNegative, 0.2)}`,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
export const input = style([
|
|
159
|
+
sprinkles({
|
|
160
|
+
position: 'absolute',
|
|
161
|
+
top: 0,
|
|
162
|
+
}),
|
|
163
|
+
{
|
|
164
|
+
zIndex: 1,
|
|
165
|
+
margin: 0,
|
|
166
|
+
appearance: 'none',
|
|
167
|
+
WebkitAppearance: 'none',
|
|
168
|
+
pointerEvents: 'none',
|
|
169
|
+
background: 'transparent',
|
|
170
|
+
'::-webkit-slider-thumb': {
|
|
171
|
+
appearance: 'none',
|
|
172
|
+
WebkitAppearance: 'none',
|
|
173
|
+
pointerEvents: 'none',
|
|
174
|
+
},
|
|
175
|
+
'::-moz-range-thumb': {
|
|
176
|
+
border: 'none',
|
|
177
|
+
background: 'transparent',
|
|
178
|
+
pointerEvents: 'none',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
]);
|
package/src/slider.tsx
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as styles from './slider.css';
|
|
4
|
+
import {vars} from './skins/skin-contract.css';
|
|
5
|
+
import {isTouchableDevice} from './utils/environment';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import {cancelEvent} from './utils/dom';
|
|
8
|
+
import {useTheme} from './hooks';
|
|
9
|
+
import Tooltip from './tooltip';
|
|
10
|
+
import Box from './box';
|
|
11
|
+
import {useControlProps} from './form-context';
|
|
12
|
+
import {combineRefs} from './utils/common';
|
|
13
|
+
import {useThemeVariant} from './theme-variant-context';
|
|
14
|
+
|
|
15
|
+
import type {ExclusifyUnion} from './utils/utility-types';
|
|
16
|
+
import type {DataAttributes} from './utils/types';
|
|
17
|
+
|
|
18
|
+
const MOBILE_TOUCHABLE_AREA = 48;
|
|
19
|
+
const DEFAULT_THUMB_SIZE = 20;
|
|
20
|
+
const IOS_THUMB_SIZE = 28;
|
|
21
|
+
|
|
22
|
+
interface BaseSliderProps {
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
value?: number;
|
|
25
|
+
defaultValue?: number;
|
|
26
|
+
onChangeValue?: (value: number) => void;
|
|
27
|
+
tooltip?: boolean;
|
|
28
|
+
dataAttributes?: DataAttributes;
|
|
29
|
+
name: string;
|
|
30
|
+
'aria-label'?: string;
|
|
31
|
+
'aria-labelledby'?: string;
|
|
32
|
+
id?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface SliderWithValuesProps {
|
|
36
|
+
values: ReadonlyArray<number>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface SliderWithStepProps {
|
|
40
|
+
step?: number;
|
|
41
|
+
min?: number;
|
|
42
|
+
max?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type SliderProps = BaseSliderProps & ExclusifyUnion<SliderWithStepProps | SliderWithValuesProps>;
|
|
46
|
+
|
|
47
|
+
const getSliderValueAsPercentage = (value: number, min: number, max: number) => {
|
|
48
|
+
return min >= max ? 0 : (value - min) / (max - min);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const getValueInRange = (isPercentage: boolean, min: number, max: number, step: number, value?: number) => {
|
|
52
|
+
const getRealValue = (value?: number) => {
|
|
53
|
+
if (value === undefined) {
|
|
54
|
+
return min;
|
|
55
|
+
}
|
|
56
|
+
const realValue = isPercentage ? min + (max - min) * value : value;
|
|
57
|
+
return Math.max(min, Math.min(max, realValue));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
if (min >= max) {
|
|
61
|
+
return min;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const currentValue = getRealValue(value);
|
|
65
|
+
const valueRoundedDown = min + Math.floor((currentValue - min) / step) * step;
|
|
66
|
+
const valueRoundedUp = min + Math.ceil((currentValue - min) / step) * step;
|
|
67
|
+
|
|
68
|
+
return valueRoundedUp <= max && valueRoundedUp - currentValue <= currentValue - valueRoundedDown
|
|
69
|
+
? valueRoundedUp
|
|
70
|
+
: valueRoundedDown;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const getClosestValidValue = (min: number, value?: number, values?: ReadonlyArray<number>) => {
|
|
74
|
+
if (!values) {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
if (value === undefined) {
|
|
78
|
+
return min;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let closestIndex = 0;
|
|
82
|
+
values.forEach((currentValue, index) => {
|
|
83
|
+
if (values && Math.abs(currentValue - value) <= Math.abs(values[closestIndex] - value)) {
|
|
84
|
+
closestIndex = index;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return closestIndex;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const Slider = React.forwardRef<HTMLInputElement, SliderProps>(
|
|
91
|
+
(
|
|
92
|
+
{
|
|
93
|
+
values,
|
|
94
|
+
step = 1,
|
|
95
|
+
min = 0,
|
|
96
|
+
max = 100,
|
|
97
|
+
'aria-label': ariaLabel,
|
|
98
|
+
'aria-labelledby': ariaLabelledBy,
|
|
99
|
+
id,
|
|
100
|
+
dataAttributes,
|
|
101
|
+
tooltip,
|
|
102
|
+
...props
|
|
103
|
+
},
|
|
104
|
+
ref
|
|
105
|
+
) => {
|
|
106
|
+
if (values) {
|
|
107
|
+
if (values.length === 0) {
|
|
108
|
+
values = undefined;
|
|
109
|
+
} else {
|
|
110
|
+
max = values.length - 1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
step = step | 0;
|
|
115
|
+
step = step <= 0 ? 1 : step;
|
|
116
|
+
|
|
117
|
+
const {
|
|
118
|
+
defaultValue,
|
|
119
|
+
value,
|
|
120
|
+
onChange: onChangeValue,
|
|
121
|
+
focusableRef,
|
|
122
|
+
disabled,
|
|
123
|
+
name,
|
|
124
|
+
} = useControlProps({
|
|
125
|
+
name: props.name,
|
|
126
|
+
label: ariaLabel,
|
|
127
|
+
value:
|
|
128
|
+
props.value !== undefined
|
|
129
|
+
? getValueInRange(false, min, max, step, getClosestValidValue(min, props.value, values))
|
|
130
|
+
: undefined,
|
|
131
|
+
defaultValue:
|
|
132
|
+
props.defaultValue !== undefined
|
|
133
|
+
? getValueInRange(
|
|
134
|
+
false,
|
|
135
|
+
min,
|
|
136
|
+
max,
|
|
137
|
+
step,
|
|
138
|
+
getClosestValidValue(min, props.defaultValue, values)
|
|
139
|
+
)
|
|
140
|
+
: undefined,
|
|
141
|
+
onChange: props.onChangeValue,
|
|
142
|
+
disabled: props.disabled,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const [currentValue, setCurrentValue] = React.useState(
|
|
146
|
+
value ?? getValueInRange(false, min, max, step, getClosestValidValue(min, defaultValue, values))
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const finalValue = value ?? currentValue;
|
|
150
|
+
|
|
151
|
+
const prevValueRef = React.useRef(finalValue);
|
|
152
|
+
|
|
153
|
+
const handleChange = React.useCallback(
|
|
154
|
+
(value: number, isPercentage: boolean) => {
|
|
155
|
+
const realValue = getValueInRange(isPercentage, min, max, step, value);
|
|
156
|
+
if (prevValueRef.current !== realValue) {
|
|
157
|
+
onChangeValue(values ? values[realValue] : realValue);
|
|
158
|
+
setCurrentValue(realValue);
|
|
159
|
+
prevValueRef.current = realValue;
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
[min, max, step, values, onChangeValue]
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* HandleChange will trigger this useEffect whenever min/max/step props change.
|
|
167
|
+
* This allows the slider to be reactive to changes in these props.
|
|
168
|
+
*/
|
|
169
|
+
React.useEffect(() => {
|
|
170
|
+
handleChange(prevValueRef.current, false);
|
|
171
|
+
}, [handleChange]);
|
|
172
|
+
|
|
173
|
+
const trackRef = React.useRef<HTMLDivElement>(null);
|
|
174
|
+
const thumbRef = React.useRef<HTMLDivElement>(null);
|
|
175
|
+
const sliderRef = React.useRef<HTMLDivElement>(null);
|
|
176
|
+
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
177
|
+
|
|
178
|
+
const [isPointerDown, setIsPointerDown] = React.useState(false);
|
|
179
|
+
const [isThumbHovered, setIsThumbHovered] = React.useState(false);
|
|
180
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
181
|
+
const {isIos} = useTheme();
|
|
182
|
+
const themeVariant = useThemeVariant();
|
|
183
|
+
|
|
184
|
+
const isPointerOverElement = (element: HTMLElement | null, x: number, y: number) => {
|
|
185
|
+
const box = element?.getBoundingClientRect();
|
|
186
|
+
return !!box && box.left <= x && x <= box.right && box.top <= y && y <= box.bottom;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const isTouchable = isTouchableDevice();
|
|
190
|
+
|
|
191
|
+
const thumbSize = isIos ? IOS_THUMB_SIZE : DEFAULT_THUMB_SIZE;
|
|
192
|
+
const touchableArea = isTouchable ? MOBILE_TOUCHABLE_AREA : thumbSize;
|
|
193
|
+
|
|
194
|
+
const updateCurrentValue = (pointerPosition: number) => {
|
|
195
|
+
const track = trackRef.current;
|
|
196
|
+
if (track) {
|
|
197
|
+
const leftBorder = track.getBoundingClientRect().left + thumbSize / 2;
|
|
198
|
+
const rightBorder = track.getBoundingClientRect().right - thumbSize / 2;
|
|
199
|
+
handleChange((pointerPosition - leftBorder) / (rightBorder - leftBorder), true);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const onPointerMove = (e: PointerEvent) => {
|
|
204
|
+
cancelEvent(e);
|
|
205
|
+
updateCurrentValue(e.clientX);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const capturePointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
209
|
+
const thumb = thumbRef.current;
|
|
210
|
+
if (thumb) {
|
|
211
|
+
thumb.onpointermove = onPointerMove;
|
|
212
|
+
/**
|
|
213
|
+
* There is a known firefox bug caused by using setPointerCapture().
|
|
214
|
+
* If you press the slider, drag the pointer on top of a button and then release it,
|
|
215
|
+
* the button will be clicked. The issue doesn't happen in Chrome or Safari, and it
|
|
216
|
+
* can be reproduced by using basic HTML (https://codepen.io/Marcos-Kolodny/pen/oNmdMxM).
|
|
217
|
+
*
|
|
218
|
+
* This was reported to firefox a long time ago and many users mention different scenarios
|
|
219
|
+
* where it happens, but it seems they are not working on it
|
|
220
|
+
* (https://bugzilla.mozilla.org/show_bug.cgi?id=1648893).
|
|
221
|
+
*/
|
|
222
|
+
thumb.setPointerCapture(e.pointerId);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const releasePointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
227
|
+
const thumb = thumbRef.current;
|
|
228
|
+
if (thumb) {
|
|
229
|
+
thumb.onpointermove = null;
|
|
230
|
+
thumb.releasePointerCapture(e.pointerId);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const progress = getSliderValueAsPercentage(finalValue, min, max);
|
|
235
|
+
const thumbPosition = `calc(${progress} * (100% - ${thumbSize}px) - ${(touchableArea - thumbSize) / 2}px)`;
|
|
236
|
+
const trackProgressPosition = `calc(${thumbPosition} + ${touchableArea / 2}px)`;
|
|
237
|
+
|
|
238
|
+
const thumb = (
|
|
239
|
+
<div
|
|
240
|
+
className={classNames(isIos ? styles.iosThumb : styles.defaultThumb[themeVariant], {
|
|
241
|
+
[styles.thumbHover[themeVariant]]: !isIos && isThumbHovered && !isPointerDown,
|
|
242
|
+
[styles.thumbActive[themeVariant]]: !isIos && isPointerDown,
|
|
243
|
+
})}
|
|
244
|
+
/>
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<Box paddingY={8} dataAttributes={{'component-name': 'Slider', ...dataAttributes}}>
|
|
249
|
+
<div
|
|
250
|
+
className={classNames(styles.container, {[styles.disabled]: disabled})}
|
|
251
|
+
style={{height: touchableArea}}
|
|
252
|
+
ref={sliderRef}
|
|
253
|
+
onPointerDown={(e) => {
|
|
254
|
+
const x = e.clientX;
|
|
255
|
+
const y = e.clientY;
|
|
256
|
+
if (!isTouchable && isPointerOverElement(sliderRef.current, x, y)) {
|
|
257
|
+
if (!isPointerOverElement(thumbRef.current, x, y)) {
|
|
258
|
+
updateCurrentValue(x);
|
|
259
|
+
}
|
|
260
|
+
setIsPointerDown(true);
|
|
261
|
+
capturePointerMove(e);
|
|
262
|
+
} else {
|
|
263
|
+
cancelEvent(e);
|
|
264
|
+
}
|
|
265
|
+
}}
|
|
266
|
+
onPointerUp={(e) => {
|
|
267
|
+
if (!isTouchable) {
|
|
268
|
+
setIsPointerDown(false);
|
|
269
|
+
releasePointerMove(e);
|
|
270
|
+
}
|
|
271
|
+
}}
|
|
272
|
+
onTouchStart={(e) => {
|
|
273
|
+
cancelEvent(e);
|
|
274
|
+
if (isTouchable) {
|
|
275
|
+
const x = e.nativeEvent.touches[0].clientX;
|
|
276
|
+
const y = e.nativeEvent.touches[0].clientY;
|
|
277
|
+
if (!isPointerOverElement(thumbRef.current, x, y)) {
|
|
278
|
+
updateCurrentValue(x);
|
|
279
|
+
}
|
|
280
|
+
setIsPointerDown(true);
|
|
281
|
+
}
|
|
282
|
+
}}
|
|
283
|
+
onTouchEnd={(e) => {
|
|
284
|
+
cancelEvent(e);
|
|
285
|
+
if (isTouchable) {
|
|
286
|
+
setIsPointerDown(false);
|
|
287
|
+
}
|
|
288
|
+
}}
|
|
289
|
+
onTouchMove={(e) => {
|
|
290
|
+
cancelEvent(e);
|
|
291
|
+
if (isTouchable) {
|
|
292
|
+
updateCurrentValue(e.nativeEvent.touches[0].clientX);
|
|
293
|
+
}
|
|
294
|
+
}}
|
|
295
|
+
>
|
|
296
|
+
<div
|
|
297
|
+
className={styles.track}
|
|
298
|
+
ref={trackRef}
|
|
299
|
+
style={{
|
|
300
|
+
background: `linear-gradient(to right, ${
|
|
301
|
+
{
|
|
302
|
+
default: vars.colors.controlActivated,
|
|
303
|
+
alternative: vars.colors.controlActivated,
|
|
304
|
+
brand: vars.colors.controlActivatedBrand,
|
|
305
|
+
media: vars.colors.controlActivatedBrand,
|
|
306
|
+
negative: vars.colors.controlActivatedNegative,
|
|
307
|
+
}[themeVariant]
|
|
308
|
+
} ${trackProgressPosition}, ${
|
|
309
|
+
{
|
|
310
|
+
default: vars.colors.barTrack,
|
|
311
|
+
alternative: vars.colors.barTrack,
|
|
312
|
+
brand: vars.colors.barTrackBrand,
|
|
313
|
+
media: vars.colors.barTrackBrand,
|
|
314
|
+
negative: vars.colors.barTrackNegative,
|
|
315
|
+
}[themeVariant]
|
|
316
|
+
} ${trackProgressPosition}`,
|
|
317
|
+
}}
|
|
318
|
+
/>
|
|
319
|
+
<div
|
|
320
|
+
className={styles.thumbContainer}
|
|
321
|
+
ref={thumbRef}
|
|
322
|
+
style={{
|
|
323
|
+
cursor: isPointerDown ? 'grabbing' : isThumbHovered ? 'grab' : 'auto',
|
|
324
|
+
left: thumbPosition,
|
|
325
|
+
width: touchableArea,
|
|
326
|
+
height: touchableArea,
|
|
327
|
+
}}
|
|
328
|
+
onPointerEnter={() => {
|
|
329
|
+
if (!isTouchable) {
|
|
330
|
+
setIsThumbHovered(true);
|
|
331
|
+
}
|
|
332
|
+
}}
|
|
333
|
+
onPointerLeave={() => {
|
|
334
|
+
if (!isTouchable) {
|
|
335
|
+
setIsThumbHovered(false);
|
|
336
|
+
}
|
|
337
|
+
}}
|
|
338
|
+
>
|
|
339
|
+
{tooltip ? (
|
|
340
|
+
<Tooltip
|
|
341
|
+
target={thumb}
|
|
342
|
+
open={isPointerDown || isFocused || isThumbHovered ? true : undefined}
|
|
343
|
+
description={String(values ? values[finalValue] : finalValue)}
|
|
344
|
+
centerContent
|
|
345
|
+
delay={false}
|
|
346
|
+
/>
|
|
347
|
+
) : (
|
|
348
|
+
thumb
|
|
349
|
+
)}
|
|
350
|
+
</div>
|
|
351
|
+
<input
|
|
352
|
+
type="range"
|
|
353
|
+
min={min}
|
|
354
|
+
max={max}
|
|
355
|
+
ref={combineRefs(ref, inputRef, focusableRef)}
|
|
356
|
+
step={step}
|
|
357
|
+
aria-label={ariaLabel}
|
|
358
|
+
aria-labelledby={ariaLabelledBy}
|
|
359
|
+
id={id}
|
|
360
|
+
className={styles.input}
|
|
361
|
+
aria-valuetext={String(values ? values[finalValue] : finalValue)}
|
|
362
|
+
style={{
|
|
363
|
+
left: thumbPosition,
|
|
364
|
+
width: touchableArea,
|
|
365
|
+
height: touchableArea,
|
|
366
|
+
}}
|
|
367
|
+
name={name}
|
|
368
|
+
value={finalValue}
|
|
369
|
+
disabled={disabled}
|
|
370
|
+
onChange={(e) => handleChange(+e.target.value, false)}
|
|
371
|
+
onFocus={() => {
|
|
372
|
+
setIsFocused(true);
|
|
373
|
+
}}
|
|
374
|
+
onBlur={() => {
|
|
375
|
+
setIsFocused(false);
|
|
376
|
+
}}
|
|
377
|
+
/>
|
|
378
|
+
</div>
|
|
379
|
+
</Box>
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
|
|
384
|
+
export default Slider;
|