@edvisor/product-language 0.10.0 → 0.10.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/.babelrc +12 -0
- package/.eslintrc.json +147 -0
- package/.release-it.json +17 -0
- package/.storybook/main.js +57 -0
- package/.storybook/manager.js +7 -0
- package/.storybook/preview.js +15 -0
- package/.storybook/tsconfig.json +30 -0
- package/jest.config.ts +15 -0
- package/jest.setup.ts +2 -0
- package/package.json +2 -27
- package/project.json +98 -0
- package/src/README.md +61 -0
- package/src/assets/svg/example_icon.svg +3 -0
- package/src/assets/svg/example_icon_white.svg +3 -0
- package/src/assets/svg/spinner.svg +3 -0
- package/src/assets/svg/spinner_white.svg +3 -0
- package/src/helpers/index.ts +4 -0
- package/src/helpers/playground.ts +26 -0
- package/src/helpers/talesOf.tsx +42 -0
- package/src/index.ts +2 -0
- package/src/lib/components/README.md +49 -0
- package/src/lib/components/alert-banner/alert-banner.test.tsx +93 -0
- package/src/lib/components/alert-banner/alert-banner.tsx +117 -0
- package/src/lib/components/alert-banner/alert-level-flags.ts +101 -0
- package/src/lib/components/alert-banner/index.ts +1 -0
- package/src/lib/components/alert-banner/storybook/alert-banner.stories.mdx +67 -0
- package/src/lib/components/alert-banner/storybook/components.tsx +124 -0
- package/src/lib/components/badge/badge-type-flags.ts +72 -0
- package/src/lib/components/badge/badge.test.tsx +29 -0
- package/src/lib/components/badge/badge.tsx +22 -0
- package/src/lib/components/badge/index.ts +1 -0
- package/src/lib/components/badge/stories/badge.stories.mdx +44 -0
- package/src/lib/components/badge/stories/components.tsx +49 -0
- package/{lib/components/card/atoms/card-frame.d.ts → src/lib/components/card/atoms/card-frame.tsx} +16 -7
- package/src/lib/components/card/atoms/index.ts +1 -0
- package/src/lib/components/card/card.test.tsx +162 -0
- package/src/lib/components/card/card.tsx +78 -0
- package/src/lib/components/card/components/card-alert-banner-slot.tsx +16 -0
- package/src/lib/components/card/components/card-controls-slot.tsx +19 -0
- package/src/lib/components/card/components/card-section-slot.tsx +51 -0
- package/src/lib/components/card/components/index.ts +3 -0
- package/src/lib/components/card/index.ts +3 -0
- package/src/lib/components/card/molecules/index.ts +1 -0
- package/src/lib/components/card/molecules/left-right-card.test.tsx +89 -0
- package/src/lib/components/card/molecules/left-right-card.tsx +63 -0
- package/src/lib/components/card/storybook/card.stories.mdx +100 -0
- package/src/lib/components/card/storybook/components.tsx +227 -0
- package/src/lib/components/checkbox/checkbox.test.tsx +39 -0
- package/src/lib/components/checkbox/checkbox.tsx +70 -0
- package/src/lib/components/checkbox/helpers.tsx +98 -0
- package/src/lib/components/checkbox/index.tsx +1 -0
- package/src/lib/components/checkbox/stories/checkbox.stories.mdx +57 -0
- package/src/lib/components/checkbox/stories/components.tsx +84 -0
- package/src/lib/components/date-picker/components/custom-calendar.tsx +193 -0
- package/src/lib/components/date-picker/components/index.ts +1 -0
- package/src/lib/components/date-picker/data-picker.test.tsx +220 -0
- package/src/lib/components/date-picker/date-picker.tsx +10 -0
- package/src/lib/components/date-picker/helpers/date-picker-factory.tsx +210 -0
- package/src/lib/components/date-picker/index.ts +1 -0
- package/src/lib/components/date-picker/storybook/components.tsx +259 -0
- package/src/lib/components/date-picker/storybook/date-picker.stories.mdx +133 -0
- package/src/lib/components/divider/divider-type-flags.tsx +37 -0
- package/src/lib/components/divider/divider.test.tsx +34 -0
- package/src/lib/components/divider/divider.tsx +37 -0
- package/src/lib/components/divider/index.tsx +1 -0
- package/src/lib/components/divider/stories/components.tsx +13 -0
- package/src/lib/components/divider/stories/divider.stories.mdx +44 -0
- package/src/lib/components/flag/flag-size-flags.tsx +55 -0
- package/src/lib/components/flag/flag.list.tsx +788 -0
- package/src/lib/components/flag/flag.test.tsx +65 -0
- package/src/lib/components/flag/flag.tsx +97 -0
- package/src/lib/components/flag/index.tsx +1 -0
- package/src/lib/components/flag/stories/components.tsx +403 -0
- package/src/lib/components/flag/stories/flag.stories.mdx +48 -0
- package/src/lib/components/flag/stories/playGround-select.tsx +145 -0
- package/src/lib/components/icon/icon-list.tsx +135 -0
- package/src/lib/components/icon/icon.test.tsx +47 -0
- package/src/lib/components/icon/icon.tsx +181 -0
- package/src/lib/components/icon/index.tsx +1 -0
- package/src/lib/components/icon/stories/components.tsx +282 -0
- package/src/lib/components/icon/stories/icon.stories.mdx +65 -0
- package/src/lib/components/index.ts +26 -0
- package/src/lib/components/input-field/components/index.ts +2 -0
- package/src/lib/components/input-field/components/labeled-input.tsx +57 -0
- package/src/lib/components/input-field/components/stepper.tsx +64 -0
- package/src/lib/components/input-field/index.ts +6 -0
- package/src/lib/components/input-field/input-field.test.tsx +107 -0
- package/src/lib/components/input-field/input-field.tsx +154 -0
- package/src/lib/components/input-field/input-number.tsx +41 -0
- package/src/lib/components/input-field/input-text.tsx +30 -0
- package/src/lib/components/input-field/storybook/components.tsx +367 -0
- package/src/lib/components/input-field/storybook/input-field.stories.mdx +120 -0
- package/src/lib/components/layout/flex.tsx +22 -0
- package/src/lib/components/layout/grid-layout.tsx +40 -0
- package/src/lib/components/layout/index.ts +3 -0
- package/src/lib/components/layout/left-right-layout.tsx +67 -0
- package/src/lib/components/link/index.ts +1 -0
- package/src/lib/components/link/link.test.tsx +29 -0
- package/src/lib/components/link/link.tsx +56 -0
- package/src/lib/components/link/storybook/link.stories.mdx +52 -0
- package/src/lib/components/modal/index.ts +3 -0
- package/src/lib/components/modal/modal-base.tsx +129 -0
- package/src/lib/components/modal/modal-destructive.tsx +70 -0
- package/src/lib/components/modal/modal.test.tsx +138 -0
- package/src/lib/components/modal/modal.tsx +114 -0
- package/src/lib/components/modal/storybook/components.tsx +105 -0
- package/src/lib/components/modal/storybook/modal-destructive.stories.mdx +31 -0
- package/src/lib/components/modal/storybook/modal.stories.mdx +50 -0
- package/src/lib/components/molecules/avatar/avatar-size-flags.tsx +55 -0
- package/src/lib/components/molecules/avatar/avatar.test.tsx +114 -0
- package/src/lib/components/molecules/avatar/avatar.tsx +80 -0
- package/src/lib/components/molecules/avatar/index.tsx +1 -0
- package/src/lib/components/molecules/avatar/stories/avatar.stories.mdx +52 -0
- package/src/lib/components/molecules/avatar/stories/components.tsx +36 -0
- package/src/lib/components/molecules/button/button-flags.tsx +340 -0
- package/src/lib/components/molecules/button/button.test.tsx +77 -0
- package/src/lib/components/molecules/button/button.tsx +212 -0
- package/src/lib/components/molecules/button/index.tsx +1 -0
- package/src/lib/components/molecules/button/stories/button.stories.mdx +105 -0
- package/src/lib/components/molecules/button/stories/components.tsx +90 -0
- package/src/lib/components/molecules/index.ts +3 -0
- package/src/lib/components/molecules/input-checkbox/index.tsx +1 -0
- package/src/lib/components/molecules/input-checkbox/input-checkbox.test.tsx +34 -0
- package/src/lib/components/molecules/input-checkbox/input-checkbox.tsx +50 -0
- package/src/lib/components/molecules/input-checkbox/stories/components.tsx +53 -0
- package/src/lib/components/molecules/input-checkbox/stories/input-checkbox.stories.mdx +49 -0
- package/src/lib/components/organisms/choice-list/choice-list.test.tsx +36 -0
- package/src/lib/components/organisms/choice-list/choice-list.tsx +72 -0
- package/src/lib/components/organisms/choice-list/index.tsx +1 -0
- package/src/lib/components/organisms/choice-list/stories/choice-list.stories.mdx +57 -0
- package/src/lib/components/organisms/choice-list/stories/components.tsx +45 -0
- package/src/lib/components/organisms/index.ts +2 -0
- package/src/lib/components/organisms/multi-choice-list/index.tsx +1 -0
- package/src/lib/components/organisms/multi-choice-list/multi-choice-list.test.tsx +33 -0
- package/src/lib/components/organisms/multi-choice-list/multi-choice-list.tsx +53 -0
- package/src/lib/components/organisms/multi-choice-list/stories/components.tsx +124 -0
- package/src/lib/components/organisms/multi-choice-list/stories/multi-choice-list.stories.mdx +99 -0
- package/src/lib/components/progress-bar/index.ts +1 -0
- package/src/lib/components/progress-bar/progress-bar-size-flags.tsx +37 -0
- package/src/lib/components/progress-bar/progress-bar.test.tsx +66 -0
- package/src/lib/components/progress-bar/progress-bar.tsx +42 -0
- package/src/lib/components/progress-bar/storybook/components.tsx +62 -0
- package/src/lib/components/progress-bar/storybook/progress-bar.stories.mdx +43 -0
- package/{lib/components/spinner/index.d.ts → src/lib/components/radio-button/index.tsx} +1 -1
- package/src/lib/components/radio-button/radio-button.tsx +135 -0
- package/src/lib/components/radio-button/radio.test.tsx +59 -0
- package/src/lib/components/radio-button/stories/components.tsx +36 -0
- package/src/lib/components/radio-button/stories/radio-button.stories.mdx +44 -0
- package/src/lib/components/range-slider/components/bar-chart.tsx +50 -0
- package/src/lib/components/range-slider/components/handle.tsx +58 -0
- package/src/lib/components/range-slider/components/rail.tsx +44 -0
- package/src/lib/components/range-slider/components/slider-component.tsx +98 -0
- package/src/lib/components/range-slider/components/slider-inputs.tsx +150 -0
- package/src/lib/components/range-slider/components/tick.tsx +51 -0
- package/src/lib/components/range-slider/components/track.tsx +67 -0
- package/src/lib/components/range-slider/index.tsx +2 -0
- package/src/lib/components/range-slider/range-slider.test.tsx +185 -0
- package/src/lib/components/range-slider/range-slider.tsx +132 -0
- package/src/lib/components/range-slider/slider.test.tsx +89 -0
- package/src/lib/components/range-slider/slider.tsx +80 -0
- package/src/lib/components/range-slider/stories/components.tsx +179 -0
- package/src/lib/components/range-slider/stories/range-slider.stories.mdx +84 -0
- package/src/lib/components/range-slider/types.ts +18 -0
- package/src/lib/components/select/components/menu-container.tsx +69 -0
- package/src/lib/components/select/components/menu-list.tsx +195 -0
- package/src/lib/components/select/components/menu-row.tsx +43 -0
- package/src/lib/components/select/components/menu.tsx +151 -0
- package/src/lib/components/select/components/option.tsx +91 -0
- package/src/lib/components/select/components/select-label.tsx +10 -0
- package/src/lib/components/select/components/value-component-multi.tsx +40 -0
- package/src/lib/components/select/components/value-component-single.tsx +27 -0
- package/src/lib/components/select/components/value.tsx +370 -0
- package/src/lib/components/select/index.tsx +3 -0
- package/src/lib/components/select/select.test.tsx +148 -0
- package/src/lib/components/select/select.tsx +337 -0
- package/src/lib/components/select/storybook/components.tsx +999 -0
- package/src/lib/components/select/storybook/radio-group.tsx +157 -0
- package/src/lib/components/select/storybook/select.stories.mdx +172 -0
- package/src/lib/components/select/types.ts +149 -0
- package/src/lib/components/select/utils.ts +101 -0
- package/src/lib/components/spinner/index.tsx +1 -0
- package/src/lib/components/spinner/spinner-size-flags.tsx +39 -0
- package/src/lib/components/spinner/spinner.test.tsx +31 -0
- package/src/lib/components/spinner/spinner.tsx +54 -0
- package/src/lib/components/spinner/stories/components.tsx +39 -0
- package/src/lib/components/spinner/stories/spinner.stories.mdx +35 -0
- package/src/lib/components/tabs/components/index.ts +1 -0
- package/src/lib/components/tabs/components/tab.tsx +85 -0
- package/src/lib/components/tabs/index.tsx +1 -0
- package/src/lib/components/tabs/storybook/components.tsx +317 -0
- package/src/lib/components/tabs/storybook/tabs.stories.mdx +105 -0
- package/src/lib/components/tabs/tabs.test.tsx +86 -0
- package/src/lib/components/tabs/tabs.tsx +115 -0
- package/src/lib/components/tag/components/close-button.tsx +85 -0
- package/src/lib/components/tag/components/index.ts +2 -0
- package/src/lib/components/tag/components/tag-label.tsx +45 -0
- package/src/lib/components/tag/index.tsx +1 -0
- package/src/lib/components/tag/stories/components.tsx +86 -0
- package/src/lib/components/tag/stories/tag.stories.mdx +42 -0
- package/src/lib/components/tag/tag.test.tsx +36 -0
- package/src/lib/components/tag/tag.tsx +33 -0
- package/src/lib/components/thumbnail/index.tsx +1 -0
- package/src/lib/components/thumbnail/stories/thumbnail.stories.mdx +44 -0
- package/src/lib/components/thumbnail/thumbnail-size-flags.tsx +41 -0
- package/src/lib/components/thumbnail/thumbnail.test.tsx +51 -0
- package/src/lib/components/thumbnail/thumbnail.tsx +44 -0
- package/src/lib/components/tooltip/index.tsx +1 -0
- package/src/lib/components/tooltip/stories/components.tsx +224 -0
- package/src/lib/components/tooltip/stories/tooltip.stories.mdx +63 -0
- package/src/lib/components/tooltip/tooltip.test.tsx +22 -0
- package/src/lib/components/tooltip/tooltip.tsx +179 -0
- package/src/lib/components/tree-view/components/tree-node.tsx +203 -0
- package/src/lib/components/tree-view/helper.tsx +171 -0
- package/src/lib/components/tree-view/index.ts +2 -0
- package/src/lib/components/tree-view/stories/components.tsx +640 -0
- package/src/lib/components/tree-view/stories/tree-view.stories.mdx +127 -0
- package/src/lib/components/tree-view/tree-view.test.tsx +146 -0
- package/src/lib/components/tree-view/tree-view.tsx +168 -0
- package/src/lib/components/tree-view/types.tsx +70 -0
- package/src/lib/components/typography/index.ts +1 -0
- package/src/lib/components/typography/storybook/components.tsx +288 -0
- package/src/lib/components/typography/storybook/typography.stories.mdx +90 -0
- package/src/lib/components/typography/typography.test.tsx +97 -0
- package/src/lib/components/typography/typography.tsx +99 -0
- package/src/lib/foundations/color-system/base-palette/base-palette.stories.tsx +123 -0
- package/src/lib/foundations/color-system/base-palette/base-palette.ts +93 -0
- package/src/lib/foundations/color-system/base-palette/index.ts +1 -0
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.mdx +85 -0
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.tsx +231 -0
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.ts +160 -0
- package/src/lib/foundations/color-system/color-guidelines/index.ts +1 -0
- package/src/lib/foundations/color-system/components/color-sample.tsx +99 -0
- package/src/lib/foundations/color-system/components/index.ts +1 -0
- package/src/lib/foundations/color-system/index.ts +1 -0
- package/src/lib/foundations/index.ts +4 -0
- package/src/lib/foundations/shadows/components.tsx +59 -0
- package/src/lib/foundations/shadows/index.ts +1 -0
- package/src/lib/foundations/shadows/shadows.stories.mdx +71 -0
- package/src/lib/foundations/shadows/shadows.tsx +47 -0
- package/src/lib/foundations/spacing/index.ts +1 -0
- package/src/lib/foundations/spacing/spacing-guidelines.ts +37 -0
- package/src/lib/foundations/spacing/spacing.stories.mdx +51 -0
- package/src/lib/foundations/spacing/spacing.ts +18 -0
- package/src/lib/foundations/typography/constants.ts +25 -0
- package/src/lib/foundations/typography/fonts.ts +205 -0
- package/src/lib/foundations/typography/index.tsx +1 -0
- package/src/lib/foundations/typography/text-aspect-flags.ts +61 -0
- package/src/lib/foundations/typography/typography.tsx +102 -0
- package/src/lib/helpers/generic-types.ts +44 -0
- package/src/lib/helpers/index.ts +8 -0
- package/src/lib/helpers/isReactElementOfType.test.tsx +108 -0
- package/src/lib/helpers/isReactElementOfType.ts +42 -0
- package/src/lib/helpers/nothing.tsx +22 -0
- package/{lib/helpers/numbers.d.ts → src/lib/helpers/numbers.ts} +67 -50
- package/src/lib/helpers/safe-navigation.ts +57 -0
- package/src/lib/helpers/slots.tsx +126 -0
- package/src/lib/helpers/strings.test.ts +47 -0
- package/src/lib/helpers/strings.ts +16 -0
- package/src/lib/helpers/useInputElementState.ts +56 -0
- package/src/lib/helpers/useKeyDown.ts +17 -0
- package/tsconfig.json +35 -0
- package/tsconfig.lib.json +28 -0
- package/tsconfig.spec.json +21 -0
- package/index.d.ts +0 -2
- package/index.js +0 -11246
- package/lib/components/alert-banner/alert-banner.d.ts +0 -15
- package/lib/components/alert-banner/alert-level-flags.d.ts +0 -18
- package/lib/components/alert-banner/index.d.ts +0 -1
- package/lib/components/badge/badge-type-flags.d.ts +0 -18
- package/lib/components/badge/badge.d.ts +0 -5
- package/lib/components/badge/index.d.ts +0 -1
- package/lib/components/card/atoms/index.d.ts +0 -1
- package/lib/components/card/card.d.ts +0 -14
- package/lib/components/card/components/card-alert-banner-slot.d.ts +0 -6
- package/lib/components/card/components/card-controls-slot.d.ts +0 -5
- package/lib/components/card/components/card-section-slot.d.ts +0 -11
- package/lib/components/card/components/index.d.ts +0 -3
- package/lib/components/card/index.d.ts +0 -3
- package/lib/components/card/molecules/index.d.ts +0 -1
- package/lib/components/card/molecules/left-right-card.d.ts +0 -16
- package/lib/components/checkbox/checkbox.d.ts +0 -11
- package/lib/components/checkbox/helpers.d.ts +0 -12
- package/lib/components/checkbox/index.d.ts +0 -1
- package/lib/components/date-picker/components/custom-calendar.d.ts +0 -6
- package/lib/components/date-picker/components/index.d.ts +0 -1
- package/lib/components/date-picker/date-picker.d.ts +0 -4
- package/lib/components/date-picker/helpers/date-picker-factory.d.ts +0 -34
- package/lib/components/date-picker/index.d.ts +0 -1
- package/lib/components/divider/divider-type-flags.d.ts +0 -9
- package/lib/components/divider/divider.d.ts +0 -7
- package/lib/components/divider/index.d.ts +0 -1
- package/lib/components/flag/flag-size-flags.d.ts +0 -12
- package/lib/components/flag/flag.d.ts +0 -9
- package/lib/components/flag/flag.list.d.ts +0 -782
- package/lib/components/flag/index.d.ts +0 -1
- package/lib/components/icon/icon-list.d.ts +0 -132
- package/lib/components/icon/icon.d.ts +0 -131
- package/lib/components/icon/index.d.ts +0 -1
- package/lib/components/index.d.ts +0 -24
- package/lib/components/input-field/components/index.d.ts +0 -2
- package/lib/components/input-field/components/labeled-input.d.ts +0 -10
- package/lib/components/input-field/components/stepper.d.ts +0 -7
- package/lib/components/input-field/index.d.ts +0 -3
- package/lib/components/input-field/input-field.d.ts +0 -26
- package/lib/components/input-field/input-number.d.ts +0 -18
- package/lib/components/input-field/input-text.d.ts +0 -14
- package/lib/components/layout/flex.d.ts +0 -16
- package/lib/components/layout/grid-layout.d.ts +0 -11
- package/lib/components/layout/index.d.ts +0 -3
- package/lib/components/layout/left-right-layout.d.ts +0 -34
- package/lib/components/link/index.d.ts +0 -1
- package/lib/components/link/link.d.ts +0 -14
- package/lib/components/modal/index.d.ts +0 -3
- package/lib/components/modal/modal-base.d.ts +0 -28
- package/lib/components/modal/modal-destructive.d.ts +0 -11
- package/lib/components/modal/modal.d.ts +0 -13
- package/lib/components/molecules/avatar/avatar-size-flags.d.ts +0 -12
- package/lib/components/molecules/avatar/avatar.d.ts +0 -12
- package/lib/components/molecules/avatar/index.d.ts +0 -1
- package/lib/components/molecules/button/button-flags.d.ts +0 -44
- package/lib/components/molecules/button/button.d.ts +0 -12
- package/lib/components/molecules/button/index.d.ts +0 -1
- package/lib/components/molecules/index.d.ts +0 -3
- package/lib/components/molecules/input-checkbox/index.d.ts +0 -1
- package/lib/components/molecules/input-checkbox/input-checkbox.d.ts +0 -8
- package/lib/components/organisms/choice-list/choice-list.d.ts +0 -9
- package/lib/components/organisms/choice-list/index.d.ts +0 -1
- package/lib/components/organisms/index.d.ts +0 -2
- package/lib/components/organisms/multi-choice-list/index.d.ts +0 -1
- package/lib/components/organisms/multi-choice-list/multi-choice-list.d.ts +0 -11
- package/lib/components/progress-bar/index.d.ts +0 -1
- package/lib/components/progress-bar/progress-bar-size-flags.d.ts +0 -10
- package/lib/components/progress-bar/progress-bar.d.ts +0 -8
- package/lib/components/radio-button/index.d.ts +0 -1
- package/lib/components/radio-button/radio-button.d.ts +0 -10
- package/lib/components/range-slider/components/bar-chart.d.ts +0 -8
- package/lib/components/range-slider/components/handle.d.ts +0 -12
- package/lib/components/range-slider/components/rail.d.ts +0 -9
- package/lib/components/range-slider/components/slider-component.d.ts +0 -12
- package/lib/components/range-slider/components/slider-inputs.d.ts +0 -14
- package/lib/components/range-slider/components/tick.d.ts +0 -10
- package/lib/components/range-slider/components/track.d.ts +0 -11
- package/lib/components/range-slider/index.d.ts +0 -2
- package/lib/components/range-slider/range-slider.d.ts +0 -15
- package/lib/components/range-slider/slider.d.ts +0 -11
- package/lib/components/range-slider/types.d.ts +0 -11
- package/lib/components/select/components/menu-container.d.ts +0 -3
- package/lib/components/select/components/menu-list.d.ts +0 -3
- package/lib/components/select/components/menu-row.d.ts +0 -9
- package/lib/components/select/components/menu.d.ts +0 -3
- package/lib/components/select/components/option.d.ts +0 -13
- package/lib/components/select/components/select-label.d.ts +0 -1
- package/lib/components/select/components/value-component-multi.d.ts +0 -4
- package/lib/components/select/components/value-component-single.d.ts +0 -4
- package/lib/components/select/components/value.d.ts +0 -4
- package/lib/components/select/index.d.ts +0 -3
- package/lib/components/select/select.d.ts +0 -10
- package/lib/components/select/types.d.ts +0 -133
- package/lib/components/select/utils.d.ts +0 -15
- package/lib/components/spinner/spinner-size-flags.d.ts +0 -10
- package/lib/components/spinner/spinner.d.ts +0 -9
- package/lib/components/tabs/components/index.d.ts +0 -1
- package/lib/components/tabs/components/tab.d.ts +0 -8
- package/lib/components/tabs/index.d.ts +0 -1
- package/lib/components/tabs/tabs.d.ts +0 -16
- package/lib/components/tag/components/close-button.d.ts +0 -8
- package/lib/components/tag/components/index.d.ts +0 -2
- package/lib/components/tag/components/tag-label.d.ts +0 -8
- package/lib/components/tag/index.d.ts +0 -1
- package/lib/components/tag/tag.d.ts +0 -10
- package/lib/components/thumbnail/index.d.ts +0 -1
- package/lib/components/thumbnail/thumbnail-size-flags.d.ts +0 -10
- package/lib/components/thumbnail/thumbnail.d.ts +0 -10
- package/lib/components/tooltip/index.d.ts +0 -1
- package/lib/components/tooltip/tooltip.d.ts +0 -26
- package/lib/components/tree-view/components/tree-node.d.ts +0 -3
- package/lib/components/tree-view/helper.d.ts +0 -12
- package/lib/components/tree-view/index.d.ts +0 -2
- package/lib/components/tree-view/tree-view.d.ts +0 -3
- package/lib/components/tree-view/types.d.ts +0 -63
- package/lib/components/typography/index.d.ts +0 -1
- package/lib/components/typography/typography.d.ts +0 -24
- package/lib/foundations/color-system/base-palette/base-palette.d.ts +0 -76
- package/lib/foundations/color-system/base-palette/index.d.ts +0 -1
- package/lib/foundations/color-system/color-guidelines/color-guidelines.d.ts +0 -133
- package/lib/foundations/color-system/color-guidelines/index.d.ts +0 -1
- package/lib/foundations/color-system/components/color-sample.d.ts +0 -17
- package/lib/foundations/color-system/components/index.d.ts +0 -1
- package/lib/foundations/color-system/index.d.ts +0 -1
- package/lib/foundations/index.d.ts +0 -4
- package/lib/foundations/shadows/components.d.ts +0 -8
- package/lib/foundations/shadows/index.d.ts +0 -1
- package/lib/foundations/shadows/shadows.d.ts +0 -8
- package/lib/foundations/spacing/index.d.ts +0 -1
- package/lib/foundations/spacing/spacing-guidelines.d.ts +0 -33
- package/lib/foundations/spacing/spacing.d.ts +0 -18
- package/lib/foundations/typography/constants.d.ts +0 -22
- package/lib/foundations/typography/fonts.d.ts +0 -1
- package/lib/foundations/typography/index.d.ts +0 -1
- package/lib/foundations/typography/text-aspect-flags.d.ts +0 -19
- package/lib/foundations/typography/typography.d.ts +0 -24
- package/lib/helpers/generic-types.d.ts +0 -21
- package/lib/helpers/index.d.ts +0 -8
- package/lib/helpers/isReactElementOfType.d.ts +0 -8
- package/lib/helpers/nothing.d.ts +0 -10
- package/lib/helpers/safe-navigation.d.ts +0 -17
- package/lib/helpers/slots.d.ts +0 -17
- package/lib/helpers/strings.d.ts +0 -1
- package/lib/helpers/useInputElementState.d.ts +0 -30
- package/lib/helpers/useKeyDown.d.ts +0 -1
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import { useForm } from 'react-hook-form'
|
|
3
|
+
|
|
4
|
+
import { Margin } from '@foundations'
|
|
5
|
+
import { Playground } from '@stories'
|
|
6
|
+
|
|
7
|
+
import { SpaceBetween } from 'components/layout'
|
|
8
|
+
import { IconMinor } from 'components/icon'
|
|
9
|
+
|
|
10
|
+
import { InputField as InputFieldBase } from '../input-field'
|
|
11
|
+
import { InputNumber as InputNumberBase } from '../input-number'
|
|
12
|
+
import { InputText as InputTextBase } from '../input-text'
|
|
13
|
+
|
|
14
|
+
const InputField = styled(InputFieldBase)`
|
|
15
|
+
margin-bottom: ${Margin.xxs}
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
const InputNumber = styled(InputNumberBase)`
|
|
19
|
+
margin-bottom: ${Margin.xxs}
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
const InputText = styled(InputTextBase)`
|
|
23
|
+
margin-bottom: ${Margin.xxs}
|
|
24
|
+
`
|
|
25
|
+
|
|
26
|
+
export const PlainHTMLFormExample = () => (
|
|
27
|
+
<Playground
|
|
28
|
+
code={`
|
|
29
|
+
/* Edit this code sample! */
|
|
30
|
+
const [invalid, setInvalid] = useState(false);
|
|
31
|
+
|
|
32
|
+
<form onSubmit={(e) => e.preventDefault()}>
|
|
33
|
+
<label htmlFor="country_code">Country code*</label>
|
|
34
|
+
{/* try replacing this element with an <input /> */}
|
|
35
|
+
<InputField
|
|
36
|
+
// try setting the prefix, suffix, and invalid props
|
|
37
|
+
type="text"
|
|
38
|
+
placeholder="Enter a country code..."
|
|
39
|
+
id="country_code"
|
|
40
|
+
name="country_code"
|
|
41
|
+
pattern="[A-Za-z]{3}"
|
|
42
|
+
onInvalid={setInvalid}
|
|
43
|
+
invalid={invalid}
|
|
44
|
+
onChange={() => setInvalid(false)}
|
|
45
|
+
title="Three letter country code"
|
|
46
|
+
required
|
|
47
|
+
/>
|
|
48
|
+
<input type="submit"/>
|
|
49
|
+
</form>
|
|
50
|
+
`}
|
|
51
|
+
providerProps={{
|
|
52
|
+
renderAsComponent: true,
|
|
53
|
+
scope: {
|
|
54
|
+
InputField,
|
|
55
|
+
},
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
export const InnerLabelExample = () => (
|
|
61
|
+
<Playground
|
|
62
|
+
code={`
|
|
63
|
+
<InputField
|
|
64
|
+
type="text"
|
|
65
|
+
label="Country Code"
|
|
66
|
+
placeholder="Enter a country code..."
|
|
67
|
+
/>
|
|
68
|
+
`}
|
|
69
|
+
providerProps={{
|
|
70
|
+
renderAsComponent: true,
|
|
71
|
+
scope: {
|
|
72
|
+
InputField,
|
|
73
|
+
},
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
export const InnerLabelPositionExample = () => (
|
|
79
|
+
<Playground
|
|
80
|
+
code={`
|
|
81
|
+
<form>
|
|
82
|
+
<InputField
|
|
83
|
+
label="Side label"
|
|
84
|
+
labelPosition='side'
|
|
85
|
+
required
|
|
86
|
+
/>
|
|
87
|
+
<InputField
|
|
88
|
+
label="Top label"
|
|
89
|
+
labelPosition='top'
|
|
90
|
+
/>
|
|
91
|
+
<InputField
|
|
92
|
+
label="Default top label"
|
|
93
|
+
/>
|
|
94
|
+
</form>
|
|
95
|
+
`}
|
|
96
|
+
providerProps={{
|
|
97
|
+
renderAsComponent: true,
|
|
98
|
+
scope: {
|
|
99
|
+
InputField,
|
|
100
|
+
useForm,
|
|
101
|
+
},
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
export const ReactFormHookExample = () => (
|
|
107
|
+
<Playground
|
|
108
|
+
code={`
|
|
109
|
+
const { register, formState: { errors }, handleSubmit } = useForm();
|
|
110
|
+
const onSubmit = data => alert(data);
|
|
111
|
+
|
|
112
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
113
|
+
<InputField
|
|
114
|
+
label="First name"
|
|
115
|
+
invalid={errors.firstName}
|
|
116
|
+
required
|
|
117
|
+
{...register("firstName", { required: true, maxLength: 20 })}
|
|
118
|
+
/>
|
|
119
|
+
<InputField
|
|
120
|
+
label="Last name"
|
|
121
|
+
invalid={errors.lastName}
|
|
122
|
+
{...register("lastName", { pattern: /^[A-Za-z]+$/i })}
|
|
123
|
+
/>
|
|
124
|
+
<InputField
|
|
125
|
+
label="Age"
|
|
126
|
+
type="number"
|
|
127
|
+
invalid={errors.age}
|
|
128
|
+
{...register("age", { min: 18, max: 99 })}
|
|
129
|
+
/>
|
|
130
|
+
<input type="submit" />
|
|
131
|
+
</form>
|
|
132
|
+
`}
|
|
133
|
+
providerProps={{
|
|
134
|
+
renderAsComponent: true,
|
|
135
|
+
scope: {
|
|
136
|
+
InputField,
|
|
137
|
+
useForm,
|
|
138
|
+
},
|
|
139
|
+
}}
|
|
140
|
+
/>
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
export const SimpleInputExample = () => (
|
|
144
|
+
<Playground
|
|
145
|
+
code={`
|
|
146
|
+
const [state, setState] = useState({
|
|
147
|
+
firstName: '',
|
|
148
|
+
lastName: '',
|
|
149
|
+
age: 18
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const onChange = (change) => setState({
|
|
153
|
+
...state,
|
|
154
|
+
...change
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
<>
|
|
158
|
+
<InputText
|
|
159
|
+
label="First name"
|
|
160
|
+
value={state.firstName}
|
|
161
|
+
onChange={(firstName) => onChange({ firstName })}
|
|
162
|
+
/>
|
|
163
|
+
<InputText
|
|
164
|
+
label="Last name"
|
|
165
|
+
value={state.lastName}
|
|
166
|
+
onChange={(lastName) => onChange({ lastName })}
|
|
167
|
+
/>
|
|
168
|
+
<InputNumber
|
|
169
|
+
label="Age"
|
|
170
|
+
value={state.age}
|
|
171
|
+
onChange={(age) => onChange({ age })}
|
|
172
|
+
required
|
|
173
|
+
/>
|
|
174
|
+
</>
|
|
175
|
+
`}
|
|
176
|
+
providerProps={{
|
|
177
|
+
renderAsComponent: true,
|
|
178
|
+
scope: {
|
|
179
|
+
InputNumber,
|
|
180
|
+
InputText,
|
|
181
|
+
},
|
|
182
|
+
}}
|
|
183
|
+
/>
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
export const IconExample = () => (
|
|
187
|
+
<Playground
|
|
188
|
+
code={`
|
|
189
|
+
<InputField
|
|
190
|
+
label="Search"
|
|
191
|
+
type="text"
|
|
192
|
+
prefix="🍺"
|
|
193
|
+
>
|
|
194
|
+
<InputField.Icon>
|
|
195
|
+
<IconMinor.FolderOpen title="Icons render before the input" />
|
|
196
|
+
</InputField.Icon>
|
|
197
|
+
</InputField>
|
|
198
|
+
`}
|
|
199
|
+
providerProps={{
|
|
200
|
+
renderAsComponent: true,
|
|
201
|
+
scope: {
|
|
202
|
+
InputField,
|
|
203
|
+
IconMinor,
|
|
204
|
+
},
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
export const ControlsExample = () => (
|
|
210
|
+
<Playground
|
|
211
|
+
code={`
|
|
212
|
+
const [likes, setLikes] = useState(0);
|
|
213
|
+
|
|
214
|
+
const onLike = () => setLikes(likes + 1);
|
|
215
|
+
const onDislike = () => setLikes(Math.max(likes - 1, 0));
|
|
216
|
+
|
|
217
|
+
<InputField
|
|
218
|
+
label="Do you like this storybook?"
|
|
219
|
+
value={likes}
|
|
220
|
+
onChange={() => undefined}
|
|
221
|
+
type="number"
|
|
222
|
+
suffix="🍺"
|
|
223
|
+
>
|
|
224
|
+
<InputField.Controls>
|
|
225
|
+
<SpaceBetween>
|
|
226
|
+
<div onClick={onLike}>️👍</div>
|
|
227
|
+
<div>/</div>
|
|
228
|
+
<div onClick={onDislike}>👎️</div>
|
|
229
|
+
</SpaceBetween>
|
|
230
|
+
</InputField.Controls>
|
|
231
|
+
</InputField>
|
|
232
|
+
`}
|
|
233
|
+
providerProps={{
|
|
234
|
+
renderAsComponent: true,
|
|
235
|
+
scope: {
|
|
236
|
+
InputField,
|
|
237
|
+
IconMinor,
|
|
238
|
+
styled,
|
|
239
|
+
SpaceBetween,
|
|
240
|
+
},
|
|
241
|
+
}}
|
|
242
|
+
/>
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
export const OuterLabelExample = () => (
|
|
246
|
+
<Playground
|
|
247
|
+
code={`
|
|
248
|
+
const [value, setValue] = useState('');
|
|
249
|
+
const [errors, setErrors] = useState([]);
|
|
250
|
+
|
|
251
|
+
const handleChange = (change: string) => {
|
|
252
|
+
const errors = [];
|
|
253
|
+
|
|
254
|
+
if (!change) {
|
|
255
|
+
errors.push({ message: 'This field is required' });
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (!change.match(/[A-Za-z]{3}/)) {
|
|
259
|
+
errors.push({ message: 'Input was not a 3 letter country code' });
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
setValue(change);
|
|
263
|
+
setErrors(errors);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
<InputText.Label
|
|
267
|
+
label="Country Code"
|
|
268
|
+
helpText="Please enter a 3 letter country code"
|
|
269
|
+
errors={errors}
|
|
270
|
+
>
|
|
271
|
+
<InputText
|
|
272
|
+
value={value}
|
|
273
|
+
invalid={errors.length > 0}
|
|
274
|
+
placeholder="e.g. AUD"
|
|
275
|
+
onChange={handleChange}
|
|
276
|
+
/>
|
|
277
|
+
</InputText.Label>
|
|
278
|
+
`}
|
|
279
|
+
providerProps={{
|
|
280
|
+
renderAsComponent: true,
|
|
281
|
+
scope: {
|
|
282
|
+
InputText,
|
|
283
|
+
IconMinor,
|
|
284
|
+
},
|
|
285
|
+
}}
|
|
286
|
+
/>
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
export const StepperExample = () => (
|
|
290
|
+
<Playground
|
|
291
|
+
code={`
|
|
292
|
+
const [age, setAge] = useState(0);
|
|
293
|
+
const onUp = () => setAge(Math.min(age + 1, 99));
|
|
294
|
+
const onDown = () => setAge(Math.max(age - 1, 0));
|
|
295
|
+
const errors = []
|
|
296
|
+
|
|
297
|
+
if (0 > age || age > 100) {
|
|
298
|
+
errors.push({ message: 'Please choose an age between 0 and 99' })
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
<form onSubmit={(e) => e.preventDefault()}>
|
|
302
|
+
<InputNumber.Label
|
|
303
|
+
helpText='Age should be a number between 0 and 99'
|
|
304
|
+
errors={errors}
|
|
305
|
+
>
|
|
306
|
+
<InputNumber
|
|
307
|
+
label='Age'
|
|
308
|
+
onChange={setAge}
|
|
309
|
+
value={age}
|
|
310
|
+
invalid={errors.length > 0}
|
|
311
|
+
placeholder="Enter your age..."
|
|
312
|
+
>
|
|
313
|
+
<InputNumber.Controls>
|
|
314
|
+
<InputNumber.Stepper onUpClick={onUp} onDownClick={onDown} />
|
|
315
|
+
</InputNumber.Controls>
|
|
316
|
+
</InputNumber>
|
|
317
|
+
</InputNumber.Label>
|
|
318
|
+
<input type="submit"/>
|
|
319
|
+
</form>
|
|
320
|
+
`}
|
|
321
|
+
providerProps={{
|
|
322
|
+
renderAsComponent: true,
|
|
323
|
+
scope: {
|
|
324
|
+
InputNumber,
|
|
325
|
+
styled,
|
|
326
|
+
},
|
|
327
|
+
}}
|
|
328
|
+
/>
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
export const AllDressedExample = () => (
|
|
332
|
+
<Playground
|
|
333
|
+
code={`
|
|
334
|
+
<InputField.Label
|
|
335
|
+
label='Price'
|
|
336
|
+
helpText='Enter a price in AUD'
|
|
337
|
+
errors={[{ message: 'Too many UI decorations!' }]}
|
|
338
|
+
>
|
|
339
|
+
<InputField
|
|
340
|
+
type="number"
|
|
341
|
+
label='Price'
|
|
342
|
+
// prefix and suffix render immediately
|
|
343
|
+
// before and after the input field
|
|
344
|
+
prefix="$"
|
|
345
|
+
suffix="AUD"
|
|
346
|
+
step={0.01}
|
|
347
|
+
min={0.00}
|
|
348
|
+
placeholder="Enter an amount..."
|
|
349
|
+
>
|
|
350
|
+
<InputField.Icon>
|
|
351
|
+
<IconMinor.CircleDollar title="Icons render before the input" />
|
|
352
|
+
</InputField.Icon>
|
|
353
|
+
<InputField.Controls>
|
|
354
|
+
<IconMinor.FolderOpen title="Controls render after the input" />
|
|
355
|
+
</InputField.Controls>
|
|
356
|
+
</InputField>
|
|
357
|
+
</InputField.Label>
|
|
358
|
+
`}
|
|
359
|
+
providerProps={{
|
|
360
|
+
renderAsComponent: true,
|
|
361
|
+
scope: {
|
|
362
|
+
InputField,
|
|
363
|
+
IconMinor,
|
|
364
|
+
},
|
|
365
|
+
}}
|
|
366
|
+
/>
|
|
367
|
+
)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
|
+
import { Card, SpaceBetween } from '@components'
|
|
3
|
+
import { Playground } from 'storybook-addon-jarle-monaco'
|
|
4
|
+
import { InputField } from '../input-field'
|
|
5
|
+
import { PlainHTMLFormExample, ReactFormHookExample, SimpleInputExample, AllDressedExample, OuterLabelExample, IconExample, ControlsExample, StepperExample, InnerLabelExample, InnerLabelPositionExample } from './components'
|
|
6
|
+
|
|
7
|
+
<Meta title="Components/input-field"/>
|
|
8
|
+
|
|
9
|
+
# Input Field
|
|
10
|
+
|
|
11
|
+
An Input Field is a component that users can type into. It has a range of options and supports several text formats including numbers.
|
|
12
|
+
|
|
13
|
+
### Table of Contents
|
|
14
|
+
1. [Familiar HTML Input API](#familiar-html-input-api)
|
|
15
|
+
2. [Slots and sub-components](#slots-and-sub-components)
|
|
16
|
+
|
|
17
|
+
<div id='familiar-html-input-api'/>
|
|
18
|
+
|
|
19
|
+
## Familiar HTML input API
|
|
20
|
+
|
|
21
|
+
The input field is a drop-in replacement for the common HTML input element. It accepts all of the usual props for such an element. As you can see in the code sample below, you can simple use InputField the same way as you could a normal HTML input field. It has a few additional properties which can be used to style the component.
|
|
22
|
+
|
|
23
|
+
The available optional properties are as follows, try them out in the editable code sample below!
|
|
24
|
+
|
|
25
|
+
| Prop | Type | Description |
|
|
26
|
+
| --------------------| ----------------| ------------------------------------------------------------------------ |
|
|
27
|
+
| `prefix?` | `string` | add a small text before the input |
|
|
28
|
+
| `suffix?` | `string` | add a small text after the input |
|
|
29
|
+
| `label?` | `string` | a label to be displayed inside the input element, above the input itself |
|
|
30
|
+
| `labelPosition?` | `top` \| `side` | The position where the label should be rendered |
|
|
31
|
+
| `invalid?` | `boolean` | indicate that the input is invalid |
|
|
32
|
+
|
|
33
|
+
<PlainHTMLFormExample />
|
|
34
|
+
|
|
35
|
+
Notice that in this example (and only this example) we are using HTML's native "constraint validation API" to detect and display errors. Doing this involves watching the `onInvalid` event, and setting the invalid flag on the input if it fires.
|
|
36
|
+
|
|
37
|
+
### `props.label`
|
|
38
|
+
|
|
39
|
+
Passing a label will add a name inside the input field, above where the input will appear. This is a fancy new way people like to do inputs, and we might be adopting this style, so for now the examples will mostly all have inner labels.
|
|
40
|
+
|
|
41
|
+
<InnerLabelExample />
|
|
42
|
+
|
|
43
|
+
### `props.labelPosition`
|
|
44
|
+
|
|
45
|
+
Passing a labelPosition will change the position that the label should be displayed. Default value is `top`.
|
|
46
|
+
|
|
47
|
+
<InnerLabelPositionExample />
|
|
48
|
+
|
|
49
|
+
### Managing State
|
|
50
|
+
|
|
51
|
+
Because the input field can be used just like a regular HTML input, you can use common state-management libraries. For example, we used react-form-hook to implement the following code sample. Try it out!
|
|
52
|
+
|
|
53
|
+
<ReactFormHookExample />
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Simple Input API
|
|
57
|
+
|
|
58
|
+
The input-field module also exposes a set of components with more stream-lined APIs for implementing common UIs. These can be used instead of the base `InputField`` when you don't need all the bells and whistles of a raw HTML input, or when you aren't in the context of a form and just want to manage state with useState. The main motivation for providing these is to give the user a simple "string goes in, string comes out" API, so that they do not need to deal with HTML events.
|
|
59
|
+
|
|
60
|
+
These simple components obey the following API. In addition they have all the same optional properties described above:
|
|
61
|
+
|
|
62
|
+
| Prop | Type | Description |
|
|
63
|
+
| ----------- | --------------------- | --------------------------------------------------------------------------------- |
|
|
64
|
+
| `value` | `T` | The value of the controlled input |
|
|
65
|
+
| `onChange` | `(change: T) => void` | Called when the value changes |
|
|
66
|
+
| `required?` | `boolean` | Passed to the inner HTML element, renders an * (asterisk) next to the inner-label |
|
|
67
|
+
|
|
68
|
+
<SimpleInputExample />
|
|
69
|
+
|
|
70
|
+
<div id='slots-and-sub-components'/>
|
|
71
|
+
|
|
72
|
+
## Slots and sub-components
|
|
73
|
+
|
|
74
|
+
Using a combination of slots, sub-components, and the optional properties described above, it is possible to customize the components quite a bit. The available components include:
|
|
75
|
+
|
|
76
|
+
| Slot | Type | Description |
|
|
77
|
+
| --------------------- | ------- | ------------------------------------------------------------------------------------------------- |
|
|
78
|
+
| `InputField.Icon` | Slot | Places the children after the input, children should be icons |
|
|
79
|
+
| `InputField.Controls` | Slot | Places the children after the input, children should be small and interactive |
|
|
80
|
+
| `InputField.Label` | Wrapper | A wrapper for the input field that renders labels, help text, and error messages around the input |
|
|
81
|
+
|
|
82
|
+
### `InputField.Icon`
|
|
83
|
+
|
|
84
|
+
The `Icon` slot provides a convenient way to add a small icon (typically 20 x 20 pixel) to the right of the input, after the suffix and before the controls. In the examples below the icon is a folder, and the prefix is a 🍺.
|
|
85
|
+
|
|
86
|
+
<IconExample />
|
|
87
|
+
|
|
88
|
+
### `InputField.Controls`
|
|
89
|
+
|
|
90
|
+
The `Controls` slot is used to add a small icon or other component to the right side of the input, after the suffix. This is useful for adding steppers to number inputs, or a little grey X that clears the input when clicked. You can supply anything you like, but the intention is for this element to be clickable. In this example, the suffix is set to a 🍺 and notice that it is lined up with the input and prefix on the left-side, _not_ the controls on the right-side.
|
|
91
|
+
|
|
92
|
+
<ControlsExample />
|
|
93
|
+
|
|
94
|
+
### `InputField.Label`
|
|
95
|
+
|
|
96
|
+
The `Label` sub-component is used to wrap the `InputField` component. It provides the eponymous "label" for the wrapped input element, as an outer later. It is also used to provide additional label adjacent texts such as help text and error messages. Since we have begun to adopt an inner labelling system, this outer label will primarily be used to provide help text and errors. Since it is an HTML label element, you can click on any of these labels to focus the input.
|
|
97
|
+
|
|
98
|
+
The Label's API is given below.
|
|
99
|
+
|
|
100
|
+
| Prop | Type | Description |
|
|
101
|
+
| ----------- | ----------------------- | ---------------------------------------------------------------- |
|
|
102
|
+
| `label?` | `string` | The primary label, title, or "name" of the wrapped input element |
|
|
103
|
+
| `helpText?` | `string` | A string of help text to be displayed below the input |
|
|
104
|
+
| `errors?` | `{ message: string }[]` | An array of error messages to be displayed below the input. |
|
|
105
|
+
|
|
106
|
+
Also note that the example below uses `InputText.Label` rather than `InputField.Label`. All of the sub-components and slots available on the `InputField` are also available on the simple inputs, unless otherwise mentioned.
|
|
107
|
+
|
|
108
|
+
<OuterLabelExample />
|
|
109
|
+
|
|
110
|
+
### `InputNumber.Stepper`
|
|
111
|
+
|
|
112
|
+
Not mentioned in the general API above, but worthy of note, the stepper is such a common control for number inputs that we have provided it as a sub-component of the `InputNumber` simple input. It can be dropped into any input, not only the `InputNumber`, as you can see in the example below.
|
|
113
|
+
|
|
114
|
+
<StepperExample />
|
|
115
|
+
|
|
116
|
+
### All Dressed
|
|
117
|
+
|
|
118
|
+
Finally, just for fun, here is an example of an input with everything! Never actually do this, it's awful.
|
|
119
|
+
|
|
120
|
+
<AllDressedExample />
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import { is } from '@helpers'
|
|
3
|
+
|
|
4
|
+
export const Flex = styled.div<{ column?: boolean, center?: boolean }>`
|
|
5
|
+
display: flex;
|
|
6
|
+
${({ center }) => is(center) ? 'align-items: center;' : '' }
|
|
7
|
+
flex-direction: ${({ column }) => is(column) ? 'column' : 'row'}
|
|
8
|
+
`
|
|
9
|
+
|
|
10
|
+
export const SpaceBetween = styled(Flex)`
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
export const SpaceAround = styled(Flex)`
|
|
15
|
+
justify-content: space-around;
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
export const Center = styled(Flex)`
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: space-around;
|
|
21
|
+
`
|
|
22
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import { isDefined } from '@helpers'
|
|
3
|
+
|
|
4
|
+
interface IGridLayoutGeneratorProps {
|
|
5
|
+
columns?: number
|
|
6
|
+
rows?: number
|
|
7
|
+
columnGutter?: number
|
|
8
|
+
rowGutter?: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const DEFAULT: IGridLayoutGeneratorProps = {
|
|
12
|
+
columns: 12,
|
|
13
|
+
columnGutter: 24,
|
|
14
|
+
rowGutter: 24,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function gridLayoutGenerator (props: IGridLayoutGeneratorProps = {}) {
|
|
18
|
+
const options = {
|
|
19
|
+
...DEFAULT,
|
|
20
|
+
...props,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Grid = styled.div`
|
|
24
|
+
display: grid;
|
|
25
|
+
grid-template-columns: repeat(${options.columns}, 1fr);
|
|
26
|
+
${isDefined(options.rows)
|
|
27
|
+
? `grid-template-rows: repeat(${options.rows}, 1fr);`
|
|
28
|
+
: ''}
|
|
29
|
+
grid-column-gap: ${options.columnGutter}px;
|
|
30
|
+
grid-row-gap: ${options.rowGutter}px;
|
|
31
|
+
`
|
|
32
|
+
|
|
33
|
+
const Cell = styled.div`
|
|
34
|
+
`
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
Grid,
|
|
38
|
+
Cell,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Margin } from '@foundations'
|
|
2
|
+
import { FC, PropsWithChildren } from '@helpers'
|
|
3
|
+
import { Body, Heading3 } from 'components/typography'
|
|
4
|
+
import styled from 'styled-components'
|
|
5
|
+
|
|
6
|
+
interface ILeftRightLayoutGeneratorProps {
|
|
7
|
+
columns?: number
|
|
8
|
+
columnGutter?: number
|
|
9
|
+
rowGutter?: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const DEFAULT: ILeftRightLayoutGeneratorProps = {
|
|
13
|
+
columns: 12,
|
|
14
|
+
columnGutter: 24,
|
|
15
|
+
rowGutter: 0,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function leftRightLayoutGenerator (layoutProps: ILeftRightLayoutGeneratorProps = {}) {
|
|
19
|
+
const options = {
|
|
20
|
+
...DEFAULT,
|
|
21
|
+
...layoutProps,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const LayoutFrame = styled.div`
|
|
25
|
+
display: grid;
|
|
26
|
+
grid-template-columns: repeat(${options.columns}, 1fr);
|
|
27
|
+
grid-column-gap: ${options.columnGutter}px;
|
|
28
|
+
grid-row-gap: ${options.rowGutter}px;
|
|
29
|
+
`
|
|
30
|
+
|
|
31
|
+
const Left = styled.div`
|
|
32
|
+
grid-column: 1 / span 4;
|
|
33
|
+
grid-row: third-line / 4;
|
|
34
|
+
`
|
|
35
|
+
|
|
36
|
+
const Right = styled.div`
|
|
37
|
+
grid-column: 5 / span 8;
|
|
38
|
+
grid-row: third-line / 4;
|
|
39
|
+
`
|
|
40
|
+
|
|
41
|
+
const Slots = {
|
|
42
|
+
Left,
|
|
43
|
+
Right,
|
|
44
|
+
HeadingText: styled(Heading3)`
|
|
45
|
+
margin-bottom: ${Margin.m};
|
|
46
|
+
`,
|
|
47
|
+
HelpText: styled(Body).attrs({ subdued: true })``,
|
|
48
|
+
BodyText: Body,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const Layout: FC<PropsWithChildren, typeof Slots> = (props) => {
|
|
52
|
+
return <LayoutFrame>{props.children}</LayoutFrame>
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
Layout.Left = Left
|
|
56
|
+
Layout.Right = Right
|
|
57
|
+
Layout.HeadingText = Slots.HeadingText
|
|
58
|
+
Layout.BodyText = Slots.BodyText
|
|
59
|
+
Layout.HelpText = Slots.HelpText
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
LeftRightLayout: Layout,
|
|
63
|
+
Layout,
|
|
64
|
+
Left,
|
|
65
|
+
Right,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './link'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import { Link } from '.'
|
|
3
|
+
import { Interactive } from '@foundations'
|
|
4
|
+
|
|
5
|
+
describe('Link', () => {
|
|
6
|
+
it('should render the component Link with default color', async () => {
|
|
7
|
+
render(
|
|
8
|
+
<Link label="Edvisor" aria-label="red" href="https://app.edvisor.io/" />
|
|
9
|
+
)
|
|
10
|
+
expect(screen.getByRole('link')).toBeInTheDocument()
|
|
11
|
+
expect(screen.getByText('Edvisor')).toBeInTheDocument()
|
|
12
|
+
expect(screen.getByRole('link')).toHaveStyle(`color: ${Interactive.Default.Default}`)
|
|
13
|
+
})
|
|
14
|
+
it('should render the component Link with subtle color', async () => {
|
|
15
|
+
render(<Link href="https://app.edvisor.io/" label="Edvisor" subtle />)
|
|
16
|
+
expect(screen.getByRole('link')).toBeInTheDocument()
|
|
17
|
+
expect(screen.getByText('Edvisor')).toBeInTheDocument()
|
|
18
|
+
expect(screen.getByRole('link')).toHaveStyle(`color: ${Interactive.Subtle.Default}`)
|
|
19
|
+
})
|
|
20
|
+
it('should render the component Link with disabled color even if it has default or subtle attributes color', async () => {
|
|
21
|
+
render(
|
|
22
|
+
<Link subtle disabled label="Edvisor" href="https://app.edvisor.io/" />
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
expect(screen.getByRole('link')).toBeInTheDocument()
|
|
26
|
+
expect(screen.getByText('Edvisor')).toBeInTheDocument()
|
|
27
|
+
expect(screen.getByRole('link')).toHaveStyle(`color: ${Interactive.Default.Disabled}`)
|
|
28
|
+
})
|
|
29
|
+
})
|