@startlibs/components 1.1.4 → 1.2.0-rc.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.
- package/lib/BasicBulletList.mjs +1 -1
- package/lib/BasicBulletList.mjs.map +1 -1
- package/lib/Button.mjs +3 -3
- package/lib/Button.mjs.map +1 -1
- package/lib/ContextMenu.mjs +22 -6
- package/lib/ContextMenu.mjs.map +1 -1
- package/lib/Dialog.mjs +60 -24
- package/lib/Dialog.mjs.map +1 -1
- package/lib/Icon.mjs +10 -4
- package/lib/Icon.mjs.map +1 -1
- package/lib/Loading.mjs +26 -3
- package/lib/Loading.mjs.map +1 -1
- package/lib/PageLoader.mjs +2 -2
- package/lib/PageLoader.mjs.map +1 -1
- package/lib/PersistentNotifications.mjs +1 -1
- package/lib/PersistentNotifications.mjs.map +1 -1
- package/lib/SplitColumnsContainer.mjs +77 -6
- package/lib/SplitColumnsContainer.mjs.map +1 -1
- package/lib/TextButton.mjs +1 -1
- package/lib/TextButton.mjs.map +1 -1
- package/lib/ToastNotifications.mjs +16 -14
- package/lib/ToastNotifications.mjs.map +1 -1
- package/lib/alt/dialogs/DialogWithImageHeader.mjs +1 -1
- package/lib/alt/dialogs/DialogWithImageHeader.mjs.map +1 -1
- package/lib/alt/dialogs/DialogWithSidebar.mjs +7 -3
- package/lib/alt/dialogs/DialogWithSidebar.mjs.map +1 -1
- package/lib/alt/dialogs/MobileBubbleDialog.mjs +1 -1
- package/lib/alt/dialogs/MobileBubbleDialog.mjs.map +1 -1
- package/lib/containers/DialogContainer.mjs +29 -10
- package/lib/containers/DialogContainer.mjs.map +1 -1
- package/lib/index.cjs +286 -93
- package/lib/index.cjs.map +1 -1
- package/lib/willUseIsSticky.mjs +23 -2
- package/lib/willUseIsSticky.mjs.map +1 -1
- package/lib-yak/BasicBulletList.mjs +27 -0
- package/lib-yak/BasicBulletList.mjs.map +1 -0
- package/lib-yak/Button.mjs +374 -0
- package/lib-yak/Button.mjs.map +1 -0
- package/lib-yak/ContextMenu.mjs +642 -0
- package/lib-yak/ContextMenu.mjs.map +1 -0
- package/lib-yak/Dialog.mjs +469 -0
- package/lib-yak/Dialog.mjs.map +1 -0
- package/lib-yak/Draggable.mjs +892 -0
- package/lib-yak/Draggable.mjs.map +1 -0
- package/lib-yak/ErrorBoundary.mjs +108 -0
- package/lib-yak/ErrorBoundary.mjs.map +1 -0
- package/lib-yak/FillLastLineResizer.mjs +238 -0
- package/lib-yak/FillLastLineResizer.mjs.map +1 -0
- package/lib-yak/Flip.mjs +644 -0
- package/lib-yak/Flip.mjs.map +1 -0
- package/lib-yak/FlipList.mjs +186 -0
- package/lib-yak/FlipList.mjs.map +1 -0
- package/lib-yak/FormatDate.mjs +25 -0
- package/lib-yak/FormatDate.mjs.map +1 -0
- package/lib-yak/Icon.mjs +74 -0
- package/lib-yak/Icon.mjs.map +1 -0
- package/lib-yak/Image.mjs +41 -0
- package/lib-yak/Image.mjs.map +1 -0
- package/lib-yak/Link.mjs +116 -0
- package/lib-yak/Link.mjs.map +1 -0
- package/lib-yak/Loading.mjs +54 -0
- package/lib-yak/Loading.mjs.map +1 -0
- package/lib-yak/LoadingDiv.mjs +82 -0
- package/lib-yak/LoadingDiv.mjs.map +1 -0
- package/lib-yak/Notifications.mjs +99 -0
- package/lib-yak/Notifications.mjs.map +1 -0
- package/lib-yak/PageLoader.mjs +61 -0
- package/lib-yak/PageLoader.mjs.map +1 -0
- package/lib-yak/PersistentNotifications.mjs +209 -0
- package/lib-yak/PersistentNotifications.mjs.map +1 -0
- package/lib-yak/Popup.mjs +66 -0
- package/lib-yak/Popup.mjs.map +1 -0
- package/lib-yak/SplitColumnsContainer.mjs +140 -0
- package/lib-yak/SplitColumnsContainer.mjs.map +1 -0
- package/lib-yak/SwitchDiv.mjs +60 -0
- package/lib-yak/SwitchDiv.mjs.map +1 -0
- package/lib-yak/TextButton.mjs +61 -0
- package/lib-yak/TextButton.mjs.map +1 -0
- package/lib-yak/ToastNotifications.mjs +316 -0
- package/lib-yak/ToastNotifications.mjs.map +1 -0
- package/lib-yak/Tooltip.mjs +176 -0
- package/lib-yak/Tooltip.mjs.map +1 -0
- package/lib-yak/TransitionDiv.mjs +59 -0
- package/lib-yak/TransitionDiv.mjs.map +1 -0
- package/lib-yak/WarningDialog.mjs +107 -0
- package/lib-yak/WarningDialog.mjs.map +1 -0
- package/lib-yak/alt/buttons/OnClickLoadingButton.mjs +36 -0
- package/lib-yak/alt/buttons/OnClickLoadingButton.mjs.map +1 -0
- package/lib-yak/alt/dialogs/DialogWithImageHeader.mjs +50 -0
- package/lib-yak/alt/dialogs/DialogWithImageHeader.mjs.map +1 -0
- package/lib-yak/alt/dialogs/DialogWithSidebar.mjs +193 -0
- package/lib-yak/alt/dialogs/DialogWithSidebar.mjs.map +1 -0
- package/lib-yak/alt/dialogs/MobileBubbleDialog.mjs +82 -0
- package/lib-yak/alt/dialogs/MobileBubbleDialog.mjs.map +1 -0
- package/lib-yak/containers/DialogContainer.mjs +482 -0
- package/lib-yak/containers/DialogContainer.mjs.map +1 -0
- package/lib-yak/containers/Reposition.mjs +35 -0
- package/lib-yak/containers/Reposition.mjs.map +1 -0
- package/lib-yak/containers/usePositioning.mjs +311 -0
- package/lib-yak/containers/usePositioning.mjs.map +1 -0
- package/lib-yak/index.mjs +37 -0
- package/lib-yak/index.mjs.map +1 -0
- package/lib-yak/useDialogWithToggle.mjs +18 -0
- package/lib-yak/useDialogWithToggle.mjs.map +1 -0
- package/lib-yak/willUseIsSticky.mjs +147 -0
- package/lib-yak/willUseIsSticky.mjs.map +1 -0
- package/package.json +12 -3
- package/src/BasicBulletList.jsx +1 -1
- package/src/Button.jsx +36 -30
- package/src/ContextMenu.jsx +21 -7
- package/src/Dialog.jsx +30 -12
- package/src/Icon.jsx +5 -4
- package/src/Loading.jsx +19 -5
- package/src/PageLoader.jsx +3 -3
- package/src/PersistentNotifications.jsx +2 -2
- package/src/SplitColumnsContainer.jsx +89 -30
- package/src/TextButton.jsx +1 -1
- package/src/ToastNotifications.jsx +15 -8
- package/src/alt/dialogs/DialogWithImageHeader.jsx +2 -2
- package/src/alt/dialogs/DialogWithSidebar.jsx +6 -5
- package/src/alt/dialogs/MobileBubbleDialog.jsx +1 -1
- package/src/containers/DialogContainer.jsx +11 -4
- package/src/willUseIsSticky.jsx +22 -2
- package/lib/index.js +0 -5444
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startlibs/components",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.0-rc.1",
|
|
4
4
|
"description": "Startlibs Components",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"source": "./src/index.js",
|
|
9
|
+
"yak": "./lib-yak/index.mjs",
|
|
9
10
|
"require": "./lib/index.cjs",
|
|
10
11
|
"import": "./lib/index.mjs",
|
|
11
12
|
"default": "./lib/index.mjs"
|
|
12
13
|
},
|
|
13
14
|
"./package.json": "./package.json",
|
|
14
15
|
"./*": {
|
|
16
|
+
"yak": "./lib-yak/*.mjs",
|
|
15
17
|
"import": "./lib/*.mjs"
|
|
16
18
|
}
|
|
17
19
|
},
|
|
@@ -19,7 +21,8 @@
|
|
|
19
21
|
"source": "./src/index.js",
|
|
20
22
|
"peerDependencies": {
|
|
21
23
|
"@startlibs/core": "*",
|
|
22
|
-
"@startlibs/utils": "
|
|
24
|
+
"@startlibs/utils": ">=1.2.0-rc.1",
|
|
25
|
+
"@yak/react": "10.0.0",
|
|
23
26
|
"lodash": "^4.17.21",
|
|
24
27
|
"polished": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
25
28
|
"react": ">=16.8",
|
|
@@ -28,6 +31,11 @@
|
|
|
28
31
|
"styled-components": ">=5",
|
|
29
32
|
"wouter": "*"
|
|
30
33
|
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"@yak/react": {
|
|
36
|
+
"optional": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
31
39
|
"devDependencies": {
|
|
32
40
|
"@babel/core": "^7.2.0",
|
|
33
41
|
"@babel/plugin-transform-runtime": "^7.2.0",
|
|
@@ -50,7 +58,7 @@
|
|
|
50
58
|
},
|
|
51
59
|
"scripts": {
|
|
52
60
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
53
|
-
"build": "rollup -c",
|
|
61
|
+
"build": "rollup -c && rollup -c --environment YAK",
|
|
54
62
|
"prepare": "patch-package"
|
|
55
63
|
},
|
|
56
64
|
"repository": {
|
|
@@ -73,6 +81,7 @@
|
|
|
73
81
|
},
|
|
74
82
|
"files": [
|
|
75
83
|
"lib",
|
|
84
|
+
"lib-yak",
|
|
76
85
|
"src"
|
|
77
86
|
],
|
|
78
87
|
"module": "lib/index.mjs",
|
package/src/BasicBulletList.jsx
CHANGED
package/src/Button.jsx
CHANGED
|
@@ -25,7 +25,7 @@ const LockIcon = styled(Icon)`
|
|
|
25
25
|
`
|
|
26
26
|
|
|
27
27
|
const focus = css`
|
|
28
|
-
|
|
28
|
+
&:after{
|
|
29
29
|
content: '';
|
|
30
30
|
pointer-events: none;
|
|
31
31
|
position: absolute;
|
|
@@ -43,7 +43,7 @@ export const Button = styled(React.forwardRef(({
|
|
|
43
43
|
innerAs: Wrapper = 'button', className, children, rounded, tabIndex = 1, focused, noFocus,
|
|
44
44
|
colorSet, concealed, concealedModule, buttonRef, ...props
|
|
45
45
|
},ref) =>
|
|
46
|
-
<Wrapper ref={ref || buttonRef} tabIndex={tabIndex} className={className + ' styled-button' + ((color || success || alert || warning || highlight || dark || hover || outline || dashed || textOnly || white || alpha || props.lightAlert || props.lightWarning) ? ' styled-button-colored' : '')} type={Wrapper === 'button' ? type : ''} {...props}>
|
|
46
|
+
<Wrapper ref={ref || buttonRef} tabIndex={tabIndex} className={className + ' styled-button' + ((color || success || alert || warning || highlight || dark || hover || outline || dashed || textOnly || white || alpha || props.lightAlert || props.lightWarning) ? ' styled-button-colored' : '') + (small ? ' styled-button-small' : '')} type={Wrapper === 'button' ? type : ''} {...props}>
|
|
47
47
|
{icon && <Icon icon={icon} aria-hidden="true"/>}
|
|
48
48
|
{isLoadingIcon && <Loading white={!light && !outline && !dashed && !white} size={small ? '10' : '18'} borderWidth={small ? '2' : '3'}/>}
|
|
49
49
|
{(withDropdown || onlyDropdown) && !locked && <DropdownIcon icon='arrow-down' aria-hidden="true"/>}
|
|
@@ -60,7 +60,7 @@ export const Button = styled(React.forwardRef(({
|
|
|
60
60
|
min-width: 8rem;
|
|
61
61
|
font-weight: 600;
|
|
62
62
|
display: inline-block;
|
|
63
|
-
|
|
63
|
+
/* line-height: 16px; */
|
|
64
64
|
text-align: center;
|
|
65
65
|
padding: 10px 1.25rem;
|
|
66
66
|
outline: none;
|
|
@@ -69,17 +69,17 @@ export const Button = styled(React.forwardRef(({
|
|
|
69
69
|
text-decoration: none;
|
|
70
70
|
user-select: none;
|
|
71
71
|
flex-shrink: 0;
|
|
72
|
-
|
|
72
|
+
&:hover {
|
|
73
73
|
background: ${props => darken(0.05, getColor(props, true))};
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
&:active {
|
|
76
76
|
background: ${props => darken(0.08, getColor(props, true))};
|
|
77
77
|
}
|
|
78
78
|
${props => props.nowrap && `
|
|
79
79
|
white-space: nowrap;
|
|
80
80
|
`}
|
|
81
81
|
${props => !props.noFocus && !props.isLoading && css`
|
|
82
|
-
|
|
82
|
+
&:focus {
|
|
83
83
|
${focus}
|
|
84
84
|
}
|
|
85
85
|
${props => props.focused && focus}
|
|
@@ -89,7 +89,7 @@ export const Button = styled(React.forwardRef(({
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
${props => props.hasErrors && css`
|
|
92
|
-
|
|
92
|
+
&:after {
|
|
93
93
|
content: '';
|
|
94
94
|
pointer-events: none;
|
|
95
95
|
position: absolute;
|
|
@@ -127,7 +127,7 @@ export const Button = styled(React.forwardRef(({
|
|
|
127
127
|
min-width: 2rem;
|
|
128
128
|
min-height: 2rem;
|
|
129
129
|
font-weight: 550;
|
|
130
|
-
${props.icon && css`
|
|
130
|
+
${props => props.icon && css`
|
|
131
131
|
${Icon} {
|
|
132
132
|
font-size: 18px;
|
|
133
133
|
margin-left: -5px;
|
|
@@ -135,7 +135,7 @@ export const Button = styled(React.forwardRef(({
|
|
|
135
135
|
line-height: 0.9;
|
|
136
136
|
}
|
|
137
137
|
`}
|
|
138
|
-
${props.onlyIcon && css`
|
|
138
|
+
${props => props.onlyIcon && css`
|
|
139
139
|
padding: 0;
|
|
140
140
|
${Icon} {
|
|
141
141
|
margin: 0;
|
|
@@ -160,82 +160,88 @@ export const Button = styled(React.forwardRef(({
|
|
|
160
160
|
${props => props.light && css`
|
|
161
161
|
background: ${getColor('bluishGray')};
|
|
162
162
|
color: ${getColor('gray90')};
|
|
163
|
-
|
|
163
|
+
&:hover {
|
|
164
164
|
background: ${props => darken(0.05, getColor('bluishGray')(props))};
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
&:active {
|
|
167
167
|
background: ${props => darken(0.08, getColor('bluishGray')(props))};
|
|
168
168
|
}
|
|
169
169
|
`}
|
|
170
170
|
${props => props.lightAlert && css`
|
|
171
171
|
background: ${props => transparentize(0.86, getColor("alert")(props))};
|
|
172
172
|
color: ${getColor('alert')};
|
|
173
|
-
|
|
173
|
+
&:hover {
|
|
174
174
|
background: ${props => transparentize(0.83, getColor("alert")(props))};
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
&:active {
|
|
177
177
|
background: ${props => transparentize(0.80, getColor("alert")(props))};
|
|
178
178
|
}
|
|
179
179
|
`}
|
|
180
180
|
${props => props.lightWarning && css`
|
|
181
181
|
background: ${props => transparentize(0.84, darken(0.05, getColor('warning')(props)))};
|
|
182
182
|
color: ${props => darken(0.05, getColor('warning')(props))};
|
|
183
|
-
|
|
183
|
+
&:hover {
|
|
184
184
|
background: ${props => transparentize(0.78, darken(0.05, getColor('warning')(props)))};
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
&:active {
|
|
187
187
|
background: ${props => transparentize(0.76, darken(0.05, getColor('warning')(props)))};
|
|
188
188
|
}
|
|
189
189
|
`}
|
|
190
190
|
${props => (props.outline || props.dashed || props.textOnly) && css`
|
|
191
|
-
color: ${props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.6)'};
|
|
191
|
+
color: ${props => props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.6)'};
|
|
192
192
|
background: none;
|
|
193
193
|
${Icon}, ${DropdownIcon} {
|
|
194
|
-
color: ${props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.5)'};
|
|
194
|
+
color: ${props => props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.5)'};
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
&:before {
|
|
197
197
|
content: '';
|
|
198
|
-
|
|
198
|
+
/* 'none' explícito (não ''); yak representa cada interpolação como uma CSS custom property
|
|
199
|
+
(var()) — um var() que resolve pra string vazia dentro do shorthand "border" invalida a
|
|
200
|
+
declaração inteira pro navegador (diferente de uma string já resolvida como "1px cor",
|
|
201
|
+
que o parser aceita, tratando o espaço duplo como o token de estilo ausente). Com 'none'
|
|
202
|
+
(mesmo efeito visual de estilo ausente: computed border-width vira 0 de qualquer jeito),
|
|
203
|
+
o var() nunca fica vazio e o shorthand permanece válido nos dois modos. */
|
|
204
|
+
border: 1px ${props => props.outline ? 'solid' : props.dashed ? 'dashed' : 'none'} ${props => props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.35)'};
|
|
199
205
|
position: absolute;
|
|
200
206
|
top: 0;
|
|
201
207
|
right: 0;
|
|
202
208
|
bottom: 0;
|
|
203
209
|
left: 0;
|
|
204
|
-
border-radius: ${props.rounded ? '100px' : '8px'};
|
|
210
|
+
border-radius: ${props => props.rounded ? '100px' : '8px'};
|
|
205
211
|
pointer-events: none;
|
|
206
212
|
}
|
|
207
|
-
|
|
213
|
+
&:hover {
|
|
208
214
|
background-color: rgba(0,0,0,0.05);
|
|
209
215
|
}
|
|
210
|
-
|
|
216
|
+
&:active {
|
|
211
217
|
background-color: rgba(0,0,0,0.08);
|
|
212
218
|
}
|
|
213
|
-
|
|
214
|
-
|
|
219
|
+
&:focus {
|
|
220
|
+
&:before {
|
|
215
221
|
box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
|
|
216
|
-
${props.textOnly && 'content: none;'}
|
|
222
|
+
${props => props.textOnly && 'content: none;'}
|
|
217
223
|
}
|
|
218
|
-
|
|
224
|
+
&:after {
|
|
219
225
|
content: none;
|
|
220
226
|
}
|
|
221
227
|
}
|
|
222
228
|
`}
|
|
223
229
|
${props => props.alpha && css`
|
|
224
230
|
background: rgba(0,0,0,0.45);
|
|
225
|
-
|
|
231
|
+
&:hover {
|
|
226
232
|
background: rgba(0,0,0,0.50);
|
|
227
233
|
}
|
|
228
|
-
|
|
234
|
+
&:active {
|
|
229
235
|
background: rgba(0,0,0,0.55);
|
|
230
236
|
}
|
|
231
237
|
`}
|
|
232
238
|
${props => props.white && !props.outline && !props.dashed && css`
|
|
233
239
|
color: ${getColor('main')};
|
|
234
240
|
background: #FFFFFF;
|
|
235
|
-
|
|
241
|
+
&:hover {
|
|
236
242
|
background: ${darken(0.05, '#FFFFFF')};
|
|
237
243
|
}
|
|
238
|
-
|
|
244
|
+
&:active {
|
|
239
245
|
background: ${darken(0.08, '#FFFFFF')};
|
|
240
246
|
}
|
|
241
247
|
`}
|
package/src/ContextMenu.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {useState, useMemo, useEffect, useRef, forwardRef} from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom'
|
|
3
|
-
import styled, {css
|
|
3
|
+
import styled, {css} from 'styled-components'
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
Fill,
|
|
@@ -44,7 +44,12 @@ const popupAnimation = animationTiming('0.2s ease-out')
|
|
|
44
44
|
|
|
45
45
|
const areComponentsEqual = (a,b) => a === b
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
// Variantes como classe: no yak, o override de theme.startlibs.ListItem não lê props.
|
|
48
|
+
// Sem variante, sem a chave className: o yak sobrescreveria a do app com undefined.
|
|
49
|
+
export const ListItem = styled.li.attrs((props) => {
|
|
50
|
+
const variants = [props.hover && 'styled-list-item-hover', props.highlight && 'styled-list-item-highlight'].filter(Boolean)
|
|
51
|
+
return variants.length ? {className: variants.join(' ')} : {}
|
|
52
|
+
})`
|
|
48
53
|
position: relative;
|
|
49
54
|
font-size: 13px;
|
|
50
55
|
& > * {
|
|
@@ -207,7 +212,7 @@ export const ListHeading = styled.li`
|
|
|
207
212
|
color: rgba(0,0,0,0.4);
|
|
208
213
|
font-size: 12px;
|
|
209
214
|
text-transform: uppercase;
|
|
210
|
-
|
|
215
|
+
&:after {
|
|
211
216
|
content: '';
|
|
212
217
|
flex-grow: 1;
|
|
213
218
|
margin-left: 0.75rem;
|
|
@@ -216,13 +221,22 @@ export const ListHeading = styled.li`
|
|
|
216
221
|
}
|
|
217
222
|
`
|
|
218
223
|
|
|
224
|
+
/* No sc, styledExtend(Icon) cria uma identidade própria: o seletor ${Icon} do ListItem
|
|
225
|
+
acima não bate aqui. No yak, styledExtend vira styled(Icon) (plugin, R10) e essa seta
|
|
226
|
+
herda a classe do Icon, então aquele ${Icon} (2 classes, mais específico) passa a
|
|
227
|
+
também valer pra ela, incluindo um "left: 0" que nunca existiu aqui. Com left, right
|
|
228
|
+
e width todos setados o box fica sobreconstrangido e o browser ignora o "right"
|
|
229
|
+
(ganha left+width): a seta migra pra esquerda. !important nas propriedades em comum,
|
|
230
|
+
e left:auto explícito, devolvem o tamanho e a posição próprios nos dois modos. */
|
|
219
231
|
const SubmenuArrowIcon = styledExtend(Icon)`
|
|
220
|
-
font-size: 13px;
|
|
232
|
+
font-size: 13px !important;
|
|
221
233
|
position: absolute;
|
|
234
|
+
left: auto !important;
|
|
222
235
|
right: 0;
|
|
223
236
|
top: 50%;
|
|
224
237
|
transform: translateY(-50%);
|
|
225
|
-
width: 3rem;
|
|
238
|
+
width: 3rem !important;
|
|
239
|
+
padding-left: 0 !important;
|
|
226
240
|
text-align: center;
|
|
227
241
|
`
|
|
228
242
|
|
|
@@ -523,7 +537,7 @@ export const ContextMenuComponent = forwardRef((
|
|
|
523
537
|
let sum = 0
|
|
524
538
|
React.Children.forEach(children, child => {
|
|
525
539
|
if (child && !child.props.disabled && !child.props.readOnly) {
|
|
526
|
-
if (
|
|
540
|
+
if (child.type === Li || child.type.isKeyboardNavigable) {
|
|
527
541
|
sum += 1
|
|
528
542
|
}
|
|
529
543
|
if (areComponentsEqual(child.type, StickyContainer) || child.props.nested) {
|
|
@@ -548,7 +562,7 @@ export const ContextMenuComponent = forwardRef((
|
|
|
548
562
|
? (
|
|
549
563
|
child.props.nested
|
|
550
564
|
? React.cloneElement(child, child.props, formatChildren(child.props.children, indexRef))
|
|
551
|
-
: ((!
|
|
565
|
+
: ((!isMemo(child.type) && areComponentsEqual(child.type, Li)) || child.type.isKeyboardNavigable)
|
|
552
566
|
? React.cloneElement(child, {
|
|
553
567
|
fixedPosition:props.fixed,
|
|
554
568
|
hover: hoverCursor === indexRef.current && layerIndex === layerCursor,
|
package/src/Dialog.jsx
CHANGED
|
@@ -81,7 +81,10 @@ const DialogContent = styled((props) =>
|
|
|
81
81
|
}
|
|
82
82
|
`
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
// Host tag (styled.h2) com prop lida só no template: o styled-components filtra sozinho antes do
|
|
85
|
+
// DOM, mas o yak não filtra atributo inválido em host tag puro — tira-se fixTitleMargin à mão.
|
|
86
|
+
const TitleBase = React.forwardRef(({fixTitleMargin, ...props}, ref) => <h2 ref={ref} {...props}/>)
|
|
87
|
+
const DialogTitle = styled(TitleBase)`
|
|
85
88
|
margin-bottom: 1rem;
|
|
86
89
|
padding-bottom: 1rem;
|
|
87
90
|
${props => props.fixTitleMargin && `
|
|
@@ -92,7 +95,9 @@ const DialogTitle = styled.h2`
|
|
|
92
95
|
`}
|
|
93
96
|
`
|
|
94
97
|
|
|
95
|
-
|
|
98
|
+
// Mesma razão do TitleBase acima: sticky/isSticky só existem pro template, tiram-se antes do DOM.
|
|
99
|
+
const FooterBase = React.forwardRef(({sticky, isSticky, ...props}, ref) => <div ref={ref} {...props}/>)
|
|
100
|
+
const DialogFooter = styled(FooterBase)`
|
|
96
101
|
display: block;
|
|
97
102
|
padding-top: 1rem;
|
|
98
103
|
margin-top: 1rem;
|
|
@@ -103,6 +108,15 @@ const DialogFooter = styled.div`
|
|
|
103
108
|
background: white;
|
|
104
109
|
width: inherit;
|
|
105
110
|
z-index: 50;
|
|
111
|
+
/* isSticky ANTES dos blocos media.* de propósito: stylis (sc) hoisteia @media pro fim do
|
|
112
|
+
CSS gerado, então mesmo escrito aqui em cima, o border-radius do media.desktop sempre
|
|
113
|
+
ganhava do border-radius:0 daqui em produção — o box-shadow/border-radius:0 nunca eram
|
|
114
|
+
vistos no desktop. O yak mantém a ordem literal do fonte; colocando isSticky antes, as
|
|
115
|
+
duas saem iguais (idem Task 12, ToastBox). */
|
|
116
|
+
${props => props.isSticky && `
|
|
117
|
+
box-shadow: 0 0px 2px 0 rgba(0,0,0,0.1), 0 0px 5px 1px rgba(0,0,0,0.15);
|
|
118
|
+
border-radius: 0;
|
|
119
|
+
`}
|
|
106
120
|
${media.desktop`
|
|
107
121
|
bottom: -3rem;
|
|
108
122
|
margin-left: -2rem;
|
|
@@ -119,10 +133,6 @@ const DialogFooter = styled.div`
|
|
|
119
133
|
margin-left: -1.75rem;
|
|
120
134
|
margin-right: -1.75rem;
|
|
121
135
|
`}
|
|
122
|
-
${props => props.isSticky && `
|
|
123
|
-
box-shadow: 0 0px 2px 0 rgba(0,0,0,0.1), 0 0px 5px 1px rgba(0,0,0,0.15);
|
|
124
|
-
border-radius: 0;
|
|
125
|
-
`}
|
|
126
136
|
`}
|
|
127
137
|
${media.max(370)`
|
|
128
138
|
${Button} {
|
|
@@ -131,8 +141,8 @@ const DialogFooter = styled.div`
|
|
|
131
141
|
padding-right: 1.25rem;
|
|
132
142
|
}
|
|
133
143
|
`}
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
/* Footer's plain (non-colored) buttons use the "light" look; colored variants keep their color. */
|
|
145
|
+
/* ponytail: for a plain footer button that shows a loading spinner, pass \`light\` explicitly so the spinner renders dark instead of white-on-light. */
|
|
136
146
|
${Button}:not(.styled-button-colored) {
|
|
137
147
|
background: ${props => darken(0.03, getColor('bluishGray')(props))};
|
|
138
148
|
color: ${getColor('gray90')};
|
|
@@ -173,7 +183,7 @@ const DialogAlwaysVisibleDiv = styled.div`
|
|
|
173
183
|
`
|
|
174
184
|
// END
|
|
175
185
|
|
|
176
|
-
const
|
|
186
|
+
const DialogInner = React.forwardRef(({className, style, skipWrap, wrapChildren, stickyFooter, fixTitleMargin, skipCloseIcon, isLoading, footer, Content, children, title, illustration, icon, auxiliarActions, container = true, onClose, ...props}, outerRef) => {
|
|
177
187
|
const ref = useEnsureRef(outerRef)
|
|
178
188
|
const [WithIsSticky] = willUseIsSticky()
|
|
179
189
|
|
|
@@ -220,6 +230,7 @@ const Dialog = styled(React.forwardRef(({className, skipWrap, wrapChildren, stic
|
|
|
220
230
|
|
|
221
231
|
const dialog = (confirmCloseDialog) => <div
|
|
222
232
|
className={className + " JS-has-wc JS-dialog"}
|
|
233
|
+
style={style}
|
|
223
234
|
ref={ref}
|
|
224
235
|
>
|
|
225
236
|
{skipWrap
|
|
@@ -245,7 +256,14 @@ const Dialog = styled(React.forwardRef(({className, skipWrap, wrapChildren, stic
|
|
|
245
256
|
closeDialog={handleClose}
|
|
246
257
|
>{({confirmCloseDialog}) => dialog(confirmCloseDialog)}</DialogContainer>
|
|
247
258
|
: dialog(handleClose)
|
|
248
|
-
})
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
// R6: "as" não existe no yak. tagAs troca o componente/tag renderizado (ex.: DialogErrorContent
|
|
262
|
+
// usa tagAs="div" pra reaproveitar o CSS do Dialog sem a lógica interna; DialogWithSidebar usa
|
|
263
|
+
// tagAs={DialogWithSidebarPresentation}); sem tagAs, renderiza o Dialog de verdade (DialogInner).
|
|
264
|
+
const DialogTagAs = React.forwardRef(({tagAs: Tag = DialogInner, ...props}, ref) => <Tag ref={ref} {...props}/>)
|
|
265
|
+
|
|
266
|
+
const Dialog = styled(DialogTagAs)`
|
|
249
267
|
@supports (position:sticky) {
|
|
250
268
|
will-change: transform, opacity;
|
|
251
269
|
&.JS-wc-off {
|
|
@@ -261,7 +279,7 @@ const Dialog = styled(React.forwardRef(({className, skipWrap, wrapChildren, stic
|
|
|
261
279
|
/* Override opcional via prop. Fica ANTES do media.mobile de propósito: no mobile
|
|
262
280
|
o max-width:100% de lá continua ganhando. Inerte sem a prop → zero efeito em
|
|
263
281
|
quem já ajusta a largura por css="max-width:...". */
|
|
264
|
-
${props => props.$maxWidth && css`max-width: ${props.$maxWidth};`}
|
|
282
|
+
${props => props.$maxWidth && css`max-width: ${props => props.$maxWidth};`}
|
|
265
283
|
margin: auto;
|
|
266
284
|
position: relative;
|
|
267
285
|
align-self: baseline;
|
|
@@ -379,7 +397,7 @@ export const DialogErrorContent = ({ closeDialog, onClose, title }) => {
|
|
|
379
397
|
return (
|
|
380
398
|
<StartlibsConsumer>
|
|
381
399
|
{({ ErrorDialog: { title, content, close } }) => (
|
|
382
|
-
<Dialog
|
|
400
|
+
<Dialog tagAs="div" $maxWidth="30rem">
|
|
383
401
|
{closeDialog && <CloseIcon onClick={handleClose} />}
|
|
384
402
|
<DialogErrorLayout>
|
|
385
403
|
<DialogErrorBadge><Icon icon="warning"/></DialogErrorBadge>
|
package/src/Icon.jsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import styled from 'styled-components'
|
|
3
|
-
import { withTheme } from 'styled-components'
|
|
2
|
+
import styled, {useTheme} from 'styled-components'
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
class IconComponent extends React.Component {
|
|
@@ -27,8 +26,10 @@ class IconComponent extends React.Component {
|
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const ThemedIconComponent = React.forwardRef((props, ref) => <IconComponent ref={ref} {...props} theme={useTheme()}/>)
|
|
30
|
+
|
|
31
|
+
export const Icon = styled(ThemedIconComponent)`
|
|
32
|
+
font-family: ${props => `'${props.theme?.iconFont}'`} !important;
|
|
32
33
|
speak: none;
|
|
33
34
|
font-style: normal;
|
|
34
35
|
font-weight: normal;
|
package/src/Loading.jsx
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
import React from 'react'
|
|
1
2
|
import styled from 'styled-components'
|
|
2
|
-
import {getColor} from '@startlibs/utils'
|
|
3
|
+
import {getColor, insertKeyframes} from '@startlibs/utils'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
// Nome fixo do @keyframes preservado: um `keyframes` do styled-components geraria um nome
|
|
6
|
+
// com hash, diferente do atual "loading-spin" (quebraria quem lê animationName). Por isso
|
|
7
|
+
// o bloco fica fora de um template styled/css/keyframes, registrado pelo CSSOM (sem nonce)
|
|
8
|
+
// no primeiro render do Loading (não no import: o pacote declara "sideEffects": false e
|
|
9
|
+
// código de topo de módulo pode ser descartado por um bundler mais agressivo se achar as
|
|
10
|
+
// exportações não usadas).
|
|
11
|
+
const injectSpinKeyframes = () => insertKeyframes('loading-spin', '100% { transform: rotate(1turn) }')
|
|
12
|
+
|
|
13
|
+
// styled(LoadingBase) mira num componente, não numa tag: ao contrário do antigo styled.div,
|
|
14
|
+
// o styled-components não filtra prop inválida pra <div> nesse caso. Por isso tira aqui,
|
|
15
|
+
// à mão, cada prop que o template do Loading lê, antes de espalhar o resto no elemento real.
|
|
16
|
+
const LoadingBase = React.forwardRef(({color, white, size, borderWidth, absolute, ...props}, ref) => {
|
|
17
|
+
injectSpinKeyframes()
|
|
18
|
+
return <div ref={ref} {...props}/>
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export const Loading = styled(LoadingBase)`
|
|
5
22
|
z-index:1;
|
|
6
23
|
--loading-color: ${props => props.color || (props.white ? 'rgba(255,255,255,0.9)' : getColor("main")(props))};
|
|
7
24
|
--loading-bw: ${props => props.borderWidth || 4}px;
|
|
@@ -23,7 +40,4 @@ export const Loading = styled.div`
|
|
|
23
40
|
left: 0;
|
|
24
41
|
margin: auto;
|
|
25
42
|
`}
|
|
26
|
-
@keyframes loading-spin {
|
|
27
|
-
100% {transform: rotate(1turn)}
|
|
28
|
-
}
|
|
29
43
|
`
|
package/src/PageLoader.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {useEffect} from 'react'
|
|
2
|
-
import styled
|
|
2
|
+
import styled from 'styled-components'
|
|
3
3
|
import {oneWayAnimation, getColor} from '@startlibs/utils'
|
|
4
4
|
import {useToggle} from '@startlibs/core'
|
|
5
5
|
import {useFlipLeave} from './Flip'
|
|
@@ -10,12 +10,12 @@ export const LoadingBar = styled.div`
|
|
|
10
10
|
border-radius: 0 1px 1px 0;
|
|
11
11
|
height: 4px;
|
|
12
12
|
position: fixed;
|
|
13
|
-
background: ${props => props.bottom ?
|
|
13
|
+
background: ${props => props.bottom ? getColor('main') : `#84D359`};
|
|
14
14
|
transform: translateX(-100%);
|
|
15
15
|
${props => props.bottom ? "bottom:69px;" : "top: 0;"}
|
|
16
16
|
left: 0;
|
|
17
17
|
z-index: 99999;
|
|
18
|
-
box-shadow: ${props => props.bottom ? `0 0 1px 1px rgba(0,132,214,0.2)
|
|
18
|
+
box-shadow: ${props => props.bottom ? `0 0 1px 1px rgba(0,132,214,0.2)` : `0 0 2px 0 rgba(0,0,0,0.5)`};
|
|
19
19
|
${props => props.loading && `
|
|
20
20
|
transform: translateX(-30%);
|
|
21
21
|
transition: transform 1.5s ease;
|
|
@@ -74,10 +74,10 @@ export const PersistentNotificationCloseIcon = styled(Icon).attrs({icon: 'x'})`
|
|
|
74
74
|
right: 0.5rem;
|
|
75
75
|
color: ${props => props.type && props.type!== 'main' ? getColor(props.type)(props) : darken(0.1, getColor("main")(props))};
|
|
76
76
|
background: ${props => transparentize(0.90, getColor(props.type || "main")(props))};
|
|
77
|
-
|
|
77
|
+
&:hover {
|
|
78
78
|
background: ${props => transparentize(0.85, getColor(props.type || "main")(props))};
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
&:active {
|
|
81
81
|
background: ${props => transparentize(0.82, getColor(props.type || "main")(props))};
|
|
82
82
|
}
|
|
83
83
|
`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
|
-
import {getMargin,
|
|
4
|
-
import styled, {
|
|
3
|
+
import {callIfFunction, getMargin, scrollWidth} from '@startlibs/utils'
|
|
4
|
+
import styled, {useTheme} from 'styled-components'
|
|
5
5
|
|
|
6
6
|
const getMarginFromFieldChild = (props) => {
|
|
7
7
|
if (!props.last) return 0;
|
|
@@ -14,35 +14,94 @@ const getMarginFromFieldChild = (props) => {
|
|
|
14
14
|
|
|
15
15
|
const splitColumnMargins = {small:0.5,'default':1, big:2}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
// viewportMinWidth/twoColumnsBelowVW vêm de props: não tem CSS estático possível pra eles (yak
|
|
18
|
+
// extrai @media em tempo de build, não a partir de uma prop em tempo de render). Troca o
|
|
19
|
+
// `media.min`/`media.max` (que embutiam um `@media` dinâmico) por um hook que ouve
|
|
20
|
+
// `matchMedia` e liga/desliga classe — as duas regras de CSS ficam estáticas, e a mesma soma de
|
|
21
|
+
// `scrollWidth` que `media()` já fazia entra aqui, pro breakpoint bater igual em px (inclusive
|
|
22
|
+
// a 610px, entre 600 e 600 + barra de rolagem).
|
|
23
|
+
const useMatchMedia = (query) => {
|
|
24
|
+
const getMatch = () => (typeof window !== 'undefined' && window.matchMedia) ? window.matchMedia(query).matches : false
|
|
25
|
+
const [matches, setMatches] = React.useState(getMatch)
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
if (typeof window === 'undefined' || !window.matchMedia) return
|
|
28
|
+
const mql = window.matchMedia(query)
|
|
29
|
+
const onChange = () => setMatches(mql.matches)
|
|
30
|
+
onChange()
|
|
31
|
+
const addListener = mql.addEventListener ? (cb) => mql.addEventListener('change', cb) : (cb) => mql.addListener(cb)
|
|
32
|
+
const removeListener = mql.removeEventListener ? (cb) => mql.removeEventListener('change', cb) : (cb) => mql.removeListener(cb)
|
|
33
|
+
addListener(onChange)
|
|
34
|
+
return () => removeListener(onChange)
|
|
35
|
+
}, [query])
|
|
36
|
+
return matches
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Mesma comparação que checkCustomScreenWidth (utils/src/styled.js) fazia pro theme.overrideMediaWidth:
|
|
40
|
+
// ignora o browser de verdade e compara direto contra o breakpoint (sem somar scrollWidth — o
|
|
41
|
+
// override já é uma largura "combinada", não a viewport física). Usado em testes/impressão.
|
|
42
|
+
const matchesOverrideWidth = (overrideWidth, breakpoint, type) => {
|
|
43
|
+
const currentWidth = callIfFunction(overrideWidth)
|
|
44
|
+
return type === 'min-width' ? currentWidth >= breakpoint : currentWidth <= breakpoint
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// `breakpoint` null/undefined == bloco original não tinha condição nenhuma pra testar (o `&&`
|
|
48
|
+
// de `props.twoColumnsBelowVW &&`): nem entra no matchMedia, nem no overrideMediaWidth.
|
|
49
|
+
const useBreakpointMatch = (breakpoint, type, overrideWidth) => {
|
|
50
|
+
const hasBreakpoint = breakpoint !== undefined && breakpoint !== null
|
|
51
|
+
const useOverride = hasBreakpoint && overrideWidth !== undefined
|
|
52
|
+
const query = (hasBreakpoint && !useOverride)
|
|
53
|
+
? `(${type}: ${breakpoint + scrollWidth}px)`
|
|
54
|
+
: 'not all'
|
|
55
|
+
const mediaMatch = useMatchMedia(query)
|
|
56
|
+
if (!hasBreakpoint) return false
|
|
57
|
+
return useOverride ? matchesOverrideWidth(overrideWidth, breakpoint, type) : mediaMatch
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// styled(Base) mira num componente, não numa tag: ao contrário do antigo styled.div, o
|
|
61
|
+
// styled-components não filtra prop inválida pra <div> nesse caso. Por isso tira aqui, à mão,
|
|
62
|
+
// toda prop que ou é lida só pelo template (margin, last) ou só existe pra decidir a classe
|
|
63
|
+
// aqui dentro (viewportMinWidth, twoColumnsBelowVW), antes de espalhar o resto no elemento real.
|
|
64
|
+
const SplitColumnsContainerBase = React.forwardRef(({viewportMinWidth = 0, twoColumnsBelowVW, margin, last, className, ...rest}, ref) => {
|
|
65
|
+
const overrideWidth = useTheme()?.overrideMediaWidth
|
|
66
|
+
const isFlex = useBreakpointMatch(viewportMinWidth, 'min-width', overrideWidth)
|
|
67
|
+
const isTwoColumns = useBreakpointMatch(twoColumnsBelowVW, 'max-width', overrideWidth)
|
|
68
|
+
const classes = [className, isFlex && 'JS-flex-columns', isTwoColumns && 'JS-two-columns'].filter(Boolean).join(' ')
|
|
69
|
+
return <div ref={ref} className={classes || undefined} {...rest}/>
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
export const SplitColumnsContainer = styled(SplitColumnsContainerBase)`
|
|
73
|
+
margin-bottom: ${props => getMarginFromFieldChild(props)}rem;
|
|
74
|
+
|
|
75
|
+
&.JS-flex-columns {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-wrap: nowrap;
|
|
78
|
+
/* O yak extrai essas interpolações pra var(--...): um sinal de menos solto no texto estático,
|
|
79
|
+
logo antes da interpolação, vira "-var(--x)" na folha final — sintaxe de CSS inválida
|
|
80
|
+
(margin cai pro valor inicial, 0px). O sinal de menos tem que estar DENTRO do valor
|
|
81
|
+
calculado, não no texto ao redor. */
|
|
82
|
+
margin-left: ${props=> -getMargin(splitColumnMargins)(props)/2}rem;
|
|
83
|
+
margin-right: ${props=> -getMargin(splitColumnMargins)(props)/2}rem;
|
|
84
|
+
margin-top: ${props=> -getMargin(splitColumnMargins)(props)}rem;
|
|
85
|
+
> * {
|
|
86
|
+
flex-basis: 0;
|
|
87
|
+
flex-grow: 1;
|
|
88
|
+
margin-left: ${props=>getMargin(splitColumnMargins)(props)/2}rem;
|
|
89
|
+
margin-right: ${props=>getMargin(splitColumnMargins)(props)/2}rem;
|
|
90
|
+
margin-top: ${props=>getMargin(splitColumnMargins)(props)}rem;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
&.JS-two-columns {
|
|
94
|
+
flex-wrap: wrap;
|
|
95
|
+
> * {
|
|
96
|
+
flex-basis: 47%;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
45
99
|
`
|
|
100
|
+
// O plugin/babel-plugin-styled-components infere o displayName do nome da variável — mas só
|
|
101
|
+
// quando o import `styled` vem de 'styled-components' (modo sc). No lib-yak o arquivo passa a
|
|
102
|
+
// importar `styled` de '@yak/react' e isso não acontece mais, então fica explícito aqui, nos dois
|
|
103
|
+
// modos: fixDoubledLastMarginBottom precisa do mesmo valor em "SplitColumnsContainer.displayName".
|
|
104
|
+
SplitColumnsContainer.displayName = 'SplitColumnsContainer'
|
|
46
105
|
|
|
47
106
|
export const fixDoubledLastMarginBottom = (children) => {
|
|
48
107
|
let last = React.Children.count(children)-1
|