@pareto-engineering/design-system 4.0.0-alpha.78 → 4.0.0-alpha.81
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/dist/cjs/a/Label/styles.scss +1 -1
- package/dist/cjs/a/Quote/styles.scss +1 -1
- package/dist/cjs/a/Tooltip/Tooltip.js +21 -5
- package/dist/cjs/a/Tooltip/styles.scss +44 -36
- package/dist/cjs/a/index.js +0 -7
- package/dist/cjs/b/Page/common/PageHelmet/PageHelmet.js +4 -1
- package/dist/cjs/b/index.js +1 -8
- package/dist/cjs/f/fields/EditorInput/EditorInput.js +18 -4
- package/dist/cjs/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +8 -4
- package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +0 -6
- package/dist/cjs/f/fields/EditorInput/styles.scss +9 -2
- package/dist/cjs/f/fields/SelectInput/SelectInput.js +9 -2
- package/dist/cjs/f/fields/SelectInput/common/Single/Single.js +13 -2
- package/dist/cjs/f/fields/SelectInput/styles.scss +1 -1
- package/dist/cjs/{b → g}/ExpandableLexicalPreview/ExpandableLexicalPreview.js +59 -47
- package/dist/cjs/g/ExpandableLexicalPreview/common/NewWindowPortal/NewWindowPortal.js +79 -0
- package/dist/cjs/g/ExpandableLexicalPreview/common/NewWindowPortal/index.js +13 -0
- package/dist/cjs/g/ExpandableLexicalPreview/common/NewWindowPortal/styles.scss +9 -0
- package/dist/cjs/g/ExpandableLexicalPreview/common/index.js +12 -0
- package/dist/cjs/g/ExpandableLexicalPreview/styles.scss +34 -0
- package/dist/cjs/g/index.js +12 -0
- package/dist/cjs/index.js +11 -0
- package/dist/es/a/Label/styles.scss +1 -1
- package/dist/es/a/Quote/styles.scss +1 -1
- package/dist/es/a/Tooltip/Tooltip.js +21 -5
- package/dist/es/a/Tooltip/styles.scss +44 -36
- package/dist/es/a/index.js +0 -1
- package/dist/es/b/Page/common/PageHelmet/PageHelmet.js +4 -1
- package/dist/es/b/index.js +1 -2
- package/dist/es/f/fields/EditorInput/EditorInput.js +16 -3
- package/dist/es/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +8 -4
- package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +0 -6
- package/dist/es/f/fields/EditorInput/styles.scss +9 -2
- package/dist/es/f/fields/SelectInput/SelectInput.js +9 -2
- package/dist/es/f/fields/SelectInput/common/Single/Single.js +12 -1
- package/dist/es/f/fields/SelectInput/styles.scss +1 -1
- package/dist/es/g/ExpandableLexicalPreview/ExpandableLexicalPreview.js +126 -0
- package/dist/es/g/ExpandableLexicalPreview/common/NewWindowPortal/NewWindowPortal.js +70 -0
- package/dist/es/g/ExpandableLexicalPreview/common/NewWindowPortal/index.js +2 -0
- package/dist/es/g/ExpandableLexicalPreview/common/NewWindowPortal/styles.scss +9 -0
- package/dist/es/g/ExpandableLexicalPreview/common/index.js +1 -0
- package/dist/es/g/ExpandableLexicalPreview/styles.scss +34 -0
- package/dist/es/g/index.js +1 -0
- package/dist/es/index.js +1 -0
- package/package.json +4 -4
- package/src/stories/a/Tooltip.stories.jsx +7 -12
- package/src/stories/f/SelectInput.stories.jsx +18 -2
- package/src/stories/{b → g}/ExpandableLexicalPreview.stories.jsx +13 -5
- package/src/ui/a/Label/styles.scss +1 -1
- package/src/ui/a/Quote/styles.scss +1 -1
- package/src/ui/a/Tooltip/Tooltip.jsx +27 -4
- package/src/ui/a/Tooltip/styles.scss +44 -36
- package/src/ui/a/index.js +0 -1
- package/src/ui/b/Page/common/PageHelmet/PageHelmet.jsx +6 -0
- package/src/ui/b/index.js +0 -1
- package/src/ui/f/fields/EditorInput/EditorInput.jsx +14 -1
- package/src/ui/f/fields/EditorInput/common/ColorPicker/ColorPicker.jsx +8 -3
- package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.jsx +0 -14
- package/src/ui/f/fields/EditorInput/styles.scss +9 -2
- package/src/ui/f/fields/SelectInput/SelectInput.jsx +10 -2
- package/src/ui/f/fields/SelectInput/common/Single/Single.jsx +13 -1
- package/src/ui/f/fields/SelectInput/styles.scss +1 -1
- package/src/ui/g/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +180 -0
- package/src/ui/g/ExpandableLexicalPreview/common/NewWindowPortal/NewWindowPortal.jsx +80 -0
- package/src/ui/g/ExpandableLexicalPreview/common/NewWindowPortal/index.js +2 -0
- package/src/ui/g/ExpandableLexicalPreview/common/NewWindowPortal/styles.scss +9 -0
- package/src/ui/g/ExpandableLexicalPreview/common/index.js +1 -0
- package/src/ui/g/ExpandableLexicalPreview/styles.scss +34 -0
- package/src/ui/g/index.js +1 -0
- package/src/ui/index.js +1 -0
- package/tests/__snapshots__/Storyshots.test.js.snap +221 -99
- package/dist/cjs/a/LexicalPreview/LexicalPreview.js +0 -90
- package/dist/cjs/a/LexicalPreview/index.js +0 -13
- package/dist/cjs/a/LexicalPreview/styles.scss +0 -46
- package/dist/cjs/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +0 -112
- package/dist/cjs/b/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -13
- package/dist/cjs/b/ExpandableLexicalPreview/common/index.js +0 -12
- package/dist/cjs/b/ExpandableLexicalPreview/styles.scss +0 -84
- package/dist/es/a/LexicalPreview/LexicalPreview.js +0 -80
- package/dist/es/a/LexicalPreview/index.js +0 -2
- package/dist/es/a/LexicalPreview/styles.scss +0 -46
- package/dist/es/b/ExpandableLexicalPreview/ExpandableLexicalPreview.js +0 -115
- package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +0 -102
- package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -1
- package/dist/es/b/ExpandableLexicalPreview/common/index.js +0 -1
- package/dist/es/b/ExpandableLexicalPreview/styles.scss +0 -84
- package/src/stories/a/LexicalPreview.stories.jsx +0 -28
- package/src/ui/a/LexicalPreview/LexicalPreview.jsx +0 -109
- package/src/ui/a/LexicalPreview/index.js +0 -2
- package/src/ui/a/LexicalPreview/styles.scss +0 -46
- package/src/ui/b/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +0 -157
- package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.jsx +0 -123
- package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -1
- package/src/ui/b/ExpandableLexicalPreview/common/index.js +0 -1
- package/src/ui/b/ExpandableLexicalPreview/styles.scss +0 -84
- /package/dist/cjs/{b → g}/ExpandableLexicalPreview/index.js +0 -0
- /package/dist/es/{b → g}/ExpandableLexicalPreview/index.js +0 -0
- /package/src/ui/{b → g}/ExpandableLexicalPreview/index.js +0 -0
|
@@ -28,11 +28,11 @@ const ColorPicker = ({
|
|
|
28
28
|
className:userClassName,
|
|
29
29
|
style,
|
|
30
30
|
icon,
|
|
31
|
-
|
|
31
|
+
defaultColorHex,
|
|
32
32
|
onChange,
|
|
33
33
|
// ...otherProps
|
|
34
34
|
}) => {
|
|
35
|
-
const [colorValue, setColor] = useColor(
|
|
35
|
+
const [colorValue, setColor] = useColor(defaultColorHex)
|
|
36
36
|
|
|
37
37
|
const parentRef = useRef(null)
|
|
38
38
|
|
|
@@ -101,10 +101,15 @@ ColorPicker.propTypes = {
|
|
|
101
101
|
* The React-written, css properties for this element.
|
|
102
102
|
*/
|
|
103
103
|
style:PropTypes.objectOf(PropTypes.string),
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The required default hex value for the color picker
|
|
107
|
+
*/
|
|
108
|
+
defaultColorHex:PropTypes.string,
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
ColorPicker.defaultProps = {
|
|
107
|
-
|
|
112
|
+
defaultColorHex:'#ffffff',
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
export default ColorPicker
|
|
@@ -98,8 +98,6 @@ const ToolbarPlugin = ({
|
|
|
98
98
|
const [activeEditor, setActiveEditor] = useState(editor)
|
|
99
99
|
const [blockType, setBlockType] = useState('paragraph')
|
|
100
100
|
const [rootType, setRootType] = useState('root')
|
|
101
|
-
const [fontColor, setFontColor] = useState('#000000')
|
|
102
|
-
const [bgColor, setBgColor] = useState('#ffffff')
|
|
103
101
|
const [fontSize, setFontSize] = useState('15px')
|
|
104
102
|
const [isEditable, setIsEditable] = useState(() => editor.isEditable())
|
|
105
103
|
const [isBold, setIsBold] = useState(false)
|
|
@@ -180,16 +178,6 @@ const ToolbarPlugin = ({
|
|
|
180
178
|
setFontSize(
|
|
181
179
|
$getSelectionStyleValueForProperty(selection, 'font-size', '15px'),
|
|
182
180
|
)
|
|
183
|
-
setFontColor(
|
|
184
|
-
$getSelectionStyleValueForProperty(selection, 'color', '#000'),
|
|
185
|
-
)
|
|
186
|
-
setBgColor(
|
|
187
|
-
$getSelectionStyleValueForProperty(
|
|
188
|
-
selection,
|
|
189
|
-
'background-color',
|
|
190
|
-
'#fff',
|
|
191
|
-
),
|
|
192
|
-
)
|
|
193
181
|
}
|
|
194
182
|
}, [activeEditor])
|
|
195
183
|
|
|
@@ -354,12 +342,10 @@ const ToolbarPlugin = ({
|
|
|
354
342
|
<div className="group">
|
|
355
343
|
<ColorPicker
|
|
356
344
|
icon="'"
|
|
357
|
-
color={fontColor}
|
|
358
345
|
onChange={onFontColorSelect}
|
|
359
346
|
/>
|
|
360
347
|
<ColorPicker
|
|
361
348
|
icon="#"
|
|
362
|
-
color={bgColor}
|
|
363
349
|
onChange={onBgColorSelect}
|
|
364
350
|
/>
|
|
365
351
|
</div>
|
|
@@ -32,6 +32,11 @@ $default-check-mark-dimensions: 1rem;
|
|
|
32
32
|
border: $focus-border;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
> .content-editable {
|
|
37
|
+
border-bottom-left-radius: $default-input-border-radius;
|
|
38
|
+
border-bottom-right-radius: $default-input-border-radius;
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
&.disabled {
|
|
@@ -40,6 +45,10 @@ $default-check-mark-dimensions: 1rem;
|
|
|
40
45
|
color: var(--metadata);
|
|
41
46
|
cursor: not-allowed;
|
|
42
47
|
}
|
|
48
|
+
|
|
49
|
+
> .content-editable {
|
|
50
|
+
border-radius: $default-input-border-radius;
|
|
51
|
+
}
|
|
43
52
|
}
|
|
44
53
|
|
|
45
54
|
.color-menu-button {
|
|
@@ -70,8 +79,6 @@ $default-check-mark-dimensions: 1rem;
|
|
|
70
79
|
> .content-editable {
|
|
71
80
|
background: $default-background;
|
|
72
81
|
border: $default-border;
|
|
73
|
-
border-bottom-left-radius: $default-input-border-radius;
|
|
74
|
-
border-bottom-right-radius: $default-input-border-radius;
|
|
75
82
|
color: var(--y);
|
|
76
83
|
height: var(--rows);
|
|
77
84
|
outline: none;
|
|
@@ -29,6 +29,7 @@ const SelectInput = ({
|
|
|
29
29
|
labelColor,
|
|
30
30
|
color,
|
|
31
31
|
options,
|
|
32
|
+
hasDefault,
|
|
32
33
|
validate,
|
|
33
34
|
optional,
|
|
34
35
|
description,
|
|
@@ -46,6 +47,7 @@ const SelectInput = ({
|
|
|
46
47
|
labelColor,
|
|
47
48
|
color,
|
|
48
49
|
options,
|
|
50
|
+
hasDefault,
|
|
49
51
|
validate,
|
|
50
52
|
optional,
|
|
51
53
|
description,
|
|
@@ -162,11 +164,17 @@ SelectInput.propTypes = {
|
|
|
162
164
|
* The placeholder of the select input
|
|
163
165
|
*/
|
|
164
166
|
placeholder:PropTypes.string,
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Whether this select input has a default value(s)
|
|
170
|
+
*/
|
|
171
|
+
hasDefault:PropTypes.bool,
|
|
165
172
|
}
|
|
166
173
|
|
|
167
174
|
SelectInput.defaultProps = {
|
|
168
|
-
disabled:false,
|
|
169
|
-
multiple:false,
|
|
175
|
+
disabled :false,
|
|
176
|
+
multiple :false,
|
|
177
|
+
hasDefault:false,
|
|
170
178
|
}
|
|
171
179
|
|
|
172
180
|
export default memo(SelectInput)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
2
|
import * as React from 'react'
|
|
3
3
|
|
|
4
|
+
import { useEffect } from 'react'
|
|
5
|
+
|
|
4
6
|
import { useField } from 'formik'
|
|
5
7
|
|
|
6
8
|
import PropTypes from 'prop-types'
|
|
@@ -29,6 +31,7 @@ const Single = ({
|
|
|
29
31
|
labelColor,
|
|
30
32
|
color,
|
|
31
33
|
options,
|
|
34
|
+
hasDefault,
|
|
32
35
|
validate,
|
|
33
36
|
optional,
|
|
34
37
|
description,
|
|
@@ -37,7 +40,16 @@ const Single = ({
|
|
|
37
40
|
autoComplete,
|
|
38
41
|
// ...otherProps
|
|
39
42
|
}) => {
|
|
40
|
-
const [field] = useField({ name, validate })
|
|
43
|
+
const [field, , helpers] = useField({ name, validate })
|
|
44
|
+
|
|
45
|
+
const { setValue } = helpers
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (hasDefault && !field.value) {
|
|
49
|
+
const defaultOption = options.find((option) => option.isDefault)
|
|
50
|
+
setValue(defaultOption?.value)
|
|
51
|
+
}
|
|
52
|
+
}, [hasDefault])
|
|
41
53
|
|
|
42
54
|
return (
|
|
43
55
|
<div
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { useState } from 'react'
|
|
5
|
+
|
|
6
|
+
import { Formik } from 'formik'
|
|
7
|
+
|
|
8
|
+
import PropTypes from 'prop-types'
|
|
9
|
+
|
|
10
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
11
|
+
|
|
12
|
+
// Local Definitions
|
|
13
|
+
import { EditorInput } from 'ui/f'
|
|
14
|
+
|
|
15
|
+
import { Button } from 'ui/b'
|
|
16
|
+
|
|
17
|
+
import { NewWindowPortal } from './common'
|
|
18
|
+
|
|
19
|
+
import './styles.scss'
|
|
20
|
+
|
|
21
|
+
const baseClassName = styleNames.base
|
|
22
|
+
|
|
23
|
+
const componentClassName = 'expandable-lexical-preview'
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This is the component description.
|
|
27
|
+
*/
|
|
28
|
+
const ExpandableLexicalPreview = ({
|
|
29
|
+
id,
|
|
30
|
+
className:userClassName,
|
|
31
|
+
style,
|
|
32
|
+
nodes,
|
|
33
|
+
name,
|
|
34
|
+
color,
|
|
35
|
+
resize,
|
|
36
|
+
pageTitle,
|
|
37
|
+
onBlock,
|
|
38
|
+
onOpen,
|
|
39
|
+
header,
|
|
40
|
+
// ...otherProps
|
|
41
|
+
}) => {
|
|
42
|
+
const [isCollapsed, setIsCollapsed] = useState(false)
|
|
43
|
+
|
|
44
|
+
const handleButtonClick = () => {
|
|
45
|
+
setIsCollapsed(!isCollapsed)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Formik
|
|
50
|
+
initialValues={{
|
|
51
|
+
[name]:nodes,
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
id={id}
|
|
56
|
+
className={[
|
|
57
|
+
|
|
58
|
+
baseClassName,
|
|
59
|
+
|
|
60
|
+
componentClassName,
|
|
61
|
+
userClassName,
|
|
62
|
+
`y-${color}`,
|
|
63
|
+
isCollapsed && 'collapsed',
|
|
64
|
+
]
|
|
65
|
+
.filter((e) => e)
|
|
66
|
+
.join(' ')}
|
|
67
|
+
style={style}
|
|
68
|
+
>
|
|
69
|
+
{typeof header === 'string' ? <p className="title h2">{header}</p> : header}
|
|
70
|
+
{isCollapsed ? (
|
|
71
|
+
<>
|
|
72
|
+
<Button
|
|
73
|
+
onClick={handleButtonClick}
|
|
74
|
+
color="background-far"
|
|
75
|
+
isCompact
|
|
76
|
+
>
|
|
77
|
+
<span className="ai-icon c-x x-paragraph">
|
|
78
|
+
C
|
|
79
|
+
</span>
|
|
80
|
+
</Button>
|
|
81
|
+
<NewWindowPortal
|
|
82
|
+
pageTitle={pageTitle}
|
|
83
|
+
onBlock={() => {
|
|
84
|
+
onBlock?.()
|
|
85
|
+
setIsCollapsed(false)
|
|
86
|
+
}}
|
|
87
|
+
onOpen={() => {
|
|
88
|
+
onOpen?.()
|
|
89
|
+
setIsCollapsed(true)
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<EditorInput
|
|
93
|
+
name={name}
|
|
94
|
+
resize={resize}
|
|
95
|
+
disabled
|
|
96
|
+
/>
|
|
97
|
+
</NewWindowPortal>
|
|
98
|
+
</>
|
|
99
|
+
) : (
|
|
100
|
+
<>
|
|
101
|
+
<EditorInput
|
|
102
|
+
name={name}
|
|
103
|
+
resize={resize}
|
|
104
|
+
disabled
|
|
105
|
+
id="the-bad-ass-input"
|
|
106
|
+
/>
|
|
107
|
+
<Button
|
|
108
|
+
id={id}
|
|
109
|
+
className="expand-button ai-icon"
|
|
110
|
+
color="background-far"
|
|
111
|
+
isCompact
|
|
112
|
+
onClick={handleButtonClick}
|
|
113
|
+
>
|
|
114
|
+
D
|
|
115
|
+
</Button>
|
|
116
|
+
</>
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
</Formik>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
ExpandableLexicalPreview.propTypes = {
|
|
124
|
+
/**
|
|
125
|
+
* The HTML id for this element
|
|
126
|
+
*/
|
|
127
|
+
id:PropTypes.string,
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The HTML class names for this element
|
|
131
|
+
*/
|
|
132
|
+
className:PropTypes.string,
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The React-written, css properties for this element.
|
|
136
|
+
*/
|
|
137
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Color of the text
|
|
141
|
+
*/
|
|
142
|
+
color:PropTypes.string,
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The nodes to render in the form of a json string
|
|
146
|
+
*/
|
|
147
|
+
nodes:PropTypes.string,
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The resize property of the textarea
|
|
151
|
+
*/
|
|
152
|
+
resize:PropTypes.string,
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The header for the preview component.
|
|
156
|
+
*/
|
|
157
|
+
header:PropTypes.node,
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The page title for the expanded preview.
|
|
161
|
+
*/
|
|
162
|
+
pageTitle:PropTypes.string,
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The name used to acces the nodes
|
|
166
|
+
*/
|
|
167
|
+
name:PropTypes.string.isRequired,
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The function to run when a new window portal can be opened
|
|
171
|
+
*/
|
|
172
|
+
onBlock:PropTypes.func.isRequired,
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
ExpandableLexicalPreview.defaultProps = {
|
|
176
|
+
color :'paragraph',
|
|
177
|
+
resize:'vertical',
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export default ExpandableLexicalPreview
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import { createPortal } from 'react-dom'
|
|
3
|
+
|
|
4
|
+
import { useState, useEffect, useMemo } from 'react'
|
|
5
|
+
|
|
6
|
+
import PropTypes from 'prop-types'
|
|
7
|
+
|
|
8
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
9
|
+
|
|
10
|
+
// Local Definitions
|
|
11
|
+
import { useTheme } from 'ui/a'
|
|
12
|
+
|
|
13
|
+
import './styles.scss'
|
|
14
|
+
|
|
15
|
+
const baseClassName = styleNames.base
|
|
16
|
+
|
|
17
|
+
const copyStyles = (sourceDocument, targetDocument) => {
|
|
18
|
+
Array.from(sourceDocument.querySelectorAll('link[rel="stylesheet"], style'))
|
|
19
|
+
.forEach((link) => {
|
|
20
|
+
targetDocument.head.appendChild(link.cloneNode(true))
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* This is the component description.
|
|
25
|
+
*/
|
|
26
|
+
const NewWindowPortal = ({
|
|
27
|
+
children, pageTitle, onBlock, onOpen,
|
|
28
|
+
}) => {
|
|
29
|
+
const [newWindow, setNewWindow] = useState(null)
|
|
30
|
+
const container = useMemo(() => document.createElement('div'), [])
|
|
31
|
+
const { userTheme = 'light' } = useTheme()
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!container) return
|
|
35
|
+
|
|
36
|
+
container.classList.add(baseClassName, 'new-window-portal', `ui-${userTheme}`)
|
|
37
|
+
const newExternalWindow = window.open('', pageTitle, 'width="100%",height="100%"')
|
|
38
|
+
|
|
39
|
+
if (newExternalWindow) {
|
|
40
|
+
newExternalWindow.document.title = pageTitle
|
|
41
|
+
newExternalWindow.document.body.appendChild(container)
|
|
42
|
+
setNewWindow(newExternalWindow)
|
|
43
|
+
onOpen()
|
|
44
|
+
} else {
|
|
45
|
+
console.warn('A new window / tab could not be opened. Check your settings and/or extensions, maybe it was blocked.')
|
|
46
|
+
onBlock()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line consistent-return
|
|
50
|
+
return () => {
|
|
51
|
+
container.classList.remove(...container.classList)
|
|
52
|
+
newExternalWindow?.close()
|
|
53
|
+
}
|
|
54
|
+
}, [container, pageTitle, userTheme])
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (newWindow) {
|
|
58
|
+
copyStyles(document, newWindow.document)
|
|
59
|
+
}
|
|
60
|
+
}, [newWindow])
|
|
61
|
+
|
|
62
|
+
return createPortal(children, container)
|
|
63
|
+
}
|
|
64
|
+
NewWindowPortal.propTypes = {
|
|
65
|
+
/**
|
|
66
|
+
* The children JSX
|
|
67
|
+
*/
|
|
68
|
+
children:PropTypes.node,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The new window page title
|
|
72
|
+
*/
|
|
73
|
+
pageTitle:PropTypes.string.isRequired,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
NewWindowPortal.defaultProps = {
|
|
77
|
+
// someProp:false
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default NewWindowPortal
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NewWindowPortal } from './NewWindowPortal'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
.#{bem.$base}.expandable-lexical-preview {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
flex-wrap: wrap;
|
|
9
|
+
gap: var(--gap);
|
|
10
|
+
position: relative;
|
|
11
|
+
width: 100%;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
&.collapsed {
|
|
15
|
+
flex-direction: row;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
> .title {
|
|
19
|
+
margin: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
> .#{bem.$base}.button {
|
|
23
|
+
align-items: center;
|
|
24
|
+
border: 1px solid var(--outline-inputs);
|
|
25
|
+
display: flex;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
> .#{bem.$base}.expand-button {
|
|
29
|
+
border: 1px solid var(--outline-inputs);
|
|
30
|
+
position: absolute;
|
|
31
|
+
right: 1em;
|
|
32
|
+
top: 5.5rem;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ExpandableLexicalPreview } from './ExpandableLexicalPreview'
|