@innovaccer/design-system 2.5.0 → 2.7.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +54 -0
- package/.github/workflows/chromatic.yml +5 -0
- package/.github/workflows/main.yml +2 -2
- package/.github/workflows/pull_request.yml +2 -2
- package/.github/workflows/test.yml +1 -1
- package/.husky/commit-msg +4 -0
- package/.prettierrc +2 -2
- package/.storybook/main.js +4 -0
- package/.vscode/settings.json +11 -0
- package/CHANGELOG.md +78 -0
- package/CONTRIBUTING.md +180 -98
- package/commitlint.config.js +1 -0
- package/core/accessibility/utils/index.ts +5 -0
- package/core/accessibility/utils/isEnterKey.ts +5 -0
- package/core/accessibility/utils/isSpaceKey.ts +5 -0
- package/core/accessibility/utils/useAccessibilityProps.ts +33 -0
- package/core/common.type.tsx +22 -0
- package/core/components/atoms/_chip/__tests__/__snapshots__/_chip.test.tsx.snap +17 -9
- package/core/components/atoms/_chip/index.tsx +19 -3
- package/core/components/atoms/avatar/Avatar.tsx +4 -14
- package/core/components/atoms/avatar/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/avatar/__tests__/Avatar.test.tsx +14 -9
- package/core/components/atoms/avatarGroup/AvatarGroup.tsx +3 -5
- package/core/components/atoms/badge/Badge.tsx +2 -12
- package/core/components/atoms/badge/__tests__/Badge.test.tsx +22 -7
- package/core/components/atoms/badge/_stories_/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/badge/_stories_/variants/Subtle.story.tsx +3 -2
- package/core/components/atoms/button/Button.tsx +10 -7
- package/core/components/atoms/button/__stories__/Alert.story.tsx +8 -1
- package/core/components/atoms/button/__stories__/Cancel.story.tsx +4 -1
- package/core/components/atoms/button/__stories__/IconButtonGroup.story.tsx +12 -3
- package/core/components/atoms/button/__stories__/IconButtonSecondary.story.tsx +6 -1
- package/core/components/atoms/button/__stories__/IconLeftSecondary.story.tsx +4 -1
- package/core/components/atoms/button/__stories__/IconRightSecondary.story.tsx +4 -1
- package/core/components/atoms/button/__stories__/IconTransparent.story.tsx +4 -1
- package/core/components/atoms/button/__stories__/LabelButtonGroup.story.tsx +14 -3
- package/core/components/atoms/button/__stories__/LargeIconExpanded.story.tsx +4 -1
- package/core/components/atoms/button/__stories__/LoadingPrimary.story.tsx +4 -1
- package/core/components/atoms/button/__stories__/Primary.story.tsx +5 -2
- package/core/components/atoms/button/__stories__/SplitButton.story.tsx +6 -1
- package/core/components/atoms/button/__stories__/Transparent.story.tsx +8 -1
- package/core/components/atoms/button/__stories__/index.story.tsx +12 -2
- package/core/components/atoms/button/__stories__/variants/Appearance.story.tsx +6 -2
- package/core/components/atoms/button/__stories__/variants/Expanded.story.tsx +6 -2
- package/core/components/atoms/button/__stories__/variants/Size.story.tsx +4 -0
- package/core/components/atoms/button/__stories__/variants/icon/Icon.story.tsx +15 -0
- package/core/components/atoms/button/__stories__/variants/icon/IconLeft.story.tsx +6 -2
- package/core/components/atoms/button/__stories__/variants/icon/IconRight.story.tsx +6 -2
- package/core/components/atoms/button/__stories__/variants/state/Alert.story.tsx +7 -17
- package/core/components/atoms/button/__stories__/variants/state/Basic.story.tsx +9 -17
- package/core/components/atoms/button/__stories__/variants/state/Primary.story.tsx +7 -17
- package/core/components/atoms/button/__stories__/variants/state/Transparent.story.tsx +13 -17
- package/core/components/atoms/button/__tests__/Button.test.tsx +1 -1
- package/core/components/atoms/button/__tests__/__snapshots__/Button.test.tsx.snap +0 -137
- package/core/components/atoms/card/__stories__/empty.story.tsx +1 -1
- package/core/components/atoms/card/__stories__/nested.story.tsx +1 -1
- package/core/components/atoms/card/__stories__/scroll.story.tsx +1 -1
- package/core/components/atoms/checkbox/Checkbox.tsx +8 -9
- package/core/components/atoms/checkbox/__stories__/variants/Size.story.tsx +2 -2
- package/core/components/atoms/chip/Chip.tsx +3 -2
- package/core/components/atoms/chip/__stories__/variants/Selection.story.tsx +17 -0
- package/core/components/atoms/chip/__stories__/variants/Type.story.tsx +2 -2
- package/core/components/atoms/chip/__tests__/Chip.test.tsx +7 -0
- package/core/components/atoms/chipGroup/__tests__/__snapshots__/chipGroup.test.tsx.snap +11 -5
- package/core/components/atoms/chipGroup/__tests__/chipGroup.test.tsx +2 -2
- package/core/components/atoms/chipGroup/_stories_/index.story.tsx +2 -2
- package/core/components/atoms/collapsible/__tests__/__snapshots__/Collapsible.test.tsx.snap +8 -0
- package/core/components/atoms/divider/Divider.tsx +44 -0
- package/core/components/atoms/divider/__stories__/BasicDividerInCard.story.tsx +74 -0
- package/core/components/atoms/divider/__stories__/HeaderDividerInCard.story.tsx +35 -0
- package/core/components/atoms/divider/__stories__/IndentedDivider.story.tsx +49 -0
- package/core/components/atoms/divider/__stories__/Vertical.story.tsx +51 -0
- package/core/components/atoms/divider/__stories__/index.story.tsx +91 -0
- package/core/components/atoms/divider/__stories__/variants/HorizontalDivider.story.tsx +27 -0
- package/core/components/atoms/divider/__tests__/Divider.test.tsx +50 -0
- package/core/components/atoms/divider/__tests__/__snapshots__/Divider.test.tsx.snap +53 -0
- package/core/components/atoms/divider/index.tsx +2 -0
- package/core/components/atoms/dropdown/Dropdown.tsx +18 -17
- package/core/components/atoms/dropdown/DropdownButton.tsx +2 -2
- package/core/components/atoms/dropdown/DropdownList.tsx +18 -7
- package/core/components/atoms/dropdown/Loading.tsx +1 -1
- package/core/components/atoms/dropdown/__stories__/CustomSearchPlaceholder.story.tsx +45 -0
- package/core/components/atoms/dropdown/__stories__/_common_/types.tsx +3 -0
- package/core/components/atoms/dropdown/__stories__/variants/Size.story.tsx +2 -2
- package/core/components/atoms/dropdown/__stories__/variants/controlledDropdown/MultiSelect.story.tsx +28 -18
- package/core/components/atoms/dropdown/__tests__/Dropdown.test.tsx +12 -1
- package/core/components/atoms/dropdown/__tests__/Loading.test.tsx +0 -1
- package/core/components/atoms/dropdown/option/DefaultOption.tsx +3 -0
- package/core/components/atoms/dropdown/option/IconOption.tsx +3 -0
- package/core/components/atoms/dropdown/option/IconWithMetaOption.tsx +3 -0
- package/core/components/atoms/dropdown/option/MetaOption.tsx +3 -0
- package/core/components/atoms/dropdown/option/index.tsx +1 -1
- package/core/components/atoms/editable/Editable.tsx +3 -0
- package/core/components/atoms/heading/Heading.tsx +4 -4
- package/core/components/atoms/heading/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/heading/__tests__/Heading.test.tsx +4 -3
- package/core/components/atoms/icon/Icon.tsx +16 -5
- package/core/components/atoms/icon/__stories__/variants/Image.story.tsx +6 -1
- package/core/components/atoms/icon/__tests__/__snapshots__/Icon.test.tsx.snap +74 -0
- package/core/components/atoms/input/Input.tsx +17 -7
- package/core/components/atoms/input/__stories__/BasicInput.story.tsx +2 -1
- package/core/components/atoms/input/__stories__/InputWithCaption.story.tsx +91 -9
- package/core/components/atoms/input/__stories__/InputWithLabel.story.tsx +11 -3
- package/core/components/atoms/input/__stories__/LabelPosition.story.tsx +46 -4
- package/core/components/atoms/input/__stories__/RequiredVsOptional.story.tsx +12 -8
- package/core/components/atoms/input/__stories__/variants/controlledInput.story.tsx +46 -0
- package/core/components/atoms/input/__stories__/variants/types/BasicInput.story.tsx +2 -2
- package/core/components/atoms/input/__stories__/variants/types/IconLeft.story.tsx +2 -10
- package/core/components/atoms/input/__stories__/variants/types/WithLabel.story.tsx +1 -9
- package/core/components/atoms/input/__tests__/__snapshots__/Input.test.tsx.snap +19 -0
- package/core/components/atoms/label/Label.tsx +1 -1
- package/core/components/atoms/legend/Legend.tsx +5 -2
- package/core/components/atoms/legend/__stories__/variants/labelAppearance.story.tsx +2 -2
- package/core/components/atoms/link/Link.tsx +4 -4
- package/core/components/atoms/message/Message.tsx +12 -12
- package/core/components/atoms/message/__stories__/index.story.tsx +1 -1
- package/core/components/atoms/message/__stories__/variants/Appearance.story.tsx +1 -1
- package/core/components/atoms/message/__stories__/variants/AppearanceTitle.story.tsx +1 -1
- package/core/components/atoms/message/__tests__/Message.test.tsx +1 -6
- package/core/components/atoms/message/__tests__/__snapshots__/Message.test.tsx.snap +0 -45
- package/core/components/atoms/metaList/__tests__/MetaList.test.tsx +2 -2
- package/core/components/atoms/metricInput/MetricInput.tsx +17 -7
- package/core/components/atoms/metricInput/__stories__/DefaultMetric.story.tsx +8 -2
- package/core/components/atoms/metricInput/__stories__/WithPrefix.story.tsx +6 -2
- package/core/components/atoms/metricInput/__stories__/index.story.tsx +1 -0
- package/core/components/atoms/metricInput/__stories__/variants/Controlled.story.tsx +2 -0
- package/core/components/atoms/metricInput/__stories__/variants/Size.story.tsx +2 -2
- package/core/components/atoms/metricInput/__stories__/withSuffix.story.tsx +6 -2
- package/core/components/atoms/metricInput/__tests__/__snapshots__/MetricInput.test.tsx.snap +20 -4
- package/core/components/atoms/multiSlider/Handle.tsx +3 -0
- package/core/components/atoms/multiSlider/SliderUtils.tsx +1 -4
- package/core/components/atoms/multiSlider/index.tsx +9 -4
- package/core/components/atoms/outsideClick/OutsideClick.tsx +1 -2
- package/core/components/atoms/paragraph/Paragraph.tsx +2 -2
- package/core/components/atoms/paragraph/__stories__/variants/Appearance.story.tsx +2 -2
- package/core/components/atoms/paragraph/__tests__/Paragraph.test.tsx +2 -2
- package/core/components/atoms/pills/Pills.tsx +2 -12
- package/core/components/atoms/pills/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/pills/__stories__/variants/Subtle.story.tsx +3 -2
- package/core/components/atoms/pills/__tests__/Pills.test.tsx +3 -2
- package/core/components/atoms/placeholderImage/PlaceholderImage.tsx +2 -2
- package/core/components/atoms/placeholderImage/__stories__/variants/Size.story.tsx +2 -2
- package/core/components/atoms/placeholderParagraph/PlaceholderParagraph.tsx +2 -2
- package/core/components/atoms/placeholderParagraph/__stories__/variants/Size.story.tsx +2 -2
- package/core/components/atoms/popperWrapper/PopperWrapper.tsx +2 -6
- package/core/components/atoms/progressRing/ProgressRing.tsx +2 -2
- package/core/components/atoms/progressRing/__stories__/variants/Size.story.tsx +1 -1
- package/core/components/atoms/radio/Radio.tsx +4 -5
- package/core/components/atoms/rangeSlider/RangeSlider.tsx +1 -2
- package/core/components/atoms/rangeSlider/__stories__/index.story.tsx +1 -2
- package/core/components/atoms/rangeSlider/__stories__/variants/Controlled.story.tsx +1 -2
- package/core/components/atoms/rangeSlider/__stories__/variants/CustomLabels.story.tsx +1 -2
- package/core/components/atoms/spinner/Spinner.tsx +4 -4
- package/core/components/atoms/spinner/__stories__/variants/Appearance.story.tsx +2 -2
- package/core/components/atoms/spinner/__stories__/variants/Size.story.tsx +1 -1
- package/core/components/atoms/statusHint/StatusHint.tsx +5 -3
- package/core/components/atoms/statusHint/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/statusHint/__tests__/StatusHint.test.tsx +3 -2
- package/core/components/atoms/subheading/Subheading.tsx +2 -2
- package/core/components/atoms/subheading/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/subheading/__tests__/Subheading.test.tsx +3 -2
- package/core/components/atoms/switchInput/Switch.tsx +14 -9
- package/core/components/atoms/switchInput/__stories__/DefaultSwitch.story.tsx +4 -1
- package/core/components/atoms/switchInput/__stories__/OffState.story.tsx +4 -1
- package/core/components/atoms/switchInput/__stories__/index.story.tsx +26 -3
- package/core/components/atoms/switchInput/__stories__/variants/Size.story.tsx +10 -1
- package/core/components/atoms/switchInput/__stories__/variants/State.story.tsx +9 -2
- package/core/components/atoms/text/Text.tsx +4 -4
- package/core/components/atoms/text/__stories__/variants/Appearance.story.tsx +2 -2
- package/core/components/atoms/text/__tests__/Text.test.tsx +2 -3
- package/core/components/atoms/textarea/__stories__/TextareaWithCaption.story.tsx +9 -3
- package/core/components/atoms/textarea/__stories__/defaultTextarea.story.tsx +10 -2
- package/core/components/atoms/textarea/__stories__/index.story.tsx +1 -0
- package/core/components/atoms/textarea/__stories__/variants/Disable.story.tsx +1 -0
- package/core/components/atoms/toast/ActionButton.tsx +2 -2
- package/core/components/atoms/toast/Toast.tsx +11 -6
- package/core/components/atoms/toast/__stories__/index.story.tsx +2 -6
- package/core/components/atoms/toast/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/toast/__stories__/variants/ToastMessage.story.tsx +3 -2
- package/core/components/atoms/toast/__stories__/variants/ToastWithAction.story.tsx +3 -2
- package/core/components/atoms/toast/__tests__/Toast.test.tsx +1 -1
- package/core/components/atoms/toast/__tests__/__snapshots__/Toast.test.tsx.snap +24 -125
- package/core/components/css-utilities/Schema.tsx +1 -1
- package/core/components/css-utilities/Spacing/Schema.tsx +1 -1
- package/core/components/molecules/chatMessage/Box.tsx +3 -0
- package/core/components/molecules/chipInput/ChipInput.tsx +3 -0
- package/core/components/molecules/chipInput/__tests__/__snapshots__/ChipInput.test.tsx.snap +14 -2
- package/core/components/molecules/dropzone/Dropzone.tsx +6 -3
- package/core/components/molecules/dropzone/DropzoneBase.tsx +22 -38
- package/core/components/molecules/dropzone/FileSelectorUtils.tsx +1 -1
- package/core/components/molecules/dropzone/__stories__/index.story.tsx +151 -41
- package/core/components/molecules/dropzone/__tests__/Dropzone.test.tsx +2 -2
- package/core/components/molecules/dropzone/utils.tsx +6 -4
- package/core/components/molecules/editableChipInput/EditableChipInput.tsx +9 -5
- package/core/components/molecules/editableChipInput/__stories__/Uncontrolled.story.tsx +1 -1
- package/core/components/molecules/editableChipInput/__tests__/__snapshots__/EditableChipInput.test.tsx.snap +12 -4
- package/core/components/molecules/editableDropdown/EditableDropdown.tsx +2 -2
- package/core/components/molecules/editableInput/EditableInput.tsx +13 -4
- package/core/components/molecules/emptyState/EmptyState.tsx +9 -5
- package/core/components/molecules/emptyState/__stories__/pageNotLoadedWithSVG.story.tsx +26 -26
- package/core/components/molecules/fileList/FileListItem.tsx +3 -2
- package/core/components/molecules/fileUploader/FileUploaderItem.tsx +3 -2
- package/core/components/molecules/fileUploader/FileUploaderStatus.tsx +1 -1
- package/core/components/molecules/fileUploader/__stories__/_common_/types.tsx +3 -0
- package/core/components/molecules/fileUploader/__stories__/index.story.tsx +3 -222
- package/core/components/molecules/fullscreenModal/FullscreenModal.tsx +5 -7
- package/core/components/molecules/inputMask/InputMask.tsx +212 -146
- package/core/components/molecules/inputMask/__stories__/index.story.tsx +24 -0
- package/core/components/molecules/inputMask/__tests__/__snapshots__/InputMask.test.tsx.snap +1 -0
- package/core/components/molecules/modal/Modal.tsx +4 -6
- package/core/components/molecules/modal/__stories__/Confirmation.story.tsx +1 -1
- package/core/components/molecules/pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +5 -1
- package/core/components/molecules/placeholder/Placeholder.tsx +2 -2
- package/core/components/molecules/popover/Popover.tsx +2 -9
- package/core/components/molecules/sidesheet/Sidesheet.tsx +5 -7
- package/core/components/molecules/sidesheet/__stories__/variants/CustomHeader.story.tsx +172 -0
- package/core/components/molecules/stepper/Step.tsx +2 -0
- package/core/components/molecules/tabs/Tabs.tsx +2 -0
- package/core/components/molecules/tabs/TabsWrapper.tsx +2 -0
- package/core/components/molecules/tabs/__stories__/CustomLabels.story.tsx +1 -1
- package/core/components/molecules/tooltip/Tooltip.tsx +4 -4
- package/core/components/molecules/verificationCodeInput/VerificationCodeInput.tsx +8 -4
- package/core/components/molecules/verificationCodeInput/__stories__/index.story.tsx +3 -1
- package/core/components/molecules/verificationCodeInput/__tests__/__snapshots__/VerificationCodeInput.test.tsx.snap +1 -0
- package/core/components/organisms/calendar/Calendar.tsx +130 -8
- package/core/components/organisms/calendar/__stories__/variants/firstDayOfWeek.story.tsx +2 -2
- package/core/components/organisms/calendar/__tests__/Calendar.test.tsx +27 -0
- package/core/components/organisms/calendar/utility.ts +3 -3
- package/core/components/organisms/choiceList/ChoiceList.tsx +12 -12
- package/core/components/organisms/datePicker/DatePicker.tsx +31 -16
- package/core/components/organisms/datePicker/Trigger.tsx +1 -5
- package/core/components/organisms/datePicker/__tests__/__snapshots__/DatePicker.test.tsx.snap +4518 -4479
- package/core/components/organisms/dateRangePicker/DateRangePicker.tsx +9 -10
- package/core/components/organisms/dateRangePicker/SingleInputTrigger.tsx +0 -1
- package/core/components/organisms/dateRangePicker/Trigger.tsx +2 -2
- package/core/components/organisms/dateRangePicker/__stories__/variants/monthsInView.story.tsx +2 -2
- package/core/components/organisms/dateRangePicker/__tests__/__snapshots__/DateRangePicker.test.tsx.snap +112 -40
- package/core/components/organisms/grid/Cell.tsx +23 -19
- package/core/components/organisms/grid/Grid.tsx +3 -4
- package/core/components/organisms/grid/GridBody.tsx +0 -1
- package/core/components/organisms/grid/GridContext.ts +1 -1
- package/core/components/organisms/grid/GridRow.tsx +4 -0
- package/core/components/organisms/grid/__stories__/_common_/editableSchema.tsx +1 -3
- package/core/components/organisms/grid/__stories__/_common_/fetchData.ts +3 -3
- package/core/components/organisms/grid/__stories__/_common_/loaderSchema.ts +0 -2
- package/core/components/organisms/grid/__stories__/_common_/schema.tsx +1 -3
- package/core/components/organisms/grid/__stories__/_common_/simpleLoaderSchema.ts +0 -2
- package/core/components/organisms/grid/__stories__/_common_/statusSchema.ts +0 -2
- package/core/components/organisms/horizontalNav/HorizontalNav.tsx +2 -0
- package/core/components/organisms/inlineMessage/InlineMessage.tsx +5 -7
- package/core/components/organisms/inlineMessage/__tests__/InlineMessage.test.tsx +3 -2
- package/core/components/organisms/inlineMessage/__tests__/__snapshots__/InlineMessage.test.tsx.snap +30 -40
- package/core/components/organisms/list/__stories__/_common_/types.tsx +3 -0
- package/core/components/organisms/list/__stories__/index.story.tsx +0 -16
- package/core/components/organisms/navigation/VerticalNavigation.tsx +4 -0
- package/core/components/organisms/table/Table.tsx +3 -2
- package/core/components/organisms/table/__stories__/CompressedTable.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/DataTable.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/NestedTableWithNestedCard.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/PinnedColumn.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/ResourceTable.story.tsx +4 -3
- package/core/components/organisms/table/__stories__/Selection.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/StandardTable.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/TableAsDescriptionList.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/TableAsOptionList.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/TightStory.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/_common_/types.tsx +3 -0
- package/core/components/organisms/table/__stories__/syncTable.story.tsx +14 -6
- package/core/components/organisms/table/__stories__/variants/showHead.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/variants/showMenu.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/variants/size.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/variants/type.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/variants/withCheckbox.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/variants/withHeader.story.tsx +0 -2
- package/core/components/organisms/table/__stories__/variants/withPagination.story.tsx +2 -2
- package/core/components/organisms/timePicker/TimePicker.tsx +4 -8
- package/core/components/organisms/timePicker/__tests__/__snapshots__/TimePicker.test.tsx.snap +14 -2
- package/core/components/organisms/verticalNav/MenuItem.tsx +2 -0
- package/core/components/organisms/verticalNav/__stories__/schema.tsx +0 -2
- package/core/components/organisms/verticalNav/__tests__/VerticalNav.test.tsx +1 -2
- package/core/components/patterns/datePicker/datePickerWithPresets.story.tsx +126 -0
- package/core/components/patterns/dateRangePicker/withCustomPopover.story.tsx +8 -8
- package/core/components/patterns/forms/CreatePassword.story.tsx +1 -1
- package/core/components/patterns/forms/VerificationCodeInput.story.tsx +2 -2
- package/core/components/patterns/table/Table with Header/tableWithHeader.story.jsx +7 -7
- package/core/global.d.ts +9 -0
- package/core/index.tsx +2 -1
- package/core/index.type.tsx +1 -0
- package/core/utils/Keys.ts +4 -0
- package/core/utils/__tests__/__snapshots__/TS.test.tsx.snap +562 -541
- package/core/utils/docPage/generateImports.tsx +2 -3
- package/core/utils/docPage/index.tsx +52 -37
- package/core/utils/docPage/sandbox.tsx +14 -7
- package/core/utils/overlayHelper.ts +7 -3
- package/core/utils/testHelper.ts +2 -2
- package/core/utils/types.tsx +1 -1
- package/core/utils/validators.ts +37 -34
- package/css/dist/index.css +1550 -1415
- package/css/dist/index.css.map +1 -1
- package/css/src/components/Legend.css +7 -7
- package/css/src/components/ProgressBar.css +1 -1
- package/css/src/components/avatarGroup.css +1 -1
- package/css/src/components/backdrop.css +12 -6
- package/css/src/components/badge.css +52 -52
- package/css/src/components/button.css +95 -94
- package/css/src/components/calendar.css +137 -126
- package/css/src/components/card.css +0 -1
- package/css/src/components/cardSubdued.css +3 -5
- package/css/src/components/chat.css +1 -1
- package/css/src/components/checkbox.css +71 -70
- package/css/src/components/chip.css +20 -17
- package/css/src/components/chipGroup.css +5 -5
- package/css/src/components/chipInput.css +1 -1
- package/css/src/components/choiceList.css +4 -4
- package/css/src/components/dateRangePicker.css +13 -13
- package/css/src/components/divider.css +20 -0
- package/css/src/components/dropdown.css +61 -61
- package/css/src/components/dropdownButton.css +36 -36
- package/css/src/components/dropzone.css +16 -20
- package/css/src/components/editableChipInput.css +10 -9
- package/css/src/components/editableDropdown.css +1 -1
- package/css/src/components/editableInput.css +1 -1
- package/css/src/components/emptyState.css +15 -15
- package/css/src/components/fileList.css +44 -45
- package/css/src/components/fullscreenModal.css +4 -3
- package/css/src/components/grid.css +217 -199
- package/css/src/components/horizontalNav.css +0 -1
- package/css/src/components/icon.css +1 -7
- package/css/src/components/inlineMessage.css +2 -1
- package/css/src/components/input.css +62 -62
- package/css/src/components/link.css +1 -1
- package/css/src/components/list.css +10 -10
- package/css/src/components/message.css +64 -70
- package/css/src/components/metaList.css +26 -26
- package/css/src/components/metricInput.css +3 -4
- package/css/src/components/modal.css +1 -1
- package/css/src/components/navigation.css +3 -3
- package/css/src/components/pageHeader.css +1 -2
- package/css/src/components/pagination.css +36 -36
- package/css/src/components/pills.css +19 -19
- package/css/src/components/placeholder.css +10 -5
- package/css/src/components/popover.css +2 -2
- package/css/src/components/progressRing.css +1 -1
- package/css/src/components/radio.css +74 -74
- package/css/src/components/slider.css +5 -5
- package/css/src/components/statusHints.css +15 -15
- package/css/src/components/switch.css +66 -41
- package/css/src/components/table.css +15 -15
- package/css/src/components/tabs.css +53 -53
- package/css/src/components/textarea.css +1 -1
- package/css/src/components/toast.css +51 -56
- package/css/src/components/verificationCodeInput.css +5 -6
- package/css/src/components/verticalNav.css +1 -2
- package/css/src/core/base.css +3 -0
- package/css/src/core/typography.css +1 -1
- package/css/src/core/utilities.css +1 -1
- package/css/src/tokens/index.css +63 -63
- package/css/src/utils/align.css +1 -1
- package/css/src/utils/background.css +1 -1
- package/css/src/utils/cursor.css +1 -1
- package/css/src/utils/display.css +1 -1
- package/css/src/utils/flex.css +1 -1
- package/css/src/utils/grid.css +1 -1
- package/css/src/utils/overflow.css +1 -1
- package/css/src/utils/position.css +1 -1
- package/css/src/utils/spacing.css +1 -1
- package/css/src/utils/utility.css +13 -13
- package/css/src/variables/index.css +6 -3
- package/dist/core/accessibility/utils/index.d.ts +4 -0
- package/dist/core/accessibility/utils/isEnterKey.d.ts +3 -0
- package/dist/core/accessibility/utils/isSpaceKey.d.ts +3 -0
- package/dist/core/accessibility/utils/useAccessibilityProps.d.ts +18 -0
- package/dist/core/common.type.d.ts +12 -0
- package/dist/core/components/atoms/avatar/Avatar.d.ts +4 -4
- package/dist/core/components/atoms/avatarGroup/AvatarGroup.d.ts +2 -3
- package/dist/core/components/atoms/badge/Badge.d.ts +2 -2
- package/dist/core/components/atoms/button/Button.d.ts +6 -6
- package/dist/core/components/atoms/checkbox/Checkbox.d.ts +3 -3
- package/dist/core/components/atoms/chip/Chip.d.ts +2 -2
- package/dist/core/components/atoms/divider/Divider.d.ts +15 -0
- package/dist/core/components/atoms/divider/index.d.ts +2 -0
- package/dist/core/components/atoms/dropdown/Dropdown.d.ts +18 -17
- package/dist/core/components/atoms/dropdown/DropdownButton.d.ts +2 -2
- package/dist/core/components/atoms/dropdown/DropdownList.d.ts +4 -3
- package/dist/core/components/atoms/dropdown/option/index.d.ts +1 -1
- package/dist/core/components/atoms/heading/Heading.d.ts +4 -4
- package/dist/core/components/atoms/icon/Icon.d.ts +5 -3
- package/dist/core/components/atoms/input/Input.d.ts +4 -4
- package/dist/core/components/atoms/legend/Legend.d.ts +2 -2
- package/dist/core/components/atoms/link/Link.d.ts +4 -4
- package/dist/core/components/atoms/message/Message.d.ts +2 -2
- package/dist/core/components/atoms/metricInput/MetricInput.d.ts +3 -3
- package/dist/core/components/atoms/multiSlider/SliderUtils.d.ts +1 -1
- package/dist/core/components/atoms/multiSlider/index.d.ts +3 -3
- package/dist/core/components/atoms/paragraph/Paragraph.d.ts +2 -2
- package/dist/core/components/atoms/pills/Pills.d.ts +2 -2
- package/dist/core/components/atoms/placeholderImage/PlaceholderImage.d.ts +2 -2
- package/dist/core/components/atoms/placeholderParagraph/PlaceholderParagraph.d.ts +2 -2
- package/dist/core/components/atoms/popperWrapper/PopperWrapper.d.ts +51 -51
- package/dist/core/components/atoms/progressRing/ProgressRing.d.ts +2 -2
- package/dist/core/components/atoms/radio/Radio.d.ts +4 -4
- package/dist/core/components/atoms/rangeSlider/RangeSlider.d.ts +1 -1
- package/dist/core/components/atoms/spinner/Spinner.d.ts +4 -4
- package/dist/core/components/atoms/statusHint/StatusHint.d.ts +2 -2
- package/dist/core/components/atoms/subheading/Subheading.d.ts +2 -2
- package/dist/core/components/atoms/switchInput/Switch.d.ts +7 -6
- package/dist/core/components/atoms/text/Text.d.ts +4 -4
- package/dist/core/components/atoms/toast/ActionButton.d.ts +2 -2
- package/dist/core/components/atoms/toast/Toast.d.ts +2 -2
- package/dist/core/components/molecules/dropzone/Dropzone.d.ts +3 -3
- package/dist/core/components/molecules/dropzone/DropzoneBase.d.ts +1 -1
- package/dist/core/components/molecules/dropzone/utils.d.ts +5 -3
- package/dist/core/components/molecules/emptyState/EmptyState.d.ts +4 -4
- package/dist/core/components/molecules/fileList/FileListItem.d.ts +1 -1
- package/dist/core/components/molecules/fileUploader/FileUploaderItem.d.ts +1 -1
- package/dist/core/components/molecules/fileUploader/FileUploaderStatus.d.ts +1 -1
- package/dist/core/components/molecules/fullscreenModal/FullscreenModal.d.ts +4 -7
- package/dist/core/components/molecules/inputMask/InputMask.d.ts +10 -2
- package/dist/core/components/molecules/modal/Modal.d.ts +3 -6
- package/dist/core/components/molecules/placeholder/Placeholder.d.ts +2 -2
- package/dist/core/components/molecules/popover/Popover.d.ts +0 -1
- package/dist/core/components/molecules/sidesheet/Sidesheet.d.ts +3 -6
- package/dist/core/components/molecules/tooltip/Tooltip.d.ts +3 -3
- package/dist/core/components/organisms/calendar/Calendar.d.ts +31 -0
- package/dist/core/components/organisms/choiceList/ChoiceList.d.ts +5 -6
- package/dist/core/components/organisms/datePicker/DatePicker.d.ts +2 -0
- package/dist/core/components/organisms/dateRangePicker/DateRangePicker.d.ts +24 -0
- package/dist/core/components/organisms/grid/Cell.d.ts +1 -1
- package/dist/core/components/organisms/grid/Grid.d.ts +3 -3
- package/dist/core/components/organisms/grid/GridContext.d.ts +1 -1
- package/dist/core/components/organisms/inlineMessage/InlineMessage.d.ts +2 -2
- package/dist/core/components/organisms/table/Table.d.ts +2 -2
- package/dist/core/components/patterns/datePicker/datePickerWithPresets.story.d.ts +15 -0
- package/dist/core/components/patterns/dateRangePicker/withCustomPopover.story.d.ts +5 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.type.d.ts +1 -0
- package/dist/core/utils/docPage/generateImports.d.ts +1 -1
- package/dist/core/utils/overlayHelper.d.ts +1 -1
- package/dist/core/utils/types.d.ts +1 -1
- package/dist/index.esm.js +1039 -729
- package/dist/index.js +532 -371
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.br +0 -0
- package/dist/index.umd.js.gz +0 -0
- package/dts.config.js +11 -2
- package/package.json +32 -27
- package/tsconfig.json +3 -16
- package/tsconfig.type.json +2 -1
- package/types/index.d.ts +2217 -0
- package/types/{innovaccer-design-system/tsconfig.json → tsconfig.json} +1 -1
- package/types/{innovaccer-design-system/tslint.json → tslint.json} +0 -0
- package/types/types-tests.tsx +936 -0
- package/.husky/prepare-commit-msg +0 -6
- package/core/components/atoms/button/__stories__/variants/state/Success.story.tsx +0 -99
- package/core/components/atoms/message/__stories__/default.story.tsx +0 -16
- package/core/components/atoms/toast/__stories__/DefaultToast.story.tsx +0 -16
- package/core/components/molecules/dropzone/__stories__/variants/DropzoneWithFileList.story.tsx +0 -176
- package/core/components/molecules/fileUploader/__stories__/variants/FileUploaderList.story.tsx +0 -80
- package/tslint.json +0 -30
- package/types/innovaccer-design-system/index.d.ts +0 -39
- package/types/innovaccer-design-system/innovaccer-design-system-tests.ts +0 -0
package/CONTRIBUTING.md
CHANGED
|
@@ -8,14 +8,13 @@ present you with this guide.
|
|
|
8
8
|
There are different ways to contribute, each with a different level
|
|
9
9
|
of involvement and technical knowledge required, such as:
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
- [Reporting Bugs](#reporting-bugs)
|
|
12
|
+
- [Request Features](#request-features)
|
|
13
|
+
- [Development](#development)
|
|
14
14
|
|
|
15
15
|
**Please read this document carefully. It will help maintainers and readers
|
|
16
16
|
in solving your issue(s), evaluating your feature request, etc.**
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
## Reporting Bugs
|
|
20
19
|
|
|
21
20
|
We welcome clear, detailed bug reports.
|
|
@@ -25,10 +24,9 @@ documentation.**
|
|
|
25
24
|
|
|
26
25
|
If you've found a bug, please file a report in our [issue tracker](https://github.com/innovaccer/design-system/issues).
|
|
27
26
|
|
|
28
|
-
|
|
29
27
|
### Issue Search
|
|
30
28
|
|
|
31
|
-
Search to see if it has already been reported via the
|
|
29
|
+
Search to see if it has already been reported via the _issue search_.
|
|
32
30
|
If so, up-vote it (using GitHub reactions) or add additional helpful details to
|
|
33
31
|
the existing issue to show that it's affecting multiple people.
|
|
34
32
|
|
|
@@ -43,20 +41,22 @@ New feature requests are welcomed. Analyze whether the idea fits within the scop
|
|
|
43
41
|
|
|
44
42
|
Please provide:
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
- A detailed description of the advantages of your request
|
|
45
|
+
- A potential implementation or design
|
|
46
|
+
- Whatever else you have in your mind 🤓
|
|
49
47
|
|
|
50
48
|
## Development
|
|
51
49
|
|
|
52
50
|
### Setting up the environment
|
|
51
|
+
|
|
53
52
|
1. Fork the repository on Github.
|
|
54
53
|
|
|
55
54
|
2. Run the environment locally:
|
|
56
|
-
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
57
|
#clone repository
|
|
58
58
|
git clone https://github.com/[GITHUB_USERNAME]/design-system.git
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
#change directory to the cloned repository
|
|
61
61
|
cd design-system
|
|
62
62
|
|
|
@@ -93,11 +93,22 @@ mkdir __stories__
|
|
|
93
93
|
mkdir __stories__/variants
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
+
### Naming
|
|
97
|
+
|
|
98
|
+
- **Extensions**: Use `.tsx` extension for components.
|
|
99
|
+
- **Filename**: Use PascalCase for filenames. E.g., `DropdownOptions.tsx`.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import DropdownOptions from './DropdownOptions';
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- **Component Naming**: Use the filename as the component name. For example, `DropdownOptions.tsx` should have a reference name of `DropdownOptions`. However, for root components of a directory, use `index.tsx` as the filename and use the directory name as the component name:
|
|
106
|
+
|
|
96
107
|
#### Typescript Types
|
|
97
108
|
|
|
98
|
-
- Component
|
|
109
|
+
- Component _types_ names must be uppercase, e.g. Appearance, Size, etc.
|
|
99
110
|
- Component Props interface should be named as `[COMPONENT_NAME]Props`, e.g. AvatarProps, HeadingProps.
|
|
100
|
-
- Every component props interface should extend **BaseProps** (e.g className, data-test). Properties inside BaseProps
|
|
111
|
+
- Every component props interface should extend **BaseProps** (e.g className, data-test). Properties inside BaseProps interface are defined in `@/utils/types`.
|
|
101
112
|
|
|
102
113
|
#### Exports
|
|
103
114
|
|
|
@@ -121,6 +132,7 @@ mkdir __stories__/variants
|
|
|
121
132
|
- `component`: Used by addons for automatic prop table generation and display of other component metadata
|
|
122
133
|
- `parameters`: Used to control the behavior of Storybook features and addons.
|
|
123
134
|
- `subcomponents`: Used to include subcomponents in prop table.
|
|
135
|
+
|
|
124
136
|
```tsx
|
|
125
137
|
// Storybook CSF Format
|
|
126
138
|
export default {
|
|
@@ -131,24 +143,25 @@ export default {
|
|
|
131
143
|
docs: {
|
|
132
144
|
docPage: {
|
|
133
145
|
noHtml: true, // Includes Html in docPage
|
|
134
|
-
noStory:true, // Includes Story in docPage
|
|
146
|
+
noStory: true, // Includes Story in docPage
|
|
135
147
|
noProps: true, // Includes props table in docPage,
|
|
136
148
|
noSandbox: true, // Includes code sandbox button in docPage,
|
|
137
149
|
title: 'Avatar', // Custom title
|
|
138
150
|
description: 'Dummy description', // Custom description
|
|
139
|
-
customCode: '() => <Avatar>JD</Avatar>' // Custom code for live code editor,
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
151
|
+
customCode: '() => <Avatar>JD</Avatar>', // Custom code for live code editor,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
143
155
|
};
|
|
144
156
|
```
|
|
157
|
+
|
|
145
158
|
### Example Component
|
|
146
159
|
|
|
147
|
-
|
|
160
|
+
Let's assume we want to add _Avatar_ component in _Atoms_ category.
|
|
148
161
|
|
|
149
162
|
##### Create folder structure
|
|
150
163
|
|
|
151
|
-
|
|
164
|
+
```bash
|
|
152
165
|
cd core/atoms
|
|
153
166
|
mkdir avatar
|
|
154
167
|
cd avatar
|
|
@@ -156,10 +169,10 @@ mkdir __tests__
|
|
|
156
169
|
mkdir __stories__
|
|
157
170
|
mkdir __stories__/variants
|
|
158
171
|
```
|
|
159
|
-
|
|
172
|
+
|
|
160
173
|
##### [./core/components/atoms/avatar/Avatar.tsx](https://github.com/innovaccer/design-system/blob/master/core/components/atoms/avatar/Avatar.tsx)
|
|
161
174
|
|
|
162
|
-
Now we will add
|
|
175
|
+
Now we will add _Avatar_ component logic.
|
|
163
176
|
|
|
164
177
|
###### Imports
|
|
165
178
|
|
|
@@ -178,13 +191,25 @@ import { BaseProps, extractBaseProps } from '@/utils/types';
|
|
|
178
191
|
###### Component types
|
|
179
192
|
|
|
180
193
|
```tsx
|
|
181
|
-
export type Appearance =
|
|
194
|
+
export type Appearance =
|
|
195
|
+
| 'secondary'
|
|
196
|
+
| 'primary'
|
|
197
|
+
| 'alert'
|
|
198
|
+
| 'warning'
|
|
199
|
+
| 'success'
|
|
200
|
+
| 'accent1'
|
|
201
|
+
| 'accent2'
|
|
202
|
+
| 'accent3'
|
|
203
|
+
| 'accent4';
|
|
182
204
|
|
|
183
205
|
export type Size = 'regular' | 'tiny';
|
|
184
206
|
```
|
|
207
|
+
|
|
185
208
|
###### Component interface
|
|
209
|
+
|
|
186
210
|
- Component props interface should extend BaseProps.
|
|
187
211
|
- Additional information of a prop is written in `/** */` block.
|
|
212
|
+
|
|
188
213
|
```tsx
|
|
189
214
|
export interface AvatarProps extends BaseProps {
|
|
190
215
|
/**
|
|
@@ -217,8 +242,10 @@ export interface AvatarProps extends BaseProps {
|
|
|
217
242
|
size: Size;
|
|
218
243
|
}
|
|
219
244
|
```
|
|
245
|
+
|
|
220
246
|
###### Component Logic
|
|
221
|
-
|
|
247
|
+
|
|
248
|
+
- Props are destructured _(Note that Avatar is a Function Component)_.
|
|
222
249
|
|
|
223
250
|
```jsx
|
|
224
251
|
export const Avatar = (props: AvatarProps) => {
|
|
@@ -233,44 +260,52 @@ export const Avatar = (props: AvatarProps) => {
|
|
|
233
260
|
appearance,
|
|
234
261
|
} = props;
|
|
235
262
|
```
|
|
263
|
+
|
|
236
264
|
- BaseProps are extracted via `extractBaseProps` function;
|
|
265
|
+
|
|
237
266
|
```jsx
|
|
238
|
-
|
|
267
|
+
const baseProps = extractBaseProps(props);
|
|
268
|
+
|
|
269
|
+
const initials = children
|
|
270
|
+
? children.trim().slice(0, initialsLength)
|
|
271
|
+
: `${firstName ? firstName.trim()[0] : ''}${lastName ? lastName.trim()[0] : ''}`;
|
|
239
272
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
: `${firstName ? firstName.trim()[0] : ''}${lastName ? lastName.trim()[0] : ''}`;
|
|
273
|
+
const tooltip = children || `${firstName || ''} ${lastName || ''}` || '';
|
|
274
|
+
const DefaultAppearance = 'secondary';
|
|
243
275
|
|
|
244
|
-
|
|
245
|
-
const DefaultAppearance = 'secondary';
|
|
276
|
+
const colors = ['accent4', 'primary', 'accent3', 'alert', 'accent2', 'warning', 'accent1', 'success'];
|
|
246
277
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const AvatarAppearance = appearance
|
|
250
|
-
|| colors[(initials.charCodeAt(0) + (initials.charCodeAt(1) || 0)) % 8]
|
|
251
|
-
|| DefaultAppearance;
|
|
278
|
+
const AvatarAppearance =
|
|
279
|
+
appearance || colors[(initials.charCodeAt(0) + (initials.charCodeAt(1) || 0)) % 8] || DefaultAppearance;
|
|
252
280
|
```
|
|
281
|
+
|
|
253
282
|
- [ClassNames](https://www.npmjs.com/package/classnames) is a utility for conditionally joining CSS classNames together.
|
|
254
283
|
- CSS is added according to [BEM Convention](http://getbem.com/naming/).
|
|
284
|
+
|
|
255
285
|
```jsx
|
|
256
|
-
|
|
286
|
+
const classes = classNames(
|
|
287
|
+
{
|
|
257
288
|
Avatar: true,
|
|
258
289
|
[`Avatar--${size}`]: size,
|
|
259
290
|
[`Avatar--${AvatarAppearance}`]: AvatarAppearance,
|
|
260
291
|
['Avatar--disabled']: !initials || !withTooltip,
|
|
261
|
-
},
|
|
292
|
+
},
|
|
293
|
+
className
|
|
294
|
+
);
|
|
262
295
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
296
|
+
const ContentClass = classNames({
|
|
297
|
+
[`Avatar-content--${size}`]: size,
|
|
298
|
+
[`Avatar-content--${AvatarAppearance}`]: AvatarAppearance,
|
|
299
|
+
});
|
|
267
300
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
301
|
+
const IconClass = classNames({
|
|
302
|
+
[`Avatar-content--${AvatarAppearance}`]: AvatarAppearance,
|
|
303
|
+
});
|
|
271
304
|
```
|
|
305
|
+
|
|
272
306
|
- Add rendering logic and `data-test` attribute.
|
|
273
307
|
- Convention for adding data-test id is `DesignSystem-[COMPONENT_NAME]` and it is used for testing.
|
|
308
|
+
|
|
274
309
|
```jsx
|
|
275
310
|
const renderAvatar = () => {
|
|
276
311
|
return (
|
|
@@ -312,7 +347,9 @@ export const Avatar = (props: AvatarProps) => {
|
|
|
312
347
|
return renderTooltip();
|
|
313
348
|
};
|
|
314
349
|
```
|
|
350
|
+
|
|
315
351
|
- Export Avatar component
|
|
352
|
+
|
|
316
353
|
```jsx
|
|
317
354
|
Avatar.displayName = 'Avatar';
|
|
318
355
|
|
|
@@ -325,19 +362,26 @@ export default Avatar;
|
|
|
325
362
|
export { default } from './Avatar';
|
|
326
363
|
export * from './Avatar';
|
|
327
364
|
```
|
|
365
|
+
|
|
328
366
|
#### Component Stories
|
|
367
|
+
|
|
329
368
|
A [story](https://storybook.js.org/docs/react/get-started/whats-a-story) captures the rendered state of a UI component. We write multiple stories per component that describe all the interesting states a component can support.
|
|
330
369
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
-
|
|
370
|
+
##### Default Story
|
|
371
|
+
|
|
372
|
+
###### [/core/components/atoms/avatar/\_\_stories\_\_/index.story.tsx](https://github.com/innovaccer/design-system/blob/master/core/components/atoms/avatar/__stories__/index.story.tsx).
|
|
373
|
+
|
|
374
|
+
- Import component and story knobs.
|
|
375
|
+
|
|
334
376
|
```tsx
|
|
335
377
|
import * as React from 'react';
|
|
336
378
|
import { select, text } from '@storybook/addon-knobs';
|
|
337
379
|
import { Avatar } from '@/index';
|
|
338
380
|
```
|
|
381
|
+
|
|
339
382
|
- Every named export in the file represents the name of the story, in this case `All`.
|
|
340
383
|
- Storybook knobs (e.g. select, text, boolean) allows to edit props dynamically using the Storybook UI.
|
|
384
|
+
|
|
341
385
|
```tsx
|
|
342
386
|
export const all = () => {
|
|
343
387
|
const appearance = select(
|
|
@@ -345,42 +389,46 @@ export const all = () => {
|
|
|
345
389
|
['primary', 'alert', 'warning', 'success', 'accent1', 'accent2', 'accent3', 'accent4', 'secondary'],
|
|
346
390
|
undefined
|
|
347
391
|
);
|
|
348
|
-
|
|
392
|
+
|
|
349
393
|
const size = select('size', ['regular', 'tiny'], undefined);
|
|
350
394
|
const withTooltip = boolean('withTooltip', true);
|
|
351
395
|
|
|
352
396
|
const children = text('children', 'JD');
|
|
353
397
|
|
|
354
398
|
return (
|
|
355
|
-
<Avatar
|
|
356
|
-
appearance={appearance}
|
|
357
|
-
size={size}
|
|
358
|
-
withTooltip={withTooltip}
|
|
359
|
-
>
|
|
399
|
+
<Avatar appearance={appearance} size={size} withTooltip={withTooltip}>
|
|
360
400
|
{children}
|
|
361
401
|
</Avatar>
|
|
362
402
|
);
|
|
363
403
|
};
|
|
364
404
|
```
|
|
405
|
+
|
|
365
406
|
- The default export defines metadata about component.
|
|
366
407
|
- Title `Avatar/All` will show up in the navigation UI story hierarchy.
|
|
408
|
+
|
|
367
409
|
```jsx
|
|
368
410
|
export default {
|
|
369
411
|
title: 'Components/Avatar/All'',
|
|
370
412
|
component: Avatar
|
|
371
413
|
};
|
|
372
414
|
```
|
|
415
|
+
|
|
373
416
|
##### Variant Story
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
-
|
|
417
|
+
|
|
418
|
+
We write stories corresponding to each prop in the variants folder. For example: `size` and `appearance` are props of Avatar component. Let us look at an example of `size` variant story.
|
|
419
|
+
|
|
420
|
+
###### [./core/components/atoms/avatar/\_\_stories\_\_/variants/size.story.tsx](https://github.com/innovaccer/design-system/blob/master/core/components/atoms/avatar/__stories__/variants/Size.story.tsx)
|
|
421
|
+
|
|
422
|
+
- Import the required components.
|
|
423
|
+
|
|
378
424
|
```tsx
|
|
379
425
|
import * as React from 'react';
|
|
380
|
-
import { Avatar, Text} from '@/index';
|
|
426
|
+
import { Avatar, Text } from '@/index';
|
|
381
427
|
```
|
|
428
|
+
|
|
382
429
|
- Name of the story in this case will be `Size`.
|
|
383
430
|
- JSX corresponding to this story will look like this:
|
|
431
|
+
|
|
384
432
|
```tsx
|
|
385
433
|
export const size = () => (
|
|
386
434
|
<div className="d-flex">
|
|
@@ -390,12 +438,14 @@ export const size = () => (
|
|
|
390
438
|
</div>
|
|
391
439
|
<div className="d-flex flex-column">
|
|
392
440
|
<Text weight="strong">Tiny</Text> <br />
|
|
393
|
-
<Avatar firstName="John" lastName="Doe" size="tiny"/>
|
|
441
|
+
<Avatar firstName="John" lastName="Doe" size="tiny" />
|
|
394
442
|
</div>
|
|
395
443
|
</div>
|
|
396
444
|
);
|
|
397
445
|
```
|
|
446
|
+
|
|
398
447
|
- The default export defines metadata about component.
|
|
448
|
+
|
|
399
449
|
```jsx
|
|
400
450
|
export default {
|
|
401
451
|
title: 'Components/Avatar/Variants/Appearance',
|
|
@@ -404,9 +454,13 @@ export default {
|
|
|
404
454
|
```
|
|
405
455
|
|
|
406
456
|
#### Component Testing
|
|
457
|
+
|
|
407
458
|
##### [./core/components/atoms/avatar/\_\_tests\_\_/Avatar.test.tsx](https://github.com/innovaccer/design-system/blob/master/core/components/atoms/avatar/__tests__/Avatar.test.tsx)
|
|
459
|
+
|
|
408
460
|
Now we will add snapshot and unit testing.
|
|
461
|
+
|
|
409
462
|
###### Imports
|
|
463
|
+
|
|
410
464
|
```tsx
|
|
411
465
|
import * as React from 'react';
|
|
412
466
|
import { render } from '@testing-library/react';
|
|
@@ -414,9 +468,12 @@ import { Avatar } from '@/index';
|
|
|
414
468
|
import { AvatarProps as Props } from '@/index.type';
|
|
415
469
|
import { testHelper, filterUndefined, valueHelper, testMessageHelper } from '@/utils/testHelper';
|
|
416
470
|
```
|
|
471
|
+
|
|
417
472
|
##### Snapshot Testing
|
|
473
|
+
|
|
418
474
|
- [Snapshot tests](https://jestjs.io/docs/en/snapshot-testing) are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
|
|
419
475
|
- Create a mapper object which includes required/iterable props.
|
|
476
|
+
|
|
420
477
|
```tsx
|
|
421
478
|
const sizes: AvatarProps['size'][] = ['regular', 'tiny'];
|
|
422
479
|
|
|
@@ -429,13 +486,7 @@ describe('Avatar component', () => {
|
|
|
429
486
|
const attr = filterUndefined(props) as Props;
|
|
430
487
|
|
|
431
488
|
it(testMessageHelper(attr), () => {
|
|
432
|
-
const { asFragment } = render(
|
|
433
|
-
<Avatar
|
|
434
|
-
{...attr}
|
|
435
|
-
>
|
|
436
|
-
JD
|
|
437
|
-
</Avatar>
|
|
438
|
-
);
|
|
489
|
+
const { asFragment } = render(<Avatar {...attr}>JD</Avatar>);
|
|
439
490
|
expect(asFragment()).toMatchSnapshot();
|
|
440
491
|
});
|
|
441
492
|
};
|
|
@@ -443,16 +494,23 @@ describe('Avatar component', () => {
|
|
|
443
494
|
testHelper(mapper, testFunc);
|
|
444
495
|
});
|
|
445
496
|
```
|
|
497
|
+
|
|
446
498
|
### DocPage Story
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
499
|
+
|
|
500
|
+
When our component has state or callbacks, we need to write custom code to render the story on docs page. Let us consider an example of `Controlled Checkbox` story.
|
|
501
|
+
|
|
502
|
+
###### [./core/components/atoms/checkbox/\_\_stories\_\_/variants/controlledCheckbox.story.tsx](https://github.com/innovaccer/design-system/blob/master/core/components/atoms/checkbox/__stories__/variants/Uncontrolled.story.tsx)
|
|
503
|
+
|
|
504
|
+
- Import the required components.
|
|
505
|
+
|
|
450
506
|
```tsx
|
|
451
507
|
import * as React from 'react';
|
|
452
508
|
import { Checkbox } from '@/index';
|
|
453
509
|
```
|
|
510
|
+
|
|
454
511
|
- Name of the story in this case will be `Controlled Checkbox`.
|
|
455
512
|
- We will create a state `checked` which will be false initially (showing that checkbox is not selected) and will update it when checkbox is clicked.
|
|
513
|
+
|
|
456
514
|
```tsx
|
|
457
515
|
export const controlledCheckbox = () => {
|
|
458
516
|
const [checked, setChecked] = React.useState(false);
|
|
@@ -461,17 +519,12 @@ export const controlledCheckbox = () => {
|
|
|
461
519
|
setChecked(event.target.checked);
|
|
462
520
|
};
|
|
463
521
|
|
|
464
|
-
return
|
|
465
|
-
<Checkbox
|
|
466
|
-
label="Innovaccer"
|
|
467
|
-
value="Innovaccer"
|
|
468
|
-
checked={checked}
|
|
469
|
-
onChange={handleParentChange}
|
|
470
|
-
/>
|
|
471
|
-
);
|
|
522
|
+
return <Checkbox label="Innovaccer" value="Innovaccer" checked={checked} onChange={handleParentChange} />;
|
|
472
523
|
};
|
|
473
524
|
```
|
|
525
|
+
|
|
474
526
|
- At this point, we will only see JSX in our live code editor. To fix this, we will write cutsom code for docs page.
|
|
527
|
+
|
|
475
528
|
```
|
|
476
529
|
const customCode = `() => {
|
|
477
530
|
const [checked, setChecked] = React.useState(false);
|
|
@@ -490,7 +543,9 @@ const customCode = `() => {
|
|
|
490
543
|
);
|
|
491
544
|
}`;
|
|
492
545
|
```
|
|
493
|
-
|
|
546
|
+
|
|
547
|
+
- Now we will export metadata of our story.
|
|
548
|
+
|
|
494
549
|
```jsx
|
|
495
550
|
export default {
|
|
496
551
|
title: 'Components/Checkbox/Variants/Controlled Checkbox',
|
|
@@ -498,24 +553,30 @@ export default {
|
|
|
498
553
|
parameters: {
|
|
499
554
|
docs: {
|
|
500
555
|
docPage: {
|
|
501
|
-
customCode
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
556
|
+
customCode,
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
},
|
|
505
560
|
};
|
|
506
561
|
```
|
|
562
|
+
|
|
507
563
|
### Creating Patterns
|
|
564
|
+
|
|
508
565
|
Patterns are best practice solutions for how a user achieves a goal. They show reusable combinations of components and templates that address common user objectives with sequences and flows.
|
|
509
566
|
Note: Patterns are only shown in `docs tab`.
|
|
510
567
|
|
|
511
568
|
Let us create a pattern for SideNav.
|
|
512
|
-
|
|
513
|
-
|
|
569
|
+
|
|
570
|
+
- Name of the pattern will be `Side Nav`.
|
|
571
|
+
- As patterns are shown only in docs tab, canvas tab will not render any element..
|
|
572
|
+
|
|
514
573
|
```tsx
|
|
515
574
|
import * as React from 'react';
|
|
516
575
|
export const sideNav = () => <></>;
|
|
517
576
|
```
|
|
518
|
-
|
|
577
|
+
|
|
578
|
+
- We will write custom code for docs tab.
|
|
579
|
+
|
|
519
580
|
```
|
|
520
581
|
const customCode = `() => {
|
|
521
582
|
const menus = [
|
|
@@ -597,10 +658,12 @@ const customCode = `() => {
|
|
|
597
658
|
);
|
|
598
659
|
}`;
|
|
599
660
|
```
|
|
661
|
+
|
|
600
662
|
- We have created a mock data for side nav menus.
|
|
601
663
|
- We then need `expanded` and `active` state to manage VerticalNav component props.
|
|
602
664
|
- We will then return JSX from our sideNav component.
|
|
603
665
|
- Now we will export metadata of our pattern. As we do not need props table for patterns, so we will add `noProps: true` in our metadata.
|
|
666
|
+
|
|
604
667
|
```
|
|
605
668
|
export default {
|
|
606
669
|
title: 'Patterns/VerticalNavigation/Side Nav',
|
|
@@ -616,6 +679,7 @@ export default {
|
|
|
616
679
|
};
|
|
617
680
|
|
|
618
681
|
```
|
|
682
|
+
|
|
619
683
|
### Submitting a Pull Request
|
|
620
684
|
|
|
621
685
|
The following are the steps you should follow when creating a pull request.
|
|
@@ -642,7 +706,6 @@ Before committing, **you must ensure there are no linting, formatting errors and
|
|
|
642
706
|
|
|
643
707
|
To ensure the above conditions, run:
|
|
644
708
|
|
|
645
|
-
|
|
646
709
|
For checking prettier issues:
|
|
647
710
|
|
|
648
711
|
```bash
|
|
@@ -654,7 +717,14 @@ For formating prettier issues:
|
|
|
654
717
|
```bash
|
|
655
718
|
npm run prettier
|
|
656
719
|
```
|
|
657
|
-
|
|
720
|
+
|
|
721
|
+
For checking lint issues:
|
|
722
|
+
|
|
723
|
+
```bash
|
|
724
|
+
npm run lint:check
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
For formating lint issues:
|
|
658
728
|
|
|
659
729
|
```bash
|
|
660
730
|
npm run lint
|
|
@@ -662,9 +732,9 @@ npm run lint
|
|
|
662
732
|
|
|
663
733
|
For tests:
|
|
664
734
|
|
|
665
|
-
|
|
735
|
+
```bash
|
|
666
736
|
npm run test
|
|
667
|
-
|
|
737
|
+
```
|
|
668
738
|
|
|
669
739
|
Then, and only then, you can create your pull request.
|
|
670
740
|
|
|
@@ -672,14 +742,14 @@ Then, and only then, you can create your pull request.
|
|
|
672
742
|
|
|
673
743
|
The following are the steps you should follow when creating a new branch.
|
|
674
744
|
|
|
675
|
-
- Start the branch name with prefixes like fix-, feat-, test-
|
|
745
|
+
- Start the branch name with prefixes like fix-, feat-, test- as mentioned in [conventional commit messages](https://conventionalcommits.org/)
|
|
676
746
|
- Add a short description of the task. This makes the branch name recognizable and distinct.
|
|
677
747
|
- Use hyphens as separators
|
|
678
748
|
|
|
679
749
|
For example:
|
|
680
750
|
|
|
681
|
-
|
|
682
|
-
|
|
751
|
+
- `feat-add-billing-module`
|
|
752
|
+
- `fix-modal-height`
|
|
683
753
|
|
|
684
754
|
#### Commit Guidelines
|
|
685
755
|
|
|
@@ -689,8 +759,8 @@ semantic versioning.
|
|
|
689
759
|
|
|
690
760
|
For example:
|
|
691
761
|
|
|
692
|
-
|
|
693
|
-
|
|
762
|
+
- `feat: A new feature`
|
|
763
|
+
- `fix: A bug fix`
|
|
694
764
|
|
|
695
765
|
A commit of the type **feat** introduces a new feature to the codebase
|
|
696
766
|
(this correlates with MINOR in semantic versioning).
|
|
@@ -712,19 +782,16 @@ fix: xxxxxxxxxx
|
|
|
712
782
|
Commits types such as as `docs:`,`style:`,`refactor:`,`perf:`,`test:`
|
|
713
783
|
and `chore:` are valid but have no effect on versioning. **It would be great if you use them.**
|
|
714
784
|
|
|
715
|
-
|
|
716
785
|
**PRs that do not follow the commit message guidelines will not be merged.**
|
|
717
786
|
|
|
718
787
|
## Update Tests
|
|
719
788
|
|
|
720
789
|
**Any change in source code must include test updates**.
|
|
721
790
|
|
|
722
|
-
|
|
723
791
|
## Update Stories
|
|
724
792
|
|
|
725
793
|
**For any change in source code of components that changes the API or functioning of the component corresponding story should be updated or a new story should be included**.
|
|
726
794
|
|
|
727
|
-
|
|
728
795
|
## Add yourself to the contributor list
|
|
729
796
|
|
|
730
797
|
We want to make sure everyone is recognized for their contributions !
|
|
@@ -741,9 +808,24 @@ run the following commands from the root of the repo:
|
|
|
741
808
|
Then, you'll need to generate the updated `all-contributors` table by running
|
|
742
809
|
|
|
743
810
|
```sh
|
|
744
|
-
all-contributors generate
|
|
811
|
+
all-contributors generate
|
|
745
812
|
OR
|
|
746
813
|
./node_modules/.bin/all-contributors generate
|
|
747
814
|
|
|
748
815
|
```
|
|
749
816
|
|
|
817
|
+
## Accessibility
|
|
818
|
+
|
|
819
|
+
Accessibility is the practice of making your websites usable by as many people as possible. A page should be
|
|
820
|
+
|
|
821
|
+
1. Keyboard friendly
|
|
822
|
+
2. Color blind friendly / Color contrast
|
|
823
|
+
3. Screen Reader / Voice over
|
|
824
|
+
4. Should not distort on Zoom In or Out.
|
|
825
|
+
|
|
826
|
+
To met the above criteria make sure following things are addressed.
|
|
827
|
+
|
|
828
|
+
1. There is no `jsx-a11y` linting issue.
|
|
829
|
+
2. All the Storybook Accessibility plugin checks are met.
|
|
830
|
+
3. All the [WCAG 2.0 checks AA are covered](https://docs.google.com/spreadsheets/d/1q7SaO-Bki9RIusQKB01Q8WclHvmERXGU1rdl4ou9s5E/edit#gid=1091897153)
|
|
831
|
+
4. All the [WAI-ARIA Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.2/) are met.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = { extends: ['@commitlint/config-conventional'] };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { isEnterKey } from '@/accessibility/utils';
|
|
3
|
+
|
|
4
|
+
interface IProps {
|
|
5
|
+
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
6
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
7
|
+
role?: React.AriaRole;
|
|
8
|
+
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const useAccessibilityProps = ({ onClick, onKeyDown, role, ...rest }: IProps) => {
|
|
12
|
+
return {
|
|
13
|
+
...(onClick
|
|
14
|
+
? {
|
|
15
|
+
onClick: onClick,
|
|
16
|
+
role: role || 'button',
|
|
17
|
+
tabIndex: 0,
|
|
18
|
+
'aria-label': rest['aria-label'],
|
|
19
|
+
onKeyDown: (e: React.SyntheticEvent<HTMLElement>) => {
|
|
20
|
+
if (onKeyDown) {
|
|
21
|
+
onKeyDown(e as React.KeyboardEvent<HTMLElement>);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (isEnterKey(e as React.KeyboardEvent<HTMLElement>) && onClick) {
|
|
25
|
+
onClick(e as React.MouseEvent<HTMLElement>);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
: { role, 'aria-label': rest['aria-label'] }),
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default useAccessibilityProps;
|