Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ packages/react-components/react-calendar-preview/library @microsoft/cxe-prg
packages/react-components/react-calendar-preview/stories @microsoft/cxe-prg
Comment thread
dmytrokirpa marked this conversation as resolved.
packages/react-components/react-timepicker-preview/library @microsoft/cxe-prg
packages/react-components/react-timepicker-preview/stories @microsoft/cxe-prg
packages/react-components/react-datepicker-preview/library @microsoft/cxe-prg
packages/react-components/react-datepicker-preview/stories @microsoft/cxe-prg
packages/react-components/react-range-slider-preview/library @microsoft/cxe-prg
packages/react-components/react-range-slider-preview/stories @microsoft/cxe-prg
# <%= NX-CODEOWNER-PLACEHOLDER %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../../../.babelrc-v9.json",
"plugins": ["annotate-pure-calls", "@babel/transform-react-pure-annotations"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"exclude": [
"/testing",
"/**/*.cy.ts",
"/**/*.cy.tsx",
"/**/*.spec.ts",
"/**/*.spec.tsx",
"/**/*.test.ts",
"/**/*.test.tsx"
],
"jsc": {
"baseUrl": ".",
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": false,
"dynamicImport": false
},
"externalHelpers": true,
"transform": {
"react": {
"runtime": "classic",
"useSpread": true
}
},
"target": "es2019"
},
"minify": false,
"sourceMaps": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@fluentui/react-datepicker-preview

Copyright (c) Microsoft Corporation

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @fluentui/react-datepicker-preview

