@dropins/tools 0.21.1 → 0.21.2-alpha1
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/components/Accordion/Accordion.d.ts +25 -0
- package/components/Accordion/Accordion.d.ts.map +1 -0
- package/components/Accordion/Accordion.jsx +59 -0
- package/components/Accordion/Accordion.stories.d.ts +22 -0
- package/components/Accordion/Accordion.stories.d.ts.map +1 -0
- package/components/Accordion/Accordion.stories.jsx +320 -0
- package/components/Accordion/Accordion.test.d.ts +3 -0
- package/components/Accordion/Accordion.test.d.ts.map +1 -0
- package/components/Accordion/Accordion.test.jsx +79 -0
- package/components/Accordion/index.d.ts +3 -0
- package/components/Accordion/index.d.ts.map +1 -0
- package/components/Accordion/index.js +2 -0
- package/components/ActionButton/ActionButton.d.ts +11 -0
- package/components/ActionButton/ActionButton.d.ts.map +1 -0
- package/components/ActionButton/ActionButton.jsx +14 -0
- package/components/ActionButton/ActionButton.stories.d.ts +16 -0
- package/components/ActionButton/ActionButton.stories.d.ts.map +1 -0
- package/components/ActionButton/ActionButton.stories.jsx +119 -0
- package/components/ActionButton/ActionButton.test.d.ts +3 -0
- package/components/ActionButton/ActionButton.test.d.ts.map +1 -0
- package/components/ActionButton/ActionButton.test.jsx +47 -0
- package/components/ActionButton/index.d.ts +2 -0
- package/components/ActionButton/index.d.ts.map +1 -0
- package/components/ActionButton/index.js +1 -0
- package/components/ActionButtonGroup/ActionButtonGroup.d.ts +20 -0
- package/components/ActionButtonGroup/ActionButtonGroup.d.ts.map +1 -0
- package/components/ActionButtonGroup/ActionButtonGroup.jsx +39 -0
- package/components/ActionButtonGroup/ActionButtonGroup.stories.d.ts +16 -0
- package/components/ActionButtonGroup/ActionButtonGroup.stories.d.ts.map +1 -0
- package/components/ActionButtonGroup/ActionButtonGroup.stories.jsx +72 -0
- package/components/ActionButtonGroup/ActionButtonGroup.test.d.ts +3 -0
- package/components/ActionButtonGroup/ActionButtonGroup.test.d.ts.map +1 -0
- package/components/ActionButtonGroup/ActionButtonGroup.test.jsx +78 -0
- package/components/ActionButtonGroup/index.d.ts +2 -0
- package/components/ActionButtonGroup/index.d.ts.map +1 -0
- package/components/ActionButtonGroup/index.js +1 -0
- package/components/AlertBanner/AlertBanner.d.ts +15 -0
- package/components/AlertBanner/AlertBanner.d.ts.map +1 -0
- package/components/AlertBanner/AlertBanner.jsx +30 -0
- package/components/AlertBanner/AlertBanner.stories.d.ts +17 -0
- package/components/AlertBanner/AlertBanner.stories.d.ts.map +1 -0
- package/components/AlertBanner/AlertBanner.stories.jsx +128 -0
- package/components/AlertBanner/AlertBanner.test.d.ts +3 -0
- package/components/AlertBanner/AlertBanner.test.d.ts.map +1 -0
- package/components/AlertBanner/AlertBanner.test.jsx +40 -0
- package/components/AlertBanner/index.d.ts +3 -0
- package/components/AlertBanner/index.d.ts.map +1 -0
- package/components/AlertBanner/index.js +2 -0
- package/components/Breadcrumbs/Breadcrumbs.d.ts +9 -0
- package/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -0
- package/components/Breadcrumbs/Breadcrumbs.jsx +26 -0
- package/components/Breadcrumbs/Breadcrumbs.stories.d.ts +15 -0
- package/components/Breadcrumbs/Breadcrumbs.stories.d.ts.map +1 -0
- package/components/Breadcrumbs/Breadcrumbs.stories.jsx +110 -0
- package/components/Breadcrumbs/Breadcrumbs.test.d.ts +3 -0
- package/components/Breadcrumbs/Breadcrumbs.test.d.ts.map +1 -0
- package/components/Breadcrumbs/Breadcrumbs.test.jsx +67 -0
- package/components/Breadcrumbs/index.d.ts +3 -0
- package/components/Breadcrumbs/index.d.ts.map +1 -0
- package/components/Breadcrumbs/index.js +2 -0
- package/components/Button/Button.d.ts +15 -0
- package/components/Button/Button.d.ts.map +1 -0
- package/components/Button/Button.jsx +59 -0
- package/components/Button/Button.stories.d.ts +135 -0
- package/components/Button/Button.stories.d.ts.map +1 -0
- package/components/Button/Button.stories.jsx +354 -0
- package/components/Button/Button.test.d.ts +2 -0
- package/components/Button/Button.test.d.ts.map +1 -0
- package/components/Button/Button.test.jsx +134 -0
- package/components/Button/index.d.ts +3 -0
- package/components/Button/index.d.ts.map +1 -0
- package/components/Button/index.js +2 -0
- package/components/Card/Card.d.ts +9 -0
- package/components/Card/Card.d.ts.map +1 -0
- package/components/Card/Card.jsx +7 -0
- package/components/Card/Card.stories.d.ts +16 -0
- package/components/Card/Card.stories.d.ts.map +1 -0
- package/components/Card/Card.stories.jsx +47 -0
- package/components/Card/Card.test.d.ts +3 -0
- package/components/Card/Card.test.d.ts.map +1 -0
- package/components/Card/Card.test.jsx +26 -0
- package/components/Card/index.d.ts +2 -0
- package/components/Card/index.d.ts.map +1 -0
- package/components/Card/index.js +1 -0
- package/components/CartItem/CartItem.d.ts +25 -0
- package/components/CartItem/CartItem.d.ts.map +1 -0
- package/components/CartItem/CartItem.jsx +124 -0
- package/components/CartItem/CartItem.stories.d.ts +54 -0
- package/components/CartItem/CartItem.stories.d.ts.map +1 -0
- package/components/CartItem/CartItem.stories.jsx +309 -0
- package/components/CartItem/CartItem.test.d.ts +3 -0
- package/components/CartItem/CartItem.test.d.ts.map +1 -0
- package/components/CartItem/CartItem.test.jsx +71 -0
- package/components/CartItem/CartItemSkeleton.d.ts +3 -0
- package/components/CartItem/CartItemSkeleton.d.ts.map +1 -0
- package/components/CartItem/CartItemSkeleton.jsx +25 -0
- package/components/CartItem/CartItemSkeleton.test.d.ts +3 -0
- package/components/CartItem/CartItemSkeleton.test.d.ts.map +1 -0
- package/components/CartItem/CartItemSkeleton.test.jsx +11 -0
- package/components/CartItem/index.d.ts +4 -0
- package/components/CartItem/index.d.ts.map +1 -0
- package/components/CartItem/index.js +3 -0
- package/components/CartList/CartList.d.ts +7 -0
- package/components/CartList/CartList.d.ts.map +1 -0
- package/components/CartList/CartList.jsx +14 -0
- package/components/CartList/CartList.stories.d.ts +17 -0
- package/components/CartList/CartList.stories.d.ts.map +1 -0
- package/components/CartList/CartList.stories.jsx +54 -0
- package/components/CartList/CartList.test.d.ts +3 -0
- package/components/CartList/CartList.test.d.ts.map +1 -0
- package/components/CartList/CartList.test.jsx +12 -0
- package/components/CartList/index.d.ts +3 -0
- package/components/CartList/index.d.ts.map +1 -0
- package/components/CartList/index.js +2 -0
- package/components/Checkbox/Checkbox.d.ts +13 -0
- package/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/components/Checkbox/Checkbox.jsx +51 -0
- package/components/Checkbox/Checkbox.stories.d.ts +22 -0
- package/components/Checkbox/Checkbox.stories.d.ts.map +1 -0
- package/components/Checkbox/Checkbox.stories.jsx +157 -0
- package/components/Checkbox/Checkbox.test.d.ts +3 -0
- package/components/Checkbox/Checkbox.test.d.ts.map +1 -0
- package/components/Checkbox/Checkbox.test.jsx +136 -0
- package/components/Checkbox/index.d.ts +2 -0
- package/components/Checkbox/index.d.ts.map +1 -0
- package/components/Checkbox/index.js +1 -0
- package/components/ColorSwatch/ColorSwatch.d.ts +20 -0
- package/components/ColorSwatch/ColorSwatch.d.ts.map +1 -0
- package/components/ColorSwatch/ColorSwatch.jsx +57 -0
- package/components/ColorSwatch/ColorSwatch.stories.d.ts +20 -0
- package/components/ColorSwatch/ColorSwatch.stories.d.ts.map +1 -0
- package/components/ColorSwatch/ColorSwatch.stories.jsx +206 -0
- package/components/ColorSwatch/ColorSwatch.test.d.ts +3 -0
- package/components/ColorSwatch/ColorSwatch.test.d.ts.map +1 -0
- package/components/ColorSwatch/ColorSwatch.test.jsx +87 -0
- package/components/ColorSwatch/index.d.ts +3 -0
- package/components/ColorSwatch/index.d.ts.map +1 -0
- package/components/ColorSwatch/index.js +2 -0
- package/components/Divider/Divider.d.ts +8 -0
- package/components/Divider/Divider.d.ts.map +1 -0
- package/components/Divider/Divider.jsx +9 -0
- package/components/Divider/Divider.stories.d.ts +11 -0
- package/components/Divider/Divider.stories.d.ts.map +1 -0
- package/components/Divider/Divider.stories.jsx +43 -0
- package/components/Divider/Divider.test.d.ts +2 -0
- package/components/Divider/Divider.test.d.ts.map +1 -0
- package/components/Divider/Divider.test.jsx +19 -0
- package/components/Divider/index.d.ts +3 -0
- package/components/Divider/index.d.ts.map +1 -0
- package/components/Divider/index.js +2 -0
- package/components/Field/Field.d.ts +14 -0
- package/components/Field/Field.d.ts.map +1 -0
- package/components/Field/Field.jsx +29 -0
- package/components/Field/Field.stories.d.ts +37 -0
- package/components/Field/Field.stories.d.ts.map +1 -0
- package/components/Field/Field.stories.jsx +174 -0
- package/components/Field/Field.test.d.ts +3 -0
- package/components/Field/Field.test.d.ts.map +1 -0
- package/components/Field/Field.test.jsx +91 -0
- package/components/Field/index.d.ts +2 -0
- package/components/Field/index.d.ts.map +1 -0
- package/components/Field/index.js +1 -0
- package/components/Icon/Icon.d.ts +11 -0
- package/components/Icon/Icon.d.ts.map +1 -0
- package/components/Icon/Icon.jsx +57 -0
- package/components/Icon/Icon.stories.d.ts +16 -0
- package/components/Icon/Icon.stories.d.ts.map +1 -0
- package/components/Icon/Icon.stories.helpers.d.ts +4 -0
- package/components/Icon/Icon.stories.helpers.d.ts.map +1 -0
- package/components/Icon/Icon.stories.helpers.jsx +7 -0
- package/components/Icon/Icon.stories.jsx +48 -0
- package/components/Icon/Icon.test.d.ts +3 -0
- package/components/Icon/Icon.test.d.ts.map +1 -0
- package/components/Icon/Icon.test.jsx +67 -0
- package/components/Icon/index.d.ts +2 -0
- package/components/Icon/index.d.ts.map +1 -0
- package/components/Icon/index.js +1 -0
- package/components/IllustratedMessage/IllustratedMessage.d.ts +13 -0
- package/components/IllustratedMessage/IllustratedMessage.d.ts.map +1 -0
- package/components/IllustratedMessage/IllustratedMessage.jsx +21 -0
- package/components/IllustratedMessage/IllustratedMessage.stories.d.ts +10 -0
- package/components/IllustratedMessage/IllustratedMessage.stories.d.ts.map +1 -0
- package/components/IllustratedMessage/IllustratedMessage.stories.jsx +90 -0
- package/components/IllustratedMessage/IllustratedMessage.test.d.ts +3 -0
- package/components/IllustratedMessage/IllustratedMessage.test.d.ts.map +1 -0
- package/components/IllustratedMessage/IllustratedMessage.test.jsx +42 -0
- package/components/IllustratedMessage/index.d.ts +3 -0
- package/components/IllustratedMessage/index.d.ts.map +1 -0
- package/components/IllustratedMessage/index.js +2 -0
- package/components/Image/Image.d.ts +11 -0
- package/components/Image/Image.d.ts.map +1 -0
- package/components/Image/Image.jsx +26 -0
- package/components/Image/Image.stories.d.ts +11 -0
- package/components/Image/Image.stories.d.ts.map +1 -0
- package/components/Image/Image.stories.jsx +66 -0
- package/components/Image/Image.test.d.ts +3 -0
- package/components/Image/Image.test.d.ts.map +1 -0
- package/components/Image/Image.test.jsx +82 -0
- package/components/Image/index.d.ts +2 -0
- package/components/Image/index.d.ts.map +1 -0
- package/components/Image/index.js +1 -0
- package/components/ImageSwatch/ImageSwatch.d.ts +20 -0
- package/components/ImageSwatch/ImageSwatch.d.ts.map +1 -0
- package/components/ImageSwatch/ImageSwatch.jsx +49 -0
- package/components/ImageSwatch/ImageSwatch.stories.d.ts +20 -0
- package/components/ImageSwatch/ImageSwatch.stories.d.ts.map +1 -0
- package/components/ImageSwatch/ImageSwatch.stories.jsx +206 -0
- package/components/ImageSwatch/ImageSwatch.test.d.ts +3 -0
- package/components/ImageSwatch/ImageSwatch.test.d.ts.map +1 -0
- package/components/ImageSwatch/ImageSwatch.test.jsx +64 -0
- package/components/ImageSwatch/index.d.ts +3 -0
- package/components/ImageSwatch/index.d.ts.map +1 -0
- package/components/ImageSwatch/index.js +2 -0
- package/components/InLineAlert/InLineAlert.d.ts +16 -0
- package/components/InLineAlert/InLineAlert.d.ts.map +1 -0
- package/components/InLineAlert/InLineAlert.jsx +38 -0
- package/components/InLineAlert/InLineAlert.stories.d.ts +86 -0
- package/components/InLineAlert/InLineAlert.stories.d.ts.map +1 -0
- package/components/InLineAlert/InLineAlert.stories.jsx +193 -0
- package/components/InLineAlert/InLineAlert.test.d.ts +3 -0
- package/components/InLineAlert/InLineAlert.test.d.ts.map +1 -0
- package/components/InLineAlert/InLineAlert.test.jsx +77 -0
- package/components/InLineAlert/index.d.ts +3 -0
- package/components/InLineAlert/index.d.ts.map +1 -0
- package/components/InLineAlert/index.js +2 -0
- package/components/Incrementer/Incrementer.d.ts +17 -0
- package/components/Incrementer/Incrementer.d.ts.map +1 -0
- package/components/Incrementer/Incrementer.jsx +87 -0
- package/components/Incrementer/Incrementer.stories.d.ts +10 -0
- package/components/Incrementer/Incrementer.stories.d.ts.map +1 -0
- package/components/Incrementer/Incrementer.stories.jsx +68 -0
- package/components/Incrementer/Incrementer.test.d.ts +3 -0
- package/components/Incrementer/Incrementer.test.d.ts.map +1 -0
- package/components/Incrementer/Incrementer.test.jsx +112 -0
- package/components/Incrementer/index.d.ts +2 -0
- package/components/Incrementer/index.d.ts.map +1 -0
- package/components/Incrementer/index.js +1 -0
- package/components/Input/Input.d.ts +19 -0
- package/components/Input/Input.d.ts.map +1 -0
- package/components/Input/Input.jsx +73 -0
- package/components/Input/Input.stories.d.ts +11 -0
- package/components/Input/Input.stories.d.ts.map +1 -0
- package/components/Input/Input.stories.jsx +115 -0
- package/components/Input/Input.test.d.ts +3 -0
- package/components/Input/Input.test.d.ts.map +1 -0
- package/components/Input/Input.test.jsx +111 -0
- package/components/Input/index.d.ts +3 -0
- package/components/Input/index.d.ts.map +1 -0
- package/components/Input/index.js +2 -0
- package/components/Modal/Modal.d.ts +15 -0
- package/components/Modal/Modal.d.ts.map +1 -0
- package/components/Modal/Modal.jsx +93 -0
- package/components/Modal/Modal.stories.d.ts +56 -0
- package/components/Modal/Modal.stories.d.ts.map +1 -0
- package/components/Modal/Modal.stories.jsx +189 -0
- package/components/Modal/Modal.test.d.ts +3 -0
- package/components/Modal/Modal.test.d.ts.map +1 -0
- package/components/Modal/Modal.test.jsx +85 -0
- package/components/Modal/index.d.ts +2 -0
- package/components/Modal/index.d.ts.map +1 -0
- package/components/Modal/index.js +14 -0
- package/components/Picker/Picker.d.ts +26 -0
- package/components/Picker/Picker.d.ts.map +1 -0
- package/components/Picker/Picker.jsx +81 -0
- package/components/Picker/Picker.stories.d.ts +22 -0
- package/components/Picker/Picker.stories.d.ts.map +1 -0
- package/components/Picker/Picker.stories.jsx +236 -0
- package/components/Picker/Picker.test.d.ts +2 -0
- package/components/Picker/Picker.test.d.ts.map +1 -0
- package/components/Picker/Picker.test.jsx +190 -0
- package/components/Picker/index.d.ts +2 -0
- package/components/Picker/index.d.ts.map +1 -0
- package/components/Picker/index.js +1 -0
- package/components/Price/Price.d.ts +17 -0
- package/components/Price/Price.d.ts.map +1 -0
- package/components/Price/Price.jsx +24 -0
- package/components/Price/Price.stories.d.ts +17 -0
- package/components/Price/Price.stories.d.ts.map +1 -0
- package/components/Price/Price.stories.jsx +78 -0
- package/components/Price/Price.test.d.ts +3 -0
- package/components/Price/Price.test.d.ts.map +1 -0
- package/components/Price/Price.test.jsx +68 -0
- package/components/Price/index.d.ts +2 -0
- package/components/Price/index.d.ts.map +1 -0
- package/components/Price/index.js +1 -0
- package/components/PriceRange/PriceRange.d.ts +17 -0
- package/components/PriceRange/PriceRange.d.ts.map +1 -0
- package/components/PriceRange/PriceRange.jsx +75 -0
- package/components/PriceRange/PriceRange.stories.d.ts +107 -0
- package/components/PriceRange/PriceRange.stories.d.ts.map +1 -0
- package/components/PriceRange/PriceRange.stories.jsx +210 -0
- package/components/PriceRange/PriceRange.test.d.ts +3 -0
- package/components/PriceRange/PriceRange.test.d.ts.map +1 -0
- package/components/PriceRange/PriceRange.test.jsx +188 -0
- package/components/PriceRange/index.d.ts +3 -0
- package/components/PriceRange/index.d.ts.map +1 -0
- package/components/PriceRange/index.js +2 -0
- package/components/PriceSummary/PriceSummary.d.ts +43 -0
- package/components/PriceSummary/PriceSummary.d.ts.map +1 -0
- package/components/PriceSummary/PriceSummary.jsx +228 -0
- package/components/PriceSummary/PriceSummary.stories.d.ts +127 -0
- package/components/PriceSummary/PriceSummary.stories.d.ts.map +1 -0
- package/components/PriceSummary/PriceSummary.stories.jsx +456 -0
- package/components/PriceSummary/PriceSummary.test.d.ts +3 -0
- package/components/PriceSummary/PriceSummary.test.d.ts.map +1 -0
- package/components/PriceSummary/PriceSummary.test.jsx +275 -0
- package/components/PriceSummary/index.d.ts +3 -0
- package/components/PriceSummary/index.d.ts.map +1 -0
- package/components/PriceSummary/index.js +2 -0
- package/components/ProgressSpinner/ProgressSpinner.d.ts +14 -0
- package/components/ProgressSpinner/ProgressSpinner.d.ts.map +1 -0
- package/components/ProgressSpinner/ProgressSpinner.jsx +31 -0
- package/components/ProgressSpinner/ProgressSpinner.stories.d.ts +19 -0
- package/components/ProgressSpinner/ProgressSpinner.stories.d.ts.map +1 -0
- package/components/ProgressSpinner/ProgressSpinner.stories.jsx +195 -0
- package/components/ProgressSpinner/ProgressSpinner.test.d.ts +3 -0
- package/components/ProgressSpinner/ProgressSpinner.test.d.ts.map +1 -0
- package/components/ProgressSpinner/ProgressSpinner.test.jsx +40 -0
- package/components/ProgressSpinner/index.d.ts +3 -0
- package/components/ProgressSpinner/index.d.ts.map +1 -0
- package/components/ProgressSpinner/index.js +2 -0
- package/components/RadioButton/RadioButton.d.ts +15 -0
- package/components/RadioButton/RadioButton.d.ts.map +1 -0
- package/components/RadioButton/RadioButton.jsx +31 -0
- package/components/RadioButton/RadioButton.stories.d.ts +15 -0
- package/components/RadioButton/RadioButton.stories.d.ts.map +1 -0
- package/components/RadioButton/RadioButton.stories.jsx +92 -0
- package/components/RadioButton/RadioButton.test.d.ts +3 -0
- package/components/RadioButton/RadioButton.test.d.ts.map +1 -0
- package/components/RadioButton/RadioButton.test.jsx +62 -0
- package/components/RadioButton/index.d.ts +3 -0
- package/components/RadioButton/index.d.ts.map +1 -0
- package/components/RadioButton/index.js +2 -0
- package/components/Skeleton/Skeleton.d.ts +17 -0
- package/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/components/Skeleton/Skeleton.jsx +52 -0
- package/components/Skeleton/Skeleton.stories.d.ts +67 -0
- package/components/Skeleton/Skeleton.stories.d.ts.map +1 -0
- package/components/Skeleton/Skeleton.stories.jsx +184 -0
- package/components/Skeleton/Skeleton.test.d.ts +3 -0
- package/components/Skeleton/Skeleton.test.d.ts.map +1 -0
- package/components/Skeleton/Skeleton.test.jsx +62 -0
- package/components/Skeleton/index.d.ts +2 -0
- package/components/Skeleton/index.d.ts.map +1 -0
- package/components/Skeleton/index.js +1 -0
- package/components/TextSwatch/TextSwatch.d.ts +18 -0
- package/components/TextSwatch/TextSwatch.d.ts.map +1 -0
- package/components/TextSwatch/TextSwatch.jsx +56 -0
- package/components/TextSwatch/TextSwatch.stories.d.ts +21 -0
- package/components/TextSwatch/TextSwatch.stories.d.ts.map +1 -0
- package/components/TextSwatch/TextSwatch.stories.jsx +211 -0
- package/components/TextSwatch/TextSwatch.test.d.ts +3 -0
- package/components/TextSwatch/TextSwatch.test.d.ts.map +1 -0
- package/components/TextSwatch/TextSwatch.test.jsx +85 -0
- package/components/TextSwatch/index.d.ts +3 -0
- package/components/TextSwatch/index.d.ts.map +1 -0
- package/components/TextSwatch/index.js +2 -0
- package/components/UIProvider/UIProvider.d.ts +18 -0
- package/components/UIProvider/UIProvider.d.ts.map +1 -0
- package/components/UIProvider/UIProvider.jsx +26 -0
- package/components/UIProvider/UIProvider.test.d.ts +2 -0
- package/components/UIProvider/UIProvider.test.d.ts.map +1 -0
- package/components/UIProvider/UIProvider.test.jsx +9 -0
- package/components/UIProvider/index.d.ts +2 -0
- package/components/UIProvider/index.d.ts.map +1 -0
- package/components/UIProvider/index.js +1 -0
- package/components/index.d.ts +34 -0
- package/components/index.d.ts.map +1 -0
- package/components/index.js +33 -0
- package/docs/Design/designBlocks.d.ts +21 -0
- package/docs/Design/designBlocks.d.ts.map +1 -0
- package/docs/Design/designBlocks.jsx +59 -0
- package/docs/Design/getTokenData.d.ts +7 -0
- package/docs/Design/getTokenData.d.ts.map +1 -0
- package/docs/Design/getTokenData.js +18 -0
- package/docs/Design/getTokenData.test.d.ts +2 -0
- package/docs/Design/getTokenData.test.d.ts.map +1 -0
- package/docs/Design/getTokenData.test.js +92 -0
- package/event-bus.js +49 -1
- package/fetch-graphql.js +62 -1
- package/i18n/en_US.json +112 -0
- package/i18n/index.d.ts +341 -0
- package/i18n/index.d.ts.map +1 -0
- package/i18n/index.js +12 -0
- package/i18n/index.test.d.ts +2 -0
- package/i18n/index.test.d.ts.map +1 -0
- package/i18n/index.test.js +11 -0
- package/icons/index.d.ts +35 -0
- package/icons/index.d.ts.map +1 -0
- package/icons/index.js +34 -0
- package/initializer.js +61 -1
- package/lib/classes.d.ts +5 -0
- package/lib/classes.d.ts.map +1 -0
- package/lib/classes.js +16 -0
- package/lib/classes.test.d.ts +2 -0
- package/lib/classes.test.d.ts.map +1 -0
- package/lib/classes.test.js +18 -0
- package/lib/config.d.ts +7 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +12 -0
- package/lib/config.test.d.ts +2 -0
- package/lib/config.test.d.ts.map +1 -0
- package/lib/config.test.js +12 -0
- package/lib/debounce.d.ts +2 -0
- package/lib/debounce.d.ts.map +1 -0
- package/lib/debounce.js +7 -0
- package/lib/debounce.test.d.ts +2 -0
- package/lib/debounce.test.d.ts.map +1 -0
- package/lib/debounce.test.js +40 -0
- package/lib/deepmerge.d.ts +2 -0
- package/lib/deepmerge.d.ts.map +1 -0
- package/lib/deepmerge.js +1 -0
- package/lib/form-values.d.ts +5 -0
- package/lib/form-values.d.ts.map +1 -0
- package/lib/form-values.js +17 -0
- package/lib/form-values.test.d.ts +2 -0
- package/lib/form-values.test.d.ts.map +1 -0
- package/lib/form-values.test.jsx +29 -0
- package/lib/i18n.d.ts +8 -0
- package/lib/i18n.d.ts.map +1 -0
- package/lib/i18n.js +9 -0
- package/lib/i18n.test.d.ts +2 -0
- package/lib/i18n.test.d.ts.map +1 -0
- package/lib/i18n.test.jsx +8 -0
- package/lib/image-params-keymap.d.ts +4 -0
- package/lib/image-params-keymap.d.ts.map +1 -0
- package/lib/image-params-keymap.js +19 -0
- package/lib/image-params-keymap.test.d.ts +2 -0
- package/lib/image-params-keymap.test.d.ts.map +1 -0
- package/lib/image-params-keymap.test.js +7 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +13 -0
- package/lib/initializer.d.ts +78 -0
- package/lib/initializer.d.ts.map +1 -0
- package/lib/initializer.js +93 -0
- package/lib/initializer.test.d.ts +2 -0
- package/lib/initializer.test.d.ts.map +1 -0
- package/lib/initializer.test.js +64 -0
- package/lib/render.d.ts +10 -0
- package/lib/render.d.ts.map +1 -0
- package/lib/render.jsx +34 -0
- package/lib/render.test.d.ts +2 -0
- package/lib/render.test.d.ts.map +1 -0
- package/lib/render.test.jsx +70 -0
- package/lib/resolve-image.d.ts +10 -0
- package/lib/resolve-image.d.ts.map +1 -0
- package/lib/resolve-image.js +57 -0
- package/lib/resolve-image.test.d.ts +2 -0
- package/lib/resolve-image.test.d.ts.map +1 -0
- package/lib/resolve-image.test.jsx +146 -0
- package/lib/slot.d.ts +43 -0
- package/lib/slot.d.ts.map +1 -0
- package/lib/slot.jsx +184 -0
- package/lib/slot.test.d.ts +2 -0
- package/lib/slot.test.d.ts.map +1 -0
- package/lib/slot.test.jsx +325 -0
- package/lib/tests.d.ts +4 -0
- package/lib/tests.d.ts.map +1 -0
- package/lib/tests.jsx +19 -0
- package/lib/tests.test.d.ts +2 -0
- package/lib/tests.test.d.ts.map +1 -0
- package/lib/tests.test.jsx +13 -0
- package/lib/types.d.ts +9 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +1 -0
- package/lib/vcomponent.d.ts +8 -0
- package/lib/vcomponent.d.ts.map +1 -0
- package/lib/vcomponent.jsx +27 -0
- package/lib/vcomponent.test.d.ts +2 -0
- package/lib/vcomponent.test.d.ts.map +1 -0
- package/lib/vcomponent.test.jsx +51 -0
- package/package.json +1 -1
- package/preact-compat.js +93 -1
- package/preact-hooks.js +40 -1
- package/preact-jsx-runtime.js +35 -1
- package/preact.js +21 -1
- package/runtime.js +69 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Icon } from '@adobe/elsie/components';
|
|
2
|
+
import '@adobe/elsie/components/Picker/Picker.css';
|
|
3
|
+
import { ChevronDown } from '@adobe/elsie/icons';
|
|
4
|
+
import { classes } from '@adobe/elsie/lib';
|
|
5
|
+
import { useEffect, useState } from 'preact/compat';
|
|
6
|
+
import { useRef } from 'preact/hooks';
|
|
7
|
+
export const Picker = ({ name, value = null, options, variant = 'primary', floatingLabel, size = 'medium', handleSelect = () => { }, disabled = false, error = false, placeholder, defaultOption, icon, className, ...props }) => {
|
|
8
|
+
const id = props?.id || name || `dropin-picker-${Math.random().toString(36)}`;
|
|
9
|
+
// find the first option that is not disabled
|
|
10
|
+
const firstAvailableeOption = options?.find((option) => !option.disabled);
|
|
11
|
+
const [selectedValue, setSelectedValue] = useState({
|
|
12
|
+
value,
|
|
13
|
+
text: defaultOption?.text || placeholder || firstAvailableeOption?.text,
|
|
14
|
+
icon,
|
|
15
|
+
});
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const selected = options?.find((option) => option.value === value);
|
|
18
|
+
setSelectedValue(selected ?? {
|
|
19
|
+
value: defaultOption?.value ||
|
|
20
|
+
(placeholder || floatingLabel
|
|
21
|
+
? null
|
|
22
|
+
: firstAvailableeOption?.value),
|
|
23
|
+
text: defaultOption?.text || placeholder || firstAvailableeOption?.text,
|
|
24
|
+
icon,
|
|
25
|
+
});
|
|
26
|
+
}, [value, options, placeholder, icon, defaultOption, floatingLabel]);
|
|
27
|
+
const handleOptionClick = (event) => {
|
|
28
|
+
const { options, value } = event.target;
|
|
29
|
+
for (const element of options) {
|
|
30
|
+
if (element.selected) {
|
|
31
|
+
setSelectedValue({ value, text: element.text, icon });
|
|
32
|
+
handleSelect(event);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const optionsListItems = options?.map((option) => {
|
|
37
|
+
const { value, text, disabled } = option;
|
|
38
|
+
const selected = value === selectedValue.value;
|
|
39
|
+
return (<option value={value} key={value} selected={selected} disabled={disabled} className={classes(['dropin-picker__option'])}>
|
|
40
|
+
{text}
|
|
41
|
+
</option>);
|
|
42
|
+
});
|
|
43
|
+
const placeholderOptionRef = useRef(null);
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
const selected = !placeholderOptionRef.current?.selected || !!defaultOption;
|
|
46
|
+
return (<div className={classes([
|
|
47
|
+
className,
|
|
48
|
+
'dropin-picker',
|
|
49
|
+
`dropin-picker__${size}`,
|
|
50
|
+
['dropin-picker__floating', !!floatingLabel],
|
|
51
|
+
['dropin-picker__selected', selected],
|
|
52
|
+
['dropin-picker__error', error],
|
|
53
|
+
['dropin-picker__disabled', disabled],
|
|
54
|
+
['dropin-picker__icon', icon],
|
|
55
|
+
])}>
|
|
56
|
+
{icon && (
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
<icon.type {...icon.props} className={'dropin-picker__icon--placeholder'}/>)}
|
|
59
|
+
|
|
60
|
+
<select id={id} className={classes([
|
|
61
|
+
'dropin-picker__select',
|
|
62
|
+
`dropin-picker__select--${variant}`,
|
|
63
|
+
`dropin-picker__select--${size}`,
|
|
64
|
+
['dropin-picker__select--floating', !!floatingLabel],
|
|
65
|
+
])} name={name} aria-label={name} disabled={disabled} onChange={handleOptionClick} {...props}>
|
|
66
|
+
{!defaultOption && (floatingLabel || placeholder) && (<option value={''} key={value} ref={placeholderOptionRef} className={classes([
|
|
67
|
+
'dropin-picker__option dropin-picker__placeholder',
|
|
68
|
+
])}>
|
|
69
|
+
{floatingLabel ?? placeholder}
|
|
70
|
+
</option>)}
|
|
71
|
+
|
|
72
|
+
{optionsListItems}
|
|
73
|
+
</select>
|
|
74
|
+
|
|
75
|
+
<Icon source={ChevronDown} size="24" stroke="2" className="dropin-picker__chevronDown"/>
|
|
76
|
+
|
|
77
|
+
{floatingLabel && selected && (<label htmlFor={id} className={classes(['dropin-picker__floatingLabel', !!floatingLabel])}>
|
|
78
|
+
{floatingLabel}
|
|
79
|
+
</label>)}
|
|
80
|
+
</div>);
|
|
81
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/preact';
|
|
2
|
+
import { PickerProps } from '@adobe/elsie/components/Picker';
|
|
3
|
+
/**
|
|
4
|
+
* Use Pickers to let users select values or items from predefined lists.
|
|
5
|
+
*/
|
|
6
|
+
declare const meta: Meta<PickerProps>;
|
|
7
|
+
export default meta;
|
|
8
|
+
interface StoryProps extends PickerProps {
|
|
9
|
+
handleSubmit?: (e: Event) => void;
|
|
10
|
+
}
|
|
11
|
+
type Story = StoryObj<StoryProps>;
|
|
12
|
+
/**
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Picker } from '@/checkout/components/Picker';
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const Primary: Story;
|
|
18
|
+
export declare const SecondaryWithIcon: Story;
|
|
19
|
+
export declare const PlaceholderText: Story;
|
|
20
|
+
export declare const FloatingLabel: Story;
|
|
21
|
+
export declare const FloatingLabelWithDefaultOption: Story;
|
|
22
|
+
//# sourceMappingURL=Picker.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Picker.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Picker/Picker.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAU,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAKrE;;GAEG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,WAAW,CAsF3B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,UAAU,UAAW,SAAQ,WAAW;IACtC,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC;AAED,KAAK,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAElC;;;;GAIG;AAEH,eAAO,MAAM,OAAO,EAAE,KAwCrB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KA2B/B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAuB7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAsB3B,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,KA0B5C,CAAC"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Picker } from '@adobe/elsie/components/Picker';
|
|
2
|
+
import { userEvent, within } from '@storybook/testing-library';
|
|
3
|
+
import { expect } from '@storybook/jest';
|
|
4
|
+
import { Placeholder } from '@adobe/elsie/icons';
|
|
5
|
+
/**
|
|
6
|
+
* Use Pickers to let users select values or items from predefined lists.
|
|
7
|
+
*/
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Components/Picker',
|
|
10
|
+
component: Picker,
|
|
11
|
+
argTypes: {
|
|
12
|
+
name: {
|
|
13
|
+
description: 'Field name (used for mapping the value in a form)',
|
|
14
|
+
type: {
|
|
15
|
+
required: false,
|
|
16
|
+
name: 'string',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
value: {
|
|
20
|
+
description: 'Field value',
|
|
21
|
+
type: 'string',
|
|
22
|
+
},
|
|
23
|
+
variant: {
|
|
24
|
+
description: 'Variant of the picker',
|
|
25
|
+
control: { type: 'radio' },
|
|
26
|
+
type: 'string',
|
|
27
|
+
defaultValue: { summary: 'primary' },
|
|
28
|
+
options: ['primary', 'secondary'],
|
|
29
|
+
},
|
|
30
|
+
size: {
|
|
31
|
+
description: 'Size of the picker',
|
|
32
|
+
control: 'radio',
|
|
33
|
+
options: ['medium', 'large'],
|
|
34
|
+
defaultValue: { summary: 'medium' },
|
|
35
|
+
},
|
|
36
|
+
floatingLabel: {
|
|
37
|
+
description: 'Floating label text',
|
|
38
|
+
type: {
|
|
39
|
+
required: false,
|
|
40
|
+
name: 'string',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
placeholder: {
|
|
44
|
+
description: 'Placeholder text (will be overridden by floatingLabel if provided)',
|
|
45
|
+
type: {
|
|
46
|
+
required: false,
|
|
47
|
+
name: 'string',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
defaultOption: {
|
|
51
|
+
description: 'Default available option from the options array',
|
|
52
|
+
type: {
|
|
53
|
+
required: false,
|
|
54
|
+
/* @ts-ignore */
|
|
55
|
+
name: 'object',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
error: {
|
|
59
|
+
description: 'Whether or not the field has an error',
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
defaultValue: {
|
|
62
|
+
summary: false,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
options: {
|
|
66
|
+
description: 'Array of options',
|
|
67
|
+
type: {
|
|
68
|
+
required: true,
|
|
69
|
+
/* @ts-ignore */
|
|
70
|
+
name: 'Array',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
disabled: {
|
|
74
|
+
description: 'Whether or not the field is disabled',
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
defaultValue: {
|
|
77
|
+
summary: false,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
icon: {
|
|
81
|
+
description: 'Icon to display in the Picker',
|
|
82
|
+
},
|
|
83
|
+
handleSelect: {
|
|
84
|
+
description: 'Callback function for when a value is selected',
|
|
85
|
+
type: 'function',
|
|
86
|
+
defaultValue: {
|
|
87
|
+
summary: '() => {}',
|
|
88
|
+
},
|
|
89
|
+
action: 'Value Selected',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
decorators: [(Story) => <div style={{ width: '300px' }}>{Story()}</div>],
|
|
93
|
+
};
|
|
94
|
+
export default meta;
|
|
95
|
+
/**
|
|
96
|
+
* ```ts
|
|
97
|
+
* import { Picker } from '@/checkout/components/Picker';
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export const Primary = {
|
|
101
|
+
args: {
|
|
102
|
+
name: 'pickerField',
|
|
103
|
+
variant: 'primary',
|
|
104
|
+
defaultOption: {
|
|
105
|
+
value: 'option1',
|
|
106
|
+
text: 'A Option 1',
|
|
107
|
+
},
|
|
108
|
+
placeholder: 'Select an option',
|
|
109
|
+
options: [
|
|
110
|
+
{
|
|
111
|
+
value: 'option1',
|
|
112
|
+
text: 'A Option 1',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
value: 'option2',
|
|
116
|
+
text: 'B Option 2',
|
|
117
|
+
disabled: true,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
value: 'option3',
|
|
121
|
+
text: 'C Option 3',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
play: async ({ canvasElement }) => {
|
|
126
|
+
const canvas = within(canvasElement);
|
|
127
|
+
userEvent.click(canvas.getByText('A Option 1'));
|
|
128
|
+
expect(canvas.getByText('A Option 1')).toBeVisible();
|
|
129
|
+
expect(canvas.getByText('B Option 2')).toBeVisible();
|
|
130
|
+
const select = document.querySelector('.dropin-picker__select');
|
|
131
|
+
userEvent.selectOptions(select, 'option3');
|
|
132
|
+
expect(select.textContent).toContain('C Option 3');
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
export const SecondaryWithIcon = {
|
|
136
|
+
name: 'Secondary with icon',
|
|
137
|
+
args: {
|
|
138
|
+
name: 'pickerField',
|
|
139
|
+
variant: 'secondary',
|
|
140
|
+
defaultOption: {
|
|
141
|
+
value: 'option2',
|
|
142
|
+
text: 'B Option 2',
|
|
143
|
+
},
|
|
144
|
+
placeholder: 'Select an option',
|
|
145
|
+
icon: <Placeholder />,
|
|
146
|
+
options: [
|
|
147
|
+
{
|
|
148
|
+
value: 'option1',
|
|
149
|
+
text: 'A Option 1',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
value: 'option2',
|
|
153
|
+
text: 'B Option 2',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
value: 'option3',
|
|
157
|
+
text: 'C Option 3',
|
|
158
|
+
disabled: true,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
export const PlaceholderText = {
|
|
164
|
+
name: 'Secondary with placeholder',
|
|
165
|
+
args: {
|
|
166
|
+
name: 'pickerField',
|
|
167
|
+
variant: 'primary',
|
|
168
|
+
placeholder: 'Select an option',
|
|
169
|
+
icon: <Placeholder />,
|
|
170
|
+
options: [
|
|
171
|
+
{
|
|
172
|
+
value: 'option1',
|
|
173
|
+
text: 'A Option 1',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
value: 'option2',
|
|
177
|
+
text: 'B Option 2',
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
value: 'option3',
|
|
181
|
+
text: 'C Option 3',
|
|
182
|
+
disabled: true,
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
export const FloatingLabel = {
|
|
188
|
+
name: 'Floating label',
|
|
189
|
+
args: {
|
|
190
|
+
name: 'pickerField',
|
|
191
|
+
variant: 'primary',
|
|
192
|
+
floatingLabel: 'Floating label',
|
|
193
|
+
options: [
|
|
194
|
+
{
|
|
195
|
+
value: 'option1',
|
|
196
|
+
text: 'A Option 1',
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
value: 'option2',
|
|
200
|
+
text: 'B Option 2',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
value: 'option3',
|
|
204
|
+
text: 'C Option 3',
|
|
205
|
+
disabled: true,
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
export const FloatingLabelWithDefaultOption = {
|
|
211
|
+
name: 'Floating label with default option',
|
|
212
|
+
args: {
|
|
213
|
+
name: 'pickerField',
|
|
214
|
+
variant: 'primary',
|
|
215
|
+
floatingLabel: 'Floating label',
|
|
216
|
+
defaultOption: {
|
|
217
|
+
value: 'option2',
|
|
218
|
+
text: 'B Option 2',
|
|
219
|
+
},
|
|
220
|
+
options: [
|
|
221
|
+
{
|
|
222
|
+
value: 'option1',
|
|
223
|
+
text: 'A Option 1',
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
value: 'option2',
|
|
227
|
+
text: 'B Option 2',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
value: 'option3',
|
|
231
|
+
text: 'C Option 3',
|
|
232
|
+
disabled: true,
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Picker.test.d.ts","sourceRoot":"","sources":["../../../src/components/Picker/Picker.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/** https://preactjs.com/guide/v10/preact-testing-library/ */
|
|
2
|
+
import { fireEvent, render, screen } from '@adobe/elsie/lib/tests';
|
|
3
|
+
import { Picker } from '@adobe/elsie/components';
|
|
4
|
+
import { Placeholder } from '@adobe/elsie/icons';
|
|
5
|
+
describe('Selection controls/Picker', () => {
|
|
6
|
+
const DEFAULT_PROPS = {
|
|
7
|
+
name: 'testPicker',
|
|
8
|
+
placeholder: 'Select an option',
|
|
9
|
+
options: [
|
|
10
|
+
{
|
|
11
|
+
value: 'option1',
|
|
12
|
+
text: 'Option 1',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
value: 'option2',
|
|
16
|
+
text: 'Option 2',
|
|
17
|
+
disabled: true,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: 'option3',
|
|
21
|
+
text: 'Option 3',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
handleSelect: jest.fn(),
|
|
25
|
+
};
|
|
26
|
+
const Second_Props = {
|
|
27
|
+
name: 'secondPicker',
|
|
28
|
+
options: [
|
|
29
|
+
{
|
|
30
|
+
value: 'option5',
|
|
31
|
+
text: 'Option 5',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: 'option6',
|
|
35
|
+
text: 'Option 6',
|
|
36
|
+
disabled: true,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
value: 'option3',
|
|
40
|
+
text: 'Option 3',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
handleSelect: jest.fn(),
|
|
44
|
+
};
|
|
45
|
+
describe('renders', () => {
|
|
46
|
+
test.each([
|
|
47
|
+
{ name: 'primary', props: { ...DEFAULT_PROPS, variant: 'primary' } },
|
|
48
|
+
{ name: 'secondary', props: { ...DEFAULT_PROPS, variant: 'secondary' } },
|
|
49
|
+
{ name: 'medium', props: { ...DEFAULT_PROPS, size: 'medium' } },
|
|
50
|
+
{ name: 'large', props: { ...DEFAULT_PROPS, size: 'large' } },
|
|
51
|
+
])('$name component', ({ props }) => {
|
|
52
|
+
const { container } = render(<Picker {...DEFAULT_PROPS}/>);
|
|
53
|
+
expect(!!container).toEqual(true);
|
|
54
|
+
expect(container).toMatchSnapshot();
|
|
55
|
+
// Test that the component container is rendered
|
|
56
|
+
const component = container.querySelector('.dropin-picker');
|
|
57
|
+
expect(component).toBeTruthy();
|
|
58
|
+
// Test that the placeholder is rendered
|
|
59
|
+
const placeholder = screen.getByText(props.placeholder?.toString());
|
|
60
|
+
expect(placeholder).toBeTruthy();
|
|
61
|
+
// Test that the variant class is applied
|
|
62
|
+
const variantField = container.querySelector(`.dropin-picker__selected--${props.variant}`);
|
|
63
|
+
expect(variantField).toBeDefined();
|
|
64
|
+
// Test that the size class is applied
|
|
65
|
+
const sizeField = container.querySelector(`.dropin-picker__select--${props.size}`);
|
|
66
|
+
expect(sizeField).toBeDefined();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('when options are provided', () => {
|
|
70
|
+
test('options exist and placeholder is selected by default', () => {
|
|
71
|
+
const { container } = render(<Picker {...DEFAULT_PROPS}/>);
|
|
72
|
+
const options = container.querySelectorAll('.dropin-picker__option');
|
|
73
|
+
// Placeholder option is included
|
|
74
|
+
expect(options.length).toBe(4);
|
|
75
|
+
expect(screen.getByText(DEFAULT_PROPS.placeholder?.toString()).selected).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
test('user to change default option', () => {
|
|
78
|
+
render(<Picker {...DEFAULT_PROPS}/>);
|
|
79
|
+
const select = screen.getByRole('combobox');
|
|
80
|
+
fireEvent.change(select, { target: { value: 'option2' } });
|
|
81
|
+
expect(screen.getByText('Option 2').selected).toBe(true);
|
|
82
|
+
expect(screen.getByRole('option', { name: 'Option 2' })
|
|
83
|
+
.selected).toBe(true);
|
|
84
|
+
expect(select.value).toBe('option2');
|
|
85
|
+
expect(screen.getByRole('option', { name: 'Option 3' })
|
|
86
|
+
.selected).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
describe('when floating label is provided', () => {
|
|
90
|
+
test('floating label is displayed as placeholder', () => {
|
|
91
|
+
const { container } = render(<Picker {...DEFAULT_PROPS} floatingLabel={'Floating label'}/>);
|
|
92
|
+
const selectedContent = container.querySelector('.dropin-picker__placeholder');
|
|
93
|
+
expect(selectedContent?.textContent).toBe('Floating label');
|
|
94
|
+
});
|
|
95
|
+
test('floating label is displayed when option is selected', () => {
|
|
96
|
+
const { container } = render(<Picker {...DEFAULT_PROPS} floatingLabel={'Floating label'}/>);
|
|
97
|
+
const select = screen.getByRole('combobox');
|
|
98
|
+
fireEvent.change(select, { target: { value: 'option2' } });
|
|
99
|
+
const label = container.querySelector('.dropin-picker__floatingLabel');
|
|
100
|
+
expect(label.textContent).toBe('Floating label');
|
|
101
|
+
expect(label).not.toBeNull();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
describe('when icon is provided', () => {
|
|
105
|
+
test('icon is displayed', () => {
|
|
106
|
+
const { container } = render(<Picker {...DEFAULT_PROPS} icon={<Placeholder />}/>);
|
|
107
|
+
const icon = container.querySelector('.dropin-picker__icon--placeholder');
|
|
108
|
+
expect(icon).not.toBeNull();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
describe('when handleSelect is called', () => {
|
|
112
|
+
test('calls the handleSelect callback with the correct value', () => {
|
|
113
|
+
jest.resetAllMocks();
|
|
114
|
+
render(<Picker {...DEFAULT_PROPS}/>);
|
|
115
|
+
// Test that the handleSelect callback is not called on initial render
|
|
116
|
+
expect(DEFAULT_PROPS.handleSelect).not.toHaveBeenCalled();
|
|
117
|
+
const select = screen.getByRole('combobox');
|
|
118
|
+
fireEvent.change(select, { target: { value: 'option2' } });
|
|
119
|
+
expect(DEFAULT_PROPS.handleSelect).toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
test('handleSelect is undefined', () => {
|
|
122
|
+
jest.resetAllMocks();
|
|
123
|
+
const DEFAULT_PROPS = {
|
|
124
|
+
placeholder: 'Select an option',
|
|
125
|
+
options: [
|
|
126
|
+
{
|
|
127
|
+
value: 'option1',
|
|
128
|
+
text: 'Option 1',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
value: 'option2',
|
|
132
|
+
text: 'Option 2',
|
|
133
|
+
disabled: true,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
value: 'option3',
|
|
137
|
+
text: 'Option 3',
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
handleSelect: undefined,
|
|
141
|
+
};
|
|
142
|
+
render(<Picker {...DEFAULT_PROPS}/>);
|
|
143
|
+
const select = screen.getByRole('combobox');
|
|
144
|
+
fireEvent.change(select, { target: { value: 'option2' } });
|
|
145
|
+
expect(screen.getByText('Option 2').selected).toBe(true);
|
|
146
|
+
expect(screen.getByRole('option', { name: 'Option 2' })
|
|
147
|
+
.selected).toBe(true);
|
|
148
|
+
expect(select.value).toBe('option2');
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
describe('display priority sequence with defaultOption and placeholder', () => {
|
|
152
|
+
test('display priority sequence', () => {
|
|
153
|
+
// when defaultOption is not provided, placeholder is displayed
|
|
154
|
+
render(<Picker {...DEFAULT_PROPS}/>);
|
|
155
|
+
expect(screen.getByText('Select an option')).toBeTruthy();
|
|
156
|
+
// when defaultOption is provided, defaultOption is displayed
|
|
157
|
+
const { container } = render(<Picker {...DEFAULT_PROPS} defaultOption={{
|
|
158
|
+
value: 'option3',
|
|
159
|
+
text: 'Option 3',
|
|
160
|
+
}}/>);
|
|
161
|
+
const selected = container.querySelector('.dropin-picker__select');
|
|
162
|
+
expect(selected?.textContent).toContain('Option 3');
|
|
163
|
+
});
|
|
164
|
+
test('when defaultOption and placeholder are not provided, first option is displayed', () => {
|
|
165
|
+
const { container } = render(<Picker {...Second_Props}/>);
|
|
166
|
+
const selectedContent = container.querySelector('.dropin-picker__select');
|
|
167
|
+
expect(selectedContent?.textContent).toContain('Option 5');
|
|
168
|
+
});
|
|
169
|
+
test('when defaultOption is provided, it is selected by default', () => {
|
|
170
|
+
render(<Picker {...DEFAULT_PROPS} defaultOption={{
|
|
171
|
+
value: 'option3',
|
|
172
|
+
text: 'Option 3',
|
|
173
|
+
}}/>);
|
|
174
|
+
expect(screen.getByText('Option 3').selected).toBe(true);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
describe('when defaultOption is provided with floating label', () => {
|
|
178
|
+
test('defaultOption is displayed', () => {
|
|
179
|
+
const { container } = render(<Picker {...DEFAULT_PROPS} defaultOption={{
|
|
180
|
+
value: 'option3',
|
|
181
|
+
text: 'Option 3',
|
|
182
|
+
}} floatingLabel={'Floating label'}/>);
|
|
183
|
+
const selected = container.querySelector('.dropin-picker__select');
|
|
184
|
+
expect(selected?.textContent).toContain('Option 3');
|
|
185
|
+
// Test that the floating label is displayed
|
|
186
|
+
const label = container.querySelector('.dropin-picker__floatingLabel');
|
|
187
|
+
expect(label.textContent).toBe('Floating label');
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Picker/index.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@adobe/elsie/components/Picker/Picker';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FunctionComponent } from 'preact';
|
|
2
|
+
import { HTMLAttributes } from 'preact/compat';
|
|
3
|
+
import '@adobe/elsie/components/Price/Price.css';
|
|
4
|
+
export interface PriceProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'size'> {
|
|
5
|
+
amount?: number;
|
|
6
|
+
currency?: string;
|
|
7
|
+
locale?: string;
|
|
8
|
+
formatOptions?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
variant?: 'default' | 'strikethrough';
|
|
12
|
+
weight?: 'bold' | 'normal';
|
|
13
|
+
sale?: boolean;
|
|
14
|
+
size?: 'small' | 'medium' | 'large';
|
|
15
|
+
}
|
|
16
|
+
export declare const Price: FunctionComponent<PriceProps>;
|
|
17
|
+
//# sourceMappingURL=Price.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Price.d.ts","sourceRoot":"","sources":["../../../src/components/Price/Price.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAW,MAAM,eAAe,CAAC;AAExD,OAAO,yCAAyC,CAAC;AAEjD,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,OAAO,CAAC,EAAE,SAAS,GAAG,eAAe,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC;AAED,eAAO,MAAM,KAAK,EAAE,iBAAiB,CAAC,UAAU,CA2C/C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useMemo } from 'preact/compat';
|
|
2
|
+
import { classes } from '@adobe/elsie/lib';
|
|
3
|
+
import '@adobe/elsie/components/Price/Price.css';
|
|
4
|
+
export const Price = ({ amount = 0, currency, locale = undefined, variant = 'default', weight = 'bold', className, children, sale = false, formatOptions = {}, size = 'small', ...props }) => {
|
|
5
|
+
const formatter = useMemo(() => new Intl.NumberFormat(locale, {
|
|
6
|
+
style: 'currency',
|
|
7
|
+
currency: currency || 'USD',
|
|
8
|
+
// These options are needed to round to whole numbers if that's what you want.
|
|
9
|
+
minimumFractionDigits: 2,
|
|
10
|
+
maximumFractionDigits: 2,
|
|
11
|
+
...formatOptions,
|
|
12
|
+
}), [locale, currency, formatOptions]);
|
|
13
|
+
const formattedAmount = useMemo(() => formatter.format(amount), [amount, formatter]);
|
|
14
|
+
return (<span {...props} className={classes([
|
|
15
|
+
'dropin-price',
|
|
16
|
+
`dropin-price--${variant}`,
|
|
17
|
+
`dropin-price--${size}`,
|
|
18
|
+
`dropin-price--${weight}`,
|
|
19
|
+
['dropin-price--sale', sale],
|
|
20
|
+
className,
|
|
21
|
+
])}>
|
|
22
|
+
{formattedAmount}
|
|
23
|
+
</span>);
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/preact';
|
|
2
|
+
import { PriceProps } from '@adobe/elsie/components/Price';
|
|
3
|
+
/**
|
|
4
|
+
* Use Price components to display the cost of an item or service.
|
|
5
|
+
*/
|
|
6
|
+
declare const meta: Meta<PriceProps>;
|
|
7
|
+
export default meta;
|
|
8
|
+
type Story = StoryObj<PriceProps>;
|
|
9
|
+
/**
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { Price } from '@adobe/elsie/components/Price';
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const Primary: Story;
|
|
15
|
+
export declare const SpecialDefault: Story;
|
|
16
|
+
export declare const HighContrast: Story;
|
|
17
|
+
//# sourceMappingURL=Price.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Price.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Price/Price.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAS,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIlE;;GAEG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAAU,CAoC1B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAElC;;;;GAIG;AAEH,eAAO,MAAM,OAAO,EAAE,KAUrB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAU5B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAU1B,CAAC"}
|