@agility/plenum-ui 1.3.50 → 2.0.0-rc10
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 +6 -0
- package/.prettierrc +12 -12
- package/.storybook/Layout.jsx +9 -6
- package/.storybook/head.tsx +4 -0
- package/.storybook/main.ts +18 -0
- package/.storybook/manager-head.html +1 -0
- package/.storybook/manager.ts +25 -0
- package/.storybook/plenumTheme.ts +8 -0
- package/.storybook/preview-head.html +4 -0
- package/.storybook/preview.tsx +28 -0
- package/.vscode/settings.json +4 -0
- package/.yarnrc.yml +1 -0
- package/README.md +165 -53
- package/app/globals.css +99 -0
- package/app/head.tsx +59 -0
- package/app/layout.tsx +28 -0
- package/app/page.tsx +7 -0
- package/build.js +41 -0
- package/dist/index.d.ts +1117 -0
- package/dist/index.js +6296 -0
- package/dist/index.js.map +7 -0
- package/dist/lib/tailwind.css +63535 -0
- package/{lib/components → dist/types/stories/atoms}/Avatar/Avatar.d.ts +28 -27
- package/dist/types/stories/atoms/Avatar/index.d.ts +3 -0
- package/dist/types/stories/atoms/badges/Badge.d.ts +21 -0
- package/dist/types/stories/atoms/badges/index.d.ts +3 -0
- package/dist/types/stories/atoms/buttons/Button/Alternative/Alternative.stories.d.ts +14 -0
- package/dist/types/stories/atoms/buttons/Button/Button.d.ts +35 -0
- package/dist/types/stories/atoms/buttons/Button/Danger/Danger.stories.d.ts +14 -0
- package/dist/types/stories/atoms/buttons/Button/Primary/Primary.stories.d.ts +14 -0
- package/dist/types/stories/atoms/buttons/Button/Secondary/Secondary.stories.d.ts +14 -0
- package/dist/types/stories/atoms/buttons/Button/defaultArgs.d.ts +3 -0
- package/dist/types/stories/atoms/buttons/Button/index.d.ts +3 -0
- package/dist/types/stories/atoms/buttons/Capsule/Alternative/Alternative.stories.d.ts +6 -0
- package/dist/types/stories/atoms/buttons/Capsule/Capsule.d.ts +27 -0
- package/dist/types/stories/atoms/buttons/Capsule/Danger/Danger.stories.d.ts +6 -0
- package/dist/types/stories/atoms/buttons/Capsule/Primary/Primary.stories.d.ts +6 -0
- package/dist/types/stories/atoms/buttons/Capsule/Secondary/Secondary.stories.d.ts +6 -0
- package/dist/types/stories/atoms/buttons/Capsule/index.d.ts +3 -0
- package/dist/types/stories/atoms/buttons/index.d.ts +4 -0
- package/{lib/components/DynamicIcons/DynamicIcons.d.ts → dist/types/stories/atoms/icons/DynamicIcon.d.ts} +20 -18
- package/dist/types/stories/atoms/icons/DynamicIcon.stories.d.ts +10 -0
- package/dist/types/stories/atoms/icons/IconWithShadow.d.ts +6 -0
- package/dist/types/stories/atoms/icons/IconWithShadow.stories.d.ts +10 -0
- package/{lib/components/DynamicIcons → dist/types/stories/atoms/icons}/TablerIcon.d.ts +9 -9
- package/dist/types/stories/atoms/icons/index.d.ts +4 -0
- package/dist/types/stories/atoms/icons/tablerIconNames.d.ts +2 -0
- package/dist/types/stories/atoms/index.d.ts +7 -0
- package/dist/types/stories/atoms/loaders/Loader.d.ts +6 -0
- package/dist/types/stories/atoms/loaders/Loader.stories.d.ts +6 -0
- package/dist/types/stories/atoms/loaders/NProgress/RadialProgress.d.ts +11 -0
- package/dist/types/stories/atoms/loaders/NProgress/index.d.ts +3 -0
- package/dist/types/stories/atoms/loaders/index.d.ts +4 -0
- package/dist/types/stories/index.d.ts +5 -0
- package/dist/types/stories/layouts/index.d.ts +0 -0
- package/dist/types/stories/molecules/index.d.ts +3 -0
- package/{lib/components/Forms → dist/types/stories/molecules/inputs}/InputCounter/InputCounter.d.ts +10 -9
- package/dist/types/stories/molecules/inputs/InputCounter/index.d.ts +2 -0
- package/dist/types/stories/molecules/inputs/InputField/InputField.d.ts +30 -0
- package/dist/types/stories/molecules/inputs/InputField/index.d.ts +3 -0
- package/{lib/components/Forms → dist/types/stories/molecules/inputs}/InputLabel/InputLabel.d.ts +15 -14
- package/dist/types/stories/molecules/inputs/InputLabel/index.d.ts +3 -0
- package/dist/types/stories/molecules/inputs/NestedInputButton/NestedInputButton.d.ts +17 -0
- package/dist/types/stories/molecules/inputs/NestedInputButton/index.d.ts +3 -0
- package/{lib/components/Forms → dist/types/stories/molecules/inputs}/TextInput/TextInput.d.ts +39 -39
- package/dist/types/stories/molecules/inputs/TextInput/index.d.ts +4 -0
- package/{lib/components/Forms/Checkbox → dist/types/stories/molecules/inputs/checkbox}/Checkbox.d.ts +28 -27
- package/dist/types/stories/molecules/inputs/checkbox/Checkbox.stories.d.ts +6 -0
- package/dist/types/stories/molecules/inputs/checkbox/index.d.ts +3 -0
- package/{lib/components/Combobox/Combobox.d.ts → dist/types/stories/molecules/inputs/combobox/ComboBox.d.ts} +34 -34
- package/dist/types/stories/molecules/inputs/combobox/ComboBox.stories.d.ts +6 -0
- package/dist/types/stories/molecules/inputs/combobox/index.d.ts +3 -0
- package/dist/types/stories/molecules/inputs/index.d.ts +12 -0
- package/{lib/components/Forms/Radio → dist/types/stories/molecules/inputs/radio}/Radio.d.ts +27 -27
- package/dist/types/stories/molecules/inputs/radio/Radio.stories.d.ts +6 -0
- package/dist/types/stories/molecules/inputs/radio/index.d.ts +3 -0
- package/{lib/components/Forms/Select → dist/types/stories/molecules/inputs/select}/Select.d.ts +27 -27
- package/dist/types/stories/molecules/inputs/select/Select.stories.d.ts +6 -0
- package/dist/types/stories/molecules/inputs/select/index.d.ts +3 -0
- package/{lib/components/Forms/Textarea/Textarea.d.ts → dist/types/stories/molecules/inputs/textArea/TextArea.d.ts} +35 -32
- package/dist/types/stories/molecules/inputs/textArea/TextArea.stories.d.ts +6 -0
- package/dist/types/stories/molecules/inputs/textArea/index.d.ts +3 -0
- package/dist/types/stories/molecules/inputs/toggleSwitch/ToggleSwitch.d.ts +18 -0
- package/dist/types/stories/molecules/inputs/toggleSwitch/index.d.ts +3 -0
- package/dist/types/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.d.ts +18 -0
- package/dist/types/stories/organisms/AnimatedLabelInput/index.d.ts +3 -0
- package/dist/types/stories/organisms/ButtonDropdown/ButtonDropdown.d.ts +14 -0
- package/dist/types/stories/organisms/ButtonDropdown/index.d.ts +3 -0
- package/{lib/components/Dropdown/Dropdown.d.ts → dist/types/stories/organisms/DropdownComponent/DropdownComponent.d.ts} +36 -39
- package/dist/types/stories/organisms/DropdownComponent/dropdownItems.d.ts +3 -0
- package/dist/types/stories/organisms/DropdownComponent/index.d.ts +4 -0
- package/dist/types/stories/organisms/EmptySectionPlaceholder/EmptySectionPlaceholder.d.ts +19 -0
- package/dist/types/stories/organisms/EmptySectionPlaceholder/index.d.ts +3 -0
- package/dist/types/stories/organisms/FormInputWithAddons/FormInputWithAddons.d.ts +21 -0
- package/dist/types/stories/organisms/FormInputWithAddons/index.d.ts +3 -0
- package/{lib/components/Forms/TextInputSelect/InputSelect → dist/types/stories/organisms/TextInputSelect}/InputSelect.d.ts +16 -13
- package/{lib/components/Forms → dist/types/stories/organisms}/TextInputSelect/TextInputSelect.d.ts +48 -48
- package/dist/types/stories/organisms/TextInputSelect/index.d.ts +3 -0
- package/dist/types/stories/organisms/index.d.ts +8 -0
- package/dist/types/utils/types.d.ts +2 -0
- package/dist/types/utils/useId.d.ts +1 -0
- package/next.config.js +8 -0
- package/package.json +55 -78
- package/pages/api/hello.ts +13 -0
- package/postcss.config.js +5 -6
- package/public/next.svg +1 -0
- package/public/thirteen.svg +1 -0
- package/public/vercel.svg +1 -0
- package/scripts/create-component.js +97 -0
- package/stories/Introduction.mdx +314 -0
- package/stories/assets/code-brackets.svg +1 -0
- package/stories/assets/colors.svg +1 -0
- package/stories/assets/comments.svg +1 -0
- package/stories/assets/direction.svg +1 -0
- package/stories/assets/flow.svg +1 -0
- package/stories/assets/plugin.svg +1 -0
- package/stories/assets/repo.svg +1 -0
- package/stories/assets/stackalt.svg +1 -0
- package/stories/atoms/Avatar/Avatar.stories.tsx +96 -0
- package/stories/atoms/Avatar/Avatar.tsx +123 -0
- package/stories/atoms/Avatar/index.ts +3 -0
- package/stories/atoms/badges/Badge.tsx +127 -0
- package/stories/atoms/badges/Pill/Pill.stories.tsx +75 -0
- package/stories/atoms/badges/Rounded/Rounded.stories.tsx +75 -0
- package/stories/atoms/badges/index.ts +3 -0
- package/stories/atoms/buttons/Button/Alternative/Alternative.stories.ts +76 -0
- package/stories/atoms/buttons/Button/Button.tsx +146 -0
- package/stories/atoms/buttons/Button/Danger/Danger.stories.ts +78 -0
- package/stories/atoms/buttons/Button/Primary/Primary.stories.ts +85 -0
- package/stories/atoms/buttons/Button/Secondary/Secondary.stories.ts +81 -0
- package/stories/atoms/buttons/Button/defaultArgs.ts +9 -0
- package/stories/atoms/buttons/Button/index.ts +3 -0
- package/stories/atoms/buttons/Capsule/Alternative/Alternative.stories.ts +27 -0
- package/stories/atoms/buttons/Capsule/Capsule.tsx +87 -0
- package/stories/atoms/buttons/Capsule/Danger/Danger.stories.ts +27 -0
- package/stories/atoms/buttons/Capsule/Primary/Primary.stories.ts +27 -0
- package/stories/atoms/buttons/Capsule/Secondary/Secondary.stories.ts +27 -0
- package/stories/atoms/buttons/Capsule/index.ts +3 -0
- package/stories/atoms/buttons/FloatingActionButton/FloatingActionButton.stories.tsx +15 -0
- package/stories/atoms/buttons/FloatingActionButton/FloatingActionButton.tsx +22 -0
- package/stories/atoms/buttons/FloatingActionButton/index.tsx +3 -0
- package/stories/atoms/buttons/index.ts +4 -0
- package/stories/atoms/crumb/Crumb.stories.tsx +18 -0
- package/stories/atoms/crumb/Crumb.tsx +22 -0
- package/stories/atoms/crumb/index.tsx +3 -0
- package/stories/atoms/icons/DynamicIcon.stories.ts +43 -0
- package/stories/atoms/icons/DynamicIcon.tsx +90 -0
- package/stories/atoms/icons/IconWithShadow.stories.ts +43 -0
- package/stories/atoms/icons/IconWithShadow.tsx +16 -0
- package/stories/atoms/icons/TablerIcon.tsx +22 -0
- package/stories/atoms/icons/index.tsx +14 -0
- package/stories/atoms/icons/tablerIconNames.ts +4336 -0
- package/stories/atoms/index.ts +46 -0
- package/stories/atoms/loaders/Loader.stories.ts +15 -0
- package/stories/atoms/loaders/Loader.tsx +15 -0
- package/stories/atoms/loaders/NProgress/RadialProgress.stories.tsx +19 -0
- package/stories/atoms/loaders/NProgress/RadialProgress.tsx +76 -0
- package/stories/atoms/loaders/NProgress/index.ts +3 -0
- package/stories/atoms/loaders/index.ts +4 -0
- package/stories/index.ts +134 -0
- package/stories/layouts/CardLayout/CardLayout.stories.tsx +18 -0
- package/stories/layouts/CardLayout/CardLayout.tsx +22 -0
- package/stories/layouts/CardLayout/index.tsx +3 -0
- package/stories/layouts/ModalLayout/ModalLayout.stories.tsx +18 -0
- package/stories/layouts/ModalLayout/ModalLayout.tsx +22 -0
- package/stories/layouts/ModalLayout/index.tsx +3 -0
- package/stories/layouts/index.ts +0 -0
- package/stories/molecules/index.ts +51 -0
- package/stories/molecules/inputs/InputCounter/InputCounter.stories.tsx +18 -0
- package/stories/molecules/inputs/InputCounter/InputCounter.tsx +24 -0
- package/stories/molecules/inputs/InputCounter/index.tsx +3 -0
- package/stories/molecules/inputs/InputField/InputField.stories.tsx +29 -0
- package/stories/molecules/inputs/InputField/InputField.tsx +94 -0
- package/stories/molecules/inputs/InputField/index.tsx +3 -0
- package/stories/molecules/inputs/InputLabel/InputLabel.stories.tsx +19 -0
- package/stories/molecules/inputs/InputLabel/InputLabel.tsx +45 -0
- package/stories/molecules/inputs/InputLabel/index.tsx +3 -0
- package/stories/molecules/inputs/NestedInputButton/NestedInputButton.stories.tsx +52 -0
- package/stories/molecules/inputs/NestedInputButton/NestedInputButton.tsx +64 -0
- package/stories/molecules/inputs/NestedInputButton/index.tsx +3 -0
- package/stories/molecules/inputs/TextInput/TextInput.stories.tsx +32 -0
- package/stories/molecules/inputs/TextInput/TextInput.tsx +162 -0
- package/stories/molecules/inputs/TextInput/index.tsx +5 -0
- package/stories/molecules/inputs/checkbox/Checkbox.stories.ts +23 -0
- package/stories/molecules/inputs/checkbox/Checkbox.tsx +99 -0
- package/stories/molecules/inputs/checkbox/index.ts +3 -0
- package/stories/molecules/inputs/combobox/ComboBox.stories.ts +41 -0
- package/stories/molecules/inputs/combobox/ComboBox.tsx +194 -0
- package/stories/molecules/inputs/combobox/index.ts +3 -0
- package/stories/molecules/inputs/index.ts +38 -0
- package/stories/molecules/inputs/radio/Radio.stories.ts +27 -0
- package/stories/molecules/inputs/radio/Radio.tsx +92 -0
- package/stories/molecules/inputs/radio/index.ts +3 -0
- package/stories/molecules/inputs/select/Select.stories.ts +23 -0
- package/stories/molecules/inputs/select/Select.tsx +100 -0
- package/stories/molecules/inputs/select/index.ts +3 -0
- package/stories/molecules/inputs/textArea/TextArea.stories.ts +22 -0
- package/stories/molecules/inputs/textArea/TextArea.tsx +128 -0
- package/stories/molecules/inputs/textArea/index.ts +3 -0
- package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.stories.tsx +119 -0
- package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.tsx +75 -0
- package/stories/molecules/inputs/toggleSwitch/index.ts +3 -0
- package/stories/molecules/tabs/Tabs.stories.tsx +18 -0
- package/stories/molecules/tabs/Tabs.tsx +22 -0
- package/stories/molecules/tabs/index.tsx +3 -0
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.stories.tsx +21 -0
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.tsx +60 -0
- package/stories/organisms/AnimatedLabelInput/index.tsx +3 -0
- package/stories/organisms/ButtonDropdown/ButtonDropdown.stories.tsx +118 -0
- package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +81 -0
- package/stories/organisms/ButtonDropdown/index.tsx +3 -0
- package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +49 -0
- package/stories/organisms/DropdownComponent/Dropdown.test.tsx +0 -0
- package/stories/organisms/DropdownComponent/DropdownComponent.tsx +300 -0
- package/stories/organisms/DropdownComponent/dropdownItems.ts +101 -0
- package/stories/organisms/DropdownComponent/index.ts +4 -0
- package/stories/organisms/EmptySectionPlaceholder/EmptySectionPlaceholder.stories.tsx +76 -0
- package/stories/organisms/EmptySectionPlaceholder/EmptySectionPlaceholder.tsx +52 -0
- package/stories/organisms/EmptySectionPlaceholder/index.tsx +3 -0
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.stories.tsx +29 -0
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.tsx +140 -0
- package/stories/organisms/FormInputWithAddons/index.tsx +3 -0
- package/stories/organisms/TextInputSelect/InputSelect.tsx +59 -0
- package/stories/organisms/TextInputSelect/TextInputSelect.stories.tsx +33 -0
- package/stories/organisms/TextInputSelect/TextInputSelect.tsx +186 -0
- package/stories/organisms/TextInputSelect/index.tsx +3 -0
- package/stories/organisms/index.ts +18 -0
- package/tailwind.config.js +165 -36
- package/tsconfig.json +27 -21
- package/tsconfig.lib.json +19 -0
- package/utils/types.d.ts +2 -0
- package/utils/types.ts +3 -0
- package/utils/useId.d.ts +1 -0
- package/utils/useId.tsx +16 -0
- package/.babelrc +0 -14
- package/.editorconfig +0 -9
- package/.eslintrc +0 -13
- package/.github/workflows/test.yml +0 -27
- package/.storybook/main.js +0 -17
- package/.storybook/manager.js +0 -6
- package/.storybook/plenumTheme.js +0 -8
- package/.storybook/preview.js +0 -44
- package/_templates/component/new/component.ejs.t +0 -18
- package/_templates/component/new/component.stories.ejs.t +0 -21
- package/_templates/component/new/component.test.ejs.t +0 -15
- package/_templates/component/new/index.ejs.t +0 -6
- package/_templates/component/new/prompt.js +0 -7
- package/jest.config.js +0 -8
- package/lib/common/brandCfg.d.ts +0 -3
- package/lib/common/index.d.ts +0 -3
- package/lib/common/storyCfg.d.ts +0 -5
- package/lib/components/Avatar/Avatar.stories.d.ts +0 -6
- package/lib/components/Avatar/Avatar.test.d.ts +0 -1
- package/lib/components/Avatar/index.d.ts +0 -1
- package/lib/components/Button/Button.d.ts +0 -55
- package/lib/components/Button/Button.stories.d.ts +0 -12
- package/lib/components/Button/Button.test.d.ts +0 -1
- package/lib/components/Button/index.d.ts +0 -1
- package/lib/components/ButtonDropdown/ButtonDropdown.d.ts +0 -12
- package/lib/components/ButtonDropdown/ButtonDropdown.stories.d.ts +0 -9
- package/lib/components/ButtonDropdown/index.d.ts +0 -1
- package/lib/components/Combobox/Combobox.stories.d.ts +0 -14
- package/lib/components/Combobox/Combobox.test.d.ts +0 -1
- package/lib/components/Combobox/index.d.ts +0 -1
- package/lib/components/Dropdown/Dropdown.stories.d.ts +0 -8
- package/lib/components/Dropdown/Dropdown.test.d.ts +0 -1
- package/lib/components/Dropdown/data.d.ts +0 -3
- package/lib/components/Dropdown/index.d.ts +0 -1
- package/lib/components/DynamicIcons/DynamicIcons.stories.d.ts +0 -9
- package/lib/components/DynamicIcons/index.d.ts +0 -3
- package/lib/components/DynamicIcons/tablerIconNames.d.ts +0 -2
- package/lib/components/Forms/BaseField/BaseField.d.ts +0 -34
- package/lib/components/Forms/BaseField/BaseField.stories.d.ts +0 -6
- package/lib/components/Forms/BaseField/BaseField.test.d.ts +0 -1
- package/lib/components/Forms/BaseField/index.d.ts +0 -1
- package/lib/components/Forms/Checkbox/Checkbox.stories.d.ts +0 -14
- package/lib/components/Forms/Checkbox/Checkbox.test.d.ts +0 -1
- package/lib/components/Forms/Checkbox/index.d.ts +0 -1
- package/lib/components/Forms/InputCounter/InputCounter.stories.d.ts +0 -6
- package/lib/components/Forms/InputCounter/InputCounter.test.d.ts +0 -1
- package/lib/components/Forms/InputCounter/index.d.ts +0 -1
- package/lib/components/Forms/InputLabel/InputLabel.stories.d.ts +0 -6
- package/lib/components/Forms/InputLabel/InputLabel.test.d.ts +0 -1
- package/lib/components/Forms/InputLabel/index.d.ts +0 -1
- package/lib/components/Forms/Radio/Radio.stories.d.ts +0 -12
- package/lib/components/Forms/Radio/Radio.test.d.ts +0 -1
- package/lib/components/Forms/Radio/index.d.ts +0 -1
- package/lib/components/Forms/Select/Select.stories.d.ts +0 -11
- package/lib/components/Forms/Select/Select.test.d.ts +0 -1
- package/lib/components/Forms/Select/index.d.ts +0 -1
- package/lib/components/Forms/TextInput/TextInput.stories.d.ts +0 -12
- package/lib/components/Forms/TextInput/index.d.ts +0 -1
- package/lib/components/Forms/TextInputAddon/InputCta/InputCta.d.ts +0 -16
- package/lib/components/Forms/TextInputAddon/InputCta/InputCta.stories.d.ts +0 -6
- package/lib/components/Forms/TextInputAddon/InputCta/InputCta.test.d.ts +0 -1
- package/lib/components/Forms/TextInputAddon/InputCta/index.d.ts +0 -1
- package/lib/components/Forms/TextInputAddon/TextInputAddon.d.ts +0 -54
- package/lib/components/Forms/TextInputAddon/TextInputAddon.stories.d.ts +0 -13
- package/lib/components/Forms/TextInputAddon/index.d.ts +0 -1
- package/lib/components/Forms/TextInputSelect/InputSelect/InputSelect.stories.d.ts +0 -6
- package/lib/components/Forms/TextInputSelect/InputSelect/InputSelect.test.d.ts +0 -1
- package/lib/components/Forms/TextInputSelect/InputSelect/index.d.ts +0 -1
- package/lib/components/Forms/TextInputSelect/TextInputSelect.stories.d.ts +0 -8
- package/lib/components/Forms/TextInputSelect/index.d.ts +0 -1
- package/lib/components/Forms/Textarea/Textarea.stories.d.ts +0 -12
- package/lib/components/Forms/Textarea/Textarea.test.d.ts +0 -1
- package/lib/components/Forms/Textarea/index.d.ts +0 -1
- package/lib/components/ToggleSwitch/ToggleSwitch.d.ts +0 -28
- package/lib/components/ToggleSwitch/ToggleSwitch.stories.d.ts +0 -21
- package/lib/components/ToggleSwitch/ToggleSwitch.test.d.ts +0 -1
- package/lib/components/ToggleSwitch/index.d.ts +0 -1
- package/lib/components/TreeView/TreeView.d.ts +0 -36
- package/lib/components/TreeView/TreeView.stories.d.ts +0 -6
- package/lib/components/TreeView/TreeView.test.d.ts +0 -1
- package/lib/components/TreeView/index.d.ts +0 -1
- package/lib/components/TreeView V1/TreeItem/TreeItem.d.ts +0 -16
- package/lib/components/TreeView V1/TreeItem/TreeItem.stories.d.ts +0 -9
- package/lib/components/TreeView V1/TreeItem/TreeItem.test.d.ts +0 -1
- package/lib/components/TreeView V1/TreeItem/index.d.ts +0 -1
- package/lib/components/TreeView V1/TreeView.d.ts +0 -6
- package/lib/components/TreeView V1/TreeView.stories.d.ts +0 -6
- package/lib/components/TreeView V1/TreeView.test.d.ts +0 -1
- package/lib/components/TreeView V1/context.d.ts +0 -9
- package/lib/components/TreeView V1/index.d.ts +0 -1
- package/lib/components/TreeView V1/sampleData.d.ts +0 -71
- package/lib/components/TreeView V1/types/tree.types.d.ts +0 -21
- package/lib/index.d.ts +0 -13
- package/lib/index.esm.js +0 -105883
- package/lib/index.esm.js.map +0 -1
- package/lib/index.js +0 -105922
- package/lib/index.js.map +0 -1
- package/lib/page/TreeNavigation/CustomNode/CustomNode.d.ts +0 -3
- package/lib/page/TreeNavigation/CustomNode/CustomNode.test.d.ts +0 -1
- package/lib/page/TreeNavigation/CustomNode/index.d.ts +0 -1
- package/lib/page/TreeNavigation/TreeNavigation.d.ts +0 -8
- package/lib/page/TreeNavigation/TreeNavigation.stories.d.ts +0 -6
- package/lib/page/TreeNavigation/hooks/useFetch.d.ts +0 -14
- package/lib/page/TreeNavigation/index.d.ts +0 -1
- package/lib/tailwind.css +0 -2023
- package/lib/util/DynamicIcons.d.ts +0 -10
- package/lib/util/Loader.d.ts +0 -5
- package/lib/util/types.d.ts +0 -2
- package/lib/util/useID.d.ts +0 -1
- package/rollup.config.js +0 -37
- package/setupTests.js +0 -6
- package/styleMock.js +0 -2
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react"
|
|
2
|
+
import { default as cn } from "classnames"
|
|
3
|
+
import { Combobox as HeadlessUICombobox } from "@headlessui/react"
|
|
4
|
+
import InputLabel from "@/stories/molecules/inputs/InputLabel"
|
|
5
|
+
import { DynamicIcon } from "@/stories/atoms/icons"
|
|
6
|
+
|
|
7
|
+
export interface IComboboxProps<T extends Record<string, unknown>> {
|
|
8
|
+
/** Label */
|
|
9
|
+
label?: string
|
|
10
|
+
/** ID */
|
|
11
|
+
id: string
|
|
12
|
+
/** Array of items to display */
|
|
13
|
+
items: T[]
|
|
14
|
+
/** the item property to use as the key */
|
|
15
|
+
keyProperty: string
|
|
16
|
+
|
|
17
|
+
/** the item property to use as the display */
|
|
18
|
+
displayProperty: string
|
|
19
|
+
/** Placeholder */
|
|
20
|
+
placeholder?: string
|
|
21
|
+
/** Callback to trigger on change */
|
|
22
|
+
onChange?(value: T | undefined): void
|
|
23
|
+
/** Select disabled state */
|
|
24
|
+
isDisabled?: boolean
|
|
25
|
+
/** Select error state */
|
|
26
|
+
isError?: boolean
|
|
27
|
+
/** Select required state */
|
|
28
|
+
isRequired?: boolean
|
|
29
|
+
/** Message shown under field */
|
|
30
|
+
message?: string
|
|
31
|
+
|
|
32
|
+
displayValue?: string
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Whether this item is nullable or not.
|
|
36
|
+
*
|
|
37
|
+
* @type {boolean}
|
|
38
|
+
* @memberof ComboboxProps
|
|
39
|
+
*/
|
|
40
|
+
nullable?: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function classNames(...classes: string[]) {
|
|
44
|
+
return classes.filter(Boolean).join(" ")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const Combobox = <T extends Record<string, unknown>>({
|
|
48
|
+
label,
|
|
49
|
+
items,
|
|
50
|
+
displayProperty,
|
|
51
|
+
displayValue,
|
|
52
|
+
keyProperty,
|
|
53
|
+
onChange,
|
|
54
|
+
placeholder,
|
|
55
|
+
message,
|
|
56
|
+
isDisabled,
|
|
57
|
+
isError,
|
|
58
|
+
isRequired,
|
|
59
|
+
id,
|
|
60
|
+
nullable
|
|
61
|
+
}: IComboboxProps<T>) => {
|
|
62
|
+
const [query, setQuery] = useState<string>("")
|
|
63
|
+
const [selectedItem, setSelectedItem] = useState<T | undefined>()
|
|
64
|
+
|
|
65
|
+
const onChangeValue = (value: T | undefined) => {
|
|
66
|
+
if (value && selectedItem && value[keyProperty] === selectedItem[keyProperty]) {
|
|
67
|
+
setSelectedItem(undefined)
|
|
68
|
+
} else {
|
|
69
|
+
setSelectedItem(value)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (displayValue) {
|
|
75
|
+
const dv = items.find((i) => i[displayProperty] === displayValue)
|
|
76
|
+
setSelectedItem(dv)
|
|
77
|
+
}
|
|
78
|
+
}, [displayValue])
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
typeof onChange === "function" && onChange(selectedItem)
|
|
82
|
+
}, [selectedItem])
|
|
83
|
+
|
|
84
|
+
const filteredItems =
|
|
85
|
+
query === ""
|
|
86
|
+
? items
|
|
87
|
+
: items.filter((item) => {
|
|
88
|
+
return `${item[displayProperty]}`.toLowerCase().includes(query.toLowerCase())
|
|
89
|
+
})
|
|
90
|
+
const labelStyles = cn("block text-sm font-medium text-gray-700")
|
|
91
|
+
const buttonStyles = cn("absolute inset-y-0 right-0 flex items-center rounded-r px-2 focus:outline-none")
|
|
92
|
+
const optionStyles = cn(
|
|
93
|
+
"absolute z-30 mt-1 max-h-60 w-full overflow-auto rounded bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
|
|
94
|
+
)
|
|
95
|
+
return (
|
|
96
|
+
<HeadlessUICombobox
|
|
97
|
+
as="div"
|
|
98
|
+
value={selectedItem}
|
|
99
|
+
onChange={(e: T | undefined) => onChangeValue(e)}
|
|
100
|
+
disabled={isDisabled}
|
|
101
|
+
nullable={nullable ? undefined : false}
|
|
102
|
+
>
|
|
103
|
+
{label && (
|
|
104
|
+
<HeadlessUICombobox.Label className={labelStyles}>
|
|
105
|
+
<InputLabel
|
|
106
|
+
isPlaceholder
|
|
107
|
+
isActive
|
|
108
|
+
label={label}
|
|
109
|
+
isRequired={isRequired}
|
|
110
|
+
id={id}
|
|
111
|
+
isError={isError}
|
|
112
|
+
isDisabled={isDisabled}
|
|
113
|
+
/>
|
|
114
|
+
</HeadlessUICombobox.Label>
|
|
115
|
+
)}
|
|
116
|
+
<div className="relative">
|
|
117
|
+
<div className="relative">
|
|
118
|
+
<HeadlessUICombobox.Input
|
|
119
|
+
className={`w-full rounded border border-gray-300 focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 sm:text-sm ${
|
|
120
|
+
isError ? "border-red-500" : ""
|
|
121
|
+
}`}
|
|
122
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
123
|
+
displayValue={(item: Record<string, unknown>) => `${item ? item[displayProperty] : ""}`}
|
|
124
|
+
placeholder={placeholder}
|
|
125
|
+
/>
|
|
126
|
+
{selectedItem && nullable && (
|
|
127
|
+
<button
|
|
128
|
+
className="absolute right-8 top-[1px] h-9 w-5 text-gray-400 hover:text-gray-500"
|
|
129
|
+
onClick={() => setSelectedItem(undefined)}
|
|
130
|
+
>
|
|
131
|
+
<DynamicIcon icon="XIcon" className="h-4 w-4 " aria-hidden="true" />
|
|
132
|
+
</button>
|
|
133
|
+
)}
|
|
134
|
+
</div>
|
|
135
|
+
<HeadlessUICombobox.Button className={buttonStyles}>
|
|
136
|
+
<DynamicIcon icon="SelectorIcon" className="h-5 w-5 text-gray-400" aria-hidden="true" />
|
|
137
|
+
</HeadlessUICombobox.Button>
|
|
138
|
+
|
|
139
|
+
{filteredItems.length > 0 && (
|
|
140
|
+
<HeadlessUICombobox.Options className={optionStyles}>
|
|
141
|
+
{filteredItems.map((item, index) => (
|
|
142
|
+
<HeadlessUICombobox.Option
|
|
143
|
+
key={`${item[keyProperty]}-${index}`}
|
|
144
|
+
value={item}
|
|
145
|
+
className={({ active }) =>
|
|
146
|
+
classNames(
|
|
147
|
+
"relative cursor-default select-none py-2 pl-3 pr-9",
|
|
148
|
+
active ? "bg-purple-600 text-white" : "text-gray-900"
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
>
|
|
152
|
+
{({ active, selected }) => (
|
|
153
|
+
<>
|
|
154
|
+
<span
|
|
155
|
+
className={classNames(
|
|
156
|
+
"block truncate",
|
|
157
|
+
selected ? "font-semibold" : ""
|
|
158
|
+
)}
|
|
159
|
+
>
|
|
160
|
+
{`${item[displayProperty]}`}
|
|
161
|
+
</span>
|
|
162
|
+
|
|
163
|
+
{selected && (
|
|
164
|
+
<span
|
|
165
|
+
className={classNames(
|
|
166
|
+
"absolute inset-y-0 right-0 flex items-center pr-4",
|
|
167
|
+
active ? "text-white" : "text-purple-600"
|
|
168
|
+
)}
|
|
169
|
+
>
|
|
170
|
+
<DynamicIcon
|
|
171
|
+
icon="CheckIcon"
|
|
172
|
+
className="h-5 w-5"
|
|
173
|
+
aria-hidden="true"
|
|
174
|
+
/>
|
|
175
|
+
</span>
|
|
176
|
+
)}
|
|
177
|
+
</>
|
|
178
|
+
)}
|
|
179
|
+
</HeadlessUICombobox.Option>
|
|
180
|
+
))}
|
|
181
|
+
</HeadlessUICombobox.Options>
|
|
182
|
+
)}
|
|
183
|
+
</div>
|
|
184
|
+
<div className="grow">
|
|
185
|
+
{message && (
|
|
186
|
+
<span className={`mt-1 block text-sm ${isError ? `text-red-500` : `text-gray-500`}`}>
|
|
187
|
+
{message}
|
|
188
|
+
</span>
|
|
189
|
+
)}
|
|
190
|
+
</div>
|
|
191
|
+
</HeadlessUICombobox>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
export default Combobox
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Checkbox, { ICheckboxProps } from "./checkbox"
|
|
2
|
+
import Combobox, { IComboboxProps } from "./combobox"
|
|
3
|
+
import InputField, { AcceptedInputTypes, IInputFieldProps } from "./InputField"
|
|
4
|
+
import InputLabel, { IInputLabelProps } from "./InputLabel"
|
|
5
|
+
import NestedInputButton, { INestedInputButtonProps } from "./NestedInputButton"
|
|
6
|
+
import Radio, { IRadioProps } from "./radio"
|
|
7
|
+
import Select, { ISelectProps, ISimpleSelectOptions } from "./select"
|
|
8
|
+
import Textarea, { ITextareaProps } from "./textArea"
|
|
9
|
+
import TextInput, { ITextInputProps } from "./TextInput"
|
|
10
|
+
import ToggleSwitch, { IToggleSwitchProps } from "./toggleSwitch"
|
|
11
|
+
|
|
12
|
+
export type {
|
|
13
|
+
ICheckboxProps,
|
|
14
|
+
IComboboxProps,
|
|
15
|
+
IInputFieldProps,
|
|
16
|
+
IInputLabelProps,
|
|
17
|
+
INestedInputButtonProps,
|
|
18
|
+
IRadioProps,
|
|
19
|
+
ISelectProps,
|
|
20
|
+
ISimpleSelectOptions,
|
|
21
|
+
ITextareaProps,
|
|
22
|
+
ITextInputProps,
|
|
23
|
+
IToggleSwitchProps,
|
|
24
|
+
AcceptedInputTypes
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
Checkbox,
|
|
29
|
+
Combobox,
|
|
30
|
+
InputField,
|
|
31
|
+
InputLabel,
|
|
32
|
+
NestedInputButton,
|
|
33
|
+
Radio,
|
|
34
|
+
Select,
|
|
35
|
+
Textarea,
|
|
36
|
+
ToggleSwitch,
|
|
37
|
+
TextInput
|
|
38
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import Radio from "./Radio"
|
|
3
|
+
const meta: Meta<typeof Radio> = {
|
|
4
|
+
title: "Design System/Molecules/Inputs/Radio",
|
|
5
|
+
component: Radio,
|
|
6
|
+
tags: []
|
|
7
|
+
}
|
|
8
|
+
type Story = StoryObj<typeof Radio>
|
|
9
|
+
export const DefaultRadio: Story = {
|
|
10
|
+
args: {
|
|
11
|
+
label: "Radio Label",
|
|
12
|
+
id: "radioId",
|
|
13
|
+
isDisabled: false,
|
|
14
|
+
isChecked: false,
|
|
15
|
+
isRequired: false,
|
|
16
|
+
isError: false,
|
|
17
|
+
message: "",
|
|
18
|
+
name: "radio-group",
|
|
19
|
+
onChange: (value: string, checked: boolean) => {
|
|
20
|
+
console.log(`onChange ${value} ${checked}`)
|
|
21
|
+
},
|
|
22
|
+
onClick: (value: string, checked: boolean) => {
|
|
23
|
+
console.log(`onClick ${value} ${checked}`)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export default meta
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import InputLabel from "@/stories/molecules/inputs/InputLabel"
|
|
2
|
+
import { useId } from "@/utils/useId"
|
|
3
|
+
import React from "react"
|
|
4
|
+
import { default as cn } from "classnames"
|
|
5
|
+
export interface IRadioProps {
|
|
6
|
+
/** group name */
|
|
7
|
+
name?: string
|
|
8
|
+
/** Radio label */
|
|
9
|
+
label: string
|
|
10
|
+
/** Radio ID */
|
|
11
|
+
id?: string
|
|
12
|
+
/** Disabled state */
|
|
13
|
+
isDisabled?: boolean
|
|
14
|
+
/** Check state */
|
|
15
|
+
isChecked?: boolean
|
|
16
|
+
/** If field is required */
|
|
17
|
+
isRequired?: boolean
|
|
18
|
+
/** Error state */
|
|
19
|
+
isError?: boolean
|
|
20
|
+
/** Message or description */
|
|
21
|
+
message?: string
|
|
22
|
+
/** value */
|
|
23
|
+
value?: string
|
|
24
|
+
/** Callback on input change */
|
|
25
|
+
onChange?(value: string, isChecked: boolean): void
|
|
26
|
+
/** Callback on click */
|
|
27
|
+
onClick?(value: string, isChecked: boolean): void
|
|
28
|
+
}
|
|
29
|
+
const Radio: React.FC<IRadioProps> = ({
|
|
30
|
+
label,
|
|
31
|
+
id,
|
|
32
|
+
name,
|
|
33
|
+
isDisabled = false,
|
|
34
|
+
isChecked = false,
|
|
35
|
+
isRequired = false,
|
|
36
|
+
isError = false,
|
|
37
|
+
message,
|
|
38
|
+
onChange,
|
|
39
|
+
onClick,
|
|
40
|
+
value
|
|
41
|
+
}) => {
|
|
42
|
+
const uniqueID = useId()
|
|
43
|
+
if (!id) id = `input-${uniqueID}`
|
|
44
|
+
if (!name) name = id
|
|
45
|
+
|
|
46
|
+
const checboxStyles = cn("focus:ring-purple-500 h-4 w-4 text-purple-600 border-gray-300", {
|
|
47
|
+
"border-red-500 shadow-none": isError
|
|
48
|
+
})
|
|
49
|
+
const wrapperStyles = cn("relative flex items-start", { "opacity-50": isDisabled })
|
|
50
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
51
|
+
const targetValue = e.currentTarget.value
|
|
52
|
+
const targetChecked = e.currentTarget.checked
|
|
53
|
+
typeof onChange === "function" && onChange(targetValue, targetChecked)
|
|
54
|
+
}
|
|
55
|
+
const handleClick = (e: React.MouseEvent<HTMLInputElement>) => {
|
|
56
|
+
const targetValue = e.currentTarget.value
|
|
57
|
+
const targetChecked = e.currentTarget.checked
|
|
58
|
+
typeof onClick === "function" && onClick(targetValue, targetChecked)
|
|
59
|
+
}
|
|
60
|
+
return (
|
|
61
|
+
<div className={wrapperStyles}>
|
|
62
|
+
<div className="flex items-center h-5">
|
|
63
|
+
<input
|
|
64
|
+
id={id}
|
|
65
|
+
aria-describedby={`${id}-description`}
|
|
66
|
+
name={name}
|
|
67
|
+
type="radio"
|
|
68
|
+
value={value}
|
|
69
|
+
className={checboxStyles}
|
|
70
|
+
disabled={isDisabled}
|
|
71
|
+
defaultChecked={isChecked}
|
|
72
|
+
onChange={(e) => {
|
|
73
|
+
handleChange(e)
|
|
74
|
+
}}
|
|
75
|
+
onClick={(e) => {
|
|
76
|
+
handleClick(e)
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
<div className="ml-3 text-sm">
|
|
81
|
+
<InputLabel label={label} isRequired={isRequired} id={id} />
|
|
82
|
+
{message && (
|
|
83
|
+
<p id={`${id}-description`} className="text-gray-500">
|
|
84
|
+
{message}
|
|
85
|
+
</p>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default Radio
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import Select from "./Select"
|
|
3
|
+
const meta: Meta<typeof Select> = {
|
|
4
|
+
title: "Design System/Molecules/Inputs/Select",
|
|
5
|
+
component: Select,
|
|
6
|
+
tags: ["autodocs"]
|
|
7
|
+
}
|
|
8
|
+
type Story = StoryObj<typeof Select>
|
|
9
|
+
export const DefaultSelect: Story = {
|
|
10
|
+
args: {
|
|
11
|
+
label: "Label",
|
|
12
|
+
id: "select",
|
|
13
|
+
name: "select",
|
|
14
|
+
options: [
|
|
15
|
+
{ label: "Canada", value: "value1" },
|
|
16
|
+
{ label: "USA", value: "value2" }
|
|
17
|
+
],
|
|
18
|
+
isDisabled: false,
|
|
19
|
+
isError: false,
|
|
20
|
+
isRequired: false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default meta
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react"
|
|
2
|
+
import InputLabel from "@/stories/molecules/inputs/InputLabel"
|
|
3
|
+
import { useId } from "@/utils/useId"
|
|
4
|
+
import { default as cn } from "classnames"
|
|
5
|
+
|
|
6
|
+
export interface ISimpleSelectOptions {
|
|
7
|
+
label: string
|
|
8
|
+
value: string
|
|
9
|
+
}
|
|
10
|
+
export interface ISelectProps {
|
|
11
|
+
/** Label */
|
|
12
|
+
label?: string
|
|
13
|
+
/** Select ID prop */
|
|
14
|
+
id?: string
|
|
15
|
+
/** Select name prop */
|
|
16
|
+
name?: string
|
|
17
|
+
/** List of options to display in the select menu */
|
|
18
|
+
options: ISimpleSelectOptions[]
|
|
19
|
+
/** Select name prop */
|
|
20
|
+
onChange?(value: string): void
|
|
21
|
+
/** Select disabled state */
|
|
22
|
+
isDisabled?: boolean
|
|
23
|
+
/** Select error state */
|
|
24
|
+
isError?: boolean
|
|
25
|
+
/** Select required state */
|
|
26
|
+
isRequired?: boolean
|
|
27
|
+
|
|
28
|
+
value?: string
|
|
29
|
+
|
|
30
|
+
className?: string
|
|
31
|
+
}
|
|
32
|
+
const Select: React.FC<ISelectProps> = ({
|
|
33
|
+
label,
|
|
34
|
+
id,
|
|
35
|
+
name,
|
|
36
|
+
options,
|
|
37
|
+
onChange,
|
|
38
|
+
isDisabled,
|
|
39
|
+
isError,
|
|
40
|
+
isRequired,
|
|
41
|
+
value,
|
|
42
|
+
className
|
|
43
|
+
}) => {
|
|
44
|
+
const [selectedOption, setSelectedOption] = useState<string>(value || options[0].value)
|
|
45
|
+
const uniqueID = useId()
|
|
46
|
+
if (!id) id = `select-${uniqueID}`
|
|
47
|
+
if (!name) name = id
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (value !== undefined && value !== null) {
|
|
51
|
+
setSelectedOption(value)
|
|
52
|
+
}
|
|
53
|
+
}, [value])
|
|
54
|
+
|
|
55
|
+
const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
56
|
+
const targetValue = e.target.value
|
|
57
|
+
typeof onChange == "function" && onChange(targetValue)
|
|
58
|
+
setSelectedOption(targetValue)
|
|
59
|
+
}
|
|
60
|
+
const wrapperStyle = cn({ "opacity-50": isDisabled })
|
|
61
|
+
return (
|
|
62
|
+
<div className={wrapperStyle}>
|
|
63
|
+
{label && (
|
|
64
|
+
<InputLabel
|
|
65
|
+
isPlaceholder
|
|
66
|
+
isActive
|
|
67
|
+
label={label}
|
|
68
|
+
isRequired={isRequired}
|
|
69
|
+
id={id}
|
|
70
|
+
isError={isError}
|
|
71
|
+
isDisabled={isDisabled}
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
<select
|
|
75
|
+
id={id}
|
|
76
|
+
name={name}
|
|
77
|
+
className={cn(
|
|
78
|
+
"block w-full border-gray-300 py-2 pl-3 pr-10 text-base focus:outline-none",
|
|
79
|
+
"rounded focus:border-purple-500 focus:ring-purple-500 sm:text-sm",
|
|
80
|
+
{ "border-red-500": isError },
|
|
81
|
+
{ "border-gray-300": !isError },
|
|
82
|
+
className
|
|
83
|
+
)}
|
|
84
|
+
onChange={handleChange}
|
|
85
|
+
disabled={isDisabled}
|
|
86
|
+
value={selectedOption}
|
|
87
|
+
>
|
|
88
|
+
{options.map(({ value, label }) => {
|
|
89
|
+
return (
|
|
90
|
+
<option key={value} value={value}>
|
|
91
|
+
{label}
|
|
92
|
+
</option>
|
|
93
|
+
)
|
|
94
|
+
})}
|
|
95
|
+
</select>
|
|
96
|
+
</div>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default Select
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import Textarea from "./TextArea"
|
|
3
|
+
const meta: Meta<typeof Textarea> = {
|
|
4
|
+
title: "Design System/Molecules/Inputs/TextArea",
|
|
5
|
+
component: Textarea,
|
|
6
|
+
tags: ["autodocs"]
|
|
7
|
+
}
|
|
8
|
+
const dummyText: string = `Checkmate... Life finds a way. Is this my espresso machine? Wh-what is-h-how did you get my espresso machine? You're a very talented young man, with your own clever thoughts and ideas. Do you need a manager? Is this my espresso machine? Wh-what is-h-how did you get my espresso machine?
|
|
9
|
+
|
|
10
|
+
I was part of something special. Just my luck, no ice. You really think you can fly that thing? Must go faster... go, go, go, go, go! God creates dinosaurs. God destroys dinosaurs. God creates Man. Man destroys God. Man creates Dinosaurs. Yeah, but your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should.`
|
|
11
|
+
type Story = StoryObj<typeof Textarea>
|
|
12
|
+
export const DefaultTextarea: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
id: "appDescription",
|
|
15
|
+
name: "description",
|
|
16
|
+
rows: 12,
|
|
17
|
+
cols: 18,
|
|
18
|
+
label: "Description",
|
|
19
|
+
placeholder: dummyText
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export default meta
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React, { forwardRef, useEffect, useId, useState } from "react"
|
|
2
|
+
import { default as cn } from "classnames"
|
|
3
|
+
import InputLabel from "../InputLabel"
|
|
4
|
+
import InputCounter from "../InputCounter"
|
|
5
|
+
export interface ITextareaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange"> {
|
|
6
|
+
/** Input ID */
|
|
7
|
+
id?: string
|
|
8
|
+
/** Input Name */
|
|
9
|
+
name?: string
|
|
10
|
+
/** Label for the input */
|
|
11
|
+
label?: string
|
|
12
|
+
/** Error state */
|
|
13
|
+
isError?: boolean
|
|
14
|
+
/** If field is required */
|
|
15
|
+
isRequired?: boolean
|
|
16
|
+
/** Disabled state */
|
|
17
|
+
isDisabled?: boolean
|
|
18
|
+
/** Set default value */
|
|
19
|
+
defaultValue?: string
|
|
20
|
+
|
|
21
|
+
value?: string
|
|
22
|
+
|
|
23
|
+
/** Message shown under the text field */
|
|
24
|
+
message?: string
|
|
25
|
+
/** Input character counter */
|
|
26
|
+
isShowCounter?: boolean
|
|
27
|
+
/** Max length of input character */
|
|
28
|
+
maxLength?: number
|
|
29
|
+
/** Callback on change */
|
|
30
|
+
onChange?(value: string): void
|
|
31
|
+
/** Number of rows */
|
|
32
|
+
rows?: number
|
|
33
|
+
/** Number of cols */
|
|
34
|
+
cols?: number
|
|
35
|
+
placeholder?: string
|
|
36
|
+
className?: string
|
|
37
|
+
ref?: React.LegacyRef<HTMLTextAreaElement>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const Textarea: React.FC<ITextareaProps> = ({
|
|
41
|
+
id,
|
|
42
|
+
name,
|
|
43
|
+
label,
|
|
44
|
+
isError,
|
|
45
|
+
isRequired,
|
|
46
|
+
isDisabled,
|
|
47
|
+
defaultValue,
|
|
48
|
+
message,
|
|
49
|
+
isShowCounter,
|
|
50
|
+
maxLength,
|
|
51
|
+
rows = 12,
|
|
52
|
+
cols = 48,
|
|
53
|
+
onChange,
|
|
54
|
+
value: externalValue,
|
|
55
|
+
placeholder,
|
|
56
|
+
className,
|
|
57
|
+
ref,
|
|
58
|
+
...rest
|
|
59
|
+
}) => {
|
|
60
|
+
const uniqueID = useId()
|
|
61
|
+
const [value, setValue] = useState<string | undefined>(externalValue || defaultValue || "")
|
|
62
|
+
const handleOnchange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
63
|
+
const targetValue = e.currentTarget.value
|
|
64
|
+
typeof onChange === "function" && onChange(targetValue)
|
|
65
|
+
setValue(targetValue)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError })
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
//if the external value is updated by the parent component, reset the value in here...
|
|
72
|
+
if (externalValue !== undefined && externalValue !== null) {
|
|
73
|
+
setValue(externalValue)
|
|
74
|
+
}
|
|
75
|
+
}, [externalValue])
|
|
76
|
+
|
|
77
|
+
if (!id) id = `ta-${uniqueID}`
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div>
|
|
81
|
+
{label && (
|
|
82
|
+
<InputLabel
|
|
83
|
+
isPlaceholder
|
|
84
|
+
isActive
|
|
85
|
+
label={label}
|
|
86
|
+
isRequired={isRequired}
|
|
87
|
+
id={id}
|
|
88
|
+
isError={isError}
|
|
89
|
+
isDisabled={isDisabled}
|
|
90
|
+
/>
|
|
91
|
+
)}
|
|
92
|
+
<div>
|
|
93
|
+
<textarea
|
|
94
|
+
ref={ref}
|
|
95
|
+
maxLength={maxLength}
|
|
96
|
+
onChange={handleOnchange}
|
|
97
|
+
rows={rows}
|
|
98
|
+
name={name}
|
|
99
|
+
id={id}
|
|
100
|
+
cols={cols}
|
|
101
|
+
className={cn(
|
|
102
|
+
"block w-full rounded focus:border-purple-500 focus:ring-purple-500 sm:text-sm",
|
|
103
|
+
{ "border-gray-300 ": !isError },
|
|
104
|
+
{
|
|
105
|
+
"border-red-500 outline-red-500 focus:ring-red-500": isError
|
|
106
|
+
},
|
|
107
|
+
className
|
|
108
|
+
)}
|
|
109
|
+
disabled={isDisabled}
|
|
110
|
+
defaultValue={defaultValue}
|
|
111
|
+
value={value}
|
|
112
|
+
placeholder={placeholder}
|
|
113
|
+
{...rest}
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
<div className="flex flex-row space-x-3">
|
|
117
|
+
<div className="grow">{message && <span className={discriptionStyles}>{message}</span>}</div>
|
|
118
|
+
{isShowCounter && (
|
|
119
|
+
<div className="shrink-0">
|
|
120
|
+
<InputCounter current={Number(value?.length)} limit={maxLength} />
|
|
121
|
+
</div>
|
|
122
|
+
)}
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default Textarea
|