@toptal/picasso-prompt-modal 1.0.24 → 2.0.1

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.
@@ -36,6 +36,6 @@ export interface Props extends Omit<ModalProps, 'children' | 'onSubmit'> {
36
36
  submitButton?: string;
37
37
  };
38
38
  }
39
- export declare const PromptModal: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLElement>>;
39
+ export declare const PromptModal: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
40
40
  export default PromptModal;
41
41
  //# sourceMappingURL=PromptModal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromptModal.d.ts","sourceRoot":"","sources":["../../../src/PromptModal/PromptModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAqB,MAAM,OAAO,CAAA;AAOzC,OAAO,KAAK,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAMhE,oBAAY,WAAW,GAAG,UAAU,GAAG,UAAU,CAAA;AAEjD,oBAAY,aAAa,GAAG;IAC1B,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;IACvC,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAClC,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAMD,MAAM,WAAW,KAAM,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IACtE,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,SAAS,CAAA;IAC/C,qBAAqB;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,qBAAqB;IACr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AAI,CAAA;IAClC,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,MAAM,WAAW,KAAM,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IACtE,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,SAAS,CAAA;IAC/C,qBAAqB;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,6DAA6D;IAC7D,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,qFAAqF;IACrF,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;IACzD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;IAC1B,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;CACF;AAED,eAAO,MAAM,WAAW,8EAgGvB,CAAA;AAaD,eAAe,WAAW,CAAA"}
@@ -19,19 +19,13 @@ var __rest = (this && this.__rest) || function (s, e) {
19
19
  return t;
20
20
  };
21
21
  import React, { forwardRef } from 'react';
22
- import { makeStyles } from '@material-ui/core/styles';
23
22
  import { Container } from '@toptal/picasso-container';
24
23
  import { Typography } from '@toptal/picasso-typography';
25
24
  import { Button } from '@toptal/picasso-button';
26
25
  import { noop, useSafeState } from '@toptal/picasso-utils';
27
26
  import { ModalCompound as Modal } from '@toptal/picasso-modal';
