@ainias42/react-bootstrap-mobile 1.0.1 → 1.0.3
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/.ctirc +114 -0
- package/.prettierrc +1 -5
- package/.storybook/main.ts +31 -0
- package/.storybook/preview.ts +36 -0
- package/bin/release.sh +1 -37
- package/bin/updatePackages.sh +3 -0
- package/dist/{src/Components → Components}/ActionSheet/ActionSheet.d.ts +5 -5
- package/dist/Components/ActionSheet/ActionSheet.stories.d.ts +9 -0
- package/dist/Components/Card/Card.d.ts +12 -0
- package/dist/Components/Card/Card.stories.d.ts +16 -0
- package/dist/{src/Components → Components}/Clickable/Clickable.d.ts +3 -3
- package/dist/Components/Colors.stories.d.ts +5 -0
- package/dist/Components/Dialog/AlertDialog.d.ts +8 -0
- package/dist/Components/Dialog/AlertDialog.stories.d.ts +14 -0
- package/dist/{src/Components → Components}/Dialog/ButtonDialog.d.ts +3 -3
- package/dist/Components/Dialog/ConfirmDialog.d.ts +9 -0
- package/dist/Components/Dialog/ConfirmDialog.stories.d.ts +15 -0
- package/dist/{src/Components → Components}/Dialog/Dialog.d.ts +2 -2
- package/dist/{src/Components → Components}/Dialog/DialogBackground.d.ts +2 -2
- package/dist/{src/Components → Components}/Dialog/DialogContainer.d.ts +3 -3
- package/dist/{src/Components → Components}/Dialog/DialogContext.d.ts +3 -2
- package/dist/{src/Components → Components}/DragAndDrop/DragItem.d.ts +2 -2
- package/dist/{src/Components → Components}/DragAndDrop/DropArea.d.ts +2 -2
- package/dist/{src/Components → Components}/FormElements/Button/Button.d.ts +8 -8
- package/dist/Components/FormElements/Button/Button.stories.d.ts +43 -0
- package/dist/Components/FormElements/CheckBox/Checkbox.d.ts +12 -0
- package/dist/Components/FormElements/CheckBox/Checkbox.stories.d.ts +17 -0
- package/dist/{src/Components → Components}/FormElements/ColorInput/ColorInput.d.ts +3 -5
- package/dist/Components/FormElements/ColorInput/ColorInput.stories.d.ts +8 -0
- package/dist/{src/Components → Components}/FormElements/Controller/ColorInputController.d.ts +1 -1
- package/dist/{src/Components → Components}/FormElements/Controller/FileInputController.d.ts +4 -4
- package/dist/Components/FormElements/Controller/HookForm.d.ts +15 -0
- package/dist/{src/Components → Components}/FormElements/Controller/InputController.d.ts +1 -1
- package/dist/{src/Components → Components}/FormElements/Controller/MultipleFileInputController.d.ts +1 -1
- package/dist/{src/Components → Components}/FormElements/Controller/PasswordInputController.d.ts +1 -1
- package/dist/{src/Components → Components}/FormElements/Controller/SelectController.d.ts +1 -1
- package/dist/Components/FormElements/Controller/SliderController.d.ts +5 -0
- package/dist/{src/Components → Components}/FormElements/Controller/SwitchController.d.ts +1 -1
- package/dist/{src/Components → Components}/FormElements/Controller/TextareaController.d.ts +1 -1
- package/dist/{src/Components → Components}/FormElements/Controller/useYupResolver.d.ts +1 -1
- package/dist/{src/Components → Components}/FormElements/Controller/withHookController.d.ts +3 -2
- package/dist/Components/FormElements/Error/FormError.d.ts +6 -0
- package/dist/Components/FormElements/Error/FormError.stories.d.ts +7 -0
- package/dist/Components/FormElements/Form.stories.d.ts +7 -0
- package/dist/Components/FormElements/Input/FileInput/FileInput.d.ts +13 -0
- package/dist/{src/Components → Components}/FormElements/Input/FileInput/MultipleFileInput.d.ts +6 -6
- package/dist/Components/FormElements/Input/HiddenInput.d.ts +6 -0
- package/dist/Components/FormElements/Input/HiddenInput.stories.d.ts +9 -0
- package/dist/{src/Components → Components}/FormElements/Input/Input.d.ts +4 -4
- package/dist/Components/FormElements/Input/Input.stories.d.ts +18 -0
- package/dist/{src/Components → Components}/FormElements/Input/PasswordInput/PasswordInput.d.ts +5 -4
- package/dist/Components/FormElements/Input/PasswordInput/PasswordInput.stories.d.ts +8 -0
- package/dist/{src/Components → Components}/FormElements/SearchSelectInput/SearchSelectInput.d.ts +4 -4
- package/dist/Components/FormElements/SearchSelectInput/SearchSelectInput.stories.d.ts +9 -0
- package/dist/{src/Components → Components}/FormElements/Select/Select.d.ts +4 -4
- package/dist/Components/FormElements/Select/Select.stories.d.ts +8 -0
- package/dist/{src/Components → Components}/FormElements/Slider/Slider.d.ts +4 -4
- package/dist/Components/FormElements/Slider/Slider.stories.d.ts +7 -0
- package/dist/{src/Components → Components}/FormElements/Switch/Switch.d.ts +5 -5
- package/dist/Components/FormElements/Switch/Switch.stories.d.ts +11 -0
- package/dist/{src/Components → Components}/FormElements/Textarea/Textarea.d.ts +4 -4
- package/dist/Components/FormElements/Textarea/Textarea.stories.d.ts +9 -0
- package/dist/{src/Components → Components}/FormElements/hooks/useOnChangeDone.d.ts +1 -1
- package/dist/{src/Components → Components}/FullScreen/FullScreen.d.ts +4 -4
- package/dist/{src/Components → Components}/Hooks/useClientLayoutEffect.d.ts +1 -1
- package/dist/{src/Components → Components}/Hooks/useComposedRef.d.ts +1 -1
- package/dist/{src/Components → Components}/Hooks/useDelayedState.d.ts +1 -1
- package/dist/{src/Components → Components}/Hooks/useInViewport.d.ts +1 -1
- package/dist/{src/Components → Components}/Icon/DoubleIcon.d.ts +1 -1
- package/dist/Components/Icon/DoubleIcon.stories.d.ts +23 -0
- package/dist/{src/Components → Components}/Icon/Icon.d.ts +5 -5
- package/dist/Components/Icon/Icon.stories.d.ts +17 -0
- package/dist/Components/Image/Image.d.ts +10 -0
- package/dist/Components/Image/Image.stories.d.ts +7 -0
- package/dist/{src/Components → Components}/InViewport/InViewport.d.ts +1 -1
- package/dist/{src/Components → Components}/Layout/Block.d.ts +4 -4
- package/dist/{src/Components → Components}/Layout/Container.d.ts +1 -1
- package/dist/{src/Components → Components}/Layout/Flex.d.ts +3 -3
- package/dist/{src/Components → Components}/Layout/Grid/Grid.d.ts +3 -3
- package/dist/{src/Components → Components}/Layout/Grid/GridItem.d.ts +1 -1
- package/dist/Components/Layout/Grow.d.ts +10 -0
- package/dist/{src/Components → Components}/Layout/Inline.d.ts +3 -3
- package/dist/{src/Components → Components}/Layout/InlineBlock.d.ts +3 -3
- package/dist/{src/Components → Components}/Layout/View.d.ts +4 -4
- package/dist/{src/Components → Components}/Layout/ViewWithoutListeners.d.ts +3 -3
- package/dist/Components/LoadingArea/LoadingArea.d.ts +9 -0
- package/dist/Components/LoadingArea/LoadingArea.stories.d.ts +9 -0
- package/dist/Components/LoadingCircle/LoadingCircle.d.ts +7 -0
- package/dist/Components/LoadingCircle/LoadingCircle.stories.d.ts +26 -0
- package/dist/{src/Components → Components}/Menu/HoverMenu.d.ts +3 -3
- package/dist/Components/Menu/HoverMenu.stories.d.ts +16 -0
- package/dist/{src/Components → Components}/Menu/Menu.d.ts +2 -2
- package/dist/Components/Menu/Menu.stories.d.ts +14 -0
- package/dist/{src/Components → Components}/Menu/MenuCloseContext.d.ts +1 -1
- package/dist/{src/Components → Components}/Menu/MenuDivider.d.ts +1 -1
- package/dist/{src/Components → Components}/Menu/MenuItem.d.ts +4 -3
- package/dist/Components/Menu/MenuItem.stories.d.ts +21 -0
- package/dist/{src/Components → Components}/Menu/Submenu.d.ts +3 -3
- package/dist/Components/Menu/Submenu.stories.d.ts +10 -0
- package/dist/{src/Components → Components}/Menu/useMenu.d.ts +2 -2
- package/dist/{src/Components → Components}/RbmComponentProps.d.ts +4 -4
- package/dist/{src/Components → Components}/SizeCalculator/SizeCalculator.d.ts +1 -1
- package/dist/Components/SpoilerList/Spoiler/Spoiler.d.ts +16 -0
- package/dist/Components/SpoilerList/Spoiler/Spoiler.stories.d.ts +7 -0
- package/dist/{src/Components → Components}/SpoilerList/SpoilerList.d.ts +3 -5
- package/dist/{src/Components → Components}/TabBar/TabBar.d.ts +4 -6
- package/dist/Components/TabBar/TabBar.stories.d.ts +10 -0
- package/dist/Components/TabBar/TabBarButton.d.ts +7 -0
- package/dist/{src/Components → Components}/Table/Table.d.ts +3 -3
- package/dist/{src/Components → Components}/Text/Heading.d.ts +2 -2
- package/dist/{src/Components → Components}/Text/Text.d.ts +3 -3
- package/dist/Components/Text/Text.stories.d.ts +35 -0
- package/dist/Components/Toast/Toast.d.ts +12 -0
- package/dist/Components/Toast/Toast.stories.d.ts +8 -0
- package/dist/{src/Components → Components}/Toast/ToastContainer.d.ts +2 -2
- package/dist/Components/TopBar/MoreButton.d.ts +7 -0
- package/dist/{src/Components → Components}/TopBar/TopBar.d.ts +4 -6
- package/dist/Components/TopBar/TopBar.stories.d.ts +7 -0
- package/dist/Components/TopBar/TopBarButton.d.ts +7 -0
- package/dist/helper/useDeepShallow.d.ts +1 -0
- package/dist/helper/withMemo.d.ts +3 -0
- package/dist/{src/helper → helper}/withRenderBrowserOnly.d.ts +1 -1
- package/dist/helper/withRestrictedChildren.d.ts +7 -0
- package/dist/index.css +36 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.js +5357 -0
- package/dist/index.js.map +1 -0
- package/dist/treeshakeTest.d.ts +1 -0
- package/eslint.config.js +17 -0
- package/package.json +41 -90
- package/react-bootstrap-mobile.scss +6 -6
- package/src/Components/ActionSheet/ActionSheet.stories.tsx +55 -0
- package/src/Components/ActionSheet/ActionSheet.tsx +37 -24
- package/src/Components/ActionSheet/actionSheet.module.scss +198 -0
- package/src/Components/Card/Card.stories.tsx +41 -0
- package/src/Components/Card/Card.tsx +6 -9
- package/src/Components/Card/card.module.scss +74 -0
- package/src/Components/Clickable/Clickable.tsx +73 -63
- package/src/Components/Clickable/clickable.module.scss +14 -0
- package/src/Components/Colors.stories.tsx +77 -0
- package/src/Components/Dialog/AlertDialog.stories.tsx +28 -0
- package/src/Components/Dialog/AlertDialog.tsx +10 -9
- package/src/Components/Dialog/ButtonDialog.tsx +15 -13
- package/src/Components/Dialog/ConfirmDialog.stories.tsx +29 -0
- package/src/Components/Dialog/ConfirmDialog.tsx +11 -9
- package/src/Components/Dialog/Dialog.tsx +10 -10
- package/src/Components/Dialog/DialogBackground.tsx +32 -21
- package/src/Components/Dialog/DialogContainer.tsx +23 -18
- package/src/Components/Dialog/DialogContext.ts +7 -6
- package/src/Components/Dialog/{buttonDialog.scss → buttonDialog.module.scss} +29 -21
- package/src/Components/Dialog/dialog.module.scss +30 -0
- package/src/Components/Dialog/dialogBackground.module.scss +17 -0
- package/src/Components/Dialog/useAlertDialog.ts +3 -3
- package/src/Components/Dialog/useConfirmDialog.ts +3 -3
- package/src/Components/DragAndDrop/DragItem.tsx +7 -6
- package/src/Components/DragAndDrop/DropArea.tsx +5 -4
- package/src/Components/Flavor.ts +4 -4
- package/src/Components/FormElements/Button/Button.stories.tsx +79 -0
- package/src/Components/FormElements/Button/Button.tsx +49 -36
- package/src/Components/FormElements/Button/ButtonType.ts +2 -2
- package/src/Components/FormElements/Button/button.module.scss +87 -0
- package/src/Components/FormElements/CheckBox/Checkbox.stories.tsx +50 -0
- package/src/Components/FormElements/CheckBox/Checkbox.tsx +13 -14
- package/src/Components/FormElements/CheckBox/{checkbox.scss → checkbox.module.scss} +30 -11
- package/src/Components/FormElements/ColorInput/ColorInput.stories.tsx +24 -0
- package/src/Components/FormElements/ColorInput/ColorInput.tsx +55 -59
- package/src/Components/FormElements/ColorInput/{colorInput.scss → colorInput.module.scss} +17 -19
- package/src/Components/FormElements/ColorInput/sharedSelectedColor.ts +19 -10
- package/src/Components/FormElements/Controller/ColorInputController.ts +3 -3
- package/src/Components/FormElements/Controller/FileInputController.tsx +29 -20
- package/src/Components/FormElements/Controller/HookForm.tsx +128 -24
- package/src/Components/FormElements/Controller/InputController.ts +3 -3
- package/src/Components/FormElements/Controller/MultipleFileInputController.ts +2 -3
- package/src/Components/FormElements/Controller/PasswordInputController.ts +3 -3
- package/src/Components/FormElements/Controller/SelectController.ts +3 -3
- package/src/Components/FormElements/Controller/SendFormContext.ts +3 -3
- package/src/Components/FormElements/Controller/SliderController.ts +4 -0
- package/src/Components/FormElements/Controller/SwitchController.ts +3 -3
- package/src/Components/FormElements/Controller/TextareaController.ts +2 -2
- package/src/Components/FormElements/Controller/useYupResolver.ts +10 -8
- package/src/Components/FormElements/Controller/withHookController.tsx +21 -18
- package/src/Components/FormElements/Error/FormError.stories.tsx +16 -0
- package/src/Components/FormElements/Error/FormError.tsx +42 -0
- package/src/Components/FormElements/Error/formError.module.scss +9 -0
- package/src/Components/FormElements/Form.stories.tsx +16 -0
- package/src/Components/FormElements/Input/FileInput/FileInput.tsx +52 -32
- package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +234 -231
- package/src/Components/FormElements/Input/FileInput/{fileInput.scss → fileInput.module.scss} +10 -12
- package/src/Components/FormElements/Input/HiddenInput.stories.tsx +44 -0
- package/src/Components/FormElements/Input/HiddenInput.tsx +6 -8
- package/src/Components/FormElements/Input/Input.stories.tsx +59 -0
- package/src/Components/FormElements/Input/Input.tsx +173 -172
- package/src/Components/FormElements/Input/PasswordInput/PasswordInput.stories.tsx +31 -0
- package/src/Components/FormElements/Input/PasswordInput/PasswordInput.tsx +20 -16
- package/src/Components/FormElements/Input/input.module.scss +95 -0
- package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.stories.tsx +49 -0
- package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.tsx +178 -166
- package/src/Components/FormElements/SearchSelectInput/seachSelectInput.module.scss +112 -0
- package/src/Components/FormElements/Select/Select.stories.tsx +49 -0
- package/src/Components/FormElements/Select/Select.tsx +34 -24
- package/src/Components/FormElements/Select/select.module.scss +63 -0
- package/src/Components/FormElements/Slider/Slider.stories.tsx +15 -0
- package/src/Components/FormElements/Slider/Slider.tsx +29 -20
- package/src/Components/FormElements/Slider/slider.module.scss +93 -0
- package/src/Components/FormElements/Switch/Switch.stories.tsx +65 -0
- package/src/Components/FormElements/Switch/Switch.tsx +72 -63
- package/src/Components/FormElements/Switch/switch.module.scss +157 -0
- package/src/Components/FormElements/Textarea/Textarea.stories.tsx +37 -0
- package/src/Components/FormElements/Textarea/Textarea.tsx +46 -45
- package/src/Components/FormElements/Textarea/textarea.module.scss +34 -0
- package/src/Components/FormElements/hooks/useOnChangeDone.ts +6 -2
- package/src/Components/FullScreen/FullScreen.tsx +16 -16
- package/src/Components/Hooks/useBreakpoint.ts +13 -7
- package/src/Components/Hooks/useClientLayoutEffect.ts +1 -1
- package/src/Components/Hooks/useComposedRef.ts +2 -1
- package/src/Components/Hooks/useDebounced.ts +2 -2
- package/src/Components/Hooks/useDelayed.ts +2 -3
- package/src/Components/Hooks/useDelayedEffect.ts +3 -3
- package/src/Components/Hooks/useDelayedState.ts +18 -10
- package/src/Components/Hooks/useInViewport.ts +3 -2
- package/src/Components/Hooks/useKeyListener.ts +9 -6
- package/src/Components/Hooks/useListener.ts +4 -4
- package/src/Components/Hooks/useMousePosition.ts +2 -2
- package/src/Components/Hooks/useRerender.ts +17 -14
- package/src/Components/Hooks/useWindowDimensions.ts +11 -12
- package/src/Components/Icon/DoubleIcon.stories.tsx +38 -0
- package/src/Components/Icon/DoubleIcon.tsx +22 -17
- package/src/Components/Icon/Icon.stories.tsx +37 -0
- package/src/Components/Icon/Icon.tsx +39 -17
- package/src/Components/Icon/{icon.scss → icon.module.scss} +2 -0
- package/src/Components/Image/Image.stories.tsx +17 -0
- package/src/Components/Image/Image.tsx +7 -12
- package/src/Components/InViewport/InViewport.tsx +5 -6
- package/src/Components/Layout/Block.tsx +18 -12
- package/src/Components/Layout/Container.tsx +5 -6
- package/src/Components/Layout/Flex.tsx +17 -9
- package/src/Components/Layout/Grid/Grid.tsx +20 -10
- package/src/Components/Layout/Grid/GridItem.tsx +5 -6
- package/src/Components/Layout/Grid/{grid.scss → grid.module.scss} +19 -26
- package/src/Components/Layout/Grow.tsx +18 -8
- package/src/Components/Layout/Inline.tsx +15 -12
- package/src/Components/Layout/InlineBlock.tsx +17 -12
- package/src/Components/Layout/View.tsx +20 -9
- package/src/Components/Layout/ViewWithoutListeners.tsx +24 -15
- package/src/Components/Layout/container.module.scss +54 -0
- package/src/Components/LoadingArea/LoadingArea.stories.tsx +35 -0
- package/src/Components/LoadingArea/LoadingArea.tsx +10 -15
- package/src/Components/LoadingArea/{loadingArea.scss → loadingArea.module.scss} +8 -5
- package/src/Components/LoadingCircle/LoadingCircle.stories.tsx +58 -0
- package/src/Components/LoadingCircle/LoadingCircle.tsx +26 -13
- package/src/Components/LoadingCircle/{loadingCircle.scss → loadingCircle.module.scss} +14 -5
- package/src/Components/Menu/HoverMenu.stories.tsx +32 -0
- package/src/Components/Menu/HoverMenu.tsx +61 -45
- package/src/Components/Menu/Menu.stories.tsx +69 -0
- package/src/Components/Menu/Menu.tsx +67 -58
- package/src/Components/Menu/MenuCloseContext.ts +1 -1
- package/src/Components/Menu/MenuDivider.tsx +6 -6
- package/src/Components/Menu/MenuItem.stories.tsx +35 -0
- package/src/Components/Menu/MenuItem.tsx +66 -55
- package/src/Components/Menu/Submenu.stories.tsx +37 -0
- package/src/Components/Menu/Submenu.tsx +72 -58
- package/src/Components/Menu/{menu.scss → menu.module.scss} +23 -11
- package/src/Components/Menu/useMenu.ts +4 -3
- package/src/Components/RbmComponentProps.ts +6 -7
- package/src/Components/SizeCalculator/SizeCalculator.tsx +3 -3
- package/src/Components/SpoilerList/Spoiler/Spoiler.stories.tsx +21 -0
- package/src/Components/SpoilerList/Spoiler/Spoiler.tsx +49 -48
- package/src/Components/SpoilerList/Spoiler/{spoiler.scss → spoiler.module.scss} +46 -30
- package/src/Components/SpoilerList/SpoilerList.tsx +8 -12
- package/src/Components/SpoilerList/useSpoilerGroup.ts +2 -2
- package/src/Components/TabBar/TabBar.stories.tsx +32 -0
- package/src/Components/TabBar/TabBar.tsx +16 -18
- package/src/Components/TabBar/TabBarButton.tsx +13 -10
- package/src/Components/TabBar/tabBar.module.scss +128 -0
- package/src/Components/Table/Table.tsx +16 -15
- package/src/Components/Text/Heading.tsx +6 -7
- package/src/Components/Text/Text.stories.tsx +121 -0
- package/src/Components/Text/Text.tsx +19 -10
- package/src/Components/Text/{text.scss → text.module.scss} +3 -8
- package/src/Components/Toast/Toast.stories.tsx +25 -0
- package/src/Components/Toast/Toast.tsx +15 -17
- package/src/Components/Toast/ToastContainer.tsx +72 -54
- package/src/Components/Toast/ToastContext.ts +9 -3
- package/src/Components/Toast/toast.module.scss +65 -0
- package/src/Components/TopBar/MoreButton.tsx +9 -11
- package/src/Components/TopBar/TopBar.stories.tsx +63 -0
- package/src/Components/TopBar/TopBar.tsx +49 -40
- package/src/Components/TopBar/TopBarButton.tsx +20 -10
- package/src/Components/TopBar/{topBar.scss → topBar.module.scss} +40 -23
- package/src/Size.ts +1 -2
- package/src/WrongChildError.ts +1 -1
- package/src/helper/EmptyProps.ts +1 -1
- package/src/helper/nonEmptyString.ts +1 -1
- package/src/helper/useDeepShallow.ts +10 -0
- package/src/helper/withMemo.ts +7 -8
- package/src/helper/withRenderBrowserOnly.tsx +2 -1
- package/src/helper/withRestrictedChildren.tsx +11 -14
- package/src/index.ts +116 -0
- package/src/scss/_colors.scss +32 -19
- package/src/scss/_default.scss +5 -5
- package/src/scss/_flavorMixin.scss +3 -0
- package/src/scss/_variables.scss +19 -19
- package/src/scss/_vars.scss +12 -0
- package/src/scss/baseClasses.module.scss +23 -0
- package/src/scss/breakpoints.scss +79 -0
- package/src/treeshakeTest.ts +3 -0
- package/src/types/{react-table-config.d.ts → reactTableConfig.d.ts} +2 -43
- package/stylelint.config.mjs +4 -0
- package/tsconfig.build.json +7 -0
- package/tsconfig.json +16 -48
- package/webpack.config.ts +6 -0
- package/.eslintrc.json +0 -191
- package/.npnignore +0 -5
- package/LICENSE +0 -21
- package/README.md +0 -1
- package/babel.config.js +0 -22
- package/bin/build.js +0 -60
- package/bin/updateCopies.js +0 -94
- package/bootstrapReactMobile.ts +0 -119
- package/dist/bootstrapReactMobile.d.ts +0 -119
- package/dist/bootstrapReactMobile.js +0 -14043
- package/dist/bootstrapReactMobile.js.map +0 -1
- package/dist/src/Components/Card/Card.d.ts +0 -14
- package/dist/src/Components/Dialog/AlertDialog.d.ts +0 -10
- package/dist/src/Components/Dialog/ConfirmDialog.d.ts +0 -11
- package/dist/src/Components/FormElements/CheckBox/Checkbox.d.ts +0 -14
- package/dist/src/Components/FormElements/Controller/HookForm.d.ts +0 -8
- package/dist/src/Components/FormElements/FormError.d.ts +0 -5
- package/dist/src/Components/FormElements/Input/FileInput/FileInput.d.ts +0 -13
- package/dist/src/Components/FormElements/Input/HiddenInput.d.ts +0 -8
- package/dist/src/Components/Image/Image.d.ts +0 -12
- package/dist/src/Components/Layout/Grow.d.ts +0 -9
- package/dist/src/Components/List/BulletList/BulletList.d.ts +0 -8
- package/dist/src/Components/List/BulletList/ListItem.d.ts +0 -7
- package/dist/src/Components/List/InfiniteList.d.ts +0 -7
- package/dist/src/Components/List/List.d.ts +0 -15
- package/dist/src/Components/LoadingArea/LoadingArea.d.ts +0 -12
- package/dist/src/Components/LoadingCircle/LoadingCircle.d.ts +0 -8
- package/dist/src/Components/SpoilerList/Spoiler/Spoiler.d.ts +0 -18
- package/dist/src/Components/TabBar/TabBarButton.d.ts +0 -9
- package/dist/src/Components/Toast/Toast.d.ts +0 -13
- package/dist/src/Components/TopBar/MoreButton.d.ts +0 -9
- package/dist/src/Components/TopBar/TopBarButton.d.ts +0 -9
- package/dist/src/ListRow/ListRow.d.ts +0 -1
- package/dist/src/StyleProvider.d.ts +0 -2
- package/dist/src/helper/withMemo.d.ts +0 -3
- package/dist/src/helper/withRestrictedChildren.d.ts +0 -6
- package/scripts/getPackageJson.js +0 -25
- package/src/Components/ActionSheet/actionSheet.scss +0 -153
- package/src/Components/Card/card.scss +0 -76
- package/src/Components/Clickable/clickable.scss +0 -8
- package/src/Components/Dialog/dialog.scss +0 -30
- package/src/Components/Dialog/dialogBackground.scss +0 -11
- package/src/Components/FormElements/Button/button.scss +0 -73
- package/src/Components/FormElements/FormError.tsx +0 -29
- package/src/Components/FormElements/Input/input.scss +0 -83
- package/src/Components/FormElements/SearchSelectInput/seachSelectInput.scss +0 -97
- package/src/Components/FormElements/Select/select.scss +0 -61
- package/src/Components/FormElements/Slider/slider.scss +0 -92
- package/src/Components/FormElements/Switch/switch.scss +0 -152
- package/src/Components/FormElements/Textarea/textarea.scss +0 -31
- package/src/Components/FormElements/formError.scss +0 -4
- package/src/Components/Layout/container.scss +0 -12
- package/src/Components/List/BulletList/BulletList.tsx +0 -33
- package/src/Components/List/BulletList/ListItem.tsx +0 -34
- package/src/Components/List/InfiniteList.tsx +0 -56
- package/src/Components/List/List.tsx +0 -95
- package/src/Components/List/list.scss +0 -30
- package/src/Components/TabBar/tabBar.scss +0 -108
- package/src/Components/Toast/toast.scss +0 -55
- package/src/ListRow/ListRow.tsx +0 -20
- package/src/StyleProvider.ts +0 -4
- package/src/scss/_baseClasses.scss +0 -23
- package/src/types/isomorphic-style-loader.d.ts +0 -3
- package/webpack.config.js +0 -95
- /package/dist/{src/Components → Components}/Dialog/useAlertDialog.d.ts +0 -0
- /package/dist/{src/Components → Components}/Dialog/useConfirmDialog.d.ts +0 -0
- /package/dist/{src/Components → Components}/DragAndDrop/useStrictEnabled.d.ts +0 -0
- /package/dist/{src/Components → Components}/Flavor.d.ts +0 -0
- /package/dist/{src/Components → Components}/FormElements/Button/ButtonType.d.ts +0 -0
- /package/dist/{src/Components → Components}/FormElements/ColorInput/sharedSelectedColor.d.ts +0 -0
- /package/dist/{src/Components → Components}/FormElements/Controller/SendFormContext.d.ts +0 -0
- /package/dist/{src/Components → Components}/FormElements/Input/FileInput/FileType.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useBreakpoint.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useDebounced.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useDelayed.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useDelayedEffect.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useKeyListener.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useListener.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useMousePosition.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useOnMount.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useOnce.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useRerender.d.ts +0 -0
- /package/dist/{src/Components → Components}/Hooks/useWindowDimensions.d.ts +0 -0
- /package/dist/{src/Components → Components}/SpoilerList/useSpoilerGroup.d.ts +0 -0
- /package/dist/{src/Components → Components}/Toast/ToastContext.d.ts +0 -0
- /package/dist/{src/Size.d.ts → Size.d.ts} +0 -0
- /package/dist/{src/TypeHelpers.d.ts → TypeHelpers.d.ts} +0 -0
- /package/dist/{src/WindowContext → WindowContext}/WindowContext.d.ts +0 -0
- /package/dist/{src/WrongChildError.d.ts → WrongChildError.d.ts} +0 -0
- /package/dist/{src/helper → helper}/Characters.d.ts +0 -0
- /package/dist/{src/helper → helper}/DistributiveOmit.d.ts +0 -0
- /package/dist/{src/helper → helper}/EmptyProps.d.ts +0 -0
- /package/dist/{src/helper → helper}/memoComparator.d.ts +0 -0
- /package/dist/{src/helper → helper}/nonEmptyString.d.ts +0 -0
- /package/src/Components/FormElements/Input/PasswordInput/{passwordInput.scss → passwordInput.module.scss} +0 -0
- /package/src/Components/Image/{image.scss → image.module.scss} +0 -0
- /package/src/Components/InViewport/{inViewport.scss → inViewport.module.scss} +0 -0
- /package/src/Components/Layout/{layout.scss → layout.module.scss} +0 -0
- /package/src/Components/Text/{heading.scss → heading.module.scss} +0 -0
- /package/src/types/{scss-module.d.ts → scss.d.ts} +0 -0
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ChangeEventHandler, SelectHTMLAttributes
|
|
5
|
-
import {
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useListenerWithExtractedProps } from '@/Components/Hooks/useListener';
|
|
4
|
+
import type { ChangeEventHandler, SelectHTMLAttributes } from 'react';
|
|
5
|
+
import type { Override } from '@/TypeHelpers';
|
|
6
|
+
import type { RbmComponentProps } from '@/Components/RbmComponentProps';
|
|
6
7
|
|
|
7
|
-
import
|
|
8
|
-
import { withMemo } from '
|
|
8
|
+
import { FormError } from '@/Components/FormElements/Error/FormError';
|
|
9
|
+
import { withMemo } from '@/helper/withMemo';
|
|
9
10
|
import classNames from 'classnames';
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
11
|
+
import styles from '@/Components/FormElements/Select/select.module.scss';
|
|
12
|
+
import type { OptionalListener } from '@/Components/Hooks/useListener';
|
|
12
13
|
|
|
13
|
-
export type SelectOption<ValueType=string> = {
|
|
14
|
+
export type SelectOption<ValueType = string> = {
|
|
14
15
|
label: string;
|
|
15
16
|
value: ValueType;
|
|
16
17
|
key?: string;
|
|
@@ -24,15 +25,19 @@ export type SelectProps<OnChangeData> = RbmComponentProps<
|
|
|
24
25
|
inline?: boolean;
|
|
25
26
|
small?: boolean;
|
|
26
27
|
error?: string;
|
|
27
|
-
} & (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
} & (
|
|
29
|
+
| {
|
|
30
|
+
options: SelectOption[];
|
|
31
|
+
onChangeValue?: (newValue: string) => void;
|
|
32
|
+
useNumericValues?: false;
|
|
33
|
+
}
|
|
34
|
+
| {
|
|
35
|
+
options: SelectOption<number>[];
|
|
36
|
+
onChangeValue?: (newValue: number) => void;
|
|
37
|
+
useNumericValues: true;
|
|
38
|
+
}
|
|
39
|
+
) &
|
|
40
|
+
OptionalListener<'onChange', OnChangeData>
|
|
36
41
|
>
|
|
37
42
|
>;
|
|
38
43
|
|
|
@@ -57,7 +62,10 @@ export const Select = withMemo(function Select<OnChangeData>({
|
|
|
57
62
|
// Selectors
|
|
58
63
|
|
|
59
64
|
// Callbacks
|
|
60
|
-
const [onChangeWithData, propsWithoutData] = useListenerWithExtractedProps<'onChange', OnChangeData>(
|
|
65
|
+
const [onChangeWithData, propsWithoutData] = useListenerWithExtractedProps<'onChange', OnChangeData>(
|
|
66
|
+
'onChange',
|
|
67
|
+
otherProps,
|
|
68
|
+
);
|
|
61
69
|
const onChange = useCallback<ChangeEventHandler<HTMLSelectElement>>(
|
|
62
70
|
(e) => {
|
|
63
71
|
if (useNumericValues) {
|
|
@@ -67,7 +75,7 @@ export const Select = withMemo(function Select<OnChangeData>({
|
|
|
67
75
|
}
|
|
68
76
|
onChangeWithData(e);
|
|
69
77
|
},
|
|
70
|
-
[onChangeWithData, onChangeValue, useNumericValues]
|
|
78
|
+
[onChangeWithData, onChangeValue, useNumericValues],
|
|
71
79
|
);
|
|
72
80
|
|
|
73
81
|
// Effects
|
|
@@ -78,7 +86,10 @@ export const Select = withMemo(function Select<OnChangeData>({
|
|
|
78
86
|
|
|
79
87
|
return (
|
|
80
88
|
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
81
|
-
<label
|
|
89
|
+
<label
|
|
90
|
+
className={classNames(styles.select, { [styles.inline]: inline, [styles.small]: small }, className)}
|
|
91
|
+
style={style}
|
|
92
|
+
>
|
|
82
93
|
{label ? <span className={styles.label}>{label}</span> : null}
|
|
83
94
|
<select {...propsWithoutData} className={styles.input} onChange={onChange}>
|
|
84
95
|
{options.map((option) => (
|
|
@@ -87,8 +98,7 @@ export const Select = withMemo(function Select<OnChangeData>({
|
|
|
87
98
|
</option>
|
|
88
99
|
))}
|
|
89
100
|
</select>
|
|
90
|
-
|
|
101
|
+
<FormError error={error} />
|
|
91
102
|
</label>
|
|
92
103
|
);
|
|
93
|
-
}
|
|
94
|
-
styles);
|
|
104
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
@use "../../../scss/variables" as variables;
|
|
2
|
+
@use "../../../scss/designMixin" as mixin;
|
|
3
|
+
@use "../../../scss/vars" as *;
|
|
4
|
+
|
|
5
|
+
@include vars {
|
|
6
|
+
--select-background-color: transparent;
|
|
7
|
+
--select-text-color: var(--text-primary);
|
|
8
|
+
--select-background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTBweCIgaGVpZ2h0PSI1cHgiIHZpZXdCb3g9IjAgMCAxMCA1IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA0My4yICgzOTA2OSkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+CiAgICA8dGl0bGU+c2VsZWN0LWFsbG93PC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+PC9kZWZzPgogICAgPGcgaWQ9InNlbGVjdCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9Imlvcy1zZWxlY3QiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0xOTguMDAwMDAwLCAtMTE0LjAwMDAwMCkiIGZpbGw9IiM3NTc1NzUiPgogICAgICAgICAgICA8ZyBpZD0ibWVudS1iYXItKy1vcGVuLW1lbnUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEyMy4wMDAwMDAsIDEwMC4wMDAwMDApIj4KICAgICAgICAgICAgICAgIDxnIGlkPSJtZW51LWJhciI+CiAgICAgICAgICAgICAgICAgICAgPHBvbHlnb24gaWQ9InNlbGVjdC1hbGxvdyIgcG9pbnRzPSI3NSAxNCA4MCAxOSA4NSAxNCI+PC9wb2x5Z29uPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.select {
|
|
12
|
+
width: 100%;
|
|
13
|
+
|
|
14
|
+
.label {
|
|
15
|
+
font-weight: bold;
|
|
16
|
+
display: block;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.input {
|
|
20
|
+
outline: none;
|
|
21
|
+
background-color: var(--select-background-color);
|
|
22
|
+
height: 2rem;
|
|
23
|
+
line-height: 2rem;
|
|
24
|
+
color: var(--select-text-color);
|
|
25
|
+
appearance: none;
|
|
26
|
+
border: none;
|
|
27
|
+
border-radius: 0;
|
|
28
|
+
padding: 0 20px 0 0;
|
|
29
|
+
background-image: var(--select-background-image);
|
|
30
|
+
background-repeat: no-repeat;
|
|
31
|
+
|
|
32
|
+
&:focus {
|
|
33
|
+
outline: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@include mixin.design(variables.$material) {
|
|
37
|
+
-webkit-font-smoothing: antialiased;
|
|
38
|
+
font-size: 15px;
|
|
39
|
+
background-size: auto, 100% 1px;
|
|
40
|
+
background-position: right center, left bottom;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@include mixin.design(variables.$flat) {
|
|
44
|
+
font-size: 17px;
|
|
45
|
+
background-position: right center;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&.inline {
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
|
|
53
|
+
.label {
|
|
54
|
+
padding-right: 4px;
|
|
55
|
+
flex: 1;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&.small .input {
|
|
60
|
+
height: initial;
|
|
61
|
+
line-height: 1.5rem;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Slider } from '@/Components/FormElements/Slider/Slider';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
component: Slider,
|
|
7
|
+
} satisfies Meta<typeof Slider>;
|
|
8
|
+
|
|
9
|
+
export default meta;
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = {
|
|
14
|
+
args: {},
|
|
15
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import styles from './slider.scss';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useListenerWithExtractedProps } from '@/Components/Hooks/useListener';
|
|
4
|
+
import { useOnChangeDone } from '@/Components/FormElements/hooks/useOnChangeDone';
|
|
5
|
+
import { withMemo } from '@/helper/withMemo';
|
|
7
6
|
import classNames from 'classnames';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import styles from '@/Components/FormElements/Slider/slider.module.scss';
|
|
8
|
+
import type { ChangeEventHandler, InputHTMLAttributes, MutableRefObject } from 'react';
|
|
9
|
+
import type { OptionalListener } from '@/Components/Hooks/useListener';
|
|
10
|
+
import type { Override } from '@/TypeHelpers';
|
|
11
|
+
import type { RbmComponentProps } from '@/Components/RbmComponentProps';
|
|
11
12
|
|
|
12
13
|
export type SliderProps<OnChangeData, OnChangeValueData, OnChangeDoneData> = RbmComponentProps<
|
|
13
14
|
Override<
|
|
@@ -38,7 +39,7 @@ export const Slider = withMemo(function Slider<OnChangeData, OnChangeValueData,
|
|
|
38
39
|
// Callbacks
|
|
39
40
|
const [onChange, otherPropsWithoutOnchange] = useListenerWithExtractedProps<'onChange', OnChangeData>(
|
|
40
41
|
'onChange',
|
|
41
|
-
props
|
|
42
|
+
props,
|
|
42
43
|
);
|
|
43
44
|
|
|
44
45
|
const [onChangeValue, otherPropsWithoutOnChangeValue] = useListenerWithExtractedProps<
|
|
@@ -48,7 +49,7 @@ export const Slider = withMemo(function Slider<OnChangeData, OnChangeValueData,
|
|
|
48
49
|
|
|
49
50
|
const [onChangeDone, otherPropsWithoutData] = useListenerWithExtractedProps<'onChangeDone', OnChangeDoneData>(
|
|
50
51
|
'onChangeDone',
|
|
51
|
-
otherPropsWithoutOnChangeValue
|
|
52
|
+
otherPropsWithoutOnChangeValue,
|
|
52
53
|
);
|
|
53
54
|
|
|
54
55
|
const innerOnChange = useCallback<ChangeEventHandler<HTMLInputElement>>(
|
|
@@ -56,25 +57,34 @@ export const Slider = withMemo(function Slider<OnChangeData, OnChangeValueData,
|
|
|
56
57
|
onChangeValue(Number(e.target.value));
|
|
57
58
|
onChange(e);
|
|
58
59
|
},
|
|
59
|
-
[onChange, onChangeValue]
|
|
60
|
+
[onChange, onChangeValue],
|
|
60
61
|
);
|
|
61
62
|
|
|
62
|
-
const checkStopPropagation = useCallback(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
const checkStopPropagation = useCallback(
|
|
64
|
+
(ev: React.MouseEvent) => {
|
|
65
|
+
if (stopPropagation) {
|
|
66
|
+
ev.stopPropagation();
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
[stopPropagation],
|
|
70
|
+
);
|
|
67
71
|
|
|
68
72
|
// Effects
|
|
69
|
-
const innerRef = useOnChangeDone(onChangeDone) as MutableRefObject<HTMLInputElement|null>;
|
|
73
|
+
const innerRef = useOnChangeDone(onChangeDone) as MutableRefObject<HTMLInputElement | null>;
|
|
70
74
|
|
|
71
75
|
// Other
|
|
72
76
|
|
|
73
77
|
// Render Functions
|
|
74
78
|
|
|
75
79
|
return (
|
|
80
|
+
// The label has an input-area-element. This is okay
|
|
76
81
|
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
77
|
-
<label
|
|
82
|
+
<label
|
|
83
|
+
role="none"
|
|
84
|
+
className={classNames(styles.slider, className)}
|
|
85
|
+
style={style}
|
|
86
|
+
onClick={checkStopPropagation}
|
|
87
|
+
>
|
|
78
88
|
<input
|
|
79
89
|
type="range"
|
|
80
90
|
{...otherPropsWithoutData}
|
|
@@ -84,5 +94,4 @@ export const Slider = withMemo(function Slider<OnChangeData, OnChangeValueData,
|
|
|
84
94
|
/>
|
|
85
95
|
</label>
|
|
86
96
|
);
|
|
87
|
-
}
|
|
88
|
-
styles);
|
|
97
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
@use "../../../scss/vars" as *;
|
|
2
|
+
|
|
3
|
+
$thumbHeight: 16;
|
|
4
|
+
$thumbWidth: 16;
|
|
5
|
+
$trackHeight: calc($thumbHeight / 4);
|
|
6
|
+
$maxScreenSize: 10000;
|
|
7
|
+
|
|
8
|
+
@include vars {
|
|
9
|
+
--slider-thumb-height: #{$thumbHeight}px;
|
|
10
|
+
--slider-thumb-width: #{$thumbWidth}px;
|
|
11
|
+
--slider-track-height: calc(var(--slider-thumb-height) / 4);
|
|
12
|
+
--slider-track-color: var(--border-light);
|
|
13
|
+
--slider-active-track-color: var(--flavor-accent);
|
|
14
|
+
--slider-thumb-color: var(--flavor-accent);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.slider {
|
|
18
|
+
width: 100%;
|
|
19
|
+
|
|
20
|
+
.input {
|
|
21
|
+
position: relative;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
appearance: none;
|
|
25
|
+
width: 100%;
|
|
26
|
+
background: transparent;
|
|
27
|
+
transition: all ease 100ms;
|
|
28
|
+
height: var(--slider-thumb-height);
|
|
29
|
+
|
|
30
|
+
&:active {
|
|
31
|
+
cursor: grabbing;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@mixin track {
|
|
35
|
+
appearance: none;
|
|
36
|
+
transition: all ease 100ms;
|
|
37
|
+
height: var(--slider-thumb-height);
|
|
38
|
+
position: relative;
|
|
39
|
+
width: 100%;
|
|
40
|
+
border-radius: var(--slider-track-height);
|
|
41
|
+
background: linear-gradient(var(--slider-track-color) 0 0) scroll no-repeat center / 100% calc(var(--slider-track-height) + 1px);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@mixin thumb {
|
|
45
|
+
appearance: none;
|
|
46
|
+
width: var(--slider-thumb-width);
|
|
47
|
+
transition: all ease 100ms;
|
|
48
|
+
height: var(--slider-thumb-height);
|
|
49
|
+
background: var(--slider-thumb-color);
|
|
50
|
+
position: relative;
|
|
51
|
+
border: 0;
|
|
52
|
+
border-radius: var(--slider-thumb-width);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&::-webkit-slider-runnable-track {
|
|
56
|
+
@include track;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&::-webkit-slider-thumb {
|
|
60
|
+
@include thumb;
|
|
61
|
+
|
|
62
|
+
box-shadow: calc(-100vmax - (var(--slider-thumb-width, var(--slider-thumb-height)) / 2)) 0 0 100vmax var(--slider-active-track-color);
|
|
63
|
+
|
|
64
|
+
$clipTop: calc(($thumbHeight - $trackHeight) / 2);
|
|
65
|
+
$clipBottom: $thumbHeight - $clipTop;
|
|
66
|
+
|
|
67
|
+
clip-path: path("M 0, #{0.5 * $thumbHeight} \
|
|
68
|
+
a #{0.5 * $thumbWidth} #{0.5 * $thumbHeight}, 0 1 0, #{$thumbWidth} 0 \
|
|
69
|
+
a #{0.5 * $thumbWidth} #{0.5 * $thumbHeight}, 0 1 0, #{-1 * $thumbWidth} 0 \
|
|
70
|
+
L #{0.5 * $thumbWidth} #{$clipTop} \
|
|
71
|
+
L #{-1 * $maxScreenSize} #{$clipTop} \
|
|
72
|
+
L #{-1 * $maxScreenSize} #{$clipBottom} \
|
|
73
|
+
L #{0.5 * $thumbWidth} #{$clipBottom} \
|
|
74
|
+
z");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&::-moz-range-thumb {
|
|
78
|
+
@include thumb;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&::-moz-range-track {
|
|
82
|
+
@include track;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&::-moz-range-progress {
|
|
86
|
+
appearance: none;
|
|
87
|
+
background: var(--slider-active-track-color);
|
|
88
|
+
transition-delay: 30ms;
|
|
89
|
+
height: var(--slider-track-height);
|
|
90
|
+
border-radius: var(--slider-track-height);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Switch } from '@/Components/FormElements/Switch/Switch';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
component: Switch,
|
|
8
|
+
} satisfies Meta<typeof Switch>;
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
args: {
|
|
16
|
+
label: 'Label',
|
|
17
|
+
preLabel: '',
|
|
18
|
+
isLabelBeforeSwitch: false,
|
|
19
|
+
isDual: false,
|
|
20
|
+
error: '',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Error: Story = {
|
|
25
|
+
args: {
|
|
26
|
+
label: 'Label',
|
|
27
|
+
preLabel: '',
|
|
28
|
+
isLabelBeforeSwitch: false,
|
|
29
|
+
isDual: false,
|
|
30
|
+
error: 'Wrong Value',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const LabelBefore: Story = {
|
|
35
|
+
args: {
|
|
36
|
+
label: 'Label',
|
|
37
|
+
preLabel: '',
|
|
38
|
+
isLabelBeforeSwitch: true,
|
|
39
|
+
isDual: false,
|
|
40
|
+
error: '',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const DualLabel: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
label: 'Label',
|
|
47
|
+
preLabel: 'Pre Label',
|
|
48
|
+
isLabelBeforeSwitch: false,
|
|
49
|
+
isDual: false,
|
|
50
|
+
error: '',
|
|
51
|
+
},
|
|
52
|
+
render: (args) => (
|
|
53
|
+
<>
|
|
54
|
+
<div>
|
|
55
|
+
<Switch {...args} checked={false} />
|
|
56
|
+
</div>
|
|
57
|
+
<div style={{ marginTop: '1rem', marginBottom: '1rem' }}>
|
|
58
|
+
<Switch {...args} checked={true} />
|
|
59
|
+
</div>
|
|
60
|
+
<div>
|
|
61
|
+
<Switch {...args} isDual={true} />
|
|
62
|
+
</div>
|
|
63
|
+
</>
|
|
64
|
+
),
|
|
65
|
+
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { FormError } from '@/Components/FormElements/Error/FormError';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useListenerWithExtractedProps } from '@/Components/Hooks/useListener';
|
|
5
|
+
import { withMemo } from '@/helper/withMemo';
|
|
5
6
|
import classNames from 'classnames';
|
|
6
|
-
import styles from '
|
|
7
|
-
import {
|
|
8
|
-
import { OptionalListener
|
|
9
|
-
import {
|
|
7
|
+
import styles from '@/Components/FormElements/Switch/switch.module.scss';
|
|
8
|
+
import type { ChangeEventHandler, InputHTMLAttributes, MouseEvent } from 'react';
|
|
9
|
+
import type { OptionalListener } from '@/Components/Hooks/useListener';
|
|
10
|
+
import type { Override } from '@/TypeHelpers';
|
|
11
|
+
import type { RbmComponentProps } from '@/Components/RbmComponentProps';
|
|
10
12
|
|
|
11
13
|
export type SwitchProps<OnChangeCheckedData> = RbmComponentProps<
|
|
12
14
|
Override<
|
|
@@ -21,78 +23,85 @@ export type SwitchProps<OnChangeCheckedData> = RbmComponentProps<
|
|
|
21
23
|
classNameLabel?: string;
|
|
22
24
|
classNamePreLabel?: string;
|
|
23
25
|
stopPropagation?: boolean;
|
|
24
|
-
} & OptionalListener<
|
|
26
|
+
} & OptionalListener<'onChangeChecked', OnChangeCheckedData, boolean>
|
|
25
27
|
>
|
|
26
28
|
>;
|
|
27
29
|
|
|
28
30
|
export const Switch = withMemo(function Switch<OnChangeCheckedData>({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
children,
|
|
32
|
+
label = '',
|
|
33
|
+
preLabel = '',
|
|
34
|
+
isLabelBeforeSwitch = false,
|
|
35
|
+
isDual = undefined,
|
|
36
|
+
stopPropagation = true,
|
|
37
|
+
id,
|
|
38
|
+
className,
|
|
39
|
+
classNamePreLabel,
|
|
40
|
+
classNameLabel,
|
|
41
|
+
style,
|
|
42
|
+
error,
|
|
43
|
+
onChange,
|
|
44
|
+
...props
|
|
45
|
+
}: SwitchProps<OnChangeCheckedData>) {
|
|
46
|
+
// Variables
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
// States
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
// Refs
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
// Callbacks
|
|
53
|
+
const [onChangeChecked, otherProps] = useListenerWithExtractedProps('onChangeChecked', props);
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
const realOnChange = useCallback<ChangeEventHandler<HTMLInputElement>>(
|
|
56
|
+
(e) => {
|
|
57
|
+
onChange?.(e);
|
|
58
|
+
onChangeChecked(e.target.checked);
|
|
59
|
+
},
|
|
60
|
+
[onChange, onChangeChecked],
|
|
61
|
+
);
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
const checkStopPropagation = useCallback(
|
|
64
|
+
(ev: MouseEvent) => {
|
|
62
65
|
if (stopPropagation) {
|
|
63
66
|
ev.stopPropagation();
|
|
64
67
|
ev.nativeEvent.stopPropagation();
|
|
65
68
|
}
|
|
66
|
-
},
|
|
69
|
+
},
|
|
70
|
+
[stopPropagation],
|
|
71
|
+
);
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
// Effects
|
|
69
74
|
|
|
70
|
-
|
|
75
|
+
// Other
|
|
71
76
|
|
|
72
|
-
|
|
77
|
+
// Render Functions
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
if (React.Children.count(children) === 1 && typeof children === 'string') {
|
|
80
|
+
label = children;
|
|
81
|
+
}
|
|
77
82
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
if (isLabelBeforeSwitch) {
|
|
84
|
+
[label, preLabel] = [preLabel, label];
|
|
85
|
+
}
|
|
81
86
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
if (label && preLabel && isDual === undefined) {
|
|
88
|
+
isDual = true;
|
|
89
|
+
}
|
|
90
|
+
return (
|
|
91
|
+
<span
|
|
92
|
+
className={classNames(styles.switch, { [styles.dual]: isDual }, className)}
|
|
93
|
+
style={style}
|
|
94
|
+
onClick={checkStopPropagation}
|
|
95
|
+
>
|
|
96
|
+
<label htmlFor={id} key={id}>
|
|
97
|
+
<span className={classNames(styles.label, classNamePreLabel)}>{preLabel}</span>
|
|
98
|
+
<input {...otherProps} type="checkbox" id={id} onChange={realOnChange} />
|
|
99
|
+
<div className={styles.toggle}>
|
|
100
|
+
<span className={styles.handle} />
|
|
101
|
+
</div>
|
|
102
|
+
<span className={classNames(styles.label, classNameLabel)}>{label}</span>
|
|
103
|
+
<FormError error={error} />
|
|
104
|
+
</label>
|
|
105
|
+
</span>
|
|
106
|
+
);
|
|
107
|
+
});
|