@automattic/plans-grid-next 1.0.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/CHANGELOG.md +4 -0
- package/README.md +3 -0
- package/dist/cjs/__mocks__/wpcom-proxy-request.js +17 -0
- package/dist/cjs/__mocks__/wpcom-proxy-request.js.map +1 -0
- package/dist/cjs/_media-queries.scss +14 -0
- package/dist/cjs/_mixins.scss +15 -0
- package/dist/cjs/_shared.scss +174 -0
- package/dist/cjs/components/comparison-grid/index.js +527 -0
- package/dist/cjs/components/comparison-grid/index.js.map +1 -0
- package/dist/cjs/components/comparison-grid/index.stories.js +74 -0
- package/dist/cjs/components/comparison-grid/index.stories.js.map +1 -0
- package/dist/cjs/components/comparison-grid/style.scss +318 -0
- package/dist/cjs/components/dropdown-option.js +33 -0
- package/dist/cjs/components/dropdown-option.js.map +1 -0
- package/dist/cjs/components/features-grid/billing-timeframes.js +15 -0
- package/dist/cjs/components/features-grid/billing-timeframes.js.map +1 -0
- package/dist/cjs/components/features-grid/client-logo-list/client-list.js +106 -0
- package/dist/cjs/components/features-grid/client-logo-list/client-list.js.map +1 -0
- package/dist/cjs/components/features-grid/client-logo-list/index.js +17 -0
- package/dist/cjs/components/features-grid/client-logo-list/index.js.map +1 -0
- package/dist/cjs/components/features-grid/client-logo-list/style.scss +52 -0
- package/dist/cjs/components/features-grid/enterprise-features.js +41 -0
- package/dist/cjs/components/features-grid/enterprise-features.js.map +1 -0
- package/dist/cjs/components/features-grid/index.js +130 -0
- package/dist/cjs/components/features-grid/index.js.map +1 -0
- package/dist/cjs/components/features-grid/index.stories.js +112 -0
- package/dist/cjs/components/features-grid/index.stories.js.map +1 -0
- package/dist/cjs/components/features-grid/mobile-free-domain.js +25 -0
- package/dist/cjs/components/features-grid/mobile-free-domain.js.map +1 -0
- package/dist/cjs/components/features-grid/plan-features-list.js +56 -0
- package/dist/cjs/components/features-grid/plan-features-list.js.map +1 -0
- package/dist/cjs/components/features-grid/plan-headers.js +15 -0
- package/dist/cjs/components/features-grid/plan-headers.js.map +1 -0
- package/dist/cjs/components/features-grid/plan-logos.js +12 -0
- package/dist/cjs/components/features-grid/plan-logos.js.map +1 -0
- package/dist/cjs/components/features-grid/plan-prices.js +14 -0
- package/dist/cjs/components/features-grid/plan-prices.js.map +1 -0
- package/dist/cjs/components/features-grid/plan-tagline.js +12 -0
- package/dist/cjs/components/features-grid/plan-tagline.js.map +1 -0
- package/dist/cjs/components/features-grid/previous-features-included-title.js +36 -0
- package/dist/cjs/components/features-grid/previous-features-included-title.js.map +1 -0
- package/dist/cjs/components/features-grid/spotlight-plan.js +24 -0
- package/dist/cjs/components/features-grid/spotlight-plan.js.map +1 -0
- package/dist/cjs/components/features-grid/spotlight-plan.scss +5 -0
- package/dist/cjs/components/features-grid/style.scss +630 -0
- package/dist/cjs/components/features-grid/table.js +38 -0
- package/dist/cjs/components/features-grid/table.js.map +1 -0
- package/dist/cjs/components/features-grid/top-buttons.js +15 -0
- package/dist/cjs/components/features-grid/top-buttons.js.map +1 -0
- package/dist/cjs/components/features.js +72 -0
- package/dist/cjs/components/features.js.map +1 -0
- package/dist/cjs/components/item.js +9 -0
- package/dist/cjs/components/item.js.map +1 -0
- package/dist/cjs/components/plan-button/index.js +21 -0
- package/dist/cjs/components/plan-button/index.js.map +1 -0
- package/dist/cjs/components/plan-button/style.scss +179 -0
- package/dist/cjs/components/plan-div-td-container.js +9 -0
- package/dist/cjs/components/plan-div-td-container.js.map +1 -0
- package/dist/cjs/components/plan-logo.js +45 -0
- package/dist/cjs/components/plan-logo.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-dropdown.js +39 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-dropdown.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-selector.js +12 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-selector.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-toggle.js +55 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-toggle.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/components/popup-messages.js +108 -0
- package/dist/cjs/components/plan-type-selector/components/popup-messages.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-interval-options.js +56 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-interval-options.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discount.js +45 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discount.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js +68 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/index.js +27 -0
- package/dist/cjs/components/plan-type-selector/index.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/style.scss +196 -0
- package/dist/cjs/components/plans-2023-tooltip.js +46 -0
- package/dist/cjs/components/plans-2023-tooltip.js.map +1 -0
- package/dist/cjs/components/popular-badge.js +16 -0
- package/dist/cjs/components/popular-badge.js.map +1 -0
- package/dist/cjs/components/shared/action-button/index.js +91 -0
- package/dist/cjs/components/shared/action-button/index.js.map +1 -0
- package/dist/cjs/components/shared/action-button/style.scss +12 -0
- package/dist/cjs/components/shared/billing-timeframe/index.js +58 -0
- package/dist/cjs/components/shared/billing-timeframe/index.js.map +1 -0
- package/dist/cjs/components/shared/header-price/header-price-context.js +14 -0
- package/dist/cjs/components/shared/header-price/header-price-context.js.map +1 -0
- package/dist/cjs/components/shared/header-price/index.js +102 -0
- package/dist/cjs/components/shared/header-price/index.js.map +1 -0
- package/dist/cjs/components/shared/header-price/style.scss +112 -0
- package/dist/cjs/components/shared/plan-pill/index.js +6 -0
- package/dist/cjs/components/shared/plan-pill/index.js.map +1 -0
- package/dist/cjs/components/shared/plan-pill/style.scss +30 -0
- package/dist/cjs/components/shared/storage/components/plan-storage.js +28 -0
- package/dist/cjs/components/shared/storage/components/plan-storage.js.map +1 -0
- package/dist/cjs/components/shared/storage/components/storage-dropdown.js +96 -0
- package/dist/cjs/components/shared/storage/components/storage-dropdown.js.map +1 -0
- package/dist/cjs/components/shared/storage/components/storage-feature-label.js +40 -0
- package/dist/cjs/components/shared/storage/components/storage-feature-label.js.map +1 -0
- package/dist/cjs/components/shared/storage/constants.js +6 -0
- package/dist/cjs/components/shared/storage/constants.js.map +1 -0
- package/dist/cjs/components/shared/storage/hooks/use-default-storage-option.js +26 -0
- package/dist/cjs/components/shared/storage/hooks/use-default-storage-option.js.map +1 -0
- package/dist/cjs/components/shared/storage/hooks/use-plan-storage.js +29 -0
- package/dist/cjs/components/shared/storage/hooks/use-plan-storage.js.map +1 -0
- package/dist/cjs/components/shared/storage/hooks/use-purchased-storage-add-on.js +51 -0
- package/dist/cjs/components/shared/storage/hooks/use-purchased-storage-add-on.js.map +1 -0
- package/dist/cjs/components/shared/storage/hooks/use-storage-string.js +13 -0
- package/dist/cjs/components/shared/storage/hooks/use-storage-string.js.map +1 -0
- package/dist/cjs/components/shared/storage/index.js +14 -0
- package/dist/cjs/components/shared/storage/index.js.map +1 -0
- package/dist/cjs/components/sticky-container.js +74 -0
- package/dist/cjs/components/sticky-container.js.map +1 -0
- package/dist/cjs/constants.js +11 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/css-mixins.js +14 -0
- package/dist/cjs/css-mixins.js.map +1 -0
- package/dist/cjs/fixtures/plans.js +1542 -0
- package/dist/cjs/fixtures/plans.js.map +1 -0
- package/dist/cjs/fixtures/sites-plans.js +458 -0
- package/dist/cjs/fixtures/sites-plans.js.map +1 -0
- package/dist/cjs/fixtures/sites-purchases.js +133 -0
- package/dist/cjs/fixtures/sites-purchases.js.map +1 -0
- package/dist/cjs/grid-context.js +40 -0
- package/dist/cjs/grid-context.js.map +1 -0
- package/dist/cjs/hooks/data-store/is-popular-plan.js +9 -0
- package/dist/cjs/hooks/data-store/is-popular-plan.js.map +1 -0
- package/dist/cjs/hooks/data-store/types.js +3 -0
- package/dist/cjs/hooks/data-store/types.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-grid-plan-for-spotlight.js +18 -0
- package/dist/cjs/hooks/data-store/use-grid-plan-for-spotlight.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-grid-plans-for-comparison-grid.js +55 -0
- package/dist/cjs/hooks/data-store/use-grid-plans-for-comparison-grid.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-grid-plans-for-features-grid.js +56 -0
- package/dist/cjs/hooks/data-store/use-grid-plans-for-features-grid.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-grid-plans.js +254 -0
- package/dist/cjs/hooks/data-store/use-grid-plans.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-highlight-labels.js +60 -0
- package/dist/cjs/hooks/data-store/use-highlight-labels.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-highlighted-features.js +35 -0
- package/dist/cjs/hooks/data-store/use-highlighted-features.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-plan-billing-description.js +216 -0
- package/dist/cjs/hooks/data-store/use-plan-billing-description.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-plan-features-for-grid-plans.js +133 -0
- package/dist/cjs/hooks/data-store/use-plan-features-for-grid-plans.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-plans-from-types.js +30 -0
- package/dist/cjs/hooks/data-store/use-plans-from-types.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js +90 -0
- package/dist/cjs/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js.map +1 -0
- package/dist/cjs/hooks/use-grid-size.js +33 -0
- package/dist/cjs/hooks/use-grid-size.js.map +1 -0
- package/dist/cjs/hooks/use-highlight-adjacency-matrix.js +31 -0
- package/dist/cjs/hooks/use-highlight-adjacency-matrix.js.map +1 -0
- package/dist/cjs/hooks/use-is-large-currency.js +69 -0
- package/dist/cjs/hooks/use-is-large-currency.js.map +1 -0
- package/dist/cjs/hooks/use-manage-tooltip-toggle.js +29 -0
- package/dist/cjs/hooks/use-manage-tooltip-toggle.js.map +1 -0
- package/dist/cjs/hooks/use-plan-pricing-info-from-grid-plans.js +17 -0
- package/dist/cjs/hooks/use-plan-pricing-info-from-grid-plans.js.map +1 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/filter-unused-features-object.js +19 -0
- package/dist/cjs/lib/filter-unused-features-object.js.map +1 -0
- package/dist/cjs/lib/get-plan-features-object.js +11 -0
- package/dist/cjs/lib/get-plan-features-object.js.map +1 -0
- package/dist/cjs/lib/get-plan-pricing-info-from-grid-plans.js +16 -0
- package/dist/cjs/lib/get-plan-pricing-info-from-grid-plans.js.map +1 -0
- package/dist/cjs/lib/is-same-plan.js +12 -0
- package/dist/cjs/lib/is-same-plan.js.map +1 -0
- package/dist/cjs/lib/sort-plan-properties.js +39 -0
- package/dist/cjs/lib/sort-plan-properties.js.map +1 -0
- package/dist/cjs/lib/touch-detect/index.js +20 -0
- package/dist/cjs/lib/touch-detect/index.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/__mocks__/wpcom-proxy-request.js +11 -0
- package/dist/esm/__mocks__/wpcom-proxy-request.js.map +1 -0
- package/dist/esm/_media-queries.scss +14 -0
- package/dist/esm/_mixins.scss +15 -0
- package/dist/esm/_shared.scss +174 -0
- package/dist/esm/components/comparison-grid/index.js +524 -0
- package/dist/esm/components/comparison-grid/index.js.map +1 -0
- package/dist/esm/components/comparison-grid/index.stories.js +71 -0
- package/dist/esm/components/comparison-grid/index.stories.js.map +1 -0
- package/dist/esm/components/comparison-grid/style.scss +318 -0
- package/dist/esm/components/dropdown-option.js +30 -0
- package/dist/esm/components/dropdown-option.js.map +1 -0
- package/dist/esm/components/features-grid/billing-timeframes.js +12 -0
- package/dist/esm/components/features-grid/billing-timeframes.js.map +1 -0
- package/dist/esm/components/features-grid/client-logo-list/client-list.js +104 -0
- package/dist/esm/components/features-grid/client-logo-list/client-list.js.map +1 -0
- package/dist/esm/components/features-grid/client-logo-list/index.js +14 -0
- package/dist/esm/components/features-grid/client-logo-list/index.js.map +1 -0
- package/dist/esm/components/features-grid/client-logo-list/style.scss +52 -0
- package/dist/esm/components/features-grid/enterprise-features.js +38 -0
- package/dist/esm/components/features-grid/enterprise-features.js.map +1 -0
- package/dist/esm/components/features-grid/index.js +127 -0
- package/dist/esm/components/features-grid/index.js.map +1 -0
- package/dist/esm/components/features-grid/index.stories.js +109 -0
- package/dist/esm/components/features-grid/index.stories.js.map +1 -0
- package/dist/esm/components/features-grid/mobile-free-domain.js +23 -0
- package/dist/esm/components/features-grid/mobile-free-domain.js.map +1 -0
- package/dist/esm/components/features-grid/plan-features-list.js +53 -0
- package/dist/esm/components/features-grid/plan-features-list.js.map +1 -0
- package/dist/esm/components/features-grid/plan-headers.js +12 -0
- package/dist/esm/components/features-grid/plan-headers.js.map +1 -0
- package/dist/esm/components/features-grid/plan-logos.js +9 -0
- package/dist/esm/components/features-grid/plan-logos.js.map +1 -0
- package/dist/esm/components/features-grid/plan-prices.js +11 -0
- package/dist/esm/components/features-grid/plan-prices.js.map +1 -0
- package/dist/esm/components/features-grid/plan-tagline.js +9 -0
- package/dist/esm/components/features-grid/plan-tagline.js.map +1 -0
- package/dist/esm/components/features-grid/previous-features-included-title.js +33 -0
- package/dist/esm/components/features-grid/previous-features-included-title.js.map +1 -0
- package/dist/esm/components/features-grid/spotlight-plan.js +21 -0
- package/dist/esm/components/features-grid/spotlight-plan.js.map +1 -0
- package/dist/esm/components/features-grid/spotlight-plan.scss +5 -0
- package/dist/esm/components/features-grid/style.scss +630 -0
- package/dist/esm/components/features-grid/table.js +35 -0
- package/dist/esm/components/features-grid/table.js.map +1 -0
- package/dist/esm/components/features-grid/top-buttons.js +12 -0
- package/dist/esm/components/features-grid/top-buttons.js.map +1 -0
- package/dist/esm/components/features.js +69 -0
- package/dist/esm/components/features.js.map +1 -0
- package/dist/esm/components/item.js +5 -0
- package/dist/esm/components/item.js.map +1 -0
- package/dist/esm/components/plan-button/index.js +18 -0
- package/dist/esm/components/plan-button/index.js.map +1 -0
- package/dist/esm/components/plan-button/style.scss +179 -0
- package/dist/esm/components/plan-div-td-container.js +7 -0
- package/dist/esm/components/plan-div-td-container.js.map +1 -0
- package/dist/esm/components/plan-logo.js +42 -0
- package/dist/esm/components/plan-logo.js.map +1 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-dropdown.js +34 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-dropdown.js.map +1 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-selector.js +8 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-selector.js.map +1 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-toggle.js +50 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-toggle.js.map +1 -0
- package/dist/esm/components/plan-type-selector/components/popup-messages.js +105 -0
- package/dist/esm/components/plan-type-selector/components/popup-messages.js.map +1 -0
- package/dist/esm/components/plan-type-selector/hooks/use-interval-options.js +52 -0
- package/dist/esm/components/plan-type-selector/hooks/use-interval-options.js.map +1 -0
- package/dist/esm/components/plan-type-selector/hooks/use-max-discount.js +42 -0
- package/dist/esm/components/plan-type-selector/hooks/use-max-discount.js.map +1 -0
- package/dist/esm/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js +65 -0
- package/dist/esm/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js.map +1 -0
- package/dist/esm/components/plan-type-selector/index.js +24 -0
- package/dist/esm/components/plan-type-selector/index.js.map +1 -0
- package/dist/esm/components/plan-type-selector/style.scss +196 -0
- package/dist/esm/components/plans-2023-tooltip.js +41 -0
- package/dist/esm/components/plans-2023-tooltip.js.map +1 -0
- package/dist/esm/components/popular-badge.js +13 -0
- package/dist/esm/components/popular-badge.js.map +1 -0
- package/dist/esm/components/shared/action-button/index.js +88 -0
- package/dist/esm/components/shared/action-button/index.js.map +1 -0
- package/dist/esm/components/shared/action-button/style.scss +12 -0
- package/dist/esm/components/shared/billing-timeframe/index.js +55 -0
- package/dist/esm/components/shared/billing-timeframe/index.js.map +1 -0
- package/dist/esm/components/shared/header-price/header-price-context.js +10 -0
- package/dist/esm/components/shared/header-price/header-price-context.js.map +1 -0
- package/dist/esm/components/shared/header-price/index.js +99 -0
- package/dist/esm/components/shared/header-price/index.js.map +1 -0
- package/dist/esm/components/shared/header-price/style.scss +112 -0
- package/dist/esm/components/shared/plan-pill/index.js +4 -0
- package/dist/esm/components/shared/plan-pill/index.js.map +1 -0
- package/dist/esm/components/shared/plan-pill/style.scss +30 -0
- package/dist/esm/components/shared/storage/components/plan-storage.js +25 -0
- package/dist/esm/components/shared/storage/components/plan-storage.js.map +1 -0
- package/dist/esm/components/shared/storage/components/storage-dropdown.js +93 -0
- package/dist/esm/components/shared/storage/components/storage-dropdown.js.map +1 -0
- package/dist/esm/components/shared/storage/components/storage-feature-label.js +37 -0
- package/dist/esm/components/shared/storage/components/storage-feature-label.js.map +1 -0
- package/dist/esm/components/shared/storage/constants.js +3 -0
- package/dist/esm/components/shared/storage/constants.js.map +1 -0
- package/dist/esm/components/shared/storage/hooks/use-default-storage-option.js +22 -0
- package/dist/esm/components/shared/storage/hooks/use-default-storage-option.js.map +1 -0
- package/dist/esm/components/shared/storage/hooks/use-plan-storage.js +27 -0
- package/dist/esm/components/shared/storage/hooks/use-plan-storage.js.map +1 -0
- package/dist/esm/components/shared/storage/hooks/use-purchased-storage-add-on.js +48 -0
- package/dist/esm/components/shared/storage/hooks/use-purchased-storage-add-on.js.map +1 -0
- package/dist/esm/components/shared/storage/hooks/use-storage-string.js +11 -0
- package/dist/esm/components/shared/storage/hooks/use-storage-string.js.map +1 -0
- package/dist/esm/components/shared/storage/index.js +9 -0
- package/dist/esm/components/shared/storage/index.js.map +1 -0
- package/dist/esm/components/sticky-container.js +69 -0
- package/dist/esm/components/sticky-container.js.map +1 -0
- package/dist/esm/constants.js +8 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/css-mixins.js +10 -0
- package/dist/esm/css-mixins.js.map +1 -0
- package/dist/esm/fixtures/plans.js +1540 -0
- package/dist/esm/fixtures/plans.js.map +1 -0
- package/dist/esm/fixtures/sites-plans.js +456 -0
- package/dist/esm/fixtures/sites-plans.js.map +1 -0
- package/dist/esm/fixtures/sites-purchases.js +131 -0
- package/dist/esm/fixtures/sites-purchases.js.map +1 -0
- package/dist/esm/grid-context.js +36 -0
- package/dist/esm/grid-context.js.map +1 -0
- package/dist/esm/hooks/data-store/is-popular-plan.js +5 -0
- package/dist/esm/hooks/data-store/is-popular-plan.js.map +1 -0
- package/dist/esm/hooks/data-store/types.js +2 -0
- package/dist/esm/hooks/data-store/types.js.map +1 -0
- package/dist/esm/hooks/data-store/use-grid-plan-for-spotlight.js +16 -0
- package/dist/esm/hooks/data-store/use-grid-plan-for-spotlight.js.map +1 -0
- package/dist/esm/hooks/data-store/use-grid-plans-for-comparison-grid.js +52 -0
- package/dist/esm/hooks/data-store/use-grid-plans-for-comparison-grid.js.map +1 -0
- package/dist/esm/hooks/data-store/use-grid-plans-for-features-grid.js +53 -0
- package/dist/esm/hooks/data-store/use-grid-plans-for-features-grid.js.map +1 -0
- package/dist/esm/hooks/data-store/use-grid-plans.js +249 -0
- package/dist/esm/hooks/data-store/use-grid-plans.js.map +1 -0
- package/dist/esm/hooks/data-store/use-highlight-labels.js +58 -0
- package/dist/esm/hooks/data-store/use-highlight-labels.js.map +1 -0
- package/dist/esm/hooks/data-store/use-highlighted-features.js +33 -0
- package/dist/esm/hooks/data-store/use-highlighted-features.js.map +1 -0
- package/dist/esm/hooks/data-store/use-plan-billing-description.js +213 -0
- package/dist/esm/hooks/data-store/use-plan-billing-description.js.map +1 -0
- package/dist/esm/hooks/data-store/use-plan-features-for-grid-plans.js +130 -0
- package/dist/esm/hooks/data-store/use-plan-features-for-grid-plans.js.map +1 -0
- package/dist/esm/hooks/data-store/use-plans-from-types.js +27 -0
- package/dist/esm/hooks/data-store/use-plans-from-types.js.map +1 -0
- package/dist/esm/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js +87 -0
- package/dist/esm/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js.map +1 -0
- package/dist/esm/hooks/use-grid-size.js +29 -0
- package/dist/esm/hooks/use-grid-size.js.map +1 -0
- package/dist/esm/hooks/use-highlight-adjacency-matrix.js +29 -0
- package/dist/esm/hooks/use-highlight-adjacency-matrix.js.map +1 -0
- package/dist/esm/hooks/use-is-large-currency.js +66 -0
- package/dist/esm/hooks/use-is-large-currency.js.map +1 -0
- package/dist/esm/hooks/use-manage-tooltip-toggle.js +25 -0
- package/dist/esm/hooks/use-manage-tooltip-toggle.js.map +1 -0
- package/dist/esm/hooks/use-plan-pricing-info-from-grid-plans.js +13 -0
- package/dist/esm/hooks/use-plan-pricing-info-from-grid-plans.js.map +1 -0
- package/dist/esm/index.js +28 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/filter-unused-features-object.js +17 -0
- package/dist/esm/lib/filter-unused-features-object.js.map +1 -0
- package/dist/esm/lib/get-plan-features-object.js +9 -0
- package/dist/esm/lib/get-plan-features-object.js.map +1 -0
- package/dist/esm/lib/get-plan-pricing-info-from-grid-plans.js +12 -0
- package/dist/esm/lib/get-plan-pricing-info-from-grid-plans.js.map +1 -0
- package/dist/esm/lib/is-same-plan.js +8 -0
- package/dist/esm/lib/is-same-plan.js.map +1 -0
- package/dist/esm/lib/sort-plan-properties.js +35 -0
- package/dist/esm/lib/sort-plan-properties.js.map +1 -0
- package/dist/esm/lib/touch-detect/index.js +16 -0
- package/dist/esm/lib/touch-detect/index.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/tsconfig-cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/__mocks__/wpcom-proxy-request.d.ts +8 -0
- package/dist/types/__mocks__/wpcom-proxy-request.d.ts.map +1 -0
- package/dist/types/components/comparison-grid/index.d.ts +5 -0
- package/dist/types/components/comparison-grid/index.d.ts.map +1 -0
- package/dist/types/components/comparison-grid/index.stories.d.ts +66 -0
- package/dist/types/components/comparison-grid/index.stories.d.ts.map +1 -0
- package/dist/types/components/dropdown-option.d.ts +10 -0
- package/dist/types/components/dropdown-option.d.ts.map +1 -0
- package/dist/types/components/features-grid/billing-timeframes.d.ts +11 -0
- package/dist/types/components/features-grid/billing-timeframes.d.ts.map +1 -0
- package/dist/types/components/features-grid/client-logo-list/client-list.d.ts +11 -0
- package/dist/types/components/features-grid/client-logo-list/client-list.d.ts.map +1 -0
- package/dist/types/components/features-grid/client-logo-list/index.d.ts +4 -0
- package/dist/types/components/features-grid/client-logo-list/index.d.ts.map +1 -0
- package/dist/types/components/features-grid/enterprise-features.d.ts +11 -0
- package/dist/types/components/features-grid/enterprise-features.d.ts.map +1 -0
- package/dist/types/components/features-grid/index.d.ts +5 -0
- package/dist/types/components/features-grid/index.d.ts.map +1 -0
- package/dist/types/components/features-grid/index.stories.d.ts +173 -0
- package/dist/types/components/features-grid/index.stories.d.ts.map +1 -0
- package/dist/types/components/features-grid/mobile-free-domain.d.ts +8 -0
- package/dist/types/components/features-grid/mobile-free-domain.d.ts.map +1 -0
- package/dist/types/components/features-grid/plan-features-list.d.ts +31 -0
- package/dist/types/components/features-grid/plan-features-list.d.ts.map +1 -0
- package/dist/types/components/features-grid/plan-headers.d.ts +10 -0
- package/dist/types/components/features-grid/plan-headers.d.ts.map +1 -0
- package/dist/types/components/features-grid/plan-logos.d.ts +11 -0
- package/dist/types/components/features-grid/plan-logos.d.ts.map +1 -0
- package/dist/types/components/features-grid/plan-prices.d.ts +11 -0
- package/dist/types/components/features-grid/plan-prices.d.ts.map +1 -0
- package/dist/types/components/features-grid/plan-tagline.d.ts +10 -0
- package/dist/types/components/features-grid/plan-tagline.d.ts.map +1 -0
- package/dist/types/components/features-grid/previous-features-included-title.d.ts +10 -0
- package/dist/types/components/features-grid/previous-features-included-title.d.ts.map +1 -0
- package/dist/types/components/features-grid/spotlight-plan.d.ts +17 -0
- package/dist/types/components/features-grid/spotlight-plan.d.ts.map +1 -0
- package/dist/types/components/features-grid/table.d.ts +26 -0
- package/dist/types/components/features-grid/table.d.ts.map +1 -0
- package/dist/types/components/features-grid/top-buttons.d.ts +14 -0
- package/dist/types/components/features-grid/top-buttons.d.ts.map +1 -0
- package/dist/types/components/features.d.ts +17 -0
- package/dist/types/components/features.d.ts.map +1 -0
- package/dist/types/components/item.d.ts +5 -0
- package/dist/types/components/item.d.ts.map +1 -0
- package/dist/types/components/plan-button/index.d.ts +17 -0
- package/dist/types/components/plan-button/index.d.ts.map +1 -0
- package/dist/types/components/plan-div-td-container.d.ts +7 -0
- package/dist/types/components/plan-div-td-container.d.ts.map +1 -0
- package/dist/types/components/plan-logo.d.ts +12 -0
- package/dist/types/components/plan-logo.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/components/interval-type-dropdown.d.ts +4 -0
- package/dist/types/components/plan-type-selector/components/interval-type-dropdown.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/components/interval-type-selector.d.ts +4 -0
- package/dist/types/components/plan-type-selector/components/interval-type-selector.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/components/interval-type-toggle.d.ts +4 -0
- package/dist/types/components/plan-type-selector/components/interval-type-toggle.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/components/popup-messages.d.ts +9 -0
- package/dist/types/components/plan-type-selector/components/popup-messages.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/hooks/use-interval-options.d.ts +11 -0
- package/dist/types/components/plan-type-selector/hooks/use-interval-options.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/hooks/use-max-discount.d.ts +4 -0
- package/dist/types/components/plan-type-selector/hooks/use-max-discount.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.d.ts +10 -0
- package/dist/types/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/index.d.ts +6 -0
- package/dist/types/components/plan-type-selector/index.d.ts.map +1 -0
- package/dist/types/components/plans-2023-tooltip.d.ts +11 -0
- package/dist/types/components/plans-2023-tooltip.d.ts.map +1 -0
- package/dist/types/components/popular-badge.d.ts +9 -0
- package/dist/types/components/popular-badge.d.ts.map +1 -0
- package/dist/types/components/shared/action-button/index.d.ts +19 -0
- package/dist/types/components/shared/action-button/index.d.ts.map +1 -0
- package/dist/types/components/shared/billing-timeframe/index.d.ts +8 -0
- package/dist/types/components/shared/billing-timeframe/index.d.ts.map +1 -0
- package/dist/types/components/shared/header-price/header-price-context.d.ts +12 -0
- package/dist/types/components/shared/header-price/header-price-context.d.ts.map +1 -0
- package/dist/types/components/shared/header-price/index.d.ts +11 -0
- package/dist/types/components/shared/header-price/index.d.ts.map +1 -0
- package/dist/types/components/shared/plan-pill/index.d.ts +3 -0
- package/dist/types/components/shared/plan-pill/index.d.ts.map +1 -0
- package/dist/types/components/shared/storage/components/plan-storage.d.ts +13 -0
- package/dist/types/components/shared/storage/components/plan-storage.d.ts.map +1 -0
- package/dist/types/components/shared/storage/components/storage-dropdown.d.ts +9 -0
- package/dist/types/components/shared/storage/components/storage-dropdown.d.ts.map +1 -0
- package/dist/types/components/shared/storage/components/storage-feature-label.d.ts +7 -0
- package/dist/types/components/shared/storage/components/storage-feature-label.d.ts.map +1 -0
- package/dist/types/components/shared/storage/constants.d.ts +2 -0
- package/dist/types/components/shared/storage/constants.d.ts.map +1 -0
- package/dist/types/components/shared/storage/hooks/use-default-storage-option.d.ts +14 -0
- package/dist/types/components/shared/storage/hooks/use-default-storage-option.d.ts.map +1 -0
- package/dist/types/components/shared/storage/hooks/use-plan-storage.d.ts +4 -0
- package/dist/types/components/shared/storage/hooks/use-plan-storage.d.ts.map +1 -0
- package/dist/types/components/shared/storage/hooks/use-purchased-storage-add-on.d.ts +3 -0
- package/dist/types/components/shared/storage/hooks/use-purchased-storage-add-on.d.ts.map +1 -0
- package/dist/types/components/shared/storage/hooks/use-storage-string.d.ts +4 -0
- package/dist/types/components/shared/storage/hooks/use-storage-string.d.ts.map +1 -0
- package/dist/types/components/shared/storage/index.d.ts +9 -0
- package/dist/types/components/shared/storage/index.d.ts.map +1 -0
- package/dist/types/components/sticky-container.d.ts +33 -0
- package/dist/types/components/sticky-container.d.ts.map +1 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/css-mixins.d.ts +3 -0
- package/dist/types/css-mixins.d.ts.map +1 -0
- package/dist/types/fixtures/plans.d.ts +201 -0
- package/dist/types/fixtures/plans.d.ts.map +1 -0
- package/dist/types/fixtures/sites-plans.d.ts +457 -0
- package/dist/types/fixtures/sites-plans.d.ts.map +1 -0
- package/dist/types/fixtures/sites-purchases.d.ts +96 -0
- package/dist/types/fixtures/sites-purchases.d.ts.map +1 -0
- package/dist/types/grid-context.d.ts +40 -0
- package/dist/types/grid-context.d.ts.map +1 -0
- package/dist/types/hooks/data-store/is-popular-plan.d.ts +2 -0
- package/dist/types/hooks/data-store/is-popular-plan.d.ts.map +1 -0
- package/dist/types/hooks/data-store/types.d.ts +40 -0
- package/dist/types/hooks/data-store/types.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-grid-plan-for-spotlight.d.ts +10 -0
- package/dist/types/hooks/data-store/use-grid-plan-for-spotlight.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-grid-plans-for-comparison-grid.d.ts +5 -0
- package/dist/types/hooks/data-store/use-grid-plans-for-comparison-grid.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-grid-plans-for-features-grid.d.ts +5 -0
- package/dist/types/hooks/data-store/use-grid-plans-for-features-grid.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-grid-plans.d.ts +13 -0
- package/dist/types/hooks/data-store/use-grid-plans.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-highlight-labels.d.ts +20 -0
- package/dist/types/hooks/data-store/use-highlight-labels.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-highlighted-features.d.ts +22 -0
- package/dist/types/hooks/data-store/use-highlighted-features.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-plan-billing-description.d.ts +16 -0
- package/dist/types/hooks/data-store/use-plan-billing-description.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-plan-features-for-grid-plans.d.ts +21 -0
- package/dist/types/hooks/data-store/use-plan-features-for-grid-plans.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-plans-from-types.d.ts +10 -0
- package/dist/types/hooks/data-store/use-plans-from-types.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-restructured-plan-features-for-comparison-grid.d.ts +15 -0
- package/dist/types/hooks/data-store/use-restructured-plan-features-for-comparison-grid.d.ts.map +1 -0
- package/dist/types/hooks/use-grid-size.d.ts +18 -0
- package/dist/types/hooks/use-grid-size.d.ts.map +1 -0
- package/dist/types/hooks/use-highlight-adjacency-matrix.d.ts +15 -0
- package/dist/types/hooks/use-highlight-adjacency-matrix.d.ts.map +1 -0
- package/dist/types/hooks/use-is-large-currency.d.ts +16 -0
- package/dist/types/hooks/use-is-large-currency.d.ts.map +1 -0
- package/dist/types/hooks/use-manage-tooltip-toggle.d.ts +3 -0
- package/dist/types/hooks/use-manage-tooltip-toggle.d.ts.map +1 -0
- package/dist/types/hooks/use-plan-pricing-info-from-grid-plans.d.ts +11 -0
- package/dist/types/hooks/use-plan-pricing-info-from-grid-plans.d.ts.map +1 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/filter-unused-features-object.d.ts +8 -0
- package/dist/types/lib/filter-unused-features-object.d.ts.map +1 -0
- package/dist/types/lib/get-plan-features-object.d.ts +4 -0
- package/dist/types/lib/get-plan-features-object.d.ts.map +1 -0
- package/dist/types/lib/get-plan-pricing-info-from-grid-plans.d.ts +9 -0
- package/dist/types/lib/get-plan-pricing-info-from-grid-plans.d.ts.map +1 -0
- package/dist/types/lib/is-same-plan.d.ts +3 -0
- package/dist/types/lib/is-same-plan.d.ts.map +1 -0
- package/dist/types/lib/sort-plan-properties.d.ts +3 -0
- package/dist/types/lib/sort-plan-properties.d.ts.map +1 -0
- package/dist/types/lib/touch-detect/index.d.ts +11 -0
- package/dist/types/lib/touch-detect/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +225 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +83 -0
- package/src/__mocks__/wpcom-proxy-request.js +13 -0
- package/src/_media-queries.scss +14 -0
- package/src/_mixins.scss +15 -0
- package/src/_shared.scss +174 -0
- package/src/components/comparison-grid/README.md +3 -0
- package/src/components/comparison-grid/index.stories.tsx +91 -0
- package/src/components/comparison-grid/index.tsx +1215 -0
- package/src/components/comparison-grid/style.scss +318 -0
- package/src/components/dropdown-option.tsx +44 -0
- package/src/components/features-grid/README.md +3 -0
- package/src/components/features-grid/billing-timeframes.tsx +37 -0
- package/src/components/features-grid/client-logo-list/client-list.tsx +199 -0
- package/src/components/features-grid/client-logo-list/index.tsx +24 -0
- package/src/components/features-grid/client-logo-list/style.scss +52 -0
- package/src/components/features-grid/enterprise-features.tsx +101 -0
- package/src/components/features-grid/index.stories.tsx +143 -0
- package/src/components/features-grid/index.tsx +442 -0
- package/src/components/features-grid/mobile-free-domain.tsx +51 -0
- package/src/components/features-grid/plan-features-list.tsx +187 -0
- package/src/components/features-grid/plan-headers.tsx +31 -0
- package/src/components/features-grid/plan-logos.tsx +27 -0
- package/src/components/features-grid/plan-prices.tsx +37 -0
- package/src/components/features-grid/plan-tagline.tsx +25 -0
- package/src/components/features-grid/previous-features-included-title.tsx +66 -0
- package/src/components/features-grid/spotlight-plan.scss +5 -0
- package/src/components/features-grid/spotlight-plan.tsx +77 -0
- package/src/components/features-grid/style.scss +630 -0
- package/src/components/features-grid/table.tsx +185 -0
- package/src/components/features-grid/top-buttons.tsx +49 -0
- package/src/components/features.tsx +168 -0
- package/src/components/item.tsx +9 -0
- package/src/components/plan-button/index.tsx +59 -0
- package/src/components/plan-button/style.scss +179 -0
- package/src/components/plan-div-td-container.tsx +15 -0
- package/src/components/plan-logo.tsx +111 -0
- package/src/components/plan-type-selector/components/interval-type-dropdown.tsx +70 -0
- package/src/components/plan-type-selector/components/interval-type-selector.tsx +13 -0
- package/src/components/plan-type-selector/components/interval-type-toggle.tsx +100 -0
- package/src/components/plan-type-selector/components/popup-messages.tsx +128 -0
- package/src/components/plan-type-selector/hooks/use-interval-options.tsx +89 -0
- package/src/components/plan-type-selector/hooks/use-max-discount.ts +64 -0
- package/src/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.ts +99 -0
- package/src/components/plan-type-selector/index.tsx +50 -0
- package/src/components/plan-type-selector/style.scss +196 -0
- package/src/components/plans-2023-tooltip.tsx +85 -0
- package/src/components/popular-badge.tsx +30 -0
- package/src/components/shared/README.md +1 -0
- package/src/components/shared/action-button/index.tsx +205 -0
- package/src/components/shared/action-button/style.scss +12 -0
- package/src/components/shared/billing-timeframe/index.tsx +106 -0
- package/src/components/shared/header-price/header-price-context.tsx +24 -0
- package/src/components/shared/header-price/index.tsx +278 -0
- package/src/components/shared/header-price/style.scss +112 -0
- package/src/components/shared/plan-pill/index.jsx +7 -0
- package/src/components/shared/plan-pill/style.scss +30 -0
- package/src/components/shared/storage/components/plan-storage.tsx +51 -0
- package/src/components/shared/storage/components/storage-dropdown.tsx +187 -0
- package/src/components/shared/storage/components/storage-feature-label.tsx +68 -0
- package/src/components/shared/storage/constants.ts +3 -0
- package/src/components/shared/storage/hooks/use-default-storage-option.ts +34 -0
- package/src/components/shared/storage/hooks/use-plan-storage.ts +41 -0
- package/src/components/shared/storage/hooks/use-purchased-storage-add-on.ts +53 -0
- package/src/components/shared/storage/hooks/use-storage-string.ts +13 -0
- package/src/components/shared/storage/index.ts +9 -0
- package/src/components/sticky-container.tsx +146 -0
- package/src/components/test/actions-button.tsx +397 -0
- package/src/components/test/billing-timeframe.tsx +341 -0
- package/src/components/test/header-price.tsx +189 -0
- package/src/components/test/plan-type-selector.tsx +44 -0
- package/src/constants.ts +13 -0
- package/src/css-mixins.tsx +11 -0
- package/src/fixtures/plans.ts +1539 -0
- package/src/fixtures/sites-plans.ts +455 -0
- package/src/fixtures/sites-purchases.ts +130 -0
- package/src/grid-context.tsx +104 -0
- package/src/hooks/data-store/is-popular-plan.ts +5 -0
- package/src/hooks/data-store/types.ts +41 -0
- package/src/hooks/data-store/use-grid-plan-for-spotlight.ts +35 -0
- package/src/hooks/data-store/use-grid-plans-for-comparison-grid.ts +81 -0
- package/src/hooks/data-store/use-grid-plans-for-features-grid.ts +79 -0
- package/src/hooks/data-store/use-grid-plans.tsx +360 -0
- package/src/hooks/data-store/use-highlight-labels.ts +88 -0
- package/src/hooks/data-store/use-highlighted-features.ts +51 -0
- package/src/hooks/data-store/use-plan-billing-description.tsx +309 -0
- package/src/hooks/data-store/use-plan-features-for-grid-plans.ts +219 -0
- package/src/hooks/data-store/use-plans-from-types.ts +51 -0
- package/src/hooks/data-store/use-restructured-plan-features-for-comparison-grid.ts +158 -0
- package/src/hooks/test/use-is-large-currency.ts +69 -0
- package/src/hooks/use-grid-size.ts +46 -0
- package/src/hooks/use-highlight-adjacency-matrix.ts +48 -0
- package/src/hooks/use-is-large-currency.ts +91 -0
- package/src/hooks/use-manage-tooltip-toggle.ts +30 -0
- package/src/hooks/use-plan-pricing-info-from-grid-plans.ts +36 -0
- package/src/index.tsx +46 -0
- package/src/lib/filter-unused-features-object.ts +31 -0
- package/src/lib/get-plan-features-object.ts +12 -0
- package/src/lib/get-plan-pricing-info-from-grid-plans.ts +31 -0
- package/src/lib/is-same-plan.ts +8 -0
- package/src/lib/sort-plan-properties.ts +46 -0
- package/src/lib/test/filter-plan-features-object.ts +65 -0
- package/src/lib/test/sort-plan-properties.ts +104 -0
- package/src/lib/touch-detect/README.md +11 -0
- package/src/lib/touch-detect/index.js +17 -0
- package/src/types.ts +340 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyTestFiltersToPlansList,
|
|
3
|
+
isMonthly,
|
|
4
|
+
isWooExpressPlan,
|
|
5
|
+
type FeatureList,
|
|
6
|
+
FEATURE_CUSTOM_DOMAIN,
|
|
7
|
+
} from '@automattic/calypso-products';
|
|
8
|
+
import { useMemo } from 'react';
|
|
9
|
+
import getPlanFeaturesObject from '../../lib/get-plan-features-object';
|
|
10
|
+
import usePlanFeaturesForGridPlans from './use-plan-features-for-grid-plans';
|
|
11
|
+
import type {
|
|
12
|
+
TransformedFeatureObject,
|
|
13
|
+
PlanFeaturesForGridPlan,
|
|
14
|
+
PlansIntent,
|
|
15
|
+
GridPlan,
|
|
16
|
+
} from '../../types';
|
|
17
|
+
|
|
18
|
+
export type UseRestructuredPlanFeaturesForComparisonGrid = ( {
|
|
19
|
+
gridPlans,
|
|
20
|
+
allFeaturesList,
|
|
21
|
+
hasRedeemedDomainCredit,
|
|
22
|
+
intent,
|
|
23
|
+
showLegacyStorageFeature,
|
|
24
|
+
selectedFeature,
|
|
25
|
+
}: {
|
|
26
|
+
gridPlans: Omit< GridPlan, 'features' >[];
|
|
27
|
+
allFeaturesList: FeatureList;
|
|
28
|
+
hasRedeemedDomainCredit?: boolean;
|
|
29
|
+
intent?: PlansIntent;
|
|
30
|
+
selectedFeature?: string | null;
|
|
31
|
+
showLegacyStorageFeature?: boolean;
|
|
32
|
+
} ) => { [ planSlug: string ]: PlanFeaturesForGridPlan };
|
|
33
|
+
|
|
34
|
+
const useRestructuredPlanFeaturesForComparisonGrid: UseRestructuredPlanFeaturesForComparisonGrid =
|
|
35
|
+
( {
|
|
36
|
+
gridPlans,
|
|
37
|
+
allFeaturesList,
|
|
38
|
+
hasRedeemedDomainCredit,
|
|
39
|
+
intent,
|
|
40
|
+
selectedFeature,
|
|
41
|
+
showLegacyStorageFeature,
|
|
42
|
+
} ) => {
|
|
43
|
+
const planFeaturesForGridPlans = usePlanFeaturesForGridPlans( {
|
|
44
|
+
gridPlans,
|
|
45
|
+
allFeaturesList,
|
|
46
|
+
intent,
|
|
47
|
+
selectedFeature,
|
|
48
|
+
showLegacyStorageFeature,
|
|
49
|
+
} );
|
|
50
|
+
|
|
51
|
+
return useMemo( () => {
|
|
52
|
+
let previousPlan = null;
|
|
53
|
+
const planFeatureMap: Record< string, PlanFeaturesForGridPlan > = {};
|
|
54
|
+
|
|
55
|
+
for ( const gridPlan of gridPlans ) {
|
|
56
|
+
const planSlug = gridPlan.planSlug;
|
|
57
|
+
const planConstantObj = applyTestFiltersToPlansList( planSlug, undefined );
|
|
58
|
+
const annualPlansOnlyFeatures = planConstantObj.getAnnualPlansOnlyFeatures?.();
|
|
59
|
+
const isMonthlyPlan = isMonthly( planSlug );
|
|
60
|
+
|
|
61
|
+
const wpcomFeatures = planConstantObj.get2023PlanComparisonFeatureOverride?.().length
|
|
62
|
+
? getPlanFeaturesObject(
|
|
63
|
+
allFeaturesList,
|
|
64
|
+
planConstantObj.get2023PlanComparisonFeatureOverride().slice()
|
|
65
|
+
)
|
|
66
|
+
: getPlanFeaturesObject(
|
|
67
|
+
allFeaturesList,
|
|
68
|
+
planConstantObj.get2023PricingGridSignupWpcomFeatures?.().slice()
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const jetpackFeatures = planConstantObj.get2023PlanComparisonJetpackFeatureOverride?.()
|
|
72
|
+
.length
|
|
73
|
+
? getPlanFeaturesObject(
|
|
74
|
+
allFeaturesList,
|
|
75
|
+
planConstantObj.get2023PlanComparisonJetpackFeatureOverride().slice()
|
|
76
|
+
)
|
|
77
|
+
: getPlanFeaturesObject(
|
|
78
|
+
allFeaturesList,
|
|
79
|
+
planConstantObj.get2023PricingGridSignupJetpackFeatures?.().slice()
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const wpcomFeaturesTransformed: TransformedFeatureObject[] | null | undefined =
|
|
83
|
+
annualPlansOnlyFeatures
|
|
84
|
+
? wpcomFeatures?.map( ( feature ) => {
|
|
85
|
+
const availableOnlyForAnnualPlans = annualPlansOnlyFeatures.includes(
|
|
86
|
+
feature.getSlug()
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
...feature,
|
|
91
|
+
availableOnlyForAnnualPlans,
|
|
92
|
+
availableForCurrentPlan: ! isMonthlyPlan || ! availableOnlyForAnnualPlans,
|
|
93
|
+
};
|
|
94
|
+
} )
|
|
95
|
+
: null;
|
|
96
|
+
|
|
97
|
+
const jetpackFeaturesTransformed: TransformedFeatureObject[] | null | undefined =
|
|
98
|
+
annualPlansOnlyFeatures
|
|
99
|
+
? jetpackFeatures?.map( ( feature ) => {
|
|
100
|
+
const availableOnlyForAnnualPlans = annualPlansOnlyFeatures.includes(
|
|
101
|
+
feature.getSlug()
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
...feature,
|
|
106
|
+
availableOnlyForAnnualPlans,
|
|
107
|
+
availableForCurrentPlan: ! isMonthlyPlan || ! availableOnlyForAnnualPlans,
|
|
108
|
+
};
|
|
109
|
+
} )
|
|
110
|
+
: null;
|
|
111
|
+
|
|
112
|
+
const featuresAvailable = isWooExpressPlan( planSlug )
|
|
113
|
+
? {
|
|
114
|
+
wpcomFeatures: wpcomFeaturesTransformed ?? [],
|
|
115
|
+
jetpackFeatures: [],
|
|
116
|
+
}
|
|
117
|
+
: {
|
|
118
|
+
wpcomFeatures: wpcomFeaturesTransformed ?? [],
|
|
119
|
+
jetpackFeatures: jetpackFeaturesTransformed ?? [],
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const previousPlanFeatures = {
|
|
123
|
+
wpcomFeatures: previousPlan !== null ? planFeatureMap[ previousPlan ].wpcomFeatures : [],
|
|
124
|
+
jetpackFeatures:
|
|
125
|
+
previousPlan !== null ? planFeatureMap[ previousPlan ].jetpackFeatures : [],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
planFeatureMap[ planSlug ] = {
|
|
129
|
+
wpcomFeatures: [
|
|
130
|
+
...featuresAvailable.wpcomFeatures,
|
|
131
|
+
...previousPlanFeatures.wpcomFeatures,
|
|
132
|
+
].filter( ( feature ) => {
|
|
133
|
+
// Remove the custom domain feature if custom domain has been redeemed or for Woo Express plans with an introductory offer.
|
|
134
|
+
if (
|
|
135
|
+
( ( 'plans-woocommerce' === intent && gridPlan.pricing.introOffer ) ||
|
|
136
|
+
hasRedeemedDomainCredit ) &&
|
|
137
|
+
FEATURE_CUSTOM_DOMAIN === feature.getSlug()
|
|
138
|
+
) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
|
+
} ),
|
|
143
|
+
jetpackFeatures: [
|
|
144
|
+
...featuresAvailable.jetpackFeatures,
|
|
145
|
+
...previousPlanFeatures.jetpackFeatures,
|
|
146
|
+
],
|
|
147
|
+
storageFeature: planFeaturesForGridPlans[ planSlug ].storageFeature,
|
|
148
|
+
comparisonGridFeatureLabels: planConstantObj.getPlanComparisonFeatureLabels?.(),
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
previousPlan = planSlug;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return planFeatureMap;
|
|
155
|
+
}, [ gridPlans, allFeaturesList, planFeaturesForGridPlans, intent, hasRedeemedDomainCredit ] );
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export default useRestructuredPlanFeaturesForComparisonGrid;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import useIsLargeCurrency from '../use-is-large-currency';
|
|
6
|
+
|
|
7
|
+
jest.mock( '@wordpress/element', () => ( {
|
|
8
|
+
...jest.requireActual( '@wordpress/element' ),
|
|
9
|
+
useMemo: jest.fn().mockImplementation( ( fn ) => fn() ),
|
|
10
|
+
} ) );
|
|
11
|
+
|
|
12
|
+
describe( 'useIsLargeCurrency', () => {
|
|
13
|
+
afterAll( () => {
|
|
14
|
+
jest.clearAllMocks();
|
|
15
|
+
} );
|
|
16
|
+
|
|
17
|
+
const smallPrices = [ 0, 0, 100, 0, 2500, 0 ];
|
|
18
|
+
const largePrices = [ 0, 0, 100000, 0, 30000000, 20 ];
|
|
19
|
+
|
|
20
|
+
describe( 'Given add on prices', () => {
|
|
21
|
+
describe( 'when all display prices are below 7 digits', () => {
|
|
22
|
+
test( 'should not consider prices to be large large', () => {
|
|
23
|
+
expect(
|
|
24
|
+
useIsLargeCurrency( { prices: smallPrices, isAddOn: true, currencyCode: 'USD' } )
|
|
25
|
+
).toEqual( false );
|
|
26
|
+
} );
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
describe( 'when some display prices are above 7 digits', () => {
|
|
30
|
+
test( 'should consider prices to be large', () => {
|
|
31
|
+
expect(
|
|
32
|
+
useIsLargeCurrency( { prices: largePrices, isAddOn: true, currencyCode: 'USD' } )
|
|
33
|
+
).toEqual( true );
|
|
34
|
+
} );
|
|
35
|
+
} );
|
|
36
|
+
} );
|
|
37
|
+
|
|
38
|
+
describe( 'Given plan prices', () => {
|
|
39
|
+
describe( 'when all display prices are below 6 digits', () => {
|
|
40
|
+
test( 'should not consider prices to be large', () => {
|
|
41
|
+
expect(
|
|
42
|
+
useIsLargeCurrency( { prices: smallPrices, isAddOn: false, currencyCode: 'USD' } )
|
|
43
|
+
).toEqual( false );
|
|
44
|
+
} );
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
describe( 'when some display prices are above 6 digits', () => {
|
|
48
|
+
test( 'should consider prices to be large', () => {
|
|
49
|
+
expect(
|
|
50
|
+
useIsLargeCurrency( { prices: largePrices, isAddOn: false, currencyCode: 'USD' } )
|
|
51
|
+
).toEqual( true );
|
|
52
|
+
} );
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
describe( 'when a pair of original and discounted prices are above 9 digits', () => {
|
|
56
|
+
test( 'should consider it large', () => {
|
|
57
|
+
const largeCombinedPlanPrices = [ 20000, 3000 ];
|
|
58
|
+
|
|
59
|
+
expect(
|
|
60
|
+
useIsLargeCurrency( {
|
|
61
|
+
prices: largeCombinedPlanPrices,
|
|
62
|
+
isAddOn: false,
|
|
63
|
+
currencyCode: 'USD',
|
|
64
|
+
} )
|
|
65
|
+
).toEqual( false );
|
|
66
|
+
} );
|
|
67
|
+
} );
|
|
68
|
+
} );
|
|
69
|
+
} );
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useLayoutEffect, useState } from '@wordpress/element';
|
|
2
|
+
import ResizeObserver from 'resize-observer-polyfill';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
containerRef: React.MutableRefObject< HTMLDivElement | null >;
|
|
6
|
+
/**
|
|
7
|
+
* Labelled breakpoints a la "container query".
|
|
8
|
+
* These are currently observed manually (i.e. we do not use container queries),
|
|
9
|
+
* but they could be used in the future in a containment context.
|
|
10
|
+
* The keys are the labels, the values are the minimum widths.
|
|
11
|
+
*/
|
|
12
|
+
containerBreakpoints: Map< string, number >;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* useGridSize returns the current grid size based on the width of the container
|
|
17
|
+
* and the breakpoints passed through as props.
|
|
18
|
+
*/
|
|
19
|
+
export default function useGridSize( { containerRef, containerBreakpoints }: Props ) {
|
|
20
|
+
const [ gridSize, setGridSize ] = useState< string | null >( null );
|
|
21
|
+
|
|
22
|
+
useLayoutEffect( () => {
|
|
23
|
+
if ( ! containerRef.current ) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const observer = new ResizeObserver( ( [ entry ] ) => {
|
|
28
|
+
const { width } = entry.contentRect;
|
|
29
|
+
|
|
30
|
+
if ( width ) {
|
|
31
|
+
for ( const [ key, value ] of [ ...containerBreakpoints ].reverse() ) {
|
|
32
|
+
if ( width >= value ) {
|
|
33
|
+
setGridSize( key );
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
observer.observe( containerRef.current );
|
|
41
|
+
|
|
42
|
+
return () => observer.disconnect();
|
|
43
|
+
}, [ containerRef, containerBreakpoints ] );
|
|
44
|
+
|
|
45
|
+
return gridSize;
|
|
46
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useMemo } from '@wordpress/element';
|
|
2
|
+
import type { GridPlan } from '../types';
|
|
3
|
+
import type { PlanSlug } from '@automattic/calypso-products';
|
|
4
|
+
|
|
5
|
+
type HighlightAdjacencyMatrix = {
|
|
6
|
+
[ planSlug in PlanSlug ]: {
|
|
7
|
+
leftOfHighlight: boolean;
|
|
8
|
+
rightOfHighlight: boolean;
|
|
9
|
+
isOnlyHighlight?: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
renderedGridPlans: GridPlan[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const useHighlightAdjacencyMatrix = ( { renderedGridPlans }: Props ) => {
|
|
18
|
+
return useMemo( () => {
|
|
19
|
+
const adjacencyMatrix = {} as HighlightAdjacencyMatrix;
|
|
20
|
+
const highlightIndices = renderedGridPlans.reduce( ( acc, gridPlan, index ) => {
|
|
21
|
+
if ( gridPlan.highlightLabel ) {
|
|
22
|
+
acc.push( index );
|
|
23
|
+
}
|
|
24
|
+
return acc;
|
|
25
|
+
}, [] as number[] );
|
|
26
|
+
|
|
27
|
+
renderedGridPlans.forEach( ( { planSlug }, index ) => {
|
|
28
|
+
adjacencyMatrix[ planSlug ] = { leftOfHighlight: false, rightOfHighlight: false };
|
|
29
|
+
|
|
30
|
+
highlightIndices.forEach( ( highlightIndex ) => {
|
|
31
|
+
if ( highlightIndex === index - 1 ) {
|
|
32
|
+
adjacencyMatrix[ planSlug ].rightOfHighlight = true;
|
|
33
|
+
}
|
|
34
|
+
if ( highlightIndex === index + 1 ) {
|
|
35
|
+
adjacencyMatrix[ planSlug ].leftOfHighlight = true;
|
|
36
|
+
}
|
|
37
|
+
} );
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
if ( highlightIndices.length === 1 ) {
|
|
41
|
+
adjacencyMatrix[ renderedGridPlans[ highlightIndices[ 0 ] ].planSlug ].isOnlyHighlight = true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return adjacencyMatrix;
|
|
45
|
+
}, [ renderedGridPlans ] );
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default useHighlightAdjacencyMatrix;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useMemo } from '@wordpress/element';
|
|
2
|
+
import { formatCurrency } from 'i18n-calypso';
|
|
3
|
+
const LARGE_ADD_ON_CURRENCY_CHAR_THRESHOLD = 7;
|
|
4
|
+
const LARGE_CURRENCY_CHAR_THRESHOLD = 6;
|
|
5
|
+
const LARGE_CURRENCY_COMBINED_CHAR_THRESHOLD = 9;
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
prices?: number[];
|
|
9
|
+
isAddOn?: boolean;
|
|
10
|
+
currencyCode: string;
|
|
11
|
+
ignoreWhitespace?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function useDisplayPrices( currencyCode: string, prices?: number[], ignoreWhitespace = false ) {
|
|
15
|
+
/**
|
|
16
|
+
* Prices are represented in smallest units for a currency, and not as prices that
|
|
17
|
+
* are actually displayed. Ex. $20 is the integer 2000, and not 20. To determine if
|
|
18
|
+
* the display price is too long, we convert the integer to a display string.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
return useMemo(
|
|
22
|
+
() =>
|
|
23
|
+
prices?.map( ( price ) => {
|
|
24
|
+
const displayPrice = formatCurrency( price, currencyCode, {
|
|
25
|
+
stripZeros: true,
|
|
26
|
+
isSmallestUnit: true,
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
return ignoreWhitespace ? displayPrice.replace( /\s/g, '' ) : displayPrice;
|
|
30
|
+
} ),
|
|
31
|
+
[ currencyCode, prices, ignoreWhitespace ]
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function hasExceededPriceThreshold( displayPrices?: string[], isAddOn = false ) {
|
|
36
|
+
const threshold = isAddOn ? LARGE_ADD_ON_CURRENCY_CHAR_THRESHOLD : LARGE_CURRENCY_CHAR_THRESHOLD;
|
|
37
|
+
return !! displayPrices?.some( ( price ) => price.length > threshold );
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns true if the combined length of the display prices exceeds the threshold.
|
|
42
|
+
* Checks the adjacent pairs in the displayPrices array,
|
|
43
|
+
* which correspnd to the original-price and discounted-price for each plan.
|
|
44
|
+
*/
|
|
45
|
+
function hasExceededCombinedPriceThreshold( displayPrices?: string[] ) {
|
|
46
|
+
if ( ! displayPrices || displayPrices.length < 2 ) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
for ( let i = 0; i < displayPrices.length - 1; i++ ) {
|
|
51
|
+
const originalPrice = displayPrices[ i ];
|
|
52
|
+
const discountedPrice = displayPrices[ i + 1 ];
|
|
53
|
+
|
|
54
|
+
if ( originalPrice.length + discountedPrice.length > LARGE_CURRENCY_COMBINED_CHAR_THRESHOLD ) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Hook that returns true if the string representation of any price (discounted/undiscounted)
|
|
64
|
+
* of any of the plan slugs exceeds 6 characters. For example, $4,000 would be 6 characters.
|
|
65
|
+
* Additionally, also returns true if the combined discounted / undiscounted prices exceed
|
|
66
|
+
* 9 characters. For example, $4,000 undiscounted and $30 discounted would be 9 characters.
|
|
67
|
+
* This is primarily used for lowering the font-size of "large" display prices.
|
|
68
|
+
*/
|
|
69
|
+
export default function useIsLargeCurrency( {
|
|
70
|
+
prices,
|
|
71
|
+
isAddOn = false,
|
|
72
|
+
currencyCode,
|
|
73
|
+
ignoreWhitespace = false,
|
|
74
|
+
}: Props ) {
|
|
75
|
+
/**
|
|
76
|
+
* Because this hook is primarily used for lowering font-sizes of "large" display prices,
|
|
77
|
+
* this implementation is non-ideal. It assumes that each character in the display price,
|
|
78
|
+
* including currency symbols, comma separators, decimal points, etc. are all the same width.
|
|
79
|
+
*
|
|
80
|
+
* For the time being, however, this is a good enough approximation and works with our existing
|
|
81
|
+
* currencies. We'll need to update this in the near future, especially to prevent issues with
|
|
82
|
+
* newly introduced currencies.
|
|
83
|
+
*
|
|
84
|
+
* https://github.com/Automattic/wp-calypso/pull/81537#discussion_r1323182287
|
|
85
|
+
*/
|
|
86
|
+
const displayPrices = useDisplayPrices( currencyCode, prices, ignoreWhitespace );
|
|
87
|
+
const exceedsPriceThreshold = hasExceededPriceThreshold( displayPrices, isAddOn );
|
|
88
|
+
const exceedsCombinedPriceThreshold = hasExceededCombinedPriceThreshold( displayPrices );
|
|
89
|
+
|
|
90
|
+
return isAddOn ? exceedsPriceThreshold : exceedsPriceThreshold || exceedsCombinedPriceThreshold;
|
|
91
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useState, useEffect, Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { hasTouch } from '../lib/touch-detect';
|
|
3
|
+
|
|
4
|
+
export function useManageTooltipToggle(): [ string, Dispatch< SetStateAction< string > > ] {
|
|
5
|
+
const [ activeTooltipId, setActiveTooltipId ] = useState( '' );
|
|
6
|
+
const isTouch = hasTouch();
|
|
7
|
+
|
|
8
|
+
useEffect( () => {
|
|
9
|
+
if ( ! isTouch ) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Close all tooltips if the user touches anywhere outside a tooltip container.
|
|
14
|
+
// Since the plan logos are an SVG, we are checking the event target's parent classes to determine the tooltip container.
|
|
15
|
+
const closeAllTooltips = ( event: TouchEvent ) => {
|
|
16
|
+
const eventTarget = event.target as Element;
|
|
17
|
+
if ( ! eventTarget.closest( '.plans-2023-tooltip__hover-area-container' ) ) {
|
|
18
|
+
setActiveTooltipId( '' );
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
document.addEventListener( 'touchstart', closeAllTooltips );
|
|
23
|
+
|
|
24
|
+
return () => {
|
|
25
|
+
document.removeEventListener( 'touchstart', closeAllTooltips );
|
|
26
|
+
};
|
|
27
|
+
}, [ isTouch ] );
|
|
28
|
+
|
|
29
|
+
return [ activeTooltipId, setActiveTooltipId ];
|
|
30
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useMemo } from '@wordpress/element';
|
|
2
|
+
import type { GridPlan } from '../types';
|
|
3
|
+
|
|
4
|
+
type PricingInfo = {
|
|
5
|
+
prices: number[];
|
|
6
|
+
currencyCode?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function usePlanPricingInfoFromGridPlans( {
|
|
10
|
+
gridPlans,
|
|
11
|
+
returnMonthly = true,
|
|
12
|
+
}: {
|
|
13
|
+
gridPlans: GridPlan[];
|
|
14
|
+
returnMonthly?: boolean;
|
|
15
|
+
} ) {
|
|
16
|
+
return useMemo(
|
|
17
|
+
() =>
|
|
18
|
+
gridPlans.reduce(
|
|
19
|
+
( acc: PricingInfo, gridPlan ) => {
|
|
20
|
+
const {
|
|
21
|
+
pricing: { originalPrice, discountedPrice, currencyCode },
|
|
22
|
+
} = gridPlan;
|
|
23
|
+
|
|
24
|
+
const originalPriceForTerm = originalPrice[ returnMonthly ? 'monthly' : 'full' ] || 0;
|
|
25
|
+
const discountedPriceForTerm = discountedPrice[ returnMonthly ? 'monthly' : 'full' ] || 0;
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
prices: [ ...acc.prices, originalPriceForTerm, discountedPriceForTerm ],
|
|
29
|
+
currencyCode: currencyCode ?? acc.currencyCode,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
{ prices: [], currencyCode: 'USD' }
|
|
33
|
+
),
|
|
34
|
+
[ gridPlans, returnMonthly ]
|
|
35
|
+
);
|
|
36
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import ComparisonGrid from './components/comparison-grid';
|
|
2
|
+
import FeaturesGrid from './components/features-grid';
|
|
3
|
+
import PlanButton from './components/plan-button';
|
|
4
|
+
import PlanTypeSelector from './components/plan-type-selector';
|
|
5
|
+
import { Plans2023Tooltip } from './components/plans-2023-tooltip';
|
|
6
|
+
import { EFFECTIVE_TERMS_LIST } from './constants';
|
|
7
|
+
import useGridPlanForSpotlight from './hooks/data-store/use-grid-plan-for-spotlight';
|
|
8
|
+
import useGridPlans, { usePlanTypesWithIntent } from './hooks/data-store/use-grid-plans';
|
|
9
|
+
import useGridPlansForComparisonGrid from './hooks/data-store/use-grid-plans-for-comparison-grid';
|
|
10
|
+
import useGridPlansForFeaturesGrid from './hooks/data-store/use-grid-plans-for-features-grid';
|
|
11
|
+
import usePlanBillingDescription from './hooks/data-store/use-plan-billing-description';
|
|
12
|
+
import usePlanFeaturesForGridPlans from './hooks/data-store/use-plan-features-for-grid-plans';
|
|
13
|
+
import usePlansFromTypes from './hooks/data-store/use-plans-from-types';
|
|
14
|
+
import useRestructuredPlanFeaturesForComparisonGrid from './hooks/data-store/use-restructured-plan-features-for-comparison-grid';
|
|
15
|
+
import { useManageTooltipToggle } from './hooks/use-manage-tooltip-toggle';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Types
|
|
19
|
+
*/
|
|
20
|
+
export type * from './types';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Components
|
|
24
|
+
*/
|
|
25
|
+
export { ComparisonGrid, FeaturesGrid, PlanTypeSelector, PlanButton, Plans2023Tooltip };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Hooks/helpers
|
|
29
|
+
*/
|
|
30
|
+
export {
|
|
31
|
+
useManageTooltipToggle,
|
|
32
|
+
useGridPlans,
|
|
33
|
+
useGridPlansForFeaturesGrid,
|
|
34
|
+
useGridPlansForComparisonGrid,
|
|
35
|
+
useGridPlanForSpotlight,
|
|
36
|
+
usePlanBillingDescription,
|
|
37
|
+
usePlanFeaturesForGridPlans,
|
|
38
|
+
usePlansFromTypes,
|
|
39
|
+
usePlanTypesWithIntent,
|
|
40
|
+
useRestructuredPlanFeaturesForComparisonGrid,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Constants
|
|
45
|
+
*/
|
|
46
|
+
export { EFFECTIVE_TERMS_LIST };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { GridPlan } from '../types';
|
|
2
|
+
import type { FeatureObject } from '@automattic/calypso-products';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Removes features that are not available in any of the visible grid plans.
|
|
6
|
+
*/
|
|
7
|
+
const filterUnusedFeaturesObject = (
|
|
8
|
+
visibleGridPlans: GridPlan[],
|
|
9
|
+
features: FeatureObject[]
|
|
10
|
+
): FeatureObject[] => {
|
|
11
|
+
if ( ! visibleGridPlans || ! features ) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Get all unique feature slugs in all gridPlans.
|
|
16
|
+
const uniqueFeaturesAvailable = new Set(
|
|
17
|
+
visibleGridPlans
|
|
18
|
+
.map( ( gridPlan ) =>
|
|
19
|
+
[ ...gridPlan.features.wpcomFeatures, ...gridPlan.features.jetpackFeatures ].map(
|
|
20
|
+
( feature ) => feature.getSlug()
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
.flat()
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return features.filter( ( feature ) => {
|
|
27
|
+
return uniqueFeaturesAvailable.has( feature.getSlug() );
|
|
28
|
+
} );
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default filterUnusedFeaturesObject;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FeatureList } from '@automattic/calypso-products';
|
|
2
|
+
|
|
3
|
+
// TODO: Temporary until feature definitions are ported to calypso-products package
|
|
4
|
+
const getPlanFeaturesObject = ( featuresList: FeatureList, planFeatures?: Array< string > ) => {
|
|
5
|
+
if ( ! planFeatures ) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return planFeatures.map( ( featuresConst ) => featuresList[ featuresConst ] );
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default getPlanFeaturesObject;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { GridPlan } from '../types';
|
|
2
|
+
|
|
3
|
+
type PricingInfo = {
|
|
4
|
+
prices: number[];
|
|
5
|
+
currencyCode?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function getPlanPricingInfoFromGridPlans( {
|
|
9
|
+
gridPlans,
|
|
10
|
+
returnMonthly = true,
|
|
11
|
+
}: {
|
|
12
|
+
gridPlans: GridPlan[];
|
|
13
|
+
returnMonthly?: boolean;
|
|
14
|
+
} ) {
|
|
15
|
+
return gridPlans.reduce(
|
|
16
|
+
( acc: PricingInfo, gridPlan ) => {
|
|
17
|
+
const {
|
|
18
|
+
pricing: { originalPrice, discountedPrice, currencyCode },
|
|
19
|
+
} = gridPlan;
|
|
20
|
+
|
|
21
|
+
const originalPriceForTerm = originalPrice[ returnMonthly ? 'monthly' : 'full' ] || 0;
|
|
22
|
+
const discountedPriceForTerm = discountedPrice[ returnMonthly ? 'monthly' : 'full' ] || 0;
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
prices: [ ...acc.prices, originalPriceForTerm, discountedPriceForTerm ],
|
|
26
|
+
...( currencyCode && { currencyCode } ),
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
{ prices: [], currencyCode: 'USD' }
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PLAN_FREE, isFreePlan, type PlanSlug } from '@automattic/calypso-products';
|
|
2
|
+
|
|
3
|
+
export function isSamePlan( currentSitePlanSlug: string, planSlug: PlanSlug ): boolean {
|
|
4
|
+
// Handles matching variants of the free plan, like PLAN_P2_FREE and PLAN_JETPACK_FREE
|
|
5
|
+
return currentSitePlanSlug === PLAN_FREE
|
|
6
|
+
? isFreePlan( planSlug )
|
|
7
|
+
: currentSitePlanSlug === planSlug;
|
|
8
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isFreePlan } from '@automattic/calypso-products';
|
|
2
|
+
import { isPopularPlan } from '../hooks/data-store/is-popular-plan';
|
|
3
|
+
import type { GridPlan } from '../types';
|
|
4
|
+
|
|
5
|
+
export function sortPlans(
|
|
6
|
+
gridPlans: GridPlan[],
|
|
7
|
+
currentSitePlanProductSlug?: string | null,
|
|
8
|
+
isMobile?: boolean
|
|
9
|
+
): GridPlan[] {
|
|
10
|
+
let firstPlanIndex = -1;
|
|
11
|
+
|
|
12
|
+
// Try to find the current paid plan in the plans list
|
|
13
|
+
if ( currentSitePlanProductSlug && ! isFreePlan( currentSitePlanProductSlug ) ) {
|
|
14
|
+
firstPlanIndex = gridPlans.findIndex( ( gridPlan ) => {
|
|
15
|
+
return gridPlan.planSlug === currentSitePlanProductSlug;
|
|
16
|
+
} );
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if ( firstPlanIndex < 0 ) {
|
|
20
|
+
// Site is on a free plan or the current plan is not in the list. Try to find the popular plan.
|
|
21
|
+
firstPlanIndex = gridPlans.findIndex( ( { planSlug } ) => {
|
|
22
|
+
return isPopularPlan( planSlug );
|
|
23
|
+
} );
|
|
24
|
+
// If the popular plan exists, on mobile, it will be second plan for comparison.
|
|
25
|
+
if ( firstPlanIndex > 0 && isMobile ) {
|
|
26
|
+
firstPlanIndex = firstPlanIndex - 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if ( firstPlanIndex < 0 ) {
|
|
31
|
+
return gridPlans;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return [
|
|
35
|
+
// The first plan
|
|
36
|
+
gridPlans[ firstPlanIndex ],
|
|
37
|
+
// Rest of the plans in default order
|
|
38
|
+
...gridPlans.slice( firstPlanIndex + 1 ),
|
|
39
|
+
// Leftover plans (before the first plan) in descending order of value
|
|
40
|
+
...gridPlans.slice( 0, firstPlanIndex ).sort( ( planA, planB ) => {
|
|
41
|
+
return (
|
|
42
|
+
( planB?.pricing.originalPrice.full || 0 ) - ( planA?.pricing.originalPrice.full || 0 )
|
|
43
|
+
);
|
|
44
|
+
} ),
|
|
45
|
+
].filter( ( gridPlan ) => Boolean( gridPlan ) );
|
|
46
|
+
}
|