28
- import styles from './styles';
29
- const useStyles = makeStyles(styles, {
30
- name: 'PicassoPromptModal',
31
- });
32
27
  export const PromptModal = forwardRef(function PromptModal(props, ref) {
33
28
  const { children, title, message, variant, submitText, cancelText, onSubmit, onAfterSubmit = noop, onCancel = noop, onClose, testIds } = props, rest = __rest(props, ["children", "title", "message", "variant", "submitText", "cancelText", "onSubmit", "onAfterSubmit", "onCancel", "onClose", "testIds"]);
34
- const classes = useStyles();
35
29
  const [result, setResult] = useSafeState();
36
30
  const [loading, setLoading] = useSafeState(false);
37
31
  const [error, setError] = useSafeState(false);
@@ -62,8 +56,8 @@ export const PromptModal = forwardRef(function PromptModal(props, ref) {
62
56
  onClose();
63
57
  }
64
58
  };
65
- return (React.createElement(Modal, Object.assign({ ref: ref, onClose: onClose && handleClose, classes: classes }, rest),
66
- title && React.createElement(Modal.Title, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.title }, title),
59
+ return (React.createElement(Modal, Object.assign({ ref: ref, onClose: onClose && handleClose }, rest),
60
+ title && (React.createElement(Modal.Title, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.title }, title)),
67
61
  React.createElement(Modal.Content, null,
68
62
  React.createElement(Typography, { size: 'medium', "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.message }, message),
69
63
  children && (React.createElement(Container, { top: 'xsmall' }, children({
@@ -1 +1 @@
1
- {"version":3,"file":"PromptModal.js","sourceRoot":"","sources":["../../../src/PromptModal/PromptModal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C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BACV,OAAO;gBACP,QAAQ;gBACR,KAAK;aACN,CAAC,CACQ,CACb,CACa;QAChB,oBAAC,KAAK,CAAC,OAAO;YACZ,oBAAC,MAAM,IACL,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,YAAY,iBACR,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,IAEhC,UAAU,CACJ;YACT,oBAAC,MAAM,IACL,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,GAAG,OAAO,EAAuB,iBAC7B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,IAEjC,UAAU,CACJ,CACK,CACV,CACT,CAAA;AACH,CAAC,CACF,CAAA;AAED,WAAW,CAAC,YAAY,GAAG;IACzB,UAAU,EAAE,QAAQ;IACpB,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,OAAO;IACb,UAAU,EAAE,QAAQ;IACpB,OAAO,EAAE,UAAU;IACnB,aAAa,EAAE,IAAI;CACpB,CAAA;AAED,WAAW,CAAC,WAAW,GAAG,aAAa,CAAA;AAEvC,eAAe,WAAW,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/picasso-prompt-modal",
3
- "version": "1.0.24",
3
+ "version": "2.0.1",
4
4
  "description": "Toptal UI components library - PromptModal",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,10 +22,10 @@
22
22
  },
23
23
  "homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
24
24
  "dependencies": {
25
- "@toptal/picasso-button": "2.1.1",
26
- "@toptal/picasso-container": "1.0.3",
27
- "@toptal/picasso-modal": "2.0.10",
28
- "@toptal/picasso-typography": "2.0.2",
25
+ "@toptal/picasso-button": "3.0.1",
26
+ "@toptal/picasso-container": "2.0.0",
27
+ "@toptal/picasso-modal": "3.0.1",
28
+ "@toptal/picasso-typography": "3.0.0",
29
29
  "@toptal/picasso-utils": "1.0.3"
30
30
  },
31
31
  "sideEffects": [
@@ -33,8 +33,8 @@
33
33
  "**/styles.js"
34
34
  ],
35
35
  "peerDependencies": {
36
- "@material-ui/core": "4.12.4",
37
- "react": ">=16.12.0 < 19.0.0"
36
+ "react": ">=16.12.0 < 19.0.0",
37
+ "@toptal/picasso-tailwind": ">=2.7"
38
38
  },
39
39
  "exports": {
40
40
  ".": "./dist-package/src/index.js"
@@ -1,7 +1,5 @@
1
1
  import type { ReactNode } from 'react'
2
2
  import React, { forwardRef } from 'react'
3
- import type { Theme } from '@material-ui/core/styles'
4
- import { makeStyles } from '@material-ui/core/styles'
5
3
  import { Container } from '@toptal/picasso-container'
6
4
  import { Typography } from '@toptal/picasso-typography'
7
5
  import { Button } from '@toptal/picasso-button'
@@ -10,8 +8,6 @@ import type { Props as ModalProps } from '@toptal/picasso-modal'
10
8
  import { ModalCompound as Modal } from '@toptal/picasso-modal'
11
9
  import type { VariantType as ButtonVariantType } from '@toptal/picasso-button'
12
10
 
13
- import styles from './styles'
14
-
15
11
  export type VariantType = 'positive' | 'negative'
16
12
 
17
13
  export type PromptOptions = {
@@ -23,10 +19,6 @@ export type PromptOptions = {
23
19
  error: boolean
24
20
  }
25
21
 
26
- const useStyles = makeStyles<Theme>(styles, {
27
- name: 'PicassoPromptModal',
28
- })
29
-
30
22
  export interface Props extends Omit<ModalProps, 'children' | 'onSubmit'> {
31
23
  /** Pass input component to allow you get input value from prompt modal */
32
24
  children?: (result: PromptOptions) => ReactNode
@@ -54,108 +46,103 @@ export interface Props extends Omit<ModalProps, 'children' | 'onSubmit'> {
54
46
  }
55
47
  }
56
48
 
57
- export const PromptModal = forwardRef<HTMLElement, Props>(function PromptModal(
58
- props,
59
- ref
60
- ) {
61
- const {
62
- children,
63
- title,
64
- message,
65
- variant,
66
- submitText,
67
- cancelText,
68
- onSubmit,
69
- onAfterSubmit = noop,
70
- onCancel = noop,
71
- onClose,
72
- testIds,
73
- ...rest
74
- } = props
75
- const classes = useStyles()
76
- const [result, setResult] = useSafeState<unknown>()
77
- const [loading, setLoading] = useSafeState(false)
78
- const [error, setError] = useSafeState(false)
79
-
80
- const handleSubmit = async () => {
81
- try {
82
- setLoading(true)
83
- setError(false)
84
-
85
- await onSubmit(result)
86
-
87
- setLoading(false)
88
- handleOnAfterSubmit()
89
- } catch (err) {
90
- setError(true)
91
- setLoading(false)
49
+ export const PromptModal = forwardRef<HTMLDivElement, Props>(
50
+ function PromptModal(props, ref) {
51
+ const {
52
+ children,
53
+ title,
54
+ message,
55
+ variant,
56
+ submitText,
57
+ cancelText,
58
+ onSubmit,
59
+ onAfterSubmit = noop,
60
+ onCancel = noop,
61
+ onClose,
62
+ testIds,
63
+ ...rest
64
+ } = props
65
+ const [result, setResult] = useSafeState<unknown>()
66
+ const [loading, setLoading] = useSafeState(false)
67
+ const [error, setError] = useSafeState(false)
68
+
69
+ const handleSubmit = async () => {
70
+ try {
71
+ setLoading(true)
72
+ setError(false)
73
+
74
+ await onSubmit(result)
75
+
76
+ setLoading(false)
77
+ handleOnAfterSubmit()
78
+ } catch (err) {
79
+ setError(true)
80
+ setLoading(false)
81
+ }
92
82
  }
93
- }
94
83
 
95
- const handleOnAfterSubmit = () => {
96
- onAfterSubmit()
97
- handleClose()
98
- }
84
+ const handleOnAfterSubmit = () => {
85
+ onAfterSubmit()
86
+ handleClose()
87
+ }
99
88
 
100
- const handleCancel = () => {
101
- onCancel()
102
- handleClose()
103
- }
89
+ const handleCancel = () => {
90
+ onCancel()
91
+ handleClose()
92
+ }
104
93
 
105
- const handleClose = () => {
106
- setResult(undefined)
94
+ const handleClose = () => {
95
+ setResult(undefined)
107
96
 
108
- if (onClose) {
109
- onClose()
97
+ if (onClose) {
98
+ onClose()
99
+ }
110
100
  }
111
- }
112
101
 
113
- return (
114
- <Modal
115
- ref={ref}
116
- onClose={onClose && handleClose}
117
- classes={classes}
118
- {...rest}
119
- >
120
- {title && <Modal.Title data-testid={testIds?.title}>{title}</Modal.Title>}
121
- <Modal.Content>
122
- <Typography size='medium' data-testid={testIds?.message}>
123
- {message}
124
- </Typography>
125
- {children && (
126
- <Container top='xsmall'>
127
- {children({
128
- setResult,
129
- result,
130
- setLoading,
131
- loading,
132
- setError,
133
- error,
134
- })}
135
- </Container>
102
+ return (
103
+ <Modal ref={ref} onClose={onClose && handleClose} {...rest}>
104
+ {title && (
105
+ <Modal.Title data-testid={testIds?.title}>{title}</Modal.Title>
136
106
  )}
137
- </Modal.Content>
138
- <Modal.Actions>
139
- <Button
140
- disabled={loading}
141
- variant='secondary'
142
- onClick={handleCancel}
143
- data-testid={testIds?.closeButton}
144
- >
145
- {cancelText}
146
- </Button>
147
- <Button
148
- loading={loading}
149
- onClick={handleSubmit}
150
- variant={`${variant}` as ButtonVariantType}
151
- data-testid={testIds?.submitButton}
152
- >
153
- {submitText}
154
- </Button>
155
- </Modal.Actions>
156
- </Modal>
157
- )
158
- })
107
+ <Modal.Content>
108
+ <Typography size='medium' data-testid={testIds?.message}>
109
+ {message}
110
+ </Typography>
111
+ {children && (
112
+ <Container top='xsmall'>
113
+ {children({
114
+ setResult,
115
+ result,
116
+ setLoading,
117
+ loading,
118
+ setError,
119
+ error,
120
+ })}
121
+ </Container>
122
+ )}
123
+ </Modal.Content>
124
+ <Modal.Actions>
125
+ <Button
126
+ disabled={loading}
127
+ variant='secondary'
128
+ onClick={handleCancel}
129
+ data-testid={testIds?.closeButton}
130
+ >
131
+ {cancelText}
132
+ </Button>
133
+ <Button
134
+ loading={loading}
135
+ onClick={handleSubmit}
136
+ variant={`${variant}` as ButtonVariantType}
137
+ data-testid={testIds?.submitButton}
138
+ >
139
+ {submitText}
140
+ </Button>
141
+ </Modal.Actions>
142
+ </Modal>
143
+ )
144
+ }
145
+ )
159
146
 
160
147
  PromptModal.defaultProps = {
161
148
  cancelText: 'Cancel',
@@ -10,87 +10,81 @@ exports[`PromptModal renders 1`] = `
10
10
  />
11
11
  </div>
12
12
  <div
13
- class="MuiDialog-root PicassoModal-root"
13
+ class="base-Modal fixed z-modal inset-0 flex flex-col text-lg leading-[normal] justify-center items-center"
14
14
  role="presentation"
15
- style="position: fixed; z-index: 1300; right: 0px; bottom: 0px; top: 0px; left: 0px;"
16
15
  >
17
16
  <div
18
17
  aria-hidden="true"
19
- class="MuiBackdrop-root"
20
- style="opacity: 1; webkit-transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;"
18
+ class="opacity-0 transition-opacity fixed -z inset-0 bg-black -webkit-tap-highlight-color bg-opacity"
19
+ style="transition-duration: 300ms; opacity: 1;"
21
20
  />
22
21
  <div
23
- data-test="sentinelStart"
22
+ data-testid="sentinelStart"
24
23
  tabindex="0"
25
24
  />
26
25
  <div
27
- class="MuiDialog-container PicassoModal-container MuiDialog-scrollPaper"
28
- role="none presentation"
29
- style="opacity: 1; webkit-transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;"
26
+ class="bg-white shadow-2 duration-300 delay-0 opacity-0 transition-opacity outline-none overflow-y flex flex-col m-4 sm:h-auto sm:m-8 max-w-[calc(100%_ sm:max-w-[calc(100%_ rounded-md w-[32.5rem] relative max-h-[calc(100%_ sm:max-h-[calc(100%_"
27
+ role="dialog"
28
+ style="transition-duration: 300ms; opacity: 1;"
30
29
  tabindex="-1"
31
30
  >
32
31
  <div
33
- class="MuiPaper-root MuiDialog-paper PicassoModal-paper PicassoModal-small MuiDialog-paperScrollPaper MuiDialog-paperWidthFalse MuiPaper-elevation2"
34
- role="dialog"
32
+ class="pr-6 mt-8 mx-8 mb-0"
35
33
  >
36
- <div
37
- class="PicassoModalTitle-root"
34
+ <h2
35
+ class="m-0 text-xl text-black font-semibold"
38
36
  >
39
- <h2
40
- class="m-0 text-xl text-black font-semibold"
41
- >
42
- Test title
43
- </h2>
44
- </div>
37
+ Test title
38
+ </h2>
39
+ </div>
40
+ <div
41
+ class="flex relative flex-auto overflow-y"
42
+ >
45
43
  <div
46
- class="PicassoModalContent-wrapper"
44
+ class="pt-6 px-8 pb-8 overflow-auto flex-auto"
47
45
  >
48
- <div
49
- class="PicassoModalContent-modalContent"
46
+ <p
47
+ class="m-0 text-md text-graphite font-regular"
50
48
  >
51
- <p
52
- class="m-0 text-md text-graphite font-regular"
53
- >
54
- Test message
55
- </p>
56
- </div>
49
+ Test message
50
+ </p>
57
51
  </div>
58
- <div
59
- class="PicassoModalAction-root"
52
+ </div>
53
+ <div
54
+ class="mt-0 mx-8 mb-8 text-right"
55
+ >
56
+ <button
57
+ aria-disabled="false"
58
+ class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle transition-colors duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline hover:no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] focus-within:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border border-solid text-black hover:border-black visited:text-black active:bg-gray active:border-black bg-white border-gray min-w h-8 py-0 px-4"
59
+ data-component-type="button"
60
+ role="button"
61
+ tabindex="0"
62
+ type="button"
60
63
  >
61
- <button
62
- aria-disabled="false"
63
- class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle transition-colors duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline hover:no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] focus-within:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border border-solid text-black hover:border-black visited:text-black active:bg-gray active:border-black bg-white border-gray min-w h-8 py-0 px-4"
64
- data-component-type="button"
65
- role="button"
66
- tabindex="0"
67
- type="button"
64
+ <span
65
+ class="items-center inline-flex font-semibold whitespace-nowrap text-button"
68
66
  >
69
- <span
70
- class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline font-semibold whitespace-nowrap text-button"
71
- >
72
- Cancel
73
- </span>
74
- </button>
75
- <button
76
- aria-disabled="false"
77
- class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle transition-colors duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline hover:no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] focus-within:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border-none text-white visited:text-white hover:bg-[#27D496] active:bg-[#00A96C] bg-green min-w h-8 py-0 px-4"
78
- data-component-type="button"
79
- role="button"
80
- tabindex="0"
81
- type="button"
67
+ Cancel
68
+ </span>
69
+ </button>
70
+ <button
71
+ aria-disabled="false"
72
+ class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle transition-colors duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline hover:no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] focus-within:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border-none text-white visited:text-white hover:bg-[#27D496] active:bg-[#00A96C] bg-green min-w h-8 py-0 px-4"
73
+ data-component-type="button"
74
+ role="button"
75
+ tabindex="0"
76
+ type="button"
77
+ >
78
+ <span
79
+ class="items-center inline-flex font-semibold whitespace-nowrap text-button"
82
80
  >
83
- <span
84
- class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline font-semibold whitespace-nowrap text-button"
85
- >
86
- Submit
87
- </span>
88
- </button>
89
- </div>
81
+ Submit
82
+ </span>
83
+ </button>
90
84
  </div>
91
85
  </div>
92
86
  <div
93
- data-test="sentinelEnd"
87
+ data-testid="sentinelEnd"
94
88
  tabindex="0"
95
89
  />
96
90
  </div>
@@ -112,7 +106,7 @@ exports[`PromptModal showPrompt opens and closes modal on Submit action 1`] = `
112
106
  type="button"
113
107
  >
114
108
  <span
115
- class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline font-semibold whitespace-nowrap text-button"
109
+ class="items-center inline-flex font-semibold whitespace-nowrap text-button"
116
110
  >
117
111
  Show
118
112
  </span>
@@ -138,93 +132,87 @@ exports[`PromptModal showPrompt opens and closes modal on Submit action 2`] = `
138
132
  type="button"
139
133
  >
140
134
  <span
141
- class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline font-semibold whitespace-nowrap text-button"
135
+ class="items-center inline-flex font-semibold whitespace-nowrap text-button"
142
136
  >
143
137
  Show
144
138
  </span>
145
139
  </button>
146
140
  <div
147
- class="MuiDialog-root PicassoModal-root"
141
+ class="base-Modal fixed z-modal inset-0 flex flex-col text-lg leading-[normal] justify-center items-center"
148
142
  role="presentation"
149
- style="position: fixed; z-index: 1300; right: 0px; bottom: 0px; top: 0px; left: 0px;"
150
143
  >
151
144
  <div
152
145
  aria-hidden="true"
153
- class="MuiBackdrop-root"
154
- style="opacity: 1; webkit-transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;"
146
+ class="opacity-0 transition-opacity fixed -z inset-0 bg-black -webkit-tap-highlight-color bg-opacity"
147
+ style="transition-duration: 300ms; opacity: 1;"
155
148
  />
156
149
  <div
157
- data-test="sentinelStart"
150
+ data-testid="sentinelStart"
158
151
  tabindex="0"
159
152
  />
160
153
  <div
161
- class="MuiDialog-container PicassoModal-container MuiDialog-scrollPaper"
162
- role="none presentation"
163
- style="opacity: 1; webkit-transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;"
154
+ class="bg-white shadow-2 duration-300 delay-0 opacity-0 transition-opacity outline-none overflow-y flex flex-col m-4 sm:h-auto sm:m-8 max-w-[calc(100%_ sm:max-w-[calc(100%_ rounded-md w-[32.5rem] relative max-h-[calc(100%_ sm:max-h-[calc(100%_"
155
+ role="dialog"
156
+ style="transition-duration: 300ms; opacity: 1;"
164
157
  tabindex="-1"
165
158
  >
166
159
  <div
167
- class="MuiPaper-root MuiDialog-paper PicassoModal-paper PicassoModal-small MuiDialog-paperScrollPaper MuiDialog-paperWidthFalse MuiPaper-elevation2"
168
- role="dialog"
160
+ class="pr-6 mt-8 mx-8 mb-0"
169
161
  >
170
- <div
171
- class="PicassoModalTitle-root"
162
+ <h2
163
+ class="m-0 text-xl text-black font-semibold"
172
164
  >
173
- <h2
174
- class="m-0 text-xl text-black font-semibold"
175
- >
176
- Test title
177
- </h2>
178
- </div>
165
+ Test title
166
+ </h2>
167
+ </div>
168
+ <div
169
+ class="flex relative flex-auto overflow-y"
170
+ >
179
171
  <div
180
- class="PicassoModalContent-wrapper"
172
+ class="pt-6 px-8 pb-8 overflow-auto flex-auto"
181
173
  >
182
- <div
183
- class="PicassoModalContent-modalContent"
174
+ <p
175
+ class="m-0 text-md text-graphite font-regular"
184
176
  >
185
- <p
186
- class="m-0 text-md text-graphite font-regular"
187
- >
188
- Test message
189
- </p>
190
- </div>
177
+ Test message
178
+ </p>
191
179
  </div>
192
- <div
193
- class="PicassoModalAction-root"
180
+ </div>
181
+ <div
182
+ class="mt-0 mx-8 mb-8 text-right"
183
+ >
184
+ <button
185
+ aria-disabled="false"
186
+ class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle transition-colors duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline hover:no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] focus-within:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border border-solid text-black hover:border-black visited:text-black active:bg-gray active:border-black bg-white border-gray min-w h-8 py-0 px-4"
187
+ data-component-type="button"
188
+ role="button"
189
+ tabindex="0"
190
+ type="button"
194
191
  >
195
- <button
196
- aria-disabled="false"
197
- class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle transition-colors duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline hover:no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] focus-within:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border border-solid text-black hover:border-black visited:text-black active:bg-gray active:border-black bg-white border-gray min-w h-8 py-0 px-4"
198
- data-component-type="button"
199
- role="button"
200
- tabindex="0"
201
- type="button"
192
+ <span
193
+ class="items-center inline-flex font-semibold whitespace-nowrap text-button"
202
194
  >
203
- <span
204
- class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline font-semibold whitespace-nowrap text-button"
205
- >
206
- Cancel
207
- </span>
208
- </button>
209
- <button
210
- aria-disabled="false"
211
- class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle transition-colors duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline hover:no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] focus-within:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border-none text-white visited:text-white hover:bg-[#27D496] active:bg-[#00A96C] bg-green min-w h-8 py-0 px-4"
212
- data-component-type="button"
213
- role="button"
214
- tabindex="0"
215
- type="button"
195
+ Cancel
196
+ </span>
197
+ </button>
198
+ <button
199
+ aria-disabled="false"
200
+ class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle transition-colors duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline hover:no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] focus-within:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border-none text-white visited:text-white hover:bg-[#27D496] active:bg-[#00A96C] bg-green min-w h-8 py-0 px-4"
201
+ data-component-type="button"
202
+ role="button"
203
+ tabindex="0"
204
+ type="button"
205
+ >
206
+ <span
207
+ class="items-center inline-flex font-semibold whitespace-nowrap text-button"
216
208
  >
217
- <span
218
- class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline font-semibold whitespace-nowrap text-button"
219
- >
220
- Submit
221
- </span>
222
- </button>
223
- </div>
209
+ Submit
210
+ </span>
211
+ </button>
224
212
  </div>
225
213
  </div>
226
214
  <div
227
- data-test="sentinelEnd"
215
+ data-testid="sentinelEnd"
228
216
  tabindex="0"
229
217
  />
230
218
  </div>
@@ -248,7 +236,7 @@ exports[`PromptModal showPrompt opens and closes modal on Submit action 3`] = `
248
236
  type="button"
249
237
  >
250
238
  <span
251
- class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline font-semibold whitespace-nowrap text-button"
239
+ class="items-center inline-flex font-semibold whitespace-nowrap text-button"
252
240
  >
253
241
  Show
254
242
  </span>
@@ -273,7 +261,7 @@ exports[`PromptModal showPrompt with input returns result on Submit action 1`] =
273
261
  type="button"
274
262
  >
275
263
  <span
276
- class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline font-semibold whitespace-nowrap text-button"
264
+ class="items-center inline-flex font-semibold whitespace-nowrap text-button"
277
265
  >
278
266
  Show
279
267
  </span>
@@ -1,3 +0,0 @@
1
- declare const _default: () => import("@material-ui/styles").StyleRules<{}, never>;
2
- export default _default;
3
- //# sourceMappingURL=styles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/PromptModal/styles.ts"],"names":[],"mappings":";AAEA,wBAAqC"}
@@ -1,3 +0,0 @@
1
- import { createStyles } from '@material-ui/core/styles';
2
- export default () => createStyles({});
3
- //# sourceMappingURL=styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/PromptModal/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,eAAe,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA"}
@@ -1,3 +0,0 @@
1
- import { createStyles } from '@material-ui/core/styles'
2
-
3
- export default () => createStyles({})