@modul/mbui 0.0.1-beta-pv-50528-277b7dcf → 0.0.2-beta-storybook-9d462616
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/package.json +15 -4
- package/src/DatePicker/DatePicker.styl +5 -0
- package/src/DatePicker/index.tsx +1 -0
- package/src/index.ts +1 -3
- package/src/stories/DatePicker/DatePicker.stories.tsx +47 -0
- package/src/stories/Input/Input.stories.tsx +30 -0
- package/src/Popup/BaseModal.tsx +0 -53
- package/src/Popup/Popup.tsx +0 -45
- package/src/Popup/index.ts +0 -3
- package/src/Popup/types.ts +0 -16
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modul/mbui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-beta-storybook-9d462616",
|
|
4
4
|
"packageManager": "yarn@3.5.1",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build:demo": "webpack --config ./demo/webpack.config.js",
|
|
8
8
|
"dev:demo": "webpack serve --config ./demo/webpack.config.js --open",
|
|
9
|
-
"demo": "yarn dlx http-server demo/dist -so -c-1"
|
|
9
|
+
"demo": "yarn dlx http-server demo/dist -so -c-1",
|
|
10
|
+
"storybook": "storybook dev -p 6006",
|
|
11
|
+
"build:storybook": "storybook build"
|
|
10
12
|
},
|
|
11
13
|
"lintConfig": "./.eslintrc.json",
|
|
12
14
|
"files": [
|
|
@@ -14,14 +16,21 @@
|
|
|
14
16
|
],
|
|
15
17
|
"dependencies": {
|
|
16
18
|
"react-datepicker": "4.16.0",
|
|
17
|
-
"react-imask": "7.1.3"
|
|
18
|
-
"react-modal": "3.16.1"
|
|
19
|
+
"react-imask": "7.1.3"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@babel/core": "^7.9.0",
|
|
22
23
|
"@babel/preset-env": "^7.9.5",
|
|
23
24
|
"@babel/preset-react": "^7.9.4",
|
|
24
25
|
"@babel/preset-typescript": "^7.21.5",
|
|
26
|
+
"@storybook/addon-essentials": "^7.4.0",
|
|
27
|
+
"@storybook/addon-interactions": "^7.4.0",
|
|
28
|
+
"@storybook/addon-links": "^7.4.0",
|
|
29
|
+
"@storybook/addon-onboarding": "^1.0.8",
|
|
30
|
+
"@storybook/blocks": "^7.4.0",
|
|
31
|
+
"@storybook/react": "^7.4.0",
|
|
32
|
+
"@storybook/react-webpack5": "^7.4.0",
|
|
33
|
+
"@storybook/testing-library": "^0.2.0",
|
|
25
34
|
"@types/node": "^20.1.4",
|
|
26
35
|
"@types/react": "^18.2.6",
|
|
27
36
|
"@types/react-datepicker": "4.15.0",
|
|
@@ -43,11 +52,13 @@
|
|
|
43
52
|
"eslint-plugin-prettier": "4.2.1",
|
|
44
53
|
"eslint-plugin-react": "7.31.10",
|
|
45
54
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
55
|
+
"eslint-plugin-storybook": "^0.6.13",
|
|
46
56
|
"glob": "^10.2.4",
|
|
47
57
|
"html-webpack-plugin": "5.5.1",
|
|
48
58
|
"prettier": "2.7.1",
|
|
49
59
|
"react": "18.2.0",
|
|
50
60
|
"react-dom": "^18.2.0",
|
|
61
|
+
"storybook": "^7.4.0",
|
|
51
62
|
"style-loader": "^3.3.3",
|
|
52
63
|
"stylus": "^0.59.0",
|
|
53
64
|
"stylus-loader": "^7.1.3",
|
package/src/DatePicker/index.tsx
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,7 +2,5 @@ import { Button } from './Base/Buttons'
|
|
|
2
2
|
import { TextLink } from './Base/Links'
|
|
3
3
|
import { DatePicker } from './DatePicker'
|
|
4
4
|
import { Input } from './Base/Input'
|
|
5
|
-
//
|
|
6
|
-
import { Popup } from './Popup'
|
|
7
5
|
|
|
8
|
-
export { Button, TextLink, DatePicker, Input
|
|
6
|
+
export { Button, TextLink, DatePicker, Input }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
3
|
+
import { DatePicker } from '../../DatePicker'
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof DatePicker> = {
|
|
6
|
+
component: DatePicker,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default meta
|
|
10
|
+
type Story = StoryObj<typeof DatePicker>
|
|
11
|
+
|
|
12
|
+
const DefaultDatePickerWrapper = (props) => {
|
|
13
|
+
const [startDate, setStartDate] = useState(new Date())
|
|
14
|
+
return (
|
|
15
|
+
<DatePicker
|
|
16
|
+
selected={startDate}
|
|
17
|
+
locale='ru-RU'
|
|
18
|
+
onChange={(date) => setStartDate(date)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
export const Default: Story = {
|
|
24
|
+
args: {
|
|
25
|
+
dateFormat: 'dd.MM.yyyy',
|
|
26
|
+
disabled: false,
|
|
27
|
+
dateFormatCalendar: 'dd.MM.yyyy',
|
|
28
|
+
},
|
|
29
|
+
render: (args) => <DefaultDatePickerWrapper {...args} />,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const TimePicker: Story = {
|
|
33
|
+
args: {
|
|
34
|
+
...Default.args,
|
|
35
|
+
dateFormat: 'hh:mm',
|
|
36
|
+
timeCaption: 'Выберите время:',
|
|
37
|
+
timeIntervals: 30,
|
|
38
|
+
timeFormat: 'hh:mm',
|
|
39
|
+
},
|
|
40
|
+
render: (args) => (
|
|
41
|
+
<DefaultDatePickerWrapper
|
|
42
|
+
showTimeSelect
|
|
43
|
+
showTimeSelectOnly
|
|
44
|
+
{...args}
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
3
|
+
import { Input } from '../../Base/Input'
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Input> = {
|
|
6
|
+
component: Input,
|
|
7
|
+
}
|
|
8
|
+
type Story = StoryObj<typeof Input>
|
|
9
|
+
|
|
10
|
+
const DefaultInputWrapper = (props) => {
|
|
11
|
+
const [val, setVal] = useState<string>('')
|
|
12
|
+
return (
|
|
13
|
+
<Input
|
|
14
|
+
value={val}
|
|
15
|
+
onChange={(e) => setVal(e)}
|
|
16
|
+
type="text"
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
disabled: false,
|
|
25
|
+
placeholder: 'placeholder...',
|
|
26
|
+
},
|
|
27
|
+
render: (args) => <DefaultInputWrapper {...args} />,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default meta
|
package/src/Popup/BaseModal.tsx
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames'
|
|
2
|
-
import React, { FC } from 'react'
|
|
3
|
-
import Modal from 'react-modal'
|
|
4
|
-
import { IBaseModal } from './types'
|
|
5
|
-
|
|
6
|
-
const BaseModal: FC<IBaseModal> = ({
|
|
7
|
-
shouldCloseOnOverlayClick = true,
|
|
8
|
-
children,
|
|
9
|
-
isOpen,
|
|
10
|
-
appElement,
|
|
11
|
-
onAfterOpen,
|
|
12
|
-
onRequestClose,
|
|
13
|
-
overlayClassName,
|
|
14
|
-
}) => {
|
|
15
|
-
const handleOverlayOnClick = () => {
|
|
16
|
-
if (shouldCloseOnOverlayClick) {
|
|
17
|
-
onRequestClose?.()
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//FIXME: из-за portalCreate у нас события клика всплывают с модального окна в компонент где он был замуонтин
|
|
22
|
-
const preventEvents = (e: React.MouseEvent) => {
|
|
23
|
-
e.stopPropagation()
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const overlayClasses = classNames('popup_overlay', overlayClassName)
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Modal
|
|
30
|
-
isOpen={isOpen}
|
|
31
|
-
contentLabel=""
|
|
32
|
-
appElement={appElement}
|
|
33
|
-
onRequestClose={onRequestClose}
|
|
34
|
-
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
|
|
35
|
-
onAfterOpen={onAfterOpen}
|
|
36
|
-
className="popup_table"
|
|
37
|
-
overlayClassName={overlayClasses}
|
|
38
|
-
>
|
|
39
|
-
<div
|
|
40
|
-
className="popup_cell"
|
|
41
|
-
onClick={preventEvents}
|
|
42
|
-
>
|
|
43
|
-
{children}
|
|
44
|
-
<div
|
|
45
|
-
className="popup_backdrop"
|
|
46
|
-
onClick={handleOverlayOnClick}
|
|
47
|
-
/>
|
|
48
|
-
</div>
|
|
49
|
-
</Modal>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export default BaseModal
|
package/src/Popup/Popup.tsx
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react'
|
|
2
|
-
import BaseModal from './BaseModal'
|
|
3
|
-
import { IPopup } from './types'
|
|
4
|
-
|
|
5
|
-
const Popup: FC<IPopup> = ({
|
|
6
|
-
shouldCloseOnOverlayClick = true,
|
|
7
|
-
children,
|
|
8
|
-
isOpen,
|
|
9
|
-
appElement = document.getElementsByTagName('body')[0],
|
|
10
|
-
onAfterOpen,
|
|
11
|
-
onRequestClose,
|
|
12
|
-
overlayClassName,
|
|
13
|
-
layerClassName,
|
|
14
|
-
disableClose,
|
|
15
|
-
...props
|
|
16
|
-
}) => {
|
|
17
|
-
const handleRequestClose = () => {
|
|
18
|
-
onRequestClose()
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const classNames = ['popup_layer', layerClassName || ''].join(' ')
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<BaseModal
|
|
25
|
-
{...props}
|
|
26
|
-
isOpen={isOpen}
|
|
27
|
-
appElement={appElement}
|
|
28
|
-
onAfterOpen={onAfterOpen}
|
|
29
|
-
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
|
|
30
|
-
onRequestClose={handleRequestClose}
|
|
31
|
-
>
|
|
32
|
-
<div className={classNames}>
|
|
33
|
-
{!disableClose && (
|
|
34
|
-
<button
|
|
35
|
-
className="popup_close icon-close"
|
|
36
|
-
onClick={handleRequestClose}
|
|
37
|
-
/>
|
|
38
|
-
)}
|
|
39
|
-
{children}
|
|
40
|
-
</div>
|
|
41
|
-
</BaseModal>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default Popup
|
package/src/Popup/index.ts
DELETED
package/src/Popup/types.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
export interface IBaseModal {
|
|
4
|
-
isOpen: boolean //modal state
|
|
5
|
-
shouldCloseOnOverlayClick?: boolean // When shouldCloseOnOverlayClick is true. it requires the onRequestClose to be defined in order to close.
|
|
6
|
-
children?: ReactNode
|
|
7
|
-
appElement?: object
|
|
8
|
-
onAfterOpen?: () => void // This event helps to trigger a function just after the modal opens
|
|
9
|
-
onRequestClose?: () => void
|
|
10
|
-
overlayClassName?: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface IPopup extends IBaseModal {
|
|
14
|
-
layerClassName?: string
|
|
15
|
-
disableClose?: boolean
|
|
16
|
-
}
|