@startlibs/components 1.1.5 → 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.
Files changed (123) hide show
  1. package/lib/BasicBulletList.mjs +1 -1
  2. package/lib/BasicBulletList.mjs.map +1 -1
  3. package/lib/Button.mjs +3 -3
  4. package/lib/Button.mjs.map +1 -1
  5. package/lib/ContextMenu.mjs +22 -6
  6. package/lib/ContextMenu.mjs.map +1 -1
  7. package/lib/Dialog.mjs +60 -24
  8. package/lib/Dialog.mjs.map +1 -1
  9. package/lib/Icon.mjs +10 -4
  10. package/lib/Icon.mjs.map +1 -1
  11. package/lib/Loading.mjs +26 -3
  12. package/lib/Loading.mjs.map +1 -1
  13. package/lib/PageLoader.mjs +2 -2
  14. package/lib/PageLoader.mjs.map +1 -1
  15. package/lib/PersistentNotifications.mjs +1 -1
  16. package/lib/PersistentNotifications.mjs.map +1 -1
  17. package/lib/SplitColumnsContainer.mjs +77 -6
  18. package/lib/SplitColumnsContainer.mjs.map +1 -1
  19. package/lib/TextButton.mjs +1 -1
  20. package/lib/TextButton.mjs.map +1 -1
  21. package/lib/ToastNotifications.mjs +16 -14
  22. package/lib/ToastNotifications.mjs.map +1 -1
  23. package/lib/alt/dialogs/DialogWithImageHeader.mjs +1 -1
  24. package/lib/alt/dialogs/DialogWithImageHeader.mjs.map +1 -1
  25. package/lib/alt/dialogs/DialogWithSidebar.mjs +7 -3
  26. package/lib/alt/dialogs/DialogWithSidebar.mjs.map +1 -1
  27. package/lib/alt/dialogs/MobileBubbleDialog.mjs +1 -1
  28. package/lib/alt/dialogs/MobileBubbleDialog.mjs.map +1 -1
  29. package/lib/containers/DialogContainer.mjs +29 -10
  30. package/lib/containers/DialogContainer.mjs.map +1 -1
  31. package/lib/index.cjs +286 -93
  32. package/lib/index.cjs.map +1 -1
  33. package/lib/willUseIsSticky.mjs +23 -2
  34. package/lib/willUseIsSticky.mjs.map +1 -1
  35. package/lib-yak/BasicBulletList.mjs +27 -0
  36. package/lib-yak/BasicBulletList.mjs.map +1 -0
  37. package/lib-yak/Button.mjs +374 -0
  38. package/lib-yak/Button.mjs.map +1 -0
  39. package/lib-yak/ContextMenu.mjs +642 -0
  40. package/lib-yak/ContextMenu.mjs.map +1 -0
  41. package/lib-yak/Dialog.mjs +469 -0
  42. package/lib-yak/Dialog.mjs.map +1 -0
  43. package/lib-yak/Draggable.mjs +892 -0
  44. package/lib-yak/Draggable.mjs.map +1 -0
  45. package/lib-yak/ErrorBoundary.mjs +108 -0
  46. package/lib-yak/ErrorBoundary.mjs.map +1 -0
  47. package/lib-yak/FillLastLineResizer.mjs +238 -0
  48. package/lib-yak/FillLastLineResizer.mjs.map +1 -0
  49. package/lib-yak/Flip.mjs +644 -0
  50. package/lib-yak/Flip.mjs.map +1 -0
  51. package/lib-yak/FlipList.mjs +186 -0
  52. package/lib-yak/FlipList.mjs.map +1 -0
  53. package/lib-yak/FormatDate.mjs +25 -0
  54. package/lib-yak/FormatDate.mjs.map +1 -0
  55. package/lib-yak/Icon.mjs +74 -0
  56. package/lib-yak/Icon.mjs.map +1 -0
  57. package/lib-yak/Image.mjs +41 -0
  58. package/lib-yak/Image.mjs.map +1 -0
  59. package/lib-yak/Link.mjs +116 -0
  60. package/lib-yak/Link.mjs.map +1 -0
  61. package/lib-yak/Loading.mjs +54 -0
  62. package/lib-yak/Loading.mjs.map +1 -0
  63. package/lib-yak/LoadingDiv.mjs +82 -0
  64. package/lib-yak/LoadingDiv.mjs.map +1 -0
  65. package/lib-yak/Notifications.mjs +99 -0
  66. package/lib-yak/Notifications.mjs.map +1 -0
  67. package/lib-yak/PageLoader.mjs +61 -0
  68. package/lib-yak/PageLoader.mjs.map +1 -0
  69. package/lib-yak/PersistentNotifications.mjs +209 -0
  70. package/lib-yak/PersistentNotifications.mjs.map +1 -0
  71. package/lib-yak/Popup.mjs +66 -0
  72. package/lib-yak/Popup.mjs.map +1 -0
  73. package/lib-yak/SplitColumnsContainer.mjs +140 -0
  74. package/lib-yak/SplitColumnsContainer.mjs.map +1 -0
  75. package/lib-yak/SwitchDiv.mjs +60 -0
  76. package/lib-yak/SwitchDiv.mjs.map +1 -0
  77. package/lib-yak/TextButton.mjs +61 -0
  78. package/lib-yak/TextButton.mjs.map +1 -0
  79. package/lib-yak/ToastNotifications.mjs +316 -0
  80. package/lib-yak/ToastNotifications.mjs.map +1 -0
  81. package/lib-yak/Tooltip.mjs +176 -0
  82. package/lib-yak/Tooltip.mjs.map +1 -0
  83. package/lib-yak/TransitionDiv.mjs +59 -0
  84. package/lib-yak/TransitionDiv.mjs.map +1 -0
  85. package/lib-yak/WarningDialog.mjs +107 -0
  86. package/lib-yak/WarningDialog.mjs.map +1 -0
  87. package/lib-yak/alt/buttons/OnClickLoadingButton.mjs +36 -0
  88. package/lib-yak/alt/buttons/OnClickLoadingButton.mjs.map +1 -0
  89. package/lib-yak/alt/dialogs/DialogWithImageHeader.mjs +50 -0
  90. package/lib-yak/alt/dialogs/DialogWithImageHeader.mjs.map +1 -0
  91. package/lib-yak/alt/dialogs/DialogWithSidebar.mjs +193 -0
  92. package/lib-yak/alt/dialogs/DialogWithSidebar.mjs.map +1 -0
  93. package/lib-yak/alt/dialogs/MobileBubbleDialog.mjs +82 -0
  94. package/lib-yak/alt/dialogs/MobileBubbleDialog.mjs.map +1 -0
  95. package/lib-yak/containers/DialogContainer.mjs +482 -0
  96. package/lib-yak/containers/DialogContainer.mjs.map +1 -0
  97. package/lib-yak/containers/Reposition.mjs +35 -0
  98. package/lib-yak/containers/Reposition.mjs.map +1 -0
  99. package/lib-yak/containers/usePositioning.mjs +311 -0
  100. package/lib-yak/containers/usePositioning.mjs.map +1 -0
  101. package/lib-yak/index.mjs +37 -0
  102. package/lib-yak/index.mjs.map +1 -0
  103. package/lib-yak/useDialogWithToggle.mjs +18 -0
  104. package/lib-yak/useDialogWithToggle.mjs.map +1 -0
  105. package/lib-yak/willUseIsSticky.mjs +147 -0
  106. package/lib-yak/willUseIsSticky.mjs.map +1 -0
  107. package/package.json +12 -3
  108. package/src/BasicBulletList.jsx +1 -1
  109. package/src/Button.jsx +36 -30
  110. package/src/ContextMenu.jsx +21 -7
  111. package/src/Dialog.jsx +31 -12
  112. package/src/Icon.jsx +5 -4
  113. package/src/Loading.jsx +19 -5
  114. package/src/PageLoader.jsx +3 -3
  115. package/src/PersistentNotifications.jsx +2 -2
  116. package/src/SplitColumnsContainer.jsx +89 -30
  117. package/src/TextButton.jsx +1 -1
  118. package/src/ToastNotifications.jsx +15 -8
  119. package/src/alt/dialogs/DialogWithImageHeader.jsx +2 -2
  120. package/src/alt/dialogs/DialogWithSidebar.jsx +6 -5
  121. package/src/alt/dialogs/MobileBubbleDialog.jsx +1 -1
  122. package/src/containers/DialogContainer.jsx +11 -4
  123. package/src/willUseIsSticky.jsx +22 -2
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "@startlibs/components",
3
- "version": "1.1.5",
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",
@@ -9,7 +9,7 @@ export const BasicBulletList = styled.ul`
9
9
  padding-left: 1rem;
10
10
  position: relative;
11
11
 
12
- :before {
12
+ &:before {
13
13
  content: '•';
14
14
  font-size: 17px;
15
15
  line-height: 0;
package/src/Button.jsx CHANGED
@@ -25,7 +25,7 @@ const LockIcon = styled(Icon)`
25
25
  `
26
26
 
27
27
  const focus = css`
