@servicetitan/culture 25.7.0 → 25.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +11 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
- package/src/index.tsx +37 -32
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
DateTimeFormat?: {
|
|
5
|
-
MomentShortDatePattern?: string;
|
|
6
|
-
MomentShortYearDatePattern?: string;
|
|
7
|
-
MomentShortYearDateTimePattern?: string;
|
|
8
|
-
};
|
|
9
|
-
NumberFormat?: {
|
|
10
|
-
NumberDecimalSeparator?: string;
|
|
11
|
-
NumberGroupSeparator?: string;
|
|
12
|
-
};
|
|
13
|
-
PhoneFormat?: {
|
|
14
|
-
PhoneFormatInfo?: {
|
|
15
|
-
Pattern: RegExp;
|
|
16
|
-
Format: string;
|
|
17
|
-
};
|
|
18
|
-
PhoneWithExtNumberFormatInfo?: {
|
|
19
|
-
Pattern: RegExp;
|
|
20
|
-
Format: string;
|
|
21
|
-
};
|
|
22
|
-
PhoneMask?: string;
|
|
23
|
-
SimplePhoneMask?: string;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { Culture } from '@servicetitan/application-data/culture';
|
|
3
|
+
import { provide } from '@servicetitan/react-ioc';
|
|
26
4
|
export declare const CULTURE_TOKEN: import("@servicetitan/react-ioc").SymbolToken<Culture>;
|
|
27
5
|
interface CultureProviderProps {
|
|
28
|
-
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
value?: Culture;
|
|
29
8
|
}
|
|
9
|
+
export { Culture };
|
|
30
10
|
export declare const CultureProvider: FC<CultureProviderProps>;
|
|
31
|
-
export
|
|
11
|
+
export declare const withCultureSingletons: (singletons?: Parameters<typeof provide>[0]['singletons']) => Parameters<typeof provide>[0]['singletons'];
|
|
12
|
+
export declare const provideWithCulture: (stores: {
|
|
13
|
+
singletons?: import("@servicetitan/react-ioc/dist/provider").ProviderConfigEntry<any>[] | undefined;
|
|
14
|
+
instances?: import("@servicetitan/react-ioc/dist/provider").ProviderConfigEntry<any>[] | undefined;
|
|
15
|
+
}, 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>;
|
|
32
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,OAAO,EAA4B,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAY,OAAO,EAAwC,MAAM,yBAAyB,CAAC;AAElG,eAAO,MAAM,aAAa,wDAAwC,CAAC;AAEnE,UAAU,oBAAoB;IAC1B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAWpD,CAAC;AAEF,eAAO,MAAM,qBAAqB,gBACjB,WAAW,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KACzD,WAAW,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAsD,CAAC;AAEpG,eAAO,MAAM,kBAAkB;;;0QAWP,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { CultureStore, CultureApi } from '@servicetitan/application-data/culture';
|
|
3
|
+
import { Provider, symbolToken, useOptionalDependencies } from '@servicetitan/react-ioc';
|
|
3
4
|
export const CULTURE_TOKEN = symbolToken('CULTURE_TOKEN');
|
|
4
|
-
export const CultureProvider = ({ value, children }) =>
|
|
5
|
+
export const CultureProvider = ({ value, children }) => {
|
|
6
|
+
const [store] = useOptionalDependencies(CultureStore);
|
|
7
|
+
const culture = value !== null && value !== void 0 ? value : store === null || store === void 0 ? void 0 : store.culture;
|
|
8
|
+
return (_jsx(Provider, Object.assign({ singletons: culture ? [{ provide: CULTURE_TOKEN, useValue: culture }] : undefined }, { children: children })));
|
|
9
|
+
};
|
|
10
|
+
export const withCultureSingletons = (singletons) => [...(singletons !== null && singletons !== void 0 ? singletons : []), CultureApi, CultureStore];
|
|
11
|
+
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)) }) }))));
|
|
5
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAW,YAAY,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAW,WAAW,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;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
"version": "25.
|
|
3
|
+
"version": "25.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/culture",
|
|
6
6
|
"repository": {
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"dist",
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@servicetitan/application-data": ">1.0.0"
|
|
20
|
+
},
|
|
18
21
|
"devDependencies": {
|
|
19
22
|
"@servicetitan/react-ioc": "^21.6.0",
|
|
20
23
|
"@types/react": "~17.0.38",
|
|
@@ -30,5 +33,5 @@
|
|
|
30
33
|
"cli": {
|
|
31
34
|
"webpack": false
|
|
32
35
|
},
|
|
33
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "d29437d247da3428ed25fd9fc4004c1f3a94cf1e"
|
|
34
37
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export interface Culture {
|
|
6
|
-
Name: string;
|
|
7
|
-
DateTimeFormat?: {
|
|
8
|
-
MomentShortDatePattern?: string;
|
|
9
|
-
MomentShortYearDatePattern?: string;
|
|
10
|
-
MomentShortYearDateTimePattern?: string;
|
|
11
|
-
};
|
|
12
|
-
NumberFormat?: {
|
|
13
|
-
NumberDecimalSeparator?: string;
|
|
14
|
-
NumberGroupSeparator?: string;
|
|
15
|
-
};
|
|
16
|
-
PhoneFormat?: {
|
|
17
|
-
PhoneFormatInfo?: {
|
|
18
|
-
Pattern: RegExp;
|
|
19
|
-
Format: string;
|
|
20
|
-
};
|
|
21
|
-
PhoneWithExtNumberFormatInfo?: {
|
|
22
|
-
Pattern: RegExp;
|
|
23
|
-
Format: string;
|
|
24
|
-
};
|
|
25
|
-
PhoneMask?: string;
|
|
26
|
-
SimplePhoneMask?: string;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
1
|
+
import { ComponentType, FC, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Culture, CultureStore, CultureApi } from '@servicetitan/application-data/culture';
|
|
4
|
+
import { Provider, provide, symbolToken, useOptionalDependencies } from '@servicetitan/react-ioc';
|
|
29
5
|
|
|
30
6
|
export const CULTURE_TOKEN = symbolToken<Culture>('CULTURE_TOKEN');
|
|
31
7
|
|
|
32
8
|
interface CultureProviderProps {
|
|
33
|
-
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
value?: Culture;
|
|
34
11
|
}
|
|
35
12
|
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
)
|
|
13
|
+
export { Culture };
|
|
14
|
+
|
|
15
|
+
export const CultureProvider: FC<CultureProviderProps> = ({ value, children }) => {
|
|
16
|
+
const [store] = useOptionalDependencies(CultureStore);
|
|
17
|
+
const culture = value ?? store?.culture;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Provider
|
|
21
|
+
singletons={culture ? [{ provide: CULTURE_TOKEN, useValue: culture }] : undefined}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</Provider>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const withCultureSingletons = (
|
|
29
|
+
singletons?: Parameters<typeof provide>[0]['singletons']
|
|
30
|
+
): Parameters<typeof provide>[0]['singletons'] => [...(singletons ?? []), CultureApi, CultureStore];
|
|
31
|
+
|
|
32
|
+
export const provideWithCulture = ((stores, fallback) => (Component: ComponentType) => props =>
|
|
33
|
+
(
|
|
34
|
+
<Provider
|
|
35
|
+
singletons={withCultureSingletons(stores?.singletons)}
|
|
36
|
+
instances={stores?.instances}
|
|
37
|
+
fallback={fallback}
|
|
38
|
+
>
|
|
39
|
+
<CultureProvider>
|
|
40
|
+
<Component {...props} />
|
|
41
|
+
</CultureProvider>
|
|
42
|
+
</Provider>
|
|
43
|
+
)) as typeof provide;
|