**React Datepicker components for [Fluent UI React](https://react.fluentui.dev/)**

These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "@fluentui/scripts-api-extractor/api-extractor.common.v-next.json",
"mainEntryPointFilePath": "<projectRoot>/../../../../../../dist/out-tsc/types/packages/react-components/<unscopedPackageName>/library/src/index.d.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/** Jest test setup file. */

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

const fluentPlugin = require('@fluentui/eslint-plugin');

module.exports = [...fluentPlugin.configs['flat/react']];
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## API Report File for "@fluentui/react-datepicker-preview"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import type { JSXElement } from '@fluentui/react-utilities';
import type * as React_2 from 'react';
import type { Slot } from '@fluentui/react-utilities';
import type { SlotClassNames } from '@fluentui/react-utilities';

// @public
export const DatePicker: ForwardRefComponent<DatePickerProps>;

// @public (undocumented)
export const datePickerClassNames: SlotClassNames<DatePickerSlots>;

// @public
export type DatePickerProps = ComponentProps<DatePickerSlots> & {};

// @public
export type DatePickerState = ComponentState<DatePickerSlots>;

// @public
export const renderDatePicker_unstable: (state: DatePickerState) => JSXElement;

// @public
export const useDatePicker_unstable: (props: DatePickerProps, ref: React_2.Ref<HTMLDivElement>) => DatePickerState;

// @public
export const useDatePickerStyles_unstable: (state: DatePickerState) => DatePickerState;

// (No @packageDocumentation comment for this package)

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @ts-check
/* eslint-disable */

const { readFileSync } = require('node:fs');
const { join } = require('node:path');

// Reading the SWC compilation config and remove the "exclude"
// for the test files to be compiled by SWC
const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8'));

// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves.
// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude"
if (swcJestConfig.swcrc === undefined) {
swcJestConfig.swcrc = false;
}

// Uncomment if using global setup/teardown files being transformed via swc
// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries
// jest needs EsModule Interop to find the default exported setup/teardown functions
// swcJestConfig.module.noInterop = false;

/**
* @type {import('@jest/types').Config.InitialOptions}
*/
module.exports = {
displayName: 'react-datepicker-preview',
preset: '../../../../jest.preset.js',
transform: {
'^.+\\.tsx?$': ['@swc/jest', swcJestConfig],
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.cjs'],
snapshotSerializers: ['@griffel/jest-serializer'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@fluentui/react-datepicker-preview",
"version": "0.0.0",
"private": true,
"description": "New fluentui react package",
"type": "module",
"main": "lib-commonjs/index.cjs",
"module": "lib/index.js",
"typings": "./dist/index.d.ts",
"sideEffects": false,
"files": [
"*.md",
"dist/*.d.ts",
"dist/*.d.cts",
"lib",
"lib-commonjs"
],
"repository": {
"type": "git",
"url": "https://github.com/microsoft/fluentui"
},
"license": "MIT",
"dependencies": {
"@fluentui/react-jsx-runtime": "^9.4.6",
"@fluentui/react-shared-contexts": "^9.26.4",
"@fluentui/react-theme": "^9.2.2",
"@fluentui/react-utilities": "^9.26.7",
"@griffel/react": "^1.5.32",
"@swc/helpers": "^0.5.1"
},
"peerDependencies": {
"@types/react": ">=16.14.0 <20.0.0",
"react": ">=16.14.0 <20.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./lib/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./lib-commonjs/index.cjs"
}
},
"./package.json": "./package.json"
},
"beachball": {
"disallowedChangeTypes": [
"major",
"prerelease"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "react-datepicker-preview",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "packages/react-components/react-datepicker-preview/library/src",
"tags": ["platform:web", "vNext"],
"implicitDependencies": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export {
datePickerClassNames,
DatePicker,
renderDatePicker_unstable,
useDatePicker_unstable,
useDatePickerStyles_unstable,
} from './components/DatePicker/index';
export type { DatePickerProps, DatePickerState } from './components/DatePicker/index';
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import { render } from '@testing-library/react';
import { isConformant } from '../../testing/isConformant';
import { DatePicker } from './DatePicker';

describe('DatePicker', () => {
isConformant({
Component: DatePicker,
displayName: 'DatePicker',
});

// TODO add more tests here, and create visual regression tests in /apps/vr-tests

it('renders a default state', () => {
const result = render(<DatePicker>Default DatePicker</DatePicker>);
expect(result.container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use client';
import * as React from 'react';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { useDatePicker_unstable } from './useDatePicker';
import { renderDatePicker_unstable } from './renderDatePicker';
import { useDatePickerStyles_unstable } from './useDatePickerStyles.styles';
import type { DatePickerProps } from './DatePicker.types';

/**
* DatePicker component - TODO: add more docs
*/
export const DatePicker: ForwardRefComponent<DatePickerProps> = React.forwardRef((props, ref) => {
const state = useDatePicker_unstable(props, ref);

useDatePickerStyles_unstable(state);

/**
* @see https://github.com/microsoft/fluentui/blob/master/docs/react-v9/contributing/rfcs/react-components/convergence/custom-styling.md
*
* TODO: 💡 once package will become stable (PR which will be part of promoting PREVIEW package to STABLE),
* - uncomment this line
* - update types {@link file://./../../../../../../../packages/react-components/react-shared-contexts/library/src/CustomStyleHooksContext/CustomStyleHooksContext.ts#CustomStyleHooksContextValue}
* - verify that custom global style override works for your component
*/
// useCustomStyleHook_unstable('useDatePickerStyles_unstable')(state);

return renderDatePicker_unstable(state);
});

DatePicker.displayName = 'DatePicker';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';

export type DatePickerSlots = {
root: Slot<'div'>;
};

/**
* DatePicker Props
*/
export type DatePickerProps = ComponentProps<DatePickerSlots> & {};

/**
* State used in rendering DatePicker
*/
export type DatePickerState = ComponentState<DatePickerSlots>;
// TODO: Remove semicolon from previous line, uncomment next line, and provide union of props to pick from DatePickerProps.
// & Required<Pick<DatePickerProps, 'propName'>>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`DatePicker renders a default state 1`] = `
<div>
<div
class="fui-DatePicker"
>
Default DatePicker
</div>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export { DatePicker } from './DatePicker';
export type { DatePickerProps, DatePickerState } from './DatePicker.types';
export { renderDatePicker_unstable } from './renderDatePicker';
export { useDatePicker_unstable } from './useDatePicker';
export { datePickerClassNames, useDatePickerStyles_unstable } from './useDatePickerStyles.styles';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @jsxRuntime automatic */
/** @jsxImportSource @fluentui/react-jsx-runtime */

import { assertSlots } from '@fluentui/react-utilities';
import type { JSXElement } from '@fluentui/react-utilities';
import type { DatePickerState, DatePickerSlots } from './DatePicker.types';

/**
* Render the final JSX of DatePicker
*/
export const renderDatePicker_unstable = (state: DatePickerState): JSXElement => {
assertSlots<DatePickerSlots>(state);

// TODO Add additional slots in the appropriate place
return <state.root />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type * as React from 'react';
import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
import type { DatePickerProps, DatePickerState } from './DatePicker.types';

/**
* Create the state required to render DatePicker.
*
* The returned state can be modified with hooks such as useDatePickerStyles_unstable,
* before being passed to renderDatePicker_unstable.
*
* @param props - props from this instance of DatePicker
* @param ref - reference to root HTMLDivElement of DatePicker
*/
export const useDatePicker_unstable = (props: DatePickerProps, ref: React.Ref<HTMLDivElement>): DatePickerState => {
return {
// TODO add appropriate props/defaults
components: {
// TODO add each slot's element type or component
root: 'div',
},
// TODO add appropriate slots, for example:
// mySlot: resolveShorthand(props.mySlot),
root: slot.always(
getIntrinsicElementProps('div', {
ref,
...props,
}),
{ elementType: 'div' },
),
};
};
Loading
Loading