Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(input-time-zone): add input-time-zone component #6947

Merged
merged 50 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
fe0bc8b
feat(input-time-zone): add input-time-zone component
jcfranco Apr 15, 2023
502e4ad
update for consistency
jcfranco May 10, 2023
e6bd51b
add placeholder readme
jcfranco May 10, 2023
9dd6ee8
fix event name
jcfranco May 10, 2023
a2a60d2
fix story tags
jcfranco May 10, 2023
1029ad8
Merge branch 'master' into jcfranco/6590-add-input-time-zone-component
jcfranco May 10, 2023
ffb049b
update combobox tests
jcfranco May 10, 2023
284b4c2
fix test
jcfranco May 10, 2023
f2308a5
add open, overlayPositioning props and doc
jcfranco May 10, 2023
e411271
drop unnecessary `setFocus` call in combobox
jcfranco May 10, 2023
6a9f373
update doc
jcfranco May 10, 2023
64b74bf
Merge branch 'master' into jcfranco/6590-add-input-time-zone-component
jcfranco May 11, 2023
428b2ec
display local time offset by timezones in fallback mode
jcfranco May 12, 2023
e5e8996
update tests
jcfranco May 12, 2023
354a1f2
tidy up tests
jcfranco May 12, 2023
69b97c4
update value doc
jcfranco May 12, 2023
f2a3645
implement loadable
jcfranco May 13, 2023
6ee7cf5
tidy up
jcfranco May 13, 2023
7a88782
enable delegatesFocus
jcfranco May 16, 2023
de72851
merge main
jcfranco Jul 22, 2023
7d1b944
update messages for future advanced mode
jcfranco Jul 27, 2023
20cfe98
update setFocus
jcfranco Jul 27, 2023
16126ea
update component to use basic time zone offset list by default
jcfranco Jul 27, 2023
d4504c2
merge main
jcfranco Jul 27, 2023
349b475
drop local time preview
jcfranco Jul 28, 2023
79ec8f7
update value type for consistency
jcfranco Jul 28, 2023
5529839
Merge branch 'main' into jcfranco/6590-add-input-time-zone-component
jcfranco Jul 28, 2023
54515e7
refactor(combobox): fix method name casing
jcfranco Jul 28, 2023
98bdff0
update test helpers to new structure
jcfranco Jul 28, 2023
81e0c09
handle updated value type properly
jcfranco Jul 28, 2023
f8d0aed
drop broken workaround
jcfranco Jul 28, 2023
b14d8bd
drop README and let action generate it
jcfranco Jul 28, 2023
71e6586
restore optional argument for disabled test helper
jcfranco Jul 28, 2023
3143627
add missing demo page
jcfranco Jul 28, 2023
f6c1680
Merge branch 'main' into jcfranco/6590-add-input-time-zone-component
jcfranco Jul 28, 2023
5c53b2d
revert unintentional changes from merge conflict
jcfranco Jul 28, 2023
8971850
replace all message bundles with updated messages
jcfranco Jul 28, 2023
e7870d0
fix updated type
jcfranco Jul 28, 2023
5264674
add readme to fix messages metadata script
jcfranco Jul 28, 2023
65a835f
disable value clearing affordance
jcfranco Jul 28, 2023
70fa991
drop parens from label as we only display the offset by itself
jcfranco Jul 28, 2023
0c608ac
update tests
jcfranco Jul 28, 2023
85a2115
doc updates
jcfranco Jul 28, 2023
194eb6d
update stories
jcfranco Jul 28, 2023
6c03f21
pass lang into combobox
jcfranco Jul 28, 2023
2bc16b3
wire up form association
jcfranco Jul 28, 2023
437e602
update value type
jcfranco Jul 28, 2023
af20e65
Merge branch 'main' into jcfranco/6590-add-input-time-zone-component
jcfranco Jul 28, 2023
9b72dd5
fix initial offset matching
jcfranco Jul 28, 2023
4a20965
wire up interactive, formAssociated and hidden capabilities
jcfranco Jul 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { newE2EPage } from "@stencil/core/testing";
import {
accessible,
defaults,
disabled,
focusable,
formAssociated,
hidden,
labelable,
reflects,
renders,
t9n,
} from "../../tests/commonTests";
import { html } from "../../../support/formatting";
import { toGMTLabel } from "./utils";

