Skip to content

Commit

Permalink
Merge branch 'master' into pass-timezone-when-formatting-time
Browse files Browse the repository at this point in the history
  • Loading branch information
NyxinU authored Dec 6, 2024
2 parents 8683670 + 29f5df2 commit 93c3f7f
Show file tree
Hide file tree
Showing 83 changed files with 952 additions and 463 deletions.
614 changes: 307 additions & 307 deletions .yarn/releases/yarn-4.5.1.cjs → .yarn/releases/yarn-4.5.3.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.1.cjs
yarnPath: .yarn/releases/yarn-4.5.3.cjs
9 changes: 9 additions & 0 deletions apps/mantine.dev/src/pages/charts/bar-chart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,12 @@ rendered behind the chart.
To display value above each bar, set `withBarValueLabel`:

<Demo data={BarChartDemos.barValueLabel} />

## Bar value label props

You can pass props down to recharts [LabelList](https://recharts.org/en-US/api/LabelList)
component with `valueLabelProps` prop. `valueLabelProps` accepts either an object with props
or a function that receives series data as an argument and returns an object with
props.

<Demo data={BarChartDemos.valueLabelProps} />
21 changes: 21 additions & 0 deletions apps/mantine.dev/src/pages/core/app-shell.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,24 @@ function Demo() {
- `AppShell.Aside` root element is `aside`
- `AppShell.Footer` root element is `footer`
- `AppShell.Main` root element is `main`**!important:** do not use `main` element inside `AppShell.Main` component

## CSS variables

You can use the following CSS variables in all components used inside `AppShell`:

- `--app-shell-navbar-width` – width of the `AppShell.Navbar`
- `--app-shell-navbar-offset` – offset of the `AppShell.Navbar`
- `--app-shell-aside-width` – width of the `AppShell.Aside`
- `--app-shell-aside-offset` – offset of the `AppShell.Aside`
- `--app-shell-header-height` – height of the `AppShell.Header`
- `--app-shell-header-offset` – offset of the `AppShell.Header`
- `--app-shell-footer-height` – height of the `AppShell.Footer`
- `--app-shell-footer-offset` – offset of the `AppShell.Footer`

Example of using CSS variables in styles:

```scss
.main {
min-height: calc(100vh - var(--app-shell-header-height));
}
```
3 changes: 3 additions & 0 deletions apps/mantine.dev/src/pages/core/drawer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ Differences from using multiple `Drawer` components:

<Demo data={DrawerDemos.stack} />

Note that `Drawer.Stack` can only be used with `Drawer` component. Components built with `Drawer.Root`
and other compound components are not compatible with `Drawer.Stack`.

## useDrawersStack hook

`useDrawersStack` hook provides an easy way to control multiple drawers at the same time.
Expand Down
3 changes: 3 additions & 0 deletions apps/mantine.dev/src/pages/core/modal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ Differences from using multiple `Modal` components:

<Demo data={ModalDemos.stack} />

Note that `Modal.Stack` can only be used with `Modal` component. Components built with `Modal.Root`
and other compound components are not compatible with `Modal.Stack`.

## useModalsStack hook

`useModalsStack` hook provides an easy way to control multiple modals at the same time.
Expand Down
1 change: 1 addition & 0 deletions apps/mantine.dev/src/pages/styles/css-files-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import '@mantine/core/styles/ModalBase.css';
import '@mantine/core/styles/Input.css';
import '@mantine/core/styles/InlineInput.css';
import '@mantine/core/styles/Flex.css';
import '@mantine/core/styles/FloatingIndicator.css';
```

## Global styles
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "mantine-a91763c0e2",
"version": "7.14.2-alpha.0",
"version": "7.14.3",
"description": "Mantine Components Monorepo",
"packageManager": "[email protected].1",
"packageManager": "[email protected].3",
"license": "MIT",
"private": true,
"author": "Vitaly Rtishchev <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { BarChart } from '@mantine/charts';
import { MantineDemo } from '@mantinex/demo';
import { data, dataCode } from './_data';

const code = `
import { BarChart } from '@mantine/charts';
import { data } from './data';
function Demo() {
return (
<BarChart
h={300}
data={data}
dataKey="month"
valueFormatter={(value) => new Intl.NumberFormat('en-US').format(value)}
withBarValueLabel
valueLabelProps={{ position: 'inside', fill: 'white' }}
series={[
{ name: 'Smartphones', color: 'violet.6' },
{ name: 'Laptops', color: 'blue.6' },
{ name: 'Tablets', color: 'teal.6' },
]}
/>
);
}
`;

function Demo() {
return (
<BarChart
h={300}
data={data}
dataKey="month"
valueFormatter={(value) => new Intl.NumberFormat('en-US').format(value)}
withBarValueLabel
valueLabelProps={{ position: 'inside', fill: 'white' }}
series={[
{ name: 'Smartphones', color: 'violet.6' },
{ name: 'Laptops', color: 'blue.6' },
{ name: 'Tablets', color: 'teal.6' },
]}
/>
);
}

export const valueLabelProps: MantineDemo = {
type: 'code',
component: Demo,
code: [
{ code, language: 'tsx', fileName: 'Demo.tsx' },
{ code: dataCode, language: 'tsx', fileName: 'data.ts' },
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ export const Demo_barValueLabel = {
render: renderDemo(demos.barValueLabel),
};

export const Demo_valueLabelProps = {
name: '⭐ Demo: valueLabelProps',
render: renderDemo(demos.valueLabelProps),
};

export const Demo_minBarSize = {
name: '⭐ Demo: minBarSize',
render: renderDemo(demos.minBarSize),
Expand Down
1 change: 1 addition & 0 deletions packages/@docs/demos/src/demos/charts/BarChart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ export { barValueLabel } from './BarChart.demo.barValueLabel';
export { minBarSize } from './BarChart.demo.minBarSize';
export { mixedStack } from './BarChart.demo.mixedStack';
export { stripes } from './BarChart.demo.stripes';
export { valueLabelProps } from './BarChart.demo.valueLabelProps';
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,14 @@ export const withLabels: MantineDemo = {
{ fileName: 'data.ts', code: dataCode, language: 'tsx' },
],
centered: true,
controls: [{ type: 'boolean', prop: 'withLabelsLine', initialValue: true, libraryValue: '__' }],
controls: [
{ type: 'boolean', prop: 'withLabelsLine', initialValue: true, libraryValue: '__' },
{
type: 'segmented',
prop: 'labelsType',
initialValue: 'value',
libraryValue: '__',
data: ['value', 'percent'],
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { DatePicker } from '@mantine/dates';
import { MantineDemo } from '@mantinex/demo';

const code = `
import { DatePicker } from '@mantine/dates';
function Demo() {
return <DatePicker withWeekNumbers />;
}
`;

function Demo() {
return <DatePicker withWeekNumbers />;
}

export const withWeekNumbers: MantineDemo = {
type: 'code',
centered: true,
component: Demo,
code,
};
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,8 @@ export const Demo_excludeDate = {
name: '⭐ Demo: excludeDate',
render: renderDemo(demos.excludeDate),
};

export const Demo_withWeekNumbers = {
name: '⭐ Demo: withWeekNumbers',
render: renderDemo(demos.withWeekNumbers),
};
1 change: 1 addition & 0 deletions packages/@docs/demos/src/demos/dates/DatePicker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export { renderDay } from './DatePicker.demo.renderDay';
export { hideWeekdays } from './DatePicker.demo.hideWeekdays';
export { hideOutsideDates } from './DatePicker.demo.hideOutsideDates';
export { excludeDate } from './DatePicker.demo.excludeDate';
export { withWeekNumbers } from './DatePicker.demo.withWeekNumbers';
1 change: 1 addition & 0 deletions packages/@docs/styles-api/src/data/Dates.styles-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const MonthStylesApi: StylesApiData<MonthFactory> = {
weekdaysRow: 'Weekdays tr element',
weekday: 'Weekday th element',
day: 'Month day control',
weekNumber: 'Week number td element',
},

vars: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { render } from '../render';

interface Options<Props = any> {
component: React.ComponentType<Props>;
props: Props & JSX.IntrinsicAttributes;
props: Props & React.JSX.IntrinsicAttributes;
error: string;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/@mantine/carousel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mantine/carousel",
"version": "7.14.2-alpha.0",
"version": "7.14.3",
"description": "Embla based carousel",
"homepage": "https://mantine.dev/x/carousel/",
"license": "MIT",
Expand Down Expand Up @@ -44,8 +44,8 @@
"directory": "packages/@mantine/carousel"
},
"peerDependencies": {
"@mantine/core": "7.14.2-alpha.0",
"@mantine/hooks": "7.14.2-alpha.0",
"@mantine/core": "7.14.3",
"@mantine/hooks": "7.14.3",
"embla-carousel-react": ">=7.0.0",
"react": "^18.x || ^19.x",
"react-dom": "^18.x || ^19.x"
Expand Down
6 changes: 3 additions & 3 deletions packages/@mantine/charts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mantine/charts",
"version": "7.14.2-alpha.0",
"version": "7.14.3",
"description": "Charts components built with recharts and Mantine",
"homepage": "https://mantine.dev/",
"license": "MIT",
Expand Down Expand Up @@ -35,8 +35,8 @@
"directory": "packages/@mantine/charts"
},
"peerDependencies": {
"@mantine/core": "7.14.2-alpha.0",
"@mantine/hooks": "7.14.2-alpha.0",
"@mantine/core": "7.14.3",
"@mantine/hooks": "7.14.3",
"react": "^18.x || ^19.x",
"react-dom": "^18.x || ^19.x",
"recharts": "^2.13.3"
Expand Down
27 changes: 19 additions & 8 deletions packages/@mantine/charts/src/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
CartesianGrid,
Cell,
Label,
LabelList,
LabelListProps,
Legend,
BarChart as ReChartsBarChart,
ReferenceLine,
Expand All @@ -31,7 +33,6 @@ import {
import { ChartLegend, ChartLegendStylesNames } from '../ChartLegend';
import { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip';
import type { BaseChartStylesNames, ChartSeries, GridChartBaseProps } from '../types';
import { BarLabel } from './BarLabel';
import classes from '../grid-chart.module.css';

function valueToPercent(value: number) {
Expand Down Expand Up @@ -92,6 +93,11 @@ export interface BarChartProps
/** Determines whether a label with bar value should be displayed on top of each bar, incompatible with `type="stacked"` and `type="percent"`, `false` by default */
withBarValueLabel?: boolean;

/** Props passed down to recharts `LabelList` component */
valueLabelProps?:
| ((series: BarChartSeries) => Partial<Omit<LabelListProps<Record<string, any>>, 'ref'>>)
| Partial<LabelListProps<Record<string, any>>>;

/** Sets minimum height of the bar in px, `0` by default */
minBarSize?: number;

Expand Down Expand Up @@ -202,6 +208,7 @@ export const BarChart = factory<BarChartFactory>((_props, ref) => {
xAxisLabel,
yAxisLabel,
withBarValueLabel,
valueLabelProps,
withRightYAxis,
rightYAxisLabel,
rightYAxisProps,
Expand All @@ -217,6 +224,8 @@ export const BarChart = factory<BarChartFactory>((_props, ref) => {
const [highlightedArea, setHighlightedArea] = useState<string | null>(null);
const shouldHighlight = highlightedArea !== null;
const stacked = type === 'stacked' || type === 'percent';
const tickFormatter = type === 'percent' ? valueToPercent : valueFormatter;

const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {
setHighlightedArea(null);
onMouseLeave?.(event);
Expand Down Expand Up @@ -258,11 +267,6 @@ export const BarChart = factory<BarChartFactory>((_props, ref) => {
fillOpacity={dimmed ? 0.1 : fillOpacity}
strokeOpacity={dimmed ? 0.2 : 0}
stackId={stacked ? 'stack' : item.stackId || undefined}
label={
withBarValueLabel ? (
<BarLabel valueFormatter={valueFormatter} orientation={orientation} />
) : undefined
}
yAxisId={item.yAxisId || 'left'}
minPointSize={minBarSize}
{...(typeof barProps === 'function' ? barProps(item) : barProps)}
Expand All @@ -275,6 +279,15 @@ export const BarChart = factory<BarChartFactory>((_props, ref) => {
}
/>
))}
{withBarValueLabel && (
<LabelList
position={orientation === 'vertical' ? 'right' : 'top'}
fontSize={12}
fill="var(--chart-bar-label-color, var(--mantine-color-dimmed))"
formatter={tickFormatter}
{...(typeof valueLabelProps === 'function' ? valueLabelProps(item) : valueLabelProps)}
/>
)}
</Bar>
);
});
Expand All @@ -299,8 +312,6 @@ export const BarChart = factory<BarChartFactory>((_props, ref) => {
);
});

const tickFormatter = type === 'percent' ? valueToPercent : valueFormatter;

const sharedYAxisProps = {
axisLine: false,
...(orientation === 'vertical'
Expand Down
23 changes: 0 additions & 23 deletions packages/@mantine/charts/src/BarChart/BarLabel.tsx

This file was deleted.

Loading

0 comments on commit 93c3f7f

Please sign in to comment.