@headless-adminapp/app 0.0.14-alpha.0 → 0.0.17-alpha.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.
@@ -31,7 +31,7 @@ function useBaseCommandHandlerContext() {
31
31
  const queryClient = (0, react_query_1.useQueryClient)();
32
32
  const stores = (0, hooks_2.useMetadata)();
33
33
  const utility = useUtility();
34
- const [locale] = (0, locale_1.useLocale)();
34
+ const locale = (0, locale_1.useLocale)();
35
35
  return {
36
36
  dataService,
37
37
  queryClient,
@@ -24,7 +24,7 @@ const InitialValueResolver_1 = require("./InitialValueResolver");
24
24
  const ReadonlyInfoResolver_1 = require("./ReadonlyInfoResolver");
25
25
  function DataFormProvider(props) {
26
26
  const { getSchema } = (0, useMetadata_1.useMetadata)();
27
- const [{ language }] = (0, useLocale_1.useLocale)();
27
+ const { language } = (0, useLocale_1.useLocale)();
28
28
  const formValidationStrings = (0, FormValidationStringContext_1.useFormValidationStrings)();
29
29
  const [formReadOnly, setFormReadOnly] = (0, react_1.useState)(false); // A trick to provide readOnly info to formInstance
30
30
  const formInstance = (0, react_hook_form_1.useForm)({
@@ -10,7 +10,7 @@ export interface DataGridProviderProps<S extends SchemaAttributes = SchemaAttrib
10
10
  view: View<S>;
11
11
  extraFilter?: Filter;
12
12
  commands: CommandItemExperience<CommandContext>[][];
13
- onChangeView: (viewId: string) => void;
13
+ onChangeView?: (viewId: string) => void;
14
14
  isSubGrid?: boolean;
15
15
  allowViewSelection?: boolean;
16
16
  maxRecords?: number;
@@ -14,9 +14,10 @@ function DataGridProvider(props) {
14
14
  const onChangeViewRef = (0, react_1.useRef)(props.onChangeView);
15
15
  onChangeViewRef.current = props.onChangeView;
16
16
  const { schemaStore } = (0, useMetadata_1.useMetadata)();
17
- const [{ language }] = (0, useLocale_1.useLocale)();
17
+ const { language } = (0, useLocale_1.useLocale)();
18
18
  const handleViewChange = (0, react_1.useCallback)((viewId) => {
19
- onChangeViewRef.current(viewId);
19
+ var _a;
20
+ (_a = onChangeViewRef.current) === null || _a === void 0 ? void 0 : _a.call(onChangeViewRef, viewId);
20
21
  }, []);
21
22
  const contextValue = (0, context_1.useCreateContextStore)({
22
23
  schema: props.schema,
@@ -79,7 +79,7 @@ function useMainGridCommandHandlerContext() {
79
79
  const queryClient = (0, react_query_1.useQueryClient)();
80
80
  const { appStore, experienceStore, schemaStore } = (0, useMetadata_1.useMetadata)();
81
81
  const utility = useUtility();
82
- const [locale] = (0, useLocale_1.useLocale)();
82
+ const locale = (0, useLocale_1.useLocale)();
83
83
  const primaryControl = useGridControlContext();
84
84
  return {
85
85
  dataService,
@@ -44,7 +44,7 @@ function useSubGridCommandHandlerContext() {
44
44
  const extraFilter = (0, useGridExtraFilter_1.useGridExtraFilter)();
45
45
  const refresh = (0, useGridRefresh_1.useGridRefresh)();
46
46
  const utility = (0, useMainGridCommands_1.useUtility)();
47
- const [locale] = (0, useLocale_1.useLocale)();
47
+ const locale = (0, useLocale_1.useLocale)();
48
48
  const mainFormHandlerContext = (0, useMainFormCommands_1.useMainFormCommandHandlerContext)();
49
49
  // console.log('mainFormHandlerContext', mainFormHandlerContext);
50
50
  return {
@@ -0,0 +1,13 @@
1
+ import { Locale } from '@headless-adminapp/core/experience/locale';
2
+ import { FC, PropsWithChildren } from 'react';
3
+ interface LocaleProviderProps {
4
+ locale: string;
5
+ options?: {
6
+ direction?: Locale['direction'];
7
+ dateFormats?: Locale['dateFormats'];
8
+ timeFormats?: Locale['timeFormats'];
9
+ currency?: Partial<Locale['currency']>;
10
+ };
11
+ }
12
+ export declare const LocaleProvider: FC<PropsWithChildren<LocaleProviderProps>>;
13
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocaleProvider = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const locale_1 = require("@headless-adminapp/core/experience/locale");
6
+ const react_1 = require("react");
7
+ const context_1 = require("./context");
8
+ const LocaleProvider = ({ children, locale, }) => {
9
+ const localeState = (0, react_1.useMemo)(() => {
10
+ return (0, locale_1.getLocale)(locale);
11
+ }, [locale]);
12
+ return ((0, jsx_runtime_1.jsx)(context_1.LocaleContext.Provider, { value: localeState, children: children }));
13
+ };
14
+ exports.LocaleProvider = LocaleProvider;
@@ -1,2 +1,2 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
- export declare const LocaleContext: import("react").Context<[import("@headless-adminapp/core/experience/app").Locale, Dispatch<SetStateAction<import("@headless-adminapp/core/experience/app").Locale>>] | null>;
1
+ import { Locale } from '@headless-adminapp/core/experience/locale';
2
+ export declare const LocaleContext: import("react").Context<Locale | null>;
package/locale/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { LocaleContext } from './context';
2
- export * from './types';
3
2
  export * from './useLocale';
package/locale/index.js CHANGED
@@ -17,5 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.LocaleContext = void 0;
18
18
  var context_1 = require("./context");
19
19
  Object.defineProperty(exports, "LocaleContext", { enumerable: true, get: function () { return context_1.LocaleContext; } });
20
- __exportStar(require("./types"), exports);
21
20
  __exportStar(require("./useLocale"), exports);
@@ -1 +1 @@
1
- export declare function useLocale(): [import("@headless-adminapp/core/experience/app").Locale, import("react").Dispatch<import("react").SetStateAction<import("@headless-adminapp/core/experience/app").Locale>>];
1
+ export declare function useLocale(): import("@headless-adminapp/core/experience/locale").Locale;
@@ -1,9 +1,8 @@
1
1
  import { IClientAppStore, ISchemaExperienceStore, ISchemaStore } from '@headless-adminapp/core/store';
2
2
  import { FC, PropsWithChildren } from 'react';
3
- interface MetadataProviderProps {
3
+ export interface MetadataProviderProps {
4
4
  schemaStore: ISchemaStore;
5
5
  experienceStore: ISchemaExperienceStore;
6
6
  appStore: IClientAppStore;
7
7
  }
8
8
  export declare const MetadataProvider: FC<PropsWithChildren<MetadataProviderProps>>;
9
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/app",
3
- "version": "0.0.14-alpha.0",
3
+ "version": "0.0.17-alpha.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -33,5 +33,5 @@
33
33
  "clsx": "2.1.1",
34
34
  "react-custom-scrollbars-2": "^4.5.0"
35
35
  },
36
- "gitHead": "c616c164a9e637a41465cdb887b4cc85628c8d95"
36
+ "gitHead": "f57583f8390f15b373fbe095c8f3391f538b94d3"
37
37
  }