mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
`100.0.0` ⏩ `101.0.1` [Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams) ## Package updates ### `@elastic/eui` [`v101.0.1`](https://github.com/elastic/eui/releases/v101.0.1) - Updated `EuiProvider` and `EuiThemeProvider` with a new `highContrastMode` ([#8444](https://github.com/elastic/eui/pull/8444)) - This prop allows toggling a higher contrast visual style that primarily affects borders and shadows - On `EuiProvider`, if the `highContrastMode` prop is not passed, this setting will inherit from the user's OS/system settings - If the user is using a forced colors mode (e.g. Windows' high contrast themes), this system setting will take precedence over any `highContrastMode` or `colorMode` props passed - Added `highContrastModeStyles` and `preventForcedColors` styling utils ([#8444](https://github.com/elastic/eui/pull/8444)) - Updated `EuiRangeTooltip` to be easier to see in dark mode ([#8444](https://github.com/elastic/eui/pull/8444)) - Updated some deprecated color token usages that have direct substitutes ([#8444](https://github.com/elastic/eui/pull/8444)) - `text` -> `textParagraph` - `title` -> `textHeading` - `subduedText` -> `textSubdued` - `disabledText` -> `textDisabled` - `accentText` -> `textAccent` - `dangerText` -> `textDanger` - `warningText` -> `textWarning` - `useEuiShadow()` now accepts a second `options` argument ([#8234](https://github.com/elastic/eui/pull/8234)) - `useEuiShadowFlat()` now accepts an `options` object instead of only a color ([#8234](https://github.com/elastic/eui/pull/8234)) - Updated `EuiPopover` and `EuiToolTip` to be easier to see in dark mode. ([#8174](https://github.com/elastic/eui/pull/8174)) **Bug fixes** - Fixed a visual bug where a transparent border would create visible empty space (`LIGHT` mode only) for the components: ([#8427](https://github.com/elastic/eui/pull/8427)) - `EuiPanel` - `EuiPopover` - `EuiToolTip` - `EuiToast` - `EuiTour` --- ### `@elastic/eui-theme-common` [`v0.1.0`](https://github.com/elastic/eui/releases/v0.1.0) - Removed type `EuiShadowCustomColor` ([#8444](https://github.com/elastic/eui/pull/8444)) - Added types: ([#8444](https://github.com/elastic/eui/pull/8444)) - `EuiShadowOptions` - `EuiThemeHighContrastModeProp` - `EuiThemeHighContrastMode` - Updated shadow utils to accepts a second `options` argument and return borders in high contrast mode: ([#8444](https://github.com/elastic/eui/pull/8444)) - `euiShadow` - `euiShadowXSmall` - `euiShadowSmall` - `euiShadowMedium` - `euiShadowLarge` - `euiSlightShadowHover` - `euiShadowFlat` --- ### `@elastic/eui-theme-borealis` [`v0.1.0`](https://github.com/elastic/eui/releases/v0.1.0) - Added new component level tokens: ([#8444](https://github.com/elastic/eui/pull/8444)) - `buttonGroupBackgroundDisabledSelected` - `overlayMaskBackground` - `overlayMaskBackgroundHighContrast` - `skeletonBackgroundSkeletonMiddleHighContrast` ## Additional changes The latest `@elastic/eui` package introduces high contrast mode support. This PR sets all usages of `EuiProvider` to use `highContrastMode={false}` to introduce it in disabled state (this reflects the current functionality in Kibana). This is because the UI for the high contrast mode functionality (and style adjustments) need to first be implemented on Kibana side (by shared-ux). ## QA Adding high contrast mode in disabled state should result in no visual changes in Kibana. Please ensure your product view remain unchanged. --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
198 lines
6.6 KiB
TypeScript
198 lines
6.6 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the "Elastic License
|
|
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
* Public License v 1"; you may not use this file except in compliance with, at
|
|
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
*/
|
|
|
|
import React from 'react';
|
|
import {
|
|
EuiBasicTable,
|
|
EuiCallOut,
|
|
EuiCode,
|
|
EuiCodeBlock,
|
|
EuiLink,
|
|
EuiPageTemplate,
|
|
EuiProvider,
|
|
EuiSpacer,
|
|
EuiText,
|
|
EuiTitle,
|
|
} from '@elastic/eui';
|
|
import { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
|
|
import * as example1 from './examples/1_using_existing_format';
|
|
import * as example2 from './examples/2_creating_custom_formatter';
|
|
// @ts-ignore
|
|
import example1SampleCode from './examples/1_using_existing_format?raw';
|
|
// @ts-ignore
|
|
import example2SampleCodePart1 from '../common/example_currency_format?raw';
|
|
// @ts-ignore
|
|
import example2SampleCodePart2 from './examples/2_creating_custom_formatter?raw';
|
|
// @ts-ignore
|
|
import example2SampleCodePart3 from '../server/examples/2_creating_custom_formatter?raw';
|
|
// @ts-ignore
|
|
import example3SampleCode from './examples/3_creating_custom_format_editor?raw';
|
|
|
|
export interface Deps {
|
|
fieldFormats: FieldFormatsStart;
|
|
|
|
/**
|
|
* Just for demo purposes
|
|
*/
|
|
openDateViewNumberFieldEditor: () => void;
|
|
}
|
|
|
|
const UsingAnExistingFieldFormatExample: React.FC<{ deps: Deps }> = (props) => {
|
|
const sample = example1.getSample(props.deps.fieldFormats);
|
|
|
|
return (
|
|
<>
|
|
<EuiText>
|
|
<p>
|
|
This example shows how to use existing field formatter to format values. As an example, we
|
|
have a following sample configuration{' '}
|
|
<EuiCode>{JSON.stringify(example1.sampleSerializedFieldFormat)}</EuiCode> representing a{' '}
|
|
<EuiCode>bytes</EuiCode>
|
|
field formatter with a <EuiCode>0.00b</EuiCode> pattern.
|
|
</p>
|
|
</EuiText>
|
|
<EuiSpacer size={'s'} />
|
|
<EuiCodeBlock language="jsx">{example1SampleCode}</EuiCodeBlock>
|
|
<EuiSpacer size={'s'} />
|
|
<EuiBasicTable
|
|
data-test-subj={'example1 sample table'}
|
|
items={sample}
|
|
columns={[
|
|
{
|
|
field: 'raw',
|
|
name: 'Raw value',
|
|
'data-test-subj': 'example1 sample raw',
|
|
},
|
|
{
|
|
field: 'formatted',
|
|
name: 'Formatted value',
|
|
'data-test-subj': 'example1 sample formatted',
|
|
},
|
|
]}
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
|
|
const CreatingCustomFieldFormat: React.FC<{ deps: Deps }> = (props) => {
|
|
const sample = example2.getSample(props.deps.fieldFormats);
|
|
|
|
return (
|
|
<>
|
|
<EuiText>
|
|
<p>
|
|
This example shows how to create a custom field formatter. As an example, we create a
|
|
currency formatter and then display some values as <EuiCode>USD</EuiCode>. Custom field
|
|
formatter has to be registered both client and server side.
|
|
</p>
|
|
</EuiText>
|
|
<EuiSpacer size={'s'} />
|
|
<EuiCodeBlock language="jsx">{example2SampleCodePart1}</EuiCodeBlock>
|
|
<EuiSpacer size={'xs'} />
|
|
<EuiCodeBlock language="jsx">{example2SampleCodePart2}</EuiCodeBlock>
|
|
<EuiSpacer size={'xs'} />
|
|
<EuiCodeBlock language="jsx">{example2SampleCodePart3}</EuiCodeBlock>
|
|
<EuiSpacer size={'s'} />
|
|
<EuiBasicTable
|
|
items={sample}
|
|
data-test-subj={'example2 sample table'}
|
|
columns={[
|
|
{
|
|
field: 'raw',
|
|
name: 'Raw value',
|
|
'data-test-subj': 'example2 sample raw',
|
|
},
|
|
{
|
|
field: 'formatted',
|
|
name: 'Formatted value',
|
|
'data-test-subj': 'example2 sample formatted',
|
|
},
|
|
]}
|
|
/>
|
|
<EuiSpacer size={'s'} />
|
|
|
|
<EuiCallOut
|
|
title="Seamless integration with data views!"
|
|
color="success"
|
|
iconType="indexManagementApp"
|
|
>
|
|
<p>
|
|
Currency formatter that we've just created is already integrated with data views. It
|
|
can be applied to any <EuiCode>numeric</EuiCode> field of any data view.{' '}
|
|
<EuiLink onClick={() => props.deps.openDateViewNumberFieldEditor()}>
|
|
Open data view field editor to give it a try.
|
|
</EuiLink>
|
|
</p>
|
|
</EuiCallOut>
|
|
</>
|
|
);
|
|
};
|
|
|
|
const CreatingCustomFieldFormatEditor: React.FC<{ deps: Deps }> = (props) => {
|
|
return (
|
|
<>
|
|
<EuiText>
|
|
<p>
|
|
This example shows how to create a custom field formatter editor. As an example, we will
|
|
create a format editor for the currency formatter created in the previous section. This
|
|
custom editor will allow to select either <EuiCode>USD</EuiCode> or <EuiCode>EUR</EuiCode>{' '}
|
|
currency.
|
|
</p>
|
|
</EuiText>
|
|
<EuiSpacer size={'s'} />
|
|
<EuiCodeBlock language="jsx">{example3SampleCode}</EuiCodeBlock>
|
|
<EuiSpacer size={'s'} />
|
|
|
|
<EuiCallOut
|
|
title="Check the result in the data view field editor!"
|
|
color="primary"
|
|
iconType="indexManagementApp"
|
|
>
|
|
<p>
|
|
Currency formatter and its custom editor are integrated with data views. It can be applied
|
|
to any <EuiCode>numeric</EuiCode> field of any data view.{' '}
|
|
<EuiLink onClick={() => props.deps.openDateViewNumberFieldEditor()}>
|
|
Open date view field editor to give it a try.
|
|
</EuiLink>
|
|
</p>
|
|
</EuiCallOut>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export const App: React.FC<{ deps: Deps }> = (props) => {
|
|
return (
|
|
<EuiProvider highContrastMode={false}>
|
|
<EuiPageTemplate offset={0}>
|
|
<EuiPageTemplate.Header pageTitle="Field formats examples" />
|
|
<EuiPageTemplate.Section grow={false}>
|
|
<EuiTitle size="m">
|
|
<h2>Using an existing field format</h2>
|
|
</EuiTitle>
|
|
<EuiSpacer />
|
|
<UsingAnExistingFieldFormatExample deps={props.deps} />
|
|
</EuiPageTemplate.Section>
|
|
<EuiPageTemplate.Section grow={false}>
|
|
<EuiTitle size="m">
|
|
<h2>Creating a custom field format</h2>
|
|
</EuiTitle>
|
|
<EuiSpacer />
|
|
<CreatingCustomFieldFormat deps={props.deps} />
|
|
</EuiPageTemplate.Section>
|
|
<EuiPageTemplate.Section grow={false}>
|
|
<EuiTitle size="m">
|
|
<h2>Creating a custom field format editor</h2>
|
|
</EuiTitle>
|
|
<EuiSpacer />
|
|
<CreatingCustomFieldFormatEditor deps={props.deps} />
|
|
</EuiPageTemplate.Section>
|
|
</EuiPageTemplate>
|
|
</EuiProvider>
|
|
);
|
|
};
|