@telefonica/mistica 16.60.0 → 16.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/mistica.css +1 -1
- package/dist/accordion.css-mistica.js +6 -6
- package/dist/align.css-mistica.js +1 -1
- package/dist/autocomplete.css-mistica.js +1 -1
- package/dist/avatar.css-mistica.js +1 -1
- package/dist/badge.css-mistica.js +1 -1
- package/dist/box.css-mistica.js +13 -13
- package/dist/boxed.css-mistica.js +24 -24
- package/dist/button-fixed-footer-layout.d.ts +2 -1
- package/dist/button-fixed-footer-layout.js +4 -3
- package/dist/button-group.css-mistica.js +1 -1
- package/dist/button-layout.css-mistica.js +14 -14
- package/dist/button.css-mistica.js +30 -30
- package/dist/callout.css-mistica.js +11 -11
- package/dist/card-internal.css-mistica.js +15 -15
- package/dist/carousel.css-mistica.js +8 -8
- package/dist/checkbox.css-mistica.js +11 -11
- package/dist/chip.css-mistica.js +15 -15
- package/dist/circle.css-mistica.js +1 -1
- package/dist/community/advanced-data-card.css-mistica.js +6 -6
- package/dist/community/blocks.css-mistica.js +1 -1
- package/dist/community/example-component.css-mistica.js +1 -1
- package/dist/counter.css-mistica.js +1 -1
- package/dist/cover-hero.css-mistica.js +2 -2
- package/dist/credit-card-number-field.css-mistica.js +3 -3
- package/dist/date-field.css-mistica.js +1 -1
- package/dist/date-time-picker.css-mistica.js +1 -1
- package/dist/dialog.css-mistica.js +4 -4
- package/dist/divider.css-mistica.js +5 -5
- package/dist/double-field.css-mistica.js +2 -2
- package/dist/drawer.css-mistica.js +1 -1
- package/dist/empty-state-card.css-mistica.js +1 -1
- package/dist/empty-state.css-mistica.js +5 -5
- package/dist/fade-in.css-mistica.js +1 -1
- package/dist/feedback.css-mistica.js +1 -1
- package/dist/file-upload.css-mistica.js +7 -7
- package/dist/fixed-footer-layout.css-mistica.js +2 -2
- package/dist/fixed-footer-layout.d.ts +6 -1
- package/dist/fixed-footer-layout.js +29 -28
- package/dist/form.css-mistica.js +1 -1
- package/dist/grid-layout.css-mistica.js +3 -3
- package/dist/grid.css-mistica.js +120 -120
- package/dist/header.css-mistica.js +1 -1
- package/dist/hero.css-mistica.js +2 -2
- package/dist/horizontal-scroll.css-mistica.js +1 -1
- package/dist/icon-button.css-mistica.js +53 -53
- package/dist/icons/icon-chevron.css-mistica.js +2 -2
- package/dist/icons/icon-error.css-mistica.js +1 -1
- package/dist/image.css-mistica.js +2 -2
- package/dist/image.js +8 -1
- package/dist/inline.css-mistica.js +9 -9
- package/dist/list.css-mistica.js +1 -1
- package/dist/loading-bar.css-mistica.js +1 -1
- package/dist/loading-screen.css-mistica.js +4 -4
- package/dist/logo.css-mistica.js +5 -5
- package/dist/menu.css-mistica.js +13 -13
- package/dist/mosaic.css-mistica.js +1 -1
- package/dist/navigation-bar.css-mistica.js +18 -18
- package/dist/navigation-breadcrumbs.css-mistica.js +1 -1
- package/dist/package-version.js +1 -1
- package/dist/pin-field.css-mistica.js +1 -1
- package/dist/popover.css-mistica.js +1 -1
- package/dist/progress-bar.css-mistica.js +6 -6
- package/dist/radio-button.css-mistica.js +19 -19
- package/dist/rating.css-mistica.js +2 -2
- package/dist/responsive-layout.css-mistica.js +6 -6
- package/dist/screen-reader-only.css-mistica.js +1 -1
- package/dist/select.css-mistica.js +15 -15
- package/dist/sheet-action-row.css-mistica.js +1 -1
- package/dist/sheet-common.css-mistica.js +1 -1
- package/dist/sheet-info.css-mistica.js +1 -1
- package/dist/skeletons.css-mistica.js +6 -6
- package/dist/skins/skin-contract.css-mistica.js +684 -684
- package/dist/skip-link.css-mistica.js +1 -1
- package/dist/slider.css-mistica.js +18 -18
- package/dist/snackbar.css-mistica.js +4 -4
- package/dist/spinner.css-mistica.js +1 -1
- package/dist/square.css-mistica.js +1 -1
- package/dist/stack.css-mistica.js +5 -5
- package/dist/stacking-group.css-mistica.js +1 -1
- package/dist/stepper.css-mistica.js +2 -2
- package/dist/switch-component.css-mistica.js +35 -35
- package/dist/table.css-mistica.js +9 -9
- package/dist/tabs.css-mistica.js +17 -17
- package/dist/tag.css-mistica.js +1 -1
- package/dist/text-field-base.css-mistica.js +15 -15
- package/dist/text-field-components.css-mistica.js +3 -3
- package/dist/text-link.css-mistica.js +6 -6
- package/dist/text.css-mistica.js +6 -6
- package/dist/theme-context.css-mistica.js +1 -1
- package/dist/timeline.css-mistica.js +9 -9
- package/dist/timer.css-mistica.js +6 -6
- package/dist/tooltip.css-mistica.js +1 -1
- package/dist/touchable.css-mistica.js +1 -1
- package/dist/utils/aspect-ratio-support.css-mistica.js +2 -2
- package/dist/video.css-mistica.js +1 -1
- package/dist/vivinho-loading-animation/vivinho-loading-animation.css-mistica.js +1 -1
- package/dist-es/accordion.css-mistica.js +6 -6
- package/dist-es/align.css-mistica.js +1 -1
- package/dist-es/autocomplete.css-mistica.js +1 -1
- package/dist-es/avatar.css-mistica.js +1 -1
- package/dist-es/badge.css-mistica.js +1 -1
- package/dist-es/box.css-mistica.js +13 -13
- package/dist-es/boxed.css-mistica.js +23 -23
- package/dist-es/button-fixed-footer-layout.js +12 -11
- package/dist-es/button-group.css-mistica.js +1 -1
- package/dist-es/button-layout.css-mistica.js +14 -14
- package/dist-es/button.css-mistica.js +30 -30
- package/dist-es/callout.css-mistica.js +11 -11
- package/dist-es/card-internal.css-mistica.js +15 -15
- package/dist-es/carousel.css-mistica.js +8 -8
- package/dist-es/checkbox.css-mistica.js +11 -11
- package/dist-es/chip.css-mistica.js +15 -15
- package/dist-es/circle.css-mistica.js +1 -1
- package/dist-es/community/advanced-data-card.css-mistica.js +6 -6
- package/dist-es/community/blocks.css-mistica.js +1 -1
- package/dist-es/community/example-component.css-mistica.js +1 -1
- package/dist-es/counter.css-mistica.js +1 -1
- package/dist-es/cover-hero.css-mistica.js +2 -2
- package/dist-es/credit-card-number-field.css-mistica.js +3 -3
- package/dist-es/date-field.css-mistica.js +1 -1
- package/dist-es/date-time-picker.css-mistica.js +1 -1
- package/dist-es/dialog.css-mistica.js +4 -4
- package/dist-es/divider.css-mistica.js +5 -5
- package/dist-es/double-field.css-mistica.js +2 -2
- package/dist-es/drawer.css-mistica.js +1 -1
- package/dist-es/empty-state-card.css-mistica.js +1 -1
- package/dist-es/empty-state.css-mistica.js +5 -5
- package/dist-es/fade-in.css-mistica.js +1 -1
- package/dist-es/feedback.css-mistica.js +1 -1
- package/dist-es/file-upload.css-mistica.js +7 -7
- package/dist-es/fixed-footer-layout.css-mistica.js +2 -2
- package/dist-es/fixed-footer-layout.js +57 -56
- package/dist-es/form.css-mistica.js +1 -1
- package/dist-es/grid-layout.css-mistica.js +3 -3
- package/dist-es/grid.css-mistica.js +120 -120
- package/dist-es/header.css-mistica.js +1 -1
- package/dist-es/hero.css-mistica.js +2 -2
- package/dist-es/horizontal-scroll.css-mistica.js +1 -1
- package/dist-es/icon-button.css-mistica.js +53 -53
- package/dist-es/icons/icon-chevron.css-mistica.js +2 -2
- package/dist-es/icons/icon-error.css-mistica.js +1 -1
- package/dist-es/image.css-mistica.js +2 -2
- package/dist-es/image.js +8 -1
- package/dist-es/inline.css-mistica.js +9 -9
- package/dist-es/list.css-mistica.js +1 -1
- package/dist-es/loading-bar.css-mistica.js +1 -1
- package/dist-es/loading-screen.css-mistica.js +4 -4
- package/dist-es/logo.css-mistica.js +5 -5
- package/dist-es/menu.css-mistica.js +13 -13
- package/dist-es/mosaic.css-mistica.js +1 -1
- package/dist-es/navigation-bar.css-mistica.js +18 -18
- package/dist-es/navigation-breadcrumbs.css-mistica.js +1 -1
- package/dist-es/package-version.js +1 -1
- package/dist-es/pin-field.css-mistica.js +1 -1
- package/dist-es/popover.css-mistica.js +1 -1
- package/dist-es/progress-bar.css-mistica.js +6 -6
- package/dist-es/radio-button.css-mistica.js +19 -19
- package/dist-es/rating.css-mistica.js +2 -2
- package/dist-es/responsive-layout.css-mistica.js +6 -6
- package/dist-es/screen-reader-only.css-mistica.js +1 -1
- package/dist-es/select.css-mistica.js +15 -15
- package/dist-es/sheet-action-row.css-mistica.js +1 -1
- package/dist-es/sheet-common.css-mistica.js +1 -1
- package/dist-es/sheet-info.css-mistica.js +1 -1
- package/dist-es/skeletons.css-mistica.js +6 -6
- package/dist-es/skins/skin-contract.css-mistica.js +684 -684
- package/dist-es/skip-link.css-mistica.js +1 -1
- package/dist-es/slider.css-mistica.js +18 -18
- package/dist-es/snackbar.css-mistica.js +4 -4
- package/dist-es/spinner.css-mistica.js +1 -1
- package/dist-es/square.css-mistica.js +1 -1
- package/dist-es/stack.css-mistica.js +5 -5
- package/dist-es/stacking-group.css-mistica.js +1 -1
- package/dist-es/stepper.css-mistica.js +2 -2
- package/dist-es/style.css +1 -1
- package/dist-es/switch-component.css-mistica.js +35 -35
- package/dist-es/table.css-mistica.js +9 -9
- package/dist-es/tabs.css-mistica.js +17 -17
- package/dist-es/tag.css-mistica.js +1 -1
- package/dist-es/text-field-base.css-mistica.js +15 -15
- package/dist-es/text-field-components.css-mistica.js +3 -3
- package/dist-es/text-link.css-mistica.js +6 -6
- package/dist-es/text.css-mistica.js +6 -6
- package/dist-es/theme-context.css-mistica.js +1 -1
- package/dist-es/timeline.css-mistica.js +9 -9
- package/dist-es/timer.css-mistica.js +6 -6
- package/dist-es/tooltip.css-mistica.js +1 -1
- package/dist-es/touchable.css-mistica.js +1 -1
- package/dist-es/utils/aspect-ratio-support.css-mistica.js +2 -2
- package/dist-es/video.css-mistica.js +1 -1
- package/dist-es/vivinho-loading-animation/vivinho-loading-animation.css-mistica.js +1 -1
- package/doc/llms.md +11 -0
- package/package.json +13 -1
- package/src/accordion.css.ts +121 -0
- package/src/accordion.tsx +366 -0
- package/src/align.css.ts +7 -0
- package/src/align.tsx +32 -0
- package/src/autocomplete.css.ts +62 -0
- package/src/autocomplete.tsx +239 -0
- package/src/avatar.css.ts +14 -0
- package/src/avatar.tsx +120 -0
- package/src/badge.css.ts +51 -0
- package/src/badge.tsx +79 -0
- package/src/box.css.ts +51 -0
- package/src/box.tsx +114 -0
- package/src/boxed.css.ts +132 -0
- package/src/boxed.tsx +153 -0
- package/src/button-fixed-footer-layout.tsx +65 -0
- package/src/button-group.css.ts +75 -0
- package/src/button-group.tsx +91 -0
- package/src/button-layout.css.ts +162 -0
- package/src/button-layout.tsx +91 -0
- package/src/button.css.ts +758 -0
- package/src/button.tsx +632 -0
- package/src/callout.css.ts +50 -0
- package/src/callout.tsx +147 -0
- package/src/card-cover.tsx +242 -0
- package/src/card-data.tsx +152 -0
- package/src/card-internal.css.ts +271 -0
- package/src/card-internal.tsx +1724 -0
- package/src/card-media.tsx +157 -0
- package/src/card-naked.tsx +63 -0
- package/src/carousel.css.ts +522 -0
- package/src/carousel.tsx +1300 -0
- package/src/checkbox.css.ts +94 -0
- package/src/checkbox.tsx +192 -0
- package/src/chip.css.ts +204 -0
- package/src/chip.tsx +191 -0
- package/src/circle.css.ts +14 -0
- package/src/circle.tsx +52 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-button-and-link-footer-image-false-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-button-and-link-footer-image-true-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-button-footer-image-false-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-button-footer-image-true-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-link-footer-image-false-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-link-footer-image-true-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-none-footer-image-false-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-actions-none-footer-image-true-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-extras-0-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-extras-1-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-extras-3-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-extras-3-no-divider-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-inside-carousel-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/advanced-data-card-screenshot-test-tsx-advanced-data-card-without-stacking-group-with-top-actions-and-too-long-title-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-highlighted-value-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-information-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-progress-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-progress-block-2-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-row-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-simple-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/__image_snapshots__/blocks-screenshot-test-tsx-blocks-value-block-1-snap.png +0 -0
- package/src/community/__screenshot_tests__/advanced-data-card-screenshot-test.tsx +84 -0
- package/src/community/__screenshot_tests__/blocks-screenshot-test.tsx +72 -0
- package/src/community/__stories__/advanced-data-card-carousel-story.tsx +66 -0
- package/src/community/__stories__/advanced-data-card-story.tsx +158 -0
- package/src/community/__stories__/blocks-story.tsx +272 -0
- package/src/community/__stories__/example-component-story.tsx +15 -0
- package/src/community/__stories__/index-story.tsx +154 -0
- package/src/community/__type_tests__/advanced-data-card-type-test.tsx +40 -0
- package/src/community/advanced-data-card.css.ts +271 -0
- package/src/community/advanced-data-card.tsx +431 -0
- package/src/community/blocks.css.ts +12 -0
- package/src/community/blocks.tsx +290 -0
- package/src/community/example-component.css.ts +7 -0
- package/src/community/example-component.tsx +17 -0
- package/src/community/index.tsx +10 -0
- package/src/counter.css.ts +150 -0
- package/src/counter.tsx +215 -0
- package/src/cover-hero-media.tsx +39 -0
- package/src/cover-hero.css.ts +133 -0
- package/src/cover-hero.tsx +262 -0
- package/src/credit-card-expiration-field.tsx +187 -0
- package/src/credit-card-fields.tsx +56 -0
- package/src/credit-card-number-field.css.ts +47 -0
- package/src/credit-card-number-field.tsx +245 -0
- package/src/cvv-field.tsx +169 -0
- package/src/date-field.css.ts +14 -0
- package/src/date-field.tsx +130 -0
- package/src/date-time-field.tsx +141 -0
- package/src/date-time-picker.css.ts +126 -0
- package/src/date-time-picker.tsx +188 -0
- package/src/decimal-field.tsx +160 -0
- package/src/desktop-container-type-context.tsx +15 -0
- package/src/dialog-context.tsx +81 -0
- package/src/dialog.css.ts +155 -0
- package/src/dialog.tsx +423 -0
- package/src/divider.css.ts +10 -0
- package/src/divider.tsx +11 -0
- package/src/double-field.css.ts +33 -0
- package/src/double-field.tsx +71 -0
- package/src/drawer.css.ts +123 -0
- package/src/drawer.tsx +304 -0
- package/src/email-field.tsx +76 -0
- package/src/empty-state-card.css.ts +40 -0
- package/src/empty-state-card.tsx +92 -0
- package/src/empty-state.css.ts +119 -0
- package/src/empty-state.tsx +141 -0
- package/src/fade-in.css.ts +12 -0
- package/src/fade-in.tsx +40 -0
- package/src/feedback.css.ts +119 -0
- package/src/feedback.tsx +432 -0
- package/src/file-upload.css.ts +156 -0
- package/src/file-upload.tsx +612 -0
- package/src/fixed-footer-layout.css.ts +96 -0
- package/src/fixed-footer-layout.tsx +227 -0
- package/src/fixed-to-top.tsx +21 -0
- package/src/focus-trap.tsx +17 -0
- package/src/form-context.tsx +198 -0
- package/src/form.css.ts +5 -0
- package/src/form.tsx +287 -0
- package/src/grid-layout.css.ts +68 -0
- package/src/grid-layout.tsx +201 -0
- package/src/grid.css.ts +203 -0
- package/src/grid.tsx +241 -0
- package/src/header.css.ts +30 -0
- package/src/header.tsx +319 -0
- package/src/hero.css.ts +71 -0
- package/src/hero.tsx +318 -0
- package/src/hooks.tsx +313 -0
- package/src/horizontal-scroll.css.ts +43 -0
- package/src/horizontal-scroll.tsx +18 -0
- package/src/iban-field.tsx +218 -0
- package/src/icon-button.css.ts +561 -0
- package/src/icon-button.tsx +221 -0
- package/src/icons/__stories__/mistica-icons-story.tsx +192 -0
- package/src/icons/icon-amex.tsx +40 -0
- package/src/icons/icon-chevron.css.ts +23 -0
- package/src/icons/icon-chevron.tsx +150 -0
- package/src/icons/icon-cvv-amex.tsx +31 -0
- package/src/icons/icon-cvv-visa-mc.tsx +31 -0
- package/src/icons/icon-error.css.ts +27 -0
- package/src/icons/icon-error.tsx +207 -0
- package/src/icons/icon-info.tsx +86 -0
- package/src/icons/icon-mastercard.tsx +36 -0
- package/src/icons/icon-success-vivo-new.tsx +51 -0
- package/src/icons/icon-success-vivo.tsx +36 -0
- package/src/icons/icon-success.tsx +211 -0
- package/src/icons/icon-visa.tsx +32 -0
- package/src/image.css.ts +48 -0
- package/src/image.tsx +352 -0
- package/src/index.tsx +2466 -0
- package/src/inline.css.ts +131 -0
- package/src/inline.tsx +135 -0
- package/src/integer-field.tsx +93 -0
- package/src/list.css.ts +281 -0
- package/src/list.tsx +963 -0
- package/src/loading-bar.css.ts +69 -0
- package/src/loading-bar.tsx +25 -0
- package/src/loading-screen.css.ts +114 -0
- package/src/loading-screen.tsx +376 -0
- package/src/logo-blau-shell.tsx +30 -0
- package/src/logo-blau.tsx +60 -0
- package/src/logo-common.tsx +29 -0
- package/src/logo-esimflag-shell.tsx +30 -0
- package/src/logo-esimflag.tsx +56 -0
- package/src/logo-movistar-new-shell.tsx +30 -0
- package/src/logo-movistar-new.tsx +85 -0
- package/src/logo-movistar-shell.tsx +30 -0
- package/src/logo-movistar.tsx +63 -0
- package/src/logo-o2-new-shell.tsx +26 -0
- package/src/logo-o2-new.tsx +27 -0
- package/src/logo-o2-shell.tsx +26 -0
- package/src/logo-o2.tsx +27 -0
- package/src/logo-telefonica-shell.tsx +30 -0
- package/src/logo-telefonica.tsx +95 -0
- package/src/logo-tu-shell.tsx +26 -0
- package/src/logo-tu.tsx +28 -0
- package/src/logo-vivo-shell.tsx +30 -0
- package/src/logo-vivo.tsx +53 -0
- package/src/logo.css.ts +33 -0
- package/src/logo.tsx +313 -0
- package/src/master-detail-layout.tsx +28 -0
- package/src/maybe-dismissable.css.ts +37 -0
- package/src/maybe-dismissable.tsx +58 -0
- package/src/media-queries.css.ts +67 -0
- package/src/menu.css.ts +132 -0
- package/src/menu.tsx +468 -0
- package/src/meter.tsx +516 -0
- package/src/modal-context-provider.tsx +45 -0
- package/src/month-field.tsx +124 -0
- package/src/mosaic.css.ts +73 -0
- package/src/mosaic.tsx +205 -0
- package/src/navigation-bar.css.ts +558 -0
- package/src/navigation-bar.tsx +1637 -0
- package/src/navigation-breadcrumbs.css.ts +22 -0
- package/src/navigation-breadcrumbs.tsx +69 -0
- package/src/negative-box.tsx +15 -0
- package/src/nestable-context.tsx +139 -0
- package/src/overlay.tsx +86 -0
- package/src/overscroll-color-context.tsx +141 -0
- package/src/package-version.tsx +2 -0
- package/src/password-field.tsx +126 -0
- package/src/phone-number-field-lite.tsx +265 -0
- package/src/phone-number-field.tsx +171 -0
- package/src/pin-field.css.ts +90 -0
- package/src/pin-field.tsx +346 -0
- package/src/placeholder.tsx +41 -0
- package/src/popover.css.ts +8 -0
- package/src/popover.tsx +85 -0
- package/src/portal.tsx +43 -0
- package/src/progress-bar.css.ts +61 -0
- package/src/progress-bar.tsx +174 -0
- package/src/radio-button.css.ts +174 -0
- package/src/radio-button.tsx +322 -0
- package/src/rating.css.ts +128 -0
- package/src/rating.tsx +351 -0
- package/src/responsive-layout.css.ts +162 -0
- package/src/responsive-layout.tsx +106 -0
- package/src/screen-reader-only.css.ts +27 -0
- package/src/screen-reader-only.tsx +33 -0
- package/src/screen-size-context-provider.tsx +96 -0
- package/src/screen-size-context.tsx +23 -0
- package/src/search-field.tsx +126 -0
- package/src/select.css.ts +226 -0
- package/src/select.tsx +513 -0
- package/src/sheet-action-row.css.ts +33 -0
- package/src/sheet-actions-list.tsx +113 -0
- package/src/sheet-actions.tsx +95 -0
- package/src/sheet-common.css.ts +254 -0
- package/src/sheet-common.tsx +402 -0
- package/src/sheet-info.css.ts +19 -0
- package/src/sheet-info.tsx +127 -0
- package/src/sheet-native.tsx +189 -0
- package/src/sheet-radio-list.tsx +118 -0
- package/src/sheet-root.tsx +127 -0
- package/src/sheet-types.tsx +94 -0
- package/src/sheet-web.tsx +140 -0
- package/src/skeleton-base.tsx +38 -0
- package/src/skeletons.css.ts +56 -0
- package/src/skeletons.tsx +133 -0
- package/src/skins/blau.tsx +724 -0
- package/src/skins/constants.tsx +10 -0
- package/src/skins/defaults.tsx +104 -0
- package/src/skins/esimflag.tsx +728 -0
- package/src/skins/movistar-new.tsx +735 -0
- package/src/skins/movistar.tsx +740 -0
- package/src/skins/o2-new.tsx +731 -0
- package/src/skins/o2.tsx +727 -0
- package/src/skins/skin-contract.css.ts +380 -0
- package/src/skins/telefonica.tsx +768 -0
- package/src/skins/tu.tsx +741 -0
- package/src/skins/types/colors.tsx +286 -0
- package/src/skins/types/index.tsx +153 -0
- package/src/skins/utils.tsx +66 -0
- package/src/skins/vivo-new.tsx +745 -0
- package/src/skins/vivo.tsx +720 -0
- package/src/skip-link.css.ts +34 -0
- package/src/skip-link.tsx +52 -0
- package/src/slider.css.ts +181 -0
- package/src/slider.tsx +384 -0
- package/src/snackbar-context.tsx +98 -0
- package/src/snackbar-native.ts +37 -0
- package/src/snackbar.css.ts +176 -0
- package/src/snackbar.tsx +258 -0
- package/src/spinner.css.ts +66 -0
- package/src/spinner.tsx +136 -0
- package/src/sprinkles.css.ts +83 -0
- package/src/square.css.ts +15 -0
- package/src/square.tsx +55 -0
- package/src/stack.css.ts +44 -0
- package/src/stack.tsx +79 -0
- package/src/stacking-group.css.ts +15 -0
- package/src/stacking-group.tsx +82 -0
- package/src/stepper.css.ts +233 -0
- package/src/stepper.tsx +156 -0
- package/src/switch-component.css.ts +181 -0
- package/src/switch-component.tsx +187 -0
- package/src/tab-focus.tsx +68 -0
- package/src/table-actions-header.tsx +21 -0
- package/src/table-cell-text.tsx +35 -0
- package/src/table.css.ts +297 -0
- package/src/table.tsx +398 -0
- package/src/tabs.css.ts +212 -0
- package/src/tabs.tsx +263 -0
- package/src/tag.css.ts +42 -0
- package/src/tag.tsx +161 -0
- package/src/test-utils/environment/setup-ssr.tsx +10 -0
- package/src/test-utils/fail-test-on-console-error.tsx +22 -0
- package/src/test-utils/index.tsx +341 -0
- package/src/test-utils/setup-ssr-test-env.tsx +13 -0
- package/src/test-utils/ssr.tsx +197 -0
- package/src/text-field-base.css.ts +416 -0
- package/src/text-field-base.tsx +628 -0
- package/src/text-field-components.css.ts +165 -0
- package/src/text-field-components.tsx +230 -0
- package/src/text-field.tsx +118 -0
- package/src/text-link.css.ts +83 -0
- package/src/text-link.tsx +85 -0
- package/src/text-tokens.tsx +708 -0
- package/src/text.css.ts +60 -0
- package/src/text.tsx +516 -0
- package/src/theme-context-provider.tsx +370 -0
- package/src/theme-context.css.ts +3 -0
- package/src/theme-context.tsx +8 -0
- package/src/theme-variant-context.tsx +51 -0
- package/src/theme.tsx +184 -0
- package/src/time-field.tsx +99 -0
- package/src/timeline.css.ts +135 -0
- package/src/timeline.tsx +250 -0
- package/src/timer.css.ts +99 -0
- package/src/timer.tsx +420 -0
- package/src/title.tsx +119 -0
- package/src/tooltip-context-provider.tsx +57 -0
- package/src/tooltip.css.ts +106 -0
- package/src/tooltip.tsx +649 -0
- package/src/touchable.css.ts +56 -0
- package/src/touchable.tsx +355 -0
- package/src/types/font-face.d.ts +47 -0
- package/src/types/libs.d.ts +3 -0
- package/src/utils/__tests__/analytics-test.tsx +35 -0
- package/src/utils/__tests__/browser-test.tsx +28 -0
- package/src/utils/__tests__/dom-test.tsx +23 -0
- package/src/utils/__tests__/helpers-test.tsx +166 -0
- package/src/utils/analytics.tsx +28 -0
- package/src/utils/animation.tsx +201 -0
- package/src/utils/aspect-ratio-support.css.ts +28 -0
- package/src/utils/aspect-ratio-support.tsx +141 -0
- package/src/utils/browser.tsx +9 -0
- package/src/utils/color.tsx +46 -0
- package/src/utils/common.tsx +27 -0
- package/src/utils/credit-card.tsx +46 -0
- package/src/utils/css.tsx +25 -0
- package/src/utils/document-visibility.tsx +52 -0
- package/src/utils/dom.tsx +155 -0
- package/src/utils/environment.tsx +6 -0
- package/src/utils/headings.tsx +18 -0
- package/src/utils/helpers.tsx +182 -0
- package/src/utils/keys.tsx +8 -0
- package/src/utils/locale.tsx +27 -0
- package/src/utils/platform.tsx +94 -0
- package/src/utils/region-code.tsx +1 -0
- package/src/utils/renders-element.tsx +6 -0
- package/src/utils/time.tsx +22 -0
- package/src/utils/types.tsx +19 -0
- package/src/utils/utility-types.tsx +8 -0
- package/src/video.css.ts +11 -0
- package/src/video.tsx +355 -0
- package/src/vivinho-loading-animation/in-lottie.json +402 -0
- package/src/vivinho-loading-animation/index.tsx +90 -0
- package/src/vivinho-loading-animation/out-lottie.json +575 -0
- package/src/vivinho-loading-animation/pulse-lottie.json +551 -0
- package/src/vivinho-loading-animation/vivinho-loading-animation.css.ts +15 -0
- package/src/vivinho-loading-animation/wave-lottie.json +2829 -0
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import {useIsomorphicLayoutEffect, useScreenSize, useTheme} from './hooks';
|
|
5
|
+
import {InternalIconButton, InternalToggleIconButton} from './icon-button';
|
|
6
|
+
import {iconSize} from './icon-button.css';
|
|
7
|
+
import {vars} from './skins/skin-contract.css';
|
|
8
|
+
import {Text3} from './text';
|
|
9
|
+
import * as styles from './text-field-base.css';
|
|
10
|
+
import {FieldContainer, HelperText, Label} from './text-field-components';
|
|
11
|
+
import {fieldVars} from './text-field-base.css';
|
|
12
|
+
import * as tokens from './text-tokens';
|
|
13
|
+
import {ThemeVariant} from './theme-variant-context';
|
|
14
|
+
import {combineRefs} from './utils/common';
|
|
15
|
+
import {isFirefox, isRunningAcceptanceTest} from './utils/platform';
|
|
16
|
+
|
|
17
|
+
import type {FieldValidator} from './form-context';
|
|
18
|
+
import type {InputState} from './text-field-components';
|
|
19
|
+
import type {DataAttributes, IconProps} from './utils/types';
|
|
20
|
+
import type {ExclusifyUnion} from './utils/utility-types';
|
|
21
|
+
|
|
22
|
+
const isValidInputValue = (value?: string, inputType?: React.HTMLInputTypeAttribute) => {
|
|
23
|
+
if (!inputType) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const input = document.createElement('input');
|
|
28
|
+
input.type = inputType;
|
|
29
|
+
input.value = value || '';
|
|
30
|
+
return input.value !== '';
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type FieldEndIconProps = {
|
|
34
|
+
/** In date fields, we want the icon's background to stay transparent when hovering/pressing it */
|
|
35
|
+
hasBackgroundColor?: boolean;
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
} & ExclusifyUnion<
|
|
38
|
+
| {
|
|
39
|
+
Icon: (props: IconProps) => JSX.Element;
|
|
40
|
+
'aria-label'?: string;
|
|
41
|
+
onPress: (event: React.MouseEvent<HTMLElement>) => void;
|
|
42
|
+
}
|
|
43
|
+
| {
|
|
44
|
+
checkedProps: {Icon: (props: IconProps) => JSX.Element; 'aria-label'?: string};
|
|
45
|
+
uncheckedProps: {Icon: (props: IconProps) => JSX.Element; 'aria-label'?: string};
|
|
46
|
+
onChange?: (checked: boolean) => void | undefined | Promise<void>;
|
|
47
|
+
checked?: boolean;
|
|
48
|
+
}
|
|
49
|
+
>;
|
|
50
|
+
|
|
51
|
+
export const FieldEndIcon = ({
|
|
52
|
+
hasBackgroundColor = true,
|
|
53
|
+
onPress,
|
|
54
|
+
onChange,
|
|
55
|
+
disabled,
|
|
56
|
+
Icon,
|
|
57
|
+
checkedProps,
|
|
58
|
+
uncheckedProps,
|
|
59
|
+
'aria-label': ariaLabel,
|
|
60
|
+
}: FieldEndIconProps): JSX.Element => {
|
|
61
|
+
return checkedProps ? (
|
|
62
|
+
<InternalToggleIconButton
|
|
63
|
+
checkedProps={{...checkedProps, 'aria-label': checkedProps['aria-label'] || ''}}
|
|
64
|
+
uncheckedProps={{...uncheckedProps, 'aria-label': uncheckedProps['aria-label'] || ''}}
|
|
65
|
+
onChange={onChange}
|
|
66
|
+
hasOverlay={hasBackgroundColor}
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
small
|
|
69
|
+
bleedRight
|
|
70
|
+
/>
|
|
71
|
+
) : (
|
|
72
|
+
<InternalIconButton
|
|
73
|
+
Icon={Icon}
|
|
74
|
+
disabled={disabled}
|
|
75
|
+
aria-label={ariaLabel || ''}
|
|
76
|
+
onPress={onPress}
|
|
77
|
+
hasOverlay={hasBackgroundColor}
|
|
78
|
+
small
|
|
79
|
+
bleedRight
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Incomplete list, add more if needed
|
|
86
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
|
|
87
|
+
*/
|
|
88
|
+
export type AutoComplete =
|
|
89
|
+
| 'on'
|
|
90
|
+
| 'off'
|
|
91
|
+
| 'name' // full name
|
|
92
|
+
| 'given-name' // first name
|
|
93
|
+
| 'additional-name' // middle name
|
|
94
|
+
| 'family-name' // last name
|
|
95
|
+
| 'email'
|
|
96
|
+
| 'tel'
|
|
97
|
+
| 'street-address'
|
|
98
|
+
| 'address-line1' // for two address inputs
|
|
99
|
+
| 'address-line2' // for two address inputs
|
|
100
|
+
| 'address-level1' // state or province
|
|
101
|
+
| 'address-level2' // city
|
|
102
|
+
| 'country'
|
|
103
|
+
| 'postal-code'
|
|
104
|
+
| 'transaction-amount'
|
|
105
|
+
| 'new-password'
|
|
106
|
+
| 'current-password'
|
|
107
|
+
| 'cc-type' // The type of payment instrument (such as "Visa" or "Master Card")
|
|
108
|
+
| 'cc-name' // The full name as printed on or associated with a payment instrument such as a credit card
|
|
109
|
+
| 'cc-number' // A credit card number or other number identifying a payment method, such as an account number
|
|
110
|
+
| 'cc-exp' // A payment method expiration date, typically in the form "MM/YY" or "MM/YYYY"
|
|
111
|
+
| 'cc-csc' // The security code; on credit cards, this is the 3-digit verification number on the back of the card
|
|
112
|
+
| 'username'; // Username or account name, when used with a password field the browser offers to save credentials together
|
|
113
|
+
|
|
114
|
+
export interface CommonFormFieldProps<T = HTMLInputElement> {
|
|
115
|
+
autoFocus?: boolean;
|
|
116
|
+
disabled?: boolean;
|
|
117
|
+
error?: boolean;
|
|
118
|
+
helperText?: string;
|
|
119
|
+
id?: string;
|
|
120
|
+
label: string;
|
|
121
|
+
name: string;
|
|
122
|
+
optional?: boolean;
|
|
123
|
+
showOptionalLabel?: boolean;
|
|
124
|
+
maxLength?: number;
|
|
125
|
+
validate?: FieldValidator;
|
|
126
|
+
validateOnBlurInsideForm?: boolean;
|
|
127
|
+
autoComplete?: AutoComplete;
|
|
128
|
+
onFocus?: React.FocusEventHandler<T>;
|
|
129
|
+
onBlur?: React.FocusEventHandler<T>;
|
|
130
|
+
fullWidth?: boolean;
|
|
131
|
+
getSuggestions?: (text: string) => ReadonlyArray<string>;
|
|
132
|
+
placeholder?: string;
|
|
133
|
+
value?: string;
|
|
134
|
+
defaultValue?: string;
|
|
135
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
136
|
+
children?: void;
|
|
137
|
+
readOnly?: boolean;
|
|
138
|
+
preventCopy?: boolean;
|
|
139
|
+
dataAttributes?: DataAttributes;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface TextFieldBaseProps {
|
|
143
|
+
id?: string;
|
|
144
|
+
type?: string;
|
|
145
|
+
autoComplete?: AutoComplete;
|
|
146
|
+
autoFocus?: boolean;
|
|
147
|
+
disabled?: boolean;
|
|
148
|
+
error?: boolean;
|
|
149
|
+
pattern?: string;
|
|
150
|
+
required?: boolean;
|
|
151
|
+
showOptionalLabel?: boolean;
|
|
152
|
+
fullWidth?: boolean;
|
|
153
|
+
helperText?: string;
|
|
154
|
+
label?: string;
|
|
155
|
+
placeholder?: string;
|
|
156
|
+
defaultValue?: string;
|
|
157
|
+
name?: string;
|
|
158
|
+
maxLength?: number;
|
|
159
|
+
prefix?: React.ReactNode;
|
|
160
|
+
startIcon?: React.ReactNode;
|
|
161
|
+
endIcon?: React.ReactNode;
|
|
162
|
+
endIconOverlay?: React.ReactNode;
|
|
163
|
+
style?: React.CSSProperties;
|
|
164
|
+
value?: string;
|
|
165
|
+
inputRef?: React.Ref<HTMLInputElement | HTMLSelectElement>;
|
|
166
|
+
getSuggestions?: (value: string) => ReadonlyArray<string>;
|
|
167
|
+
withSuggestionsEmptyCase?: boolean | string;
|
|
168
|
+
shouldShowSuggestions?: 'focus' | number;
|
|
169
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
170
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
171
|
+
onBlur?: React.FocusEventHandler;
|
|
172
|
+
onFocus?: React.FocusEventHandler;
|
|
173
|
+
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
174
|
+
inputProps?: {[name: string]: string | number | undefined};
|
|
175
|
+
inputComponent?: React.ComponentType<any>;
|
|
176
|
+
shrinkLabel?: boolean;
|
|
177
|
+
focus?: boolean;
|
|
178
|
+
fieldRef?: React.RefObject<HTMLDivElement | null>;
|
|
179
|
+
onInput?: (event: React.FormEvent<HTMLInputElement>) => void;
|
|
180
|
+
multiline?: boolean;
|
|
181
|
+
inputMode?: string;
|
|
182
|
+
readOnly?: boolean;
|
|
183
|
+
preventCopy?: boolean;
|
|
184
|
+
min?: string;
|
|
185
|
+
max?: string;
|
|
186
|
+
role?: string;
|
|
187
|
+
dataAttributes?: DataAttributes;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const preventCopyHandler = (e: React.ClipboardEvent<HTMLInputElement>) => {
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export const TextFieldBase = React.forwardRef<any, TextFieldBaseProps>(
|
|
195
|
+
(
|
|
196
|
+
{
|
|
197
|
+
error,
|
|
198
|
+
helperText,
|
|
199
|
+
label,
|
|
200
|
+
inputProps,
|
|
201
|
+
inputRef,
|
|
202
|
+
defaultValue,
|
|
203
|
+
value,
|
|
204
|
+
onFocus,
|
|
205
|
+
onBlur,
|
|
206
|
+
inputComponent,
|
|
207
|
+
prefix,
|
|
208
|
+
startIcon,
|
|
209
|
+
endIcon,
|
|
210
|
+
endIconOverlay,
|
|
211
|
+
shrinkLabel,
|
|
212
|
+
multiline = false,
|
|
213
|
+
focus,
|
|
214
|
+
fieldRef,
|
|
215
|
+
maxLength,
|
|
216
|
+
id: idProp,
|
|
217
|
+
autoComplete: autoCompleteProp,
|
|
218
|
+
fullWidth,
|
|
219
|
+
dataAttributes,
|
|
220
|
+
preventCopy,
|
|
221
|
+
showOptionalLabel = true,
|
|
222
|
+
required,
|
|
223
|
+
...rest
|
|
224
|
+
},
|
|
225
|
+
ref
|
|
226
|
+
) => {
|
|
227
|
+
const {preventCopyInFormFields, texts, t} = useTheme();
|
|
228
|
+
preventCopy = preventCopy ?? preventCopyInFormFields;
|
|
229
|
+
const reactId = React.useId();
|
|
230
|
+
const id = idProp || reactId;
|
|
231
|
+
const leftHelperTextid = React.useId();
|
|
232
|
+
const rightHelperTextid = React.useId();
|
|
233
|
+
|
|
234
|
+
const [inputState, setInputState] = React.useState<InputState>(
|
|
235
|
+
defaultValue?.length || value?.length ? 'filled' : 'default'
|
|
236
|
+
);
|
|
237
|
+
const {isTabletOrSmaller} = useScreenSize();
|
|
238
|
+
const [characterCount, setCharacterCount] = React.useState(defaultValue?.length ?? 0);
|
|
239
|
+
const hasLabel = !!label || !required;
|
|
240
|
+
|
|
241
|
+
const isDateInput =
|
|
242
|
+
rest.type === 'date' ||
|
|
243
|
+
rest.type === 'datetime-local' ||
|
|
244
|
+
rest.type === 'time' ||
|
|
245
|
+
rest.type === 'month';
|
|
246
|
+
const valueRef = React.useRef<string | undefined>(undefined);
|
|
247
|
+
|
|
248
|
+
useIsomorphicLayoutEffect(() => {
|
|
249
|
+
/**
|
|
250
|
+
* If the date format is invalid, value will be empty in the DOM element. We treat it like the
|
|
251
|
+
* case of an empty input. We have to do this because in some browsers, like Chrome, when the
|
|
252
|
+
* date value is empty it displays a placeholder (mm/dd/yyyy) that can't be removed, so we set
|
|
253
|
+
* it's opacity to 0 to avoid showing it.
|
|
254
|
+
*/
|
|
255
|
+
const finalValue = isDateInput && !isValidInputValue(value, rest.type) ? '' : value;
|
|
256
|
+
const isControlled = value !== undefined;
|
|
257
|
+
|
|
258
|
+
// if value prop has changed, we need to set the input state to default if the new value is not valid
|
|
259
|
+
if (
|
|
260
|
+
valueRef.current !== value &&
|
|
261
|
+
isDateInput &&
|
|
262
|
+
!finalValue?.length &&
|
|
263
|
+
inputState === 'filled' &&
|
|
264
|
+
focus === undefined
|
|
265
|
+
) {
|
|
266
|
+
setInputState('default');
|
|
267
|
+
}
|
|
268
|
+
valueRef.current = value;
|
|
269
|
+
|
|
270
|
+
if (inputState !== 'focused' && isControlled) {
|
|
271
|
+
setCharacterCount(finalValue?.length ?? 0);
|
|
272
|
+
setInputState(finalValue?.length ? 'filled' : 'default');
|
|
273
|
+
}
|
|
274
|
+
if (focus) {
|
|
275
|
+
setInputState('focused');
|
|
276
|
+
}
|
|
277
|
+
if (focus === false && !finalValue?.length) {
|
|
278
|
+
// when textfield is used in selects it doesn't get or lose focus
|
|
279
|
+
setInputState('default');
|
|
280
|
+
}
|
|
281
|
+
if (focus === false && finalValue?.length) {
|
|
282
|
+
setInputState('filled');
|
|
283
|
+
}
|
|
284
|
+
}, [inputState, value, focus, isDateInput, rest.type]);
|
|
285
|
+
|
|
286
|
+
React.useEffect(() => {
|
|
287
|
+
if (rest.autoFocus) {
|
|
288
|
+
setInputState('focused');
|
|
289
|
+
}
|
|
290
|
+
}, [rest.autoFocus]);
|
|
291
|
+
|
|
292
|
+
const defaultInputElement = multiline ? 'textarea' : 'input';
|
|
293
|
+
|
|
294
|
+
// FIXME it should be enough to forward refs. inputRef could be removed
|
|
295
|
+
const inputRefProps = inputComponent
|
|
296
|
+
? {inputRef}
|
|
297
|
+
: {
|
|
298
|
+
ref: combineRefs(ref, inputRef),
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
const props = {
|
|
302
|
+
...rest,
|
|
303
|
+
maxLength,
|
|
304
|
+
autoComplete: autoCompleteProp,
|
|
305
|
+
...inputProps,
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
const startIconWidth = `calc(${iconSize.small} + ${styles.fieldElementsGap}px)`;
|
|
309
|
+
const endIconWidth = `calc(${styles.iconButtonSize} + ${styles.fieldEndIconGap}px)`;
|
|
310
|
+
|
|
311
|
+
const isShrinked = shrinkLabel || inputState === 'focused' || inputState === 'filled';
|
|
312
|
+
const scale = isShrinked
|
|
313
|
+
? isTabletOrSmaller
|
|
314
|
+
? fieldVars.labelScaleMobile
|
|
315
|
+
: fieldVars.labelScaleDesktop
|
|
316
|
+
: 1;
|
|
317
|
+
const labelStyle = {
|
|
318
|
+
left: `calc(${styles.fieldLeftPadding}px + ${startIcon ? startIconWidth : '0px'})`,
|
|
319
|
+
// shrinking means applying a scale transformation, so width will be proportionally reduced.
|
|
320
|
+
// Let's keep the original width.
|
|
321
|
+
width: `calc((100% - ${styles.fieldLeftPadding}px - ${startIcon ? startIconWidth : '0px'} - ${
|
|
322
|
+
endIcon || endIconOverlay ? endIconWidth : `${styles.fieldRightPadding}px`
|
|
323
|
+
}) / ${scale})`,
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
/* Workaround to avoid huge bullets on ios devices (-apple-system font related) */
|
|
327
|
+
const fontFamily =
|
|
328
|
+
rest.type === 'password' && characterCount > 0 ? 'Lucida Grande, Arial, sans-serif' : 'inherit';
|
|
329
|
+
|
|
330
|
+
return (
|
|
331
|
+
<FieldContainer
|
|
332
|
+
disabled={rest.disabled}
|
|
333
|
+
helperText={
|
|
334
|
+
<HelperText
|
|
335
|
+
error={error}
|
|
336
|
+
leftText={helperText}
|
|
337
|
+
leftTextId={leftHelperTextid}
|
|
338
|
+
rightTextId={rightHelperTextid}
|
|
339
|
+
rightText={multiline && maxLength ? `${characterCount}/${maxLength}` : undefined}
|
|
340
|
+
rightTextLabel={
|
|
341
|
+
multiline && maxLength
|
|
342
|
+
? t(
|
|
343
|
+
texts.formTextMultilineMaxCount || tokens.formTextMultilineMaxCount,
|
|
344
|
+
characterCount,
|
|
345
|
+
maxLength
|
|
346
|
+
)
|
|
347
|
+
: undefined
|
|
348
|
+
}
|
|
349
|
+
/>
|
|
350
|
+
}
|
|
351
|
+
multiline={multiline}
|
|
352
|
+
fullWidth={fullWidth}
|
|
353
|
+
fieldRef={fieldRef}
|
|
354
|
+
readOnly={rest.readOnly}
|
|
355
|
+
dataAttributes={dataAttributes}
|
|
356
|
+
focus={focus}
|
|
357
|
+
>
|
|
358
|
+
<ThemeVariant variant="default">
|
|
359
|
+
{startIcon && (
|
|
360
|
+
<div className={styles.startIcon} data-testid="startIcon">
|
|
361
|
+
{startIcon}
|
|
362
|
+
</div>
|
|
363
|
+
)}
|
|
364
|
+
|
|
365
|
+
{prefix && (
|
|
366
|
+
<div
|
|
367
|
+
aria-hidden
|
|
368
|
+
className={classNames(
|
|
369
|
+
styles.prefix,
|
|
370
|
+
hasLabel ? styles.inputWithLabel : styles.inputWithoutLabel
|
|
371
|
+
)}
|
|
372
|
+
style={{
|
|
373
|
+
opacity: inputState === 'default' ? 0 : 1,
|
|
374
|
+
}}
|
|
375
|
+
>
|
|
376
|
+
<Text3 color={vars.colors.textSecondary} regular wordBreak={false}>
|
|
377
|
+
{prefix}
|
|
378
|
+
</Text3>
|
|
379
|
+
</div>
|
|
380
|
+
)}
|
|
381
|
+
{label && (
|
|
382
|
+
<Label
|
|
383
|
+
style={labelStyle}
|
|
384
|
+
error={error}
|
|
385
|
+
forId={id}
|
|
386
|
+
inputState={inputState}
|
|
387
|
+
shrinkLabel={shrinkLabel}
|
|
388
|
+
showOptional={!required && showOptionalLabel}
|
|
389
|
+
>
|
|
390
|
+
{label}
|
|
391
|
+
</Label>
|
|
392
|
+
)}
|
|
393
|
+
<div className={styles.fullWidth}>
|
|
394
|
+
<Text3 as="div" regular>
|
|
395
|
+
{React.createElement(inputComponent || defaultInputElement, {
|
|
396
|
+
...inputRefProps,
|
|
397
|
+
...props,
|
|
398
|
+
id,
|
|
399
|
+
...(required && {'aria-required': true}),
|
|
400
|
+
...(error && {'aria-invalid': true}),
|
|
401
|
+
style: {
|
|
402
|
+
paddingRight: endIcon
|
|
403
|
+
? 0
|
|
404
|
+
: endIconOverlay
|
|
405
|
+
? endIconWidth
|
|
406
|
+
: styles.fieldRightPadding,
|
|
407
|
+
paddingLeft: prefix
|
|
408
|
+
? 0
|
|
409
|
+
: startIcon
|
|
410
|
+
? `calc(${startIconWidth} + ${styles.fieldLeftPadding}px)`
|
|
411
|
+
: styles.fieldLeftPadding,
|
|
412
|
+
...props.style,
|
|
413
|
+
fontFamily,
|
|
414
|
+
},
|
|
415
|
+
className: multiline
|
|
416
|
+
? classNames(
|
|
417
|
+
styles.textArea,
|
|
418
|
+
hasLabel ? styles.textAreaWithLabel : styles.textAreaWithoutLabel
|
|
419
|
+
)
|
|
420
|
+
: classNames(
|
|
421
|
+
styles.input,
|
|
422
|
+
hasLabel ? styles.inputWithLabel : styles.inputWithoutLabel,
|
|
423
|
+
{
|
|
424
|
+
[styles.inputFirefoxStyles]: isFirefox(),
|
|
425
|
+
// Hide webkit placeholder when label is not shrinked and value is empty
|
|
426
|
+
[styles.hiddenDatePlaceholder]:
|
|
427
|
+
isDateInput && inputState === 'default',
|
|
428
|
+
// Force height of input when value is empty to avoid field from having height 0 in iOS
|
|
429
|
+
[styles.emptyDateValue]: isDateInput && inputState !== 'filled',
|
|
430
|
+
}
|
|
431
|
+
),
|
|
432
|
+
onFocus: (event: React.FocusEvent<HTMLInputElement>) => {
|
|
433
|
+
setInputState('focused');
|
|
434
|
+
onFocus?.(event);
|
|
435
|
+
},
|
|
436
|
+
onBlur: (event: React.FocusEvent<HTMLInputElement>) => {
|
|
437
|
+
if (event.target.value.length > 0) {
|
|
438
|
+
setInputState('filled');
|
|
439
|
+
} else {
|
|
440
|
+
setInputState('default');
|
|
441
|
+
}
|
|
442
|
+
onBlur?.(event);
|
|
443
|
+
},
|
|
444
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
445
|
+
// Workaround for systems where maxlength prop is applied onBlur (https://caniuse.com/#feat=maxlength)
|
|
446
|
+
if (maxLength === undefined || event.target.value.length <= maxLength) {
|
|
447
|
+
setCharacterCount(event.target.value.length);
|
|
448
|
+
|
|
449
|
+
// Browser's autofill can change the value without focusing
|
|
450
|
+
if (event.target.value.length > 0 && inputState !== 'focused') {
|
|
451
|
+
setInputState(
|
|
452
|
+
event.target.value.length > 0 ? 'filled' : 'default'
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
props.onChange?.(event);
|
|
457
|
+
} else {
|
|
458
|
+
event.stopPropagation();
|
|
459
|
+
event.preventDefault();
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
defaultValue,
|
|
463
|
+
value,
|
|
464
|
+
...(error && {'aria-invalid': true}),
|
|
465
|
+
...((helperText || (multiline && maxLength)) && {
|
|
466
|
+
'aria-describedby': `${leftHelperTextid} ${rightHelperTextid}`,
|
|
467
|
+
}),
|
|
468
|
+
...(preventCopy && {
|
|
469
|
+
onCopy: preventCopyHandler,
|
|
470
|
+
onCut: preventCopyHandler,
|
|
471
|
+
}),
|
|
472
|
+
})}
|
|
473
|
+
</Text3>
|
|
474
|
+
</div>
|
|
475
|
+
{endIcon && (
|
|
476
|
+
<div className={styles.endIconContainer} data-testid="endIcon">
|
|
477
|
+
{endIcon}
|
|
478
|
+
</div>
|
|
479
|
+
)}
|
|
480
|
+
{endIconOverlay}
|
|
481
|
+
</ThemeVariant>
|
|
482
|
+
</FieldContainer>
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
const Autosuggest = React.lazy(() => import(/* webpackChunkName: "react-autosuggest" */ 'react-autosuggest'));
|
|
488
|
+
|
|
489
|
+
export const TextFieldBaseAutosuggest = React.forwardRef<any, TextFieldBaseProps>(
|
|
490
|
+
(
|
|
491
|
+
{
|
|
492
|
+
getSuggestions,
|
|
493
|
+
id: idProp,
|
|
494
|
+
shouldShowSuggestions = 'focus',
|
|
495
|
+
withSuggestionsEmptyCase = false,
|
|
496
|
+
...props
|
|
497
|
+
},
|
|
498
|
+
ref
|
|
499
|
+
) => {
|
|
500
|
+
const [suggestions, setSuggestions] = React.useState<ReadonlyArray<string>>([]);
|
|
501
|
+
const [areSuggestionsShown, setAreSuggestionsShown] = React.useState(false);
|
|
502
|
+
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
503
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
504
|
+
const {platformOverrides, texts, t} = useTheme();
|
|
505
|
+
const reactId = React.useId();
|
|
506
|
+
const id = idProp || reactId;
|
|
507
|
+
const autoSuggestId = React.useId();
|
|
508
|
+
|
|
509
|
+
const suggestionEmptyCaseText =
|
|
510
|
+
typeof withSuggestionsEmptyCase === 'string'
|
|
511
|
+
? withSuggestionsEmptyCase
|
|
512
|
+
: texts.searchFieldSuggestionsEmptyCase || t(tokens.searchFieldSuggestionsEmptyCase);
|
|
513
|
+
|
|
514
|
+
if (getSuggestions && (props.value === undefined || props.defaultValue !== undefined)) {
|
|
515
|
+
throw Error('Fields with suggestions must be used in controlled mode');
|
|
516
|
+
}
|
|
517
|
+
return getSuggestions ? (
|
|
518
|
+
<React.Suspense
|
|
519
|
+
fallback={
|
|
520
|
+
<TextFieldBase
|
|
521
|
+
{...props}
|
|
522
|
+
// This label override while loading is needed in acceptance tests because
|
|
523
|
+
// while the test is typing, the component could be remounted.
|
|
524
|
+
// By hiding the label, we ensure that the test selects the loaded component
|
|
525
|
+
label={isRunningAcceptanceTest(platformOverrides) ? '' : props.label}
|
|
526
|
+
autoComplete="off"
|
|
527
|
+
ref={ref}
|
|
528
|
+
id={id}
|
|
529
|
+
/>
|
|
530
|
+
}
|
|
531
|
+
>
|
|
532
|
+
<Autosuggest
|
|
533
|
+
id={autoSuggestId}
|
|
534
|
+
inputProps={{
|
|
535
|
+
...props,
|
|
536
|
+
id,
|
|
537
|
+
autoComplete: 'off',
|
|
538
|
+
// @ts-expect-error Autosuggest expects slightly different types
|
|
539
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>, {newValue}) => {
|
|
540
|
+
// hack to mutate event value
|
|
541
|
+
e.target = {...e.target, value: newValue};
|
|
542
|
+
e.currentTarget = {...e.currentTarget, value: newValue};
|
|
543
|
+
props.onChange?.(e);
|
|
544
|
+
},
|
|
545
|
+
}}
|
|
546
|
+
renderInputComponent={(inputProps) => {
|
|
547
|
+
// The `Autosuggest.RenderInputComponentProps` type is missing the `key` property
|
|
548
|
+
const {key, ...inputPropsWithoutKey} = inputProps as Record<string, any>;
|
|
549
|
+
// extract key from inputProps to avoid React warning:
|
|
550
|
+
// "A props object containing a "key" prop is being spread into JSX"
|
|
551
|
+
return (
|
|
552
|
+
<TextFieldBase
|
|
553
|
+
key={key}
|
|
554
|
+
role="combobox" // react-autosuggest adds this role to the container, but according to ARIA specs it should be on the input
|
|
555
|
+
{...(inputPropsWithoutKey as TextFieldBaseProps)}
|
|
556
|
+
fieldRef={containerRef}
|
|
557
|
+
inputRef={combineRefs(inputRef, props.inputRef, ref)}
|
|
558
|
+
/>
|
|
559
|
+
);
|
|
560
|
+
}}
|
|
561
|
+
suggestions={suggestions}
|
|
562
|
+
shouldRenderSuggestions={(value) =>
|
|
563
|
+
shouldShowSuggestions === 'focus' || value.trim().length >= shouldShowSuggestions
|
|
564
|
+
}
|
|
565
|
+
onSuggestionsFetchRequested={({value}) => {
|
|
566
|
+
const matchedSuggestions = getSuggestions(value);
|
|
567
|
+
setAreSuggestionsShown(true);
|
|
568
|
+
setSuggestions(matchedSuggestions);
|
|
569
|
+
}}
|
|
570
|
+
onSuggestionsClearRequested={() => {
|
|
571
|
+
setAreSuggestionsShown(false);
|
|
572
|
+
setSuggestions([]);
|
|
573
|
+
}}
|
|
574
|
+
getSuggestionValue={(suggestion: any) => suggestion}
|
|
575
|
+
renderSuggestion={(suggestion: any, {isHighlighted}) => (
|
|
576
|
+
<div
|
|
577
|
+
role="menuitem"
|
|
578
|
+
className={classNames(styles.menuItem, {
|
|
579
|
+
[styles.menuItemSelected]: isHighlighted,
|
|
580
|
+
})}
|
|
581
|
+
>
|
|
582
|
+
<Text3 regular>{suggestion}</Text3>
|
|
583
|
+
</div>
|
|
584
|
+
)}
|
|
585
|
+
renderSuggestionsContainer={(options) => {
|
|
586
|
+
if (!areSuggestionsShown) {
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// extract key from containerProps to avoid React warning:
|
|
591
|
+
// "A props object containing a "key" prop is being spread into JSX"
|
|
592
|
+
const {key, ...containerPropsWithoutKey} = options.containerProps;
|
|
593
|
+
const children =
|
|
594
|
+
suggestions.length === 0 && withSuggestionsEmptyCase ? (
|
|
595
|
+
<div role="status" className={classNames(styles.menuItemBase)}>
|
|
596
|
+
<Text3 regular color={vars.colors.textSecondary}>
|
|
597
|
+
{suggestionEmptyCaseText}
|
|
598
|
+
</Text3>
|
|
599
|
+
</div>
|
|
600
|
+
) : (
|
|
601
|
+
options.children
|
|
602
|
+
);
|
|
603
|
+
|
|
604
|
+
if (!children) {
|
|
605
|
+
return null;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
return (
|
|
609
|
+
<div
|
|
610
|
+
{...containerPropsWithoutKey}
|
|
611
|
+
key={key}
|
|
612
|
+
style={{
|
|
613
|
+
width: containerRef.current ? containerRef.current.clientWidth + 2 : 0, // +2 due to borders (input)
|
|
614
|
+
}}
|
|
615
|
+
className={styles.suggestionsContainer}
|
|
616
|
+
aria-label={`${props.label} ${texts.menuLabelSuffix || t(tokens.menuLabelSuffix)}`}
|
|
617
|
+
>
|
|
618
|
+
{children}
|
|
619
|
+
</div>
|
|
620
|
+
);
|
|
621
|
+
}}
|
|
622
|
+
/>
|
|
623
|
+
</React.Suspense>
|
|
624
|
+
) : (
|
|
625
|
+
<TextFieldBase {...props} id={id} ref={ref} />
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
);
|