@simplybusiness/mobius 4.0.0-beta.9 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -1
- package/dist/cjs/components/Button/Button.d.ts +1 -1
- package/dist/cjs/components/Button/Button.js +1 -1
- package/dist/cjs/components/Button/Button.js.map +1 -1
- package/dist/cjs/components/Button/Button.stories.js +12 -12
- package/dist/cjs/components/Button/Button.stories.js.map +1 -1
- package/dist/cjs/components/Drawer/Content.d.ts +11 -0
- package/dist/cjs/components/Drawer/Content.js +41 -0
- package/dist/cjs/components/Drawer/Content.js.map +1 -0
- package/dist/cjs/components/Drawer/Drawer.d.ts +22 -0
- package/dist/cjs/components/Drawer/Drawer.js +98 -0
- package/dist/cjs/components/Drawer/Drawer.js.map +1 -0
- package/dist/cjs/components/Drawer/Drawer.stories.d.ts +27 -0
- package/dist/cjs/components/Drawer/Drawer.stories.js +53 -0
- package/dist/cjs/components/Drawer/Drawer.stories.js.map +1 -0
- package/dist/cjs/components/Drawer/Drawer.test.d.ts +1 -0
- package/dist/cjs/components/Drawer/Drawer.test.js +123 -0
- package/dist/cjs/components/Drawer/Drawer.test.js.map +1 -0
- package/dist/cjs/components/Drawer/Header.d.ts +11 -0
- package/dist/cjs/components/Drawer/Header.js +32 -0
- package/dist/cjs/components/Drawer/Header.js.map +1 -0
- package/dist/cjs/components/Drawer/index.d.ts +12 -0
- package/dist/cjs/components/Drawer/index.js +13 -0
- package/dist/cjs/components/Drawer/index.js.map +1 -0
- package/dist/cjs/components/Flex/Flex.stories.js +8 -13
- package/dist/cjs/components/Flex/Flex.stories.js.map +1 -1
- package/dist/cjs/components/Grid/Grid.stories.js +11 -16
- package/dist/cjs/components/Grid/Grid.stories.js.map +1 -1
- package/dist/cjs/components/Icon/Icon.js +1 -2
- package/dist/cjs/components/Icon/Icon.js.map +1 -1
- package/dist/cjs/components/Icon/Icon.stories.js +1 -1
- package/dist/cjs/components/Icon/types.d.ts +1 -1
- package/dist/cjs/components/LinkButton/LinkButton.stories.js +1 -1
- package/dist/cjs/components/LinkButton/LinkButton.stories.js.map +1 -1
- package/dist/cjs/components/LoadingIndicator/LoadingIndicator.stories.js +1 -5
- package/dist/cjs/components/LoadingIndicator/LoadingIndicator.stories.js.map +1 -1
- package/dist/cjs/components/Modal/Modal.js +24 -23
- package/dist/cjs/components/Modal/Modal.js.map +1 -1
- package/dist/cjs/components/Modal/Modal.stories.d.ts +2 -0
- package/dist/cjs/components/Modal/Modal.stories.js +18 -1
- package/dist/cjs/components/Modal/Modal.stories.js.map +1 -1
- package/dist/cjs/components/Modal/Modal.test.js +34 -20
- package/dist/cjs/components/Modal/Modal.test.js.map +1 -1
- package/dist/cjs/components/Radio/Radio.stories.js +1 -1
- package/dist/cjs/components/Segment/Segment.stories.js +11 -13
- package/dist/cjs/components/Segment/Segment.stories.js.map +1 -1
- package/dist/cjs/components/Segment/SegmentGroup.d.ts +1 -1
- package/dist/cjs/components/Segment/SegmentGroup.js.map +1 -1
- package/dist/cjs/components/Text/Text.d.ts +2 -2
- package/dist/cjs/components/Text/Text.js +1 -1
- package/dist/cjs/components/Text/Text.js.map +1 -1
- package/dist/cjs/components/Text/Text.stories.js +2 -2
- package/dist/cjs/components/Text/Text.stories.js.map +1 -1
- package/dist/cjs/components/Text/Text.test.js +2 -2
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/index.js +2 -0
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/useBodyScrollLock/useBodyScrollLock.js +5 -0
- package/dist/cjs/hooks/useBodyScrollLock/useBodyScrollLock.js.map +1 -1
- package/dist/cjs/hooks/useOnClickOutside/index.js.map +1 -1
- package/dist/cjs/hooks/useOnClickOutside/useOnClickOutside.d.ts +1 -1
- package/dist/cjs/hooks/useOnClickOutside/useOnClickOutside.js +11 -0
- package/dist/cjs/hooks/useOnClickOutside/useOnClickOutside.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/utils/jestHTMLDialogPolyfill.js.map +1 -0
- package/dist/esm/components/Button/Button.js +1 -1
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/esm/components/Drawer/Content.js +35 -0
- package/dist/esm/components/Drawer/Content.js.map +1 -0
- package/dist/esm/components/Drawer/Drawer.js +69 -0
- package/dist/esm/components/Drawer/Drawer.js.map +1 -0
- package/dist/esm/components/Drawer/Header.js +26 -0
- package/dist/esm/components/Drawer/Header.js.map +1 -0
- package/dist/esm/components/Drawer/index.js +10 -0
- package/dist/esm/components/Drawer/index.js.map +1 -0
- package/dist/esm/components/Icon/Icon.js +1 -2
- package/dist/esm/components/Icon/Icon.js.map +1 -1
- package/dist/esm/components/Modal/Modal.js +24 -23
- package/dist/esm/components/Modal/Modal.js.map +1 -1
- package/dist/esm/components/Segment/SegmentGroup.js.map +1 -1
- package/dist/esm/components/Text/Text.js +1 -1
- package/dist/esm/components/Text/Text.js.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/hooks/index.js +2 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useBodyScrollLock/useBodyScrollLock.js +5 -0
- package/dist/esm/hooks/useBodyScrollLock/useBodyScrollLock.js.map +1 -1
- package/dist/esm/hooks/useOnClickOutside/index.js.map +1 -1
- package/dist/esm/hooks/useOnClickOutside/useOnClickOutside.js +11 -0
- package/dist/esm/hooks/useOnClickOutside/useOnClickOutside.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/utils/jestHTMLDialogPolyfill.js.map +1 -0
- package/dist/mobius.d.ts +51 -5
- package/package.json +2 -2
- package/src/components/Button/Button.mdx +7 -7
- package/src/components/Button/Button.stories.tsx +12 -12
- package/src/components/Button/Button.story.styles.css +1 -1
- package/src/components/Button/Button.tsx +2 -2
- package/src/components/Checkbox/Checkbox.mdx +4 -1
- package/src/components/Drawer/Content.tsx +46 -0
- package/src/components/Drawer/Drawer.mdx +132 -0
- package/src/components/Drawer/Drawer.stories.tsx +172 -0
- package/src/components/Drawer/Drawer.test.tsx +218 -0
- package/src/components/Drawer/Drawer.tsx +139 -0
- package/src/components/Drawer/Header.tsx +45 -0
- package/src/components/Drawer/index.tsx +27 -0
- package/src/components/Flex/Flex.mdx +18 -23
- package/src/components/Flex/Flex.stories.tsx +8 -13
- package/src/components/Grid/Grid.mdx +13 -18
- package/src/components/Grid/Grid.stories.tsx +11 -16
- package/src/components/Icon/Icon.stories.tsx +1 -1
- package/src/components/Icon/Icon.tsx +1 -1
- package/src/components/Icon/types.ts +1 -17
- package/src/components/LinkButton/LinkButton.stories.tsx +1 -1
- package/src/components/LoadingIndicator/LoadingIndicator.stories.tsx +2 -6
- package/src/components/Modal/Modal.mdx +52 -5
- package/src/components/Modal/Modal.stories.tsx +53 -0
- package/src/components/Modal/Modal.test.tsx +49 -24
- package/src/components/Modal/Modal.tsx +35 -29
- package/src/components/Progress/Progress.mdx +3 -3
- package/src/components/Radio/Radio.mdx +5 -2
- package/src/components/Radio/Radio.stories.tsx +1 -1
- package/src/components/Segment/Segment.mdx +22 -24
- package/src/components/Segment/Segment.stories.tsx +22 -24
- package/src/components/Segment/SegmentGroup.tsx +1 -9
- package/src/components/Text/Text.stories.tsx +3 -5
- package/src/components/Text/Text.test.tsx +2 -2
- package/src/components/Text/Text.tsx +3 -13
- package/src/components/index.tsx +1 -0
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/useBodyScrollLock/useBodyScrollLock.ts +5 -0
- package/src/hooks/useOnClickOutside/{useOnClickOutside.ts → useOnClickOutside.tsx} +16 -2
- package/dist/cjs/components/Modal/jestHTMLDialogPolyfill.js.map +0 -1
- package/dist/esm/components/Modal/jestHTMLDialogPolyfill.js.map +0 -1
- /package/dist/cjs/{components/Modal → utils}/jestHTMLDialogPolyfill.d.ts +0 -0
- /package/dist/cjs/{components/Modal → utils}/jestHTMLDialogPolyfill.js +0 -0
- /package/dist/esm/{components/Modal → utils}/jestHTMLDialogPolyfill.js +0 -0
- /package/src/hooks/useOnClickOutside/{index.ts → index.tsx} +0 -0
- /package/src/{components/Modal → utils}/jestHTMLDialogPolyfill.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,11 +5,43 @@ All notable changes to this project will be documented in this file, or link in
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## 4.0.0
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Fixed body content jumping when Modal/Drawer shown
|
|
9
13
|
|
|
10
14
|
### Added
|
|
11
15
|
|
|
12
16
|
- `useBreakPoint` hook supports initialisation with custom breakpoints array.
|
|
17
|
+
- `Drawer` atom provides a modal panel that enters screen from left, top, right or bottom.
|
|
18
|
+
- To match refined design guidelines in Figma, SB theme colour palette has been updated with the following additions: `--color-azure-300`, `--color-azure-400`, `--color-azure-700`
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Replace `<DatePicker>` with lighter alternative
|
|
23
|
+
- Use `--font-family` instead of `--font-family-body` and `--font-family-heading` as it's one font now
|
|
24
|
+
- Adjust font size variables to match Figma
|
|
25
|
+
- Rename `--line-height-loose` to `--line-height-normal` to match naming of other variables; reduce line-height from 1.7 to 1.5 as per Figma
|
|
26
|
+
- Increase `--line-height-tight` from 1.2 to 1.333 to match Figma
|
|
27
|
+
- Rename `caption` variant to `small` to reflect Figma
|
|
28
|
+
- Adjust default `<Link>` styles to match Figma
|
|
29
|
+
- Replace size-0 through to size-100 with size-xs through to size-xxl variables as per new design guidelines from the UX
|
|
30
|
+
- Change `<Icon>` size prop to only support Figma sizes - `xs`, `sm`, `md`, `lg`
|
|
31
|
+
- Change `<Button>` size prop from `small`, `medium`, `large` to `sm`, `md`, `lg`
|
|
32
|
+
- Modal and Drawer support nesting; only the topmost dialog is closed or cancelled.
|
|
33
|
+
- Load react-day-picker only on non-touch devices as for mobile `<input type="date">` is used instead. This is to optimise component performance and reduce unnecessary kilobytes when using touch devices
|
|
34
|
+
|
|
35
|
+
### Removed
|
|
36
|
+
|
|
37
|
+
- To match refined design guidelines in Figma, SB theme colour palette has been updated with the following removed: `--color-neutral-400`, `--color-bubblegum-600`, `--color-bubblegum-700`
|
|
38
|
+
- Remove `lead` variant from `<Text>` as it's no longer used
|
|
39
|
+
- Remove unused Museo Sans Rounded font as it's no longer used
|
|
40
|
+
- Remove unused Museo Sans weights 100, 300 and 900 as they're no longer used
|
|
41
|
+
- Remove `--font-weight-light` in favour of `--font-weight-normal` as they're both of the same weight - 500
|
|
42
|
+
- Remove `--line-height-single` in favour of `--line-height-normal` to match predefined line heights in Figma
|
|
43
|
+
- Remove default font size changes on breakpoints for h1, h2, h3
|
|
44
|
+
- Remove unused h5, h6 variants
|
|
13
45
|
|
|
14
46
|
## [4.0.0-beta.3] - 2023-11-09
|
|
15
47
|
|
|
@@ -400,6 +432,7 @@ Additionally, mobius and themes are available on the public NPM registry and can
|
|
|
400
432
|
|
|
401
433
|
## Github Links
|
|
402
434
|
|
|
435
|
+
[4.0.0]: https://github.com/simplybusiness/mobius/releases/tag/v4.0.0
|
|
403
436
|
[3.12.2]: https://github.com/simplybusiness/mobius/releases/tag/v3.12.2
|
|
404
437
|
[3.12.1]: https://github.com/simplybusiness/mobius/releases/tag/v3.12.1
|
|
405
438
|
[3.12.0]: https://github.com/simplybusiness/mobius/releases/tag/v3.12.0
|
|
@@ -4,7 +4,7 @@ import { ForwardedRefComponent } from "../../types/components";
|
|
|
4
4
|
import { UseButtonProps } from "../../hooks/useButton";
|
|
5
5
|
export type ButtonElementType = HTMLButtonElement;
|
|
6
6
|
export type Variant = "primary" | "secondary" | "ghost" | "inverse" | "inverse-ghost" | "basic";
|
|
7
|
-
export type Size = "
|
|
7
|
+
export type Size = "sm" | "md" | "lg";
|
|
8
8
|
export interface ButtonProps extends UseButtonProps, DOMProps, RefAttributes<ButtonElementType> {
|
|
9
9
|
/** Custom class name for setting specific CSS */
|
|
10
10
|
className?: string;
|
|
@@ -23,7 +23,7 @@ const Loading_1 = require("./Loading");
|
|
|
23
23
|
const useButton_1 = require("../../hooks/useButton");
|
|
24
24
|
let HAS_DEPRECATION_WARNING_SHOWN = false;
|
|
25
25
|
const Button = (0, react_1.forwardRef)((props, ref) => {
|
|
26
|
-
const { children, elementType: Component = "button", isDisabled, isLoading, isSuccess, variant = "primary", size = "
|
|
26
|
+
const { children, elementType: Component = "button", isDisabled, isLoading, isSuccess, variant = "primary", size = "md", icon, iconPosition,
|
|
27
27
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
28
|
onPress,
|
|
29
29
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;AAEb,iCAAkE;AAClE,+DAA2C;AAG3C,uCAAoC;AACpC,qDAAkE;AAElE,IAAI,6BAA6B,GAAG,KAAK,CAAC;AAyC1C,MAAM,MAAM,GACV,IAAA,kBAAU,EAAC,CAAC,KAAkB,EAAE,GAAc,EAAE,EAAE;IAChD,MAAM,EACJ,QAAQ,EACR,WAAW,EAAE,SAAS,GAAG,QAAQ,EACjC,UAAU,EACV,SAAS,EACT,SAAS,EACT,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;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f,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
|
@@ -48,7 +48,7 @@ exports.Normal = {
|
|
|
48
48
|
args: {
|
|
49
49
|
children: "Confirm",
|
|
50
50
|
variant: "primary",
|
|
51
|
-
size: "
|
|
51
|
+
size: "md",
|
|
52
52
|
isDisabled: false,
|
|
53
53
|
isLoading: false,
|
|
54
54
|
isSuccess: false,
|
|
@@ -59,7 +59,7 @@ exports.Secondary = {
|
|
|
59
59
|
render: (args) => (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({}, args)),
|
|
60
60
|
args: {
|
|
61
61
|
variant: "secondary",
|
|
62
|
-
size: "
|
|
62
|
+
size: "md",
|
|
63
63
|
children: "Secondary Button",
|
|
64
64
|
isDisabled: false,
|
|
65
65
|
isLoading: false,
|
|
@@ -71,7 +71,7 @@ exports.Ghost = {
|
|
|
71
71
|
render: (args) => (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({}, args)),
|
|
72
72
|
args: {
|
|
73
73
|
variant: "ghost",
|
|
74
|
-
size: "
|
|
74
|
+
size: "md",
|
|
75
75
|
children: "Ghost Button",
|
|
76
76
|
isDisabled: false,
|
|
77
77
|
isLoading: false,
|
|
@@ -83,7 +83,7 @@ exports.Basic = {
|
|
|
83
83
|
render: (args) => (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({}, args)),
|
|
84
84
|
args: {
|
|
85
85
|
variant: "basic",
|
|
86
|
-
size: "
|
|
86
|
+
size: "md",
|
|
87
87
|
children: "Basic Button",
|
|
88
88
|
isDisabled: false,
|
|
89
89
|
isLoading: false,
|
|
@@ -96,7 +96,7 @@ exports.Large = {
|
|
|
96
96
|
args: {
|
|
97
97
|
children: "Large Button",
|
|
98
98
|
variant: "primary",
|
|
99
|
-
size: "
|
|
99
|
+
size: "lg",
|
|
100
100
|
isDisabled: false,
|
|
101
101
|
isLoading: false,
|
|
102
102
|
isSuccess: false,
|
|
@@ -109,7 +109,7 @@ exports.Link = {
|
|
|
109
109
|
children: "Link Button",
|
|
110
110
|
elementType: "a",
|
|
111
111
|
variant: "primary",
|
|
112
|
-
size: "
|
|
112
|
+
size: "md",
|
|
113
113
|
isDisabled: false,
|
|
114
114
|
isLoading: false,
|
|
115
115
|
isSuccess: false,
|
|
@@ -123,7 +123,7 @@ exports.Loading = {
|
|
|
123
123
|
args: {
|
|
124
124
|
children: "Loading",
|
|
125
125
|
variant: "primary",
|
|
126
|
-
size: "
|
|
126
|
+
size: "md",
|
|
127
127
|
isDisabled: false,
|
|
128
128
|
isLoading: true,
|
|
129
129
|
isSuccess: false,
|
|
@@ -135,7 +135,7 @@ exports.Success = {
|
|
|
135
135
|
args: {
|
|
136
136
|
children: "Success",
|
|
137
137
|
variant: "primary",
|
|
138
|
-
size: "
|
|
138
|
+
size: "md",
|
|
139
139
|
isDisabled: false,
|
|
140
140
|
isLoading: false,
|
|
141
141
|
isSuccess: true,
|
|
@@ -147,7 +147,7 @@ exports.Disabled = {
|
|
|
147
147
|
args: {
|
|
148
148
|
children: "Disabled",
|
|
149
149
|
variant: "primary",
|
|
150
|
-
size: "
|
|
150
|
+
size: "md",
|
|
151
151
|
isDisabled: true,
|
|
152
152
|
isLoading: false,
|
|
153
153
|
isSuccess: false,
|
|
@@ -163,7 +163,7 @@ exports.WithIconOnTheLeft = {
|
|
|
163
163
|
args: {
|
|
164
164
|
children: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: icons_1.leftArrow }), "Back"] })),
|
|
165
165
|
variant: "secondary",
|
|
166
|
-
size: "
|
|
166
|
+
size: "md",
|
|
167
167
|
isDisabled: false,
|
|
168
168
|
isLoading: false,
|
|
169
169
|
isSuccess: false,
|
|
@@ -180,7 +180,7 @@ exports.WithIconOnTheRight = {
|
|
|
180
180
|
args: {
|
|
181
181
|
children: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Menu ", (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: icons_1.menu })] })),
|
|
182
182
|
variant: "primary",
|
|
183
|
-
size: "
|
|
183
|
+
size: "md",
|
|
184
184
|
isDisabled: false,
|
|
185
185
|
isLoading: false,
|
|
186
186
|
isSuccess: false,
|
|
@@ -197,7 +197,7 @@ exports.Themed = {
|
|
|
197
197
|
args: {
|
|
198
198
|
children: "Confirm",
|
|
199
199
|
variant: "primary",
|
|
200
|
-
size: "
|
|
200
|
+
size: "md",
|
|
201
201
|
isDisabled: false,
|
|
202
202
|
isLoading: false,
|
|
203
203
|
isSuccess: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.stories.js","sourceRoot":"","sources":["../../../../src/components/Button/Button.stories.tsx"],"names":[],"mappings":";;;;AAAA,iCAAiC;AAEjC,iDAAwD;AACxD,qCAA+C;AAC/C,kCAA+B;AAC/B,iEAA8D;AAE9D,kBAAe;IACb,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,eAAM;IACjB,cAAc,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;IAC1C,QAAQ,kBACN,SAAS,EAAE;YACT,EAAE,EAAE;gBACF,GAAG,EAAE,WAAW;gBAChB,MAAM,EAAE,KAAK;aACd;SACF,EACD,SAAS,EAAE;YACT,EAAE,EAAE;gBACF,GAAG,EAAE,WAAW;gBAChB,MAAM,EAAE,KAAK;aACd;SACF,EACD,IAAI,EAAE;YACJ,EAAE,EAAE;gBACF,GAAG,EAAE,aAAa;gBAClB,EAAE,EAAE,GAAG;aACR;SACF,EACD,GAAG,EAAE;YACH,EAAE,EAAE;gBACF,GAAG,EAAE,aAAa;gBAClB,EAAE,EAAE,GAAG;aACR;SACF,EACD,MAAM,EAAE;YACN,EAAE,EAAE;gBACF,GAAG,EAAE,aAAa;gBAClB,EAAE,EAAE,GAAG;aACR;SACF,EACD,IAAI,EAAE;YACJ,EAAE,EAAE;gBACF,GAAG,EAAE,aAAa;gBAClB,GAAG,EAAE,GAAG;aACT;SACF,IACE,IAAA,iCAAe,EAChB,WAAW,EACX,SAAS,EACT,aAAa,EACb,SAAS,EACT,MAAM,EACN,MAAM,EACN,cAAc,EACd,UAAU,CACX,CACF;CACF,CAAC;AAEW,QAAA,MAAM,GAAwB;IACzC,MAAM,EAAE,CAAC,IAAiB,EAAE,EAAE,CAAC,uBAAC,eAAM,oBAAK,IAAI,EAAI;IACnD,IAAI,EAAE;QACJ,QAAQ,EAAE,SAAS;QACnB,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"Button.stories.js","sourceRoot":"","sources":["../../../../src/components/Button/Button.stories.tsx"],"names":[],"mappings":";;;;AAAA,iCAAiC;AAEjC,iDAAwD;AACxD,qCAA+C;AAC/C,kCAA+B;AAC/B,iEAA8D;AAE9D,kBAAe;IACb,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,eAAM;IACjB,cAAc,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;IAC1C,QAAQ,kBACN,SAAS,EAAE;YACT,EAAE,EAAE;gBACF,GAAG,EAAE,WAAW;gBAChB,MAAM,EAAE,KAAK;aACd;SACF,EACD,SAAS,EAAE;YACT,EAAE,EAAE;gBACF,GAAG,EAAE,WAAW;gBAChB,MAAM,EAAE,KAAK;aACd;SACF,EACD,IAAI,EAAE;YACJ,EAAE,EAAE;gBACF,GAAG,EAAE,aAAa;gBAClB,EAAE,EAAE,GAAG;aACR;SACF,EACD,GAAG,EAAE;YACH,EAAE,EAAE;gBACF,GAAG,EAAE,aAAa;gBAClB,EAAE,EAAE,GAAG;aACR;SACF,EACD,MAAM,EAAE;YACN,EAAE,EAAE;gBACF,GAAG,EAAE,aAAa;gBAClB,EAAE,EAAE,GAAG;aACR;SACF,EACD,IAAI,EAAE;YACJ,EAAE,EAAE;gBACF,GAAG,EAAE,aAAa;gBAClB,GAAG,EAAE,GAAG;aACT;SACF,IACE,IAAA,iCAAe,EAChB,WAAW,EACX,SAAS,EACT,aAAa,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CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC;IACF,OAAO,CACL,4CACE,uBAAC,eAAM,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,yBAAmB,EACxD,yCACG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC9B,oDAAoD;gBACpD,yCAAa,QAAQ,IAAZ,CAAC,CAAiB,CAC5B,CAAC,GACC,IACD,CACP,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,WAAW,eAgBtB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode, Ref, RefAttributes } from "react";
|
|
2
|
+
import { DOMProps } from "../../types/dom";
|
|
3
|
+
export type DivRef = Ref<HTMLDivElement>;
|
|
4
|
+
export type DivElementType = HTMLDivElement;
|
|
5
|
+
export interface ContentProps extends DOMProps, RefAttributes<DivElementType> {
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
closeLabel?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const Content: import("react").ForwardRefExoticComponent<Omit<ContentProps, "ref"> & RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export { Content };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Content = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const dedupe_1 = __importDefault(require("classnames/dedupe"));
|
|
20
|
+
const react_1 = require("react");
|
|
21
|
+
const Content = (0, react_1.forwardRef)((
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
+
_a, ref) => {
|
|
24
|
+
var
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
+
{ children, onClose, closeLabel } = _a, otherProps = __rest(_a,
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
+
["children", "onClose", "closeLabel"]);
|
|
29
|
+
const classes = (0, dedupe_1.default)("mobius/DrawerContent");
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: ref }, otherProps, { className: classes, children: react_1.Children.map(children, child => {
|
|
31
|
+
if ((0, react_1.isValidElement)(child)) {
|
|
32
|
+
return (0, react_1.cloneElement)(child, {
|
|
33
|
+
onClose,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return child;
|
|
37
|
+
}) })));
|
|
38
|
+
});
|
|
39
|
+
exports.Content = Content;
|
|
40
|
+
Content.displayName = "Content";
|
|
41
|
+
//# sourceMappingURL=Content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../src/components/Drawer/Content.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+DAA2C;AAC3C,iCAQe;AAWf,MAAM,OAAO,GAAG,IAAA,kBAAU,EACxB;AACE,6DAA6D;AAC7D,EAA8D,EAC9D,GAAW,EACX,EAAE;;IAHF,6DAA6D;IAC7D,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,OAA+B,EAA1B,UAAU;IAD9C,6DAA6D;IAC7D,qCAAgD,CAAF;IAG9C,MAAM,OAAO,GAAG,IAAA,gBAAU,EAAC,sBAAsB,CAAC,CAAC;IAEnD,OAAO,CACL,8CAAK,GAAG,EAAE,GAAG,IAAM,UAAU,IAAE,SAAS,EAAE,OAAO,YAC9C,gBAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE;YAC9B,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,EAAE;gBACzB,OAAO,IAAA,oBAAY,EAAC,KAAK,EAAE;oBACzB,OAAO;iBACD,CAAC,CAAC;aACX;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAGO,0BAAO;AADhB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export interface DrawerProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Direction that drawer will open from
|
|
6
|
+
*/
|
|
7
|
+
direction: "top" | "bottom" | "left" | "right";
|
|
8
|
+
className?: string;
|
|
9
|
+
closeLabel?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Announce text for screen readers when drawer opens
|
|
12
|
+
*/
|
|
13
|
+
announce?: string;
|
|
14
|
+
onOpen?: () => void;
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
declare const Drawer: {
|
|
19
|
+
({ isOpen, className, closeLabel, direction, announce, onOpen, onClose, children, }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
displayName: string;
|
|
21
|
+
};
|
|
22
|
+
export { Drawer };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
"use client";
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.Drawer = void 0;
|
|
32
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
33
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
34
|
+
const dedupe_1 = __importDefault(require("classnames/dedupe"));
|
|
35
|
+
const react_1 = require("react");
|
|
36
|
+
const useBodyScrollLock_1 = require("../../hooks/useBodyScrollLock");
|
|
37
|
+
const polyfill_tests_1 = require("../../utils/polyfill-tests");
|
|
38
|
+
const VisuallyHidden_1 = require("../VisuallyHidden");
|
|
39
|
+
const Drawer = ({ isOpen, className, closeLabel, direction, announce = "Drawer opened on screen", onOpen, onClose, children, }) => {
|
|
40
|
+
const hasOpened = (0, react_1.useRef)(false);
|
|
41
|
+
const modalRef = (0, react_1.useRef)(null);
|
|
42
|
+
const dialog = modalRef.current;
|
|
43
|
+
// Fire onOpen once
|
|
44
|
+
if (onOpen && !hasOpened.current) {
|
|
45
|
+
onOpen();
|
|
46
|
+
hasOpened.current = true;
|
|
47
|
+
}
|
|
48
|
+
(0, useBodyScrollLock_1.useBodyScrollLock)({ enabled: isOpen });
|
|
49
|
+
// Add close handler, to enable closing animations
|
|
50
|
+
const handleClose = (0, react_1.useCallback)(event => {
|
|
51
|
+
if (event) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
const doClose = () => {
|
|
55
|
+
dialog.close();
|
|
56
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
57
|
+
};
|
|
58
|
+
// Delay close to allow exit animation
|
|
59
|
+
dialog.classList.add("close");
|
|
60
|
+
dialog.addEventListener("animationend", () => {
|
|
61
|
+
dialog.classList.remove("close");
|
|
62
|
+
doClose();
|
|
63
|
+
}, { once: true });
|
|
64
|
+
}
|
|
65
|
+
}, [onClose, dialog]);
|
|
66
|
+
const modalClasses = (0, dedupe_1.default)("mobius", "mobius/Drawer", `--${direction}`, className);
|
|
67
|
+
// Add polyfill for HTML Dialog in old browsers
|
|
68
|
+
(0, react_1.useEffect)(() => {
|
|
69
|
+
async function toggleModal() {
|
|
70
|
+
var _a, _b, _c;
|
|
71
|
+
if (!(0, polyfill_tests_1.supportsDialog)() && typeof window !== "undefined") {
|
|
72
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
73
|
+
const { default: dialogPolyfill } = await Promise.resolve().then(() => __importStar(require("dialog-polyfill")));
|
|
74
|
+
dialogPolyfill.registerDialog(modalRef.current);
|
|
75
|
+
}
|
|
76
|
+
if (isOpen) {
|
|
77
|
+
(_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.showModal();
|
|
78
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
79
|
+
}
|
|
80
|
+
else if ((_b = modalRef.current) === null || _b === void 0 ? void 0 : _b.open) {
|
|
81
|
+
(_c = modalRef.current) === null || _c === void 0 ? void 0 : _c.close();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
toggleModal();
|
|
85
|
+
}, [isOpen, onOpen]);
|
|
86
|
+
return ((0, jsx_runtime_1.jsxs)("dialog", { ref: modalRef, onCancel: handleClose, className: modalClasses, "aria-describedby": "screen-reader-announce", children: [(0, jsx_runtime_1.jsx)(VisuallyHidden_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("div", { id: "screen-reader-announce", children: announce }) }), react_1.Children.map(children, child => {
|
|
87
|
+
if ((0, react_1.isValidElement)(child)) {
|
|
88
|
+
return (0, react_1.cloneElement)(child, {
|
|
89
|
+
onClose: handleClose,
|
|
90
|
+
closeLabel,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return child;
|
|
94
|
+
})] }));
|
|
95
|
+
};
|
|
96
|
+
exports.Drawer = Drawer;
|
|
97
|
+
Drawer.displayName = "Drawer";
|
|
98
|
+
//# sourceMappingURL=Drawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../../src/components/Drawer/Drawer.tsx"],"names":[],"mappings":";AAAA,+BAA+B;AAE/B,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,6DAA6D;AAC7D,+DAA2C;AAC3C,iCASe;AACf,qEAAkE;AAClE,+DAA4D;AAC5D,sDAAmD;AAmBnD,MAAM,MAAM,GAAG,CAAC,EACd,MAAM,EACN,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,GAAG,yBAAyB,EACpC,MAAM,EACN,OAAO,EACP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3
|
+
declare const Demo: ({ direction, closeLabel }: DrawerProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const LogoHeader: ({ direction, closeLabel }: DrawerProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare const WithLongContentDemo: (props: DrawerProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare const _default: {
|
|
7
|
+
title: string;
|
|
8
|
+
component: {
|
|
9
|
+
({ isOpen, className, closeLabel, direction, announce, onOpen, onClose, children, }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
} & {
|
|
12
|
+
Header: import("react").ForwardRefExoticComponent<Omit<import("./Header").HeaderProps, "ref"> & import("react").RefAttributes<HTMLElement>>;
|
|
13
|
+
Content: import("react").ForwardRefExoticComponent<Omit<import("./Content").ContentProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
};
|
|
15
|
+
argTypes: {
|
|
16
|
+
direction: {
|
|
17
|
+
options: string[];
|
|
18
|
+
control: {
|
|
19
|
+
type: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
25
|
+
export declare const Normal: Meta<typeof Demo>;
|
|
26
|
+
export declare const WithLogoHeader: Meta<typeof LogoHeader>;
|
|
27
|
+
export declare const WithLongContent: Meta<typeof WithLongContentDemo>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WithLongContent = exports.WithLogoHeader = exports.Normal = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const _1 = require(".");
|
|
7
|
+
const excludeControls_1 = require("../../utils/excludeControls");
|
|
8
|
+
const Button_1 = require("../Button");
|
|
9
|
+
const Text_1 = require("../Text");
|
|
10
|
+
const Demo = ({ direction, closeLabel }) => {
|
|
11
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => setOpen(true), children: "Show Drawer" }), (0, jsx_runtime_1.jsxs)(_1.Drawer, { isOpen: open, onClose: () => setOpen(false), direction: direction, closeLabel: closeLabel, children: [(0, jsx_runtime_1.jsx)(_1.Drawer.Header, { children: "The Latin Drawer" }), (0, jsx_runtime_1.jsx)(_1.Drawer.Content, { children: "Aliquam fringilla quam vel purus rhoncus interdum in quis sapien. Sed at eros et lectus mollis posuere. Morbi augue augue, venenatis vel consectetur sed, vulputate et lorem. Integer venenatis nibh molestie commodo lobortis. Phasellus sit amet dignissim nisi. Vivamus nisi augue, scelerisque commodo libero vitae, vulputate interdum ex. Integer non risus sollicitudin, cursus ipsum vitae, rhoncus nulla." })] })] }));
|
|
13
|
+
};
|
|
14
|
+
const LogoHeader = ({ direction, closeLabel }) => {
|
|
15
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
16
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => setOpen(true), children: "Show Drawer" }), (0, jsx_runtime_1.jsxs)(_1.Drawer, { isOpen: open, onClose: () => setOpen(false), direction: direction, closeLabel: closeLabel, children: [(0, jsx_runtime_1.jsx)(_1.Drawer.Header, { children: (0, jsx_runtime_1.jsx)("img", { src: "https://quote.simplybusiness.com/assets/logos/insurers/harborway_insurance-1a46ba508f3dfcc89aa2498e7680ed15bd1704ccb01c614eb5335bd7b25e0537.png", alt: "Provider logo" }) }), (0, jsx_runtime_1.jsx)(_1.Drawer.Content, { children: "Content." })] })] }));
|
|
17
|
+
};
|
|
18
|
+
const WithLongContentDemo = (props) => {
|
|
19
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => setOpen(true), children: "Show Drawer" }), (0, jsx_runtime_1.jsxs)(_1.Drawer, Object.assign({}, props, { isOpen: open, onClose: () => setOpen(false), children: [(0, jsx_runtime_1.jsx)(_1.Drawer.Header, { children: "Aliquam fringilla quam vel purus rhoncus isuere. Morbi augue augue, venenatis vel consectetur sed, vulputate et lorem. Int" }), (0, jsx_runtime_1.jsxs)(_1.Drawer.Content, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Aliquam fringilla quam vel purus rhoncus interdum in quis sapien. Sed at eros et lectus mollis posuere. Morbi augue augue, venenatis vel consectetur sed, vulputate et lorem. Integer venenatis nibh molestie commodo lobortis. Phasellus sit amet dignissim nisi. Vivamus nisi augue, scelerisque commodo libero vitae, vulputate interdum ex. Integer non risus sollicitudin, cursus ipsum vitae, rhoncus nulla." }), (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Aliquam fringilla quam vel purus rhoncus interdum in quis sapien. Sed at eros et lectus mollis posuere. Morbi augue augue, venenatis vel consectetur sed, vulputate et lorem. Integer venenatis nibh molestie commodo lobortis. Phasellus sit amet dignissim nisi. Vivamus nisi augue, scelerisque commodo libero vitae, vulputate interdum ex. Integer non risus sollicitudin, cursus ipsum vitae, rhoncus nulla." }), (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Aliquam fringilla quam vel purus rhoncus interdum in quis sapien. Sed at eros et lectus mollis posuere. Morbi augue augue, venenatis vel consectetur sed, vulputate et lorem. Integer venenatis nibh molestie commodo lobortis. Phasellus sit amet dignissim nisi. Vivamus nisi augue, scelerisque commodo libero vitae, vulputate interdum ex. Integer non risus sollicitudin, cursus ipsum vitae, rhoncus nulla." }), (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Aliquam fringilla quam vel purus rhoncus interdum in quis sapien. Sed at eros et lectus mollis posuere. Morbi augue augue, venenatis vel consectetur sed, vulputate et lorem. Integer venenatis nibh molestie commodo lobortis. Phasellus sit amet dignissim nisi. Vivamus nisi augue, scelerisque commodo libero vitae, vulputate interdum ex. Integer non risus sollicitudin, cursus ipsum vitae, rhoncus nulla." }), (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Aliquam fringilla quam vel purus rhoncus interdum in quis sapien. Sed at eros et lectus mollis posuere. Morbi augue augue, venenatis vel consectetur sed, vulputate et lorem. Integer venenatis nibh molestie commodo lobortis. Phasellus sit amet dignissim nisi. Vivamus nisi augue, scelerisque commodo libero vitae, vulputate interdum ex. Integer non risus sollicitudin, cursus ipsum vitae, rhoncus nulla." }), (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Aliquam fringilla quam vel purus rhoncus interdum in quis sapien. Sed at eros et lectus mollis posuere. Morbi augue augue, venenatis vel consectetur sed, vulputate et lorem. Integer venenatis nibh molestie commodo lobortis. Phasellus sit amet dignissim nisi. Vivamus nisi augue, scelerisque commodo libero vitae, vulputate interdum ex. Integer non risus sollicitudin, cursus ipsum vitae, rhoncus nulla." }), (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Aliquam fringilla quam vel purus rhoncus interdum in quis sapien. Sed at eros et lectus mollis posuere. Morbi augue augue, venenatis vel consectetur sed, vulputate et lorem. Integer venenatis nibh molestie commodo lobortis. Phasellus sit amet dignissim nisi. Vivamus nisi augue, scelerisque commodo libero vitae, vulputate interdum ex. Integer non risus sollicitudin, cursus ipsum vitae, rhoncus nulla." })] })] }))] }));
|
|
21
|
+
};
|
|
22
|
+
exports.default = {
|
|
23
|
+
title: "Components/Drawer",
|
|
24
|
+
component: _1.Drawer,
|
|
25
|
+
argTypes: Object.assign({ direction: {
|
|
26
|
+
options: ["top", "bottom", "left", "right"],
|
|
27
|
+
control: { type: "radio" },
|
|
28
|
+
} }, (0, excludeControls_1.excludeControls)("className", "onOpen", "onClose", "isOpen")),
|
|
29
|
+
};
|
|
30
|
+
exports.Normal = {
|
|
31
|
+
render: (args) => (0, jsx_runtime_1.jsx)(Demo, Object.assign({}, args)),
|
|
32
|
+
args: {
|
|
33
|
+
isOpen: false,
|
|
34
|
+
direction: "right",
|
|
35
|
+
closeLabel: "Close",
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
exports.WithLogoHeader = {
|
|
39
|
+
render: (args) => (0, jsx_runtime_1.jsx)(LogoHeader, Object.assign({}, args)),
|
|
40
|
+
args: {
|
|
41
|
+
isOpen: false,
|
|
42
|
+
direction: "right",
|
|
43
|
+
closeLabel: "Close",
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
exports.WithLongContent = {
|
|
47
|
+
render: (args) => (0, jsx_runtime_1.jsx)(WithLongContentDemo, Object.assign({}, args)),
|
|
48
|
+
args: {
|
|
49
|
+
isOpen: false,
|
|
50
|
+
direction: "right",
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=Drawer.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.stories.js","sourceRoot":"","sources":["../../../../src/components/Drawer/Drawer.stories.tsx"],"names":[],"mappings":";;;;AACA,iCAAiC;AACjC,wBAAwC;AACxC,iEAA8D;AAC9D,sCAAmC;AACnC,kCAA+B;AAE/B,MAAM,IAAI,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAe,EAAE,EAAE;IACtD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACxC,OAAO,CACL,6DACE,uBAAC,eAAM,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,4BAAsB,EAC1D,wBAAC,SAAM,IACL,MAAM,EAAE,IAAI,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAC7B,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,aAEtB,uBAAC,SAAM,CAAC,MAAM,mCAAiC,EAC/C,uBAA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BAAC,WAAI,qaAQE,EACP,uBAAC,WAAI,qaAQE,IACQ,KACV,IACR,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe;IACb,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,SAAM;IACjB,QAAQ,kBACN,SAAS,EAAE;YACT,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;YAC3C,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;SAC3B,IACE,IAAA,iCAAe,EAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAC/D;CACF,CAAC;AAEW,QAAA,MAAM,GAAsB;IACvC,MAAM,EAAE,CAAC,IAAiB,EAAE,EAAE,CAAC,uBAAC,IAAI,oBAAK,IAAI,EAAI;IACjD,IAAI,EAAE;QACJ,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,OAAO;KACpB;CACF,CAAC;AAEW,QAAA,cAAc,GAA4B;IACrD,MAAM,EAAE,CAAC,IAAiB,EAAE,EAAE,CAAC,uBAAC,UAAU,oBAAK,IAAI,EAAI;IACvD,IAAI,EAAE;QACJ,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,OAAO;KACpB;CACF,CAAC;AAEW,QAAA,eAAe,GAAqC;IAC/D,MAAM,EAAE,CAAC,IAAiB,EAAE,EAAE,CAAC,uBAAC,mBAAmB,oBAAK,IAAI,EAAI;IAChE,IAAI,EAAE;QACJ,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,OAAO;KACnB;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("@testing-library/react");
|
|
8
|
+
const user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
9
|
+
const react_2 = require("react");
|
|
10
|
+
const _1 = require(".");
|
|
11
|
+
const jestHTMLDialogPolyfill_1 = require("../../utils/jestHTMLDialogPolyfill");
|
|
12
|
+
(0, jestHTMLDialogPolyfill_1.jestHTMLDialogPolyfill)();
|
|
13
|
+
const DRAWER_CLASS_NAME = "mobius/Drawer";
|
|
14
|
+
const DRAWER_CLOSE_CLASS_NAME = "mobius/DrawerClose";
|
|
15
|
+
const mockMatchMedia = (matches) => {
|
|
16
|
+
Object.defineProperty(window, "matchMedia", {
|
|
17
|
+
writable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
value: jest.fn().mockImplementation(query => ({
|
|
20
|
+
matches,
|
|
21
|
+
media: query,
|
|
22
|
+
onchange: null,
|
|
23
|
+
addListener: jest.fn(),
|
|
24
|
+
removeListener: jest.fn(),
|
|
25
|
+
addEventListener: jest.fn(),
|
|
26
|
+
removeEventListener: jest.fn(),
|
|
27
|
+
dispatchEvent: jest.fn(),
|
|
28
|
+
})),
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
describe("Drawer", () => {
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
mockMatchMedia(true);
|
|
34
|
+
});
|
|
35
|
+
afterAll(() => {
|
|
36
|
+
jest.resetAllMocks();
|
|
37
|
+
});
|
|
38
|
+
it("should render without errors", () => {
|
|
39
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(_1.Drawer, { isOpen: true, direction: "right", onClose: () => { } }));
|
|
40
|
+
expect(container).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
it("should render with default class names", () => {
|
|
43
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(_1.Drawer, { isOpen: true, direction: "right", onClose: () => { }, children: (0, jsx_runtime_1.jsx)(_1.Drawer.Header, {}) }));
|
|
44
|
+
const dialog = react_1.screen.getByRole("dialog");
|
|
45
|
+
const closeButton = react_1.screen.getByLabelText("Close");
|
|
46
|
+
expect(dialog).toHaveClass(DRAWER_CLASS_NAME);
|
|
47
|
+
expect(closeButton).toHaveClass(DRAWER_CLOSE_CLASS_NAME);
|
|
48
|
+
});
|
|
49
|
+
it("should render with custom class name", () => {
|
|
50
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(_1.Drawer, { direction: "right", className: "my-test-modal", isOpen: true, onClose: () => { }, children: (0, jsx_runtime_1.jsx)(_1.Drawer.Header, {}) }));
|
|
51
|
+
const dialog = react_1.screen.getByRole("dialog");
|
|
52
|
+
const closeButton = react_1.screen.getByLabelText("Close");
|
|
53
|
+
expect(dialog).toHaveClass(DRAWER_CLASS_NAME);
|
|
54
|
+
expect(dialog).toHaveClass("my-test-modal");
|
|
55
|
+
expect(closeButton).toHaveClass(DRAWER_CLOSE_CLASS_NAME);
|
|
56
|
+
});
|
|
57
|
+
describe("given the direction prop is set", () => {
|
|
58
|
+
it("should render with appropriate class name (right)", () => {
|
|
59
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(_1.Drawer, { isOpen: true, onClose: () => { }, direction: "right" }));
|
|
60
|
+
const dialog = react_1.screen.getByRole("dialog");
|
|
61
|
+
expect(dialog).toHaveClass("--right");
|
|
62
|
+
});
|
|
63
|
+
it("should render with appropriate class name (bottom)", () => {
|
|
64
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(_1.Drawer, { isOpen: true, onClose: () => { }, direction: "bottom" }));
|
|
65
|
+
const dialog = react_1.screen.getByRole("dialog");
|
|
66
|
+
expect(dialog).toHaveClass("--bottom");
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe("screen reader", () => {
|
|
70
|
+
it("should announce a default message on opening", () => {
|
|
71
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(_1.Drawer, { isOpen: true, onClose: () => { }, direction: "right" }));
|
|
72
|
+
const message = react_1.screen.getByText("Drawer opened on screen");
|
|
73
|
+
expect(message).toBeInTheDocument();
|
|
74
|
+
});
|
|
75
|
+
it("should respect a custom announce message on opening", () => {
|
|
76
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(_1.Drawer, { isOpen: true, onClose: () => { }, direction: "right", announce: "Quote details page" }));
|
|
77
|
+
const message = react_1.screen.getByText("Quote details page");
|
|
78
|
+
expect(message).toBeInTheDocument();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
xdescribe("pressing close button", () => {
|
|
82
|
+
it("should close the modal", async () => {
|
|
83
|
+
const App = () => {
|
|
84
|
+
const [isOpen, setIsOpen] = (0, react_2.useState)(true);
|
|
85
|
+
return ((0, jsx_runtime_1.jsxs)(_1.Drawer, { direction: "right", isOpen: isOpen, onClose: () => setIsOpen(false), children: [(0, jsx_runtime_1.jsx)(_1.Drawer.Header, { children: "Header" }), (0, jsx_runtime_1.jsx)(_1.Drawer.Content, { children: "Sample content" })] }));
|
|
86
|
+
};
|
|
87
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(App, {}));
|
|
88
|
+
const modalContent = react_1.screen.getByText("Sample content");
|
|
89
|
+
expect(modalContent).toBeInTheDocument();
|
|
90
|
+
const closeButton = react_1.screen.getByLabelText("Close");
|
|
91
|
+
await user_event_1.default.click(closeButton);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe("closeLabel prop", () => {
|
|
95
|
+
it("should render the label", () => {
|
|
96
|
+
const closeLabel = "Leave";
|
|
97
|
+
(0, react_1.render)((0, jsx_runtime_1.jsxs)(_1.Drawer, { direction: "right", isOpen: true, onClose: () => { }, closeLabel: closeLabel, children: [(0, jsx_runtime_1.jsx)(_1.Drawer.Header, {}), "Sample content"] }));
|
|
98
|
+
const closeButton = react_1.screen.getByText(closeLabel);
|
|
99
|
+
expect(closeButton).toBeInTheDocument();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
it("should render the default close button", () => {
|
|
103
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(_1.Drawer, { isOpen: true, direction: "right", onClose: () => { }, children: (0, jsx_runtime_1.jsx)(_1.Drawer.Header, {}) }));
|
|
104
|
+
const closeButton = react_1.screen.getByLabelText("Close");
|
|
105
|
+
expect(closeButton).toBeInTheDocument();
|
|
106
|
+
});
|
|
107
|
+
it("should fire onOpen callback if supplied", async () => {
|
|
108
|
+
const onOpen = jest.fn();
|
|
109
|
+
const App = () => {
|
|
110
|
+
const [isOpen, setIsOpen] = (0, react_2.useState)(false);
|
|
111
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { "aria-label": "Show modal", id: "btn", type: "button", onClick: () => setIsOpen(true), children: "Show modal" }), (0, jsx_runtime_1.jsxs)(_1.Drawer, { isOpen: isOpen, onClose: () => setIsOpen(false), direction: "right", onOpen: onOpen, children: [(0, jsx_runtime_1.jsx)(_1.Drawer.Header, { children: "Header" }), "Sample content"] })] }));
|
|
112
|
+
};
|
|
113
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(App, {}));
|
|
114
|
+
const showBtn = react_1.screen.getByText("Show modal");
|
|
115
|
+
expect(showBtn).toBeInTheDocument();
|
|
116
|
+
await user_event_1.default.click(showBtn);
|
|
117
|
+
expect(onOpen).toHaveBeenCalled();
|
|
118
|
+
});
|
|
119
|
+
it.todo("Drawer closes when Escape key is presed");
|
|
120
|
+
// JSDom does not support HTMLDialog click events
|
|
121
|
+
it.todo("Drawer closes when backdrop is clicked");
|
|
122
|
+
});
|
|
123
|
+
//# sourceMappingURL=Drawer.test.js.map
|