@servicetitan/culture
Advanced tools
Comparing version 25.7.0 to 25.8.0
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { Provider, symbolToken } from '@servicetitan/react-ioc'; | ||
import { CultureStore, CultureApi } from '@servicetitan/application-data/culture'; | ||
import { Provider, symbolToken, useOptionalDependencies } from '@servicetitan/react-ioc'; | ||
export const CULTURE_TOKEN = symbolToken('CULTURE_TOKEN'); | ||
export const CultureProvider = ({ value, children }) => (_jsx(Provider, Object.assign({ singletons: [{ provide: CULTURE_TOKEN, useValue: value }] }, { children: children }))); | ||
export const CultureProvider = ({ value, children }) => { | ||
const [store] = useOptionalDependencies(CultureStore); | ||
const culture = value !== null && value !== void 0 ? value : store === null || store === void 0 ? void 0 : store.culture; | ||
return (_jsx(Provider, Object.assign({ singletons: culture ? [{ provide: CULTURE_TOKEN, useValue: culture }] : undefined }, { children: children }))); | ||
}; | ||
export const withCultureSingletons = (singletons) => [...(singletons !== null && singletons !== void 0 ? singletons : []), CultureApi, CultureStore]; | ||
export const provideWithCulture = ((stores, fallback) => (Component) => props => (_jsx(Provider, Object.assign({ singletons: withCultureSingletons(stores === null || stores === void 0 ? void 0 : stores.singletons), instances: stores === null || stores === void 0 ? void 0 : stores.instances, fallback: fallback }, { children: _jsx(CultureProvider, { children: _jsx(Component, Object.assign({}, props)) }) })))); | ||
//# sourceMappingURL=index.js.map |
@@ -1,32 +0,16 @@ | ||
import { FC } from 'react'; | ||
export interface Culture { | ||
Name: string; | ||
DateTimeFormat?: { | ||
MomentShortDatePattern?: string; | ||
MomentShortYearDatePattern?: string; | ||
MomentShortYearDateTimePattern?: string; | ||
}; | ||
NumberFormat?: { | ||
NumberDecimalSeparator?: string; | ||
NumberGroupSeparator?: string; | ||
}; | ||
PhoneFormat?: { | ||
PhoneFormatInfo?: { | ||
Pattern: RegExp; | ||
Format: string; | ||
}; | ||
PhoneWithExtNumberFormatInfo?: { | ||
Pattern: RegExp; | ||
Format: string; | ||
}; | ||
PhoneMask?: string; | ||
SimplePhoneMask?: string; | ||
}; | ||
} | ||
import { FC, ReactNode } from 'react'; | ||
import { Culture } from '@servicetitan/application-data/culture'; | ||
import { provide } from '@servicetitan/react-ioc'; | ||
export declare const CULTURE_TOKEN: import("@servicetitan/react-ioc").SymbolToken<Culture>; | ||
interface CultureProviderProps { | ||
value: Culture; | ||
children?: ReactNode; | ||
value?: Culture; | ||
} | ||
export { Culture }; | ||
export declare const CultureProvider: FC<CultureProviderProps>; | ||
export {}; | ||
export declare const withCultureSingletons: (singletons?: Parameters<typeof provide>[0]['singletons']) => Parameters<typeof provide>[0]['singletons']; | ||
export declare const provideWithCulture: (stores: { | ||
singletons?: import("@servicetitan/react-ioc/dist/provider").ProviderConfigEntry<any>[] | undefined; | ||
instances?: import("@servicetitan/react-ioc/dist/provider").ProviderConfigEntry<any>[] | undefined; | ||
}, fallback?: JSX.Element | undefined) => <T extends import("react").StatelessComponent<any> | import("react").ClassicComponentClass<any> | import("react").ComponentClass<any, any>>(target: T) => T & import("@servicetitan/react-ioc/dist/provide").WrappedComponent<T>; | ||
//# sourceMappingURL=index.d.ts.map |
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { Provider, symbolToken } from '@servicetitan/react-ioc'; | ||
import { CultureStore, CultureApi } from '@servicetitan/application-data/culture'; | ||
import { Provider, symbolToken, useOptionalDependencies } from '@servicetitan/react-ioc'; | ||
export const CULTURE_TOKEN = symbolToken('CULTURE_TOKEN'); | ||
export const CultureProvider = ({ value, children }) => (_jsx(Provider, Object.assign({ singletons: [{ provide: CULTURE_TOKEN, useValue: value }] }, { children: children }))); | ||
export const CultureProvider = ({ value, children }) => { | ||
const [store] = useOptionalDependencies(CultureStore); | ||
const culture = value !== null && value !== void 0 ? value : store === null || store === void 0 ? void 0 : store.culture; | ||
return (_jsx(Provider, Object.assign({ singletons: culture ? [{ provide: CULTURE_TOKEN, useValue: culture }] : undefined }, { children: children }))); | ||
}; | ||
export const withCultureSingletons = (singletons) => [...(singletons !== null && singletons !== void 0 ? singletons : []), CultureApi, CultureStore]; | ||
export const provideWithCulture = ((stores, fallback) => (Component) => props => (_jsx(Provider, Object.assign({ singletons: withCultureSingletons(stores === null || stores === void 0 ? void 0 : stores.singletons), instances: stores === null || stores === void 0 ? void 0 : stores.instances, fallback: fallback }, { children: _jsx(CultureProvider, { children: _jsx(Component, Object.assign({}, props)) }) })))); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@servicetitan/culture", | ||
"version": "25.7.0", | ||
"version": "25.8.0", | ||
"description": "", | ||
@@ -18,2 +18,5 @@ "homepage": "https://docs.st.dev/docs/frontend/culture", | ||
], | ||
"dependencies": { | ||
"@servicetitan/application-data": ">1.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -34,3 +37,3 @@ "@servicetitan/react-ioc": "^21.6.0", | ||
}, | ||
"gitHead": "3e0aaed77a4a1cbdc7675d2f47bcc8f144cd16c3" | ||
"gitHead": "d29437d247da3428ed25fd9fc4004c1f3a94cf1e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7820
74
3