@telefonica/mistica 16.60.0 → 16.62.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 +16 -16
- package/dist/align.css-mistica.js +2 -2
- package/dist/autocomplete.css-mistica.js +6 -6
- package/dist/avatar.css-mistica.js +3 -3
- package/dist/badge.css-mistica.js +7 -7
- package/dist/box.css-mistica.js +15 -15
- package/dist/boxed.css-mistica.js +31 -31
- 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 +10 -10
- package/dist/button-layout.css-mistica.js +21 -21
- package/dist/button.css-mistica.js +51 -51
- package/dist/callout.css-mistica.js +16 -16
- package/dist/card-internal.css-mistica.js +38 -38
- package/dist/carousel.css-mistica.js +18 -18
- package/dist/checkbox.css-mistica.js +21 -21
- package/dist/chip.css-mistica.js +30 -30
- package/dist/circle.css-mistica.js +2 -2
- package/dist/community/advanced-data-card.css-mistica.js +26 -26
- package/dist/community/blocks.css-mistica.js +3 -3
- package/dist/community/example-component.css-mistica.js +2 -2
- package/dist/counter.css-mistica.js +12 -12
- package/dist/cover-hero.css-mistica.js +16 -16
- package/dist/credit-card-number-field.css-mistica.js +6 -6
- package/dist/date-field.css-mistica.js +1 -1
- package/dist/date-time-picker.css-mistica.js +2 -2
- package/dist/dialog.css-mistica.js +15 -15
- package/dist/divider.css-mistica.js +5 -5
- package/dist/double-field.css-mistica.js +4 -4
- package/dist/drawer.css-mistica.js +15 -15
- package/dist/empty-state-card.css-mistica.js +4 -4
- package/dist/empty-state.css-mistica.js +14 -14
- package/dist/fade-in.css-mistica.js +1 -1
- package/dist/feedback.css-mistica.js +14 -14
- package/dist/file-upload.css-mistica.js +14 -14
- package/dist/fixed-footer-layout.css-mistica.js +12 -12
- package/dist/fixed-footer-layout.d.ts +6 -1
- package/dist/fixed-footer-layout.js +29 -28
- package/dist/form.css-mistica.js +2 -2
- package/dist/grid-layout.css-mistica.js +9 -9
- package/dist/grid.css-mistica.js +147 -147
- package/dist/header.css-mistica.js +5 -5
- package/dist/hero.css-mistica.js +11 -11
- package/dist/horizontal-scroll.css-mistica.js +3 -3
- package/dist/icon-button.css-mistica.js +66 -66
- package/dist/icons/icon-chevron.css-mistica.js +6 -6
- package/dist/icons/icon-error.css-mistica.js +3 -3
- package/dist/image.css-mistica.js +11 -11
- package/dist/image.js +8 -1
- package/dist/inline.css-mistica.js +16 -16
- package/dist/list.css-mistica.js +15 -15
- package/dist/loading-bar.css-mistica.js +5 -5
- package/dist/loading-screen.css-mistica.js +15 -15
- package/dist/logo.css-mistica.js +9 -9
- package/dist/menu.css-mistica.js +24 -24
- package/dist/mosaic.css-mistica.js +3 -3
- package/dist/navigation-bar.css-mistica.js +45 -45
- package/dist/navigation-breadcrumbs.css-mistica.js +5 -5
- package/dist/package-version.js +2 -2
- package/dist/pin-field.css-mistica.js +10 -10
- package/dist/popover.css-mistica.js +2 -2
- package/dist/progress-bar.css-mistica.js +12 -12
- package/dist/radio-button.css-mistica.js +33 -33
- package/dist/rating.css-mistica.js +12 -12
- package/dist/responsive-layout.css-mistica.js +20 -20
- package/dist/screen-reader-only.css-mistica.js +2 -2
- package/dist/select.css-mistica.js +29 -29
- package/dist/sheet-action-row.css-mistica.js +2 -2
- package/dist/sheet-common.css-mistica.js +16 -16
- package/dist/sheet-info.css-mistica.js +4 -4
- package/dist/skeletons.css-mistica.js +12 -12
- package/dist/skins/skin-contract.css-mistica.js +686 -686
- package/dist/skip-link.css-mistica.js +3 -3
- package/dist/slider.css-mistica.js +28 -28
- package/dist/snackbar.css-mistica.js +16 -16
- package/dist/spinner.css-mistica.js +5 -5
- package/dist/square.css-mistica.js +2 -2
- package/dist/stack.css-mistica.js +9 -9
- package/dist/stacking-group.css-mistica.js +2 -2
- package/dist/stepper.css-mistica.js +16 -16
- package/dist/switch-component.css-mistica.js +53 -53
- package/dist/table.css-mistica.js +24 -24
- package/dist/tabs.css-mistica.js +30 -30
- package/dist/tag.css-mistica.js +5 -5
- package/dist/text-field-base.css-mistica.js +30 -30
- package/dist/text-field-components.css-mistica.js +19 -19
- package/dist/text-link.css-mistica.js +10 -10
- package/dist/text.css-mistica.js +13 -13
- package/dist/theme-context.css-mistica.js +2 -2
- package/dist/timeline.css-mistica.js +18 -18
- package/dist/timer.css-mistica.js +13 -13
- package/dist/tooltip.css-mistica.js +12 -12
- package/dist/touchable.css-mistica.js +5 -5
- package/dist/utils/aspect-ratio-support.css-mistica.js +7 -7
- package/dist/video.css-mistica.js +2 -2
- package/dist/vivinho-loading-animation/vivinho-loading-animation.css-mistica.js +3 -3
- package/dist-es/accordion.css-mistica.js +7 -7
- package/dist-es/align.css-mistica.js +2 -2
- package/dist-es/autocomplete.css-mistica.js +2 -2
- package/dist-es/avatar.css-mistica.js +2 -2
- package/dist-es/badge.css-mistica.js +2 -2
- package/dist-es/box.css-mistica.js +15 -15
- package/dist-es/boxed.css-mistica.js +25 -25
- package/dist-es/button-fixed-footer-layout.js +12 -11
- package/dist-es/button-group.css-mistica.js +2 -2
- package/dist-es/button-layout.css-mistica.js +16 -16
- package/dist-es/button.css-mistica.js +38 -38
- package/dist-es/callout.css-mistica.js +12 -12
- package/dist-es/card-internal.css-mistica.js +20 -20
- package/dist-es/carousel.css-mistica.js +10 -10
- package/dist-es/checkbox.css-mistica.js +14 -14
- package/dist-es/chip.css-mistica.js +17 -17
- package/dist-es/circle.css-mistica.js +2 -2
- package/dist-es/community/advanced-data-card.css-mistica.js +7 -7
- package/dist-es/community/blocks.css-mistica.js +2 -2
- package/dist-es/community/example-component.css-mistica.js +2 -2
- package/dist-es/counter.css-mistica.js +2 -2
- package/dist-es/cover-hero.css-mistica.js +4 -4
- package/dist-es/credit-card-number-field.css-mistica.js +4 -4
- package/dist-es/date-field.css-mistica.js +1 -1
- package/dist-es/date-time-picker.css-mistica.js +2 -2
- package/dist-es/dialog.css-mistica.js +5 -5
- package/dist-es/divider.css-mistica.js +5 -5
- package/dist-es/double-field.css-mistica.js +4 -4
- package/dist-es/drawer.css-mistica.js +2 -2
- package/dist-es/empty-state-card.css-mistica.js +2 -2
- package/dist-es/empty-state.css-mistica.js +7 -7
- package/dist-es/fade-in.css-mistica.js +1 -1
- package/dist-es/feedback.css-mistica.js +2 -2
- package/dist-es/file-upload.css-mistica.js +8 -8
- package/dist-es/fixed-footer-layout.css-mistica.js +4 -4
- package/dist-es/fixed-footer-layout.js +57 -56
- package/dist-es/form.css-mistica.js +2 -2
- package/dist-es/grid-layout.css-mistica.js +4 -4
- package/dist-es/grid.css-mistica.js +127 -127
- package/dist-es/header.css-mistica.js +2 -2
- package/dist-es/hero.css-mistica.js +4 -4
- package/dist-es/horizontal-scroll.css-mistica.js +2 -2
- package/dist-es/icon-button.css-mistica.js +56 -56
- package/dist-es/icons/icon-chevron.css-mistica.js +4 -4
- package/dist-es/icons/icon-error.css-mistica.js +2 -2
- package/dist-es/image.css-mistica.js +4 -4
- package/dist-es/image.js +8 -1
- package/dist-es/inline.css-mistica.js +10 -10
- package/dist-es/list.css-mistica.js +2 -2
- package/dist-es/loading-bar.css-mistica.js +2 -2
- package/dist-es/loading-screen.css-mistica.js +5 -5
- package/dist-es/logo.css-mistica.js +7 -7
- package/dist-es/menu.css-mistica.js +15 -15
- package/dist-es/mosaic.css-mistica.js +2 -2
- package/dist-es/navigation-bar.css-mistica.js +20 -20
- package/dist-es/navigation-breadcrumbs.css-mistica.js +2 -2
- package/dist-es/package-version.js +2 -2
- package/dist-es/pin-field.css-mistica.js +2 -2
- package/dist-es/popover.css-mistica.js +2 -2
- package/dist-es/progress-bar.css-mistica.js +8 -8
- package/dist-es/radio-button.css-mistica.js +25 -25
- package/dist-es/rating.css-mistica.js +4 -4
- package/dist-es/responsive-layout.css-mistica.js +7 -7
- package/dist-es/screen-reader-only.css-mistica.js +2 -2
- package/dist-es/select.css-mistica.js +20 -20
- package/dist-es/sheet-action-row.css-mistica.js +2 -2
- package/dist-es/sheet-common.css-mistica.js +2 -2
- package/dist-es/sheet-info.css-mistica.js +2 -2
- package/dist-es/skeletons.css-mistica.js +8 -8
- package/dist-es/skins/skin-contract.css-mistica.js +686 -686
- package/dist-es/skip-link.css-mistica.js +2 -2
- package/dist-es/slider.css-mistica.js +20 -20
- package/dist-es/snackbar.css-mistica.js +5 -5
- package/dist-es/spinner.css-mistica.js +2 -2
- package/dist-es/square.css-mistica.js +2 -2
- package/dist-es/stack.css-mistica.js +7 -7
- package/dist-es/stacking-group.css-mistica.js +2 -2
- package/dist-es/stepper.css-mistica.js +4 -4
- package/dist-es/style.css +1 -1
- package/dist-es/switch-component.css-mistica.js +41 -41
- package/dist-es/table.css-mistica.js +11 -11
- package/dist-es/tabs.css-mistica.js +21 -21
- package/dist-es/tag.css-mistica.js +2 -2
- package/dist-es/text-field-base.css-mistica.js +17 -17
- package/dist-es/text-field-components.css-mistica.js +4 -4
- package/dist-es/text-link.css-mistica.js +9 -9
- package/dist-es/text.css-mistica.js +8 -8
- package/dist-es/theme-context.css-mistica.js +2 -2
- package/dist-es/timeline.css-mistica.js +11 -11
- package/dist-es/timer.css-mistica.js +7 -7
- package/dist-es/tooltip.css-mistica.js +3 -3
- package/dist-es/touchable.css-mistica.js +2 -2
- package/dist-es/utils/aspect-ratio-support.css-mistica.js +4 -4
- package/dist-es/video.css-mistica.js +2 -2
- package/dist-es/vivinho-loading-animation/vivinho-loading-animation.css-mistica.js +2 -2
- package/doc/components.md +19 -0
- package/doc/figma-mcp.md +136 -0
- package/doc/layout.md +20 -1
- package/doc/llms.md +18 -0
- package/doc/patterns.md +6 -17
- 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,187 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {useForm, useFieldProps} from './form-context';
|
|
4
|
+
import {useTheme} from './hooks';
|
|
5
|
+
import {TextFieldBaseAutosuggest} from './text-field-base';
|
|
6
|
+
import * as tokens from './text-tokens';
|
|
7
|
+
|
|
8
|
+
import type {CommonFormFieldProps} from './text-field-base';
|
|
9
|
+
|
|
10
|
+
type ExpirationDateValue = {
|
|
11
|
+
month: number | null;
|
|
12
|
+
year: number | null;
|
|
13
|
+
raw: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const MonthYearDateInput = ({inputRef, defaultValue, value, ...rest}: any) => {
|
|
17
|
+
const {texts, t} = useTheme();
|
|
18
|
+
const keyDownRef = React.useRef('');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 1) characters other than [0-9] and '/' are removed
|
|
22
|
+
* 2) automatically insert "/" as you type
|
|
23
|
+
* 3) the user must be able to remove text
|
|
24
|
+
*/
|
|
25
|
+
const format = (s: string) => {
|
|
26
|
+
// slash was removed
|
|
27
|
+
if (s.length === 2 && keyDownRef.current === 'Backspace') {
|
|
28
|
+
return s[0];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let value = '';
|
|
32
|
+
/**
|
|
33
|
+
* format after adding characters one by one in order to prevent unwanted results when
|
|
34
|
+
* writing multiple characters at the same time (for example, by using copy/paste)
|
|
35
|
+
*/
|
|
36
|
+
[...s].forEach((c) => {
|
|
37
|
+
value = (value + c)
|
|
38
|
+
.replace(
|
|
39
|
+
/[^0-9]/g,
|
|
40
|
+
'' // allow only numbers
|
|
41
|
+
)
|
|
42
|
+
.replace(
|
|
43
|
+
/^([2-9])$/g,
|
|
44
|
+
'0$1' // 3 -> 03
|
|
45
|
+
)
|
|
46
|
+
.replace(
|
|
47
|
+
/^(1{1})([3-9]{1})$/g,
|
|
48
|
+
'0$1/$2' // 13 -> 01/3
|
|
49
|
+
)
|
|
50
|
+
.replace(
|
|
51
|
+
/^0{1,}/g,
|
|
52
|
+
'0' // 00 -> 0
|
|
53
|
+
)
|
|
54
|
+
.replace(
|
|
55
|
+
/^([0-1]{1}[0-9]{1})([0-9]{1,2}).*/g,
|
|
56
|
+
'$1/$2' // 113 > 11/3
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (value.length === 2) {
|
|
61
|
+
return value + '/';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return value;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
68
|
+
keyDownRef.current = e.key;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<input
|
|
73
|
+
{...rest}
|
|
74
|
+
placeholder={texts.expirationDatePlaceholder || t(tokens.expirationDatePlaceholder)}
|
|
75
|
+
type="text"
|
|
76
|
+
inputMode="decimal"
|
|
77
|
+
maxLength="5" // MM/YY
|
|
78
|
+
onKeyDown={handleKeyDown}
|
|
79
|
+
onInput={(e) => {
|
|
80
|
+
const nextValue = format(e.currentTarget.value);
|
|
81
|
+
e.currentTarget.value = nextValue;
|
|
82
|
+
}}
|
|
83
|
+
value={value === undefined ? undefined : format(value)}
|
|
84
|
+
defaultValue={defaultValue === undefined ? undefined : format(defaultValue)}
|
|
85
|
+
ref={inputRef}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export interface CreditCardExpirationFieldProps extends CommonFormFieldProps {
|
|
91
|
+
validate?: (value: ExpirationDateValue | undefined, rawValue: string) => string | undefined;
|
|
92
|
+
onChangeValue?: (value: ExpirationDateValue) => void;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const CreditCardExpirationField = ({
|
|
96
|
+
disabled,
|
|
97
|
+
error,
|
|
98
|
+
helperText,
|
|
99
|
+
name,
|
|
100
|
+
label,
|
|
101
|
+
optional,
|
|
102
|
+
validate: validateProp,
|
|
103
|
+
validateOnBlurInsideForm,
|
|
104
|
+
onChange,
|
|
105
|
+
onChangeValue,
|
|
106
|
+
onBlur,
|
|
107
|
+
value,
|
|
108
|
+
autoComplete = 'cc-exp',
|
|
109
|
+
defaultValue,
|
|
110
|
+
dataAttributes,
|
|
111
|
+
...rest
|
|
112
|
+
}: CreditCardExpirationFieldProps): JSX.Element => {
|
|
113
|
+
const {texts, t} = useTheme();
|
|
114
|
+
const {setFormError, jumpToNext} = useForm();
|
|
115
|
+
|
|
116
|
+
const validate = (value: ExpirationDateValue, rawValue: string): string | undefined => {
|
|
117
|
+
const {month, year} = value;
|
|
118
|
+
if (!month || !year) {
|
|
119
|
+
return texts.formCreditCardExpirationError || t(tokens.formCreditCardExpirationError);
|
|
120
|
+
}
|
|
121
|
+
const currentDate = new Date();
|
|
122
|
+
const currentMonth = currentDate.getMonth() + 1;
|
|
123
|
+
const currentYear = currentDate.getFullYear();
|
|
124
|
+
if (year < currentYear) {
|
|
125
|
+
return texts.formCreditCardExpirationError || t(tokens.formCreditCardExpirationError);
|
|
126
|
+
}
|
|
127
|
+
if (year === currentYear && month < currentMonth) {
|
|
128
|
+
return texts.formCreditCardExpirationError || t(tokens.formCreditCardExpirationError);
|
|
129
|
+
}
|
|
130
|
+
return validateProp?.(value, rawValue);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const processValue = (s: any): ExpirationDateValue => {
|
|
134
|
+
const [month, year] = String(s)
|
|
135
|
+
.split('/')
|
|
136
|
+
.map((n) => parseInt(n));
|
|
137
|
+
|
|
138
|
+
const fullYear = Number.isInteger(year) ? 2000 + year : null;
|
|
139
|
+
return {month: month || null, year: fullYear, raw: s};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const fieldProps = useFieldProps({
|
|
143
|
+
name,
|
|
144
|
+
label,
|
|
145
|
+
value,
|
|
146
|
+
defaultValue,
|
|
147
|
+
processValue,
|
|
148
|
+
helperText,
|
|
149
|
+
optional,
|
|
150
|
+
error,
|
|
151
|
+
disabled,
|
|
152
|
+
onBlur,
|
|
153
|
+
validate,
|
|
154
|
+
validateOnBlurInsideForm,
|
|
155
|
+
onChange,
|
|
156
|
+
onChangeValue,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<TextFieldBaseAutosuggest
|
|
161
|
+
{...rest}
|
|
162
|
+
{...fieldProps}
|
|
163
|
+
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
164
|
+
fieldProps.onChange(event);
|
|
165
|
+
const rawValue = event.currentTarget.value;
|
|
166
|
+
const value = processValue(rawValue);
|
|
167
|
+
if (rawValue.length === 5) {
|
|
168
|
+
const error = validate?.(value, rawValue);
|
|
169
|
+
if (error) {
|
|
170
|
+
setFormError({name, error});
|
|
171
|
+
} else {
|
|
172
|
+
jumpToNext(name);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}}
|
|
176
|
+
autoComplete={autoComplete}
|
|
177
|
+
inputComponent={MonthYearDateInput}
|
|
178
|
+
dataAttributes={{
|
|
179
|
+
'component-name': 'CreditCardExpirationField',
|
|
180
|
+
testid: 'CreditCardExpirationField',
|
|
181
|
+
...dataAttributes,
|
|
182
|
+
}}
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export default CreditCardExpirationField;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {useForm} from './form-context';
|
|
4
|
+
import {useTheme} from './hooks';
|
|
5
|
+
import {getCvvLength} from './utils/credit-card';
|
|
6
|
+
import DoubleField from './double-field';
|
|
7
|
+
import Stack from './stack';
|
|
8
|
+
import CreditCardExpirationField from './credit-card-expiration-field';
|
|
9
|
+
import CreditCardNumberField from './credit-card-number-field';
|
|
10
|
+
import CvvField from './cvv-field';
|
|
11
|
+
import * as tokens from './text-tokens';
|
|
12
|
+
|
|
13
|
+
import type {CardOptions} from './utils/credit-card';
|
|
14
|
+
|
|
15
|
+
type CreditCardFieldsProps = {
|
|
16
|
+
numberFieldName?: string;
|
|
17
|
+
expirationFieldName?: string;
|
|
18
|
+
cvvFieldName?: string;
|
|
19
|
+
acceptedCards?: CardOptions;
|
|
20
|
+
children?: void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const CreditCardFields = ({
|
|
24
|
+
numberFieldName = 'ccNum',
|
|
25
|
+
expirationFieldName = 'ccExp',
|
|
26
|
+
cvvFieldName = 'ccCvv',
|
|
27
|
+
acceptedCards,
|
|
28
|
+
}: CreditCardFieldsProps): JSX.Element => {
|
|
29
|
+
const {values} = useForm();
|
|
30
|
+
const {texts, t} = useTheme();
|
|
31
|
+
const cvvLength = getCvvLength(String(values[numberFieldName]));
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Stack space={16}>
|
|
35
|
+
<CreditCardNumberField
|
|
36
|
+
acceptedCards={acceptedCards}
|
|
37
|
+
name={numberFieldName}
|
|
38
|
+
label={texts.formCreditCardNumberLabel || t(tokens.formCreditCardNumberLabel)}
|
|
39
|
+
/>
|
|
40
|
+
<DoubleField layout="60/40">
|
|
41
|
+
<CreditCardExpirationField
|
|
42
|
+
name={expirationFieldName}
|
|
43
|
+
label={texts.formCreditCardExpirationLabel || t(tokens.formCreditCardExpirationLabel)}
|
|
44
|
+
/>
|
|
45
|
+
<CvvField
|
|
46
|
+
acceptedCards={acceptedCards}
|
|
47
|
+
name={cvvFieldName}
|
|
48
|
+
label={texts.formCreditCardCvvLabel || t(tokens.formCreditCardCvvLabel)}
|
|
49
|
+
maxLength={cvvLength}
|
|
50
|
+
/>
|
|
51
|
+
</DoubleField>
|
|
52
|
+
</Stack>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default CreditCardFields;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {style, styleVariants} from '@vanilla-extract/css';
|
|
2
|
+
import {sprinkles} from './sprinkles.css';
|
|
3
|
+
|
|
4
|
+
export const flip = style({
|
|
5
|
+
perspective: 1000,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const baseIconContainer = style([
|
|
9
|
+
sprinkles({
|
|
10
|
+
display: 'flex',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
justifyContent: 'center',
|
|
13
|
+
height: '100%',
|
|
14
|
+
}),
|
|
15
|
+
{
|
|
16
|
+
backfaceVisibility: 'hidden',
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export const flipFront = style([
|
|
21
|
+
baseIconContainer,
|
|
22
|
+
sprinkles({
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
}),
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
export const flipBack = style([
|
|
28
|
+
baseIconContainer,
|
|
29
|
+
{
|
|
30
|
+
transform: 'rotateY(180deg)',
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
const flipInner = style([
|
|
35
|
+
sprinkles({
|
|
36
|
+
position: 'relative',
|
|
37
|
+
}),
|
|
38
|
+
{
|
|
39
|
+
transition: 'transform 0.4s',
|
|
40
|
+
transformStyle: 'preserve-3d',
|
|
41
|
+
},
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
export const variants = styleVariants({
|
|
45
|
+
default: [flipInner, style({transform: 'none'})],
|
|
46
|
+
backface: [flipInner, style({transform: 'rotateY(180deg)'})],
|
|
47
|
+
});
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {useForm, useFieldProps} from './form-context';
|
|
4
|
+
import {useTheme} from './hooks';
|
|
5
|
+
import {
|
|
6
|
+
getCreditCardNumberLength,
|
|
7
|
+
isAmericanExpress,
|
|
8
|
+
isVisa,
|
|
9
|
+
isMasterCard,
|
|
10
|
+
isValidCreditCardNumber,
|
|
11
|
+
} from './utils/credit-card';
|
|
12
|
+
import {TextFieldBaseAutosuggest} from './text-field-base';
|
|
13
|
+
import IconCreditCardVisaRegular from './generated/mistica-icons/icon-credit-card-visa-regular';
|
|
14
|
+
import IconVisa from './icons/icon-visa';
|
|
15
|
+
import IconMastercard from './icons/icon-mastercard';
|
|
16
|
+
import IconAmex from './icons/icon-amex';
|
|
17
|
+
import {useRifm} from 'rifm';
|
|
18
|
+
import {createChangeEvent} from './utils/dom';
|
|
19
|
+
import {combineRefs} from './utils/common';
|
|
20
|
+
import * as styles from './credit-card-number-field.css';
|
|
21
|
+
import {vars} from './skins/skin-contract.css';
|
|
22
|
+
import {iconSize} from './icon-button.css';
|
|
23
|
+
import * as tokens from './text-tokens';
|
|
24
|
+
|
|
25
|
+
import type {CardOptions} from './utils/credit-card';
|
|
26
|
+
import type {CommonFormFieldProps} from './text-field-base';
|
|
27
|
+
|
|
28
|
+
const format = (s?: string) => {
|
|
29
|
+
const sanitizedNumber = String(s ?? '').replace(/[^\d]/g, '');
|
|
30
|
+
return sanitizedNumber.match(/.{1,4}/g)?.join(' ') ?? sanitizedNumber;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type Props = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onInput'> & {
|
|
34
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
35
|
+
value?: string;
|
|
36
|
+
defaultValue?: string;
|
|
37
|
+
onInput?: (event: React.FormEvent<HTMLInputElement>) => void;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const CreditCardInput = ({inputRef, value, defaultValue, onChange, ...other}: Props) => {
|
|
41
|
+
const [selfValue, setSelfValue] = React.useState(defaultValue ?? '');
|
|
42
|
+
const ref = React.useRef<HTMLInputElement | null>(null);
|
|
43
|
+
|
|
44
|
+
const isControlledByParent = typeof value !== 'undefined';
|
|
45
|
+
const controlledValue = (isControlledByParent ? value : selfValue) as string;
|
|
46
|
+
|
|
47
|
+
const handleChangeValue = React.useCallback(
|
|
48
|
+
(newFormattedValue: string) => {
|
|
49
|
+
if (!isControlledByParent) {
|
|
50
|
+
setSelfValue(newFormattedValue);
|
|
51
|
+
}
|
|
52
|
+
if (ref.current) {
|
|
53
|
+
onChange?.(createChangeEvent(ref.current, newFormattedValue));
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
[isControlledByParent, onChange]
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const rifm = useRifm({
|
|
60
|
+
format,
|
|
61
|
+
value: controlledValue,
|
|
62
|
+
onChange: handleChangeValue,
|
|
63
|
+
accept: /[\d]+/g,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<input
|
|
68
|
+
{...other}
|
|
69
|
+
type="text"
|
|
70
|
+
inputMode="decimal"
|
|
71
|
+
maxLength={getCreditCardNumberLength(rifm.value) + 3} // We have to take into account formatting spaces
|
|
72
|
+
onChange={rifm.onChange}
|
|
73
|
+
value={rifm.value}
|
|
74
|
+
ref={combineRefs(inputRef, ref)}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const getAnimationTarget = (value?: string) => {
|
|
80
|
+
if (isVisa(value)) {
|
|
81
|
+
return <IconVisa size={iconSize.small} />;
|
|
82
|
+
}
|
|
83
|
+
if (isMasterCard(value)) {
|
|
84
|
+
return <IconMastercard size={iconSize.small} />;
|
|
85
|
+
}
|
|
86
|
+
if (isAmericanExpress(value)) {
|
|
87
|
+
return <IconAmex size={iconSize.small} />;
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const initialState = {
|
|
93
|
+
showBackface: false,
|
|
94
|
+
animationTarget: <IconCreditCardVisaRegular size={iconSize.small} />,
|
|
95
|
+
isAnimating: false,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const reducer = (
|
|
99
|
+
state: typeof initialState,
|
|
100
|
+
{
|
|
101
|
+
type,
|
|
102
|
+
value,
|
|
103
|
+
}: {
|
|
104
|
+
type: string;
|
|
105
|
+
value?: string;
|
|
106
|
+
}
|
|
107
|
+
) => {
|
|
108
|
+
if (type === 'INPUT') {
|
|
109
|
+
const animationTarget = getAnimationTarget(value);
|
|
110
|
+
if (animationTarget && !state.showBackface) {
|
|
111
|
+
return {animationTarget, showBackface: true, isAnimating: true};
|
|
112
|
+
}
|
|
113
|
+
if (!isVisa(value) && !isMasterCard(value) && !isAmericanExpress(value) && state.showBackface) {
|
|
114
|
+
return {animationTarget: state.animationTarget, showBackface: false, isAnimating: true};
|
|
115
|
+
}
|
|
116
|
+
if (animationTarget && state.showBackface) {
|
|
117
|
+
return {
|
|
118
|
+
...state,
|
|
119
|
+
animationTarget,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (type === 'TRANSITION_END') {
|
|
124
|
+
return {...state, isAnimating: false};
|
|
125
|
+
}
|
|
126
|
+
return state;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const CreditcardAdornment = ({value}: {value?: string}) => {
|
|
130
|
+
const [{showBackface, animationTarget, isAnimating}, dispatch] = React.useReducer(reducer, initialState);
|
|
131
|
+
React.useEffect(() => {
|
|
132
|
+
dispatch({type: 'INPUT', value});
|
|
133
|
+
}, [value]);
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<div className={styles.flip}>
|
|
137
|
+
<div
|
|
138
|
+
className={styles.variants[showBackface ? 'backface' : 'default']}
|
|
139
|
+
onTransitionEnd={() => isAnimating && dispatch({type: 'TRANSITION_END'})}
|
|
140
|
+
>
|
|
141
|
+
<div className={styles.flipFront}>
|
|
142
|
+
<IconCreditCardVisaRegular size={iconSize.small} color={vars.colors.neutralMedium} />
|
|
143
|
+
</div>
|
|
144
|
+
<div className={styles.flipBack}>{animationTarget}</div>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
interface CreditCardNumberFieldProps extends CommonFormFieldProps {
|
|
151
|
+
acceptedCards?: CardOptions;
|
|
152
|
+
onChangeValue?: (value: string, rawValue: string) => void;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const CreditCardNumberField = ({
|
|
156
|
+
disabled,
|
|
157
|
+
error,
|
|
158
|
+
helperText,
|
|
159
|
+
name,
|
|
160
|
+
label,
|
|
161
|
+
optional,
|
|
162
|
+
validate: validateProp,
|
|
163
|
+
validateOnBlurInsideForm,
|
|
164
|
+
onChange,
|
|
165
|
+
onChangeValue,
|
|
166
|
+
onBlur,
|
|
167
|
+
acceptedCards = {americanExpress: true, visa: true, masterCard: true},
|
|
168
|
+
value,
|
|
169
|
+
autoComplete = 'cc-number',
|
|
170
|
+
defaultValue,
|
|
171
|
+
dataAttributes,
|
|
172
|
+
...rest
|
|
173
|
+
}: CreditCardNumberFieldProps): JSX.Element => {
|
|
174
|
+
const {texts, t} = useTheme();
|
|
175
|
+
const {jumpToNext, rawValues, setFormError} = useForm();
|
|
176
|
+
|
|
177
|
+
const validate = (value: string | undefined, rawValue: string) => {
|
|
178
|
+
const error = texts.formCreditCardNumberError || t(tokens.formCreditCardNumberError);
|
|
179
|
+
if (isAmericanExpress(value) && !acceptedCards.americanExpress) {
|
|
180
|
+
return error;
|
|
181
|
+
}
|
|
182
|
+
if (isVisa(value) && !acceptedCards.visa) {
|
|
183
|
+
return error;
|
|
184
|
+
}
|
|
185
|
+
if (isMasterCard(value) && !acceptedCards.masterCard) {
|
|
186
|
+
return error;
|
|
187
|
+
}
|
|
188
|
+
if (!isValidCreditCardNumber(value)) {
|
|
189
|
+
return error;
|
|
190
|
+
}
|
|
191
|
+
if (getCreditCardNumberLength(value) !== value?.length) {
|
|
192
|
+
return error;
|
|
193
|
+
}
|
|
194
|
+
return validateProp?.(value, rawValue);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const processValue = (s: string) => s.replace(/\s/g, '');
|
|
198
|
+
|
|
199
|
+
const fieldProps = useFieldProps({
|
|
200
|
+
name,
|
|
201
|
+
label,
|
|
202
|
+
value,
|
|
203
|
+
defaultValue,
|
|
204
|
+
processValue,
|
|
205
|
+
helperText,
|
|
206
|
+
optional,
|
|
207
|
+
error,
|
|
208
|
+
disabled,
|
|
209
|
+
onBlur,
|
|
210
|
+
validate,
|
|
211
|
+
validateOnBlurInsideForm,
|
|
212
|
+
onChange,
|
|
213
|
+
onChangeValue,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<TextFieldBaseAutosuggest
|
|
218
|
+
{...rest}
|
|
219
|
+
{...fieldProps}
|
|
220
|
+
onChange={(event) => {
|
|
221
|
+
fieldProps.onChange(event);
|
|
222
|
+
const rawValue = event.currentTarget.value;
|
|
223
|
+
const value = processValue(rawValue);
|
|
224
|
+
if (value.length >= getCreditCardNumberLength(value)) {
|
|
225
|
+
const error = validate?.(value, rawValue);
|
|
226
|
+
if (error) {
|
|
227
|
+
setFormError({name, error});
|
|
228
|
+
} else {
|
|
229
|
+
jumpToNext(name);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}}
|
|
233
|
+
inputComponent={CreditCardInput}
|
|
234
|
+
autoComplete={autoComplete}
|
|
235
|
+
endIcon={<CreditcardAdornment value={value ?? rawValues[name] ?? ''} />}
|
|
236
|
+
dataAttributes={{
|
|
237
|
+
'component-name': 'CreditCardNumberField',
|
|
238
|
+
testid: 'CreditCardNumberField',
|
|
239
|
+
...dataAttributes,
|
|
240
|
+
}}
|
|
241
|
+
/>
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export default CreditCardNumberField;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {useTheme} from './hooks';
|
|
4
|
+
import IconCvvVisaMc from './icons/icon-cvv-visa-mc';
|
|
5
|
+
import IconCvvAmex from './icons/icon-cvv-amex';
|
|
6
|
+
import Popover from './popover';
|
|
7
|
+
import IconInformationRegular from './generated/mistica-icons/icon-information-regular';
|
|
8
|
+
import {useFieldProps, useForm} from './form-context';
|
|
9
|
+
import {TextFieldBaseAutosuggest} from './text-field-base';
|
|
10
|
+
import {IntegerInput} from './integer-field';
|
|
11
|
+
import Inline from './inline';
|
|
12
|
+
import Stack from './stack';
|
|
13
|
+
import Box from './box';
|
|
14
|
+
import Divider from './divider';
|
|
15
|
+
import Text2 from './text';
|
|
16
|
+
import {vars} from './skins/skin-contract.css';
|
|
17
|
+
import {pxToRem} from './utils/css';
|
|
18
|
+
import {iconButtonSize} from './text-field-base.css';
|
|
19
|
+
import Touchable from './touchable';
|
|
20
|
+
import * as tokens from './text-tokens';
|
|
21
|
+
|
|
22
|
+
import type {CommonFormFieldProps} from './text-field-base';
|
|
23
|
+
import type {CardOptions} from './utils/credit-card';
|
|
24
|
+
|
|
25
|
+
const TooltipContent = ({acceptedCards}: {acceptedCards: CardOptions}) => {
|
|
26
|
+
const {texts, t} = useTheme();
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<Box padding={8}>
|
|
31
|
+
<Stack space={8}>
|
|
32
|
+
<Inline space={16} alignItems="center">
|
|
33
|
+
<IconCvvVisaMc size={48} role="img" />
|
|
34
|
+
<Text2>
|
|
35
|
+
{texts.formCreditCardCvvTooltipVisaMc || t(tokens.formCreditCardCvvTooltipVisaMc)}
|
|
36
|
+
</Text2>
|
|
37
|
+
</Inline>
|
|
38
|
+
<Divider />
|
|
39
|
+
{acceptedCards?.americanExpress && (
|
|
40
|
+
<Inline space={16} alignItems="center">
|
|
41
|
+
<IconCvvAmex size={48} role="img" />
|
|
42
|
+
<Text2>
|
|
43
|
+
{texts.formCreditCardCvvTooltipAmex || t(tokens.formCreditCardCvvTooltipAmex)}
|
|
44
|
+
</Text2>
|
|
45
|
+
</Inline>
|
|
46
|
+
)}
|
|
47
|
+
</Stack>
|
|
48
|
+
</Box>
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export interface CvvFieldProps extends CommonFormFieldProps {
|
|
54
|
+
acceptedCards?: CardOptions;
|
|
55
|
+
onChangeValue?: (value: string, rawValue: string) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const CvvField = ({
|
|
59
|
+
disabled,
|
|
60
|
+
error,
|
|
61
|
+
helperText,
|
|
62
|
+
name,
|
|
63
|
+
label,
|
|
64
|
+
optional,
|
|
65
|
+
validate: validateProp,
|
|
66
|
+
validateOnBlurInsideForm,
|
|
67
|
+
onChange,
|
|
68
|
+
onChangeValue,
|
|
69
|
+
onBlur,
|
|
70
|
+
acceptedCards = {americanExpress: true, visa: true, masterCard: true},
|
|
71
|
+
maxLength = 4,
|
|
72
|
+
value,
|
|
73
|
+
autoComplete = 'cc-csc',
|
|
74
|
+
defaultValue,
|
|
75
|
+
dataAttributes,
|
|
76
|
+
...rest
|
|
77
|
+
}: CvvFieldProps): JSX.Element => {
|
|
78
|
+
const {texts, t} = useTheme();
|
|
79
|
+
const {setFormError, jumpToNext} = useForm();
|
|
80
|
+
const [isCvvHelpOpen, setIsCvvHelpOpen] = React.useState(false);
|
|
81
|
+
|
|
82
|
+
const validate = (value: string, rawValue: string) => {
|
|
83
|
+
if (value.length !== maxLength) {
|
|
84
|
+
return texts.formCreditCardCvvError || t(tokens.formCreditCardCvvError);
|
|
85
|
+
}
|
|
86
|
+
return validateProp?.(value, rawValue);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const processValue = (s: string) => s;
|
|
90
|
+
|
|
91
|
+
const fieldProps = useFieldProps({
|
|
92
|
+
name,
|
|
93
|
+
label,
|
|
94
|
+
value,
|
|
95
|
+
defaultValue,
|
|
96
|
+
processValue,
|
|
97
|
+
helperText,
|
|
98
|
+
optional,
|
|
99
|
+
error,
|
|
100
|
+
disabled,
|
|
101
|
+
onBlur,
|
|
102
|
+
validate,
|
|
103
|
+
validateOnBlurInsideForm,
|
|
104
|
+
onChange,
|
|
105
|
+
onChangeValue,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const iconSize = pxToRem(16);
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<TextFieldBaseAutosuggest
|
|
112
|
+
{...rest}
|
|
113
|
+
{...fieldProps}
|
|
114
|
+
maxLength={maxLength}
|
|
115
|
+
onChange={(event) => {
|
|
116
|
+
fieldProps.onChange(event);
|
|
117
|
+
const rawValue = event.currentTarget.value;
|
|
118
|
+
const value = processValue(rawValue);
|
|
119
|
+
if (value.length === maxLength) {
|
|
120
|
+
const error = validate(value, rawValue);
|
|
121
|
+
if (error) {
|
|
122
|
+
setFormError({name, error});
|
|
123
|
+
} else {
|
|
124
|
+
jumpToNext(name);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}}
|
|
128
|
+
endIcon={
|
|
129
|
+
<Popover
|
|
130
|
+
position="top"
|
|
131
|
+
open={isCvvHelpOpen}
|
|
132
|
+
children={<TooltipContent acceptedCards={acceptedCards} />}
|
|
133
|
+
onClose={() => setIsCvvHelpOpen(false)}
|
|
134
|
+
target={
|
|
135
|
+
<div style={{width: iconSize, height: iconSize}}>
|
|
136
|
+
<Touchable
|
|
137
|
+
style={{
|
|
138
|
+
display: 'flex',
|
|
139
|
+
alignItems: 'center',
|
|
140
|
+
justifyContent: 'center',
|
|
141
|
+
width: iconButtonSize,
|
|
142
|
+
height: iconButtonSize,
|
|
143
|
+
position: 'relative',
|
|
144
|
+
left: `calc(-1 * (${iconButtonSize} - ${iconSize}) / 2)`,
|
|
145
|
+
top: `calc(-1 * (${iconButtonSize} - ${iconSize}) / 2)`,
|
|
146
|
+
}}
|
|
147
|
+
onPress={() => setIsCvvHelpOpen(!isCvvHelpOpen)}
|
|
148
|
+
aria-label={
|
|
149
|
+
isCvvHelpOpen
|
|
150
|
+
? texts.formCreditCardCvvTooltipVisaMcButtonClose ||
|
|
151
|
+
t(tokens.formCreditCardCvvTooltipVisaMcButtonClose)
|
|
152
|
+
: texts.formCreditCardCvvTooltipVisaMcButtonOpen ||
|
|
153
|
+
t(tokens.formCreditCardCvvTooltipVisaMcButtonOpen)
|
|
154
|
+
}
|
|
155
|
+
>
|
|
156
|
+
<IconInformationRegular size={iconSize} color={vars.colors.neutralMedium} />
|
|
157
|
+
</Touchable>
|
|
158
|
+
</div>
|
|
159
|
+
}
|
|
160
|
+
/>
|
|
161
|
+
}
|
|
162
|
+
autoComplete={autoComplete}
|
|
163
|
+
inputComponent={IntegerInput}
|
|
164
|
+
dataAttributes={{'component-name': 'CvvField', testid: 'CvvField', ...dataAttributes}}
|
|
165
|
+
/>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export default CvvField;
|