@headless-adminapp/app 0.0.17-alpha.8 → 1.0.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/app/AppProvider.d.ts +0 -3
- package/app/AppProvider.js +10 -33
- package/app/AuthWrapper.d.ts +1 -1
- package/app/AuthWrapper.js +4 -1
- package/app/LayoutProvider.d.ts +8 -7
- package/app/LayoutProvider.js +28 -2
- package/app/context.d.ts +1 -1
- package/auth/AuthProvider.d.ts +1 -1
- package/auth/AuthProvider.js +30 -23
- package/auth/context.d.ts +2 -0
- package/auth/hooks/useIsSkipAuthCheck.d.ts +1 -0
- package/auth/hooks/useIsSkipAuthCheck.js +8 -0
- package/auth/hooks/useLogout.js +1 -1
- package/board/BoardColumnDataResolver.d.ts +1 -0
- package/board/BoardColumnDataResolver.js +64 -0
- package/board/BoardColumnProvider.d.ts +7 -0
- package/board/BoardColumnProvider.js +36 -0
- package/board/context.d.ts +19 -0
- package/board/context.js +6 -0
- package/board/hooks/index.d.ts +6 -0
- package/board/hooks/index.js +15 -0
- package/board/hooks/useBoardColumnConfig.d.ts +2 -0
- package/board/hooks/useBoardColumnConfig.js +8 -0
- package/board/hooks/useBoardColumnData.d.ts +3 -0
- package/board/hooks/useBoardColumnData.js +9 -0
- package/board/hooks/useBoardColumnDataState.d.ts +5 -0
- package/board/hooks/useBoardColumnDataState.js +9 -0
- package/board/hooks/useBoardConfig.d.ts +3 -0
- package/board/hooks/useBoardConfig.js +8 -0
- package/board/hooks/useBoardSchema.d.ts +2 -0
- package/board/hooks/useBoardSchema.js +7 -0
- package/board/hooks/useSearchText.d.ts +1 -0
- package/board/hooks/useSearchText.js +14 -0
- package/board/types.d.ts +47 -0
- package/board/utils.d.ts +3 -0
- package/board/utils.js +6 -0
- package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +15 -6
- package/builders/CommandBuilder/DefaultCommandBuilder.js +42 -20
- package/builders/CommandBuilder/FormCommandBuilder.d.ts +14 -13
- package/builders/CommandBuilder/FormCommandBuilder.js +66 -52
- package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +8 -27
- package/builders/CommandBuilder/SubgridCommandBuilder.js +115 -57
- package/builders/CommandBuilder/ViewCommandBuilder.js +32 -52
- package/builders/CommandBuilder/utils.js +1 -1
- package/builders/DefineFormExperience.d.ts +27 -0
- package/builders/DefineFormExperience.js +99 -0
- package/builders/DefineViewExperience.d.ts +13 -0
- package/builders/DefineViewExperience.js +33 -0
- package/builders/SchemaExperienceBuilder.d.ts +9 -7
- package/builders/SchemaExperienceBuilder.js +62 -40
- package/builders/utils.js +30 -44
- package/calendar/baseEventAttributes.d.ts +35 -0
- package/calendar/baseEventAttributes.js +38 -0
- package/calendar/context.d.ts +6 -0
- package/calendar/context.js +5 -0
- package/calendar/hooks/index.d.ts +1 -0
- package/{appearance → calendar}/hooks/index.js +1 -1
- package/calendar/hooks/useConfig.d.ts +3 -0
- package/calendar/hooks/useConfig.js +8 -0
- package/calendar/types.d.ts +41 -0
- package/calendar/types.js +2 -0
- package/calendar/utils.d.ts +3 -0
- package/calendar/utils.js +6 -0
- package/command/hooks/useBaseCommandHandlerContext.js +15 -6
- package/command/hooks/useCommands.js +1 -1
- package/command/utils/index.js +34 -9
- package/components/ScrollView/index.d.ts +1 -1
- package/components/ScrollView/index.js +2 -2
- package/components/ScrollbarWithMoreDataRequest/index.d.ts +9 -0
- package/components/ScrollbarWithMoreDataRequest/index.js +32 -0
- package/dataform/DataFormProvider/CustomHookExecuter.d.ts +5 -0
- package/dataform/DataFormProvider/CustomHookExecuter.js +14 -0
- package/dataform/DataFormProvider/DataResolver.d.ts +6 -4
- package/dataform/DataFormProvider/DataResolver.js +11 -94
- package/dataform/DataFormProvider/InitialValueResolver.js +3 -2
- package/dataform/DataFormProvider/ReadonlyInfoResolver.js +2 -3
- package/dataform/DataFormProvider/getRecord.d.ts +3 -0
- package/dataform/DataFormProvider/getRecord.js +56 -0
- package/dataform/DataFormProvider/index.d.ts +4 -0
- package/dataform/DataFormProvider/index.js +34 -12
- package/dataform/DataFormProvider/types.d.ts +13 -0
- package/dataform/DataFormProvider/types.js +2 -0
- package/dataform/DataFormProvider/utils.d.ts +23 -0
- package/dataform/DataFormProvider/utils.js +105 -0
- package/dataform/FormManager.d.ts +57 -0
- package/dataform/FormManager.js +247 -0
- package/dataform/constants.d.ts +1 -0
- package/dataform/constants.js +4 -0
- package/dataform/context.d.ts +26 -1
- package/dataform/hooks/index.d.ts +11 -0
- package/dataform/hooks/index.js +11 -0
- package/dataform/hooks/useContextKey.d.ts +1 -0
- package/dataform/hooks/useContextKey.js +8 -0
- package/dataform/hooks/useDisabledControlsManager.d.ts +6 -0
- package/dataform/hooks/useDisabledControlsManager.js +46 -0
- package/dataform/hooks/useEventManager.d.ts +1 -0
- package/dataform/hooks/useEventManager.js +8 -0
- package/dataform/hooks/useFormManager.d.ts +2 -0
- package/dataform/hooks/useFormManager.js +13 -0
- package/dataform/hooks/useFormNotifications.js +2 -2
- package/dataform/hooks/useFormSave.js +28 -31
- package/dataform/hooks/useHiddenControlsManager.d.ts +7 -0
- package/dataform/hooks/useHiddenControlsManager.js +50 -0
- package/dataform/hooks/useIsControlDisabled.d.ts +1 -0
- package/dataform/hooks/useIsControlDisabled.js +27 -0
- package/dataform/hooks/useIsControlHiddenByAttributeName.d.ts +1 -0
- package/dataform/hooks/useIsControlHiddenByAttributeName.js +17 -0
- package/dataform/hooks/useIsControlHiddenByKey.d.ts +1 -0
- package/dataform/hooks/useIsControlHiddenByKey.js +17 -0
- package/dataform/hooks/useIsFieldRequired.d.ts +1 -0
- package/dataform/hooks/useIsFieldRequired.js +25 -0
- package/dataform/hooks/useLoadFormGridPage.js +8 -17
- package/dataform/hooks/useMainFormCommands.d.ts +1 -12
- package/dataform/hooks/useMainFormCommands.js +13 -3
- package/dataform/hooks/useOnFieldValueChangeListener.d.ts +1 -0
- package/dataform/hooks/useOnFieldValueChangeListener.js +30 -0
- package/dataform/hooks/useProcessFlowSteps.d.ts +1 -0
- package/dataform/hooks/useProcessFlowSteps.js +45 -0
- package/dataform/hooks/useRecordTitle.d.ts +3 -1
- package/dataform/hooks/useRecordTitle.js +12 -5
- package/dataform/hooks/useRequiredFieldManager.d.ts +6 -0
- package/dataform/hooks/useRequiredFieldManager.js +49 -0
- package/dataform/test.d.ts +57 -0
- package/dataform/test.js +247 -0
- package/dataform/utils/defaultParameters.d.ts +6 -0
- package/dataform/utils/defaultParameters.js +54 -0
- package/dataform/utils/index.d.ts +6 -24
- package/dataform/utils/index.js +164 -190
- package/dataform/utils/saveRecord.d.ts +27 -0
- package/dataform/utils/saveRecord.js +163 -0
- package/datagrid/DataGridProvider/DataResolver.js +38 -109
- package/datagrid/DataGridProvider/index.d.ts +6 -0
- package/datagrid/DataGridProvider/index.js +18 -8
- package/datagrid/DataGridProvider/transformViewColumns.js +10 -2
- package/datagrid/DataGridProvider/utils.js +8 -8
- package/datagrid/column-filter/constants.js +38 -3
- package/datagrid/column-filter/utils.js +7 -1
- package/datagrid/context.d.ts +6 -0
- package/datagrid/hooks/useChangeView.js +1 -1
- package/datagrid/hooks/useGridColumnFilter.js +4 -1
- package/datagrid/hooks/useGridDisabled.d.ts +1 -0
- package/datagrid/hooks/useGridDisabled.js +8 -0
- package/datagrid/hooks/useLoadMainGridPage.js +1 -1
- package/datagrid/hooks/useMainGridCommands.js +23 -9
- package/datagrid/hooks/useOpenRecord.js +2 -2
- package/datagrid/hooks/useSubGridCommands.js +23 -45
- package/defaults.d.ts +2 -0
- package/defaults.js +5 -0
- package/dialog/hooks/useCloseDialog.js +17 -15
- package/dialog/hooks/useOpenAlertDialog.js +8 -3
- package/dialog/hooks/useOpenConfirmDialog.js +10 -4
- package/dialog/hooks/useOpenDialog.js +7 -5
- package/dialog/hooks/useOpenErrorDialog.js +8 -3
- package/dialog/hooks/useOpenPromptDialog.js +10 -4
- package/form/FormValidationStringContext.d.ts +1 -0
- package/form/FormValidationStringContext.js +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +3 -0
- package/hooks/useDebouncedValue.js +0 -1
- package/hooks/useElementLayout.js +1 -1
- package/hooks/useIsMobile.js +0 -1
- package/hooks/useItemsWithKey.d.ts +7 -0
- package/hooks/useItemsWithKey.js +13 -0
- package/hooks/useStorageState.js +1 -2
- package/hooks/useSystemColorScheme.d.ts +1 -1
- package/hooks/useSystemColorScheme.js +0 -1
- package/insights/InsightsProvider.d.ts +8 -0
- package/insights/InsightsProvider.js +27 -0
- package/locale/LocaleProvider.d.ts +2 -1
- package/locale/LocaleProvider.js +3 -3
- package/locale/index.d.ts +1 -0
- package/locale/index.js +1 -0
- package/locale/useCurrencySymbol.d.ts +1 -0
- package/locale/useCurrencySymbol.js +12 -0
- package/locale/utils.js +4 -2
- package/metadata/MetadataProvider.d.ts +8 -4
- package/metadata/MetadataProvider.js +23 -17
- package/metadata/context.d.ts +3 -2
- package/metadata/hooks/index.d.ts +1 -1
- package/metadata/hooks/index.js +1 -1
- package/metadata/hooks/useAppExperience.d.ts +1 -0
- package/metadata/hooks/useAppExperience.js +8 -0
- package/metadata/hooks/useAppStore.d.ts +1 -1
- package/metadata/hooks/useAppStore.js +3 -3
- package/metadata/hooks/useExperienceView.js +2 -11
- package/metadata/hooks/useExperienceViewCommands.d.ts +1 -1
- package/metadata/hooks/useExperienceViewCommands.js +5 -14
- package/metadata/hooks/useExperienceViewLookup.js +2 -11
- package/metadata/hooks/useExperienceViewSubgridCommands.d.ts +1 -1
- package/metadata/hooks/useExperienceViewSubgridCommands.js +5 -14
- package/metadata/hooks/useMetadata.d.ts +11 -10
- package/metadata/hooks/useMetadata.js +4 -16
- package/metadata/hooks/useSchema.d.ts +1 -1
- package/metadata/hooks/useSchema.js +3 -0
- package/mutable/context.d.ts +3 -0
- package/mutable/context.js +8 -0
- package/mutable/utils.js +5 -12
- package/navigation/hooks/useOpenForm.js +4 -0
- package/package.json +6 -10
- package/providers/PageEntityFormProvider/index.d.ts +5 -1
- package/providers/PageEntityFormProvider/index.js +2 -2
- package/recordset/hooks/useRecordSetResult.js +4 -14
- package/route/RouteProvider.d.ts +2 -2
- package/route/RouteProvider.js +4 -1
- package/store/ClientAppStore.js +7 -20
- package/store/ComponentStore.d.ts +1 -1
- package/store/ComponentStore.js +6 -12
- package/store/EventManager.d.ts +2 -2
- package/store/EventManager.js +13 -29
- package/store/SchemaExperienceStore.js +179 -215
- package/store/index.d.ts +0 -1
- package/store/index.js +0 -1
- package/toast-notification/hooks/useCloseToastNotification.js +17 -15
- package/toast-notification/hooks/useOpenToastNotification.js +7 -5
- package/transport/InMemoryDataService/index.js +54 -77
- package/transport/RestDataService/index.d.ts +3 -3
- package/transport/RestDataService/index.js +68 -91
- package/transport/context.d.ts +2 -1
- package/transport/context.js +7 -1
- package/transport/hooks/index.d.ts +1 -0
- package/transport/hooks/index.js +1 -0
- package/transport/hooks/useFileService.d.ts +1 -0
- package/transport/hooks/useFileService.js +9 -0
- package/transport/hooks/useRetriveRecords.d.ts +33 -0
- package/transport/hooks/useRetriveRecords.js +110 -0
- package/utils/calculateColumnWidths.js +1 -1
- package/utils/color.d.ts +1 -0
- package/utils/color.js +14 -0
- package/utils/getAttributeFormattedValue.d.ts +4 -1
- package/utils/getAttributeFormattedValue.js +109 -54
- package/utils/phone.d.ts +13 -0
- package/utils/phone.js +33 -0
- package/appearance/context.d.ts +0 -7
- package/appearance/context.js +0 -5
- package/appearance/hooks/index.d.ts +0 -1
- package/appearance/hooks/useAppearanceContext.d.ts +0 -1
- package/appearance/hooks/useAppearanceContext.js +0 -12
- package/appearance/index.d.ts +0 -2
- package/appearance/index.js +0 -20
- package/builders/CommandBuilder.d.ts +0 -176
- package/builders/CommandBuilder.js +0 -567
- package/locale/types.d.ts +0 -2
- /package/{locale → board}/types.js +0 -0
|
@@ -4,26 +4,28 @@ exports.useCloseDialog = useCloseDialog;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const context_1 = require("../../mutable/context");
|
|
6
6
|
const context_2 = require("../context");
|
|
7
|
+
function markDialogAsClosed(items, id) {
|
|
8
|
+
return items.map((item) => {
|
|
9
|
+
if (item.id === id) {
|
|
10
|
+
return { ...item, isOpen: false };
|
|
11
|
+
}
|
|
12
|
+
return item;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function excludeDialogItemById(items, id) {
|
|
16
|
+
return items.filter((item) => item.id !== id);
|
|
17
|
+
}
|
|
7
18
|
function useCloseDialog() {
|
|
8
19
|
const setValue = (0, context_1.useContextSetValue)(context_2.DialogContext);
|
|
9
20
|
const closeDialog = (0, react_1.useCallback)((id) => {
|
|
10
|
-
setValue((state) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (item.id === id) {
|
|
14
|
-
return Object.assign(Object.assign({}, item), { isOpen: false });
|
|
15
|
-
}
|
|
16
|
-
return item;
|
|
17
|
-
}),
|
|
18
|
-
};
|
|
19
|
-
});
|
|
21
|
+
setValue((state) => ({
|
|
22
|
+
items: markDialogAsClosed(state.items, id),
|
|
23
|
+
}));
|
|
20
24
|
// Simulate a delay to show the dialog closing animation
|
|
21
25
|
setTimeout(() => {
|
|
22
|
-
setValue((state) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
});
|
|
26
|
+
setValue((state) => ({
|
|
27
|
+
items: excludeDialogItemById(state.items, id),
|
|
28
|
+
}));
|
|
27
29
|
}, 1000);
|
|
28
30
|
}, [setValue]);
|
|
29
31
|
return closeDialog;
|
|
@@ -7,13 +7,18 @@ function useOpenAlertDialog() {
|
|
|
7
7
|
const openDialog = (0, useOpenDialog_1.useOpenDialog)();
|
|
8
8
|
const openAlertDialog = (0, react_1.useCallback)((options) => {
|
|
9
9
|
return new Promise((resolve) => {
|
|
10
|
-
const { close } = openDialog(
|
|
10
|
+
const { close } = openDialog({
|
|
11
|
+
type: 'alert',
|
|
12
|
+
...options,
|
|
13
|
+
onDismiss: () => {
|
|
11
14
|
close();
|
|
12
15
|
resolve();
|
|
13
|
-
},
|
|
16
|
+
},
|
|
17
|
+
onConfirm: () => {
|
|
14
18
|
close();
|
|
15
19
|
resolve();
|
|
16
|
-
}
|
|
20
|
+
},
|
|
21
|
+
});
|
|
17
22
|
});
|
|
18
23
|
}, [openDialog]);
|
|
19
24
|
return openAlertDialog;
|
|
@@ -7,19 +7,25 @@ function useOpenConfirmDialog() {
|
|
|
7
7
|
const openDialog = (0, useOpenDialog_1.useOpenDialog)();
|
|
8
8
|
const openConfirmDialog = (0, react_1.useCallback)((options) => {
|
|
9
9
|
return new Promise((resolve) => {
|
|
10
|
-
const { close } = openDialog(
|
|
10
|
+
const { close } = openDialog({
|
|
11
|
+
type: 'confirm',
|
|
12
|
+
...options,
|
|
13
|
+
onDismiss: () => {
|
|
11
14
|
if (!options.allowDismiss) {
|
|
12
15
|
return;
|
|
13
16
|
}
|
|
14
17
|
close();
|
|
15
18
|
resolve(null);
|
|
16
|
-
},
|
|
19
|
+
},
|
|
20
|
+
onConfirm: () => {
|
|
17
21
|
close();
|
|
18
22
|
resolve({ confirmed: true });
|
|
19
|
-
},
|
|
23
|
+
},
|
|
24
|
+
onCancel: () => {
|
|
20
25
|
close();
|
|
21
26
|
resolve({ confirmed: false });
|
|
22
|
-
}
|
|
27
|
+
},
|
|
28
|
+
});
|
|
23
29
|
});
|
|
24
30
|
}, [openDialog]);
|
|
25
31
|
return openConfirmDialog;
|
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOpenDialog = useOpenDialog;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
5
6
|
const context_1 = require("../../mutable/context");
|
|
6
7
|
const context_2 = require("../context");
|
|
7
8
|
const useCloseDialog_1 = require("./useCloseDialog");
|
|
8
|
-
function randomId() {
|
|
9
|
-
return Math.random().toString(36).substring(2);
|
|
10
|
-
}
|
|
11
9
|
function useOpenDialog() {
|
|
12
10
|
const setValue = (0, context_1.useContextSetValue)(context_2.DialogContext);
|
|
13
11
|
const closeDialog = (0, useCloseDialog_1.useCloseDialog)();
|
|
14
12
|
const openDialog = (0, react_1.useCallback)((options) => {
|
|
15
|
-
const id =
|
|
13
|
+
const id = (0, uuid_1.v4)();
|
|
16
14
|
setValue((state) => {
|
|
17
15
|
return {
|
|
18
16
|
items: [
|
|
19
17
|
...state.items,
|
|
20
|
-
|
|
18
|
+
{
|
|
19
|
+
id,
|
|
20
|
+
isOpen: true,
|
|
21
|
+
...options,
|
|
22
|
+
},
|
|
21
23
|
],
|
|
22
24
|
};
|
|
23
25
|
});
|
|
@@ -6,11 +6,16 @@ const useOpenDialog_1 = require("./useOpenDialog");
|
|
|
6
6
|
function useOpenErrorDialog() {
|
|
7
7
|
const openDialog = (0, useOpenDialog_1.useOpenDialog)();
|
|
8
8
|
const openErrorDialog = (0, react_1.useCallback)((options) => {
|
|
9
|
-
const { close } = openDialog(
|
|
9
|
+
const { close } = openDialog({
|
|
10
|
+
type: 'error',
|
|
11
|
+
...options,
|
|
12
|
+
onDismiss: () => {
|
|
10
13
|
close();
|
|
11
|
-
},
|
|
14
|
+
},
|
|
15
|
+
onConfirm: () => {
|
|
12
16
|
close();
|
|
13
|
-
}
|
|
17
|
+
},
|
|
18
|
+
});
|
|
14
19
|
}, [openDialog]);
|
|
15
20
|
return openErrorDialog;
|
|
16
21
|
}
|
|
@@ -7,19 +7,25 @@ function useOpenPromptDialog() {
|
|
|
7
7
|
const openDialog = (0, useOpenDialog_1.useOpenDialog)();
|
|
8
8
|
const openPromptDialog = (0, react_1.useCallback)((options) => {
|
|
9
9
|
return new Promise((resolve) => {
|
|
10
|
-
const { close } = openDialog(
|
|
10
|
+
const { close } = openDialog({
|
|
11
|
+
type: 'prompt',
|
|
12
|
+
...options,
|
|
13
|
+
onDismiss: () => {
|
|
11
14
|
if (!options.allowDismiss) {
|
|
12
15
|
return;
|
|
13
16
|
}
|
|
14
17
|
close();
|
|
15
18
|
resolve(null);
|
|
16
|
-
},
|
|
19
|
+
},
|
|
20
|
+
onConfirm: (result) => {
|
|
17
21
|
close();
|
|
18
22
|
resolve(result);
|
|
19
|
-
},
|
|
23
|
+
},
|
|
24
|
+
onCancel: () => {
|
|
20
25
|
close();
|
|
21
26
|
resolve(null);
|
|
22
|
-
}
|
|
27
|
+
},
|
|
28
|
+
});
|
|
23
29
|
});
|
|
24
30
|
}, [openDialog]);
|
|
25
31
|
return openPromptDialog;
|
|
@@ -6,6 +6,7 @@ export interface FormValidationStringSet {
|
|
|
6
6
|
invalidEmail: string;
|
|
7
7
|
invalidPhoneNumber: string;
|
|
8
8
|
atLeastOneRowRequired: string;
|
|
9
|
+
fileSizeExceeded: string;
|
|
9
10
|
}
|
|
10
11
|
export declare const defaultFormValidationStrings: FormValidationStringSet;
|
|
11
12
|
export declare const FormValidationStringContext: import("react").Context<FormValidationStringSet>;
|
|
@@ -11,6 +11,7 @@ exports.defaultFormValidationStrings = {
|
|
|
11
11
|
invalidEmail: 'Invalid email.',
|
|
12
12
|
invalidPhoneNumber: 'Invalid phone number.',
|
|
13
13
|
atLeastOneRowRequired: 'At least one row required.',
|
|
14
|
+
fileSizeExceeded: 'File size exceeded.',
|
|
14
15
|
};
|
|
15
16
|
exports.FormValidationStringContext = (0, react_1.createContext)(exports.defaultFormValidationStrings);
|
|
16
17
|
function useFormValidationStrings() {
|
package/hooks/index.d.ts
CHANGED
package/hooks/index.js
CHANGED
|
@@ -14,8 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.useItemsWithKey = void 0;
|
|
17
18
|
__exportStar(require("./useDebouncedValue"), exports);
|
|
18
19
|
__exportStar(require("./useElementLayout"), exports);
|
|
19
20
|
__exportStar(require("./useIsMobile"), exports);
|
|
20
21
|
__exportStar(require("./useStorageState"), exports);
|
|
21
22
|
__exportStar(require("./useSystemColorScheme"), exports);
|
|
23
|
+
var useItemsWithKey_1 = require("./useItemsWithKey");
|
|
24
|
+
Object.defineProperty(exports, "useItemsWithKey", { enumerable: true, get: function () { return useItemsWithKey_1.useItemsWithKey; } });
|
|
@@ -4,7 +4,7 @@ exports.useElementSize = useElementSize;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useElementSize(elementRef, interval) {
|
|
6
6
|
const [size, setSize] = (0, react_1.useState)({ width: 0, height: 0 });
|
|
7
|
-
(0, react_1.
|
|
7
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
8
8
|
function updateSize() {
|
|
9
9
|
if (elementRef.current) {
|
|
10
10
|
const element = elementRef.current;
|
package/hooks/useIsMobile.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ItemWithKey } from '@headless-adminapp/core/types';
|
|
2
|
+
export declare function useItemsWithKey<T>(value: T[]): ItemWithKey<T>[];
|
|
3
|
+
export declare function useItemsWithKey(value: null): null;
|
|
4
|
+
export declare function useItemsWithKey(value: undefined): undefined;
|
|
5
|
+
export declare function useItemsWithKey<T>(value: T[] | null): ItemWithKey<T>[] | null;
|
|
6
|
+
export declare function useItemsWithKey<T>(value: T[] | undefined): ItemWithKey<T>[] | undefined;
|
|
7
|
+
export declare function useItemsWithKey<T>(value: T[] | null | undefined): ItemWithKey<T>[] | null | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useItemsWithKey = useItemsWithKey;
|
|
4
|
+
const utils_1 = require("@headless-adminapp/core/utils");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
function useItemsWithKey(value) {
|
|
7
|
+
return (0, react_1.useMemo)(() => {
|
|
8
|
+
if (!value) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
return (0, utils_1.createItemsWithKey)(value);
|
|
12
|
+
}, [value]);
|
|
13
|
+
}
|
package/hooks/useStorageState.js
CHANGED
|
@@ -13,8 +13,7 @@ function setStorageValue(key, value, store) {
|
|
|
13
13
|
store.setItem(key, JSON.stringify(value));
|
|
14
14
|
}
|
|
15
15
|
function useStorageState(initialState, key, store = localStorage) {
|
|
16
|
-
|
|
17
|
-
const [state, setState] = (0, react_1.useState)((_a = getStorageValue(key, store)) !== null && _a !== void 0 ? _a : initialState);
|
|
16
|
+
const [state, setState] = (0, react_1.useState)(getStorageValue(key, store) ?? initialState);
|
|
18
17
|
const setStoredState = (0, react_1.useCallback)((value) => {
|
|
19
18
|
setState((prevState) => {
|
|
20
19
|
const finalState = value instanceof Function ? value(prevState) : value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useSystemColorScheme(): "
|
|
1
|
+
export declare function useSystemColorScheme(): "dark" | "light";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InsightExpereince, InsightLookup } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
export declare function InsightsProvider<SA extends SchemaAttributes = SchemaAttributes>({ children, experience, insightLookup, onInsightSelect, }: PropsWithChildren<{
|
|
5
|
+
experience: InsightExpereince<SA>;
|
|
6
|
+
insightLookup: InsightLookup[];
|
|
7
|
+
onInsightSelect: (id: string) => void;
|
|
8
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InsightsProvider = InsightsProvider;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const mutable_1 = require("../mutable");
|
|
7
|
+
const context_1 = require("./context");
|
|
8
|
+
function InsightsProvider({ children, experience, insightLookup, onInsightSelect, }) {
|
|
9
|
+
const onInsightSelectRef = (0, react_1.useRef)(onInsightSelect);
|
|
10
|
+
onInsightSelectRef.current = onInsightSelect;
|
|
11
|
+
const onInsightSelectInternal = (0, react_1.useCallback)((id) => {
|
|
12
|
+
onInsightSelectRef.current(id);
|
|
13
|
+
}, [onInsightSelectRef]);
|
|
14
|
+
const insightsValues = (0, mutable_1.useCreateContextStore)({
|
|
15
|
+
experience,
|
|
16
|
+
data: experience.defaultData,
|
|
17
|
+
insightLookup: insightLookup,
|
|
18
|
+
onInsightSelect: onInsightSelectInternal,
|
|
19
|
+
});
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
insightsValues.setValue({
|
|
22
|
+
experience,
|
|
23
|
+
data: experience.defaultData,
|
|
24
|
+
});
|
|
25
|
+
}, [experience, insightsValues]);
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(context_1.InsightsContext.Provider, { value: insightsValues, children: children }));
|
|
27
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Locale } from '@headless-adminapp/core/experience/locale';
|
|
2
2
|
import { FC, PropsWithChildren } from 'react';
|
|
3
3
|
export interface LocaleProviderProps {
|
|
4
|
-
locale
|
|
4
|
+
locale?: string;
|
|
5
|
+
timezone?: string;
|
|
5
6
|
options?: {
|
|
6
7
|
direction?: Locale['direction'];
|
|
7
8
|
dateFormats?: Locale['dateFormats'];
|
package/locale/LocaleProvider.js
CHANGED
|
@@ -5,10 +5,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const locale_1 = require("@headless-adminapp/core/experience/locale");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const context_1 = require("./context");
|
|
8
|
-
const LocaleProvider = ({ children, locale, options, }) => {
|
|
8
|
+
const LocaleProvider = ({ children, locale = 'en-US', timezone = 'UTC', options, }) => {
|
|
9
9
|
const localeState = (0, react_1.useMemo)(() => {
|
|
10
|
-
return (0, locale_1.getLocale)(locale, options);
|
|
11
|
-
}, [locale, options]);
|
|
10
|
+
return (0, locale_1.getLocale)(locale, timezone, options);
|
|
11
|
+
}, [locale, timezone, options]);
|
|
12
12
|
return ((0, jsx_runtime_1.jsx)(context_1.LocaleContext.Provider, { value: localeState, children: children }));
|
|
13
13
|
};
|
|
14
14
|
exports.LocaleProvider = LocaleProvider;
|
package/locale/index.d.ts
CHANGED
package/locale/index.js
CHANGED
|
@@ -18,5 +18,6 @@ exports.LocaleProvider = 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
20
|
__exportStar(require("./useLocale"), exports);
|
|
21
|
+
__exportStar(require("./useCurrencySymbol"), exports);
|
|
21
22
|
var LocaleProvider_1 = require("./LocaleProvider");
|
|
22
23
|
Object.defineProperty(exports, "LocaleProvider", { enumerable: true, get: function () { return LocaleProvider_1.LocaleProvider; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useCurrencySymbol(): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCurrencySymbol = useCurrencySymbol;
|
|
4
|
+
const utils_1 = require("@headless-adminapp/core/experience/locale/utils");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const useLocale_1 = require("./useLocale");
|
|
7
|
+
function useCurrencySymbol() {
|
|
8
|
+
const locale = (0, useLocale_1.useLocale)();
|
|
9
|
+
return (0, react_1.useMemo)(() => {
|
|
10
|
+
return (0, utils_1.getCurrencySymbol)(locale.locale, locale.currency.currency ?? 'USD');
|
|
11
|
+
}, [locale]);
|
|
12
|
+
}
|
package/locale/utils.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.localizedLabel = localizedLabel;
|
|
4
4
|
function localizedLabel(language, value, fallback) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
return (value.localizedLabels?.[language] ??
|
|
6
|
+
fallback?.localizedLabels?.[language] ??
|
|
7
|
+
value.label ??
|
|
8
|
+
fallback?.label);
|
|
7
9
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppExperience } from '@headless-adminapp/core/experience/app';
|
|
2
|
+
import { ISchemaExperienceStore, ISchemaStore, SchemaStore } from '@headless-adminapp/core/store';
|
|
2
3
|
import { FC, PropsWithChildren } from 'react';
|
|
4
|
+
import { SchemaExperienceStore } from '../store';
|
|
3
5
|
export interface MetadataProviderProps {
|
|
4
|
-
schemaStore
|
|
5
|
-
experienceStore
|
|
6
|
-
|
|
6
|
+
schemaStore?: ISchemaStore;
|
|
7
|
+
experienceStore?: ISchemaExperienceStore;
|
|
8
|
+
appExperience?: AppExperience;
|
|
7
9
|
}
|
|
10
|
+
export declare const defaultSchemaStore: SchemaStore<import("@headless-adminapp/core/schema").SchemaAttributes>;
|
|
11
|
+
export declare const defaultExperienceStore: SchemaExperienceStore;
|
|
8
12
|
export declare const MetadataProvider: FC<PropsWithChildren<MetadataProviderProps>>;
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MetadataProvider = void 0;
|
|
3
|
+
exports.MetadataProvider = exports.defaultExperienceStore = exports.defaultSchemaStore = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const app_1 = require("@headless-adminapp/core/experience/app");
|
|
6
|
+
const store_1 = require("@headless-adminapp/core/store");
|
|
7
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
5
8
|
const context_1 = require("../mutable/context");
|
|
9
|
+
const store_2 = require("../store");
|
|
6
10
|
const context_2 = require("./context");
|
|
7
|
-
|
|
11
|
+
exports.defaultSchemaStore = new store_1.SchemaStore();
|
|
12
|
+
exports.defaultExperienceStore = new store_2.SchemaExperienceStore({
|
|
13
|
+
schemaStore: exports.defaultSchemaStore,
|
|
14
|
+
});
|
|
15
|
+
const defaultApp = {
|
|
16
|
+
id: 'default',
|
|
17
|
+
title: 'Demo App',
|
|
18
|
+
navItems: [],
|
|
19
|
+
defaultPage: {
|
|
20
|
+
label: 'Home',
|
|
21
|
+
link: '/home',
|
|
22
|
+
type: app_1.PageType.Custom,
|
|
23
|
+
icon: icons_1.IconPlaceholder,
|
|
24
|
+
},
|
|
25
|
+
logo: {},
|
|
26
|
+
};
|
|
27
|
+
const MetadataProvider = ({ children, experienceStore = exports.defaultExperienceStore, schemaStore = exports.defaultSchemaStore, appExperience = defaultApp, }) => {
|
|
8
28
|
const contextValue = (0, context_1.useCreateContextStore)({
|
|
9
|
-
// schemas: {},
|
|
10
|
-
// schemaLoading: true,
|
|
11
29
|
experienceStore,
|
|
12
30
|
schemaStore,
|
|
13
|
-
|
|
31
|
+
appExperience,
|
|
14
32
|
});
|
|
15
|
-
// const [loading, setLoading] = useState(true);
|
|
16
|
-
// useEffect(() => {
|
|
17
|
-
// const schemas = schemaStore.getSchemas();
|
|
18
|
-
// contextValue.setValue({
|
|
19
|
-
// schemas,
|
|
20
|
-
// schemaLoading: false,
|
|
21
|
-
// });
|
|
22
|
-
// setLoading(false);
|
|
23
|
-
// }, [contextValue, schemaStore]);
|
|
24
|
-
// if (loading) {
|
|
25
|
-
// return null;
|
|
26
|
-
// }
|
|
27
33
|
return ((0, jsx_runtime_1.jsx)(context_2.MetadataContext.Provider, { value: contextValue, children: children }));
|
|
28
34
|
};
|
|
29
35
|
exports.MetadataProvider = MetadataProvider;
|
package/metadata/context.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AppExperience } from '@headless-adminapp/core/experience/app';
|
|
2
|
+
import type { ISchemaExperienceStore, ISchemaStore } from '@headless-adminapp/core/store';
|
|
2
3
|
export interface MetadataContextState {
|
|
3
|
-
appStore: IClientAppStore;
|
|
4
4
|
schemaStore: ISchemaStore;
|
|
5
5
|
experienceStore: ISchemaExperienceStore;
|
|
6
|
+
appExperience: AppExperience;
|
|
6
7
|
}
|
|
7
8
|
export declare const MetadataContext: import("react").Context<import("../mutable/context").ContextValue<MetadataContextState>>;
|
package/metadata/hooks/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./useAppExperience"), exports);
|
|
18
18
|
__exportStar(require("./useExperienceStore"), exports);
|
|
19
19
|
__exportStar(require("./useExperienceView"), exports);
|
|
20
20
|
__exportStar(require("./useExperienceViewCommands"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useAppExperience(): import("@headless-adminapp/core/experience/app").AppExperience;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAppExperience = useAppExperience;
|
|
4
|
+
const context_1 = require("../../mutable/context");
|
|
5
|
+
const context_2 = require("../context");
|
|
6
|
+
function useAppExperience() {
|
|
7
|
+
return (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.appExperience);
|
|
8
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function useAppExperience(): import("@headless-adminapp/core/experience/app").AppExperience;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useAppExperience = useAppExperience;
|
|
4
4
|
const context_1 = require("../../mutable/context");
|
|
5
5
|
const context_2 = require("../context");
|
|
6
|
-
function
|
|
7
|
-
return (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.
|
|
6
|
+
function useAppExperience() {
|
|
7
|
+
return (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.app);
|
|
8
8
|
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.useExperienceView = useExperienceView;
|
|
13
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
@@ -22,12 +13,12 @@ function useExperienceView(logicalName, viewId, associated, viewIds) {
|
|
|
22
13
|
associated,
|
|
23
14
|
viewIds,
|
|
24
15
|
],
|
|
25
|
-
queryFn: () =>
|
|
16
|
+
queryFn: async () => {
|
|
26
17
|
if (associated) {
|
|
27
18
|
return experienceStore.getAssociatedView(logicalName, viewId, viewIds);
|
|
28
19
|
}
|
|
29
20
|
return experienceStore.getPublicView(logicalName, viewId, viewIds);
|
|
30
|
-
}
|
|
21
|
+
},
|
|
31
22
|
placeholderData: react_query_1.keepPreviousData,
|
|
32
23
|
});
|
|
33
24
|
return {
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.useExperienceViewCommands = useExperienceViewCommands;
|
|
13
4
|
const app_1 = require("@headless-adminapp/app/app");
|
|
@@ -16,16 +7,16 @@ const useExperienceStore_1 = require("./useExperienceStore");
|
|
|
16
7
|
/** @todo move in different dir */
|
|
17
8
|
function useExperienceViewCommands(logicalName) {
|
|
18
9
|
const experienceStore = (0, useExperienceStore_1.useExperienceStore)();
|
|
19
|
-
const {
|
|
10
|
+
const { appExperience: { viewCommands }, } = (0, app_1.useAppContext)();
|
|
20
11
|
const { data: commands } = (0, react_query_1.useQuery)({
|
|
21
12
|
queryKey: ['experience-schema-view-commands', logicalName],
|
|
22
|
-
queryFn: () =>
|
|
23
|
-
let commands =
|
|
13
|
+
queryFn: async () => {
|
|
14
|
+
let commands = await experienceStore.getViewCommands(logicalName);
|
|
24
15
|
if (!commands) {
|
|
25
16
|
commands = viewCommands;
|
|
26
17
|
}
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
18
|
+
return commands ?? [];
|
|
19
|
+
},
|
|
29
20
|
initialData: [],
|
|
30
21
|
});
|
|
31
22
|
return {
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.useExperienceViewLookup = useExperienceViewLookup;
|
|
13
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
@@ -22,12 +13,12 @@ function useExperienceViewLookup(logicalName, associated, viewIds) {
|
|
|
22
13
|
associated,
|
|
23
14
|
viewIds,
|
|
24
15
|
],
|
|
25
|
-
queryFn: () =>
|
|
16
|
+
queryFn: async () => {
|
|
26
17
|
if (associated) {
|
|
27
18
|
return experienceStore.getAssociatedViewLookup(logicalName, viewIds);
|
|
28
19
|
}
|
|
29
20
|
return experienceStore.getPublicViewLookup(logicalName, viewIds);
|
|
30
|
-
}
|
|
21
|
+
},
|
|
31
22
|
initialData: [],
|
|
32
23
|
});
|
|
33
24
|
return {
|