describe("calcite-input-time-zone", () => {
describe("accessible", () => {
accessible("calcite-input-time-zone");
});

describe("focusable", () => {
focusable("calcite-input-time-zone");
});

describe("formAssociated", () => {
formAssociated("calcite-input-time-zone", { testValue: "-360", clearable: false });
});

describe("hidden", () => {
hidden("calcite-input-time-zone");
});

describe("renders", () => {
renders("calcite-input-time-zone", { display: "block" });
});

describe("labelable", () => {
labelable("calcite-input-time-zone");
});

describe("reflects", () => {
reflects("calcite-input-time-zone", [
{ propertyName: "disabled", value: true },
{ propertyName: "open", value: true },
{ propertyName: "scale", value: "m" },
{ propertyName: "overlayPositioning", value: "absolute" },
]);
});

describe("defaults", () => {
defaults("calcite-input-time-zone", [
{ propertyName: "disabled", defaultValue: false },
{ propertyName: "messageOverrides", defaultValue: undefined },
{ propertyName: "open", defaultValue: false },
{ propertyName: "overlayPositioning", defaultValue: "absolute" },
{ propertyName: "scale", defaultValue: "m" },
]);
});

describe("disabled", () => {
disabled("calcite-input-time-zone", { shadowAriaAttributeTargetSelector: "calcite-combobox" });
});

describe("t9n", () => {
t9n("calcite-input-time-zone");
});

describe("selects user's matching timezone offset by default", () => {
const timeZoneNamesAndOffsets = [
{ name: "America/Los_Angeles", offset: -420 },
{ name: "Europe/London", offset: 60 },
];

timeZoneNamesAndOffsets.forEach(({ name, offset }) => {
it(`selects default timezone for "${name}"`, async () => {
const page = await newE2EPage();
await page.emulateTimezone(name);
await page.setContent(html`<calcite-input-time-zone></calcite-input-time-zone>`);
await page.waitForTimeout(1000);

const input = await page.find("calcite-input-time-zone");

expect(await input.getProperty("value")).toBe(`${offset}`);

const timeZoneItem = await page.find("calcite-input-time-zone >>> calcite-combobox-item[selected]");

expect(await timeZoneItem.getProperty("textLabel")).toMatch(toGMTLabel(offset / 60));
});
});
});

it("allows users to preselect a timezone offset", async () => {
const page = await newE2EPage();
await page.emulateTimezone("America/Los_Angeles");
await page.setContent(html`<calcite-input-time-zone value="-360"></calcite-input-time-zone>`);

const input = await page.find("calcite-input-time-zone");

expect(await input.getProperty("value")).toBe("-360");

const timeZoneItem = await page.find("calcite-input-time-zone >>> calcite-combobox-item[selected]");

expect(await timeZoneItem.getProperty("textLabel")).toMatch("GMT-6");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:host {
display: block;
}

@include base-component();
@include disabled();
@include hidden-form-input();
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { select } from "@storybook/addon-knobs";
import { boolean, storyFilters } from "../../../.storybook/helpers";
import { modesDarkDefault } from "../../../.storybook/utils";
import { html } from "../../../support/formatting";
import readme from "./readme.md";

export default {
title: "Components/Controls/InputTimeZone",
parameters: {
notes: readme,
options: {
timezone: "America/Los_Angeles",
},
},
...storyFilters(),
};

export const simple = (): string => html`
<calcite-input-time-zone
${boolean("disabled", false)}
scale="${select("scale", ["s", "m", "l"], "m")}"
></calcite-input-time-zone>
`;

export const initialOffsetSelected_TestOnly = (): string => html`
<calcite-input-time-zone value="-360"></calcite-input-time-zone>
`;

export const displayingTimeZoneOffsets_TestOnly = (): string => html`
<calcite-input-time-zone open></calcite-input-time-zone>
`;

export const disabled_TestOnly = (): string => html`<calcite-input-time-zone disabled></calcite-input-time-zone>`;

export const darkModeRTL_TestOnly = (): string => html`
<calcite-input-time-zone dir="rtl" class="calcite-mode-dark"></calcite-input-time-zone>
`;
darkModeRTL_TestOnly.parameters = { modes: modesDarkDefault };
Loading