@automattic/plans-grid-next 1.0.1 → 1.0.3
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 -1
- package/dist/cjs/_shared.scss +4 -3
- package/dist/cjs/components/comparison-grid/index.js +101 -71
- package/dist/cjs/components/comparison-grid/index.js.map +1 -1
- package/dist/cjs/components/comparison-grid/index.stories.js.map +1 -1
- package/dist/cjs/components/comparison-grid/style.scss +10 -2
- package/dist/cjs/components/features-grid/client-logo-list/client-list.js +0 -12
- package/dist/cjs/components/features-grid/client-logo-list/client-list.js.map +1 -1
- package/dist/cjs/components/features-grid/index.js +9 -6
- package/dist/cjs/components/features-grid/index.js.map +1 -1
- package/dist/cjs/components/features-grid/plan-features-list.js +10 -3
- package/dist/cjs/components/features-grid/plan-features-list.js.map +1 -1
- package/dist/cjs/components/features-grid/plan-headers.js +2 -2
- package/dist/cjs/components/features-grid/plan-headers.js.map +1 -1
- package/dist/cjs/components/features-grid/plan-tagline.js +1 -1
- package/dist/cjs/components/features-grid/plan-tagline.js.map +1 -1
- package/dist/cjs/components/features-grid/style.scss +111 -21
- package/dist/cjs/components/features-grid/table.js +1 -1
- package/dist/cjs/components/features-grid/table.js.map +1 -1
- package/dist/cjs/components/features.js +43 -4
- package/dist/cjs/components/features.js.map +1 -1
- package/dist/cjs/components/item.js +1 -1
- package/dist/cjs/components/item.js.map +1 -1
- package/dist/cjs/components/plan-button/index.js +5 -3
- package/dist/cjs/components/plan-button/index.js.map +1 -1
- package/dist/cjs/components/plan-button/style.scss +71 -47
- package/dist/cjs/components/plan-div-td-container.js +4 -1
- package/dist/cjs/components/plan-div-td-container.js.map +1 -1
- package/dist/cjs/components/plan-logo.js +6 -3
- package/dist/cjs/components/plan-logo.js.map +1 -1
- package/dist/cjs/components/plan-type-selector/components/interval-type-dropdown.js +12 -1
- package/dist/cjs/components/plan-type-selector/components/interval-type-dropdown.js.map +1 -1
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discount.js +4 -33
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discount.js.map +1 -1
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js +11 -13
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js.map +1 -1
- package/dist/cjs/components/plans-2023-tooltip.js +16 -5
- package/dist/cjs/components/plans-2023-tooltip.js.map +1 -1
- package/dist/cjs/components/shared/action-button/index.js +22 -7
- package/dist/cjs/components/shared/action-button/index.js.map +1 -1
- package/dist/cjs/components/shared/action-button/style.scss +4 -0
- package/dist/cjs/components/shared/billing-timeframe/index.js +8 -4
- package/dist/cjs/components/shared/billing-timeframe/index.js.map +1 -1
- package/dist/cjs/components/shared/header-price/index.js +60 -15
- package/dist/cjs/components/shared/header-price/index.js.map +1 -1
- package/dist/cjs/components/shared/header-price/style.scss +10 -2
- package/dist/cjs/components/shared/storage/components/plan-storage.js +2 -2
- package/dist/cjs/components/shared/storage/components/plan-storage.js.map +1 -1
- package/dist/cjs/components/shared/storage/components/storage-dropdown.js +29 -6
- package/dist/cjs/components/shared/storage/components/storage-dropdown.js.map +1 -1
- package/dist/cjs/components/shared/storage/components/storage-feature-label.js +2 -1
- package/dist/cjs/components/shared/storage/components/storage-feature-label.js.map +1 -1
- package/dist/cjs/components/shared/storage/hooks/use-plan-storage.js +2 -0
- package/dist/cjs/components/shared/storage/hooks/use-plan-storage.js.map +1 -1
- package/dist/cjs/fixtures/sites-purchases.js +2 -4
- package/dist/cjs/fixtures/sites-purchases.js.map +1 -1
- package/dist/cjs/grid-context.js +4 -1
- package/dist/cjs/grid-context.js.map +1 -1
- package/dist/cjs/hooks/data-store/get-renewal-pricing-text.js +50 -0
- package/dist/cjs/hooks/data-store/get-renewal-pricing-text.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-grid-plans-for-comparison-grid.js +6 -1
- package/dist/cjs/hooks/data-store/use-grid-plans-for-comparison-grid.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-grid-plans-for-features-grid.js +6 -1
- package/dist/cjs/hooks/data-store/use-grid-plans-for-features-grid.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-grid-plans.js +175 -21
- package/dist/cjs/hooks/data-store/use-grid-plans.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-highlight-labels.js +13 -4
- package/dist/cjs/hooks/data-store/use-highlight-labels.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-plan-billing-description.js +68 -13
- package/dist/cjs/hooks/data-store/use-plan-billing-description.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-plan-billing-period.js +14 -0
- package/dist/cjs/hooks/data-store/use-plan-billing-period.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-plan-features-for-grid-plans.js +76 -2
- package/dist/cjs/hooks/data-store/use-plan-features-for-grid-plans.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js +60 -12
- package/dist/cjs/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-title-badges.js +19 -0
- package/dist/cjs/hooks/data-store/use-title-badges.js.map +1 -0
- package/dist/cjs/hooks/use-grid-size.js.map +1 -1
- package/dist/cjs/hooks/use-is-large-currency.js +2 -2
- package/dist/cjs/hooks/use-is-large-currency.js.map +1 -1
- package/dist/cjs/hooks/use-visible-grid-plans.js +70 -0
- package/dist/cjs/hooks/use-visible-grid-plans.js.map +1 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/get-plan-features-object.js +15 -2
- package/dist/cjs/lib/get-plan-features-object.js.map +1 -1
- package/dist/cjs/lib/plan-pricing-utils.js +135 -0
- package/dist/cjs/lib/plan-pricing-utils.js.map +1 -0
- package/dist/esm/_shared.scss +4 -3
- package/dist/esm/components/comparison-grid/index.js +102 -72
- package/dist/esm/components/comparison-grid/index.js.map +1 -1
- package/dist/esm/components/comparison-grid/index.stories.js.map +1 -1
- package/dist/esm/components/comparison-grid/style.scss +10 -2
- package/dist/esm/components/features-grid/client-logo-list/client-list.js +0 -12
- package/dist/esm/components/features-grid/client-logo-list/client-list.js.map +1 -1
- package/dist/esm/components/features-grid/index.js +9 -6
- package/dist/esm/components/features-grid/index.js.map +1 -1
- package/dist/esm/components/features-grid/plan-features-list.js +10 -3
- package/dist/esm/components/features-grid/plan-features-list.js.map +1 -1
- package/dist/esm/components/features-grid/plan-headers.js +3 -3
- package/dist/esm/components/features-grid/plan-headers.js.map +1 -1
- package/dist/esm/components/features-grid/plan-tagline.js +1 -1
- package/dist/esm/components/features-grid/plan-tagline.js.map +1 -1
- package/dist/esm/components/features-grid/style.scss +111 -21
- package/dist/esm/components/features-grid/table.js +1 -1
- package/dist/esm/components/features-grid/table.js.map +1 -1
- package/dist/esm/components/features.js +44 -5
- package/dist/esm/components/features.js.map +1 -1
- package/dist/esm/components/item.js +1 -1
- package/dist/esm/components/item.js.map +1 -1
- package/dist/esm/components/plan-button/index.js +5 -3
- package/dist/esm/components/plan-button/index.js.map +1 -1
- package/dist/esm/components/plan-button/style.scss +71 -47
- package/dist/esm/components/plan-div-td-container.js +4 -1
- package/dist/esm/components/plan-div-td-container.js.map +1 -1
- package/dist/esm/components/plan-logo.js +7 -4
- package/dist/esm/components/plan-logo.js.map +1 -1
- package/dist/esm/components/plan-type-selector/components/interval-type-dropdown.js +12 -1
- package/dist/esm/components/plan-type-selector/components/interval-type-dropdown.js.map +1 -1
- package/dist/esm/components/plan-type-selector/hooks/use-max-discount.js +3 -33
- package/dist/esm/components/plan-type-selector/hooks/use-max-discount.js.map +1 -1
- package/dist/esm/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js +11 -13
- package/dist/esm/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js.map +1 -1
- package/dist/esm/components/plans-2023-tooltip.js +16 -5
- package/dist/esm/components/plans-2023-tooltip.js.map +1 -1
- package/dist/esm/components/shared/action-button/index.js +22 -7
- package/dist/esm/components/shared/action-button/index.js.map +1 -1
- package/dist/esm/components/shared/action-button/style.scss +4 -0
- package/dist/esm/components/shared/billing-timeframe/index.js +8 -4
- package/dist/esm/components/shared/billing-timeframe/index.js.map +1 -1
- package/dist/esm/components/shared/header-price/index.js +60 -15
- package/dist/esm/components/shared/header-price/index.js.map +1 -1
- package/dist/esm/components/shared/header-price/style.scss +10 -2
- package/dist/esm/components/shared/storage/components/plan-storage.js +2 -2
- package/dist/esm/components/shared/storage/components/plan-storage.js.map +1 -1
- package/dist/esm/components/shared/storage/components/storage-dropdown.js +30 -7
- package/dist/esm/components/shared/storage/components/storage-dropdown.js.map +1 -1
- package/dist/esm/components/shared/storage/components/storage-feature-label.js +2 -1
- package/dist/esm/components/shared/storage/components/storage-feature-label.js.map +1 -1
- package/dist/esm/components/shared/storage/hooks/use-plan-storage.js +3 -1
- package/dist/esm/components/shared/storage/hooks/use-plan-storage.js.map +1 -1
- package/dist/esm/fixtures/sites-purchases.js +2 -4
- package/dist/esm/fixtures/sites-purchases.js.map +1 -1
- package/dist/esm/grid-context.js +4 -1
- package/dist/esm/grid-context.js.map +1 -1
- package/dist/esm/hooks/data-store/get-renewal-pricing-text.js +47 -0
- package/dist/esm/hooks/data-store/get-renewal-pricing-text.js.map +1 -0
- package/dist/esm/hooks/data-store/use-grid-plans-for-comparison-grid.js +6 -1
- package/dist/esm/hooks/data-store/use-grid-plans-for-comparison-grid.js.map +1 -1
- package/dist/esm/hooks/data-store/use-grid-plans-for-features-grid.js +6 -1
- package/dist/esm/hooks/data-store/use-grid-plans-for-features-grid.js.map +1 -1
- package/dist/esm/hooks/data-store/use-grid-plans.js +176 -22
- package/dist/esm/hooks/data-store/use-grid-plans.js.map +1 -1
- package/dist/esm/hooks/data-store/use-highlight-labels.js +14 -5
- package/dist/esm/hooks/data-store/use-highlight-labels.js.map +1 -1
- package/dist/esm/hooks/data-store/use-plan-billing-description.js +66 -11
- package/dist/esm/hooks/data-store/use-plan-billing-description.js.map +1 -1
- package/dist/esm/hooks/data-store/use-plan-billing-period.js +12 -0
- package/dist/esm/hooks/data-store/use-plan-billing-period.js.map +1 -0
- package/dist/esm/hooks/data-store/use-plan-features-for-grid-plans.js +77 -3
- package/dist/esm/hooks/data-store/use-plan-features-for-grid-plans.js.map +1 -1
- package/dist/esm/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js +59 -11
- package/dist/esm/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js.map +1 -1
- package/dist/esm/hooks/data-store/use-title-badges.js +17 -0
- package/dist/esm/hooks/data-store/use-title-badges.js.map +1 -0
- package/dist/esm/hooks/use-grid-size.js.map +1 -1
- package/dist/esm/hooks/use-is-large-currency.js +1 -1
- package/dist/esm/hooks/use-is-large-currency.js.map +1 -1
- package/dist/esm/hooks/use-visible-grid-plans.js +66 -0
- package/dist/esm/hooks/use-visible-grid-plans.js.map +1 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/get-plan-features-object.js +15 -2
- package/dist/esm/lib/get-plan-features-object.js.map +1 -1
- package/dist/esm/lib/plan-pricing-utils.js +129 -0
- package/dist/esm/lib/plan-pricing-utils.js.map +1 -0
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/comparison-grid/index.d.ts +1 -1
- package/dist/types/components/comparison-grid/index.d.ts.map +1 -1
- package/dist/types/components/comparison-grid/index.stories.d.ts +2 -2
- package/dist/types/components/dropdown-option.d.ts.map +1 -1
- package/dist/types/components/features-grid/billing-timeframes.d.ts.map +1 -1
- package/dist/types/components/features-grid/client-logo-list/client-list.d.ts.map +1 -1
- package/dist/types/components/features-grid/client-logo-list/index.d.ts.map +1 -1
- package/dist/types/components/features-grid/enterprise-features.d.ts.map +1 -1
- package/dist/types/components/features-grid/index.d.ts.map +1 -1
- package/dist/types/components/features-grid/plan-features-list.d.ts.map +1 -1
- package/dist/types/components/features-grid/plan-headers.d.ts +2 -0
- package/dist/types/components/features-grid/plan-headers.d.ts.map +1 -1
- package/dist/types/components/features-grid/plan-logos.d.ts.map +1 -1
- package/dist/types/components/features-grid/plan-prices.d.ts.map +1 -1
- package/dist/types/components/features-grid/plan-tagline.d.ts.map +1 -1
- package/dist/types/components/features-grid/previous-features-included-title.d.ts.map +1 -1
- package/dist/types/components/features-grid/spotlight-plan.d.ts.map +1 -1
- package/dist/types/components/features-grid/table.d.ts.map +1 -1
- package/dist/types/components/features-grid/top-buttons.d.ts.map +1 -1
- package/dist/types/components/features.d.ts.map +1 -1
- package/dist/types/components/item.d.ts +2 -1
- package/dist/types/components/item.d.ts.map +1 -1
- package/dist/types/components/plan-button/index.d.ts +2 -1
- package/dist/types/components/plan-button/index.d.ts.map +1 -1
- package/dist/types/components/plan-div-td-container.d.ts +2 -0
- package/dist/types/components/plan-div-td-container.d.ts.map +1 -1
- package/dist/types/components/plan-logo.d.ts.map +1 -1
- package/dist/types/components/plan-type-selector/components/interval-type-dropdown.d.ts.map +1 -1
- package/dist/types/components/plan-type-selector/hooks/use-max-discount.d.ts.map +1 -1
- package/dist/types/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.d.ts.map +1 -1
- package/dist/types/components/plans-2023-tooltip.d.ts.map +1 -1
- package/dist/types/components/shared/action-button/index.d.ts +2 -1
- package/dist/types/components/shared/action-button/index.d.ts.map +1 -1
- package/dist/types/components/shared/billing-timeframe/index.d.ts.map +1 -1
- package/dist/types/components/shared/header-price/header-price-context.d.ts.map +1 -1
- package/dist/types/components/shared/header-price/index.d.ts.map +1 -1
- package/dist/types/components/shared/storage/components/plan-storage.d.ts.map +1 -1
- package/dist/types/components/shared/storage/components/storage-dropdown.d.ts.map +1 -1
- package/dist/types/components/shared/storage/components/storage-feature-label.d.ts.map +1 -1
- package/dist/types/components/shared/storage/hooks/use-plan-storage.d.ts +1 -1
- package/dist/types/components/shared/storage/hooks/use-plan-storage.d.ts.map +1 -1
- package/dist/types/css-mixins.d.ts.map +1 -1
- package/dist/types/fixtures/sites-purchases.d.ts +2 -4
- package/dist/types/fixtures/sites-purchases.d.ts.map +1 -1
- package/dist/types/grid-context.d.ts +4 -1
- package/dist/types/grid-context.d.ts.map +1 -1
- package/dist/types/hooks/data-store/get-renewal-pricing-text.d.ts +14 -0
- package/dist/types/hooks/data-store/get-renewal-pricing-text.d.ts.map +1 -0
- package/dist/types/hooks/data-store/types.d.ts +21 -0
- package/dist/types/hooks/data-store/types.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-grid-plan-for-spotlight.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-grid-plans-for-comparison-grid.d.ts +1 -1
- package/dist/types/hooks/data-store/use-grid-plans-for-comparison-grid.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-grid-plans-for-features-grid.d.ts +1 -1
- package/dist/types/hooks/data-store/use-grid-plans-for-features-grid.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-grid-plans.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-highlight-labels.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-plan-billing-description.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-plan-billing-period.d.ts +8 -0
- package/dist/types/hooks/data-store/use-plan-billing-period.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-plan-features-for-grid-plans.d.ts +4 -1
- package/dist/types/hooks/data-store/use-plan-features-for-grid-plans.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-plans-from-types.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-restructured-plan-features-for-comparison-grid.d.ts +4 -1
- package/dist/types/hooks/data-store/use-restructured-plan-features-for-comparison-grid.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-title-badges.d.ts +9 -0
- package/dist/types/hooks/data-store/use-title-badges.d.ts.map +1 -0
- package/dist/types/hooks/use-grid-size.d.ts +3 -2
- package/dist/types/hooks/use-grid-size.d.ts.map +1 -1
- package/dist/types/hooks/use-highlight-adjacency-matrix.d.ts.map +1 -1
- package/dist/types/hooks/use-visible-grid-plans.d.ts +14 -0
- package/dist/types/hooks/use-visible-grid-plans.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/filter-unused-features-object.d.ts.map +1 -1
- package/dist/types/lib/get-plan-features-object.d.ts +1 -1
- package/dist/types/lib/get-plan-features-object.d.ts.map +1 -1
- package/dist/types/lib/plan-pricing-utils.d.ts +105 -0
- package/dist/types/lib/plan-pricing-utils.d.ts.map +1 -0
- package/dist/types/types.d.ts +33 -6
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +39 -28
- package/src/_shared.scss +4 -3
- package/src/components/comparison-grid/index.stories.tsx +1 -1
- package/src/components/comparison-grid/index.tsx +263 -158
- package/src/components/comparison-grid/style.scss +10 -2
- package/src/components/features-grid/client-logo-list/client-list.tsx +0 -25
- package/src/components/features-grid/index.tsx +37 -19
- package/src/components/features-grid/plan-features-list.tsx +15 -4
- package/src/components/features-grid/plan-headers.tsx +10 -3
- package/src/components/features-grid/plan-tagline.tsx +1 -1
- package/src/components/features-grid/style.scss +111 -21
- package/src/components/features-grid/table.tsx +4 -2
- package/src/components/features.tsx +66 -6
- package/src/components/item.tsx +6 -3
- package/src/components/plan-button/index.tsx +7 -1
- package/src/components/plan-button/style.scss +71 -47
- package/src/components/plan-div-td-container.tsx +6 -2
- package/src/components/plan-logo.tsx +16 -9
- package/src/components/plan-type-selector/components/interval-type-dropdown.tsx +14 -1
- package/src/components/plan-type-selector/hooks/use-max-discount.ts +8 -47
- package/src/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.ts +19 -17
- package/src/components/plans-2023-tooltip.tsx +17 -5
- package/src/components/shared/action-button/index.tsx +46 -5
- package/src/components/shared/action-button/style.scss +4 -0
- package/src/components/shared/billing-timeframe/index.tsx +12 -7
- package/src/components/shared/header-price/index.tsx +129 -27
- package/src/components/shared/header-price/style.scss +10 -2
- package/src/components/shared/storage/components/plan-storage.tsx +2 -2
- package/src/components/shared/storage/components/storage-dropdown.tsx +36 -15
- package/src/components/shared/storage/components/storage-feature-label.tsx +2 -1
- package/src/components/shared/storage/hooks/use-plan-storage.ts +3 -0
- package/src/components/test/actions-button.tsx +5 -0
- package/src/components/test/billing-timeframe.tsx +1 -1
- package/src/components/test/header-price.tsx +342 -4
- package/src/fixtures/sites-purchases.ts +2 -4
- package/src/grid-context.tsx +9 -0
- package/src/hooks/data-store/get-renewal-pricing-text.ts +73 -0
- package/src/hooks/data-store/types.ts +21 -0
- package/src/hooks/data-store/use-grid-plans-for-comparison-grid.ts +10 -0
- package/src/hooks/data-store/use-grid-plans-for-features-grid.ts +10 -0
- package/src/hooks/data-store/use-grid-plans.tsx +189 -23
- package/src/hooks/data-store/use-highlight-labels.ts +12 -3
- package/src/hooks/data-store/use-plan-billing-description.tsx +80 -15
- package/src/hooks/data-store/use-plan-billing-period.tsx +28 -0
- package/src/hooks/data-store/use-plan-features-for-grid-plans.ts +135 -1
- package/src/hooks/data-store/use-restructured-plan-features-for-comparison-grid.ts +93 -20
- package/src/hooks/data-store/use-title-badges.ts +31 -0
- package/src/hooks/test/use-visible-grid-plans.tsx +116 -0
- package/src/hooks/use-grid-size.ts +3 -2
- package/src/hooks/use-is-large-currency.ts +1 -1
- package/src/hooks/use-visible-grid-plans.tsx +102 -0
- package/src/index.tsx +20 -0
- package/src/lib/get-plan-features-object.ts +23 -2
- package/src/lib/plan-pricing-utils.ts +211 -0
- package/src/lib/test/plan-pricing-utils.ts +594 -0
- package/src/style-imports.d.ts +3 -0
- package/src/types.ts +45 -4
- package/dist/cjs/components/features-grid/mobile-free-domain.js +0 -25
- package/dist/cjs/components/features-grid/mobile-free-domain.js.map +0 -1
- package/dist/cjs/lib/get-plan-pricing-info-from-grid-plans.js +0 -15
- package/dist/cjs/lib/get-plan-pricing-info-from-grid-plans.js.map +0 -1
- package/dist/cjs/lib/sort-plan-properties.js +0 -26
- package/dist/cjs/lib/sort-plan-properties.js.map +0 -1
- package/dist/esm/components/features-grid/mobile-free-domain.js +0 -23
- package/dist/esm/components/features-grid/mobile-free-domain.js.map +0 -1
- package/dist/esm/lib/get-plan-pricing-info-from-grid-plans.js +0 -12
- package/dist/esm/lib/get-plan-pricing-info-from-grid-plans.js.map +0 -1
- package/dist/esm/lib/sort-plan-properties.js +0 -23
- package/dist/esm/lib/sort-plan-properties.js.map +0 -1
- package/dist/types/components/features-grid/mobile-free-domain.d.ts +0 -8
- package/dist/types/components/features-grid/mobile-free-domain.d.ts.map +0 -1
- package/dist/types/lib/get-plan-pricing-info-from-grid-plans.d.ts +0 -9
- package/dist/types/lib/get-plan-pricing-info-from-grid-plans.d.ts.map +0 -1
- package/dist/types/lib/sort-plan-properties.d.ts +0 -3
- package/dist/types/lib/sort-plan-properties.d.ts.map +0 -1
- package/src/components/features-grid/mobile-free-domain.tsx +0 -51
- package/src/lib/get-plan-pricing-info-from-grid-plans.ts +0 -31
- package/src/lib/sort-plan-properties.ts +0 -27
- package/src/lib/test/sort-plan-properties.ts +0 -122
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EFFECTIVE_TERMS_LIST = exports.useRestructuredPlanFeaturesForComparisonGrid = exports.usePlanTypesWithIntent = exports.usePlansFromTypes = exports.usePlanFeaturesForGridPlans = exports.usePlanBillingDescription = exports.useGridPlanForSpotlight = exports.useGridPlansForComparisonGrid = exports.useGridPlansForFeaturesGrid = exports.useGridPlans = exports.useManageTooltipToggle = exports.Plans2023Tooltip = exports.PlanButton = exports.PlanTypeSelector = exports.FeaturesGrid = exports.ComparisonGrid = void 0;
|
|
3
|
+
exports.fromVariantPriceData = exports.fromPricingMetaForGridPlan = exports.calculateDiscountPercentage = exports.getPlanPriceForDuration = exports.EFFECTIVE_TERMS_LIST = exports.useRestructuredPlanFeaturesForComparisonGrid = exports.usePlanTypesWithIntent = exports.usePlansFromTypes = exports.usePlanFeaturesForGridPlans = exports.usePlanBillingDescription = exports.usePlanBillingPeriod = exports.useGridPlanForSpotlight = exports.useGridPlansForComparisonGrid = exports.useGridPlansForFeaturesGrid = exports.useGridPlans = exports.useManageTooltipToggle = exports.Plans2023Tooltip = exports.PlanButton = exports.PlanTypeSelector = exports.FeaturesGrid = exports.ComparisonGrid = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const comparison_grid_1 = tslib_1.__importDefault(require("./components/comparison-grid"));
|
|
6
6
|
exports.ComparisonGrid = comparison_grid_1.default;
|
|
@@ -25,6 +25,8 @@ const use_grid_plans_for_features_grid_1 = tslib_1.__importDefault(require("./ho
|
|
|
25
25
|
exports.useGridPlansForFeaturesGrid = use_grid_plans_for_features_grid_1.default;
|
|
26
26
|
const use_plan_billing_description_1 = tslib_1.__importDefault(require("./hooks/data-store/use-plan-billing-description"));
|
|
27
27
|
exports.usePlanBillingDescription = use_plan_billing_description_1.default;
|
|
28
|
+
const use_plan_billing_period_1 = tslib_1.__importDefault(require("./hooks/data-store/use-plan-billing-period"));
|
|
29
|
+
exports.usePlanBillingPeriod = use_plan_billing_period_1.default;
|
|
28
30
|
const use_plan_features_for_grid_plans_1 = tslib_1.__importDefault(require("./hooks/data-store/use-plan-features-for-grid-plans"));
|
|
29
31
|
exports.usePlanFeaturesForGridPlans = use_plan_features_for_grid_plans_1.default;
|
|
30
32
|
const use_plans_from_types_1 = tslib_1.__importDefault(require("./hooks/data-store/use-plans-from-types"));
|
|
@@ -33,4 +35,9 @@ const use_restructured_plan_features_for_comparison_grid_1 = tslib_1.__importDef
|
|
|
33
35
|
exports.useRestructuredPlanFeaturesForComparisonGrid = use_restructured_plan_features_for_comparison_grid_1.default;
|
|
34
36
|
const use_manage_tooltip_toggle_1 = require("./hooks/use-manage-tooltip-toggle");
|
|
35
37
|
Object.defineProperty(exports, "useManageTooltipToggle", { enumerable: true, get: function () { return use_manage_tooltip_toggle_1.useManageTooltipToggle; } });
|
|
38
|
+
const plan_pricing_utils_1 = require("./lib/plan-pricing-utils");
|
|
39
|
+
Object.defineProperty(exports, "getPlanPriceForDuration", { enumerable: true, get: function () { return plan_pricing_utils_1.getPlanPriceForDuration; } });
|
|
40
|
+
Object.defineProperty(exports, "calculateDiscountPercentage", { enumerable: true, get: function () { return plan_pricing_utils_1.calculateDiscountPercentage; } });
|
|
41
|
+
Object.defineProperty(exports, "fromPricingMetaForGridPlan", { enumerable: true, get: function () { return plan_pricing_utils_1.fromPricingMetaForGridPlan; } });
|
|
42
|
+
Object.defineProperty(exports, "fromVariantPriceData", { enumerable: true, get: function () { return plan_pricing_utils_1.fromVariantPriceData; } });
|
|
36
43
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";;;;AAAA,2FAA0D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";;;;AAAA,2FAA0D;AAgCjD,yBAhCF,yBAAc,CAgCE;AA/BvB,uFAAsD;AA+B7B,uBA/BlB,uBAAY,CA+BkB;AA9BrC,mFAAkD;AA8BO,qBA9BlD,qBAAU,CA8BkD;AA7BnE,iGAA+D;AA6BxB,2BA7BhC,4BAAgB,CA6BgC;AA5BvD,wEAAmE;AA4BE,iGA5B5D,qCAAgB,OA4B4D;AA3BrF,2CAAmD;AAiD1C,qGAjDA,gCAAoB,OAiDA;AAhD7B,yHAAqF;AAoCpF,kCApCM,qCAAuB,CAoCN;AAnCxB,4FAAyF;AAgCxF,uBAhCM,wBAAY,CAgCN;AAQZ,uGAxCsB,uCAAsB,OAwCtB;AAvCvB,uIAAkG;AAiCjG,wCAjCM,4CAA6B,CAiCN;AAhC9B,mIAA8F;AA+B7F,sCA/BM,0CAA2B,CA+BN;AA9B5B,2HAAwF;AAkCvF,oCAlCM,sCAAyB,CAkCN;AAjC1B,iHAA8E;AAgC7E,+BAhCM,iCAAoB,CAgCN;AA/BrB,mIAA8F;AAiC7F,sCAjCM,0CAA2B,CAiCN;AAhC5B,2GAAwE;AAiCvE,4BAjCM,8BAAiB,CAiCN;AAhClB,uKAAiI;AAkChI,uDAlCM,4DAA4C,CAkCN;AAjC7C,iFAA2E;AAuB1E,uGAvBQ,kDAAsB,OAuBR;AAtBvB,iEAKkC;AAwCjC,wGA5CA,4CAAuB,OA4CA;AACvB,4GA5CA,gDAA2B,OA4CA;AAC3B,2GA5CA,+CAA0B,OA4CA;AAC1B,qGA5CA,yCAAoB,OA4CA"}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// TODO: Temporary until feature definitions are ported to calypso-products package
|
|
4
|
-
const getPlanFeaturesObject = (featuresList, planFeatures) => {
|
|
4
|
+
const getPlanFeaturesObject = (featuresList, planFeatures, isExperimentVariant) => {
|
|
5
5
|
if (!planFeatures) {
|
|
6
6
|
return [];
|
|
7
7
|
}
|
|
8
|
-
return planFeatures.map((featuresConst) =>
|
|
8
|
+
return planFeatures.map((featuresConst) => {
|
|
9
|
+
const feature = featuresList[featuresConst];
|
|
10
|
+
if (!feature || !isExperimentVariant) {
|
|
11
|
+
return feature;
|
|
12
|
+
}
|
|
13
|
+
// Wrap feature methods to pass isExperimentVariant parameter
|
|
14
|
+
return {
|
|
15
|
+
...feature,
|
|
16
|
+
getTitle: (params) => feature.getTitle({ ...params, isExperimentVariant }),
|
|
17
|
+
...(feature.getDescription && {
|
|
18
|
+
getDescription: (params) => feature.getDescription({ ...params, isExperimentVariant }),
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
});
|
|
9
22
|
};
|
|
10
23
|
exports.default = getPlanFeaturesObject;
|
|
11
24
|
//# sourceMappingURL=get-plan-features-object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-plan-features-object.js","sourceRoot":"","sources":["../../../src/lib/get-plan-features-object.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"get-plan-features-object.js","sourceRoot":"","sources":["../../../src/lib/get-plan-features-object.ts"],"names":[],"mappings":";;AAIA,mFAAmF;AACnF,MAAM,qBAAqB,GAAG,CAC7B,YAAyB,EACzB,YAA8B,EAC9B,mBAA6B,EAC5B,EAAE;IACH,IAAK,CAAE,YAAY,EAAG,CAAC;QACtB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,YAAY,CAAC,GAAG,CAAE,CAAE,aAAa,EAAG,EAAE;QAC5C,MAAM,OAAO,GAAG,YAAY,CAAE,aAAa,CAAE,CAAC;QAC9C,IAAK,CAAE,OAAO,IAAI,CAAE,mBAAmB,EAAG,CAAC;YAC1C,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,6DAA6D;QAC7D,OAAO;YACN,GAAG,OAAO;YACV,QAAQ,EAAE,CAAE,MAA4B,EAAG,EAAE,CAC5C,OAAO,CAAC,QAAQ,CAAE,EAAE,GAAG,MAAM,EAAE,mBAAmB,EAAE,CAAE;YACvD,GAAG,CAAE,OAAO,CAAC,cAAc,IAAI;gBAC9B,cAAc,EAAE,CAAE,MAA4B,EAAG,EAAE,CAClD,OAAO,CAAC,cAAe,CAAE,EAAE,GAAG,MAAM,EAAE,mBAAmB,EAAE,CAAE;aAC9D,CAAE;SACH,CAAC;IACH,CAAC,CAAE,CAAC;AACL,CAAC,CAAC;AAEF,kBAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPlanPriceForDuration = getPlanPriceForDuration;
|
|
4
|
+
exports.calculateDiscountPercentage = calculateDiscountPercentage;
|
|
5
|
+
exports.fromPricingMetaForGridPlan = fromPricingMetaForGridPlan;
|
|
6
|
+
exports.fromVariantPriceData = fromVariantPriceData;
|
|
7
|
+
// billingPeriod values are in days (from PERIOD_LIST in calypso-products)
|
|
8
|
+
const BILLING_PERIOD_DAYS_TO_MONTHS = {
|
|
9
|
+
31: 1,
|
|
10
|
+
365: 12,
|
|
11
|
+
730: 24,
|
|
12
|
+
1095: 36,
|
|
13
|
+
};
|
|
14
|
+
function billingPeriodDaysToMonths(billingPeriod) {
|
|
15
|
+
if (billingPeriod === undefined || billingPeriod === null) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return BILLING_PERIOD_DAYS_TO_MONTHS[billingPeriod] ?? null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Calculates the total cost of a plan over `durationMonths` months.
|
|
22
|
+
*
|
|
23
|
+
* Handles partial billing periods via pro-ration (e.g. a yearly plan priced at
|
|
24
|
+
* $200/year costs $100 for 6 months).
|
|
25
|
+
*
|
|
26
|
+
* When `useIntroOffer` is true (default) and an active intro offer exists, the
|
|
27
|
+
* intro price is applied for the first `introOffer.durationMonths` months, and
|
|
28
|
+
* the regular (or discounted) price for the remainder.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Monthly plan: $10 intro for 1 month, then $20/month; cost for 6 months:
|
|
32
|
+
* // 1×$10 + 5×$20 = $110 (in cents: 1100 + 10000 = 11000)
|
|
33
|
+
* getPlanPriceForDuration( info, 6, { useIntroOffer: true } ) // 11000
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Yearly plan: $100/yr intro, $200/yr regular; cost for 6 months:
|
|
37
|
+
* // useIntroOffer=true → 6×($100/12) = $50 (5000 cents)
|
|
38
|
+
* // useIntroOffer=false → 6×($200/12) = $100 (10000 cents)
|
|
39
|
+
*/
|
|
40
|
+
function getPlanPriceForDuration(info, durationMonths, { useIntroOffer = true } = {}) {
|
|
41
|
+
const basePricePerMonth = info.discountedPricePerMonth ?? info.regularPricePerMonth;
|
|
42
|
+
if (useIntroOffer && info.introOffer?.isActive) {
|
|
43
|
+
const introMonths = Math.min(durationMonths, info.introOffer.durationMonths);
|
|
44
|
+
const regularMonths = Math.max(0, durationMonths - info.introOffer.durationMonths);
|
|
45
|
+
return introMonths * info.introOffer.pricePerMonth + regularMonths * basePricePerMonth;
|
|
46
|
+
}
|
|
47
|
+
return durationMonths * basePricePerMonth;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Calculates the percentage discount between a reference price and a cheaper price.
|
|
51
|
+
*
|
|
52
|
+
* Always uses Math.floor — conservative, never overstates savings.
|
|
53
|
+
*
|
|
54
|
+
* Returns `undefined` (not 0) when there is no saving, allowing callers to
|
|
55
|
+
* distinguish "no discount" from a computed "0% discount".
|
|
56
|
+
*/
|
|
57
|
+
function calculateDiscountPercentage(referencePrice, cheaperPrice) {
|
|
58
|
+
if (cheaperPrice >= referencePrice || referencePrice <= 0) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
return Math.floor((100 * (referencePrice - cheaperPrice)) / referencePrice);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Converts a `PricingMetaForGridPlan` (from @automattic/data-stores Plans hooks)
|
|
65
|
+
* into a `PlanPriceInfo` suitable for use with `getPlanPriceForDuration` and
|
|
66
|
+
* `calculateDiscountPercentage`.
|
|
67
|
+
*
|
|
68
|
+
* Returns null when required pricing data is absent (e.g. free/enterprise plans
|
|
69
|
+
* that have no monthly price, or plans whose billing period is unknown).
|
|
70
|
+
*/
|
|
71
|
+
function fromPricingMetaForGridPlan(meta) {
|
|
72
|
+
const termMonths = billingPeriodDaysToMonths(meta.billingPeriod);
|
|
73
|
+
if (termMonths === null || meta.originalPrice.monthly === null) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const isIntroActive = !!meta.introOffer && !meta.introOffer.isOfferComplete;
|
|
77
|
+
return {
|
|
78
|
+
termMonths,
|
|
79
|
+
regularPricePerMonth: meta.originalPrice.monthly,
|
|
80
|
+
// The API sometimes sets discountedPrice.monthly to the intro offer price rather than
|
|
81
|
+
// a genuine site-level discount (e.g. currency conversion, proration credit). When an
|
|
82
|
+
// intro offer is active the intro structure already captures the discounted period, so
|
|
83
|
+
// using discountedPrice here would contaminate the post-intro "regular" rate used by
|
|
84
|
+
// getPlanPriceForDuration — producing incorrect totals for the non-intro months.
|
|
85
|
+
discountedPricePerMonth: isIntroActive ? undefined : meta.discountedPrice.monthly ?? undefined,
|
|
86
|
+
introOffer: meta.introOffer
|
|
87
|
+
? {
|
|
88
|
+
pricePerMonth: meta.introOffer.rawPrice.monthly,
|
|
89
|
+
durationMonths: meta.introOffer.intervalCount * (meta.introOffer.intervalUnit === 'year' ? 12 : 1),
|
|
90
|
+
isActive: isIntroActive,
|
|
91
|
+
}
|
|
92
|
+
: undefined,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Converts a variant price data object (structurally compatible with
|
|
97
|
+
* `WPCOMProductVariant`) into a `PlanPriceInfo`.
|
|
98
|
+
*
|
|
99
|
+
* `discountedPricePerMonth` is intentionally not set: `WPCOMProductVariant`
|
|
100
|
+
* does not separate site-level discounts from the intro price. Coupon discounts
|
|
101
|
+
* in checkout are tracked separately via `product.coupon_savings_integer`.
|
|
102
|
+
*
|
|
103
|
+
* Per-month values are derived by dividing full-term prices (integers in the
|
|
104
|
+
* smallest currency unit) by the number of months. The result is rounded to the
|
|
105
|
+
* nearest integer (Math.round) so that all fields in the returned `PlanPriceInfo`
|
|
106
|
+
* remain whole-cent values safe for use with currency formatters. The rounding
|
|
107
|
+
* error is at most 0.5¢ per month and is negligible for percentage comparisons.
|
|
108
|
+
*/
|
|
109
|
+
function fromVariantPriceData(variant) {
|
|
110
|
+
const { termIntervalInMonths: termMonths, priceBeforeDiscounts, priceInteger, introductoryInterval, introductoryTerm, } = variant;
|
|
111
|
+
const regularPricePerMonth = Math.round(priceBeforeDiscounts / termMonths);
|
|
112
|
+
const introDurationMonths = introductoryInterval > 0 ? introductoryInterval * (introductoryTerm === 'year' ? 12 : 1) : 0;
|
|
113
|
+
let introOffer;
|
|
114
|
+
if (introDurationMonths > 0 && priceInteger < priceBeforeDiscounts) {
|
|
115
|
+
// When the intro spans the full term (introDurationMonths >= termMonths), all of
|
|
116
|
+
// priceInteger is at the intro rate and there are zero non-intro months.
|
|
117
|
+
// When the intro is shorter than the term (introDurationMonths < termMonths), we
|
|
118
|
+
// subtract the non-intro portion (billed at the regular rate) to isolate the intro cost.
|
|
119
|
+
const nonIntroMonths = Math.max(0, termMonths - introDurationMonths);
|
|
120
|
+
const introPriceTotal = priceInteger - nonIntroMonths * regularPricePerMonth;
|
|
121
|
+
// A non-positive introPriceTotal means inconsistent data (e.g. a sub-term intro
|
|
122
|
+
// with a priceInteger that is less than the non-intro months at the regular rate).
|
|
123
|
+
if (introPriceTotal > 0) {
|
|
124
|
+
// When introDurationMonths > termMonths the whole billing term is within the
|
|
125
|
+
// intro period, so we spread introPriceTotal over termMonths (not introDurationMonths).
|
|
126
|
+
introOffer = {
|
|
127
|
+
pricePerMonth: Math.round(introPriceTotal / Math.min(introDurationMonths, termMonths)),
|
|
128
|
+
durationMonths: introDurationMonths,
|
|
129
|
+
isActive: true,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { termMonths, regularPricePerMonth, introOffer };
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=plan-pricing-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-pricing-utils.js","sourceRoot":"","sources":["../../../src/lib/plan-pricing-utils.ts"],"names":[],"mappings":";;AA6DA,0DAcC;AAUD,kEAQC;AAUD,gEA4BC;AAyCD,oDAsCC;AAxLD,0EAA0E;AAC1E,MAAM,6BAA6B,GAA6B;IAC/D,EAAE,EAAE,CAAC;IACL,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,EAAE;CACR,CAAC;AAEF,SAAS,yBAAyB,CAAE,aAAiC;IACpE,IAAK,aAAa,KAAK,SAAS,IAAI,aAAa,KAAK,IAAI,EAAG,CAAC;QAC7D,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,6BAA6B,CAAE,aAAa,CAAE,IAAI,IAAI,CAAC;AAC/D,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,uBAAuB,CACtC,IAAmB,EACnB,cAAsB,EACtB,EAAE,aAAa,GAAG,IAAI,KAAkC,EAAE;IAE1D,MAAM,iBAAiB,GAAG,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,oBAAoB,CAAC;IAEpF,IAAK,aAAa,IAAI,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAG,CAAC;QAClD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAE,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,CAAE,CAAC;QAC/E,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAE,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,CAAE,CAAC;QACrF,OAAO,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,GAAG,aAAa,GAAG,iBAAiB,CAAC;IACxF,CAAC;IAED,OAAO,cAAc,GAAG,iBAAiB,CAAC;AAC3C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,2BAA2B,CAC1C,cAAsB,EACtB,YAAoB;IAEpB,IAAK,YAAY,IAAI,cAAc,IAAI,cAAc,IAAI,CAAC,EAAG,CAAC;QAC7D,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAE,CAAE,GAAG,GAAG,CAAE,cAAc,GAAG,YAAY,CAAE,CAAE,GAAG,cAAc,CAAE,CAAC;AACnF,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CACzC,IAAkC;IAElC,MAAM,UAAU,GAAG,yBAAyB,CAAE,IAAI,CAAC,aAAa,CAAE,CAAC;IACnE,IAAK,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,KAAK,IAAI,EAAG,CAAC;QAClE,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,aAAa,GAAG,CAAC,CAAE,IAAI,CAAC,UAAU,IAAI,CAAE,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC;IAE9E,OAAO;QACN,UAAU;QACV,oBAAoB,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO;QAChD,sFAAsF;QACtF,sFAAsF;QACtF,uFAAuF;QACvF,qFAAqF;QACrF,iFAAiF;QACjF,uBAAuB,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,IAAI,SAAS;QAC9F,UAAU,EAAE,IAAI,CAAC,UAAU;YAC1B,CAAC,CAAC;gBACA,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO;gBAC/C,cAAc,EACb,IAAI,CAAC,UAAU,CAAC,aAAa,GAAG,CAAE,IAAI,CAAC,UAAU,CAAC,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE;gBACrF,QAAQ,EAAE,aAAa;aACtB;YACH,CAAC,CAAC,SAAS;KACZ,CAAC;AACH,CAAC;AA2BD;;;;;;;;;;;;;GAaG;AACH,SAAgB,oBAAoB,CAAE,OAAyB;IAC9D,MAAM,EACL,oBAAoB,EAAE,UAAU,EAChC,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,GAChB,GAAG,OAAO,CAAC;IAEZ,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAE,oBAAoB,GAAG,UAAU,CAAE,CAAC;IAE7E,MAAM,mBAAmB,GACxB,oBAAoB,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAoB,GAAG,CAAE,gBAAgB,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhG,IAAI,UAAqD,CAAC;IAE1D,IAAK,mBAAmB,GAAG,CAAC,IAAI,YAAY,GAAG,oBAAoB,EAAG,CAAC;QACtE,iFAAiF;QACjF,yEAAyE;QACzE,iFAAiF;QACjF,yFAAyF;QACzF,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAE,CAAC,EAAE,UAAU,GAAG,mBAAmB,CAAE,CAAC;QACvE,MAAM,eAAe,GAAG,YAAY,GAAG,cAAc,GAAG,oBAAoB,CAAC;QAE7E,gFAAgF;QAChF,mFAAmF;QACnF,IAAK,eAAe,GAAG,CAAC,EAAG,CAAC;YAC3B,6EAA6E;YAC7E,wFAAwF;YACxF,UAAU,GAAG;gBACZ,aAAa,EAAE,IAAI,CAAC,KAAK,CAAE,eAAe,GAAG,IAAI,CAAC,GAAG,CAAE,mBAAmB,EAAE,UAAU,CAAE,CAAE;gBAC1F,cAAc,EAAE,mBAAmB;gBACnC,QAAQ,EAAE,IAAI;aACd,CAAC;QACH,CAAC;IACF,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,UAAU,EAAE,CAAC;AACzD,CAAC"}
|
package/dist/esm/_shared.scss
CHANGED
|
@@ -47,10 +47,11 @@ $mobile-card-max-width: 440px;
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
.plans-grid-next-storage-dropdown__option {
|
|
50
|
-
display:
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
flex-wrap: wrap;
|
|
51
53
|
line-height: 20px;
|
|
52
54
|
min-height: 30px;
|
|
53
|
-
padding-top: 5px;
|
|
54
55
|
font-size: 0.75rem;
|
|
55
56
|
text-align: start;
|
|
56
57
|
}
|
|
@@ -130,7 +131,7 @@ $storage-feature-label-y-padding: 4px;
|
|
|
130
131
|
font-size: 0.75rem;
|
|
131
132
|
|
|
132
133
|
/**************
|
|
133
|
-
|
|
134
|
+
* 1. General *
|
|
134
135
|
**************/
|
|
135
136
|
|
|
136
137
|
.components-custom-select-control__label {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { getPlanClass, FEATURE_GROUP_ESSENTIAL_FEATURES, FEATURE_GROUP_PAYMENT_TRANSACTION_FEES, getPlans, } from '@automattic/calypso-products';
|
|
2
|
+
import { getPlanClass, FEATURE_GROUP_ESSENTIAL_FEATURES, FEATURE_GROUP_PAYMENT_TRANSACTION_FEES, getPlans, FEATURE_AI_WRITER_DESIGNER, FEATURE_AI_WRITER_DESIGNER_LIMITED, FEATURE_REALTIME_BACKUPS_JP, } from '@automattic/calypso-products';
|
|
3
3
|
import { Gridicon, JetpackLogo } from '@automattic/components';
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
import styled from '@emotion/styled';
|
|
@@ -14,9 +14,9 @@ import PlansGridContextProvider, { usePlansGridContext } from '../../grid-contex
|
|
|
14
14
|
import useGridSize from '../../hooks/use-grid-size';
|
|
15
15
|
import useHighlightAdjacencyMatrix from '../../hooks/use-highlight-adjacency-matrix';
|
|
16
16
|
import { useManageTooltipToggle } from '../../hooks/use-manage-tooltip-toggle';
|
|
17
|
+
import { useVisibleGridPlans } from '../../hooks/use-visible-grid-plans';
|
|
17
18
|
import filterUnusedFeaturesObject from '../../lib/filter-unused-features-object';
|
|
18
19
|
import getPlanFeaturesObject from '../../lib/get-plan-features-object';
|
|
19
|
-
import { sortPlans } from '../../lib/sort-plan-properties';
|
|
20
20
|
import PlanTypeSelector from '../plan-type-selector';
|
|
21
21
|
import { Plans2023Tooltip } from '../plans-2023-tooltip';
|
|
22
22
|
import PopularBadge from '../popular-badge';
|
|
@@ -27,14 +27,29 @@ import HeaderPriceContextProvider from '../shared/header-price/header-price-cont
|
|
|
27
27
|
import { PlanStorage } from '../shared/storage';
|
|
28
28
|
import { StickyContainer } from '../sticky-container';
|
|
29
29
|
import './style.scss';
|
|
30
|
+
// Plans Differentiators Experiment: treat feature variants (e.g., _LIMITED) as the same row
|
|
31
|
+
const FEATURE_ALIASES = {
|
|
32
|
+
[FEATURE_AI_WRITER_DESIGNER]: [FEATURE_AI_WRITER_DESIGNER_LIMITED],
|
|
33
|
+
};
|
|
34
|
+
// Finds a matching feature, checking both the base slug and any aliases
|
|
35
|
+
const findFeatureWithAlias = (featureSlug, planFeatures) => {
|
|
36
|
+
if (!featureSlug) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const slugsToCheck = [featureSlug, ...(FEATURE_ALIASES[featureSlug] ?? [])];
|
|
40
|
+
return planFeatures.find((f) => slugsToCheck.includes(f.getSlug()));
|
|
41
|
+
};
|
|
30
42
|
const featureGroupRowTitleCellMaxWidth = 450;
|
|
31
43
|
const rowCellMaxWidth = 290;
|
|
32
44
|
const JetpackIconContainer = styled.div `
|
|
33
|
-
padding-inline-start:
|
|
45
|
+
padding-inline-start: 3px;
|
|
34
46
|
display: inline-block;
|
|
35
47
|
vertical-align: middle;
|
|
36
48
|
line-height: 1;
|
|
37
49
|
`;
|
|
50
|
+
const TitlePreventOrphans = styled.span `
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
`;
|
|
38
53
|
const Title = styled.div `
|
|
39
54
|
font-weight: 500;
|
|
40
55
|
font-size: 20px;
|
|
@@ -63,11 +78,10 @@ const Title = styled.div `
|
|
|
63
78
|
}
|
|
64
79
|
`)}
|
|
65
80
|
`;
|
|
66
|
-
const
|
|
81
|
+
const StickyGrid = styled(StickyContainer) `
|
|
67
82
|
display: grid;
|
|
68
83
|
margin: 0 auto;
|
|
69
84
|
background: #fff;
|
|
70
|
-
border: solid 1px #e0e0e0;
|
|
71
85
|
${(props) => props.visiblePlans &&
|
|
72
86
|
css `
|
|
73
87
|
max-width: ${rowCellMaxWidth * props.visiblePlans + featureGroupRowTitleCellMaxWidth}px;
|
|
@@ -76,11 +90,19 @@ const Grid = styled.div `
|
|
|
76
90
|
${plansGridMediumLarge(css `
|
|
77
91
|
border-radius: 5px;
|
|
78
92
|
`)}
|
|
93
|
+
`;
|
|
94
|
+
const Grid = styled.div `
|
|
95
|
+
display: ${(props) => (props.as === 'tbody' ? 'table-row-group' : 'grid')};
|
|
96
|
+
margin: 0 auto;
|
|
97
|
+
background: #fff;
|
|
98
|
+
${(props) => props.visiblePlans &&
|
|
99
|
+
css `
|
|
100
|
+
max-width: ${rowCellMaxWidth * props.visiblePlans + featureGroupRowTitleCellMaxWidth}px;
|
|
101
|
+
`}
|
|
79
102
|
|
|
80
|
-
|
|
81
|
-
border-
|
|
82
|
-
|
|
83
|
-
}
|
|
103
|
+
${plansGridMediumLarge(css `
|
|
104
|
+
border-radius: 5px;
|
|
105
|
+
`)}
|
|
84
106
|
`;
|
|
85
107
|
const Row = styled.div `
|
|
86
108
|
justify-content: space-between;
|
|
@@ -175,7 +197,7 @@ const Cell = styled.div `
|
|
|
175
197
|
border-right: none;
|
|
176
198
|
justify-content: center;
|
|
177
199
|
|
|
178
|
-
&:first-of-type {
|
|
200
|
+
&:first-of-type:not( .popular-plan-parent-class ) {
|
|
179
201
|
padding-inline-start: 0;
|
|
180
202
|
}
|
|
181
203
|
&:last-of-type {
|
|
@@ -188,7 +210,23 @@ const Cell = styled.div `
|
|
|
188
210
|
}
|
|
189
211
|
`)}
|
|
190
212
|
`;
|
|
191
|
-
const RowTitleCell = styled.
|
|
213
|
+
const RowTitleCell = styled.td `
|
|
214
|
+
display: none;
|
|
215
|
+
font-size: 14px;
|
|
216
|
+
padding-right: 10px;
|
|
217
|
+
${plansGridMediumLarge(css `
|
|
218
|
+
display: block;
|
|
219
|
+
flex: 1;
|
|
220
|
+
min-width: 290px;
|
|
221
|
+
`)}
|
|
222
|
+
max-width: ${(props) => {
|
|
223
|
+
if (props.isPlaceholderHeaderCell || props.isFeatureGroupRowTitleCell) {
|
|
224
|
+
return `${featureGroupRowTitleCellMaxWidth}px`;
|
|
225
|
+
}
|
|
226
|
+
return `${rowCellMaxWidth}px`;
|
|
227
|
+
}};
|
|
228
|
+
`;
|
|
229
|
+
const RowHeaderCell = styled.th `
|
|
192
230
|
display: none;
|
|
193
231
|
font-size: 14px;
|
|
194
232
|
padding-right: 10px;
|
|
@@ -271,7 +309,7 @@ const FeatureFootnote = styled.span `
|
|
|
271
309
|
}
|
|
272
310
|
`;
|
|
273
311
|
const ComparisonGridHeaderCell = ({ planSlug, allVisible, isLastInRow, isFooter, isInSignup, visibleGridPlans, onPlanChange, displayedGridPlans, currentSitePlanSlug, planActionOverrides, showRefundPeriod, isStuck, }) => {
|
|
274
|
-
const { gridPlansIndex } = usePlansGridContext();
|
|
312
|
+
const { gridPlansIndex, showBillingDescriptionForIncreasedRenewalPrice } = usePlansGridContext();
|
|
275
313
|
const gridPlan = gridPlansIndex[planSlug];
|
|
276
314
|
const highlightAdjacencyMatrix = useHighlightAdjacencyMatrix({
|
|
277
315
|
renderedGridPlans: visibleGridPlans,
|
|
@@ -294,13 +332,13 @@ const ComparisonGridHeaderCell = ({ planSlug, allVisible, isLastInRow, isFooter,
|
|
|
294
332
|
'popular-badge-is-stuck': isStuck,
|
|
295
333
|
});
|
|
296
334
|
const showPlanSelect = !allVisible && !gridPlan.current;
|
|
297
|
-
return (_jsxs(Cell, { className: headerClasses, textAlign: "start", children: [_jsx(PopularBadge, { isInSignup: isInSignup, planSlug: planSlug, additionalClassName: popularBadgeClasses }), _jsxs(PlanSelector, { children: [_jsxs("h4", { className: clsx('plan-comparison-grid__title', showPlanSelect && 'is-select-trigger'), children: [_jsx("span", { className: "plan-comparison-grid__title-label", children: gridPlan.planTitle }), showPlanSelect && (_jsx("span", { className: "plan-comparison-grid__title-icon", children: _jsx(Icon, { icon: chevronRightSmall, size: 30 }) }))] }), showPlanSelect && (_jsx("select", { onChange: (event) => onPlanChange(planSlug, event), className: "plan-comparison-grid__title-select", value: planSlug, children: displayedGridPlans.map(({ planSlug: otherPlan, planTitle }) => {
|
|
335
|
+
return (_jsxs(Cell, { as: "th", className: headerClasses, textAlign: "start", scope: 'col', "aria-label": gridPlan.planTitle, children: [_jsx(PopularBadge, { isInSignup: isInSignup, planSlug: planSlug, additionalClassName: popularBadgeClasses }), _jsxs(PlanSelector, { children: [_jsxs("h4", { className: clsx('plan-comparison-grid__title', showPlanSelect && 'is-select-trigger'), children: [_jsx("span", { className: "plan-comparison-grid__title-label", children: gridPlan.planTitle }), showPlanSelect && (_jsx("span", { className: "plan-comparison-grid__title-icon", children: _jsx(Icon, { icon: chevronRightSmall, size: 30 }) }))] }), showPlanSelect && (_jsx("select", { onChange: (event) => onPlanChange(planSlug, event), className: "plan-comparison-grid__title-select", value: planSlug, children: displayedGridPlans.map(({ planSlug: otherPlan, planTitle }) => {
|
|
298
336
|
const isVisiblePlan = visibleGridPlans.find(({ planSlug }) => planSlug === otherPlan);
|
|
299
337
|
if (isVisiblePlan && otherPlan !== planSlug) {
|
|
300
338
|
return null;
|
|
301
339
|
}
|
|
302
340
|
return (_jsx("option", { value: otherPlan, children: planTitle }, otherPlan));
|
|
303
|
-
}) }))] }), _jsx(HeaderPrice, { planSlug: planSlug, currentSitePlanSlug: currentSitePlanSlug, visibleGridPlans: visibleGridPlans }), _jsx("div", { className: "plan-comparison-grid__billing-info", children: _jsx(BillingTimeframe, { planSlug: planSlug, showRefundPeriod: showRefundPeriod }) }), _jsx(ActionButton, { currentSitePlanSlug: currentSitePlanSlug, availableForPurchase: gridPlan.availableForPurchase, isInSignup: isInSignup, planSlug: planSlug, planActionOverrides: planActionOverrides, showMonthlyPrice: false, isStuck: false, visibleGridPlans: visibleGridPlans })] }));
|
|
341
|
+
}) }))] }), _jsx(HeaderPrice, { planSlug: planSlug, currentSitePlanSlug: currentSitePlanSlug, visibleGridPlans: visibleGridPlans }), _jsx("div", { className: "plan-comparison-grid__billing-info", children: _jsx(BillingTimeframe, { planSlug: planSlug, showRefundPeriod: showRefundPeriod }) }), _jsx(ActionButton, { currentSitePlanSlug: currentSitePlanSlug, availableForPurchase: gridPlan.availableForPurchase, isInSignup: isInSignup, planSlug: planSlug, planActionOverrides: planActionOverrides, showMonthlyPrice: false, isStuck: false, visibleGridPlans: visibleGridPlans, showPostButtonText: showBillingDescriptionForIncreasedRenewalPrice ? false : true })] }));
|
|
304
342
|
};
|
|
305
343
|
const PlanTypeSelectorWrapper = styled.div `
|
|
306
344
|
display: none;
|
|
@@ -312,8 +350,9 @@ const ComparisonGridHeader = forwardRef(({ displayedGridPlans, visibleGridPlans,
|
|
|
312
350
|
const translate = useTranslate();
|
|
313
351
|
const allVisible = visibleGridPlans.length === displayedGridPlans.length;
|
|
314
352
|
const { coupon } = usePlansGridContext();
|
|
315
|
-
return (_jsxs(PlanRow, { isHiddenInMobile: isHiddenInMobile, ref: ref, children: [_jsx(RowTitleCell, { className: "plan-comparison-grid__header-cell is-placeholder-header-cell", isPlaceholderHeaderCell: true, children: isStuck && planTypeSelectorProps && (_jsx(PlanTypeSelectorWrapper, { children: _jsx(PlanTypeSelector, { ...planTypeSelectorProps, title: translate('Billing Cycle'), hideDiscount: true, coupon: coupon }) })) }, "feature-name"), _jsx(HeaderPriceContextProvider, { children: visibleGridPlans.map(({ planSlug }, index) => (_jsx(ComparisonGridHeaderCell, { planSlug: planSlug, isLastInRow: index === visibleGridPlans.length - 1, isFooter: isFooter, allVisible: allVisible, isInSignup: isInSignup, visibleGridPlans: visibleGridPlans, onPlanChange: onPlanChange, displayedGridPlans: displayedGridPlans, currentSitePlanSlug: currentSitePlanSlug, planActionOverrides: planActionOverrides, selectedPlan: selectedPlan, showRefundPeriod: showRefundPeriod, isStuck: isStuck }, planSlug))) })] }));
|
|
353
|
+
return (_jsxs(PlanRow, { as: "tr", isHiddenInMobile: isHiddenInMobile, ref: ref, children: [_jsx(RowTitleCell, { className: "plan-comparison-grid__header-cell is-placeholder-header-cell", isPlaceholderHeaderCell: true, children: isStuck && planTypeSelectorProps && (_jsx(PlanTypeSelectorWrapper, { children: _jsx(PlanTypeSelector, { ...planTypeSelectorProps, title: translate('Billing Cycle'), hideDiscount: true, coupon: coupon }) })) }, "feature-name"), _jsx(HeaderPriceContextProvider, { children: visibleGridPlans.map(({ planSlug }, index) => (_jsx(ComparisonGridHeaderCell, { planSlug: planSlug, isLastInRow: index === visibleGridPlans.length - 1, isFooter: isFooter, allVisible: allVisible, isInSignup: isInSignup, visibleGridPlans: visibleGridPlans, onPlanChange: onPlanChange, displayedGridPlans: displayedGridPlans, currentSitePlanSlug: currentSitePlanSlug, planActionOverrides: planActionOverrides, selectedPlan: selectedPlan, showRefundPeriod: showRefundPeriod, isStuck: isStuck }, planSlug))) })] }));
|
|
316
354
|
});
|
|
355
|
+
ComparisonGridHeader.displayName = 'ComparisonGridHeader';
|
|
317
356
|
const ComparisonGridFeatureGroupRowCell = ({ feature, visibleGridPlans, planSlug, isStorageFeature, intervalType, activeTooltipId, setActiveTooltipId, showUpgradeableStorage, onStorageAddOnClick, }) => {
|
|
318
357
|
const { gridPlansIndex, enableFeatureTooltips, hideUnsupportedFeatures } = usePlansGridContext();
|
|
319
358
|
const gridPlan = gridPlansIndex[planSlug];
|
|
@@ -325,14 +364,18 @@ const ComparisonGridFeatureGroupRowCell = ({ feature, visibleGridPlans, planSlug
|
|
|
325
364
|
return null;
|
|
326
365
|
}
|
|
327
366
|
const featureSlug = feature?.getSlug();
|
|
328
|
-
const
|
|
329
|
-
(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
367
|
+
const comparisonGridTitle = featureSlug === FEATURE_REALTIME_BACKUPS_JP
|
|
368
|
+
? translate('Real-time backups', { textOnly: true })
|
|
369
|
+
: feature?.getAlternativeTitle?.() || feature?.getTitle();
|
|
370
|
+
const planFeatures = [
|
|
371
|
+
...gridPlan.features.wpcomFeatures,
|
|
372
|
+
...gridPlan.features.jetpackFeatures,
|
|
373
|
+
].filter((feature) => 'monthly' === intervalType ? !feature.availableOnlyForAnnualPlans : true);
|
|
374
|
+
const matchingFeature = findFeatureWithAlias(featureSlug, planFeatures);
|
|
375
|
+
const hasFeature = isStorageFeature || !!matchingFeature;
|
|
376
|
+
const featureLabelSlug = matchingFeature?.getSlug() ?? featureSlug;
|
|
377
|
+
const featureLabel = featureLabelSlug
|
|
378
|
+
? gridPlan?.features?.comparisonGridFeatureLabels?.[featureLabelSlug]
|
|
336
379
|
: undefined;
|
|
337
380
|
const cellClasses = clsx('plan-comparison-grid__feature-group-row-cell', 'plan-comparison-grid__plan', getPlanClass(planSlug), {
|
|
338
381
|
'popular-plan-parent-class': gridPlan.highlightLabel,
|
|
@@ -345,29 +388,34 @@ const ComparisonGridFeatureGroupRowCell = ({ feature, visibleGridPlans, planSlug
|
|
|
345
388
|
'is-only-highlight': highlightAdjacencyMatrix[planSlug]?.isOnlyHighlight,
|
|
346
389
|
});
|
|
347
390
|
const planPaymentTransactionFees = gridPlan.features.wpcomFeatures?.find((feature) => feature?.getFeatureGroup?.() === FEATURE_GROUP_PAYMENT_TRANSACTION_FEES);
|
|
348
|
-
return (_jsx(Cell, { className: cellClasses, textAlign: "center", children: isStorageFeature ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "plan-comparison-grid__plan-title", children: translate('Storage') }), _jsx(PlanStorage, { planSlug: planSlug, onStorageAddOnClick: onStorageAddOnClick, showUpgradeableStorage: showUpgradeableStorage })] })) : (_jsx(_Fragment, { children: FEATURE_GROUP_PAYMENT_TRANSACTION_FEES === featureSlug ? (_jsx(_Fragment, { children: planPaymentTransactionFees ? (_jsxs(_Fragment, { children: [_jsx(Plans2023Tooltip, { text: enableFeatureTooltips ? feature?.getDescription?.() : undefined, setActiveTooltipId: setActiveTooltipId, activeTooltipId: activeTooltipId, id: `${planSlug}-${featureSlug}`, children: _jsx("span", { className: "plan-comparison-grid__plan-title", children:
|
|
391
|
+
return (_jsx(Cell, { as: "td", className: cellClasses, textAlign: "center", children: isStorageFeature ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "plan-comparison-grid__plan-title", children: translate('Storage') }), _jsx(PlanStorage, { planSlug: planSlug, onStorageAddOnClick: onStorageAddOnClick, showUpgradeableStorage: showUpgradeableStorage })] })) : (_jsx(_Fragment, { children: FEATURE_GROUP_PAYMENT_TRANSACTION_FEES === featureSlug ? (_jsx(_Fragment, { children: planPaymentTransactionFees ? (_jsxs(_Fragment, { children: [_jsx(Plans2023Tooltip, { text: enableFeatureTooltips ? feature?.getDescription?.() : undefined, setActiveTooltipId: setActiveTooltipId, activeTooltipId: activeTooltipId, id: `${planSlug}-${featureSlug}`, children: _jsx("span", { className: "plan-comparison-grid__plan-title", children: comparisonGridTitle }) }), _jsx("span", { className: "plan-comparison-grid__plan-conditional-title", children: planPaymentTransactionFees?.getAlternativeTitle?.() })] })) : (_jsx(Gridicon, { icon: "minus-small", color: "#C3C4C7" })) })) : (_jsxs(_Fragment, { children: [feature?.getIcon && (_jsx("span", { className: "plan-comparison-grid__plan-image", children: feature.getIcon() })), _jsx(Plans2023Tooltip, { text: enableFeatureTooltips ? feature?.getDescription?.() : undefined, setActiveTooltipId: setActiveTooltipId, activeTooltipId: activeTooltipId, id: `${planSlug}-${featureSlug}`, children: _jsx("span", { className: "plan-comparison-grid__plan-title", children: comparisonGridTitle }) }), feature?.getCompareTitle && (_jsx("span", { className: "plan-comparison-grid__plan-subtitle", children: feature.getCompareTitle() })), featureLabel && (_jsx("span", { className: "plan-comparison-grid__plan-conditional-title", children: featureLabel })), hasFeature && feature?.getCompareSubtitle && (_jsx("span", { className: "plan-comparison-grid__plan-subtitle", children: feature.getCompareSubtitle() })), hasFeature && !featureLabel && (_jsx(Gridicon, { icon: "checkmark", color: "var(--studio-wordpress-blue-50)", "aria-label": translate('Feature available') })), !hasFeature && !featureLabel && (_jsx(Gridicon, { icon: "minus-small", color: "#C3C4C7", "aria-label": translate('Feature not available') }))] })) })) }));
|
|
349
392
|
};
|
|
350
|
-
const ComparisonGridFeatureGroupRow = ({ feature, isHiddenInMobile, allJetpackFeatures, visibleGridPlans, planFeatureFootnotes, isStorageFeature, isHighlighted, intervalType, activeTooltipId, setActiveTooltipId, showUpgradeableStorage, onStorageAddOnClick, }) => {
|
|
393
|
+
const ComparisonGridFeatureGroupRow = ({ feature, featureGroupSlug, isHiddenInMobile, allJetpackFeatures, visibleGridPlans, planFeatureFootnotes, isStorageFeature, isHighlighted, intervalType, activeTooltipId, setActiveTooltipId, showUpgradeableStorage, onStorageAddOnClick, }) => {
|
|
351
394
|
const translate = useTranslate();
|
|
352
395
|
const rowClasses = clsx('plan-comparison-grid__feature-group-row', {
|
|
353
396
|
'is-storage-feature': isStorageFeature,
|
|
354
397
|
});
|
|
355
398
|
const featureSlug = feature?.getSlug() ?? '';
|
|
356
399
|
const footnote = planFeatureFootnotes?.footnotesByFeature?.[featureSlug];
|
|
357
|
-
const tooltipId = `${feature?.getSlug()}-comparison-grid`;
|
|
400
|
+
const tooltipId = `${featureGroupSlug}-${feature?.getSlug()}-comparison-grid`;
|
|
401
|
+
const title = featureSlug === FEATURE_REALTIME_BACKUPS_JP
|
|
402
|
+
? // Always display the short title for backups in comparison grid.
|
|
403
|
+
translate('Real-time backups', { textOnly: true })
|
|
404
|
+
: feature?.getTitle?.();
|
|
405
|
+
const headerAriaLabel = typeof title === 'string' ? title : '';
|
|
358
406
|
const { enableFeatureTooltips } = usePlansGridContext();
|
|
359
|
-
return (_jsxs(Row, { isHiddenInMobile: isHiddenInMobile, className: rowClasses, isHighlighted: isHighlighted, children: [_jsx(
|
|
407
|
+
return (_jsxs(Row, { as: "tr", isHiddenInMobile: isHiddenInMobile, className: rowClasses, isHighlighted: isHighlighted, children: [_jsx(RowHeaderCell, { className: "is-feature-group-row-title-cell", isFeatureGroupRowTitleCell: true, scope: "row", "aria-label": headerAriaLabel, children: isStorageFeature ? (_jsx(Plans2023Tooltip, { text: enableFeatureTooltips
|
|
360
408
|
? translate('Space to store your photos, media, and more.')
|
|
361
|
-
: undefined, setActiveTooltipId: setActiveTooltipId, activeTooltipId: activeTooltipId, id: tooltipId, children: translate('Storage') })) : (_jsx(_Fragment, { children: feature && (
|
|
409
|
+
: undefined, setActiveTooltipId: setActiveTooltipId, activeTooltipId: activeTooltipId, id: tooltipId, children: translate('Storage') })) : (_jsx(_Fragment, { children: feature && (_jsx(_Fragment, { children: _jsx(Plans2023Tooltip, { text: enableFeatureTooltips ? feature.getDescription?.() : undefined, setActiveTooltipId: setActiveTooltipId, activeTooltipId: activeTooltipId, id: tooltipId, children: typeof title === 'string' ? (_jsxs(_Fragment, { children: [title.split(' ').slice(0, -1).join(' '), title.includes(' ') ? ' ' : null, _jsxs(TitlePreventOrphans, { children: [title.split(' ').slice(-1), footnote && (_jsx(FeatureFootnote, { children: _jsx("sup", { children: footnote }) })), allJetpackFeatures.has(feature.getSlug()) ? (_jsxs(_Fragment, { children: ['\u00A0', _jsx(JetpackIconContainer, { children: _jsx(Plans2023Tooltip, { text: translate('Security, performance, and growth tools—powered by Jetpack.'), setActiveTooltipId: setActiveTooltipId, activeTooltipId: activeTooltipId, id: `jp-${tooltipId}`, children: _jsx(JetpackLogo, { size: 16 }) }) })] })) : null] })] })) : (_jsxs(_Fragment, { children: [feature.getTitle(), footnote && (_jsx(FeatureFootnote, { children: _jsx("sup", { children: footnote }) }))] })) }) })) })) }, "feature-name"), visibleGridPlans.map(({ planSlug }) => (_jsx(ComparisonGridFeatureGroupRowCell, { feature: feature, allJetpackFeatures: allJetpackFeatures, visibleGridPlans: visibleGridPlans, planSlug: planSlug, isStorageFeature: isStorageFeature, intervalType: intervalType, activeTooltipId: activeTooltipId, setActiveTooltipId: setActiveTooltipId, showUpgradeableStorage: showUpgradeableStorage, onStorageAddOnClick: onStorageAddOnClick }, planSlug)))] }));
|
|
362
410
|
};
|
|
363
|
-
const FeatureGroup = ({ featureGroup, selectedFeature, intervalType, activeTooltipId, setActiveTooltipId, showUpgradeableStorage, onStorageAddOnClick, featureGroupMap, visibleGridPlans, planFeatureFootnotes, }) => {
|
|
364
|
-
const { allFeaturesList } = usePlansGridContext();
|
|
411
|
+
const FeatureGroup = ({ featureGroup, selectedFeature, intervalType, activeTooltipId, setActiveTooltipId, showUpgradeableStorage, onStorageAddOnClick, featureGroupMap, visibleGridPlans, planFeatureFootnotes, plansLength, }) => {
|
|
412
|
+
const { allFeaturesList, isExperimentVariant } = usePlansGridContext();
|
|
365
413
|
const [firstSetOfFeatures] = Object.keys(featureGroupMap);
|
|
366
414
|
const [visibleFeatureGroups, setVisibleFeatureGroups] = useState([
|
|
367
415
|
firstSetOfFeatures,
|
|
368
416
|
]);
|
|
369
417
|
const features = featureGroup.getFeatures();
|
|
370
|
-
const featureObjects = filterUnusedFeaturesObject(visibleGridPlans, getPlanFeaturesObject(allFeaturesList, features));
|
|
418
|
+
const featureObjects = filterUnusedFeaturesObject(visibleGridPlans, getPlanFeaturesObject(allFeaturesList, features, isExperimentVariant));
|
|
371
419
|
const isHiddenInMobile = !visibleFeatureGroups.includes(featureGroup.slug);
|
|
372
420
|
const allJetpackFeatures = useMemo(() => {
|
|
373
421
|
const allPlans = getPlans();
|
|
@@ -398,45 +446,20 @@ const FeatureGroup = ({ featureGroup, selectedFeature, intervalType, activeToolt
|
|
|
398
446
|
if (featureGroup.slug !== FEATURE_GROUP_ESSENTIAL_FEATURES && !featureObjects.length) {
|
|
399
447
|
return null;
|
|
400
448
|
}
|
|
401
|
-
return (_jsxs("
|
|
449
|
+
return (_jsxs(Grid, { as: "tbody", visiblePlans: plansLength, className: "plan-comparison-grid__feature-group", children: [_jsx(TitleRow, { as: "tr", className: "plan-comparison-grid__feature-group-title-row", onClick: handleFeatureGroupToggle, children: _jsxs(Title, { as: "td", isHiddenInMobile: isHiddenInMobile, children: [_jsx(Gridicon, { icon: "chevron-up", size: 12, color: "#1E1E1E" }), _jsx("span", { children: featureGroup.getTitle() })] }) }), featureObjects.map((feature) => (_jsx(ComparisonGridFeatureGroupRow, { feature: feature, featureGroupSlug: featureGroup.slug, isHiddenInMobile: isHiddenInMobile, allJetpackFeatures: allJetpackFeatures, visibleGridPlans: visibleGridPlans, planFeatureFootnotes: planFeatureFootnotes, isStorageFeature: false, isHighlighted: feature.getSlug() === selectedFeature, intervalType: intervalType, activeTooltipId: activeTooltipId, setActiveTooltipId: setActiveTooltipId, showUpgradeableStorage: showUpgradeableStorage, onStorageAddOnClick: onStorageAddOnClick }, feature.getSlug()))), featureGroup.slug === FEATURE_GROUP_ESSENTIAL_FEATURES ? (_jsx(ComparisonGridFeatureGroupRow, { featureGroupSlug: featureGroup.slug, isHiddenInMobile: isHiddenInMobile, allJetpackFeatures: allJetpackFeatures, visibleGridPlans: visibleGridPlans, planFeatureFootnotes: planFeatureFootnotes, isStorageFeature: true, isHighlighted: false, intervalType: intervalType, activeTooltipId: activeTooltipId, setActiveTooltipId: setActiveTooltipId, showUpgradeableStorage: showUpgradeableStorage, onStorageAddOnClick: onStorageAddOnClick }, "feature-storage")) : null] }, featureGroup.slug));
|
|
402
450
|
};
|
|
403
|
-
const ComparisonGrid = ({ intervalType, isInSignup, currentSitePlanSlug, planActionOverrides, selectedPlan, selectedFeature, showUpgradeableStorage, stickyRowOffset, onStorageAddOnClick, showRefundPeriod, planTypeSelectorProps, gridSize, }) => {
|
|
404
|
-
const { gridPlans,
|
|
451
|
+
const ComparisonGrid = ({ intervalType, isInSignup, currentSitePlanSlug, planActionOverrides, selectedPlan, selectedFeature, showUpgradeableStorage, stickyRowOffset, onStorageAddOnClick, showRefundPeriod, planTypeSelectorProps, gridSize, siteId, onVisiblePlansCountChange, }) => {
|
|
452
|
+
const { gridPlans, featureGroupMap } = usePlansGridContext();
|
|
405
453
|
const [activeTooltipId, setActiveTooltipId] = useManageTooltipToggle();
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
454
|
+
const { visibleGridPlans, setVisibleGridPlans } = useVisibleGridPlans({
|
|
455
|
+
gridSize,
|
|
456
|
+
currentSitePlanSlug,
|
|
457
|
+
siteId,
|
|
458
|
+
intervalType,
|
|
459
|
+
});
|
|
410
460
|
useEffect(() => {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
switch (gridSize) {
|
|
414
|
-
case 'large':
|
|
415
|
-
visibleLength = 4;
|
|
416
|
-
break;
|
|
417
|
-
case 'medium':
|
|
418
|
-
visibleLength = 3;
|
|
419
|
-
break;
|
|
420
|
-
case 'smedium':
|
|
421
|
-
case 'small':
|
|
422
|
-
visibleLength = 2;
|
|
423
|
-
break;
|
|
424
|
-
}
|
|
425
|
-
return displayedGridPlans.slice(0, visibleLength).map(({ planSlug }) => planSlug);
|
|
426
|
-
});
|
|
427
|
-
}, [gridSize, displayedGridPlans, gridPlansIndex]);
|
|
428
|
-
const visibleGridPlans = useMemo(() => visiblePlans.reduce((acc, planSlug) => {
|
|
429
|
-
const gridPlan = displayedGridPlans.find((gridPlan) => getPlanClass(gridPlan.planSlug) === getPlanClass(planSlug));
|
|
430
|
-
if (gridPlan) {
|
|
431
|
-
acc.push(gridPlan);
|
|
432
|
-
}
|
|
433
|
-
return acc;
|
|
434
|
-
}, []), [visiblePlans, displayedGridPlans]);
|
|
435
|
-
const onPlanChange = useCallback((currentPlan, event) => {
|
|
436
|
-
const newPlan = event.currentTarget.value;
|
|
437
|
-
const newVisiblePlans = visiblePlans.map((plan) => plan === currentPlan ? newPlan : plan);
|
|
438
|
-
setVisiblePlans(newVisiblePlans);
|
|
439
|
-
}, [visiblePlans]);
|
|
461
|
+
onVisiblePlansCountChange?.(visibleGridPlans.length);
|
|
462
|
+
}, [visibleGridPlans.length, onVisiblePlansCountChange]);
|
|
440
463
|
const planFeatureFootnotes = useMemo(() => {
|
|
441
464
|
// This is the main list of all footnotes. It is displayed at the bottom of the comparison grid.
|
|
442
465
|
const footnoteList = [];
|
|
@@ -463,6 +486,13 @@ const ComparisonGrid = ({ intervalType, isInSignup, currentSitePlanSlug, planAct
|
|
|
463
486
|
footnotesByFeature,
|
|
464
487
|
};
|
|
465
488
|
}, [featureGroupMap]);
|
|
489
|
+
const onPlanChange = useCallback((currentPlan, event) => {
|
|
490
|
+
const newPlanSlug = event.currentTarget.value;
|
|
491
|
+
const newPlan = gridPlans.find((plan) => plan.planSlug === newPlanSlug);
|
|
492
|
+
if (newPlan) {
|
|
493
|
+
setVisibleGridPlans((previousGridPlans) => previousGridPlans.map((plan) => (plan.planSlug === currentPlan ? newPlan : plan)));
|
|
494
|
+
}
|
|
495
|
+
}, [gridPlans, setVisibleGridPlans]);
|
|
466
496
|
// 100px is the padding of the footer row
|
|
467
497
|
const [bottomHeaderRef, isBottomHeaderInView] = useInView({ rootMargin: '-100px' });
|
|
468
498
|
/**
|
|
@@ -474,14 +504,14 @@ const ComparisonGrid = ({ intervalType, isInSignup, currentSitePlanSlug, planAct
|
|
|
474
504
|
const classes = clsx('plans-grid-next-comparison-grid', {
|
|
475
505
|
'has-highlighted-plan': hasHighlightedPlan,
|
|
476
506
|
});
|
|
477
|
-
return (_jsxs("
|
|
478
|
-
|
|
479
|
-
|
|
507
|
+
return (_jsxs("table", { className: classes, children: [_jsx(StickyGrid, { visiblePlans: visibleGridPlans.length, element: "thead", disabled: isBottomHeaderInView, stickyClass: "is-sticky-header-row", stickyOffset: stickyRowOffset, zIndex: 1, children: (isStuck) => (_jsx(ComparisonGridHeader, { displayedGridPlans: gridPlans, visibleGridPlans: visibleGridPlans, isInSignup: isInSignup, onPlanChange: onPlanChange, currentSitePlanSlug: currentSitePlanSlug, planActionOverrides: planActionOverrides, selectedPlan: selectedPlan, showRefundPeriod: showRefundPeriod, isStuck: isStuck, planTypeSelectorProps: planTypeSelectorProps })) }), Object.values(featureGroupMap).map((featureGroup) => (_jsx(FeatureGroup, { featureGroup: featureGroup, visibleGridPlans: visibleGridPlans, featureGroupMap: featureGroupMap, selectedFeature: selectedFeature, intervalType: intervalType, activeTooltipId: activeTooltipId, setActiveTooltipId: setActiveTooltipId, showUpgradeableStorage: showUpgradeableStorage, onStorageAddOnClick: onStorageAddOnClick, planFeatureFootnotes: planFeatureFootnotes, plansLength: visibleGridPlans.length }, featureGroup.slug))), _jsx("tbody", { children: _jsx(ComparisonGridHeader, { displayedGridPlans: gridPlans, visibleGridPlans: visibleGridPlans, isInSignup: isInSignup, isFooter: true, onPlanChange: onPlanChange, currentSitePlanSlug: currentSitePlanSlug, planActionOverrides: planActionOverrides, selectedPlan: selectedPlan, showRefundPeriod: showRefundPeriod, isStuck: false, isHiddenInMobile: true, ref: bottomHeaderRef, planTypeSelectorProps: planTypeSelectorProps }) }), _jsx("tfoot", { className: "plan-comparison-grid__footer", children: planFeatureFootnotes?.footnoteList && (_jsx(FeatureFootnotes, { as: "tr", children: _jsx("td", { children: _jsx("ol", { children: planFeatureFootnotes?.footnoteList?.map((footnote, index) => {
|
|
508
|
+
return _jsx("li", { children: footnote }, `${footnote}-${index}`);
|
|
509
|
+
}) }) }) })) })] }));
|
|
480
510
|
};
|
|
481
511
|
// TODO
|
|
482
512
|
// Now that everything under is functional component, we can deprecate this wrapper and only keep ComparisonGrid instead.
|
|
483
513
|
// More details can be found in https://github.com/Automattic/wp-calypso/issues/87047
|
|
484
|
-
const WrappedComparisonGrid = ({ siteId, intent, gridPlans, useCheckPlanAvailabilityForPurchase, useAction, recordTracksEvent, allFeaturesList, intervalType, isInSiteDashboard, isInSignup, currentSitePlanSlug, selectedPlan, selectedFeature, showUpgradeableStorage, onStorageAddOnClick, stickyRowOffset, coupon, className, hideUnsupportedFeatures, enableFeatureTooltips, featureGroupMap, enableTermSavingsPriceDisplay, reflectStorageSelectionInPlanPrices, ...otherProps }) => {
|
|
514
|
+
const WrappedComparisonGrid = ({ siteId, intent, gridPlans, useCheckPlanAvailabilityForPurchase, useAction, recordTracksEvent, allFeaturesList, intervalType, isInSiteDashboard, isInSignup, currentSitePlanSlug, selectedPlan, selectedFeature, showUpgradeableStorage, onStorageAddOnClick, stickyRowOffset, coupon, className, hideUnsupportedFeatures, enableFeatureTooltips, featureGroupMap, enableTermSavingsPriceDisplay, reflectStorageSelectionInPlanPrices, showSimplifiedBillingDescription, showBillingDescriptionForIncreasedRenewalPrice, isExperimentVariant, ...otherProps }) => {
|
|
485
515
|
const gridContainerRef = useRef(null);
|
|
486
516
|
const gridBreakpoints = useMemo(() => {
|
|
487
517
|
// we want to fit up to the Commerce plan in this breakpoint
|
|
@@ -507,7 +537,7 @@ const WrappedComparisonGrid = ({ siteId, intent, gridPlans, useCheckPlanAvailabi
|
|
|
507
537
|
'is-xlarge': 'xlarge' === gridSize,
|
|
508
538
|
'is-visible': true,
|
|
509
539
|
});
|
|
510
|
-
return (_jsx("div", { ref: gridContainerRef, className: classNames, children: _jsx(PlansGridContextProvider, { intent: intent, siteId: siteId, gridPlans: gridPlans, useCheckPlanAvailabilityForPurchase: useCheckPlanAvailabilityForPurchase, useAction: useAction, recordTracksEvent: recordTracksEvent, allFeaturesList: allFeaturesList, coupon: coupon, enableFeatureTooltips: enableFeatureTooltips, featureGroupMap: featureGroupMap, hideUnsupportedFeatures: hideUnsupportedFeatures, enableTermSavingsPriceDisplay: enableTermSavingsPriceDisplay, reflectStorageSelectionInPlanPrices: reflectStorageSelectionInPlanPrices, children: _jsx(ComparisonGrid, { intervalType: intervalType, isInSiteDashboard: isInSiteDashboard, isInSignup: isInSignup, currentSitePlanSlug: currentSitePlanSlug, siteId: siteId, selectedPlan: selectedPlan, selectedFeature: selectedFeature, showUpgradeableStorage: showUpgradeableStorage, stickyRowOffset: stickyRowOffset, onStorageAddOnClick: onStorageAddOnClick, gridSize: gridSize ?? undefined, ...otherProps }) }) }));
|
|
540
|
+
return (_jsx("div", { ref: gridContainerRef, className: classNames, children: _jsx(PlansGridContextProvider, { intent: intent, siteId: siteId, gridPlans: gridPlans, useCheckPlanAvailabilityForPurchase: useCheckPlanAvailabilityForPurchase, useAction: useAction, recordTracksEvent: recordTracksEvent, allFeaturesList: allFeaturesList, coupon: coupon, enableFeatureTooltips: enableFeatureTooltips, featureGroupMap: featureGroupMap, hideUnsupportedFeatures: hideUnsupportedFeatures, enableTermSavingsPriceDisplay: enableTermSavingsPriceDisplay, reflectStorageSelectionInPlanPrices: reflectStorageSelectionInPlanPrices, showSimplifiedBillingDescription: showSimplifiedBillingDescription, showBillingDescriptionForIncreasedRenewalPrice: showBillingDescriptionForIncreasedRenewalPrice, isExperimentVariant: isExperimentVariant, children: _jsx(ComparisonGrid, { intervalType: intervalType, isInSiteDashboard: isInSiteDashboard, isInSignup: isInSignup, currentSitePlanSlug: currentSitePlanSlug, siteId: siteId, selectedPlan: selectedPlan, selectedFeature: selectedFeature, showUpgradeableStorage: showUpgradeableStorage, stickyRowOffset: stickyRowOffset, onStorageAddOnClick: onStorageAddOnClick, gridSize: gridSize ?? undefined, ...otherProps }) }, intent) }));
|
|
511
541
|
};
|
|
512
542
|
export default WrappedComparisonGrid;
|
|
513
543
|
//# sourceMappingURL=index.js.map
|