Skip to content

Commit baa3617

Browse files
committed
Merge branch 'heads/upstream/master' into pretty-quick
2 parents 3c7ddd9 + 2321cf6 commit baa3617

File tree

30 files changed

+292
-246
lines changed

30 files changed

+292
-246
lines changed

apps/zero-runtime-vite-app/src/App.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as React from 'react';
2-
import { styled, generateAtomics, css } from '@mui/zero-runtime';
2+
import { styled, generateAtomics } from '@mui/zero-runtime';
33
import type { Breakpoint } from '@mui/system';
44
import { Button, bounceAnim } from 'local-ui-lib';
55
import Slider from './Slider/ZeroSlider';
6+
import { Box } from './Box';
67

78
const ShowCaseDiv = styled('div')({
89
[`.${Button}`]: {
@@ -60,11 +61,7 @@ export function App({ isRed }: AppProps) {
6061
const [isHorizontal, setIsHorizontal] = React.useState(true);
6162

6263
return (
63-
<div
64-
className={css`
65-
color: red;
66-
`}
67-
>
64+
<div>
6865
<ShowCaseDiv>
6966
<Button>This button&apos;s text color has been overridden.</Button>
7067
</ShowCaseDiv>
@@ -174,6 +171,7 @@ export function App({ isRed }: AppProps) {
174171
<span>Hello2</span>
175172
</div>
176173
</div>
174+
<Box as="div">Hello</Box>
177175
</div>
178176
);
179177
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { generateAtomics } from '@mui/zero-runtime';
2+
3+
const atomics = generateAtomics(({ theme }) => ({
4+
conditions: Object.keys(theme.breakpoints.values).reduce((acc, breakpoint) => {
5+
acc[breakpoint] = `@media (min-width: ${theme.breakpoints.values[breakpoint]}${
6+
theme.breakpoints.unit ?? 'px'
7+
})`;
8+
return acc;
9+
}, {}),
10+
defaultCondition: 'xs',
11+
properties: {
12+
display: [
13+
'block',
14+
'inline-flex',
15+
'contents',
16+
'none',
17+
'flex',
18+
'inline-flex',
19+
'grid',
20+
'inline-grid',
21+
],
22+
flexDirection: ['row', 'row-reverse', 'column', 'column-reverse'],
23+
justifyContent: [
24+
'center',
25+
'end',
26+
'flex-end',
27+
'flex-start',
28+
'left',
29+
'right',
30+
'space-around',
31+
'space-between',
32+
'space-evenly',
33+
'start',
34+
],
35+
alignItems: [
36+
'baseline',
37+
'center',
38+
'end',
39+
'flex-end',
40+
'flex-start',
41+
'self-end',
42+
'self-start',
43+
'start',
44+
'stretch',
45+
],
46+
position: ['relative', 'absolute', 'static', 'sticky', 'fixed'],
47+
},
48+
shorthands: {
49+
direction: ['flexDirection'],
50+
},
51+
}));
52+
53+
// eslint-disable-next-line react/prop-types
54+
export function Box({ children, as = 'div', className = '', style = undefined, ...rest }) {
55+
const Component = as;
56+
const atomicsResult = atomics(rest);
57+
const componentClass = `${atomicsResult.className} ${className ?? ''}`.trim();
58+
const finalStyles = {
59+
...(atomicsResult.style ?? {}),
60+
...style,
61+
};
62+
return (
63+
// eslint-disable-next-line react/jsx-filename-extension
64+
<Component className={componentClass} style={finalStyles}>
65+
{children}
66+
</Component>
67+
);
68+
}

apps/zero-runtime-vite-app/vite.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@ export default defineConfig({
2222
reactPlugin(),
2323
splitVendorChunkPlugin(),
2424
],
25+
resolve: {
26+
alias: [
27+
{
28+
find: /^@mui\/system\/(.*)/,
29+
replacement: '@mui/system/esm/$1',
30+
},
31+
],
32+
},
2533
});

docs/pages/base-ui/api/use-select.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
"open": { "type": { "name": "boolean", "description": "boolean" } },
5959
"options": {
6060
"type": {
61-
"name": "SelectOptionDefinition&lt;OptionValue&gt;[]",
62-
"description": "SelectOptionDefinition&lt;OptionValue&gt;[]"
61+
"name": "ReadonlyArray&lt;SelectOptionDefinition&lt;OptionValue&gt;&gt;",
62+
"description": "ReadonlyArray&lt;SelectOptionDefinition&lt;OptionValue&gt;&gt;"
6363
}
6464
},
6565
"required": { "type": { "name": "boolean", "description": "boolean" } },

docs/pages/base-ui/api/use-slider.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
{
22
"parameters": {
33
"aria-labelledby": { "type": { "name": "string", "description": "string" } },
4-
"defaultValue": { "type": { "name": "number | number[]", "description": "number | number[]" } },
4+
"defaultValue": {
5+
"type": {
6+
"name": "number | ReadonlyArray&lt;number&gt;",
7+
"description": "number | ReadonlyArray&lt;number&gt;"
8+
}
9+
},
510
"disabled": { "type": { "name": "boolean", "description": "boolean" }, "default": "false" },
611
"disableSwap": { "type": { "name": "boolean", "description": "boolean" }, "default": "false" },
712
"isRtl": { "type": { "name": "boolean", "description": "boolean" }, "default": "false" },
813
"marks": {
9-
"type": { "name": "boolean | Mark[]", "description": "boolean | Mark[]" },
14+
"type": {
15+
"name": "boolean | ReadonlyArray&lt;Mark&gt;",
16+
"description": "boolean | ReadonlyArray&lt;Mark&gt;"
17+
},
1018
"default": "false"
1119
},
1220
"max": { "type": { "name": "number", "description": "number" }, "default": "100" },
@@ -44,7 +52,12 @@
4452
"shiftStep": { "type": { "name": "number", "description": "number" }, "default": "10" },
4553
"step": { "type": { "name": "number | null", "description": "number | null" }, "default": "1" },
4654
"tabIndex": { "type": { "name": "number", "description": "number" } },
47-
"value": { "type": { "name": "number | number[]", "description": "number | number[]" } }
55+
"value": {
56+
"type": {
57+
"name": "number | ReadonlyArray&lt;number&gt;",
58+
"description": "number | ReadonlyArray&lt;number&gt;"
59+
}
60+
}
4861
},
4962
"returnValue": {
5063
"active": { "type": { "name": "number", "description": "number" }, "required": true },

packages/mui-base/src/FocusTrap/FocusTrap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function FocusTrap(props: FocusTrapProps): JSX.Element {
278278
return;
279279
}
280280

281-
let tabbable: string[] | HTMLElement[] = [];
281+
let tabbable: ReadonlyArray<string> | HTMLElement[] = [];
282282
if (
283283
doc.activeElement === sentinelStart.current ||
284284
doc.activeElement === sentinelEnd.current

packages/mui-base/src/FocusTrap/FocusTrap.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface FocusTrapProps {
1010
* For instance, you can provide the "tabbable" npm dependency.
1111
* @param {HTMLElement} root
1212
*/
13-
getTabbable?: (root: HTMLElement) => string[];
13+
getTabbable?: (root: HTMLElement) => ReadonlyArray<string>;
1414
/**
1515
* This prop extends the `open` prop.
1616
* It allows to toggle the open state without having to wait for a rerender when changing the `open` prop.

packages/mui-base/src/useSelect/useSelect.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export interface UseSelectParameters<OptionValue, Multiple extends boolean = fal
102102
* An alternative way to specify the options.
103103
* If this parameter is set, options defined as JSX children are ignored.
104104
*/
105-
options?: SelectOptionDefinition<OptionValue>[];
105+
options?: ReadonlyArray<SelectOptionDefinition<OptionValue>>;
106106
/**
107107
* A function to convert the currently selected value to a string.
108108
* Used to set a value of a hidden input associated with the select,

packages/mui-base/src/useSlider/useSlider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ function focusThumb({
136136
}
137137

138138
function areValuesEqual(
139-
newValue: number | Array<number>,
140-
oldValue: number | Array<number>,
139+
newValue: number | ReadonlyArray<number>,
140+
oldValue: number | ReadonlyArray<number>,
141141
): boolean {
142142
if (typeof newValue === 'number' && typeof oldValue === 'number') {
143143
return newValue === oldValue;

packages/mui-base/src/useSlider/useSlider.types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface UseSliderParameters {
88
/**
99
* The default value. Use when the component is not controlled.
1010
*/
11-
defaultValue?: number | number[];
11+
defaultValue?: number | ReadonlyArray<number>;
1212
/**
1313
* If `true`, the component is disabled.
1414
* @default false
@@ -30,7 +30,7 @@ export interface UseSliderParameters {
3030
* If an array, it should contain objects with `value` and an optional `label` keys.
3131
* @default false
3232
*/
33-
marks?: boolean | Mark[];
33+
marks?: boolean | ReadonlyArray<Mark>;
3434
/**
3535
* The maximum allowed value of the slider.
3636
* Should not be equal to min.
@@ -104,7 +104,7 @@ export interface UseSliderParameters {
104104
* The value of the slider.
105105
* For ranged sliders, provide an array with two values.
106106
*/
107-
value?: number | number[];
107+
value?: number | ReadonlyArray<number>;
108108
}
109109

110110
export interface Mark {

0 commit comments

Comments
 (0)