Skip to content

Specification for Peer-to-Peer Creation Page #390

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
23 changes: 23 additions & 0 deletions app/javascript/common/intl-polyfills/custom/displayNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// License: LGPL-3.0-or-later
import {shouldPolyfill} from '@formatjs/intl-displaynames/should-polyfill';

import getCanonicalLocales from './getCanonicalLocales';
import locale from './locale';
import type {Polyfilled} from './types';

type PolyfilledDisplayNames = Polyfilled<typeof Intl.DisplayNames>

export default async function displaynames(locales:string[]) :Promise<void> {
await locale();
await getCanonicalLocales();
if (shouldPolyfill()) {
// Load the polyfill 1st BEFORE loading data
await import('@formatjs/intl-displaynames/polyfill');
}

if ((Intl.DisplayNames as PolyfilledDisplayNames).polyfilled) {
await Promise.all(
locales.map(l => import("@formatjs/intl-displaynames/locale-data/"+ l))
);
}
}
8 changes: 8 additions & 0 deletions app/javascript/common/intl-polyfills/custom/locale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {shouldPolyfill} from '@formatjs/intl-locale/should-polyfill';

export default async function locale(): Promise<void> {
// This platform already supports Intl.Locale
if (shouldPolyfill()) {
await import('@formatjs/intl-locale/polyfill');
}
}
5 changes: 5 additions & 0 deletions app/javascript/common/intl-polyfills/displayNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// License: LGPL-3.0-or-later
import displayNames from './custom/displayNames';
import allLocales from './allLocales';
const promise = displayNames(allLocales);
export default promise;
2 changes: 2 additions & 0 deletions app/javascript/common/intl-polyfills/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const promises = Promise.all([
import('./getCanonicalLocales'),
import('./pluralRules'),
import('./numberFormat'),
import('./locale'),
import('./displayNames'),
]) as unknown as Promise<void>;

export default promises;
5 changes: 5 additions & 0 deletions app/javascript/common/intl-polyfills/locale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// License: LGPL-3.0-or-later
import locale from './custom/locale';

const promise = locale;
export default promise;
19 changes: 19 additions & 0 deletions app/javascript/components/common/LocationSelector/CountryCode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// License: LGPL-3.0-or-later
import * as React from "react";
import { useIntl } from "../../intl";
import { getLocalizedCountries } from "../../../countries";

interface CountryCodeProps {
}


function CountryCode(props:CountryCodeProps) : JSX.Element {
const intl = useIntl();
const countries = getLocalizedCountries(intl.locale);

return (

);
}

export default CountryCode;
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// License: LGPL-3.0-or-later
import React, {useCallback} from "react";
import { Field, Formik } from "formik";

import { Location } from "./types";
import { LocalizedCountry, Subregion } from "../../../countries";
import type {Schema as YupSchema} from 'yup';
import useYup from '../../../hooks/'
import { noop } from "lodash";

type OnUpdateArgs = {location:Location, isValid:boolean}
type ValidationSchemaArgs = {validCountries?:LocalizedCountry[], validStates?:Subregion[]}

interface LocationSelectorProps {
enableReinitialize:boolean;
initialLocation:Location;
onUpdate:(args:OnUpdateArgs) => void;
validationSchema:(args:ValidationSchemaArgs) => YupSchema<{city:any, country:any, stateCode:any}, unknown>;
}



function LocationSelector(props:LocationSelectorProps) : JSX.Element {
const inputValidationSchema = props.validationSchema;
const yup = useYup();

const setLatest

const validationSchema = useCallback(() => {
if (inputValidationSchema === noop) {
return () => yup.
}
else {
return inputValidationSchema;
}
}, [inputValidationSchema])


return <Formik validationSchema>

</Formik>;
}

LocationSelector.defaultProps = {
enableReinitalize: false,
initialLocation: {country: "US", stateCode: "", city: ""},
validationSchema: noop,
}

export default LocationSelector;
18 changes: 18 additions & 0 deletions app/javascript/components/common/LocationSelector/StateCode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

// License: LGPL-3.0-or-later
import * as React, {Suspense} from "react";


interface StateCodeProps {
}


function StateCode(props:StateCodeProps) : JSX.Element {

return <Suspense fallback={/* you */}>

</Suspense>;

}

export default StateCode
17 changes: 17 additions & 0 deletions app/javascript/components/common/LocationSelector/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

// License: LGPL-3.0-or-later
import * as React from "react";


interface ILocationSelectorProps {
}


function LocationSelector(props:ILocationSelectorProps) : JSX.Element {
return (
<React.Fragment>
</React.Fragment>
);
}

export default LocationSelector;
6 changes: 6 additions & 0 deletions app/javascript/components/common/LocationSelector/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

export interface Location {
country?:string;
stateCode?:string;
city?:string
}
Loading