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

Add DateTimePicker #2391

Merged
merged 18 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a8023fc
feat(odyssey-react-mui): adding DateTimePicker
bryancunningham-okta Oct 7, 2024
50ce19a
chore(odyssey-react-mui): abstracting more logic to hook
bryancunningham-okta Oct 15, 2024
cddcef5
chore(odyssey-react-mui): uodate story label
bryancunningham-okta Oct 15, 2024
bb3a698
chore(odyssey-react-mui): fix failing test
bryancunningham-okta Oct 15, 2024
b3bf21b
refactor(odyssey-react-mui): move inputchange to hook
bryancunningham-okta Oct 15, 2024
179d9ea
refactor(odyssey-react-mui): use our icons for tabs
bryancunningham-okta Oct 15, 2024
0bbca8c
feat(odyssey-react-mui): calendar styling updates
bryancunningham-okta Oct 15, 2024
e24cafc
refactor(odyssey-react-mui): adding tests
bryancunningham-okta Oct 22, 2024
1e30b15
feat(odyssey-react-mui): update padding
bryancunningham-okta Nov 12, 2024
a1a8c44
feat(odyssey-react-mui): add some more basic tests
bryancunningham-okta Nov 13, 2024
1e5ba1a
fix(odyssey-react-mui): fix broken Button imports
bryancunningham-okta Dec 2, 2024
c46280b
fix(odyssey-react-mui): remove commented code
bryancunningham-okta Dec 2, 2024
43e7851
fix(odyssey-react-mui): remove commented code and fix clock style
bryancunningham-okta Dec 2, 2024
a32e9ba
fix(odyssey-react-mui): remove forced use of mobile picker left in error
bryancunningham-okta Dec 3, 2024
ff66ef9
chore(odyssey-react-mui): test commit
bryancunningham-okta Dec 4, 2024
2c07f7b
fix(odyssey-react-mui): fix Ignored unknown option --loglevel=warn error
bryancunningham-okta Dec 4, 2024
f4fce0a
fix(odyssey-react-mui): fix lint warnings
bryancunningham-okta Dec 4, 2024
72288b1
fix(odyssey-react-mui): run prettier
bryancunningham-okta Dec 4, 2024
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"lerna-version": "lerna version --no-git-tag-version --include-merged-tags --conventional-commits --no-push --force-publish",
"lint": "yarn eslint && yarn stylelint && yarn prettier-check",
"postinstall": "yarn build && [ -z ${CI:-} ] && husky install || exit 0",
"prettier-check": "prettier --ignore-unknown --loglevel warn --check .",
"prettier-write": "prettier --ignore-unknown --loglevel warn --write .",
"prettier-check": "prettier --ignore-unknown --log-level warn --check .",
"prettier-write": "prettier --ignore-unknown --log-level warn --write .",
"start:mui": "yarn workspace @okta/odyssey-react-mui dev",
"start:storybook": "yarn workspace @okta/odyssey-storybook start",
"start": "yarn install && yarn build && yarn concurrently npm:dev:source npm:start:mui npm:start:storybook",
Expand Down
2 changes: 1 addition & 1 deletion packages/odyssey-lint-staged/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

module.exports = {
"*": "prettier --ignore-unknown --loglevel warn --write",
"*": "prettier --ignore-unknown --log-level warn --write",
"*.scss": "stylelint",
"*.{js,jsx,ts,tsx}": "eslint",
};
19 changes: 13 additions & 6 deletions packages/odyssey-react-mui/src/labs/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,20 +427,27 @@ const DataTable = <TData extends MRT_RowData>({
const rowVirtualizerInstanceRef =
useRef<MRT_RowVirtualizer<HTMLDivElement, HTMLTableRowElement>>(null);

const setHoveredRow = (table: TableType<TData>, id: TData["id"]) => {
const setHoveredRow = useCallback<
(table: TableType<TData>, id: TData["id"]) => void
>((table, id) => {
if (id) {
const nextRow = table.getRow(id) as MRT_Row<TData>;

if (nextRow) {
table.setHoveredRow(nextRow);
}
}
};
}, []);

const resetDraggingAndHoveredRow = (table: TableType<TData>) => {
setDraggingRow(null);
table.setHoveredRow(null);
};
const resetDraggingAndHoveredRow = useCallback<
(table: TableType<TData>) => void
>(
(table) => {
setDraggingRow(null);
table.setHoveredRow(null);
},
[setDraggingRow],
);

type HandleDragHandleKeyDownArgs = {
table: TableType<TData>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import {
import { DateTime } from "luxon";
import { useTranslation } from "react-i18next";

import { Field, RenderFieldComponentProps } from "../Field";
import { TextFieldProps } from "../TextField";
import { Field, RenderFieldComponentProps } from "../../Field";
import { TextFieldProps } from "../../TextField";

export type DateFieldProps = {
onChange?: (value: string) => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*!
* Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and limitations under the License.
*/

import { memo } from "react";
import { useTranslation } from "react-i18next";
import { PickersActionBarProps } from "@mui/x-date-pickers";
import styled from "@emotion/styled";

import { Button } from "../../Buttons";
import {
useOdysseyDesignTokens,
DesignTokens,
} from "../../OdysseyDesignTokensContext";

const ActionContainer = styled.div<{ odysseyDesignTokens: DesignTokens }>(
({ odysseyDesignTokens }) => ({
display: "flex",
justifyContent: "flex-end",
paddingInline: odysseyDesignTokens.Spacing4,
paddingBlockEnd: odysseyDesignTokens.Spacing4,
}),
);

const DateFieldActionBar = ({
actions,
onAccept,
onCancel,
}: PickersActionBarProps) => {
const { t } = useTranslation();
const odysseyDesignTokens = useOdysseyDesignTokens();

// actions will be [] or ["accept", "cancel"]
if (actions && actions.length > 0) {
return (
<ActionContainer odysseyDesignTokens={odysseyDesignTokens}>
<Button
label={t("picker.labels.action.cancel")}
onClick={onCancel}
variant="floating"
/>
<Button
label={t("picker.labels.action.apply")}
onClick={onAccept}
variant="primary"
/>
</ActionContainer>
);
}

return null;
};

const MemoizedDateFieldActionBar = memo(DateFieldActionBar);
MemoizedDateFieldActionBar.displayName = "DateFieldActionBar";

export { MemoizedDateFieldActionBar as DateFieldActionBar };
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*!
* Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and limitations under the License.
*/

import { memo, PropsWithChildren } from "react";
import { LocalizationProvider } from "@mui/x-date-pickers";
import { AdapterLuxon } from "@mui/x-date-pickers/AdapterLuxon";

import { DateFieldsTranslations } from "./useDateFieldsTranslations";

type DateFieldLocalizationProviderProps = {
localeText: DateFieldsTranslations;
defaultedLanguageCode: string;
};

const DateFieldLocalizationProvider = ({
children,
defaultedLanguageCode,
localeText,
}: PropsWithChildren<DateFieldLocalizationProviderProps>) => {
return (
<LocalizationProvider
dateAdapter={AdapterLuxon}
adapterLocale={defaultedLanguageCode}
localeText={localeText}
>
{children}
</LocalizationProvider>
);
};

const MemoizedDateFieldLocalizationProvider = memo(
DateFieldLocalizationProvider,
);
MemoizedDateFieldLocalizationProvider.displayName =
"DateFieldLocalizationProvider";

export { MemoizedDateFieldLocalizationProvider as DateFieldLocalizationProvider };
Loading