28
- :after{
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
- // line-height: 16px;
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
- :hover {
72
+ &:hover {
73
73
  background: ${props => darken(0.05, getColor(props, true))};
74
74
  }
75
- :active {
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
- :focus {
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
- :after {
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
- :hover {
163
+ &:hover {
164
164
  background: ${props => darken(0.05, getColor('bluishGray')(props))};
165
165
  }
166
- :active {
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
- :hover {
173
+ &:hover {
174
174
  background: ${props => transparentize(0.83, getColor("alert")(props))};
175
175
  }
176
- :active {
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
- :hover {
183
+ &:hover {
184
184
  background: ${props => transparentize(0.78, darken(0.05, getColor('warning')(props)))};
185
185
  }
186
- :active {
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
- :before {
196
+ &:before {
197
197
  content: '';
198
- border: 1px ${props.outline ? 'solid' : props.dashed ? 'dashed' : ''} ${props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.35)'};
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
- :hover {
213
+ &:hover {
208
214
  background-color: rgba(0,0,0,0.05);
209
215
  }
210
- :active {
216
+ &:active {
211
217
  background-color: rgba(0,0,0,0.08);
212
218
  }
213
- :focus {
214
- :before {
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
- :after {
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
- :hover {
231
+ &:hover {
226
232
  background: rgba(0,0,0,0.50);
227
233
  }
228
- :active {
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
- :hover {
241
+ &:hover {
236
242
  background: ${darken(0.05, '#FFFFFF')};
237
243
  }
238
- :active {
244
+ &:active {
239
245
  background: ${darken(0.08, '#FFFFFF')};
240
246
  }
241
247
  `}
@@ -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, isStyledComponent} from 'styled-components'
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
- export const ListItem = styled.li`
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
- :after {
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 ((!isStyledComponent(child.type) && child.type === Li) || child.type.isKeyboardNavigable) {
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
- : ((!isStyledComponent(child.type) && !isMemo(child.type) && areComponentsEqual(child.type, Li)) || child.type.isKeyboardNavigable)
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
- const DialogTitle = styled.h2`
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
- const DialogFooter = styled.div`
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
- // Footer's plain (non-colored) buttons use the "light" look; colored variants keep their color.
135
- // ponytail: for a plain footer button that shows a loading spinner, pass \`light\` explicitly so the spinner renders dark instead of white-on-light.
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 Dialog = styled(React.forwardRef(({className, skipWrap, wrapChildren, stickyFooter, fixTitleMargin, skipCloseIcon, isLoading, footer, Content, children, title, illustration, icon, auxiliarActions, container = true, onClose, ...props}, outerRef) => {
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,11 +279,12 @@ 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;
268
286
  display: block;
287
+ overflow: clip;
269
288
  > h3:first-child {
270
289
  margin-top: 0.5rem;
271
290
  }
@@ -378,7 +397,7 @@ export const DialogErrorContent = ({ closeDialog, onClose, title }) => {
378
397
  return (
379
398
  <StartlibsConsumer>
380
399
  {({ ErrorDialog: { title, content, close } }) => (
381
- <Dialog as="div" $maxWidth="30rem">
400
+ <Dialog tagAs="div" $maxWidth="30rem">
382
401
  {closeDialog && <CloseIcon onClick={handleClose} />}
383
402
  <DialogErrorLayout>
384
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
- export const Icon = styled(withTheme(IconComponent))`
31
- font-family: '${props => props.theme?.iconFont}' !important;
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
- export const Loading = styled.div`
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
  `
@@ -1,5 +1,5 @@
1
1
  import React, {useEffect} from 'react'
2
- import styled, {css} from 'styled-components'
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 ? css`${getColor('main')}`:`#84D359`};
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);`:`0 0 2px 0 rgba(0,0,0,0.5);`};
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
- :hover {
77
+ &:hover {
78
78
  background: ${props => transparentize(0.85, getColor(props.type || "main")(props))};
79
79
  }
80
- :active {
80
+ &:active {
81
81
  background: ${props => transparentize(0.82, getColor(props.type || "main")(props))};
82
82
  }
83
83
  `