Skip to content

Commit

Permalink
Merge branch 'main' into feat/hello-monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
tkajtoch committed May 9, 2024
2 parents b817ed2 + 808f837 commit 9e89ea2
Show file tree
Hide file tree
Showing 44 changed files with 726 additions and 66 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/eui/changelogs/upcoming/7732.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Updated `EuiSuperDatePicker`'s absolute tab UX to support setting manual timestamps via mouse click as well as enter key
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
.euiSuperDatePicker__absoluteDateFormRow {
.euiSuperDatePicker__absoluteDateForm {
padding: 0 $euiSizeS $euiSizeS;
}

/* A bit of a visual trickery to make the format "hint" become an "error" text.
NOTE: Normally reordering visually (vs DOM) isn't super great for screen reader users,
but as the help text is already read out via `aria-describedby`, and the error text
is read out immediately via `aria-live`, we can fairly safely prioritize visuals instead */
.euiFormRow__fieldWrapper {
display: flex;
flex-direction: column;
};

.euiFormControlLayout {
order: 0;
}
.euiSuperDatePicker__absoluteDateFormSubmit {
flex-shrink: 0;
}

.euiFormHelpText {
order: 1;
}
.euiSuperDatePicker__absoluteDateFormRow {
flex-grow: 1;

.euiFormErrorText {
order: 2;
// CSS hack to make the help/error text extend to the submit button.
// We can't actually put the submit button within an EuiFormRow due to
// cloneElement limitations (https://github.com/elastic/eui/issues/2493#issuecomment-561278494)
// TODO: Remove this and clean up DOM rendering once we can
.euiFormRow__text {
margin-inline-end: -1 * ($euiSizeXL + $euiSizeS); // XL - size of the button, S - size of the flex gap
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,40 @@ describe('EuiAbsoluteTab', () => {
};

describe('user input', () => {
it('displays the enter key help text when the input has been edited and the date has not yet been parsed', () => {
const { getByTestSubject, queryByText } = render(
const formatHelpText = /Allowed formats: /;

it('displays helptext and a submit button when the input has been edited and the date has not yet been parsed', () => {
const { getByTestSubject, queryByTestSubject, queryByText } = render(
<EuiAbsoluteTab {...props} />
);
const helpText = 'Press the Enter key to parse as a date.';
expect(queryByText(helpText)).not.toBeInTheDocument();
expect(queryByText(formatHelpText)).not.toBeInTheDocument();
expect(
queryByTestSubject('parseAbsoluteDateFormat')
).not.toBeInTheDocument();

const input = getByTestSubject('superDatePickerAbsoluteDateInput');
fireEvent.change(input, { target: { value: 'test' } });

expect(queryByText(helpText)).toBeInTheDocument();
expect(queryByText(formatHelpText)).toBeInTheDocument();
expect(queryByTestSubject('parseAbsoluteDateFormat')).toBeInTheDocument();
});

it('displays the formats as a hint before parse, but as an error if invalid', () => {
const { getByTestSubject, queryByText } = render(
<EuiAbsoluteTab {...props} />
);
const formatHelpText = /Allowed formats: /;
expect(queryByText(formatHelpText)).not.toBeInTheDocument();

const input = getByTestSubject('superDatePickerAbsoluteDateInput');
fireEvent.change(input, { target: { value: 'test' } });
fireEvent.change(getByTestSubject('superDatePickerAbsoluteDateInput'), {
target: { value: 'test' },
});
expect(queryByText(formatHelpText)).toHaveClass('euiFormHelpText');

fireEvent.keyDown(input, { key: 'Enter' });
fireEvent.click(getByTestSubject('parseAbsoluteDateFormat'));
expect(queryByText(formatHelpText)).toHaveClass('euiFormErrorText');
});

it('immediately parses pasted text without needing an extra enter keypress', () => {
it('immediately parses pasted text without needing an extra click or keypress', () => {
const { getByTestSubject, queryByText } = render(
<EuiAbsoluteTab {...props} />
);
Expand All @@ -84,15 +89,14 @@ describe('EuiAbsoluteTab', () => {
});
expect(input).toBeInvalid();

expect(queryByText(/Allowed formats: /)).toBeInTheDocument();
expect(queryByText(/Press the Enter key /)).not.toBeInTheDocument();
expect(queryByText(formatHelpText)).toBeInTheDocument();
});
});

describe('date parsing', () => {
const changeInput = (input: HTMLElement, value: string) => {
fireEvent.change(input, { target: { value } });
fireEvent.keyDown(input, { key: 'Enter' });
fireEvent.change(input, { target: { value: `${value}` } });
fireEvent.submit(input.closest('form')!);
};

it('parses the passed `dateFormat` prop', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
* Side Public License, v 1.
*/

import React, { Component, ChangeEvent } from 'react';
import React, { Component, ChangeEvent, FormEvent } from 'react';

import moment, { Moment, LocaleSpecifier } from 'moment'; // eslint-disable-line import/named

import dateMath from '@elastic/datemath';

import { keys } from '../../../../services';
import { EuiFormRow, EuiFieldText, EuiFormLabel } from '../../../form';
import { EuiFlexGroup } from '../../../flex';
import { EuiButtonIcon } from '../../../button';
import { EuiCode } from '../../../code';
import { EuiI18n } from '../../../i18n';

Expand Down Expand Up @@ -167,45 +168,63 @@ export class EuiAbsoluteTab extends Component<
/>
<EuiI18n
tokens={[
'euiAbsoluteTab.dateFormatHint',
'euiAbsoluteTab.dateFormatButtonLabel',
'euiAbsoluteTab.dateFormatError',
]}
defaults={[
'Press the Enter key to parse as a date.',
'Parse date',
'Allowed formats: {dateFormat}, ISO 8601, RFC 2822, or Unix timestamp.',
]}
values={{ dateFormat: <EuiCode>{dateFormat}</EuiCode> }}
>
{([dateFormatHint, dateFormatError]: string[]) => (
<EuiFormRow
className="euiSuperDatePicker__absoluteDateFormRow"
isInvalid={isTextInvalid}
error={isTextInvalid ? dateFormatError : undefined}
helpText={
hasUnparsedText
? isTextInvalid
? dateFormatHint
: [dateFormatHint, dateFormatError]
: undefined
}
{([dateFormatButtonLabel, dateFormatError]: string[]) => (
<EuiFlexGroup
component="form"
onSubmit={(e: FormEvent) => {
e.preventDefault(); // Prevents a page refresh/reload
this.parseUserDateInput(textInputValue);
}}
className="euiSuperDatePicker__absoluteDateForm"
gutterSize="s"
responsive={false}
>
<EuiFieldText
compressed
<EuiFormRow
className="euiSuperDatePicker__absoluteDateFormRow"
isInvalid={isTextInvalid}
value={textInputValue}
onChange={this.handleTextChange}
onPaste={(event) => {
this.parseUserDateInput(event.clipboardData.getData('text'));
}}
onKeyDown={(event) => {
if (event.key === keys.ENTER) {
this.parseUserDateInput(textInputValue);
}
}}
data-test-subj="superDatePickerAbsoluteDateInput"
prepend={<EuiFormLabel>{labelPrefix}</EuiFormLabel>}
/>
</EuiFormRow>
error={isTextInvalid ? dateFormatError : undefined}
helpText={
hasUnparsedText && !isTextInvalid
? dateFormatError
: undefined
}
>
<EuiFieldText
compressed
isInvalid={isTextInvalid}
value={textInputValue}
onChange={this.handleTextChange}
onPaste={(event) => {
this.parseUserDateInput(
event.clipboardData.getData('text')
);
}}
data-test-subj="superDatePickerAbsoluteDateInput"
prepend={<EuiFormLabel>{labelPrefix}</EuiFormLabel>}
/>
</EuiFormRow>
{hasUnparsedText && (
<EuiButtonIcon
type="submit"
className="euiSuperDatePicker__absoluteDateFormSubmit"
size="s"
display="base"
iconType="check"
aria-label={dateFormatButtonLabel}
title={dateFormatButtonLabel}
data-test-subj="parseAbsoluteDateFormat"
/>
)}
</EuiFlexGroup>
)}
</EuiI18n>
</>
Expand Down
37 changes: 37 additions & 0 deletions packages/eui/src/components/steps/step.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

import type { Meta, StoryObj } from '@storybook/react';

import { hideStorybookControls } from '../../../.storybook/utils';
import { STATUS } from './step_number';
import { EuiStep, EuiStepProps } from './step';

const meta: Meta<EuiStepProps> = {
title: 'Navigation/EuiSteps/EuiSteps/EuiStep',
component: EuiStep,
argTypes: {
status: { options: [undefined, ...STATUS] },
},
args: {
headingElement: 'p',
titleSize: 's',
step: 1,
},
};
hideStorybookControls(meta, ['aria-label']);

export default meta;
type Story = StoryObj<EuiStepProps>;

export const Playground: Story = {
args: {
title: 'Step 1',
children: 'lorem ipsum',
},
};
39 changes: 39 additions & 0 deletions packages/eui/src/components/steps/step_horizontal.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

import type { Meta, StoryObj } from '@storybook/react';

import {
enableFunctionToggleControls,
hideStorybookControls,
} from '../../../.storybook/utils';
import { EuiStepHorizontal, EuiStepHorizontalProps } from './step_horizontal';

const meta: Meta<EuiStepHorizontalProps> = {
title: 'Navigation/EuiSteps/EuiStepsHorizontal/EuiStepHorizontal',
component: EuiStepHorizontal,
args: {
size: 'm',
step: 1,
status: 'incomplete',
// set up for easier testing/QA
disabled: false,
},
};
hideStorybookControls(meta, ['aria-label']);
enableFunctionToggleControls(meta, ['onClick']);

export default meta;
type Story = StoryObj<EuiStepHorizontalProps>;

export const Playground: Story = {
args: {
title: 'Step 1',
children: 'lorem ipsum',
},
};
33 changes: 33 additions & 0 deletions packages/eui/src/components/steps/step_number.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

import type { Meta, StoryObj } from '@storybook/react';

import { hideStorybookControls } from '../../../.storybook/utils';
import { EuiStepNumber, EuiStepNumberProps, STATUS } from './step_number';

const meta: Meta<EuiStepNumberProps> = {
title: 'Navigation/EuiSteps/Subcomponents/EuiStepNumber',
component: EuiStepNumber,
argTypes: {
status: { options: [undefined, ...STATUS] },
},
args: {
titleSize: 's',
},
};
hideStorybookControls(meta, ['aria-label']);

export default meta;
type Story = StoryObj<EuiStepNumberProps>;

export const Playground: Story = {
args: {
number: 1,
},
};
Loading

0 comments on commit 9e89ea2

Please sign in to comment.