@vtex/faststore 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/actions.json +334 -0
- package/dist/catalog.json +6615 -0
- package/dist/client.d.ts +17 -0
- package/dist/client.js +8 -0
- package/dist/components.d.ts +87 -0
- package/dist/components.js +87 -0
- package/dist/content-types.json +684 -0
- package/dist/core/dist/actions/mock-action.d.ts +24 -0
- package/dist/core/dist/actions/mock-action.js +28 -0
- package/dist/core/dist/actions/mock-action.js.map +1 -0
- package/dist/core/dist/actions/registry.d.ts +24 -0
- package/dist/core/dist/actions/registry.js +28 -0
- package/dist/core/dist/actions/registry.js.map +1 -0
- package/dist/core/dist/define-component.d.ts +100 -0
- package/dist/core/dist/define-component.js +8 -0
- package/dist/core/dist/define-component.js.map +1 -0
- package/dist/core/dist/define-content-type.d.ts +95 -0
- package/dist/core/dist/define-content-type.js +283 -0
- package/dist/core/dist/define-content-type.js.map +1 -0
- package/dist/core/dist/index.d.ts +7 -0
- package/dist/core/dist/index.js +5 -0
- package/dist/core/dist/schema/generated/schema.d.ts +28 -0
- package/dist/core/dist/types.d.ts +1 -0
- package/dist/docs/access-code-field.md +100 -0
- package/dist/docs/access-code-sign-in.md +174 -0
- package/dist/docs/account-entry-point.md +155 -0
- package/dist/docs/address-summary.md +50 -0
- package/dist/docs/buy-button.md +162 -0
- package/dist/docs/carousel.md +105 -0
- package/dist/docs/cart-item.md +162 -0
- package/dist/docs/cart-totalizer.md +197 -0
- package/dist/docs/cart.md +495 -0
- package/dist/docs/client-preferences.md +184 -0
- package/dist/docs/client-profile-form.md +192 -0
- package/dist/docs/client-profile.md +117 -0
- package/dist/docs/container.md +97 -0
- package/dist/docs/document-field.md +97 -0
- package/dist/docs/email-field.md +93 -0
- package/dist/docs/email-identification.md +102 -0
- package/dist/docs/footer-copyright.md +112 -0
- package/dist/docs/footer-link-group.md +162 -0
- package/dist/docs/footer-root.md +145 -0
- package/dist/docs/footer-social.md +151 -0
- package/dist/docs/free-shipping-progress.md +87 -0
- package/dist/docs/gallery.md +84 -0
- package/dist/docs/header-root.md +150 -0
- package/dist/docs/identity-edit.md +88 -0
- package/dist/docs/identity-summary.md +106 -0
- package/dist/docs/incentives.md +151 -0
- package/dist/docs/logo.md +135 -0
- package/dist/docs/meter.md +67 -0
- package/dist/docs/navigation-link-list.md +171 -0
- package/dist/docs/navigation-link.md +163 -0
- package/dist/docs/navigation-menu.md +264 -0
- package/dist/docs/payment-methods.md +139 -0
- package/dist/docs/phone-field.md +106 -0
- package/dist/docs/postal-code-field.md +126 -0
- package/dist/docs/pricing.md +499 -0
- package/dist/docs/product-gallery.md +409 -0
- package/dist/docs/product-information.md +295 -0
- package/dist/docs/product-list.md +170 -0
- package/dist/docs/product-quantity.md +88 -0
- package/dist/docs/product-shelf.md +141 -0
- package/dist/docs/promotion.md +109 -0
- package/dist/docs/region.md +225 -0
- package/dist/docs/session.md +123 -0
- package/dist/docs/shipping-address.md +390 -0
- package/dist/docs/shipping-simulator.md +147 -0
- package/dist/docs/sign-in-form.md +117 -0
- package/dist/docs/tabs.md +176 -0
- package/dist/docs/toast.md +124 -0
- package/dist/docs/variant-selector.md +450 -0
- package/dist/graphql/define-subgraph.d.ts +12 -0
- package/dist/graphql/define-subgraph.js +15 -0
- package/dist/graphql/define-subgraph.js.map +1 -0
- package/dist/graphql/gql.d.ts +10 -0
- package/dist/graphql/gql.js +16 -0
- package/dist/graphql/gql.js.map +1 -0
- package/dist/graphql/types.d.ts +88 -0
- package/dist/graphql.d.ts +4 -0
- package/dist/graphql.js +3 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +5 -0
- package/dist/internal/client.d.ts +24 -0
- package/dist/internal/client.js +23 -0
- package/dist/internal/content.d.ts +2 -0
- package/dist/internal/content.js +2 -0
- package/dist/internal/server.d.ts +7 -0
- package/dist/internal/server.js +6 -0
- package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +111 -0
- package/dist/matter/access-code-sign-in/access-code-sign-in.js +387 -0
- package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -0
- package/dist/matter/account-entry-point/account-entry-point.d.ts +64 -0
- package/dist/matter/account-entry-point/account-entry-point.js +151 -0
- package/dist/matter/account-entry-point/account-entry-point.js.map +1 -0
- package/dist/matter/breadcrumb/breadcrumb.d.ts +40 -0
- package/dist/matter/breadcrumb/breadcrumb.js +155 -0
- package/dist/matter/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/matter/buy-button/buy-button.d.ts +95 -0
- package/dist/matter/buy-button/buy-button.js +259 -0
- package/dist/matter/buy-button/buy-button.js.map +1 -0
- package/dist/matter/cart/cart-namespace.d.ts +48 -0
- package/dist/matter/cart/cart-namespace.js +50 -0
- package/dist/matter/cart/cart-namespace.js.map +1 -0
- package/dist/matter/cart/cart.d.ts +312 -0
- package/dist/matter/cart/cart.js +1034 -0
- package/dist/matter/cart/cart.js.map +1 -0
- package/dist/matter/cart-item/cart-item.d.ts +103 -0
- package/dist/matter/cart-item/cart-item.js +672 -0
- package/dist/matter/cart-item/cart-item.js.map +1 -0
- package/dist/matter/cart-item-compositions/cart-item-compositions.d.ts +49 -0
- package/dist/matter/cart-item-compositions/cart-item-compositions.js +165 -0
- package/dist/matter/cart-item-compositions/cart-item-compositions.js.map +1 -0
- package/dist/matter/cart-item-customizations/cart-item-customizations.d.ts +28 -0
- package/dist/matter/cart-item-customizations/cart-item-customizations.js +73 -0
- package/dist/matter/cart-item-customizations/cart-item-customizations.js.map +1 -0
- package/dist/matter/cart-item-discounts/cart-item-discounts.d.ts +33 -0
- package/dist/matter/cart-item-discounts/cart-item-discounts.js +70 -0
- package/dist/matter/cart-item-discounts/cart-item-discounts.js.map +1 -0
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.d.ts +24 -0
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.js +54 -0
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.js.map +1 -0
- package/dist/matter/cart-item-variations/cart-item-variations.d.ts +27 -0
- package/dist/matter/cart-item-variations/cart-item-variations.js +69 -0
- package/dist/matter/cart-item-variations/cart-item-variations.js.map +1 -0
- package/dist/matter/cart-totalizer/cart-totalizer.d.ts +78 -0
- package/dist/matter/cart-totalizer/cart-totalizer.js +220 -0
- package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -0
- package/dist/matter/client-preferences/client-preferences.d.ts +50 -0
- package/dist/matter/client-preferences/client-preferences.js +206 -0
- package/dist/matter/client-preferences/client-preferences.js.map +1 -0
- package/dist/matter/client-profile/client-profile.d.ts +59 -0
- package/dist/matter/client-profile/client-profile.js +185 -0
- package/dist/matter/client-profile/client-profile.js.map +1 -0
- package/dist/matter/client-profile-form/client-profile-form.d.ts +126 -0
- package/dist/matter/client-profile-form/client-profile-form.js +660 -0
- package/dist/matter/client-profile-form/client-profile-form.js.map +1 -0
- package/dist/matter/delivery-options/delivery-options-accordion.d.ts +30 -0
- package/dist/matter/delivery-options/delivery-options-accordion.js +189 -0
- package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -0
- package/dist/matter/delivery-options/delivery-options-controller.d.ts +49 -0
- package/dist/matter/delivery-options/delivery-options-controller.js +203 -0
- package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -0
- package/dist/matter/delivery-options/delivery-options.d.ts +31 -0
- package/dist/matter/delivery-options/delivery-options.js +103 -0
- package/dist/matter/delivery-options/delivery-options.js.map +1 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.d.ts +9 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.js +76 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.js.map +1 -0
- package/dist/matter/email-identification/email-identification.d.ts +37 -0
- package/dist/matter/email-identification/email-identification.js +111 -0
- package/dist/matter/email-identification/email-identification.js.map +1 -0
- package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +44 -0
- package/dist/matter/free-shipping-progress/free-shipping-progress.js +170 -0
- package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -0
- package/dist/matter/identity-edit/identity-edit.d.ts +52 -0
- package/dist/matter/identity-edit/identity-edit.js +148 -0
- package/dist/matter/identity-edit/identity-edit.js.map +1 -0
- package/dist/matter/identity-summary/identity-summary.d.ts +128 -0
- package/dist/matter/identity-summary/identity-summary.js +344 -0
- package/dist/matter/identity-summary/identity-summary.js.map +1 -0
- package/dist/matter/pricing/pricing.d.ts +162 -0
- package/dist/matter/pricing/pricing.js +793 -0
- package/dist/matter/pricing/pricing.js.map +1 -0
- package/dist/matter/product-gallery/product-gallery.d.ts +23 -0
- package/dist/matter/product-gallery/product-gallery.js +188 -0
- package/dist/matter/product-gallery/product-gallery.js.map +1 -0
- package/dist/matter/product-information/product-information.d.ts +61 -0
- package/dist/matter/product-information/product-information.js +355 -0
- package/dist/matter/product-information/product-information.js.map +1 -0
- package/dist/matter/product-list/product-list.d.ts +86 -0
- package/dist/matter/product-list/product-list.js +342 -0
- package/dist/matter/product-list/product-list.js.map +1 -0
- package/dist/matter/product-quantity/product-quantity.d.ts +50 -0
- package/dist/matter/product-quantity/product-quantity.js +111 -0
- package/dist/matter/product-quantity/product-quantity.js.map +1 -0
- package/dist/matter/product-shelf/product-shelf.d.ts +125 -0
- package/dist/matter/product-shelf/product-shelf.js +376 -0
- package/dist/matter/product-shelf/product-shelf.js.map +1 -0
- package/dist/matter/region/region.d.ts +211 -0
- package/dist/matter/region/region.js +579 -0
- package/dist/matter/region/region.js.map +1 -0
- package/dist/matter/session/session.d.ts +58 -0
- package/dist/matter/session/session.js +112 -0
- package/dist/matter/session/session.js.map +1 -0
- package/dist/matter/shipping-address/country-descriptors.js +101 -0
- package/dist/matter/shipping-address/country-descriptors.js.map +1 -0
- package/dist/matter/shipping-address/shipping-address.d.ts +284 -0
- package/dist/matter/shipping-address/shipping-address.js +1036 -0
- package/dist/matter/shipping-address/shipping-address.js.map +1 -0
- package/dist/matter/shipping-simulator/shipping-simulator.d.ts +143 -0
- package/dist/matter/shipping-simulator/shipping-simulator.js +644 -0
- package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -0
- package/dist/matter/sign-in-form/sign-in-form.d.ts +79 -0
- package/dist/matter/sign-in-form/sign-in-form.js +226 -0
- package/dist/matter/sign-in-form/sign-in-form.js.map +1 -0
- package/dist/matter/variant-selector/variant-selector.d.ts +183 -0
- package/dist/matter/variant-selector/variant-selector.js +840 -0
- package/dist/matter/variant-selector/variant-selector.js.map +1 -0
- package/dist/message-locales.json +7 -0
- package/dist/particles/access-code-field/access-code-field.d.ts +33 -0
- package/dist/particles/access-code-field/access-code-field.js +95 -0
- package/dist/particles/access-code-field/access-code-field.js.map +1 -0
- package/dist/particles/accordion/accordion.d.ts +45 -0
- package/dist/particles/accordion/accordion.js +156 -0
- package/dist/particles/accordion/accordion.js.map +1 -0
- package/dist/particles/address-summary/address-summary.d.ts +50 -0
- package/dist/particles/address-summary/address-summary.js +129 -0
- package/dist/particles/address-summary/address-summary.js.map +1 -0
- package/dist/particles/badge/badge.d.ts +10 -0
- package/dist/particles/badge/badge.js +27 -0
- package/dist/particles/badge/badge.js.map +1 -0
- package/dist/particles/button/button.d.ts +18 -0
- package/dist/particles/button/button.js +37 -0
- package/dist/particles/button/button.js.map +1 -0
- package/dist/particles/carousel/carousel.d.ts +60 -0
- package/dist/particles/carousel/carousel.js +335 -0
- package/dist/particles/carousel/carousel.js.map +1 -0
- package/dist/particles/checkbox/checkbox.d.ts +40 -0
- package/dist/particles/checkbox/checkbox.js +82 -0
- package/dist/particles/checkbox/checkbox.js.map +1 -0
- package/dist/particles/container/container.d.ts +20 -0
- package/dist/particles/container/container.js +36 -0
- package/dist/particles/container/container.js.map +1 -0
- package/dist/particles/dialog/dialog.d.ts +54 -0
- package/dist/particles/dialog/dialog.js +192 -0
- package/dist/particles/dialog/dialog.js.map +1 -0
- package/dist/particles/document-field/document-field.d.ts +61 -0
- package/dist/particles/document-field/document-field.js +146 -0
- package/dist/particles/document-field/document-field.js.map +1 -0
- package/dist/particles/drawer/drawer.d.ts +52 -0
- package/dist/particles/drawer/drawer.js +183 -0
- package/dist/particles/drawer/drawer.js.map +1 -0
- package/dist/particles/email-field/email-field.d.ts +37 -0
- package/dist/particles/email-field/email-field.js +106 -0
- package/dist/particles/email-field/email-field.js.map +1 -0
- package/dist/particles/field/field.d.ts +50 -0
- package/dist/particles/field/field.js +133 -0
- package/dist/particles/field/field.js.map +1 -0
- package/dist/particles/fieldset/fieldset.d.ts +16 -0
- package/dist/particles/fieldset/fieldset.js +52 -0
- package/dist/particles/fieldset/fieldset.js.map +1 -0
- package/dist/particles/footer-copyright/footer-copyright.d.ts +32 -0
- package/dist/particles/footer-copyright/footer-copyright.js +50 -0
- package/dist/particles/footer-copyright/footer-copyright.js.map +1 -0
- package/dist/particles/footer-link-group/footer-link-group.d.ts +66 -0
- package/dist/particles/footer-link-group/footer-link-group.js +154 -0
- package/dist/particles/footer-link-group/footer-link-group.js.map +1 -0
- package/dist/particles/footer-root/footer-root.d.ts +21 -0
- package/dist/particles/footer-root/footer-root.js +38 -0
- package/dist/particles/footer-root/footer-root.js.map +1 -0
- package/dist/particles/footer-social/footer-social.d.ts +79 -0
- package/dist/particles/footer-social/footer-social.js +176 -0
- package/dist/particles/footer-social/footer-social.js.map +1 -0
- package/dist/particles/gallery/gallery.d.ts +181 -0
- package/dist/particles/gallery/gallery.js +920 -0
- package/dist/particles/gallery/gallery.js.map +1 -0
- package/dist/particles/header-root/header-root.d.ts +21 -0
- package/dist/particles/header-root/header-root.js +38 -0
- package/dist/particles/header-root/header-root.js.map +1 -0
- package/dist/particles/icon/icon.d.ts +22 -0
- package/dist/particles/icon/icon.js +48 -0
- package/dist/particles/icon/icon.js.map +1 -0
- package/dist/particles/image/image.d.ts +13 -0
- package/dist/particles/image/image.js +59 -0
- package/dist/particles/image/image.js.map +1 -0
- package/dist/particles/incentives/incentives.d.ts +85 -0
- package/dist/particles/incentives/incentives.js +200 -0
- package/dist/particles/incentives/incentives.js.map +1 -0
- package/dist/particles/input/input.d.ts +9 -0
- package/dist/particles/input/input.js +28 -0
- package/dist/particles/input/input.js.map +1 -0
- package/dist/particles/logo/logo.d.ts +55 -0
- package/dist/particles/logo/logo.js +96 -0
- package/dist/particles/logo/logo.js.map +1 -0
- package/dist/particles/menu/menu.d.ts +103 -0
- package/dist/particles/menu/menu.js +409 -0
- package/dist/particles/menu/menu.js.map +1 -0
- package/dist/particles/menubar/menubar.d.ts +18 -0
- package/dist/particles/menubar/menubar.js +42 -0
- package/dist/particles/menubar/menubar.js.map +1 -0
- package/dist/particles/meter/meter.d.ts +36 -0
- package/dist/particles/meter/meter.js +132 -0
- package/dist/particles/meter/meter.js.map +1 -0
- package/dist/particles/navigation-link/navigation-link.d.ts +43 -0
- package/dist/particles/navigation-link/navigation-link.js +82 -0
- package/dist/particles/navigation-link/navigation-link.js.map +1 -0
- package/dist/particles/navigation-link-list/navigation-link-list.d.ts +59 -0
- package/dist/particles/navigation-link-list/navigation-link-list.js +103 -0
- package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -0
- package/dist/particles/navigation-menu/navigation-menu.d.ts +78 -0
- package/dist/particles/navigation-menu/navigation-menu.js +295 -0
- package/dist/particles/navigation-menu/navigation-menu.js.map +1 -0
- package/dist/particles/number-field/number-field.d.ts +46 -0
- package/dist/particles/number-field/number-field.js +169 -0
- package/dist/particles/number-field/number-field.js.map +1 -0
- package/dist/particles/password-field/password-field.d.ts +31 -0
- package/dist/particles/password-field/password-field.js +109 -0
- package/dist/particles/password-field/password-field.js.map +1 -0
- package/dist/particles/payment-methods/payment-methods.d.ts +72 -0
- package/dist/particles/payment-methods/payment-methods.js +151 -0
- package/dist/particles/payment-methods/payment-methods.js.map +1 -0
- package/dist/particles/phone-field/phone-field.d.ts +67 -0
- package/dist/particles/phone-field/phone-field.js +250 -0
- package/dist/particles/phone-field/phone-field.js.map +1 -0
- package/dist/particles/popover/popover.d.ts +68 -0
- package/dist/particles/popover/popover.js +284 -0
- package/dist/particles/popover/popover.js.map +1 -0
- package/dist/particles/postal-code-field/postal-code-field.d.ts +75 -0
- package/dist/particles/postal-code-field/postal-code-field.js +169 -0
- package/dist/particles/postal-code-field/postal-code-field.js.map +1 -0
- package/dist/particles/promotion/promotion.d.ts +46 -0
- package/dist/particles/promotion/promotion.js +78 -0
- package/dist/particles/promotion/promotion.js.map +1 -0
- package/dist/particles/quantity-selector/quantity-selector.d.ts +30 -0
- package/dist/particles/quantity-selector/quantity-selector.js +116 -0
- package/dist/particles/quantity-selector/quantity-selector.js.map +1 -0
- package/dist/particles/radio/radio.d.ts +36 -0
- package/dist/particles/radio/radio.js +76 -0
- package/dist/particles/radio/radio.js.map +1 -0
- package/dist/particles/scroll-area/scroll-area.d.ts +36 -0
- package/dist/particles/scroll-area/scroll-area.js +145 -0
- package/dist/particles/scroll-area/scroll-area.js.map +1 -0
- package/dist/particles/select/select.d.ts +125 -0
- package/dist/particles/select/select.js +478 -0
- package/dist/particles/select/select.js.map +1 -0
- package/dist/particles/separator/separator.d.ts +12 -0
- package/dist/particles/separator/separator.js +33 -0
- package/dist/particles/separator/separator.js.map +1 -0
- package/dist/particles/shared/input-mask.d.ts +5 -0
- package/dist/particles/shared/input-mask.js +58 -0
- package/dist/particles/shared/input-mask.js.map +1 -0
- package/dist/particles/spinner/spinner.d.ts +13 -0
- package/dist/particles/spinner/spinner.js +31 -0
- package/dist/particles/spinner/spinner.js.map +1 -0
- package/dist/particles/switch/switch.d.ts +27 -0
- package/dist/particles/switch/switch.js +59 -0
- package/dist/particles/switch/switch.js.map +1 -0
- package/dist/particles/tabs/tabs.d.ts +45 -0
- package/dist/particles/tabs/tabs.js +164 -0
- package/dist/particles/tabs/tabs.js.map +1 -0
- package/dist/particles/text/text.d.ts +24 -0
- package/dist/particles/text/text.js +40 -0
- package/dist/particles/text/text.js.map +1 -0
- package/dist/particles/toast/toast.d.ts +83 -0
- package/dist/particles/toast/toast.js +194 -0
- package/dist/particles/toast/toast.js.map +1 -0
- package/dist/particles/toggle/toggle.d.ts +26 -0
- package/dist/particles/toggle/toggle.js +61 -0
- package/dist/particles/toggle/toggle.js.map +1 -0
- package/dist/particles/tooltip/tooltip.d.ts +61 -0
- package/dist/particles/tooltip/tooltip.js +240 -0
- package/dist/particles/tooltip/tooltip.js.map +1 -0
- package/dist/schema.graphql +2953 -0
- package/dist/sdk/actions/cart-action-provider.d.ts +19 -0
- package/dist/sdk/actions/cart-action-provider.js +23 -0
- package/dist/sdk/actions/cart-action-provider.js.map +1 -0
- package/dist/sdk/actions/identity-action-provider.d.ts +15 -0
- package/dist/sdk/actions/identity-action-provider.js +19 -0
- package/dist/sdk/actions/identity-action-provider.js.map +1 -0
- package/dist/sdk/actions/index.d.ts +7 -0
- package/dist/sdk/actions/index.js +6 -0
- package/dist/sdk/actions/inject-actions.d.ts +14 -0
- package/dist/sdk/actions/inject-actions.js +36 -0
- package/dist/sdk/actions/inject-actions.js.map +1 -0
- package/dist/sdk/actions/region-action-provider.d.ts +15 -0
- package/dist/sdk/actions/region-action-provider.js +19 -0
- package/dist/sdk/actions/region-action-provider.js.map +1 -0
- package/dist/sdk/actions/session-action-provider.d.ts +15 -0
- package/dist/sdk/actions/session-action-provider.js +19 -0
- package/dist/sdk/actions/session-action-provider.js.map +1 -0
- package/dist/sdk/actions/shipping-action-provider.d.ts +15 -0
- package/dist/sdk/actions/shipping-action-provider.js +19 -0
- package/dist/sdk/actions/shipping-action-provider.js.map +1 -0
- package/dist/sdk/actions/types.d.ts +21 -0
- package/dist/sdk/cache/storefront-cache.js +35 -0
- package/dist/sdk/cache/storefront-cache.js.map +1 -0
- package/dist/sdk/cart/operations.d.ts +31 -0
- package/dist/sdk/cart/operations.js +215 -0
- package/dist/sdk/cart/operations.js.map +1 -0
- package/dist/sdk/cart/optimistic.d.ts +24 -0
- package/dist/sdk/cart/optimistic.js +164 -0
- package/dist/sdk/cart/optimistic.js.map +1 -0
- package/dist/sdk/cart/use-cart-actions.d.ts +56 -0
- package/dist/sdk/cart/use-cart-actions.js +348 -0
- package/dist/sdk/cart/use-cart-actions.js.map +1 -0
- package/dist/sdk/cart/use-cart-validate-on-open.js +50 -0
- package/dist/sdk/cart/use-cart-validate-on-open.js.map +1 -0
- package/dist/sdk/cart/write-gate.js +54 -0
- package/dist/sdk/cart/write-gate.js.map +1 -0
- package/dist/sdk/client/assert-api-url.js +20 -0
- package/dist/sdk/client/assert-api-url.js.map +1 -0
- package/dist/sdk/client/create-client.d.ts +23 -0
- package/dist/sdk/client/create-client.js +46 -0
- package/dist/sdk/client/create-client.js.map +1 -0
- package/dist/sdk/client/fetch-page-data.d.ts +39 -0
- package/dist/sdk/client/fetch-page-data.js +33 -0
- package/dist/sdk/client/fetch-page-data.js.map +1 -0
- package/dist/sdk/client/register-preload-query.d.ts +24 -0
- package/dist/sdk/client/register-preload-query.js +33 -0
- package/dist/sdk/client/register-preload-query.js.map +1 -0
- package/dist/sdk/content/create-content-runtime.d.ts +68 -0
- package/dist/sdk/content/create-content-runtime.js +503 -0
- package/dist/sdk/content/create-content-runtime.js.map +1 -0
- package/dist/sdk/context/headers.d.ts +15 -0
- package/dist/sdk/context/headers.js +21 -0
- package/dist/sdk/context/headers.js.map +1 -0
- package/dist/sdk/context/storefront-context.d.ts +11 -0
- package/dist/sdk/context/storefront-context.js +29 -0
- package/dist/sdk/context/storefront-context.js.map +1 -0
- package/dist/sdk/data/data-override-context.d.ts +12 -0
- package/dist/sdk/data/data-override-context.js +19 -0
- package/dist/sdk/data/data-override-context.js.map +1 -0
- package/dist/sdk/data/entity-subscriber.js +28 -0
- package/dist/sdk/data/entity-subscriber.js.map +1 -0
- package/dist/sdk/data/hot-data-provider.d.ts +19 -0
- package/dist/sdk/data/hot-data-provider.js +33 -0
- package/dist/sdk/data/hot-data-provider.js.map +1 -0
- package/dist/sdk/data/index.d.ts +8 -0
- package/dist/sdk/data/index.js +8 -0
- package/dist/sdk/data/list-item-ref-context.d.ts +20 -0
- package/dist/sdk/data/list-item-ref-context.js +11 -0
- package/dist/sdk/data/list-item-ref-context.js.map +1 -0
- package/dist/sdk/data/multiple-reactive-data-provider.d.ts +32 -0
- package/dist/sdk/data/multiple-reactive-data-provider.js +20 -0
- package/dist/sdk/data/multiple-reactive-data-provider.js.map +1 -0
- package/dist/sdk/data/page-reactive-data-root.d.ts +53 -0
- package/dist/sdk/data/page-reactive-data-root.js +153 -0
- package/dist/sdk/data/page-reactive-data-root.js.map +1 -0
- package/dist/sdk/data/reactive-data-provider.d.ts +25 -0
- package/dist/sdk/data/reactive-data-provider.js +24 -0
- package/dist/sdk/data/reactive-data-provider.js.map +1 -0
- package/dist/sdk/data/reactive-list-item-data-provider.d.ts +26 -0
- package/dist/sdk/data/reactive-list-item-data-provider.js +42 -0
- package/dist/sdk/data/reactive-list-item-data-provider.js.map +1 -0
- package/dist/sdk/data/use-reactive-entity.js +40 -0
- package/dist/sdk/data/use-reactive-entity.js.map +1 -0
- package/dist/sdk/format/client.d.ts +12 -0
- package/dist/sdk/format/client.js +20 -0
- package/dist/sdk/format/client.js.map +1 -0
- package/dist/sdk/format/formatters.d.ts +32 -0
- package/dist/sdk/format/formatters.js +45 -0
- package/dist/sdk/format/formatters.js.map +1 -0
- package/dist/sdk/generated/fragment-types.js +23 -0
- package/dist/sdk/generated/fragment-types.js.map +1 -0
- package/dist/sdk/generated/gql.js +51 -0
- package/dist/sdk/generated/gql.js.map +1 -0
- package/dist/sdk/generated/graphql.d.ts +622 -0
- package/dist/sdk/generated/graphql.js +11917 -0
- package/dist/sdk/generated/graphql.js.map +1 -0
- package/dist/sdk/graphql-tag.d.ts +10 -0
- package/dist/sdk/graphql-tag.js +21 -0
- package/dist/sdk/graphql-tag.js.map +1 -0
- package/dist/sdk/i18n/client.d.ts +4 -0
- package/dist/sdk/i18n/client.js +4 -0
- package/dist/sdk/i18n/locales.d.ts +8 -0
- package/dist/sdk/i18n/locales.js +57 -0
- package/dist/sdk/i18n/locales.js.map +1 -0
- package/dist/sdk/i18n/messages/en-US.js +24 -0
- package/dist/sdk/i18n/messages/en-US.js.map +1 -0
- package/dist/sdk/i18n/messages/en-US.json +19 -0
- package/dist/sdk/i18n/messages/en-US.json.d.ts +23 -0
- package/dist/sdk/i18n/messages/es-ES.js +24 -0
- package/dist/sdk/i18n/messages/es-ES.js.map +1 -0
- package/dist/sdk/i18n/messages/es-ES.json +19 -0
- package/dist/sdk/i18n/messages/pt-BR.js +24 -0
- package/dist/sdk/i18n/messages/pt-BR.js.map +1 -0
- package/dist/sdk/i18n/messages/pt-BR.json +19 -0
- package/dist/sdk/i18n/provider.d.ts +1 -0
- package/dist/sdk/i18n/provider.js +30 -0
- package/dist/sdk/i18n/provider.js.map +1 -0
- package/dist/sdk/i18n/server.d.ts +28 -0
- package/dist/sdk/i18n/server.js +59 -0
- package/dist/sdk/i18n/server.js.map +1 -0
- package/dist/sdk/identity/operations.d.ts +34 -0
- package/dist/sdk/identity/operations.js +78 -0
- package/dist/sdk/identity/operations.js.map +1 -0
- package/dist/sdk/identity/use-identity-actions.d.ts +62 -0
- package/dist/sdk/identity/use-identity-actions.js +180 -0
- package/dist/sdk/identity/use-identity-actions.js.map +1 -0
- package/dist/sdk/provider/index.d.ts +2 -0
- package/dist/sdk/provider/index.js +2 -0
- package/dist/sdk/provider/storefront-provider.d.ts +32 -0
- package/dist/sdk/provider/storefront-provider.js +111 -0
- package/dist/sdk/provider/storefront-provider.js.map +1 -0
- package/dist/sdk/region/operations.d.ts +6 -0
- package/dist/sdk/region/region-operations.d.ts +30 -0
- package/dist/sdk/region/region-operations.js +23 -0
- package/dist/sdk/region/region-operations.js.map +1 -0
- package/dist/sdk/region/use-region-actions.d.ts +23 -0
- package/dist/sdk/region/use-region-actions.js +66 -0
- package/dist/sdk/region/use-region-actions.js.map +1 -0
- package/dist/sdk/seller.js +11 -0
- package/dist/sdk/seller.js.map +1 -0
- package/dist/sdk/session/auth-operations.d.ts +47 -0
- package/dist/sdk/session/auth-operations.js +79 -0
- package/dist/sdk/session/auth-operations.js.map +1 -0
- package/dist/sdk/session/operations.d.ts +6 -0
- package/dist/sdk/session/use-session-actions.d.ts +27 -0
- package/dist/sdk/session/use-session-actions.js +126 -0
- package/dist/sdk/session/use-session-actions.js.map +1 -0
- package/dist/sdk/shipping/cart-operations.d.ts +3 -0
- package/dist/sdk/shipping/cart-operations.js +33 -0
- package/dist/sdk/shipping/cart-operations.js.map +1 -0
- package/dist/sdk/shipping/operations.d.ts +3 -0
- package/dist/sdk/shipping/operations.js +33 -0
- package/dist/sdk/shipping/operations.js.map +1 -0
- package/dist/sdk/shipping/option-select-operations.d.ts +24 -0
- package/dist/sdk/shipping/option-select-operations.js +45 -0
- package/dist/sdk/shipping/option-select-operations.js.map +1 -0
- package/dist/sdk/shipping/request-timeout.js +41 -0
- package/dist/sdk/shipping/request-timeout.js.map +1 -0
- package/dist/sdk/shipping/shipping-operations.d.ts +38 -0
- package/dist/sdk/shipping/shipping-operations.js +77 -0
- package/dist/sdk/shipping/shipping-operations.js.map +1 -0
- package/dist/sdk/shipping/use-cart-shipping-simulation.d.ts +7 -0
- package/dist/sdk/shipping/use-cart-shipping-simulation.js +72 -0
- package/dist/sdk/shipping/use-cart-shipping-simulation.js.map +1 -0
- package/dist/sdk/shipping/use-shipping-actions.d.ts +27 -0
- package/dist/sdk/shipping/use-shipping-actions.js +113 -0
- package/dist/sdk/shipping/use-shipping-actions.js.map +1 -0
- package/dist/sdk/shipping/use-shipping-simulation.d.ts +7 -0
- package/dist/sdk/shipping/use-shipping-simulation.js +72 -0
- package/dist/sdk/shipping/use-shipping-simulation.js.map +1 -0
- package/dist/sdk/state/cart.d.ts +42 -0
- package/dist/sdk/state/cart.js +64 -0
- package/dist/sdk/state/cart.js.map +1 -0
- package/dist/sdk/state/index.js +3 -0
- package/dist/sdk/state/variant-selector.d.ts +17 -0
- package/dist/sdk/state/variant-selector.js +14 -0
- package/dist/sdk/state/variant-selector.js.map +1 -0
- package/dist/utils/safe-href.js +63 -0
- package/dist/utils/safe-href.js.map +1 -0
- package/package.json +84 -0
- package/src/styles/tailwind.css +32 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.js","names":["BasePopover","Popover"],"sources":["../../../src/particles/popover/popover.tsx"],"sourcesContent":["'use client';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport { defineComponent } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef, ReactNode } from 'react';\n\nexport type PopoverSide = 'top' | 'bottom' | 'left' | 'right';\nexport type PopoverAlign = 'start' | 'center' | 'end';\n\nexport type PopoverRootProps = {\n defaultOpen?: boolean;\n modal?: boolean;\n children?: ReactNode;\n};\n\nexport type PopoverTriggerProps = ComponentPropsWithRef<'button'> & {\n openOnHover?: boolean;\n delay?: number;\n closeDelay?: number;\n};\n\nexport type PopoverPortalProps = {\n children?: ReactNode;\n};\n\nexport type PopoverBackdropProps = ComponentPropsWithRef<'div'>;\n\nexport type PopoverPositionerProps = ComponentPropsWithRef<'div'> & {\n side?: PopoverSide;\n align?: PopoverAlign;\n sideOffset?: number;\n};\n\nexport type PopoverPopupProps = ComponentPropsWithRef<'div'>;\n\nexport type PopoverArrowProps = ComponentPropsWithRef<'div'>;\n\nexport type PopoverViewportProps = ComponentPropsWithRef<'div'>;\n\nexport type PopoverTitleProps = ComponentPropsWithRef<'h2'>;\n\nexport type PopoverDescriptionProps = ComponentPropsWithRef<'p'>;\n\nexport type PopoverCloseProps = ComponentPropsWithRef<'button'>;\n\nexport const PopoverRootDefinition = defineComponent<PopoverRootProps>({\n name: 'PopoverRoot',\n importPath: '@vtex/faststore/components',\n component: PopoverRoot,\n editor: { label: 'Popover Root', category: 'layout' },\n schema: {\n defaultOpen: { type: 'boolean', default: false, label: 'Default Open' },\n modal: { type: 'boolean', default: false, label: 'Modal' },\n },\n guideline:\n 'Root of an anchored overlay for rich content (forms, product previews). Manages open state and focus trapping. Compose as: PopoverRoot > (PopoverTrigger + PopoverPortal > (PopoverBackdrop + PopoverPositioner > PopoverPopup > (PopoverArrow + PopoverTitle + PopoverDescription + content + PopoverClose))). Set modal=true when content requires focus trap.',\n});\n\nexport const PopoverTriggerDefinition = defineComponent<PopoverTriggerProps>({\n name: 'PopoverTrigger',\n importPath: '@vtex/faststore/components',\n component: PopoverTrigger,\n editor: { label: 'Popover Trigger', category: 'action' },\n schema: {\n openOnHover: { type: 'boolean', default: false, label: 'Open On Hover' },\n delay: { type: 'number', default: 300, label: 'Delay' },\n closeDelay: { type: 'number', default: 0, label: 'Close Delay' },\n },\n guideline: 'Set openOnHover=true for instant preview panels on product cards or image thumbnails.',\n});\n\nexport const PopoverPortalDefinition = defineComponent<PopoverPortalProps>({\n name: 'PopoverPortal',\n importPath: '@vtex/faststore/components',\n component: PopoverPortal,\n editor: { label: 'Popover Portal', category: 'layout' },\n schema: {},\n guideline: 'Teleports popover content to <body> to avoid overflow/z-index issues.',\n});\n\nexport const PopoverBackdropDefinition = defineComponent<PopoverBackdropProps>({\n name: 'PopoverBackdrop',\n importPath: '@vtex/faststore/components',\n component: PopoverBackdrop,\n editor: { label: 'Popover Backdrop', category: 'layout' },\n schema: {},\n guideline: 'Semi-transparent overlay rendered behind the popup when modal=true.',\n});\n\nexport const PopoverPositionerDefinition = defineComponent<PopoverPositionerProps>({\n name: 'PopoverPositioner',\n importPath: '@vtex/faststore/components',\n component: PopoverPositioner,\n editor: { label: 'Popover Positioner', category: 'layout' },\n schema: {\n side: { type: ['top', 'bottom', 'left', 'right'] as const, default: 'bottom', label: 'Side' },\n align: { type: ['start', 'center', 'end'] as const, default: 'center', label: 'Align' },\n sideOffset: { type: 'number', default: 0, label: 'Side Offset' },\n },\n guideline: 'Controls popup placement relative to the trigger.',\n});\n\nexport const PopoverPopupDefinition = defineComponent<PopoverPopupProps>({\n name: 'PopoverPopup',\n importPath: '@vtex/faststore/components',\n component: PopoverPopup,\n editor: { label: 'Popover Popup', category: 'layout' },\n schema: {},\n guideline: 'Main popover content container. Always include Popover.Title for screen reader accessibility.',\n});\n\nexport const PopoverArrowDefinition = defineComponent<PopoverArrowProps>({\n name: 'PopoverArrow',\n importPath: '@vtex/faststore/components',\n component: PopoverArrow,\n editor: { label: 'Popover Arrow', category: 'layout' },\n schema: {},\n guideline: 'Pointing arrow attached to the popup. Optional — omit when not using an arrow indicator.',\n});\n\nexport const PopoverViewportDefinition = defineComponent<PopoverViewportProps>({\n name: 'PopoverViewport',\n importPath: '@vtex/faststore/components',\n component: PopoverViewport,\n editor: { label: 'Popover Viewport', category: 'layout' },\n schema: {},\n guideline: 'Viewport wrapper inside Popover.Popup for constraining content display area.',\n});\n\nexport const PopoverTitleDefinition = defineComponent<PopoverTitleProps>({\n name: 'PopoverTitle',\n importPath: '@vtex/faststore/components',\n component: PopoverTitle,\n editor: { label: 'Popover Title', category: 'layout' },\n schema: {},\n guideline: 'Accessible heading inside Popover.Popup. Sets the accessible name of the popover dialog.',\n});\n\nexport const PopoverDescriptionDefinition = defineComponent<PopoverDescriptionProps>({\n name: 'PopoverDescription',\n importPath: '@vtex/faststore/components',\n component: PopoverDescription,\n editor: { label: 'Popover Description', category: 'layout' },\n schema: {},\n guideline: 'Accessible description of the popover content. Announced by screen readers.',\n});\n\nexport const PopoverCloseDefinition = defineComponent<PopoverCloseProps>({\n name: 'PopoverClose',\n importPath: '@vtex/faststore/components',\n component: PopoverClose,\n editor: { label: 'Popover Close', category: 'action' },\n schema: {},\n guideline: 'Button that closes the popover. Place inside Popover.Popup.',\n});\n\nexport function PopoverRoot({ defaultOpen = false, modal = false, children }: PopoverRootProps) {\n return (\n <BasePopover.Root defaultOpen={defaultOpen} modal={modal}>\n {children}\n </BasePopover.Root>\n );\n}\n\nexport function PopoverTrigger({\n openOnHover = false,\n delay = 300,\n closeDelay,\n className,\n children,\n ...props\n}: PopoverTriggerProps) {\n return (\n <BasePopover.Trigger\n {...props}\n openOnHover={openOnHover}\n delay={delay}\n closeDelay={closeDelay}\n className={className}\n data-fs-popover-trigger=\"\"\n >\n {children}\n </BasePopover.Trigger>\n );\n}\n\nexport function PopoverPortal({ children }: PopoverPortalProps) {\n return <BasePopover.Portal>{children}</BasePopover.Portal>;\n}\n\nexport function PopoverBackdrop({ className, children, ...props }: PopoverBackdropProps) {\n return (\n <BasePopover.Backdrop {...props} className={className} data-fs-popover-backdrop=\"\">\n {children}\n </BasePopover.Backdrop>\n );\n}\n\nexport function PopoverPositioner({\n side = 'bottom',\n align = 'center',\n sideOffset = 0,\n className,\n children,\n ...props\n}: PopoverPositionerProps) {\n return (\n <BasePopover.Positioner\n {...props}\n side={side}\n align={align}\n sideOffset={sideOffset}\n className={className}\n data-fs-popover-positioner=\"\"\n >\n {children}\n </BasePopover.Positioner>\n );\n}\n\nexport function PopoverPopup({ className, children, ...props }: PopoverPopupProps) {\n return (\n <BasePopover.Popup {...props} className={className} data-fs-popover-popup=\"\">\n {children}\n </BasePopover.Popup>\n );\n}\n\nexport function PopoverArrow({ className, children, ...props }: PopoverArrowProps) {\n return (\n <BasePopover.Arrow {...props} className={className} data-fs-popover-arrow=\"\">\n {children}\n </BasePopover.Arrow>\n );\n}\n\nexport function PopoverViewport({ className, children, ...props }: PopoverViewportProps) {\n return (\n <BasePopover.Viewport {...props} className={className} data-fs-popover-viewport=\"\">\n {children}\n </BasePopover.Viewport>\n );\n}\n\nexport function PopoverTitle({ className, children, ...props }: PopoverTitleProps) {\n return (\n <BasePopover.Title {...props} className={className} data-fs-popover-title=\"\">\n {children}\n </BasePopover.Title>\n );\n}\n\nexport function PopoverDescription({ className, children, ...props }: PopoverDescriptionProps) {\n return (\n <BasePopover.Description {...props} className={className} data-fs-popover-description=\"\">\n {children}\n </BasePopover.Description>\n );\n}\n\nexport function PopoverClose({ className, children, ...props }: PopoverCloseProps) {\n return (\n <BasePopover.Close {...props} className={className} data-fs-popover-close=\"\">\n {children}\n </BasePopover.Close>\n );\n}\n\nexport const Popover = {\n Root: PopoverRoot,\n Trigger: PopoverTrigger,\n Portal: PopoverPortal,\n Backdrop: PopoverBackdrop,\n Positioner: PopoverPositioner,\n Popup: PopoverPopup,\n Arrow: PopoverArrow,\n Viewport: PopoverViewport,\n Title: PopoverTitle,\n Description: PopoverDescription,\n Close: PopoverClose,\n};\n"],"mappings":";;;;;;AA4CA,MAAa,wBAAwB,gBAAkC;CACrE,MAAM;CACN,YAAY;CACZ,WAAW;CACX,QAAQ;EAAE,OAAO;EAAgB,UAAU;CAAS;CACpD,QAAQ;EACN,aAAa;GAAE,MAAM;GAAW,SAAS;GAAO,OAAO;EAAe;EACtE,OAAO;GAAE,MAAM;GAAW,SAAS;GAAO,OAAO;EAAQ;CAC3D;CACA,WACE;AACJ,CAAC;AAED,MAAa,2BAA2B,gBAAqC;CAC3E,MAAM;CACN,YAAY;CACZ,WAAW;CACX,QAAQ;EAAE,OAAO;EAAmB,UAAU;CAAS;CACvD,QAAQ;EACN,aAAa;GAAE,MAAM;GAAW,SAAS;GAAO,OAAO;EAAgB;EACvE,OAAO;GAAE,MAAM;GAAU,SAAS;GAAK,OAAO;EAAQ;EACtD,YAAY;GAAE,MAAM;GAAU,SAAS;GAAG,OAAO;EAAc;CACjE;CACA,WAAW;AACb,CAAC;AAED,MAAa,0BAA0B,gBAAoC;CACzE,MAAM;CACN,YAAY;CACZ,WAAW;CACX,QAAQ;EAAE,OAAO;EAAkB,UAAU;CAAS;CACtD,QAAQ,CAAC;CACT,WAAW;AACb,CAAC;AAED,MAAa,4BAA4B,gBAAsC;CAC7E,MAAM;CACN,YAAY;CACZ,WAAW;CACX,QAAQ;EAAE,OAAO;EAAoB,UAAU;CAAS;CACxD,QAAQ,CAAC;CACT,WAAW;AACb,CAAC;AAED,MAAa,8BAA8B,gBAAwC;CACjF,MAAM;CACN,YAAY;CACZ,WAAW;CACX,QAAQ;EAAE,OAAO;EAAsB,UAAU;CAAS;CAC1D,QAAQ;EACN,MAAM;GAAE,MAAM;IAAC;IAAO;IAAU;IAAQ;GAAO;GAAY,SAAS;GAAU,OAAO;EAAO;EAC5F,OAAO;GAAE,MAAM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gB,aAAa,EAAE,WAAW,UAAU,GAAG,SAA4B;CACjF,OACE,oBAACA,QAAY,OAAb;EAAmB,GAAI;EAAkB;EAAW,yBAAsB;EACvE;CACgB,CAAA;AAEvB;AAEA,MAAaC,YAAU;CACrB,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,OAAO;CACP,OAAO;CACP,UAAU;CACV,OAAO;CACP,aAAa;CACb,OAAO;AACT"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ContentValue } from "../../core/dist/define-content-type.js";
|
|
2
|
+
import { ComponentDefinition } from "../../core/dist/define-component.js";
|
|
3
|
+
import "../../core/dist/index.js";
|
|
4
|
+
import { ComponentPropsWithRef, FocusEvent } from "react";
|
|
5
|
+
//#region src/particles/postal-code-field/postal-code-field.d.ts
|
|
6
|
+
export declare const PostalCodeFieldContent: {
|
|
7
|
+
readonly id: "postal-code-field";
|
|
8
|
+
readonly title: "Postal Code Field";
|
|
9
|
+
readonly description: "Editorial copy for the postal-code input.";
|
|
10
|
+
readonly schema: {
|
|
11
|
+
readonly type: "object";
|
|
12
|
+
readonly additionalProperties: false;
|
|
13
|
+
readonly properties: {
|
|
14
|
+
readonly label: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly title: "Label";
|
|
17
|
+
};
|
|
18
|
+
readonly placeholder: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly title: "Placeholder";
|
|
21
|
+
};
|
|
22
|
+
readonly errorMessage: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly title: "Error message";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type PostalCodeFieldProps = Omit<ComponentPropsWithRef<'div'>, 'defaultValue' | 'value' | 'onChange' | 'onBlur'> & {
|
|
30
|
+
/** Mask template: `9` digit, `A` alpha, `S` alphanumeric, `*` any, interleaved with literals.
|
|
31
|
+
* Pipe-delimited alternates (`99999|99999-999`) cover formats of different lengths. */
|
|
32
|
+
mask?: string;
|
|
33
|
+
label?: string;
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
errorMessage?: string;
|
|
36
|
+
/** Controlled value; masked on render, so a raw value is accepted. */
|
|
37
|
+
value?: string;
|
|
38
|
+
defaultValue?: string;
|
|
39
|
+
/** Called with the masked value on every change. */
|
|
40
|
+
onValueChange?: (value: string) => void;
|
|
41
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
42
|
+
/** Host-forced invalid state (e.g. a server rejection); ORs with the internal blur verdict. */
|
|
43
|
+
invalid?: boolean;
|
|
44
|
+
required?: boolean;
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
name?: string;
|
|
47
|
+
/** Merchant-authored copy, sliced from the page/layout content entry; wins over the props when
|
|
48
|
+
* present. Absent in a non-CMS store — the props are the fallback. The mask is not authored here:
|
|
49
|
+
* it is a build-time schema prop. */
|
|
50
|
+
$content?: ContentValue<typeof PostalCodeFieldContent>;
|
|
51
|
+
};
|
|
52
|
+
/** Remove the mask's literal separators, leaving only slot characters. */
|
|
53
|
+
export declare function stripPostalCodeMask(value: string, mask: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Sanitize (digit-only masks), truncate to the mask's slot count, then apply the mask. Idempotent:
|
|
56
|
+
* stripping the literals first means an already-masked value and a raw one produce the same display.
|
|
57
|
+
*/
|
|
58
|
+
export declare function applyPostalCodeMask(rawValue: string, mask: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* True when the value fills every slot of the mask — of any mask in a pipe-delimited set, so a
|
|
61
|
+
* shorter alternate counts as complete. An empty value is NOT complete: emptiness is the host's
|
|
62
|
+
* submit-gating concern, not this field's.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isPostalCodeComplete(value: string, mask: string): boolean;
|
|
65
|
+
export declare const PostalCodeFieldDefinition: ComponentDefinition<PostalCodeFieldProps>;
|
|
66
|
+
/**
|
|
67
|
+
* Presentational postal-code input (particle). Composes the `Field` and `Input` particles and owns
|
|
68
|
+
* one piece of logic: applying the configured mask template on every change, plus a blur verdict on
|
|
69
|
+
* whether the value fills the mask. It is country-agnostic — the pattern is configuration, not a
|
|
70
|
+
* country table — and data-agnostic: the value, the submit, and the server's verdict belong to the
|
|
71
|
+
* host, which surfaces a rejection through `invalid` + `errorMessage`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function PostalCodeField({ mask, label, placeholder, errorMessage, value, defaultValue, onValueChange, onBlur, invalid, required, disabled, name, $content, className, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, ...props }: PostalCodeFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
74
|
+
//#endregion
|
|
75
|
+
//# sourceMappingURL=postal-code-field.d.ts.map
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import { defineContentType } from "../../core/dist/define-content-type.js";
|
|
4
|
+
import "../../core/dist/index.js";
|
|
5
|
+
import { Field } from "../field/field.js";
|
|
6
|
+
import { Input } from "../input/input.js";
|
|
7
|
+
import { applyMask, countSlots, isDigitOnly, isSlotToken } from "../shared/input-mask.js";
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/particles/postal-code-field/postal-code-field.tsx
|
|
11
|
+
/** Brazilian CEP. */
|
|
12
|
+
const DEFAULT_MASK = "99999-999";
|
|
13
|
+
const PostalCodeFieldContent = defineContentType({
|
|
14
|
+
id: "postal-code-field",
|
|
15
|
+
title: "Postal Code Field",
|
|
16
|
+
description: "Editorial copy for the postal-code input.",
|
|
17
|
+
schema: {
|
|
18
|
+
type: "object",
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
properties: {
|
|
21
|
+
label: {
|
|
22
|
+
type: "string",
|
|
23
|
+
title: "Label"
|
|
24
|
+
},
|
|
25
|
+
placeholder: {
|
|
26
|
+
type: "string",
|
|
27
|
+
title: "Placeholder"
|
|
28
|
+
},
|
|
29
|
+
errorMessage: {
|
|
30
|
+
type: "string",
|
|
31
|
+
title: "Error message"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
/** Slot count of the longest mask in a (possibly pipe-delimited) template. */
|
|
37
|
+
function maxSlots(mask) {
|
|
38
|
+
return Math.max(...mask.split("|").map(countSlots));
|
|
39
|
+
}
|
|
40
|
+
/** Remove the mask's literal separators, leaving only slot characters. */
|
|
41
|
+
function stripPostalCodeMask(value, mask) {
|
|
42
|
+
const literals = new Set([...mask].filter((char) => char !== "|" && !isSlotToken(char)));
|
|
43
|
+
return [...value].filter((char) => !literals.has(char)).join("");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sanitize (digit-only masks), truncate to the mask's slot count, then apply the mask. Idempotent:
|
|
47
|
+
* stripping the literals first means an already-masked value and a raw one produce the same display.
|
|
48
|
+
*/
|
|
49
|
+
function applyPostalCodeMask(rawValue, mask) {
|
|
50
|
+
const slotChars = stripPostalCodeMask(rawValue, mask);
|
|
51
|
+
const sanitized = isDigitOnly(mask) ? slotChars.replaceAll(/\D/g, "") : slotChars;
|
|
52
|
+
return applyMask(sanitized.slice(0, maxSlots(mask)), mask);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* True when the value fills every slot of the mask — of any mask in a pipe-delimited set, so a
|
|
56
|
+
* shorter alternate counts as complete. An empty value is NOT complete: emptiness is the host's
|
|
57
|
+
* submit-gating concern, not this field's.
|
|
58
|
+
*/
|
|
59
|
+
function isPostalCodeComplete(value, mask) {
|
|
60
|
+
const slotChars = stripPostalCodeMask(value, mask);
|
|
61
|
+
if (!slotChars) return false;
|
|
62
|
+
return mask.split("|").some((single) => slotChars.length === countSlots(single));
|
|
63
|
+
}
|
|
64
|
+
const PostalCodeFieldDefinition = defineComponent({
|
|
65
|
+
name: "PostalCodeField",
|
|
66
|
+
importPath: "@vtex/faststore/components",
|
|
67
|
+
component: PostalCodeField,
|
|
68
|
+
content: PostalCodeFieldContent,
|
|
69
|
+
editor: {
|
|
70
|
+
label: "Postal Code Field",
|
|
71
|
+
category: "content"
|
|
72
|
+
},
|
|
73
|
+
schema: {
|
|
74
|
+
mask: {
|
|
75
|
+
type: "string",
|
|
76
|
+
default: DEFAULT_MASK,
|
|
77
|
+
label: "Mask pattern"
|
|
78
|
+
},
|
|
79
|
+
label: {
|
|
80
|
+
type: "string",
|
|
81
|
+
label: "Label"
|
|
82
|
+
},
|
|
83
|
+
placeholder: {
|
|
84
|
+
type: "string",
|
|
85
|
+
label: "Placeholder"
|
|
86
|
+
},
|
|
87
|
+
errorMessage: {
|
|
88
|
+
type: "string",
|
|
89
|
+
label: "Error message"
|
|
90
|
+
},
|
|
91
|
+
required: {
|
|
92
|
+
type: "boolean",
|
|
93
|
+
default: false,
|
|
94
|
+
label: "Required"
|
|
95
|
+
},
|
|
96
|
+
disabled: {
|
|
97
|
+
type: "boolean",
|
|
98
|
+
default: false,
|
|
99
|
+
label: "Disabled"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
guideline: "Presentational postal-code input composing the Field and Input particles; formats the value against the configured mask template as the shopper types and flags an incomplete value on blur. Data-agnostic (value/defaultValue/onValueChange) — a host such as the region modal owns submission and surfaces server errors through invalid/errorMessage. Set mask to the country format at build time (default 99999-999, BR CEP); the CMS edits only label, placeholder, and error copy."
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* Presentational postal-code input (particle). Composes the `Field` and `Input` particles and owns
|
|
106
|
+
* one piece of logic: applying the configured mask template on every change, plus a blur verdict on
|
|
107
|
+
* whether the value fills the mask. It is country-agnostic — the pattern is configuration, not a
|
|
108
|
+
* country table — and data-agnostic: the value, the submit, and the server's verdict belong to the
|
|
109
|
+
* host, which surfaces a rejection through `invalid` + `errorMessage`.
|
|
110
|
+
*/
|
|
111
|
+
function PostalCodeField({ mask = DEFAULT_MASK, label, placeholder, errorMessage, value, defaultValue = "", onValueChange, onBlur, invalid = false, required = false, disabled = false, name = "postalCode", $content, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
|
|
112
|
+
const isControlled = value !== void 0;
|
|
113
|
+
const [internalValue, setInternalValue] = useState(() => applyPostalCodeMask(defaultValue, mask));
|
|
114
|
+
const [blurInvalid, setBlurInvalid] = useState(false);
|
|
115
|
+
const displayValue = applyPostalCodeMask(isControlled ? value : internalValue, mask);
|
|
116
|
+
const showInvalid = invalid || blurInvalid;
|
|
117
|
+
const numericOnly = isDigitOnly(mask);
|
|
118
|
+
const resolvedLabel = $content?.label?.trim() ? $content.label : label;
|
|
119
|
+
const resolvedPlaceholder = $content?.placeholder?.trim() ? $content.placeholder : placeholder;
|
|
120
|
+
const resolvedError = $content?.errorMessage?.trim() ? $content.errorMessage : errorMessage;
|
|
121
|
+
function handleChange(event) {
|
|
122
|
+
const masked = applyPostalCodeMask(event.target.value, mask);
|
|
123
|
+
if (!isControlled) setInternalValue(masked);
|
|
124
|
+
if (blurInvalid) setBlurInvalid(false);
|
|
125
|
+
onValueChange?.(masked);
|
|
126
|
+
}
|
|
127
|
+
function handleBlur(event) {
|
|
128
|
+
setBlurInvalid(displayValue.trim() !== "" && !isPostalCodeComplete(displayValue, mask));
|
|
129
|
+
onBlur?.(event);
|
|
130
|
+
}
|
|
131
|
+
return /* @__PURE__ */ jsxs(Field.Root, {
|
|
132
|
+
...props,
|
|
133
|
+
className,
|
|
134
|
+
name,
|
|
135
|
+
invalid: showInvalid,
|
|
136
|
+
disabled,
|
|
137
|
+
"data-fs-postal-code-field": "",
|
|
138
|
+
children: [
|
|
139
|
+
resolvedLabel ? /* @__PURE__ */ jsx(Field.Label, {
|
|
140
|
+
"data-fs-postal-code-field-label": "",
|
|
141
|
+
children: resolvedLabel
|
|
142
|
+
}) : null,
|
|
143
|
+
/* @__PURE__ */ jsx(Input, {
|
|
144
|
+
"data-fs-postal-code-field-input": "",
|
|
145
|
+
type: "text",
|
|
146
|
+
name,
|
|
147
|
+
required,
|
|
148
|
+
disabled,
|
|
149
|
+
placeholder: resolvedPlaceholder,
|
|
150
|
+
"aria-label": ariaLabel,
|
|
151
|
+
"aria-labelledby": ariaLabelledBy,
|
|
152
|
+
autoComplete: "postal-code",
|
|
153
|
+
value: displayValue,
|
|
154
|
+
...numericOnly ? { inputMode: "numeric" } : {},
|
|
155
|
+
onChange: handleChange,
|
|
156
|
+
onBlur: handleBlur
|
|
157
|
+
}),
|
|
158
|
+
showInvalid && resolvedError ? /* @__PURE__ */ jsx(Field.Error, {
|
|
159
|
+
match: true,
|
|
160
|
+
"data-fs-postal-code-field-error": "",
|
|
161
|
+
children: resolvedError
|
|
162
|
+
}) : null
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
export { PostalCodeField, PostalCodeFieldContent, PostalCodeFieldDefinition, applyPostalCodeMask, isPostalCodeComplete, stripPostalCodeMask };
|
|
168
|
+
|
|
169
|
+
//# sourceMappingURL=postal-code-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postal-code-field.js","names":[],"sources":["../../../src/particles/postal-code-field/postal-code-field.tsx"],"sourcesContent":["'use client';\nimport { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport type { ChangeEvent, ComponentPropsWithRef, FocusEvent } from 'react';\nimport { useState } from 'react';\nimport { Field } from '../field/field.js';\nimport { Input } from '../input/input.js';\nimport { applyMask, countSlots, isDigitOnly, isSlotToken } from '../shared/input-mask.js';\n\n/** Brazilian CEP. */\nconst DEFAULT_MASK = '99999-999';\n\nexport const PostalCodeFieldContent = defineContentType({\n id: 'postal-code-field',\n title: 'Postal Code Field',\n description: 'Editorial copy for the postal-code input.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Label' },\n placeholder: { type: 'string', title: 'Placeholder' },\n errorMessage: { type: 'string', title: 'Error message' },\n },\n },\n});\n\nexport type PostalCodeFieldProps = Omit<\n ComponentPropsWithRef<'div'>,\n 'defaultValue' | 'value' | 'onChange' | 'onBlur'\n> & {\n /** Mask template: `9` digit, `A` alpha, `S` alphanumeric, `*` any, interleaved with literals.\n * Pipe-delimited alternates (`99999|99999-999`) cover formats of different lengths. */\n mask?: string;\n label?: string;\n placeholder?: string;\n errorMessage?: string;\n /** Controlled value; masked on render, so a raw value is accepted. */\n value?: string;\n defaultValue?: string;\n /** Called with the masked value on every change. */\n onValueChange?: (value: string) => void;\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void;\n /** Host-forced invalid state (e.g. a server rejection); ORs with the internal blur verdict. */\n invalid?: boolean;\n required?: boolean;\n disabled?: boolean;\n name?: string;\n /** Merchant-authored copy, sliced from the page/layout content entry; wins over the props when\n * present. Absent in a non-CMS store — the props are the fallback. The mask is not authored here:\n * it is a build-time schema prop. */\n $content?: ContentValue<typeof PostalCodeFieldContent>;\n};\n\n/** Slot count of the longest mask in a (possibly pipe-delimited) template. */\nfunction maxSlots(mask: string): number {\n return Math.max(...mask.split('|').map(countSlots));\n}\n\n/** Remove the mask's literal separators, leaving only slot characters. */\nexport function stripPostalCodeMask(value: string, mask: string): string {\n const literals = new Set([...mask].filter((char) => char !== '|' && !isSlotToken(char)));\n return [...value].filter((char) => !literals.has(char)).join('');\n}\n\n/**\n * Sanitize (digit-only masks), truncate to the mask's slot count, then apply the mask. Idempotent:\n * stripping the literals first means an already-masked value and a raw one produce the same display.\n */\nexport function applyPostalCodeMask(rawValue: string, mask: string): string {\n const slotChars = stripPostalCodeMask(rawValue, mask);\n const sanitized = isDigitOnly(mask) ? slotChars.replaceAll(/\\D/g, '') : slotChars;\n return applyMask(sanitized.slice(0, maxSlots(mask)), mask);\n}\n\n/**\n * True when the value fills every slot of the mask — of any mask in a pipe-delimited set, so a\n * shorter alternate counts as complete. An empty value is NOT complete: emptiness is the host's\n * submit-gating concern, not this field's.\n */\nexport function isPostalCodeComplete(value: string, mask: string): boolean {\n const slotChars = stripPostalCodeMask(value, mask);\n if (!slotChars) return false;\n return mask.split('|').some((single) => slotChars.length === countSlots(single));\n}\n\nexport const PostalCodeFieldDefinition = defineComponent<PostalCodeFieldProps>({\n name: 'PostalCodeField',\n importPath: '@vtex/faststore/components',\n component: PostalCodeField,\n content: PostalCodeFieldContent,\n editor: { label: 'Postal Code Field', category: 'content' },\n schema: {\n mask: { type: 'string', default: DEFAULT_MASK, label: 'Mask pattern' },\n label: { type: 'string', label: 'Label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n errorMessage: { type: 'string', label: 'Error message' },\n required: { type: 'boolean', default: false, label: 'Required' },\n disabled: { type: 'boolean', default: false, label: 'Disabled' },\n },\n guideline:\n 'Presentational postal-code input composing the Field and Input particles; formats the value against the configured mask template as the shopper types and flags an incomplete value on blur. Data-agnostic (value/defaultValue/onValueChange) — a host such as the region modal owns submission and surfaces server errors through invalid/errorMessage. Set mask to the country format at build time (default 99999-999, BR CEP); the CMS edits only label, placeholder, and error copy.',\n});\n\n/**\n * Presentational postal-code input (particle). Composes the `Field` and `Input` particles and owns\n * one piece of logic: applying the configured mask template on every change, plus a blur verdict on\n * whether the value fills the mask. It is country-agnostic — the pattern is configuration, not a\n * country table — and data-agnostic: the value, the submit, and the server's verdict belong to the\n * host, which surfaces a rejection through `invalid` + `errorMessage`.\n */\nexport function PostalCodeField({\n mask = DEFAULT_MASK,\n label,\n placeholder,\n errorMessage,\n value,\n defaultValue = '',\n onValueChange,\n onBlur,\n invalid = false,\n required = false,\n disabled = false,\n name = 'postalCode',\n $content,\n className,\n // Naming attributes belong on the control, not on the root the rest of the props land on. They are\n // the only way to name the field when no label resolves.\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n}: PostalCodeFieldProps) {\n const isControlled = value !== undefined;\n const [internalValue, setInternalValue] = useState(() => applyPostalCodeMask(defaultValue, mask));\n const [blurInvalid, setBlurInvalid] = useState(false);\n\n const currentValue = isControlled ? value : internalValue;\n const displayValue = applyPostalCodeMask(currentValue, mask);\n const showInvalid = invalid || blurInvalid;\n const numericOnly = isDigitOnly(mask);\n\n // Each content field falls back on its own, so a cleared one keeps the authored prop.\n const resolvedLabel = $content?.label?.trim() ? $content.label : label;\n const resolvedPlaceholder = $content?.placeholder?.trim() ? $content.placeholder : placeholder;\n const resolvedError = $content?.errorMessage?.trim() ? $content.errorMessage : errorMessage;\n\n function handleChange(event: ChangeEvent<HTMLInputElement>) {\n const masked = applyPostalCodeMask(event.target.value, mask);\n if (!isControlled) setInternalValue(masked);\n // Clear a prior blur verdict while typing; it is re-evaluated on the next blur.\n if (blurInvalid) setBlurInvalid(false);\n onValueChange?.(masked);\n }\n\n function handleBlur(event: FocusEvent<HTMLInputElement>) {\n // Judge the displayed value: a host can hand over a raw one carrying characters the mask drops,\n // and a verdict on those would contradict what the shopper sees.\n setBlurInvalid(displayValue.trim() !== '' && !isPostalCodeComplete(displayValue, mask));\n onBlur?.(event);\n }\n\n return (\n <Field.Root\n {...props}\n className={className}\n name={name}\n invalid={showInvalid}\n disabled={disabled}\n data-fs-postal-code-field=\"\"\n >\n {resolvedLabel ? <Field.Label data-fs-postal-code-field-label=\"\">{resolvedLabel}</Field.Label> : null}\n {/* `Input` wires into `Field.Root` on its own — no `Field.Control` wrapper. */}\n <Input\n data-fs-postal-code-field-input=\"\"\n type=\"text\"\n name={name}\n required={required}\n disabled={disabled}\n placeholder={resolvedPlaceholder}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n autoComplete=\"postal-code\"\n value={displayValue}\n {...(numericOnly ? { inputMode: 'numeric' as const } : {})}\n onChange={handleChange}\n onBlur={handleBlur}\n />\n {showInvalid && resolvedError ? (\n <Field.Error match data-fs-postal-code-field-error=\"\">\n {resolvedError}\n </Field.Error>\n ) : null}\n </Field.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;AASA,MAAM,eAAe;AAErB,MAAa,yBAAyB,kBAAkB;CACtD,IAAI;C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AAgB,oBAAC,MAAM,OAAP;IAAa,mCAAgC;IAAI,UAAA;GAA2B,CAAA,IAAI;GAEjG,oBAAC,OAAD;IACE,mCAAgC;IAChC,MAAK;IACC;IACI;IACA;IACV,aAAa;IACb,cAAY;IACZ,mBAAiB;IACjB,cAAa;IACb,OAAO;IACP,GAAK,cAAc,EAAE,WAAW,UAAmB,IAAI,CAAC;IACxD,UAAU;IACV,QAAQ;GACT,CAAA;GACA,eAAe,gBACd,oBAAC,MAAM,OAAP;IAAa,OAAA;IAAM,mCAAgC;IAChD,UAAA;GACU,CAAA,IACX;EACM;;AAEhB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ContentValue } from "../../core/dist/define-content-type.js";
|
|
2
|
+
import { ComponentDefinition } from "../../core/dist/define-component.js";
|
|
3
|
+
import "../../core/dist/index.js";
|
|
4
|
+
import { ComponentPropsWithRef } from "react";
|
|
5
|
+
//#region src/particles/promotion/promotion.d.ts
|
|
6
|
+
export declare const PromotionContent: {
|
|
7
|
+
readonly id: "promotion";
|
|
8
|
+
readonly title: "Promotion";
|
|
9
|
+
readonly description: "Editorial fields for a promotional callout.";
|
|
10
|
+
readonly schema: {
|
|
11
|
+
readonly type: "object";
|
|
12
|
+
readonly additionalProperties: false;
|
|
13
|
+
readonly required: readonly ["title", "body"];
|
|
14
|
+
readonly properties: {
|
|
15
|
+
readonly title: {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
readonly minLength: 1;
|
|
18
|
+
readonly title: "Title";
|
|
19
|
+
};
|
|
20
|
+
readonly body: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly title: "Body";
|
|
23
|
+
};
|
|
24
|
+
readonly image: {
|
|
25
|
+
readonly type: "string";
|
|
26
|
+
readonly format: "uri";
|
|
27
|
+
readonly title: "Image";
|
|
28
|
+
readonly widget: {
|
|
29
|
+
readonly 'ui:widget': "media-gallery";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly imageAlt: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly title: "Image alt text";
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type PromotionProps = ComponentPropsWithRef<'section'> & {
|
|
40
|
+
/** Injected by the compiler, sliced from the page's or layout's composite content entry. */
|
|
41
|
+
$content?: ContentValue<typeof PromotionContent>;
|
|
42
|
+
};
|
|
43
|
+
export declare const PromotionDefinition: ComponentDefinition<PromotionProps>;
|
|
44
|
+
export declare function Promotion({ $content, className, ...props }: PromotionProps): import("react/jsx-runtime").JSX.Element | null;
|
|
45
|
+
//#endregion
|
|
46
|
+
//# sourceMappingURL=promotion.d.ts.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { defineComponent } from "../../core/dist/define-component.js";
|
|
2
|
+
import { defineContentType } from "../../core/dist/define-content-type.js";
|
|
3
|
+
import "../../core/dist/index.js";
|
|
4
|
+
import { Image } from "../image/image.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/particles/promotion/promotion.tsx
|
|
7
|
+
const PromotionContent = defineContentType({
|
|
8
|
+
id: "promotion",
|
|
9
|
+
title: "Promotion",
|
|
10
|
+
description: "Editorial fields for a promotional callout.",
|
|
11
|
+
schema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
required: ["title", "body"],
|
|
15
|
+
properties: {
|
|
16
|
+
title: {
|
|
17
|
+
type: "string",
|
|
18
|
+
minLength: 1,
|
|
19
|
+
title: "Title"
|
|
20
|
+
},
|
|
21
|
+
body: {
|
|
22
|
+
type: "string",
|
|
23
|
+
title: "Body"
|
|
24
|
+
},
|
|
25
|
+
image: {
|
|
26
|
+
type: "string",
|
|
27
|
+
format: "uri",
|
|
28
|
+
title: "Image",
|
|
29
|
+
widget: { "ui:widget": "media-gallery" }
|
|
30
|
+
},
|
|
31
|
+
imageAlt: {
|
|
32
|
+
type: "string",
|
|
33
|
+
title: "Image alt text"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const PromotionDefinition = defineComponent({
|
|
39
|
+
name: "Promotion",
|
|
40
|
+
importPath: "@vtex/faststore/components",
|
|
41
|
+
component: Promotion,
|
|
42
|
+
content: PromotionContent,
|
|
43
|
+
editor: {
|
|
44
|
+
label: "Promotion",
|
|
45
|
+
category: "content"
|
|
46
|
+
},
|
|
47
|
+
schema: {},
|
|
48
|
+
guideline: "Editorial promotional callout driven entirely by CMS content. See promotion.md."
|
|
49
|
+
});
|
|
50
|
+
function Promotion({ $content, className, ...props }) {
|
|
51
|
+
if (!$content) return null;
|
|
52
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
53
|
+
...props,
|
|
54
|
+
className,
|
|
55
|
+
"data-fs-promotion": "",
|
|
56
|
+
children: [
|
|
57
|
+
$content.image ? /* @__PURE__ */ jsx(Image, {
|
|
58
|
+
src: $content.image,
|
|
59
|
+
alt: $content.imageAlt ?? "",
|
|
60
|
+
"data-fs-promotion-image": ""
|
|
61
|
+
}) : null,
|
|
62
|
+
/* @__PURE__ */ jsx("h2", {
|
|
63
|
+
"data-fs-text": "",
|
|
64
|
+
"data-fs-text-variant": "heading",
|
|
65
|
+
"data-fs-promotion-title": "",
|
|
66
|
+
children: $content.title
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ jsx("p", {
|
|
69
|
+
"data-fs-promotion-body": "",
|
|
70
|
+
children: $content.body
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { Promotion, PromotionContent, PromotionDefinition };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=promotion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promotion.js","names":[],"sources":["../../../src/particles/promotion/promotion.tsx"],"sourcesContent":["import { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { Image } from '../image/image.js';\n\n// ---------------------------------------------------------------------------\n// Content model\n// ---------------------------------------------------------------------------\n\nexport const PromotionContent = defineContentType({\n id: 'promotion',\n title: 'Promotion',\n description: 'Editorial fields for a promotional callout.',\n schema: {\n type: 'object',\n additionalProperties: false,\n required: ['title', 'body'],\n properties: {\n title: { type: 'string', minLength: 1, title: 'Title' },\n body: { type: 'string', title: 'Body' },\n image: { type: 'string', format: 'uri', title: 'Image', widget: { 'ui:widget': 'media-gallery' } },\n imageAlt: { type: 'string', title: 'Image alt text' },\n },\n },\n});\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type PromotionProps = ComponentPropsWithRef<'section'> & {\n /** Injected by the compiler, sliced from the page's or layout's composite content entry. */\n $content?: ContentValue<typeof PromotionContent>;\n};\n\n// ---------------------------------------------------------------------------\n// Definition\n// ---------------------------------------------------------------------------\n\nexport const PromotionDefinition = defineComponent({\n name: 'Promotion',\n importPath: '@vtex/faststore/components',\n component: Promotion,\n content: PromotionContent,\n editor: { label: 'Promotion', category: 'content' },\n schema: {},\n guideline: 'Editorial promotional callout driven entirely by CMS content. See promotion.md.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\nexport function Promotion({ $content, className, ...props }: PromotionProps) {\n if (!$content) return null;\n\n return (\n <section {...props} className={className} data-fs-promotion=\"\">\n {$content.image ? <Image src={$content.image} alt={$content.imageAlt ?? ''} data-fs-promotion-image=\"\" /> : null}\n <h2 data-fs-text=\"\" data-fs-text-variant=\"heading\" data-fs-promotion-title=\"\">\n {$content.title}\n </h2>\n <p data-fs-promotion-body=\"\">{$content.body}</p>\n </section>\n );\n}\n"],"mappings":";;;;;;AAQA,MAAa,mBAAmB,kBAAkB;CAChD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,UAAU,CAAC,SAAS,MAAM;EAC1B,YAAY;GACV,OAAO;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAQ;GACtD,MAAM;IAAE,MAAM;IAAU,OAAO;GAAO;GACtC,OAAO;IAAE,MAAM;IAAU,QAAQ;IAAO,OAAO;IAAS,QAAQ,EAAE,aAAa,gBAAgB;GAAE;GACjG,UAAU;IAAE,MAAM;IAAU,OAAO;GAAiB;EACtD;CACF;AACF,CAAC;AAeD,MAAa,sBAAsB,gBAAgB;CACjD,MAAM;CACN,YAAY;CACZ,WAAW;CACX,SAAS;CACT,QAAQ;EAAE,OAAO;EAAa,UAAU;CAAU;CAClD,QAAQ,CAAC;CACT,WAAW;AACb,CAAC;AAMD,SAAgB,UAAU,EAAE,UAAU,WAAW,GAAG,SAAyB;CAC3E,IAAI,CAAC,UAAU,OAAO;CAEtB,OACE,qBAAC,WAAD;EAAS,GAAI;EAAkB;EAAW,qBAAkB;EAA5D,UAAA;GACG,SAAS,QAAQ,oBAAC,OAAD;IAAO,KAAK,SAAS;IAAO,KAAK,SAAS,YAAY;IAAI,2BAAwB;GAAI,CAAA,IAAI;GAC5G,oBAAC,MAAD;IAAI,gBAAa;IAAG,wBAAqB;IAAU,2BAAwB;IACxE,UAAA,SAAS;GACR,CAAA;GACJ,oBAAC,KAAD;IAAG,0BAAuB;IAAI,UAAA,SAAS;GAAQ,CAAA;EACxC;;AAEb"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentDefinition } from "../../core/dist/define-component.js";
|
|
2
|
+
import "../../core/dist/index.js";
|
|
3
|
+
import { ComponentPropsWithRef } from "react";
|
|
4
|
+
//#region src/particles/quantity-selector/quantity-selector.d.ts
|
|
5
|
+
export type QuantitySelectorRootProps = Omit<ComponentPropsWithRef<'div'>, 'defaultValue' | 'value'> & {
|
|
6
|
+
value?: number | null;
|
|
7
|
+
defaultValue?: number;
|
|
8
|
+
onQuantityChange?: (quantity: number | null) => void;
|
|
9
|
+
min?: number;
|
|
10
|
+
max?: number;
|
|
11
|
+
step?: number;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type QuantitySelectorMessageProps = ComponentPropsWithRef<'div'>;
|
|
15
|
+
/**
|
|
16
|
+
* Interim: the default copy lives in the component until the `@vtex/fs-i18n` operational-message
|
|
17
|
+
* catalog exists. Translations key off this stable id; a store overrides the copy via `children`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const QUANTITY_MAX_EXCEEDED_MESSAGE_ID = "quantity-selector.max-exceeded";
|
|
20
|
+
export declare function defaultMaxExceededMessage(max: number): string;
|
|
21
|
+
export declare const QuantitySelectorRootDefinition: ComponentDefinition<QuantitySelectorRootProps>;
|
|
22
|
+
export declare const QuantitySelectorMessageDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
23
|
+
export declare function QuantitySelectorRoot({ value, defaultValue, onQuantityChange, min, max, step, disabled, className, children, ...props }: QuantitySelectorRootProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function QuantitySelectorMessage({ className, children, ...props }: QuantitySelectorMessageProps): import("react/jsx-runtime").JSX.Element | null;
|
|
25
|
+
export declare const QuantitySelector: {
|
|
26
|
+
Root: typeof QuantitySelectorRoot;
|
|
27
|
+
Message: typeof QuantitySelectorMessage;
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//# sourceMappingURL=quantity-selector.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import "../../core/dist/index.js";
|
|
4
|
+
import { createContext, useContext, useMemo, useState } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { NumberField } from "@base-ui/react/number-field";
|
|
7
|
+
//#region src/particles/quantity-selector/quantity-selector.tsx
|
|
8
|
+
const QuantitySelectorContext = createContext({ exceededMax: null });
|
|
9
|
+
/**
|
|
10
|
+
* Interim: the default copy lives in the component until the `@vtex/fs-i18n` operational-message
|
|
11
|
+
* catalog exists. Translations key off this stable id; a store overrides the copy via `children`.
|
|
12
|
+
*/
|
|
13
|
+
const QUANTITY_MAX_EXCEEDED_MESSAGE_ID = "quantity-selector.max-exceeded";
|
|
14
|
+
function defaultMaxExceededMessage(max) {
|
|
15
|
+
return `Only ${max} available. Quantity adjusted to ${max}.`;
|
|
16
|
+
}
|
|
17
|
+
const QuantitySelectorRootDefinition = defineComponent({
|
|
18
|
+
name: "QuantitySelectorRoot",
|
|
19
|
+
importPath: "@vtex/faststore/components",
|
|
20
|
+
component: QuantitySelectorRoot,
|
|
21
|
+
editor: {
|
|
22
|
+
label: "Quantity Selector",
|
|
23
|
+
category: "form"
|
|
24
|
+
},
|
|
25
|
+
schema: {
|
|
26
|
+
defaultValue: {
|
|
27
|
+
type: "number",
|
|
28
|
+
default: 1,
|
|
29
|
+
label: "Default Quantity"
|
|
30
|
+
},
|
|
31
|
+
min: {
|
|
32
|
+
type: "number",
|
|
33
|
+
default: 1,
|
|
34
|
+
label: "Min Quantity"
|
|
35
|
+
},
|
|
36
|
+
max: {
|
|
37
|
+
type: "number",
|
|
38
|
+
label: "Max Quantity"
|
|
39
|
+
},
|
|
40
|
+
step: {
|
|
41
|
+
type: "number",
|
|
42
|
+
default: 1,
|
|
43
|
+
label: "Step"
|
|
44
|
+
},
|
|
45
|
+
disabled: {
|
|
46
|
+
type: "boolean",
|
|
47
|
+
default: false,
|
|
48
|
+
label: "Disabled"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
guideline: "Generic quantity selector. Wraps NumberField and manages value state. Compose as: QuantitySelectorRoot > NumberFieldGroup > NumberFieldDecrement + NumberFieldInput + NumberFieldIncrement. Add QuantitySelectorMessage to surface the max-exceeded message. On a PDP, bind `max` to product stock via $data."
|
|
52
|
+
});
|
|
53
|
+
const QuantitySelectorMessageDefinition = defineComponent({
|
|
54
|
+
name: "QuantitySelectorMessage",
|
|
55
|
+
importPath: "@vtex/faststore/components",
|
|
56
|
+
component: QuantitySelectorMessage,
|
|
57
|
+
editor: {
|
|
58
|
+
label: "Quantity Selector Message",
|
|
59
|
+
category: "form"
|
|
60
|
+
},
|
|
61
|
+
schema: {},
|
|
62
|
+
guideline: "Message shown when a shopper enters a quantity above `max` and it was clamped down; renders nothing otherwise. Must be a descendant of QuantitySelectorRoot. Set `children` to override the default copy."
|
|
63
|
+
});
|
|
64
|
+
function QuantitySelectorRoot({ value, defaultValue = 1, onQuantityChange, min = 1, max, step = 1, disabled, className, children, ...props }) {
|
|
65
|
+
const [exceededAt, setExceededAt] = useState(null);
|
|
66
|
+
const [maxJudgedAgainst, setMaxJudgedAgainst] = useState(max);
|
|
67
|
+
if (max !== maxJudgedAgainst) {
|
|
68
|
+
setMaxJudgedAgainst(max);
|
|
69
|
+
setExceededAt(null);
|
|
70
|
+
}
|
|
71
|
+
function handleValueChange(newValue) {
|
|
72
|
+
onQuantityChange?.(newValue);
|
|
73
|
+
}
|
|
74
|
+
function handleValueCommitted(committed) {
|
|
75
|
+
setExceededAt(max != null && committed != null && committed > max ? max : null);
|
|
76
|
+
}
|
|
77
|
+
const exceededMax = exceededAt != null && exceededAt === max ? exceededAt : null;
|
|
78
|
+
const context = useMemo(() => ({ exceededMax }), [exceededMax]);
|
|
79
|
+
return /* @__PURE__ */ jsx(NumberField.Root, {
|
|
80
|
+
...props,
|
|
81
|
+
value,
|
|
82
|
+
defaultValue: value === void 0 ? defaultValue : void 0,
|
|
83
|
+
onValueChange: handleValueChange,
|
|
84
|
+
onValueCommitted: handleValueCommitted,
|
|
85
|
+
min,
|
|
86
|
+
max,
|
|
87
|
+
step,
|
|
88
|
+
disabled,
|
|
89
|
+
className,
|
|
90
|
+
"data-fs-quantity-selector": "",
|
|
91
|
+
children: /* @__PURE__ */ jsx(QuantitySelectorContext, {
|
|
92
|
+
value: context,
|
|
93
|
+
children
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function QuantitySelectorMessage({ className, children, ...props }) {
|
|
98
|
+
const { exceededMax } = useContext(QuantitySelectorContext);
|
|
99
|
+
if (exceededMax == null) return null;
|
|
100
|
+
return /* @__PURE__ */ jsx("div", {
|
|
101
|
+
...props,
|
|
102
|
+
role: "status",
|
|
103
|
+
"aria-live": "polite",
|
|
104
|
+
className,
|
|
105
|
+
"data-fs-quantity-selector-message": "",
|
|
106
|
+
children: children ?? defaultMaxExceededMessage(exceededMax)
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const QuantitySelector = {
|
|
110
|
+
Root: QuantitySelectorRoot,
|
|
111
|
+
Message: QuantitySelectorMessage
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
export { QUANTITY_MAX_EXCEEDED_MESSAGE_ID, QuantitySelector, QuantitySelectorMessage, QuantitySelectorMessageDefinition, QuantitySelectorRoot, QuantitySelectorRootDefinition, defaultMaxExceededMessage };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=quantity-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quantity-selector.js","names":["BaseNumberField"],"sources":["../../../src/particles/quantity-selector/quantity-selector.tsx"],"sourcesContent":["'use client';\nimport { NumberField as BaseNumberField } from '@base-ui/react/number-field';\nimport { defineComponent } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { createContext, useContext, useMemo, useState } from 'react';\n\nexport type QuantitySelectorRootProps = Omit<ComponentPropsWithRef<'div'>, 'defaultValue' | 'value'> & {\n value?: number | null;\n defaultValue?: number;\n onQuantityChange?: (quantity: number | null) => void;\n min?: number;\n max?: number;\n step?: number;\n disabled?: boolean;\n};\n\nexport type QuantitySelectorMessageProps = ComponentPropsWithRef<'div'>;\n\ntype QuantitySelectorContextValue = {\n /** The maximum an entry was clamped down to, or null when the last entry was within range. */\n exceededMax: number | null;\n};\n\n// Seeded with a safe default so QuantitySelectorMessage never throws when rendered\n// outside a QuantitySelectorRoot (it simply renders nothing).\nconst QuantitySelectorContext = createContext<QuantitySelectorContextValue>({ exceededMax: null });\n\n/**\n * Interim: the default copy lives in the component until the `@vtex/fs-i18n` operational-message\n * catalog exists. Translations key off this stable id; a store overrides the copy via `children`.\n */\nexport const QUANTITY_MAX_EXCEEDED_MESSAGE_ID = 'quantity-selector.max-exceeded';\n\nexport function defaultMaxExceededMessage(max: number): string {\n return `Only ${max} available. Quantity adjusted to ${max}.`;\n}\n\nexport const QuantitySelectorRootDefinition = defineComponent<QuantitySelectorRootProps>({\n name: 'QuantitySelectorRoot',\n importPath: '@vtex/faststore/components',\n component: QuantitySelectorRoot,\n editor: { label: 'Quantity Selector', category: 'form' },\n schema: {\n defaultValue: { type: 'number', default: 1, label: 'Default Quantity' },\n min: { type: 'number', default: 1, label: 'Min Quantity' },\n max: { type: 'number', label: 'Max Quantity' },\n step: { type: 'number', default: 1, label: 'Step' },\n disabled: { type: 'boolean', default: false, label: 'Disabled' },\n },\n guideline:\n 'Generic quantity selector. Wraps NumberField and manages value state. Compose as: QuantitySelectorRoot > NumberFieldGroup > NumberFieldDecrement + NumberFieldInput + NumberFieldIncrement. Add QuantitySelectorMessage to surface the max-exceeded message. On a PDP, bind `max` to product stock via $data.',\n});\n\nexport const QuantitySelectorMessageDefinition = defineComponent<QuantitySelectorMessageProps>({\n name: 'QuantitySelectorMessage',\n importPath: '@vtex/faststore/components',\n component: QuantitySelectorMessage,\n editor: { label: 'Quantity Selector Message', category: 'form' },\n schema: {},\n guideline:\n 'Message shown when a shopper enters a quantity above `max` and it was clamped down; renders nothing otherwise. Must be a descendant of QuantitySelectorRoot. Set `children` to override the default copy.',\n});\n\nexport function QuantitySelectorRoot({\n value,\n defaultValue = 1,\n onQuantityChange,\n min = 1,\n max,\n step = 1,\n disabled,\n className,\n children,\n ...props\n}: QuantitySelectorRootProps) {\n // The `max` an entry was clamped down to, kept so a later `max` change can invalidate it.\n const [exceededAt, setExceededAt] = useState<number | null>(null);\n\n // A recorded exceed belongs to the `max` it was judged against. When `max` changes — a PDP\n // variant switch lands new stock — that record is stale, so we clear it synchronously during\n // render (React's recommended alternative to a useEffect for resetting state on a prop change).\n // Without this a 5 → 10 → 5 run of `max` values would resurrect a message the shopper never\n // triggered on the return to 5.\n const [maxJudgedAgainst, setMaxJudgedAgainst] = useState(max);\n if (max !== maxJudgedAgainst) {\n setMaxJudgedAgainst(max);\n setExceededAt(null);\n }\n\n function handleValueChange(newValue: number | null) {\n onQuantityChange?.(newValue);\n }\n\n // Base UI still clamps the committed value to `max` (via onValueChange above), but reports the\n // raw entered value here on commit. A committed value above `max` means the entry was reduced,\n // which is what the message explains. Every other commit path is already within range and clears it.\n function handleValueCommitted(committed: number | null) {\n setExceededAt(max != null && committed != null && committed > max ? max : null);\n }\n\n // `exceededAt` is now always relative to the current `max` (the render-time reset above clears it\n // on any change), but the `=== max` guard is kept as a cheap invariant assertion.\n const exceededMax = exceededAt != null && exceededAt === max ? exceededAt : null;\n const context = useMemo<QuantitySelectorContextValue>(() => ({ exceededMax }), [exceededMax]);\n\n return (\n <BaseNumberField.Root\n {...props}\n value={value}\n defaultValue={value === undefined ? defaultValue : undefined}\n onValueChange={handleValueChange}\n onValueCommitted={handleValueCommitted}\n min={min}\n max={max}\n step={step}\n disabled={disabled}\n className={className}\n data-fs-quantity-selector=\"\"\n >\n <QuantitySelectorContext value={context}>{children}</QuantitySelectorContext>\n </BaseNumberField.Root>\n );\n}\n\nexport function QuantitySelectorMessage({ className, children, ...props }: QuantitySelectorMessageProps) {\n const { exceededMax } = useContext(QuantitySelectorContext);\n if (exceededMax == null) return null;\n\n return (\n <div {...props} role=\"status\" aria-live=\"polite\" className={className} data-fs-quantity-selector-message=\"\">\n {children ?? defaultMaxExceededMessage(exceededMax)}\n </div>\n );\n}\n\nexport const QuantitySelector = {\n Root: QuantitySelectorRoot,\n Message: QuantitySelectorMessage,\n};\n"],"mappings":";;;;;;;AAyBA,MAAM,0BAA0B,cAA4C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E,oBAACA,YAAgB,MAAjB;EACE,GAAI;EACG;EACP,cAAc,UAAU,KAAA,IAAY,eAAe,KAAA;EACnD,eAAe;EACf,kBAAkB;EACb;EACA;EACC;EACI;EACC;EACX,6BAA0B;EAE1B,UAAA,oBAAC,yBAAD;GAAyB,OAAO;GAAU;EAAkC,CAAA;CACxD,CAAA;AAE1B;AAEA,SAAgB,wBAAwB,EAAE,WAAW,UAAU,GAAG,SAAuC;CACvG,MAAM,EAAE,gBAAgB,WAAW,uBAAuB;CAC1D,IAAI,eAAe,MAAM,OAAO;CAEhC,OACE,oBAAC,OAAD;EAAK,GAAI;EAAO,MAAK;EAAS,aAAU;EAAoB;EAAW,qCAAkC;EACtG,UAAA,YAAY,0BAA0B,WAAW;CAC/C,CAAA;AAET;AAEA,MAAa,mBAAmB;CAC9B,MAAM;CACN,SAAS;AACX"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentDefinition } from "../../core/dist/define-component.js";
|
|
2
|
+
import "../../core/dist/index.js";
|
|
3
|
+
import { ComponentPropsWithRef, ReactNode } from "react";
|
|
4
|
+
//#region src/particles/radio/radio.d.ts
|
|
5
|
+
export type RadioGroupProps = Omit<ComponentPropsWithRef<'div'>, 'defaultValue'> & {
|
|
6
|
+
value?: string;
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
onValueChange?: (value: string) => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
name?: string;
|
|
13
|
+
};
|
|
14
|
+
export type RadioRootProps = {
|
|
15
|
+
value: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
id?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
};
|
|
21
|
+
export type RadioIndicatorProps = ComponentPropsWithRef<'span'> & {
|
|
22
|
+
keepMounted?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare const RadioGroupDefinition: ComponentDefinition<RadioGroupProps>;
|
|
25
|
+
export declare const RadioRootDefinition: ComponentDefinition<RadioRootProps>;
|
|
26
|
+
export declare const RadioIndicatorDefinition: ComponentDefinition<RadioIndicatorProps>;
|
|
27
|
+
export declare function RadioGroup({ className, children, ...props }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function RadioRoot({ value, disabled, id, className, children }: RadioRootProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare function RadioIndicator({ keepMounted, className, children, ...props }: RadioIndicatorProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare const Radio: {
|
|
31
|
+
Group: typeof RadioGroup;
|
|
32
|
+
Root: typeof RadioRoot;
|
|
33
|
+
Indicator: typeof RadioIndicator;
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
//# sourceMappingURL=radio.d.ts.map
|