pne-ui 5.0.0-rc.40 → 5.0.0-rc.41

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/README.md CHANGED
@@ -229,7 +229,7 @@ import {Button} from '@mui/material'
229
229
  | `activated` | `aria-disabled` и `tabIndex={-1}` на кнопке `text` + `success` |
230
230
  | `data-pne-variant`, `data-pne-size`, `data-pne-loading` | классы MUI: `MuiButton-contained`, `MuiButton-colorError`, `MuiButton-sizeSmall`, `MuiButton-loading` |
231
231
 
232
- ## Подсказка, радиокнопка, чип и группа переключателей: вид рисует тема
232
+ ## Подсказка, радиокнопка, чип, группа переключателей и кнопка-значок: вид рисует тема
233
233
 
234
234
  Своих компонентов подсказки, радиокнопки, чипа и группы переключателей в `pne-ui` нет. Берите `Tooltip`,
235
235
  `Radio`, `Chip` и `ToggleButtonGroup` из `@mui/material`: под темой `createPneTheme` они выглядят по UI Kit, без
@@ -308,9 +308,36 @@ import {ToggleButton, ToggleButtonGroup} from '@mui/material'
308
308
  - `fullWidth` делит ширину между пунктами поровну, `orientation="vertical"` ставит их столбцом;
309
309
  - `ToggleButton` без группы — не вкладка, тема его не рисует.
310
310
 
311
- Так же библиотека рисует выбор вида таблицы и переключатели окна Multiget.
311
+ Выбор вида таблицы и переключатели окна Multiget — та же группа `size="small"` (32 px): в окне она стоит
312
+ в ряд с полем поиска 32 px.
312
313
 
313
- Сторис: `pne-ui/Tooltip`, `pne-ui/Radio`, `pne-ui/Chip` и `pne-ui/ToggleButton`.
314
+ `IconButton` (UI Kit Icon action: действие без подписи):
315
+
316
+ ```tsx
317
+ import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined'
318
+ import {IconButton} from '@mui/material'
319
+
320
+ <IconButton aria-label="Delete" size="small" color="error" onClick={remove}>
321
+ <DeleteOutlinedIcon/>
322
+ </IconButton>
323
+ ```
324
+
325
+ - без фона и без круга под указателем: наведение и нажатие красят только значок; скругление 4 px, кольцо
326
+ фокуса с клавиатуры;
327
+ - размер кнопки не зависит от значка: `size="small"` — 24 px (строки и ячейки таблиц), по умолчанию — 32 px
328
+ (формы, крестик окна), `size="large"` — 40 px (в ряду с полями 40 px);
329
+ - значок Material обычного размера внутри кнопки получает 14 / 16 / 18 px; значок, которому страница сама
330
+ задала размер (`fontSize`, `sx`), и собственный svg приложения остаются как есть;
331
+ - `color`: по умолчанию значок серый и под указателем берёт цвет бренда; `primary` — цвет бренда сразу;
332
+ `error` — серый, под указателем красный; `inherit` — цвет места, где стоит кнопка;
333
+ - `color="pnePrimary"` и `color="pneNeutral"` — закрашенный квадрат: кнопки Primary и Soft из UI Kit в режиме
334
+ «только значок»;
335
+ - размер, который страница задала через `sx` или `styled`, сильнее темы.
336
+
337
+ Действия в строках `PneTable`, крестики окна, тоста и баннера рисуют сами компоненты той же функцией
338
+ (`pneIconActionSx`).
339
+
340
+ Сторис: `pne-ui/Tooltip`, `pne-ui/Radio`, `pne-ui/Chip`, `pne-ui/ToggleButton` и `pne-ui/IconButton`.
314
341
 
315
342
  ## PneField
316
343
 
package/cjs/buttonLook.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPneButtonOverrides = exports.PNE_BUTTON_SIZE = exports.PNE_BUTTON_FONT_FAMILY = exports.resolvePneButtonVariant = void 0;
3
+ exports.createPneButtonOverrides = exports.pneButtonLookStyle = exports.PNE_BUTTON_SIZE = exports.PNE_BUTTON_FONT_FAMILY = exports.resolvePneButtonVariant = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const CircularProgress_1 = tslib_1.__importDefault(require("@mui/material/CircularProgress"));
6
6
  const React = tslib_1.__importStar(require("react"));
@@ -111,7 +111,8 @@ const sizeStyle = (size) => {
111
111
  [`${WAITING_CENTRE} .MuiButton-loadingIndicator`]: { fontSize: config.icon },
112
112
  };
113
113
  };
114
- const lookStyle = (variant, palette, focusRing) => {
114
+ /** The colours of a UI Kit button variant in all its states; the icon-only button of the theme takes them too. */
115
+ const pneButtonLookStyle = (variant, palette, focusRing) => {
115
116
  const colors = palette[variant];
116
117
  // Later states win: default, hover, pressed, focus, waiting, picked, activated, disabled.
117
118
  return {
@@ -148,6 +149,7 @@ const lookStyle = (variant, palette, focusRing) => {
148
149
  } : {}),
149
150
  };
150
151
  };
152
+ exports.pneButtonLookStyle = pneButtonLookStyle;
151
153
  // `color="inherit"`: no fill, the label of the place the button stands in.
