@automattic/vip-design-system 1.2.0 → 1.2.2
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/.storybook/decorators/withBoundingBox.tsx +11 -0
- package/.storybook/decorators/{withThemeProvider.jsx → withThemeProvider.tsx} +1 -5
- package/.storybook/{preview.js → preview.tsx} +12 -3
- package/build/declaration.d.js +1 -0
- package/build/system/Accordion/Accordion.d.ts +41 -0
- package/build/system/Accordion/Accordion.js +10 -35
- package/build/system/Accordion/Accordion.stories.d.ts +13 -0
- package/build/system/Accordion/Accordion.stories.js +4 -7
- package/build/system/Accordion/Accordion.test.d.ts +2 -0
- package/build/system/Accordion/Accordion.test.js +5 -7
- package/build/system/Accordion/index.d.ts +5 -0
- package/build/system/Avatar/Avatar.d.ts +13 -0
- package/build/system/Avatar/Avatar.js +7 -20
- package/build/system/Avatar/Avatar.stories.d.ts +16 -0
- package/build/system/Avatar/Avatar.stories.js +5 -7
- package/build/system/Avatar/Avatar.test.d.ts +1 -0
- package/build/system/Avatar/Avatar.test.js +5 -7
- package/build/system/Avatar/index.d.ts +4 -0
- package/build/system/Avatar/index.js +1 -0
- package/build/system/Badge/Badge.d.ts +6 -0
- package/build/system/Badge/Badge.js +6 -15
- package/build/system/Badge/Badge.stories.d.ts +18 -0
- package/build/system/Badge/Badge.stories.js +70 -71
- package/build/system/Badge/Badge.test.d.ts +1 -0
- package/build/system/Badge/Badge.test.js +6 -8
- package/build/system/Badge/index.d.ts +4 -0
- package/build/system/Badge/index.js +1 -0
- package/build/system/Box/Box.d.ts +3 -0
- package/build/system/{Form/Label.stories.js → Box/Box.js} +15 -31
- package/build/system/Box/Box.stories.d.ts +16 -0
- package/build/system/Box/Box.stories.js +21 -0
- package/build/system/Box/index.d.ts +2 -0
- package/build/system/Box/index.js +5 -4
- package/build/system/Button/Button.d.ts +12 -0
- package/build/system/Button/Button.js +10 -18
- package/build/system/Button/Button.stories.d.ts +30 -0
- package/build/system/Button/Button.stories.js +10 -20
- package/build/system/Button/Button.test.d.ts +1 -0
- package/build/system/Button/Button.test.js +45 -74
- package/build/system/Button/ButtonSubmit.d.ts +2 -0
- package/build/system/Button/ButtonSubmit.js +60 -70
- package/build/system/Button/ButtonSubmit.stories.d.ts +38 -0
- package/build/system/Button/ButtonSubmit.stories.jsx +40 -0
- package/build/system/Button/ButtonSubmit.test.d.ts +1 -0
- package/build/system/Button/ButtonSubmit.test.js +32 -60
- package/build/system/Button/index.d.ts +3 -0
- package/build/system/Button/index.js +7 -6
- package/build/system/Button/variants.d.ts +2 -0
- package/build/system/Button/variants.js +1 -6
- package/build/system/Card/Card.d.ts +9 -0
- package/build/system/Card/Card.js +2 -10
- package/build/system/Card/Card.stories.d.ts +7 -0
- package/build/system/Card/Card.stories.js +4 -6
- package/build/system/Card/Card.test.d.ts +1 -0
- package/build/system/Card/Card.test.js +5 -7
- package/build/system/Card/index.d.ts +4 -0
- package/build/system/Card/index.js +1 -0
- package/build/system/Code/Code.d.ts +15 -0
- package/build/system/Code/Code.js +14 -21
- package/build/system/Code/Code.stories.d.ts +18 -0
- package/build/system/Code/Code.stories.js +31 -23
- package/build/system/Code/Code.test.d.ts +1 -0
- package/build/system/Code/Code.test.js +10 -11
- package/build/system/Code/index.d.ts +4 -0
- package/build/system/Code/index.js +1 -0
- package/build/system/ConfirmationDialog/ConfirmationDialog.d.ts +35 -0
- package/build/system/ConfirmationDialog/ConfirmationDialog.js +68 -94
- package/build/system/ConfirmationDialog/ConfirmationDialog.stories.d.ts +7 -0
- package/build/system/ConfirmationDialog/ConfirmationDialog.stories.jsx +29 -0
- package/build/system/ConfirmationDialog/index.d.ts +3 -0
- package/build/system/ConfirmationDialog/index.js +5 -5
- package/build/system/Dialog/Dialog.d.ts +18 -0
- package/build/system/Dialog/Dialog.js +81 -94
- package/build/system/Dialog/Dialog.stories.d.ts +7 -0
- package/build/system/Dialog/Dialog.stories.jsx +60 -0
- package/build/system/Dialog/DialogButton.d.ts +16 -0
- package/build/system/Dialog/DialogButton.js +51 -66
- package/build/system/Dialog/DialogContent.d.ts +18 -0
- package/build/system/Dialog/DialogContent.js +142 -137
- package/build/system/Dialog/DialogDivider.d.ts +5 -0
- package/build/system/Dialog/DialogDivider.js +5 -16
- package/build/system/Dialog/DialogMenu.d.ts +5 -0
- package/build/system/Dialog/DialogMenu.js +5 -18
- package/build/system/Dialog/DialogMenuItem.d.ts +13 -0
- package/build/system/Dialog/DialogMenuItem.js +64 -71
- package/build/system/Dialog/DialogTrigger.d.ts +1 -0
- package/build/system/Dialog/DialogTrigger.js +10 -16
- package/build/system/Dialog/index.d.ts +8 -0
- package/build/system/Dialog/index.js +19 -16
- package/build/system/Dropdown/Dropdown.d.ts +37 -0
- package/build/system/Dropdown/Dropdown.js +96 -93
- package/build/system/Dropdown/Dropdown.stories.d.ts +34 -0
- package/build/system/Dropdown/Dropdown.stories.jsx +170 -0
- package/build/system/Dropdown/Dropdown.test.d.ts +1 -0
- package/build/system/Dropdown/Dropdown.test.js +30 -52
- package/build/system/Dropdown/DropdownContent.d.ts +11 -0
- package/build/system/Dropdown/DropdownContent.js +40 -49
- package/build/system/Dropdown/DropdownItem.d.ts +32 -0
- package/build/system/Dropdown/DropdownItem.js +91 -95
- package/build/system/Dropdown/DropdownLabel.d.ts +8 -0
- package/build/system/Dropdown/DropdownLabel.js +24 -33
- package/build/system/Dropdown/DropdownSeparator.d.ts +7 -0
- package/build/system/Dropdown/DropdownSeparator.js +23 -32
- package/build/system/Dropdown/index.d.ts +40 -0
- package/build/system/Dropdown/index.js +49 -37
- package/build/system/Flex/Flex.d.ts +2 -0
- package/build/system/Flex/Flex.js +6 -8
- package/build/system/Flex/Flex.stories.d.ts +7 -0
- package/build/system/Flex/Flex.stories.js +3 -5
- package/build/system/Flex/index.d.ts +4 -0
- package/build/system/Flex/index.js +1 -0
- package/build/system/Form/Checkbox.d.ts +10 -0
- package/build/system/Form/Checkbox.js +61 -62
- package/build/system/Form/Checkbox.stories.d.ts +7 -0
- package/build/system/Form/Checkbox.stories.jsx +54 -0
- package/build/system/Form/Input.d.ts +2 -0
- package/build/system/Form/Input.js +70 -69
- package/build/system/Form/Input.stories.d.ts +5 -0
- package/build/system/Form/Input.stories.jsx +38 -0
- package/build/system/Form/Input.styles.d.ts +32 -0
- package/build/system/Form/Input.styles.js +29 -40
- package/build/system/Form/InputWithCopyButton.d.ts +2 -0
- package/build/system/Form/InputWithCopyButton.js +109 -105
- package/build/system/Form/InputWithCopyButton.stories.d.ts +5 -0
- package/build/system/Form/InputWithCopyButton.stories.jsx +30 -0
- package/build/system/Form/Label.d.ts +9 -0
- package/build/system/Form/Label.js +41 -47
- package/build/system/Form/Label.stories.d.ts +6 -0
- package/build/system/Form/Label.stories.jsx +36 -0
- package/build/system/Form/Radio.d.ts +2 -0
- package/build/system/Form/Radio.js +185 -169
- package/build/system/Form/Radio.stories.d.ts +7 -0
- package/build/system/Form/Radio.stories.jsx +100 -0
- package/build/system/Form/RadioBoxGroup.d.ts +2 -0
- package/build/system/Form/RadioBoxGroup.js +193 -187
- package/build/system/Form/RadioBoxGroup.stories.d.ts +8 -0
- package/build/system/Form/RadioBoxGroup.stories.jsx +60 -0
- package/build/system/Form/RequiredLabel.d.ts +5 -0
- package/build/system/Form/RequiredLabel.js +7 -17
- package/build/system/Form/Textarea.d.ts +2 -0
- package/build/system/Form/Textarea.js +18 -20
- package/build/system/Form/Textarea.stories.d.ts +34 -0
- package/build/system/Form/Textarea.stories.jsx +40 -0
- package/build/system/Form/Toggle.d.ts +2 -0
- package/build/system/Form/Toggle.js +67 -81
- package/build/system/Form/Toggle.stories.d.ts +19 -0
- package/build/system/Form/Toggle.stories.jsx +96 -0
- package/build/system/Form/Toggle.test.d.ts +1 -0
- package/build/system/Form/Toggle.test.js +21 -39
- package/build/system/Form/ToggleRow.d.ts +22 -0
- package/build/system/Form/ToggleRow.js +66 -95
- package/build/system/Form/Validation.d.ts +14 -0
- package/build/system/Form/Validation.js +33 -42
- package/build/system/Form/index.d.ts +11 -0
- package/build/system/Form/index.js +25 -22
- package/build/system/Grid/Grid.d.ts +6 -0
- package/build/system/Grid/Grid.js +4 -5
- package/build/system/Grid/Grid.stories.d.ts +7 -0
- package/build/system/Grid/Grid.stories.js +3 -5
- package/build/system/Grid/index.d.ts +4 -0
- package/build/system/Grid/index.js +1 -0
- package/build/system/Heading/Heading.d.ts +6 -0
- package/build/system/Heading/Heading.js +33 -0
- package/build/system/Heading/Heading.stories.d.ts +7 -0
- package/build/system/Heading/Heading.stories.js +33 -0
- package/build/system/Heading/index.d.ts +2 -0
- package/build/system/Heading/index.js +5 -4
- package/build/system/Link/Link.d.ts +6 -0
- package/build/system/Link/Link.js +5 -12
- package/build/system/Link/Link.stories.d.ts +16 -0
- package/build/system/Link/Link.stories.js +12 -13
- package/build/system/Link/index.d.ts +4 -0
- package/build/system/Link/index.js +1 -0
- package/build/system/NewConfirmationDialog/NewConfirmationDialog.d.ts +23 -0
- package/build/system/NewConfirmationDialog/NewConfirmationDialog.js +86 -99
- package/build/system/NewConfirmationDialog/NewConfirmationDialog.stories.d.ts +8 -0
- package/build/system/NewConfirmationDialog/NewConfirmationDialog.stories.jsx +34 -0
- package/build/system/NewConfirmationDialog/NewConfirmationDialog.test.d.ts +1 -0
- package/build/system/NewConfirmationDialog/NewConfirmationDialog.test.js +43 -66
- package/build/system/NewConfirmationDialog/index.d.ts +2 -0
- package/build/system/NewConfirmationDialog/index.js +5 -4
- package/build/system/NewDialog/DialogClose.d.ts +6 -0
- package/build/system/NewDialog/DialogClose.js +50 -69
- package/build/system/NewDialog/DialogClose.test.d.ts +1 -0
- package/build/system/NewDialog/DialogClose.test.js +29 -46
- package/build/system/NewDialog/DialogContent.d.ts +18 -0
- package/build/system/NewDialog/DialogContent.js +14 -21
- package/build/system/NewDialog/DialogDescription.d.ts +5 -0
- package/build/system/NewDialog/DialogDescription.js +31 -38
- package/build/system/NewDialog/DialogDescription.test.d.ts +1 -0
- package/build/system/NewDialog/DialogDescription.test.js +44 -67
- package/build/system/NewDialog/DialogOverlay.d.ts +2 -0
- package/build/system/NewDialog/DialogOverlay.js +28 -32
- package/build/system/NewDialog/DialogOverlay.test.d.ts +1 -0
- package/build/system/NewDialog/DialogOverlay.test.js +26 -42
- package/build/system/NewDialog/DialogTitle.d.ts +11 -0
- package/build/system/NewDialog/DialogTitle.js +19 -34
- package/build/system/NewDialog/DialogTitle.test.d.ts +1 -0
- package/build/system/NewDialog/DialogTitle.test.js +44 -67
- package/build/system/NewDialog/NewDialog.d.ts +29 -0
- package/build/system/NewDialog/NewDialog.js +74 -89
- package/build/system/NewDialog/NewDialog.stories.d.ts +38 -0
- package/build/system/NewDialog/NewDialog.stories.jsx +192 -0
- package/build/system/NewDialog/index.d.ts +31 -0
- package/build/system/NewDialog/index.js +9 -13
- package/build/system/NewForm/Fieldset.d.ts +2 -0
- package/build/system/NewForm/Fieldset.js +38 -43
- package/build/system/NewForm/Form.d.ts +2 -0
- package/build/system/NewForm/Form.js +21 -28
- package/build/system/NewForm/FormAutocomplete.d.ts +2 -0
- package/build/system/NewForm/FormAutocomplete.js +386 -381
- package/build/system/NewForm/FormAutocomplete.stories.d.ts +156 -0
- package/build/system/NewForm/FormAutocomplete.stories.jsx +159 -0
- package/build/system/NewForm/FormAutocomplete.test.d.ts +1 -0
- package/build/system/NewForm/FormAutocomplete.test.js +40 -73
- package/build/system/NewForm/FormAutocompleteMultiselect.d.ts +2 -0
- package/build/system/NewForm/FormAutocompleteMultiselect.js +456 -468
- package/build/system/NewForm/FormAutocompleteMultiselect.stories.d.ts +45 -0
- package/build/system/NewForm/FormAutocompleteMultiselect.stories.jsx +162 -0
- package/build/system/NewForm/FormAutocompleteMultiselect.test.d.ts +1 -0
- package/build/system/NewForm/FormAutocompleteMultiselect.test.js +37 -73
- package/build/system/NewForm/FormSelect.d.ts +2 -0
- package/build/system/NewForm/FormSelect.js +159 -140
- package/build/system/NewForm/FormSelect.stories.d.ts +137 -0
- package/build/system/NewForm/FormSelect.stories.jsx +138 -0
- package/build/system/NewForm/FormSelect.test.d.ts +1 -0
- package/build/system/NewForm/FormSelect.test.js +131 -227
- package/build/system/NewForm/FormSelectArrow.d.ts +2 -0
- package/build/system/NewForm/FormSelectArrow.js +35 -35
- package/build/system/NewForm/FormSelectContent.d.ts +2 -0
- package/build/system/NewForm/FormSelectContent.js +27 -34
- package/build/system/NewForm/FormSelectInline.d.ts +30 -0
- package/build/system/NewForm/FormSelectInline.js +41 -38
- package/build/system/NewForm/FormSelectLoading.d.ts +2 -0
- package/build/system/NewForm/FormSelectLoading.js +36 -45
- package/build/system/NewForm/FormSelectSearch.d.ts +2 -0
- package/build/system/NewForm/FormSelectSearch.js +23 -25
- package/build/system/NewForm/Legend.d.ts +2 -0
- package/build/system/NewForm/Legend.js +32 -37
- package/build/system/NewForm/index.d.ts +12 -0
- package/build/system/NewForm/index.js +30 -30
- package/build/system/Notice/Notice.d.ts +18 -0
- package/build/system/Notice/Notice.js +41 -55
- package/build/system/Notice/Notice.stories.d.ts +13 -0
- package/build/system/Notice/Notice.stories.js +3 -5
- package/build/system/Notice/index.d.ts +5 -0
- package/build/system/OptionRow/OptionRow.d.ts +2 -0
- package/build/system/OptionRow/OptionRow.js +146 -159
- package/build/system/OptionRow/OptionRow.stories.d.ts +8 -0
- package/build/system/OptionRow/OptionRow.stories.jsx +53 -0
- package/build/system/OptionRow/OptionRow.test.d.ts +1 -0
- package/build/system/OptionRow/OptionRow.test.js +38 -67
- package/build/system/OptionRow/index.d.ts +2 -0
- package/build/system/OptionRow/index.js +5 -4
- package/build/system/Progress/Progress.d.ts +2 -0
- package/build/system/Progress/Progress.js +69 -84
- package/build/system/Progress/Progress.stories.d.ts +8 -0
- package/build/system/Progress/Progress.stories.jsx +25 -0
- package/build/system/Progress/index.d.ts +2 -0
- package/build/system/Progress/index.js +5 -4
- package/build/system/ScreenReaderText/ScreenReader.test.d.ts +1 -0
- package/build/system/ScreenReaderText/ScreenReader.test.js +21 -25
- package/build/system/ScreenReaderText/ScreenReaderText.d.ts +14 -0
- package/build/system/ScreenReaderText/ScreenReaderText.js +13 -21
- package/build/system/ScreenReaderText/index.d.ts +3 -0
- package/build/system/ScreenReaderText/index.js +6 -8
- package/build/system/Spinner/Spinner.d.ts +9 -0
- package/build/system/Spinner/Spinner.js +12 -19
- package/build/system/Spinner/Spinner.stories.d.ts +7 -0
- package/build/system/Spinner/Spinner.stories.js +3 -5
- package/build/system/Spinner/Spinner.test.d.ts +1 -0
- package/build/system/Spinner/Spinner.test.js +59 -0
- package/build/system/Spinner/index.d.ts +1 -0
- package/build/system/Spinner/index.js +1 -0
- package/build/system/Table/Table.d.ts +14 -0
- package/build/system/Table/Table.js +7 -21
- package/build/system/Table/Table.stories.d.ts +9 -0
- package/build/system/Table/Table.stories.js +5 -12
- package/build/system/Table/TableCell.d.ts +15 -0
- package/build/system/Table/TableCell.js +13 -18
- package/build/system/Table/TableRow.d.ts +14 -0
- package/build/system/Table/TableRow.js +19 -24
- package/build/system/Table/index.d.ts +6 -0
- package/build/system/Table/index.js +1 -0
- package/build/system/Tabs/Tabs.d.ts +5 -0
- package/build/system/Tabs/Tabs.js +40 -38
- package/build/system/Tabs/Tabs.stories.d.ts +9 -0
- package/build/system/Tabs/Tabs.stories.jsx +69 -0
- package/build/system/Tabs/TabsContent.d.ts +16 -0
- package/build/system/Tabs/TabsContent.js +23 -30
- package/build/system/Tabs/TabsList.d.ts +15 -0
- package/build/system/Tabs/TabsList.js +24 -32
- package/build/system/Tabs/TabsTrigger.d.ts +2 -0
- package/build/system/Tabs/TabsTrigger.js +58 -66
- package/build/system/Tabs/index.d.ts +5 -0
- package/build/system/Tabs/index.js +8 -10
- package/build/system/Text/Text.d.ts +2 -0
- package/build/system/Text/Text.js +5 -13
- package/build/system/Text/Text.stories.d.ts +8 -0
- package/build/system/Text/Text.stories.js +4 -5
- package/build/system/Text/index.d.ts +4 -0
- package/build/system/Text/index.js +1 -0
- package/build/system/Tooltip/Tooltip.css +96 -0
- package/build/system/Tooltip/Tooltip.d.ts +15 -0
- package/build/system/Tooltip/Tooltip.js +23 -93
- package/build/system/Tooltip/Tooltip.stories.d.ts +15 -0
- package/build/system/Tooltip/Tooltip.stories.js +83 -21
- package/build/system/Tooltip/index.d.ts +5 -0
- package/build/system/Wizard/Wizard.d.ts +2 -0
- package/build/system/Wizard/Wizard.js +94 -103
- package/build/system/Wizard/Wizard.stories.d.ts +9 -0
- package/build/system/Wizard/Wizard.stories.jsx +145 -0
- package/build/system/Wizard/WizardStep.d.ts +2 -0
- package/build/system/Wizard/WizardStep.js +188 -198
- package/build/system/Wizard/WizardStepHorizontal.d.ts +2 -0
- package/build/system/Wizard/WizardStepHorizontal.js +43 -55
- package/build/system/Wizard/index.d.ts +4 -0
- package/build/system/Wizard/index.js +7 -8
- package/build/system/index.d.ts +51 -0
- package/build/system/index.js +104 -86
- package/build/system/theme/colors.d.ts +2 -0
- package/build/system/theme/colors.js +7 -12
- package/build/system/theme/getColor.d.ts +8 -0
- package/build/system/theme/getColor.js +47 -46
- package/build/system/theme/index.d.ts +322 -0
- package/build/system/theme/index.js +494 -396
- package/build/system/theme/textStyles.d.ts +71 -0
- package/build/system/theme/textStyles.js +45 -50
- package/build/system/utils/random.d.ts +1 -0
- package/build/system/utils/random.js +3 -7
- package/package.json +31 -37
- package/src/declaration.d.ts +1 -0
- package/src/system/Accordion/{Accordion.test.js → Accordion.test.tsx} +2 -2
- package/src/system/Accordion/{Accordion.js → Accordion.tsx} +87 -80
- package/src/system/Avatar/Avatar.stories.tsx +18 -0
- package/src/system/Avatar/{Avatar.test.js → Avatar.test.tsx} +2 -2
- package/src/system/Avatar/{Avatar.js → Avatar.tsx} +17 -19
- package/src/system/Avatar/index.ts +4 -0
- package/src/system/Badge/Badge.stories.tsx +57 -0
- package/src/system/Badge/{Badge.test.js → Badge.test.tsx} +3 -3
- package/src/system/Badge/{Badge.js → Badge.tsx} +10 -15
- package/src/system/Badge/index.ts +4 -0
- package/src/system/Box/Box.stories.tsx +13 -1
- package/src/system/Box/Box.tsx +4 -8
- package/src/system/Button/Button.stories.tsx +110 -0
- package/src/system/Button/Button.tsx +67 -0
- package/src/system/Card/{Card.stories.jsx → Card.stories.tsx} +1 -1
- package/src/system/Card/{Card.test.js → Card.test.tsx} +2 -2
- package/src/system/Card/Card.tsx +40 -0
- package/src/system/Card/index.ts +4 -0
- package/src/system/Code/Code.stories.tsx +44 -0
- package/src/system/Code/{Code.test.js → Code.test.tsx} +6 -4
- package/src/system/Code/{Code.js → Code.tsx} +27 -22
- package/src/system/Code/index.ts +4 -0
- package/src/system/Flex/Flex.tsx +11 -0
- package/src/system/Flex/index.ts +4 -0
- package/src/system/Grid/Grid.tsx +11 -0
- package/src/system/Grid/index.ts +4 -0
- package/src/system/Heading/Heading.tsx +8 -17
- package/src/system/Link/Link.stories.tsx +23 -0
- package/src/system/Link/Link.tsx +43 -0
- package/src/system/Link/index.ts +4 -0
- package/src/system/NewForm/FormAutocomplete.js +2 -2
- package/src/system/Notice/Notice.tsx +129 -0
- package/src/system/OptionRow/OptionRow.test.js +1 -1
- package/src/system/ScreenReaderText/ScreenReaderText.tsx +40 -0
- package/src/system/Spinner/Spinner.test.tsx +30 -0
- package/src/system/Spinner/Spinner.tsx +34 -0
- package/src/system/Spinner/index.ts +1 -0
- package/src/system/Table/{Table.stories.jsx → Table.stories.tsx} +6 -6
- package/src/system/Table/{Table.js → Table.tsx} +14 -18
- package/src/system/Table/{TableCell.js → TableCell.tsx} +14 -12
- package/src/system/Table/TableRow.tsx +63 -0
- package/src/system/Table/index.ts +6 -0
- package/src/system/Text/{Text.stories.jsx → Text.stories.tsx} +1 -0
- package/src/system/Text/Text.tsx +25 -0
- package/src/system/Text/index.ts +4 -0
- package/src/system/Tooltip/Tooltip.css +96 -0
- package/src/system/Tooltip/Tooltip.stories.tsx +133 -0
- package/src/system/Tooltip/Tooltip.tsx +39 -0
- package/src/system/index.js +1 -2
- package/src/system/theme/index.js +21 -1
- package/test/fileMock.ts +1 -0
- package/test/setupAfterEnv.ts +5 -0
- package/tsconfig.definition.json +12 -0
- package/.storybook/decorators/withBoundingBox.jsx +0 -22
- package/build/system/Box/Box.stories.tsx +0 -11
- package/build/system/Box/Box.tsx +0 -22
- package/build/system/Button/ButtonSubmit.stories.js +0 -58
- package/build/system/ConfirmationDialog/ConfirmationDialog.stories.js +0 -42
- package/build/system/Dialog/Dialog.stories.js +0 -70
- package/build/system/Dropdown/Dropdown.stories.js +0 -197
- package/build/system/Form/Checkbox.stories.js +0 -73
- package/build/system/Form/Input.stories.js +0 -51
- package/build/system/Form/InputWithCopyButton.stories.js +0 -39
- package/build/system/Form/Radio.stories.js +0 -115
- package/build/system/Form/RadioBoxGroup.stories.js +0 -62
- package/build/system/Form/Textarea.stories.js +0 -59
- package/build/system/Form/Toggle.stories.js +0 -104
- package/build/system/Heading/Heading.stories.tsx +0 -19
- package/build/system/Heading/Heading.tsx +0 -38
- package/build/system/NewConfirmationDialog/NewConfirmationDialog.stories.js +0 -46
- package/build/system/NewDialog/NewDialog.stories.js +0 -247
- package/build/system/NewForm/FormAutocomplete.stories.js +0 -220
- package/build/system/NewForm/FormAutocompleteMultiselect.stories.js +0 -231
- package/build/system/NewForm/FormSelect.stories.js +0 -171
- package/build/system/Notification/Notification.js +0 -97
- package/build/system/Notification/Notification.stories.js +0 -29
- package/build/system/Notification/index.js +0 -5
- package/build/system/OptionRow/OptionRow.stories.js +0 -64
- package/build/system/Progress/Progress.stories.js +0 -36
- package/build/system/Tabs/Tabs.stories.js +0 -113
- package/build/system/Wizard/Wizard.stories.js +0 -182
- package/src/system/Avatar/Avatar.stories.jsx +0 -11
- package/src/system/Avatar/index.js +0 -6
- package/src/system/Badge/Badge.stories.jsx +0 -43
- package/src/system/Badge/index.js +0 -6
- package/src/system/Button/Button.js +0 -63
- package/src/system/Button/Button.stories.jsx +0 -87
- package/src/system/Card/Card.js +0 -39
- package/src/system/Card/index.js +0 -6
- package/src/system/Code/Code.stories.jsx +0 -37
- package/src/system/Code/index.js +0 -6
- package/src/system/Flex/Flex.js +0 -15
- package/src/system/Flex/index.js +0 -6
- package/src/system/Grid/Grid.js +0 -16
- package/src/system/Grid/index.js +0 -6
- package/src/system/Link/Link.js +0 -42
- package/src/system/Link/Link.stories.jsx +0 -15
- package/src/system/Link/index.js +0 -6
- package/src/system/Notice/Notice.js +0 -136
- package/src/system/Notification/Notification.js +0 -66
- package/src/system/Notification/Notification.stories.jsx +0 -16
- package/src/system/Notification/index.js +0 -6
- package/src/system/ScreenReaderText/ScreenReaderText.js +0 -39
- package/src/system/Spinner/Spinner.js +0 -34
- package/src/system/Spinner/index.js +0 -6
- package/src/system/Table/TableRow.js +0 -50
- package/src/system/Table/index.js +0 -8
- package/src/system/Text/Text.js +0 -33
- package/src/system/Text/index.js +0 -6
- package/src/system/Tooltip/Tooltip.js +0 -79
- package/src/system/Tooltip/Tooltip.stories.jsx +0 -22
- package/test/fileMock.js +0 -1
- package/test/setupAfterEnv.js +0 -13
- package/test/setupTests.js +0 -4
- /package/.storybook/decorators/{withColorMode.jsx → withColorMode.tsx} +0 -0
- /package/src/system/Accordion/{Accordion.stories.jsx → Accordion.stories.tsx} +0 -0
- /package/src/system/Accordion/{index.js → index.ts} +0 -0
- /package/src/system/Flex/{Flex.stories.jsx → Flex.stories.tsx} +0 -0
- /package/src/system/Grid/{Grid.stories.jsx → Grid.stories.tsx} +0 -0
- /package/src/system/Notice/{Notice.stories.jsx → Notice.stories.tsx} +0 -0
- /package/src/system/Notice/{index.js → index.ts} +0 -0
- /package/src/system/Spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +0 -0
- /package/src/system/Tooltip/{index.js → index.ts} +0 -0
|
@@ -1,46 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.DialogTitle = void 0;
|
|
5
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
6
|
-
var DialogPrimitive = _interopRequireWildcard(require("@radix-ui/react-dialog"));
|
|
7
|
-
var _ScreenReaderText = _interopRequireDefault(require("../ScreenReaderText"));
|
|
8
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
1
|
/** @jsxImportSource theme-ui */
|
|
13
2
|
|
|
14
3
|
/**
|
|
15
4
|
* External dependencies
|
|
16
5
|
*/
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
8
|
+
import ScreenReaderText from '../ScreenReaderText';
|
|
17
9
|
|
|
18
10
|
/**
|
|
19
11
|
* Internal dependencies
|
|
20
12
|
*/
|
|
21
13
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
margin: 0,
|
|
35
|
-
fontSize: 3,
|
|
36
|
-
fontWeight: 500,
|
|
37
|
-
color: 'heading'
|
|
38
|
-
},
|
|
39
|
-
children: titleNode
|
|
40
|
-
});
|
|
14
|
+
export const DialogTitle = ( { title, hidden = false } ) => {
|
|
15
|
+
let titleNode = title;
|
|
16
|
+
|
|
17
|
+
if ( hidden ) {
|
|
18
|
+
titleNode = <ScreenReaderText>{ titleNode }</ScreenReaderText>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<DialogPrimitive.Title sx={ { margin: 0, fontSize: 3, fontWeight: 500, color: 'heading' } }>
|
|
23
|
+
{ titleNode }
|
|
24
|
+
</DialogPrimitive.Title>
|
|
25
|
+
);
|
|
41
26
|
};
|
|
42
|
-
|
|
27
|
+
|
|
43
28
|
DialogTitle.propTypes = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
29
|
+
title: PropTypes.node,
|
|
30
|
+
hidden: PropTypes.bool,
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,70 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Dialog } from '@radix-ui/react-dialog';
|
|
5
|
+
import { render, screen } from '@testing-library/react';
|
|
6
|
+
import { axe } from 'jest-axe';
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* External dependencies
|
|
13
|
-
*/ /**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/ // If you render any Dialog child without the `<Dialog />` parent, it will throw an error.
|
|
16
|
-
var Wrapper = function Wrapper(props) {
|
|
17
|
-
return (0, _jsxRuntime.jsx)(_reactDialog.Dialog, _extends({
|
|
18
|
-
open: true
|
|
19
|
-
}, props));
|
|
20
|
-
};
|
|
21
|
-
var defaultProps = {
|
|
22
|
-
title: 'This is a DialogTitle'
|
|
23
|
-
};
|
|
24
|
-
var getTitle = function getTitle() {
|
|
25
|
-
return _react.screen.getByRole('heading');
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { DialogTitle } from './DialogTitle';
|
|
12
|
+
|
|
13
|
+
// If you render any Dialog child without the `<Dialog />` parent, it will throw an error.
|
|
14
|
+
const Wrapper = props => <Dialog open={ true } { ...props } />;
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
title: 'This is a DialogTitle',
|
|
26
17
|
};
|
|
27
|
-
describe('<DialogTitle />', function () {
|
|
28
|
-
it('renders the DialogTitle component', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
29
|
-
var _render, container;
|
|
30
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
31
|
-
while (1) switch (_context.prev = _context.next) {
|
|
32
|
-
case 0:
|
|
33
|
-
_render = (0, _react.render)((0, _jsxRuntime.jsx)(Wrapper, {
|
|
34
|
-
children: (0, _jsxRuntime.jsx)(_DialogTitle.DialogTitle, _extends({}, defaultProps))
|
|
35
|
-
})), container = _render.container;
|
|
36
|
-
expect(getTitle()).toHaveTextContent(defaultProps.title);
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
}, _callee2);
|
|
69
|
-
})));
|
|
70
|
-
});
|
|
19
|
+
const getTitle = () => screen.getByRole( 'heading' );
|
|
20
|
+
|
|
21
|
+
describe( '<DialogTitle />', () => {
|
|
22
|
+
it( 'renders the DialogTitle component', async () => {
|
|
23
|
+
const { container } = render(
|
|
24
|
+
<Wrapper>
|
|
25
|
+
<DialogTitle { ...defaultProps } />
|
|
26
|
+
</Wrapper>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect( getTitle() ).toHaveTextContent( defaultProps.title );
|
|
30
|
+
|
|
31
|
+
// Check for accessibility issues
|
|
32
|
+
await expect( await axe( container ) ).toHaveNoViolations();
|
|
33
|
+
} );
|
|
34
|
+
|
|
35
|
+
it( 'renders text visually hidden for a11y purposes', async () => {
|
|
36
|
+
const { container } = render(
|
|
37
|
+
<Wrapper>
|
|
38
|
+
<DialogTitle { ...defaultProps } hidden={ true } />
|
|
39
|
+
</Wrapper>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Small check to make sure we are hiding with the css class
|
|
43
|
+
expect( container.innerHTML ).toContain( 'screen-reader-text' );
|
|
44
|
+
|
|
45
|
+
expect( getTitle() ).toHaveTextContent( defaultProps.title );
|
|
46
|
+
} );
|
|
47
|
+
} );
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function NewDialog({ trigger, description, title, content, showHeading, disabled, style: extraStyles, contentProps, portalProps, className, ...props }: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
trigger?: null | undefined;
|
|
4
|
+
description: any;
|
|
5
|
+
title: any;
|
|
6
|
+
content?: null | undefined;
|
|
7
|
+
showHeading?: boolean | undefined;
|
|
8
|
+
disabled?: boolean | undefined;
|
|
9
|
+
style: any;
|
|
10
|
+
contentProps?: {} | undefined;
|
|
11
|
+
portalProps?: {} | undefined;
|
|
12
|
+
className?: null | undefined;
|
|
13
|
+
}): React.JSX.Element | undefined;
|
|
14
|
+
export namespace NewDialog {
|
|
15
|
+
namespace propTypes {
|
|
16
|
+
let trigger: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
17
|
+
let title: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
18
|
+
let description: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
19
|
+
let content: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>;
|
|
20
|
+
let showHeading: PropTypes.Requireable<boolean>;
|
|
21
|
+
let disabled: PropTypes.Requireable<boolean>;
|
|
22
|
+
let style: PropTypes.Requireable<object>;
|
|
23
|
+
let className: PropTypes.Requireable<any>;
|
|
24
|
+
let contentProps: PropTypes.Requireable<any>;
|
|
25
|
+
let portalProps: PropTypes.Requireable<any>;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
import React from 'react';
|
|
29
|
+
import PropTypes from 'prop-types';
|
|
@@ -1,99 +1,84 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.NewDialog = void 0;
|
|
5
|
-
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
|
-
var DialogPrimitive = _interopRequireWildcard(require("@radix-ui/react-dialog"));
|
|
9
|
-
var _DialogOverlay = require("./DialogOverlay");
|
|
10
|
-
var _DialogClose = require("./DialogClose");
|
|
11
|
-
var _DialogTitle = require("./DialogTitle");
|
|
12
|
-
var _DialogDescription = require("./DialogDescription");
|
|
13
|
-
var _DialogContent = require("./DialogContent");
|
|
14
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
15
|
-
var _excluded = ["trigger", "description", "title", "content", "showHeading", "disabled", "style", "contentProps", "portalProps", "className"];
|
|
16
1
|
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
17
3
|
/**
|
|
18
4
|
* External dependencies
|
|
19
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
10
|
+
|
|
20
11
|
/**
|
|
21
12
|
* Internal dependencies
|
|
22
13
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
14
|
+
import { DialogOverlay } from './DialogOverlay';
|
|
15
|
+
import { DialogCloseDefault as DialogClose } from './DialogClose';
|
|
16
|
+
import { DialogTitle } from './DialogTitle';
|
|
17
|
+
import { DialogDescription } from './DialogDescription';
|
|
18
|
+
import { contentStyles } from './DialogContent';
|
|
19
|
+
|
|
20
|
+
export const NewDialog = ( {
|
|
21
|
+
trigger = null,
|
|
22
|
+
description,
|
|
23
|
+
title,
|
|
24
|
+
content = null,
|
|
25
|
+
showHeading = true,
|
|
26
|
+
disabled = false,
|
|
27
|
+
style: extraStyles,
|
|
28
|
+
contentProps = {},
|
|
29
|
+
portalProps = {},
|
|
30
|
+
className = null,
|
|
31
|
+
...props
|
|
32
|
+
} ) => {
|
|
33
|
+
const closeRef = React.useRef( null );
|
|
34
|
+
|
|
35
|
+
if ( disabled ) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// if content is a function, pass in onClose
|
|
40
|
+
const isContentFunction = typeof content === 'function';
|
|
41
|
+
|
|
42
|
+
const onClose = () => {
|
|
43
|
+
closeRef?.current?.click();
|
|
44
|
+
};
|
|
51
45
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
description: description,
|
|
74
|
-
hidden: !showHeading
|
|
75
|
-
}), (0, _jsxRuntime.jsx)("div", {
|
|
76
|
-
role: "document",
|
|
77
|
-
children: isContentFunction ? content({
|
|
78
|
-
onClose: onClose
|
|
79
|
-
}) : content
|
|
80
|
-
})]
|
|
81
|
-
}))]
|
|
82
|
-
}))]
|
|
83
|
-
}));
|
|
46
|
+
return (
|
|
47
|
+
<DialogPrimitive.Root { ...props }>
|
|
48
|
+
{ trigger && <DialogPrimitive.Trigger asChild>{ trigger }</DialogPrimitive.Trigger> }
|
|
49
|
+
|
|
50
|
+
<DialogPrimitive.Portal { ...portalProps }>
|
|
51
|
+
<DialogOverlay />
|
|
52
|
+
|
|
53
|
+
<DialogPrimitive.Content
|
|
54
|
+
className={ classNames( 'vip-dialog-component', className ) }
|
|
55
|
+
sx={ { ...contentStyles, ...extraStyles } }
|
|
56
|
+
{ ...contentProps }
|
|
57
|
+
>
|
|
58
|
+
<DialogClose ref={ closeRef } />
|
|
59
|
+
<DialogTitle title={ title } hidden={ ! showHeading } />
|
|
60
|
+
<DialogDescription description={ description } hidden={ ! showHeading } />
|
|
61
|
+
|
|
62
|
+
<div role="document">{ isContentFunction ? content( { onClose } ) : content }</div>
|
|
63
|
+
</DialogPrimitive.Content>
|
|
64
|
+
</DialogPrimitive.Portal>
|
|
65
|
+
</DialogPrimitive.Root>
|
|
66
|
+
);
|
|
84
67
|
};
|
|
85
|
-
|
|
68
|
+
|
|
86
69
|
NewDialog.propTypes = {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
70
|
+
trigger: PropTypes.node.isRequired,
|
|
71
|
+
title: PropTypes.node.isRequired,
|
|
72
|
+
description: PropTypes.node.isRequired,
|
|
73
|
+
content: PropTypes.oneOfType( [ PropTypes.node, PropTypes.func ] ),
|
|
74
|
+
showHeading: PropTypes.bool,
|
|
75
|
+
disabled: PropTypes.bool,
|
|
76
|
+
style: PropTypes.oneOfType( [ PropTypes.object, PropTypes.func ] ),
|
|
77
|
+
className: PropTypes.any,
|
|
78
|
+
|
|
79
|
+
// Content props in: https://www.radix-ui.com/docs/primitives/components/dialog#content
|
|
80
|
+
contentProps: PropTypes.any,
|
|
81
|
+
|
|
82
|
+
// Portal props in: https://www.radix-ui.com/docs/primitives/components/dialog#portal
|
|
83
|
+
portalProps: PropTypes.any,
|
|
84
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
let title: string;
|
|
3
|
+
let component: {
|
|
4
|
+
({ trigger, description, title, content, showHeading, disabled, style: extraStyles, contentProps, portalProps, className, ...props }: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
trigger?: null | undefined;
|
|
7
|
+
description: any;
|
|
8
|
+
title: any;
|
|
9
|
+
content?: null | undefined;
|
|
10
|
+
showHeading?: boolean | undefined;
|
|
11
|
+
disabled?: boolean | undefined;
|
|
12
|
+
style: any;
|
|
13
|
+
contentProps?: {} | undefined;
|
|
14
|
+
portalProps?: {} | undefined;
|
|
15
|
+
className?: null | undefined;
|
|
16
|
+
}): import("react").JSX.Element | undefined;
|
|
17
|
+
propTypes: {
|
|
18
|
+
trigger: import("prop-types").Validator<NonNullable<import("prop-types").ReactNodeLike>>;
|
|
19
|
+
title: import("prop-types").Validator<NonNullable<import("prop-types").ReactNodeLike>>;
|
|
20
|
+
description: import("prop-types").Validator<NonNullable<import("prop-types").ReactNodeLike>>;
|
|
21
|
+
content: import("prop-types").Requireable<NonNullable<import("prop-types").ReactNodeLike | ((...args: any[]) => any)>>;
|
|
22
|
+
showHeading: import("prop-types").Requireable<boolean>;
|
|
23
|
+
disabled: import("prop-types").Requireable<boolean>;
|
|
24
|
+
style: import("prop-types").Requireable<object>;
|
|
25
|
+
className: import("prop-types").Requireable<any>;
|
|
26
|
+
contentProps: import("prop-types").Requireable<any>;
|
|
27
|
+
portalProps: import("prop-types").Requireable<any>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export default _default;
|
|
32
|
+
export function Default(): import("react").JSX.Element;
|
|
33
|
+
export function AutoOpen(): import("react").JSX.Element;
|
|
34
|
+
export function HiddenHeadings(): import("react").JSX.Element;
|
|
35
|
+
export function CustomStyling(): import("react").JSX.Element;
|
|
36
|
+
export function CustomClose(): import("react").JSX.Element;
|
|
37
|
+
export function CustomStateManagement(): import("react").JSX.Element;
|
|
38
|
+
export function CustomOnClose(): import("react").JSX.Element;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { Button, Text, Input, Label } from '../../system';
|
|
13
|
+
import ScreenReaderText from '../ScreenReaderText';
|
|
14
|
+
import * as NewDialog from '.';
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
title: 'Dialog/NewDialog',
|
|
18
|
+
component: NewDialog.Root,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const defaultProps = {
|
|
22
|
+
title: 'User settings',
|
|
23
|
+
description: 'Use this form to manage your settings',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Default = () => (
|
|
27
|
+
<>
|
|
28
|
+
<Text sx={ { fontSize: 3, mb: 3 } }>
|
|
29
|
+
Regular Dialog where the title and description are built-in and the content is provided by the
|
|
30
|
+
user.
|
|
31
|
+
</Text>
|
|
32
|
+
<NewDialog.Root { ...defaultProps } trigger={ <Button>Trigger Dialog</Button> } />
|
|
33
|
+
</>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export const AutoOpen = () => (
|
|
37
|
+
<>
|
|
38
|
+
<Text sx={ { fontSize: 3, mb: 3 } }>Auto Opens when rendered. Press escape to close it.</Text>
|
|
39
|
+
<NewDialog.Root
|
|
40
|
+
{ ...defaultProps }
|
|
41
|
+
defaultOpen={ true }
|
|
42
|
+
content={
|
|
43
|
+
<div>
|
|
44
|
+
<h3>Test</h3>
|
|
45
|
+
<p>
|
|
46
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
|
|
47
|
+
has been the industry standard dummy text ever since the 1500s, when an unknown printer
|
|
48
|
+
took a galley of type and scrambled it to make a type specimen book. It has survived not
|
|
49
|
+
only five centuries, but also the leap into electronic typesetting, remaining
|
|
50
|
+
essentially unchanged. It was popularised in the 1960s with the release of Letraset
|
|
51
|
+
sheets containing Lorem Ipsum passages, and more recently with desktop publishing
|
|
52
|
+
software like Aldus PageMaker including versions of Lorem Ipsum.
|
|
53
|
+
</p>
|
|
54
|
+
</div>
|
|
55
|
+
}
|
|
56
|
+
trigger={ <ScreenReaderText>hey</ScreenReaderText> }
|
|
57
|
+
/>
|
|
58
|
+
</>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
export const HiddenHeadings = () => (
|
|
62
|
+
<>
|
|
63
|
+
<Text sx={ { fontSize: 3, mb: 3 } }>
|
|
64
|
+
Title and description are hidden, but still announced using a screen reader. Activate
|
|
65
|
+
VoiceOver or any similar screen reader to listen to: Custom dialog title, Description of the
|
|
66
|
+
dialog content.
|
|
67
|
+
</Text>
|
|
68
|
+
|
|
69
|
+
<NewDialog.Root
|
|
70
|
+
{ ...defaultProps }
|
|
71
|
+
trigger={ <Button>Trigger Dialog</Button> }
|
|
72
|
+
title="Custom dialog title"
|
|
73
|
+
showHeading={ false }
|
|
74
|
+
content={
|
|
75
|
+
<div>
|
|
76
|
+
<h3>My Custom Content</h3>
|
|
77
|
+
|
|
78
|
+
<form>
|
|
79
|
+
<Label htmlFor="username">User name</Label>
|
|
80
|
+
<Input type="text" name="username" id="username" />
|
|
81
|
+
<Button type="submit">Submit</Button>
|
|
82
|
+
</form>
|
|
83
|
+
|
|
84
|
+
<h3>Continue here</h3>
|
|
85
|
+
|
|
86
|
+
<p>This is an example.</p>
|
|
87
|
+
</div>
|
|
88
|
+
}
|
|
89
|
+
/>
|
|
90
|
+
</>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
export const CustomStyling = () => (
|
|
94
|
+
<>
|
|
95
|
+
<Text sx={ { fontSize: 3, mb: 3 } }>Custom Styling on Dialog Content</Text>
|
|
96
|
+
|
|
97
|
+
<NewDialog.Root
|
|
98
|
+
{ ...defaultProps }
|
|
99
|
+
defaultOpen
|
|
100
|
+
trigger={ <Button>Trigger Dialog</Button> }
|
|
101
|
+
title="Custom dialog title"
|
|
102
|
+
style={ {
|
|
103
|
+
background: theme => `${ theme.colors.primary }`,
|
|
104
|
+
padding: 5,
|
|
105
|
+
borderRadius: 20,
|
|
106
|
+
h2: { fontSize: 4, color: theme => `${ theme.colors.text }` },
|
|
107
|
+
h3: { fontSize: 3, color: theme => `${ theme.colors.heading }` },
|
|
108
|
+
p: { color: 'white' },
|
|
109
|
+
'button[type="button"]:focus': { outlineColor: 'white', color: 'white' },
|
|
110
|
+
} }
|
|
111
|
+
content={
|
|
112
|
+
<div>
|
|
113
|
+
<h3>This is Read because it is Custom</h3>
|
|
114
|
+
|
|
115
|
+
<p>This Dialog is styled using the `sx` property.</p>
|
|
116
|
+
</div>
|
|
117
|
+
}
|
|
118
|
+
/>
|
|
119
|
+
</>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
export const CustomClose = () => (
|
|
123
|
+
<>
|
|
124
|
+
<Text sx={ { fontSize: 3, mb: 3 } }>
|
|
125
|
+
This example shows how you can create a custom Close trigger to your dialog
|
|
126
|
+
</Text>
|
|
127
|
+
<NewDialog.Root
|
|
128
|
+
{ ...defaultProps }
|
|
129
|
+
trigger={ <Button>Trigger Dialog</Button> }
|
|
130
|
+
content={
|
|
131
|
+
<div>
|
|
132
|
+
<NewDialog.Close>
|
|
133
|
+
<Button>Close here instead</Button>
|
|
134
|
+
</NewDialog.Close>
|
|
135
|
+
</div>
|
|
136
|
+
}
|
|
137
|
+
/>
|
|
138
|
+
</>
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
export const CustomStateManagement = () => {
|
|
142
|
+
const [ open, setOpen ] = useState( false );
|
|
143
|
+
return (
|
|
144
|
+
<>
|
|
145
|
+
<Text sx={ { fontSize: 3, mb: 3 } }>
|
|
146
|
+
This example shows how you can create a custom state management. To achieve accessibility,
|
|
147
|
+
you need to control the <strong>open</strong> state, but also keep consistency using the{ ' ' }
|
|
148
|
+
<strong>onOpenChange</strong> attribute.
|
|
149
|
+
</Text>
|
|
150
|
+
|
|
151
|
+
<NewDialog.Root
|
|
152
|
+
{ ...defaultProps }
|
|
153
|
+
open={ open }
|
|
154
|
+
onOpenChange={ status => {
|
|
155
|
+
// eslint-disable-next-line no-console
|
|
156
|
+
console.log( 'New status changed', status );
|
|
157
|
+
|
|
158
|
+
setOpen( ! open );
|
|
159
|
+
} }
|
|
160
|
+
trigger={ <Button>Trigger Dialog</Button> }
|
|
161
|
+
content={
|
|
162
|
+
<div sx={ { mt: 2 } }>
|
|
163
|
+
<NewDialog.Close>
|
|
164
|
+
<Button>Close here instead</Button>
|
|
165
|
+
</NewDialog.Close>
|
|
166
|
+
</div>
|
|
167
|
+
}
|
|
168
|
+
/>
|
|
169
|
+
</>
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export const CustomOnClose = () => {
|
|
174
|
+
return (
|
|
175
|
+
<>
|
|
176
|
+
<Text sx={ { fontSize: 3, mb: 3 } }>
|
|
177
|
+
This example shows how you can use the content as a function to use the onClose method (same
|
|
178
|
+
behavior as the original Dialog component).
|
|
179
|
+
</Text>
|
|
180
|
+
|
|
181
|
+
<NewDialog.Root
|
|
182
|
+
{ ...defaultProps }
|
|
183
|
+
trigger={ <Button>Trigger Dialog</Button> }
|
|
184
|
+
content={ ( { onClose } ) => (
|
|
185
|
+
<div sx={ { mt: 2 } }>
|
|
186
|
+
<Button onClick={ onClose }>Close here instead</Button>
|
|
187
|
+
</div>
|
|
188
|
+
) }
|
|
189
|
+
/>
|
|
190
|
+
</>
|
|
191
|
+
);
|
|
192
|
+
};
|