152
154
  const inheritStyle = (theme, focusRing) => ({
153
155
  backgroundColor: 'transparent',
@@ -173,7 +175,7 @@ const buttonStyle = (theme, resolvePalette, size, look) => {
173
175
  // The two parts share no selector: the size rules set no colour, the look sets nothing else.
174
176
  style = {
175
177
  ...sizeStyle(size),
176
- ...(look ? lookStyle(look, pne.button, focusRing) : inheritStyle(theme, focusRing)),
178
+ ...(look ? (0, exports.pneButtonLookStyle)(look, pne.button, focusRing) : inheritStyle(theme, focusRing)),
177
179
  };
178
180
  styles.set(key, style);
179
181
  }
@@ -3,43 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.pneIconActionSx = void 0;
4
4
  const buttonLook_1 = require("../buttonLook");
5
5
  const createTheme_1 = require("../createTheme");
6
- const themeColors_1 = require("../themeColors");
6
+ const iconButtonLook_1 = require("../iconButtonLook");
7
7
  /**
8
8
  * UI Kit Icon action on a MUI IconButton: an icon button with no background, where hover and press
9
9
  * colour only the icon. `medium` is a 32px box with a 16px glyph (the close cross of a modal and of
10
10
  * a toast), `small` a 24px box with a 14px glyph. The icon rests in the tertiary text colour, or in
11
- * `restColor` (the tone of a toast), and takes the brand text colour under the pointer. The box and
12
- * the glyph are the height and the icon of a button of that size.
11
+ * `restColor` (the tone of a toast), and takes the brand text colour under the pointer.
12
+ *
13
+ * The theme draws every stock IconButton with the same look functions; the components of the library
14
+ * repeat the look here because they have to look right without the PNE UI theme as well, and they size
15
+ * every glyph, whatever size the icon asked for.
13
16
  */
14
- const pneIconActionSx = (size, restColor) => theme => {
15
- const pne = (0, createTheme_1.resolvePneSemanticPalette)(theme);
16
- const dark = theme.palette.mode === 'dark';
17
- const { height, icon } = buttonLook_1.PNE_BUTTON_SIZE[size];
18
- const box = `${height}px`;
19
- return {
20
- flex: '0 0 auto',
21
- width: box,
22
- height: box,
23
- padding: 0,
24
- borderRadius: '4px',
25
- backgroundColor: 'transparent',
26
- color: restColor ?? (dark ? themeColors_1.PNE_DARK_COLORS.textMuted : themeColors_1.PNE_NEUTRAL_RAMP[600]),
27
- '& .MuiSvgIcon-root': {
28
- fontSize: `${icon}px`,
29
- },
30
- '&:hover': {
31
- backgroundColor: 'transparent',
32
- color: pne.button.text.hover.text,
33
- },
34
- '&:active': {
35
- color: pne.button.text.pressed.text,
36
- },
37
- '&.Mui-focusVisible': {
38
- boxShadow: `0 0 0 2px ${theme.palette.background.paper}, 0 0 0 4px ${pne.focusRing}`,
39
- },
40
- '&.Mui-disabled': {
41
- color: dark ? themeColors_1.PNE_DARK_COLORS.textDisabled : themeColors_1.PNE_NEUTRAL_RAMP[400],
42
- },
43
- };
44
- };
17
+ const pneIconActionSx = (size, restColor) => theme => ({
18
+ flex: '0 0 auto',
19
+ ...(0, iconButtonLook_1.pneIconButtonSizeLook)(size),
20
+ ...(0, iconButtonLook_1.pneIconActionLook)(theme, (0, createTheme_1.resolvePneSemanticPalette)(theme), 'neutral', restColor),
21
+ '& .MuiSvgIcon-root': {
22
+ fontSize: `${buttonLook_1.PNE_BUTTON_SIZE[size].icon}px`,
23
+ },
24
+ });
45
25
  exports.pneIconActionSx = pneIconActionSx;
@@ -198,7 +198,6 @@ const parseInitialSelectedEntities = (multigetCriterion) => {
198
198
  return entities;
199
199
  };
200
200
  const toggleSx = {
201
- textTransform: 'none',
202
201
  flex: 1,
203
202
  };
204
203
  const topRowSx = {
@@ -2,29 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.searchUITabsGroupSx = void 0;
4
4
  const createTheme_1 = require("../../createTheme");
5
- const tableControlButtonStyle_1 = require("../table/tableControlButtonStyle");
5
+ const toggleLook_1 = require("../../toggleLook");
6
6
  /**
7
- * UI Kit Tabs group on a MUI ToggleButtonGroup: one choice out of a few. The grey shell of the table's
8
- * views with 24px buttons in it, the picked one white with the tab shadow; MUI's own borders, joined
9
- * corners and overlapping margins of a group are taken off.
7
+ * UI Kit Tabs group on a MUI ToggleButtonGroup: one choice out of a few. The small group of the theme
8
+ * (32px, 24px buttons): it stands level with the 32px search field and buttons of the Multiget window.
9
+ * The look is repeated here because the window has to look right without the PNE UI theme as well.
10
10
  */
11
- const searchUITabsGroupSx = theme => {
12
- const text = (0, createTheme_1.resolvePneSemanticPalette)(theme).button.text;
13
- return {
14
- ...(0, tableControlButtonStyle_1.createTableControlShellStyle)(theme, 'tabs'),
15
- display: 'inline-flex',
16
- '&& .MuiToggleButtonGroup-grouped': {
17
- ...(0, tableControlButtonStyle_1.createTableControlTextButtonStyle)(theme),
18
- backgroundColor: 'transparent',
19
- border: 0,
20
- borderRadius: '4px',
21
- margin: 0,
22
- '&:hover': {
23
- backgroundColor: 'transparent',
24
- color: text.hover.text,
25
- },
26
- },
27
- '&& .MuiToggleButtonGroup-grouped.Mui-selected': (0, tableControlButtonStyle_1.createTableControlActiveStyle)(theme),
28
- };
29
- };
11
+ const searchUITabsGroupSx = theme => ({
12
+ ...(0, toggleLook_1.pneToggleGroupLook)(theme, (0, createTheme_1.resolvePneSemanticPalette)(theme), 'small'),
13
+ display: 'inline-flex',
14
+ });
30
15
  exports.searchUITabsGroupSx = searchUITabsGroupSx;
@@ -100,6 +100,8 @@ const PneTablePaginationActions = (props) => {
100
100
  ...controlStyle,
101
101
  flexShrink: 0,
102
102
  minWidth: `${tableControlMetrics_1.TABLE_CONTROL_SIZE}px`,
103
+ // A label, not a glyph: the button is as wide as its number, whatever box the theme gives an icon button.
104
+ width: 'auto',
103
105
  '&:hover': hoverStyle,
104
106
  };
105
107
  const selectedButtonStyle = {
@@ -9,6 +9,7 @@ const buttonPalette_1 = require("./buttonPalette");
9
9
  const checkboxPalette_1 = require("./checkboxPalette");
10
10
  const chipLook_1 = require("./chipLook");
11
11
  const radioLook_1 = require("./radioLook");
12
+ const iconButtonLook_1 = require("./iconButtonLook");
12
13
  const toggleLook_1 = require("./toggleLook");
13
14
  const tooltipLook_1 = require("./tooltipLook");
14
15
  const dropdownPalette_1 = require("./dropdownPalette");
@@ -183,7 +184,7 @@ const mergeThemeObjects = (base, override) => {
183
184
  });
184
185
  return result;
185
186
  };
186
- const createPneComponentOverrides = (mode) => ({
187
+ const createPneComponentOverrides = () => ({
187
188
  MuiFormHelperText: {
188
189
  styleOverrides: {
189
190
  root: {
@@ -198,55 +199,8 @@ const createPneComponentOverrides = (mode) => ({
198
199
  },
199
200
  },
200
201
  },
201
- MuiIconButton: {
202
- styleOverrides: {
203
- root: ({ ownerState, theme }) => {
204
- if (ownerState.color === 'pnePrimary') {
205
- if (mode === 'light') {
206
- return {
207
- backgroundColor: theme.palette.primary.main,
208
- color: theme.palette.primary.contrastText,
209
- '&:hover': {
210
- backgroundColor: theme.palette.primary.dark,
211
- color: theme.palette.primary.contrastText,
212
- },
213
- };
214
- }
215
- return {
216
- backgroundColor: theme.palette.pne.brand.fill,
217
- color: theme.palette.pne.brand.onFill,
218
- border: '1px solid',
219
- borderColor: theme.palette.pne.brand.fillBorder,
220
- '&:hover': {
221
- backgroundColor: theme.palette.pne.brand.fillHover,
222
- color: theme.palette.pne.brand.onFill,
223
- },
224
- };
225
- }
226
- if (ownerState.color === 'pneNeutral') {
227
- if (mode === 'light') {
228
- return {
229
- backgroundColor: '#F1F5FA',
230
- stroke: theme.palette.primary.main,
231
- '&:hover': {
232
- backgroundColor: theme.palette.primary.light,
233
- stroke: theme.palette.primary.dark,
234
- },
235
- };
236
- }
237
- return {
238
- backgroundColor: theme.palette.pne.surface.subtle,
239
- stroke: theme.palette.pne.brand.foreground,
240
- '&:hover': {
241
- backgroundColor: theme.palette.pne.brand.softHover,
242
- stroke: theme.palette.pne.brand.foregroundHover,
243
- },
244
- };
245
- }
246
- return {};
247
- },
248
- },
249
- },
202
+ MuiIconButton: (0, iconButtonLook_1.createPneIconButtonOverrides)(exports.resolvePneSemanticPalette),
203
+ MuiSvgIcon: (0, iconButtonLook_1.createPneSvgIconOverrides)(),
250
204
  MuiButton: (0, buttonLook_1.createPneButtonOverrides)(exports.resolvePneSemanticPalette),
251
205
  MuiChip: (0, chipLook_1.createPneChipOverrides)(exports.resolvePneSemanticPalette),
252
206
  MuiRadio: (0, radioLook_1.createPneRadioOverrides)(exports.resolvePneSemanticPalette),
@@ -299,7 +253,7 @@ const createBaseThemeOptions = (skin, mode) => {
299
253
  pneAccentuated: { main: seed },
300
254
  ...darkModePalette,
301
255
  },
302
- components: createPneComponentOverrides(mode),
256
+ components: createPneComponentOverrides(),
303
257
  };
304
258
  };
305
259
  const createPneThemeOptions = (skin, options = {}) => {
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPneSvgIconOverrides = exports.createPneIconButtonOverrides = exports.pneIconActionLook = exports.pneIconButtonSizeLook = exports.PNE_ICON_SIZE_VAR = void 0;
4
+ const buttonLook_1 = require("./buttonLook");
5
+ const themeColors_1 = require("./themeColors");
6
+ /** A MUI icon of the default size takes its size from this property; an icon button sets it. */
7
+ exports.PNE_ICON_SIZE_VAR = '--pne-icon-size';
8
+ const resolveSize = (size) => size === 'small' || size === 'large' ? size : 'medium';
9
+ /** The box and the glyph of a size; no colour here. */
10
+ const pneIconButtonSizeLook = (size) => {
11
+ const { height, icon } = buttonLook_1.PNE_BUTTON_SIZE[size];
12
+ return {
13
+ borderRadius: '4px',
14
+ boxSizing: 'border-box',
15
+ // An icon with `fontSize='inherit'` and the spinner of a waiting button follow the button.
16
+ fontSize: `${icon}px`,
17
+ height: `${height}px`,
18
+ padding: 0,
19
+ width: `${height}px`,
20
+ [exports.PNE_ICON_SIZE_VAR]: `${icon}px`,
21
+ };
22
+ };
23
+ exports.pneIconButtonSizeLook = pneIconButtonSizeLook;
24
+ const focusRing = (theme, pne) => [`0 0 0 2px ${theme.palette.background.paper}`, `0 0 0 4px ${pne.focusRing}`];
25
+ /**
26
+ * UI Kit Icon action: the colours of an icon button without a fill. `tone` is the colour under the
27
+ * pointer, `rest` the colour of the icon at rest (the tertiary text by default).
28
+ */
29
+ const pneIconActionLook = (theme, pne, tone = 'neutral', rest) => {
30
+ const dark = theme.palette.mode === 'dark';
31
+ const colors = tone === 'danger' ? pne.button.textDanger : pne.button.text;
32
+ return {
33
+ backgroundColor: 'transparent',
34
+ color: rest ?? (dark ? themeColors_1.PNE_DARK_COLORS.textMuted : themeColors_1.PNE_NEUTRAL_RAMP[600]),
35
+ transition: 'color 120ms linear',
36
+ '&:hover': {
37
+ backgroundColor: 'transparent',
38
+ color: colors.hover.text,
39
+ },
40
+ '&:active': {
41
+ color: colors.pressed.text,
42
+ },
43
+ '&.Mui-focusVisible': {
44
+ boxShadow: focusRing(theme, pne).join(', '),
45
+ },
46
+ '&.Mui-disabled': {
47
+ color: dark ? themeColors_1.PNE_DARK_COLORS.textDisabled : themeColors_1.PNE_NEUTRAL_RAMP[400],
48
+ },
49
+ };
50
+ };
51
+ exports.pneIconActionLook = pneIconActionLook;
52
+ const paletteColor = (theme, color) => {
53
+ const entry = typeof color === 'string'
54
+ ? theme.palette[color]
55
+ : undefined;
56
+ if (entry && typeof entry === 'object' && 'main' in entry && 'dark' in entry) {
57
+ return entry;
58
+ }
59
+ return undefined;
60
+ };
61
+ const colorLook = (theme, pne, color) => {
62
+ switch (color) {
63
+ case 'pnePrimary':
64
+ return { ...(0, buttonLook_1.pneButtonLookStyle)('primary', pne.button, focusRing(theme, pne)), stroke: 'currentColor' };
65
+ case 'pneNeutral':
66
+ return { ...(0, buttonLook_1.pneButtonLookStyle)('soft', pne.button, focusRing(theme, pne)), stroke: 'currentColor' };
67
+ case 'inherit':
68
+ return {
69
+ backgroundColor: 'transparent',
70
+ color: 'inherit',
71
+ '&:hover': { backgroundColor: theme.palette.action.hover },
72
+ '&.Mui-focusVisible': { boxShadow: focusRing(theme, pne).join(', ') },
73
+ };
74
+ case 'error':
75
+ return (0, exports.pneIconActionLook)(theme, pne, 'danger');
76
+ case 'primary':
77
+ return (0, exports.pneIconActionLook)(theme, pne, 'neutral', pne.button.text.hover.text);
78
+ default: {
79
+ const palette = paletteColor(theme, color);
80
+ return palette
81
+ ? {
82
+ ...(0, exports.pneIconActionLook)(theme, pne, 'neutral', palette.main),
83
+ '&:hover': { backgroundColor: 'transparent', color: palette.dark },
84
+ '&:active': { color: palette.dark },
85
+ }
86
+ : (0, exports.pneIconActionLook)(theme, pne);
87
+ }
88
+ }
89
+ };
90
+ // MUI pulls a button at an edge out by its padding; here the pull is the air around the glyph.
91
+ const edgeLook = (edge, size) => {
92
+ const { height, icon } = buttonLook_1.PNE_BUTTON_SIZE[size];
93
+ const pull = `-${(height - icon) / 2}px`;
94
+ if (edge === 'start')
95
+ return { marginLeft: pull };
96
+ if (edge === 'end')
97
+ return { marginRight: pull };
98
+ return undefined;
99
+ };
100
+ const styleCache = new WeakMap();
101
+ /**
102
+ * The `MuiIconButton` entry of the theme. A style is built once per theme, size, colour and edge: a
103
+ * table draws hundreds of these buttons.
104
+ */
105
+ const createPneIconButtonOverrides = (resolvePalette) => ({
106
+ defaultProps: {
107
+ // The UI Kit action has no fill in any state, so there is nothing for a ripple to draw on.
108
+ disableRipple: true,
109
+ },
110
+ styleOverrides: {
111
+ root: ({ ownerState, theme }) => {
112
+ const size = resolveSize(ownerState.size);
113
+ const color = ownerState.color ?? 'default';
114
+ const edge = ownerState.edge || 'none';
115
+ let styles = styleCache.get(theme);
116
+ if (!styles) {
117
+ styles = new Map();
118
+ styleCache.set(theme, styles);
119
+ }
120
+ const key = `${size}/${String(color)}/${String(edge)}`;
121
+ let style = styles.get(key);
122
+ if (!style) {
123
+ const pne = resolvePalette(theme);
124
+ style = {
125
+ ...(0, exports.pneIconButtonSizeLook)(size),
126
+ ...colorLook(theme, pne, color),
127
+ ...edgeLook(edge, size),
128
+ };
129
+ styles.set(key, style);
130
+ }
131
+ return style;
132
+ },
133
+ },
134
+ });
135
+ exports.createPneIconButtonOverrides = createPneIconButtonOverrides;
136
+ /**
137
+ * The `MuiSvgIcon` entry of the theme: an icon of the default size takes the size its icon button
138
+ * names, and 24px anywhere else. The size is read from an inherited custom property, so the rule adds
139
+ * no weight: an icon the page sized with `fontSize` or `sx` keeps its size.
140
+ */
141
+ const createPneSvgIconOverrides = () => ({
142
+ styleOverrides: {
143
+ root: ({ ownerState, theme }) => ((ownerState.fontSize ?? 'medium') === 'medium'
144
+ ? { fontSize: `var(${exports.PNE_ICON_SIZE_VAR}, ${theme.typography.pxToRem(24)})` }
145
+ : {}),
146
+ },
147
+ });
148
+ exports.createPneSvgIconOverrides = createPneSvgIconOverrides;
package/cjs/toggleLook.js CHANGED
@@ -1,29 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPneToggleGroupOverrides = void 0;
3
+ exports.createPneToggleGroupOverrides = exports.pneToggleGroupLook = void 0;
4
4
  const buttonLook_1 = require("./buttonLook");
5
5
  const tableControlLook_1 = require("./component/table/tableControlLook");
6
6
  const tableControlMetrics_1 = require("./component/table/tableControlMetrics");
7
7
  const GROUPED = '&& .MuiToggleButtonGroup-grouped';
8
+ /**
9
+ * The group's look from a palette. The theme draws every stock group with it; a composite that has to
10
+ * look right without the theme too (the Multiget panel of SearchUI) puts the same look into its `sx`.
11
+ */
12
+ const pneToggleGroupLook = (theme, pne, size = 'medium', orientation = 'horizontal') => ({
13
+ ...(0, tableControlLook_1.tableControlShellLook)(pne, 'tabs', buttonLook_1.PNE_BUTTON_SIZE[size].height + 2 * tableControlMetrics_1.TABLE_CONTROL_SHELL_PADDING),
14
+ // A stacked group stretches its buttons to the widest one.
15
+ ...(orientation === 'vertical' ? { alignItems: 'stretch' } : undefined),
16
+ // The text button of the table bands, as the views of a table are drawn.
17
+ [GROUPED]: {
18
+ ...(0, tableControlLook_1.tableControlTextButtonLook)(theme, pne, size),
19
+ border: 0,
20
+ borderRadius: '4px',
21
+ margin: 0,
22
+ },
23
+ [`${GROUPED}.Mui-selected`]: (0, tableControlLook_1.tableControlActiveLook)(pne),
24
+ });
25
+ exports.pneToggleGroupLook = pneToggleGroupLook;
8
26
  const createPneToggleGroupOverrides = (resolvePalette) => ({
9
27
  styleOverrides: {
10
- root: ({ ownerState, theme }) => {
11
- const pne = resolvePalette(theme);
12
- const size = ownerState.size === 'small' ? 'small' : 'medium';
13
- return {
14
- ...(0, tableControlLook_1.tableControlShellLook)(pne, 'tabs', buttonLook_1.PNE_BUTTON_SIZE[size].height + 2 * tableControlMetrics_1.TABLE_CONTROL_SHELL_PADDING),
15
- // A stacked group stretches its buttons to the widest one.
16
- ...(ownerState.orientation === 'vertical' ? { alignItems: 'stretch' } : undefined),
17
- // The text button of the table bands, as the views of a table are drawn.
18
- [GROUPED]: {
19
- ...(0, tableControlLook_1.tableControlTextButtonLook)(theme, pne, size),
20
- border: 0,
21
- borderRadius: '4px',
22
- margin: 0,
23
- },
24
- [`${GROUPED}.Mui-selected`]: (0, tableControlLook_1.tableControlActiveLook)(pne),
25
- };
26
- },
28
+ root: ({ ownerState, theme }) => (0, exports.pneToggleGroupLook)(theme, resolvePalette(theme), ownerState.size === 'small' ? 'small' : 'medium', ownerState.orientation === 'vertical' ? 'vertical' : 'horizontal'),
27
29
  },
28
30
  });
29
31
  exports.createPneToggleGroupOverrides = createPneToggleGroupOverrides;
@@ -1,4 +1,4 @@
1
- import type { Components, Theme } from '@mui/material/styles';
1
+ import type { Components, CSSObject, Theme } from '@mui/material/styles';
2
2
  import type { PneButtonPalette, PneButtonVariant } from './buttonPalette';
3
3
  /**
4
4
  * The look of the MUI `Button` under the PNE UI theme (UI Kit Button: Variant × Size × State). The
@@ -40,6 +40,8 @@ export type PneButtonSizeConfig = {
40
40
  * like a button without being one (the controls of a table band, an icon action) read it too.
41
41
  */
42
42
  export declare const PNE_BUTTON_SIZE: Record<PneButtonLookSize, PneButtonSizeConfig>;
43
+ /** The colours of a UI Kit button variant in all its states; the icon-only button of the theme takes them too. */
44
+ export declare const pneButtonLookStyle: (variant: PneButtonVariant, palette: PneButtonPalette, focusRing: string[]) => CSSObject;
43
45
  type ButtonPaletteSource = {
44
46
  button: PneButtonPalette;
45
47
  focusRing: string;
package/esm/buttonLook.js CHANGED
@@ -106,7 +106,8 @@ const sizeStyle = (size) => {
106
106
  [`${WAITING_CENTRE} .MuiButton-loadingIndicator`]: { fontSize: config.icon },
107
107
  };
108
108
  };
109
- const lookStyle = (variant, palette, focusRing) => {
109
+ /** The colours of a UI Kit button variant in all its states; the icon-only button of the theme takes them too. */
110
+ export const pneButtonLookStyle = (variant, palette, focusRing) => {
110
111
  const colors = palette[variant];
111
112
  // Later states win: default, hover, pressed, focus, waiting, picked, activated, disabled.
112
113
  return {
@@ -168,7 +169,7 @@ const buttonStyle = (theme, resolvePalette, size, look) => {
168
169
  // The two parts share no selector: the size rules set no colour, the look sets nothing else.
169
170
  style = {
170
171
  ...sizeStyle(size),
171
- ...(look ? lookStyle(look, pne.button, focusRing) : inheritStyle(theme, focusRing)),
172
+ ...(look ? pneButtonLookStyle(look, pne.button, focusRing) : inheritStyle(theme, focusRing)),
172
173
  };
173
174
  styles.set(key, style);
174
175
  }
@@ -3,7 +3,10 @@ import type { SxProps, Theme } from '@mui/material/styles';
3
3
  * UI Kit Icon action on a MUI IconButton: an icon button with no background, where hover and press
4
4
  * colour only the icon. `medium` is a 32px box with a 16px glyph (the close cross of a modal and of
5
5
  * a toast), `small` a 24px box with a 14px glyph. The icon rests in the tertiary text colour, or in
6
- * `restColor` (the tone of a toast), and takes the brand text colour under the pointer. The box and
7
- * the glyph are the height and the icon of a button of that size.
6
+ * `restColor` (the tone of a toast), and takes the brand text colour under the pointer.
7
+ *
8
+ * The theme draws every stock IconButton with the same look functions; the components of the library
9
+ * repeat the look here because they have to look right without the PNE UI theme as well, and they size
10
+ * every glyph, whatever size the icon asked for.
8
11
  */
9
12
  export declare const pneIconActionSx: (size: "small" | "medium", restColor?: string) => SxProps<Theme>;
@@ -1,41 +1,21 @@
1
1
  import { PNE_BUTTON_SIZE } from '../buttonLook';
2
2
  import { resolvePneSemanticPalette } from '../createTheme';
3
- import { PNE_DARK_COLORS, PNE_NEUTRAL_RAMP } from '../themeColors';
3
+ import { pneIconActionLook, pneIconButtonSizeLook } from '../iconButtonLook';
4
4
  /**
5
5
  * UI Kit Icon action on a MUI IconButton: an icon button with no background, where hover and press
6
6
  * colour only the icon. `medium` is a 32px box with a 16px glyph (the close cross of a modal and of
7
7
  * a toast), `small` a 24px box with a 14px glyph. The icon rests in the tertiary text colour, or in
8
- * `restColor` (the tone of a toast), and takes the brand text colour under the pointer. The box and
9
- * the glyph are the height and the icon of a button of that size.
8
+ * `restColor` (the tone of a toast), and takes the brand text colour under the pointer.
9
+ *
10
+ * The theme draws every stock IconButton with the same look functions; the components of the library
11
+ * repeat the look here because they have to look right without the PNE UI theme as well, and they size
12
+ * every glyph, whatever size the icon asked for.
10
13
  */
11
- export const pneIconActionSx = (size, restColor) => theme => {
12
- const pne = resolvePneSemanticPalette(theme);
13
- const dark = theme.palette.mode === 'dark';
14
- const { height, icon } = PNE_BUTTON_SIZE[size];
15
- const box = `${height}px`;
16
- return {
17
- flex: '0 0 auto',
18
- width: box,
19
- height: box,
20
- padding: 0,
21
- borderRadius: '4px',
22
- backgroundColor: 'transparent',
23
- color: restColor ?? (dark ? PNE_DARK_COLORS.textMuted : PNE_NEUTRAL_RAMP[600]),
24
- '& .MuiSvgIcon-root': {
25
- fontSize: `${icon}px`,
26
- },
27
- '&:hover': {
28
- backgroundColor: 'transparent',
29
- color: pne.button.text.hover.text,
30
- },
31
- '&:active': {
32
- color: pne.button.text.pressed.text,
33
- },
34
- '&.Mui-focusVisible': {
35
- boxShadow: `0 0 0 2px ${theme.palette.background.paper}, 0 0 0 4px ${pne.focusRing}`,
36
- },
37
- '&.Mui-disabled': {
38
- color: dark ? PNE_DARK_COLORS.textDisabled : PNE_NEUTRAL_RAMP[400],
39
- },
40
- };
41
- };
14
+ export const pneIconActionSx = (size, restColor) => theme => ({
15
+ flex: '0 0 auto',
16
+ ...pneIconButtonSizeLook(size),
17
+ ...pneIconActionLook(theme, resolvePneSemanticPalette(theme), 'neutral', restColor),
18
+ '& .MuiSvgIcon-root': {
19
+ fontSize: `${PNE_BUTTON_SIZE[size].icon}px`,
20
+ },
21
+ });
@@ -192,7 +192,6 @@ const parseInitialSelectedEntities = (multigetCriterion) => {
192
192
  return entities;
193
193
  };
194
194
  const toggleSx = {
195
- textTransform: 'none',
196
195
  flex: 1,
197
196
  };
198
197
  const topRowSx = {
@@ -1,7 +1,7 @@
1
1
  import type { SxProps, Theme } from '@mui/material/styles';
2
2
  /**
3
- * UI Kit Tabs group on a MUI ToggleButtonGroup: one choice out of a few. The grey shell of the table's
4
- * views with 24px buttons in it, the picked one white with the tab shadow; MUI's own borders, joined
5
- * corners and overlapping margins of a group are taken off.
3
+ * UI Kit Tabs group on a MUI ToggleButtonGroup: one choice out of a few. The small group of the theme
4
+ * (32px, 24px buttons): it stands level with the 32px search field and buttons of the Multiget window.
5
+ * The look is repeated here because the window has to look right without the PNE UI theme as well.
6
6
  */
7
7
  export declare const searchUITabsGroupSx: SxProps<Theme>;
@@ -1,26 +1,11 @@
1
1
  import { resolvePneSemanticPalette } from '../../createTheme';
2
- import { createTableControlActiveStyle, createTableControlShellStyle, createTableControlTextButtonStyle, } from '../table/tableControlButtonStyle';
2
+ import { pneToggleGroupLook } from '../../toggleLook';
3
3
  /**
4
- * UI Kit Tabs group on a MUI ToggleButtonGroup: one choice out of a few. The grey shell of the table's
5
- * views with 24px buttons in it, the picked one white with the tab shadow; MUI's own borders, joined
6
- * corners and overlapping margins of a group are taken off.
4
+ * UI Kit Tabs group on a MUI ToggleButtonGroup: one choice out of a few. The small group of the theme
5
+ * (32px, 24px buttons): it stands level with the 32px search field and buttons of the Multiget window.
6
+ * The look is repeated here because the window has to look right without the PNE UI theme as well.
7
7
  */
8
- export const searchUITabsGroupSx = theme => {
9
- const text = resolvePneSemanticPalette(theme).button.text;
10
- return {
11
- ...createTableControlShellStyle(theme, 'tabs'),
12
- display: 'inline-flex',
13
- '&& .MuiToggleButtonGroup-grouped': {
14
- ...createTableControlTextButtonStyle(theme),
15
- backgroundColor: 'transparent',
16
- border: 0,
17
- borderRadius: '4px',
18
- margin: 0,
19
- '&:hover': {
20
- backgroundColor: 'transparent',
21
- color: text.hover.text,
22
- },
23
- },
24
- '&& .MuiToggleButtonGroup-grouped.Mui-selected': createTableControlActiveStyle(theme),
25
- };
26
- };
8
+ export const searchUITabsGroupSx = theme => ({
9
+ ...pneToggleGroupLook(theme, resolvePneSemanticPalette(theme), 'small'),
10
+ display: 'inline-flex',
11
+ });
@@ -97,6 +97,8 @@ const PneTablePaginationActions = (props) => {
97
97
  ...controlStyle,
98
98
  flexShrink: 0,
99
99
  minWidth: `${TABLE_CONTROL_SIZE}px`,
100
+ // A label, not a glyph: the button is as wide as its number, whatever box the theme gives an icon button.
101
+ width: 'auto',
100
102
  '&:hover': hoverStyle,
101
103
  };
102
104
  const selectedButtonStyle = {
@@ -6,6 +6,7 @@ import { createPneButtonPalette, createPneFocusRing, createPneLinkColor, } from
6
6
  import { createPneCheckboxPalette } from './checkboxPalette';
7
7
  import { createPneChipOverrides } from './chipLook';
8
8
  import { createPneRadioOverrides } from './radioLook';
9
+ import { createPneIconButtonOverrides, createPneSvgIconOverrides } from './iconButtonLook';
9
10
  import { createPneToggleGroupOverrides } from './toggleLook';
10
11
  import { createPneTooltipOverrides } from './tooltipLook';
11
12
  import { createPneDropdownPalette } from './dropdownPalette';
@@ -178,7 +179,7 @@ const mergeThemeObjects = (base, override) => {
178
179
  });
179
180
  return result;
180
181
  };
181
- const createPneComponentOverrides = (mode) => ({
182
+ const createPneComponentOverrides = () => ({
182
183
  MuiFormHelperText: {
183
184
  styleOverrides: {
184
185
  root: {
@@ -193,55 +194,8 @@ const createPneComponentOverrides = (mode) => ({
193
194
  },
194
195
  },
195
196
  },
196
- MuiIconButton: {
197
- styleOverrides: {
198
- root: ({ ownerState, theme }) => {
199
- if (ownerState.color === 'pnePrimary') {
200
- if (mode === 'light') {
201
- return {
202
- backgroundColor: theme.palette.primary.main,
203
- color: theme.palette.primary.contrastText,
204
- '&:hover': {
205
- backgroundColor: theme.palette.primary.dark,
206
- color: theme.palette.primary.contrastText,
207
- },
208
- };
209
- }
210
- return {
211
- backgroundColor: theme.palette.pne.brand.fill,
212
- color: theme.palette.pne.brand.onFill,
213
- border: '1px solid',
214
- borderColor: theme.palette.pne.brand.fillBorder,
215
- '&:hover': {
216
- backgroundColor: theme.palette.pne.brand.fillHover,
217
- color: theme.palette.pne.brand.onFill,
218
- },
219
- };
220
- }
221
- if (ownerState.color === 'pneNeutral') {
222
- if (mode === 'light') {
223
- return {
224
- backgroundColor: '#F1F5FA',
225
- stroke: theme.palette.primary.main,
226
- '&:hover': {
227
- backgroundColor: theme.palette.primary.light,
228
- stroke: theme.palette.primary.dark,
229
- },
230
- };
231
- }
232
- return {
233
- backgroundColor: theme.palette.pne.surface.subtle,
234
- stroke: theme.palette.pne.brand.foreground,
235
- '&:hover': {
236
- backgroundColor: theme.palette.pne.brand.softHover,
237
- stroke: theme.palette.pne.brand.foregroundHover,
238
- },
239
- };
240
- }
241
- return {};
242
- },
243
- },
244
- },
197
+ MuiIconButton: createPneIconButtonOverrides(resolvePneSemanticPalette),
198
+ MuiSvgIcon: createPneSvgIconOverrides(),
245
199
  MuiButton: createPneButtonOverrides(resolvePneSemanticPalette),
246
200
  MuiChip: createPneChipOverrides(resolvePneSemanticPalette),
247
201
  MuiRadio: createPneRadioOverrides(resolvePneSemanticPalette),
@@ -294,7 +248,7 @@ const createBaseThemeOptions = (skin, mode) => {
294
248
  pneAccentuated: { main: seed },
295
249
  ...darkModePalette,
296
250
  },
297
- components: createPneComponentOverrides(mode),
251
+ components: createPneComponentOverrides(),
298
252
  };
299
253
  };
300
254
  const createPneThemeOptions = (skin, options = {}) => {
@@ -0,0 +1,46 @@
1
+ import type { Components, CSSObject, Theme } from '@mui/material/styles';
2
+ import { type PneButtonLookSize } from './buttonLook';
3
+ import type { PneSemanticPalette } from './createTheme';
4
+ /**
5
+ * The look of the MUI `IconButton` under the PNE UI theme (UI Kit Icon action). The library has no icon
6
+ * button of its own: the theme draws the stock one. No background and no round hover spot: the pointer
7
+ * and the press colour only the icon.
8
+ *
9
+ * The box does not depend on the glyph: `size='small'` is 24px (rows, table cells), the default
10
+ * `medium` 32px (forms, the close cross of a window), `large` 40px (in a row with 40px fields). A MUI
11
+ * icon of the default size inside takes 14 · 16 · 18px, the icon scale of the buttons; an icon the page
12
+ * sized itself keeps its size.
13
+ *
14
+ * | `color` | Look |
15
+ * |--------------------------|-------------------------------------------------------------------|
16
+ * | `default` | neutral: tertiary text at rest, the brand text under the pointer |
17
+ * | `primary` | the brand text at rest (UI Kit: the active state of a toggle) |
18
+ * | `error` | danger: neutral at rest, the error text under the pointer |
19
+ * | `inherit` | the colour of the place, MUI's hover veil |
20
+ * | `pnePrimary` | UI Kit Button Primary, icon only: a filled square |
21
+ * | `pneNeutral` | UI Kit Button Soft, icon only: a brand icon on the sunken fill |
22
+ * | other palette colours | the colour at rest, its dark step under the pointer |
23
+ */
24
+ export type PneIconButtonLookSize = PneButtonLookSize;
25
+ /** A MUI icon of the default size takes its size from this property; an icon button sets it. */
26
+ export declare const PNE_ICON_SIZE_VAR = "--pne-icon-size";
27
+ type IconButtonPaletteSource = Pick<PneSemanticPalette, 'button' | 'focusRing'>;
28
+ /** The box and the glyph of a size; no colour here. */
29
+ export declare const pneIconButtonSizeLook: (size: PneIconButtonLookSize) => CSSObject;
30
+ /**
31
+ * UI Kit Icon action: the colours of an icon button without a fill. `tone` is the colour under the
32
+ * pointer, `rest` the colour of the icon at rest (the tertiary text by default).
33
+ */
34
+ export declare const pneIconActionLook: (theme: Theme, pne: IconButtonPaletteSource, tone?: "neutral" | "danger", rest?: string) => CSSObject;
35
+ /**
36
+ * The `MuiIconButton` entry of the theme. A style is built once per theme, size, colour and edge: a
37
+ * table draws hundreds of these buttons.
38
+ */
39
+ export declare const createPneIconButtonOverrides: (resolvePalette: (theme: Theme) => IconButtonPaletteSource) => NonNullable<Components<Theme>["MuiIconButton"]>;
40
+ /**
41
+ * The `MuiSvgIcon` entry of the theme: an icon of the default size takes the size its icon button
42
+ * names, and 24px anywhere else. The size is read from an inherited custom property, so the rule adds
43
+ * no weight: an icon the page sized with `fontSize` or `sx` keeps its size.
44
+ */
45
+ export declare const createPneSvgIconOverrides: () => NonNullable<Components<Theme>["MuiSvgIcon"]>;
46
+ export {};
@@ -0,0 +1,141 @@
1
+ import { PNE_BUTTON_SIZE, pneButtonLookStyle } from './buttonLook';
2
+ import { PNE_DARK_COLORS, PNE_NEUTRAL_RAMP } from './themeColors';
3
+ /** A MUI icon of the default size takes its size from this property; an icon button sets it. */
4
+ export const PNE_ICON_SIZE_VAR = '--pne-icon-size';
5
+ const resolveSize = (size) => size === 'small' || size === 'large' ? size : 'medium';
6
+ /** The box and the glyph of a size; no colour here. */
7
+ export const pneIconButtonSizeLook = (size) => {
8
+ const { height, icon } = PNE_BUTTON_SIZE[size];
9
+ return {
10
+ borderRadius: '4px',
11
+ boxSizing: 'border-box',
12
+ // An icon with `fontSize='inherit'` and the spinner of a waiting button follow the button.
13
+ fontSize: `${icon}px`,
14
+ height: `${height}px`,
15
+ padding: 0,
16
+ width: `${height}px`,
17
+ [PNE_ICON_SIZE_VAR]: `${icon}px`,
18
+ };
19
+ };
20
+ const focusRing = (theme, pne) => [`0 0 0 2px ${theme.palette.background.paper}`, `0 0 0 4px ${pne.focusRing}`];
21
+ /**
22
+ * UI Kit Icon action: the colours of an icon button without a fill. `tone` is the colour under the
23
+ * pointer, `rest` the colour of the icon at rest (the tertiary text by default).
24
+ */
25
+ export const pneIconActionLook = (theme, pne, tone = 'neutral', rest) => {
26
+ const dark = theme.palette.mode === 'dark';
27
+ const colors = tone === 'danger' ? pne.button.textDanger : pne.button.text;
28
+ return {
29
+ backgroundColor: 'transparent',
30
+ color: rest ?? (dark ? PNE_DARK_COLORS.textMuted : PNE_NEUTRAL_RAMP[600]),
31
+ transition: 'color 120ms linear',
32
+ '&:hover': {
33
+ backgroundColor: 'transparent',
34
+ color: colors.hover.text,
35
+ },
36
+ '&:active': {
37
+ color: colors.pressed.text,
38
+ },
39
+ '&.Mui-focusVisible': {
40
+ boxShadow: focusRing(theme, pne).join(', '),
41
+ },
42
+ '&.Mui-disabled': {
43
+ color: dark ? PNE_DARK_COLORS.textDisabled : PNE_NEUTRAL_RAMP[400],
44
+ },
45
+ };
46
+ };
47
+ const paletteColor = (theme, color) => {
48
+ const entry = typeof color === 'string'
49
+ ? theme.palette[color]
50
+ : undefined;
51
+ if (entry && typeof entry === 'object' && 'main' in entry && 'dark' in entry) {
52
+ return entry;
53
+ }
54
+ return undefined;
55
+ };
56
+ const colorLook = (theme, pne, color) => {
57
+ switch (color) {
58
+ case 'pnePrimary':
59
+ return { ...pneButtonLookStyle('primary', pne.button, focusRing(theme, pne)), stroke: 'currentColor' };
60
+ case 'pneNeutral':
61
+ return { ...pneButtonLookStyle('soft', pne.button, focusRing(theme, pne)), stroke: 'currentColor' };
62
+ case 'inherit':
63
+ return {
64
+ backgroundColor: 'transparent',
65
+ color: 'inherit',
66
+ '&:hover': { backgroundColor: theme.palette.action.hover },
67
+ '&.Mui-focusVisible': { boxShadow: focusRing(theme, pne).join(', ') },
68
+ };
69
+ case 'error':
70
+ return pneIconActionLook(theme, pne, 'danger');
71
+ case 'primary':
72
+ return pneIconActionLook(theme, pne, 'neutral', pne.button.text.hover.text);
73
+ default: {
74
+ const palette = paletteColor(theme, color);
75
+ return palette
76
+ ? {
77
+ ...pneIconActionLook(theme, pne, 'neutral', palette.main),
78
+ '&:hover': { backgroundColor: 'transparent', color: palette.dark },
79
+ '&:active': { color: palette.dark },
80
+ }
81
+ : pneIconActionLook(theme, pne);
82
+ }
83
+ }
84
+ };
85
+ // MUI pulls a button at an edge out by its padding; here the pull is the air around the glyph.
86
+ const edgeLook = (edge, size) => {
87
+ const { height, icon } = PNE_BUTTON_SIZE[size];
88
+ const pull = `-${(height - icon) / 2}px`;
89
+ if (edge === 'start')
90
+ return { marginLeft: pull };
91
+ if (edge === 'end')
92
+ return { marginRight: pull };
93
+ return undefined;
94
+ };
95
+ const styleCache = new WeakMap();
96
+ /**
97
+ * The `MuiIconButton` entry of the theme. A style is built once per theme, size, colour and edge: a
98
+ * table draws hundreds of these buttons.
99
+ */
100
+ export const createPneIconButtonOverrides = (resolvePalette) => ({
101
+ defaultProps: {
102
+ // The UI Kit action has no fill in any state, so there is nothing for a ripple to draw on.
103
+ disableRipple: true,
104
+ },
105
+ styleOverrides: {
106
+ root: ({ ownerState, theme }) => {
107
+ const size = resolveSize(ownerState.size);
108
+ const color = ownerState.color ?? 'default';
109
+ const edge = ownerState.edge || 'none';
110
+ let styles = styleCache.get(theme);
111
+ if (!styles) {
112
+ styles = new Map();
113
+ styleCache.set(theme, styles);
114
+ }
115
+ const key = `${size}/${String(color)}/${String(edge)}`;
116
+ let style = styles.get(key);
117
+ if (!style) {
118
+ const pne = resolvePalette(theme);
119
+ style = {
120
+ ...pneIconButtonSizeLook(size),
121
+ ...colorLook(theme, pne, color),
122
+ ...edgeLook(edge, size),
123
+ };
124
+ styles.set(key, style);
125
+ }
126
+ return style;
127
+ },
128
+ },
129
+ });
130
+ /**
131
+ * The `MuiSvgIcon` entry of the theme: an icon of the default size takes the size its icon button
132
+ * names, and 24px anywhere else. The size is read from an inherited custom property, so the rule adds
133
+ * no weight: an icon the page sized with `fontSize` or `sx` keeps its size.
134
+ */
135
+ export const createPneSvgIconOverrides = () => ({
136
+ styleOverrides: {
137
+ root: ({ ownerState, theme }) => ((ownerState.fontSize ?? 'medium') === 'medium'
138
+ ? { fontSize: `var(${PNE_ICON_SIZE_VAR}, ${theme.typography.pxToRem(24)})` }
139
+ : {}),
140
+ },
141
+ });
@@ -1,3 +1,23 @@
1
- import type { Components, Theme } from '@mui/material/styles';
1
+ import type { Components, CSSObject, Theme } from '@mui/material/styles';
2
2
  import type { PneSemanticPalette } from './createTheme';
3
+ /**
4
+ * The look of the MUI `ToggleButtonGroup` under the PNE UI theme (UI Kit Tabs group: one choice out of
5
+ * a few). The library has no group of its own: the theme draws the stock one. A grey shell with 4px
6
+ * around its buttons and 4px between them; the buttons are text buttons without capitals, the picked
7
+ * one is a white tile with the tab shadow. MUI's own borders, joined corners and overlapping margins
8
+ * of a group are taken off.
9
+ *
10
+ * `size='medium'` (MUI's default) is the 40px group that stands in a row with fields and buttons of
11
+ * forms (32px buttons inside), `size='small'` the 32px group of the table bands (24px buttons).
12
+ * The UI Kit draws one look, so `color` of the group changes nothing.
13
+ *
14
+ * A `ToggleButton` outside a group is not a tab and keeps MUI's look.
15
+ */
16
+ type ToggleGroupSize = 'small' | 'medium';
17
+ /**
18
+ * The group's look from a palette. The theme draws every stock group with it; a composite that has to
19
+ * look right without the theme too (the Multiget panel of SearchUI) puts the same look into its `sx`.
20
+ */
21
+ export declare const pneToggleGroupLook: (theme: Theme, pne: PneSemanticPalette, size?: ToggleGroupSize, orientation?: "horizontal" | "vertical") => CSSObject;
3
22
  export declare const createPneToggleGroupOverrides: (resolvePalette: (theme: Theme) => PneSemanticPalette) => NonNullable<Components<Theme>["MuiToggleButtonGroup"]>;
23
+ export {};
package/esm/toggleLook.js CHANGED
@@ -2,24 +2,25 @@ import { PNE_BUTTON_SIZE } from './buttonLook';
2
2
  import { tableControlActiveLook, tableControlShellLook, tableControlTextButtonLook, } from './component/table/tableControlLook';
3
3
  import { TABLE_CONTROL_SHELL_PADDING } from './component/table/tableControlMetrics';
4
4
  const GROUPED = '&& .MuiToggleButtonGroup-grouped';
5
+ /**
6
+ * The group's look from a palette. The theme draws every stock group with it; a composite that has to
7
+ * look right without the theme too (the Multiget panel of SearchUI) puts the same look into its `sx`.
8
+ */
9
+ export const pneToggleGroupLook = (theme, pne, size = 'medium', orientation = 'horizontal') => ({
10
+ ...tableControlShellLook(pne, 'tabs', PNE_BUTTON_SIZE[size].height + 2 * TABLE_CONTROL_SHELL_PADDING),
11
+ // A stacked group stretches its buttons to the widest one.
12
+ ...(orientation === 'vertical' ? { alignItems: 'stretch' } : undefined),
13
+ // The text button of the table bands, as the views of a table are drawn.
14
+ [GROUPED]: {
15
+ ...tableControlTextButtonLook(theme, pne, size),
16
+ border: 0,
17
+ borderRadius: '4px',
18
+ margin: 0,
19
+ },
20
+ [`${GROUPED}.Mui-selected`]: tableControlActiveLook(pne),
21
+ });
5
22
  export const createPneToggleGroupOverrides = (resolvePalette) => ({
6
23
  styleOverrides: {
7
- root: ({ ownerState, theme }) => {
8
- const pne = resolvePalette(theme);
9
- const size = ownerState.size === 'small' ? 'small' : 'medium';
10
- return {
11
- ...tableControlShellLook(pne, 'tabs', PNE_BUTTON_SIZE[size].height + 2 * TABLE_CONTROL_SHELL_PADDING),
12
- // A stacked group stretches its buttons to the widest one.
13
- ...(ownerState.orientation === 'vertical' ? { alignItems: 'stretch' } : undefined),
14
- // The text button of the table bands, as the views of a table are drawn.
15
- [GROUPED]: {
16
- ...tableControlTextButtonLook(theme, pne, size),
17
- border: 0,
18
- borderRadius: '4px',
19
- margin: 0,
20
- },
21
- [`${GROUPED}.Mui-selected`]: tableControlActiveLook(pne),
22
- };
23
- },
24
+ root: ({ ownerState, theme }) => pneToggleGroupLook(theme, resolvePalette(theme), ownerState.size === 'small' ? 'small' : 'medium', ownerState.orientation === 'vertical' ? 'vertical' : 'horizontal'),
24
25
  },
25
26
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pne-ui",
3
- "version": "5.0.0-rc.40",
3
+ "version": "5.0.0-rc.41",
4
4
  "description": "React component kit on MUI for Payneteasy applications",
5
5
  "repository": {
6
6
  "type": "git",