@headless-adminapp/fluent 0.0.17-alpha.57 → 0.0.17-alpha.61
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/AppHeaderContianer.js +10 -1
- package/DataGrid/useTableColumns.js +14 -0
- package/DialogContainer/PromptDialog.d.ts +12 -2
- package/DialogContainer/PromptDialog.js +19 -9
- package/PageEntityForm/RecordAvatar.js +5 -1
- package/PageEntityForm/SectionContainer.d.ts +1 -1
- package/PageEntityForm/SectionContainer.js +38 -4
- package/PageEntityForm/StandardControl.d.ts +0 -1
- package/PageEntityForm/StandardControl.js +5 -4
- package/PageEntityForm/UploadImageDialog.js +3 -0
- package/form/controls/AttachmentControl.d.ts +2 -2
- package/form/controls/EmailControl.d.ts +1 -1
- package/form/controls/EmailControl.js +1 -1
- package/form/controls/TelephoneControl.d.ts +1 -1
- package/form/controls/TelephoneControl.js +24 -2
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ const hooks_1 = require("@headless-adminapp/app/auth/hooks");
|
|
|
9
9
|
const useIsSkipAuthCheck_1 = require("@headless-adminapp/app/auth/hooks/useIsSkipAuthCheck");
|
|
10
10
|
const hooks_2 = require("@headless-adminapp/app/hooks");
|
|
11
11
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
12
|
+
const route_1 = require("@headless-adminapp/app/route");
|
|
12
13
|
const icons_1 = require("@headless-adminapp/icons");
|
|
13
14
|
const react_1 = require("react");
|
|
14
15
|
const AppLogo_1 = require("./AppLogo");
|
|
@@ -31,6 +32,7 @@ const AppHeaderContainer = ({ onNavToggle, }) => {
|
|
|
31
32
|
}, [authSession?.fullName]);
|
|
32
33
|
const quickActionItems = (0, hooks_2.useItemsWithKey)(app.quickActionItems);
|
|
33
34
|
const accountMenuItems = (0, hooks_2.useItemsWithKey)(app.accountMenuItems);
|
|
35
|
+
const router = (0, route_1.useRouter)();
|
|
34
36
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
35
37
|
display: 'flex',
|
|
36
38
|
alignItems: 'center',
|
|
@@ -69,7 +71,14 @@ const AppHeaderContainer = ({ onNavToggle, }) => {
|
|
|
69
71
|
flex: 1,
|
|
70
72
|
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1Strong, { children: authSession?.fullName }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { textOverflow: 'ellipsis', overflow: 'hidden' }, children: authSession?.email })] })] })), !isSkipAuthCheck && (0, jsx_runtime_1.jsx)(react_components_1.MenuDivider, { style: { marginInline: 0 } }), (0, jsx_runtime_1.jsxs)(react_components_1.MenuList, { style: { width: 200, marginBottom: 4 }, children: [accountMenuItems?.map((item) => {
|
|
71
73
|
const Icon = item.icon;
|
|
72
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(Icon, { size: "inherit" }), onClick: () =>
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(Icon, { size: "inherit" }), onClick: () => {
|
|
75
|
+
if (item.onClick) {
|
|
76
|
+
item.onClick();
|
|
77
|
+
}
|
|
78
|
+
else if (item.link) {
|
|
79
|
+
router.push(item.link);
|
|
80
|
+
}
|
|
81
|
+
}, children: item.localizedLabel?.[language] ?? item.label }, item.__key));
|
|
73
82
|
}), !isSkipAuthCheck && ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.SignOut, {}), onClick: () => logout(), children: strings.logout }))] })] })] }))] })] }));
|
|
74
83
|
};
|
|
75
84
|
exports.AppHeaderContainer = AppHeaderContainer;
|
|
@@ -13,6 +13,7 @@ const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
|
13
13
|
const hooks_4 = require("@headless-adminapp/app/recordset/hooks");
|
|
14
14
|
const hooks_5 = require("@headless-adminapp/app/route/hooks");
|
|
15
15
|
const utils_1 = require("@headless-adminapp/app/utils");
|
|
16
|
+
const phone_1 = require("@headless-adminapp/app/utils/phone");
|
|
16
17
|
const app_1 = require("@headless-adminapp/core/experience/app");
|
|
17
18
|
const react_table_1 = require("@tanstack/react-table");
|
|
18
19
|
const react_1 = require("react");
|
|
@@ -264,6 +265,7 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
264
265
|
currencyDisplay: currency.currencyDisplay,
|
|
265
266
|
currencySign: currency.currencySign,
|
|
266
267
|
locale: locale.locale,
|
|
268
|
+
region: locale.region,
|
|
267
269
|
}) ?? '';
|
|
268
270
|
if (column.plainText) {
|
|
269
271
|
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
@@ -311,6 +313,18 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
311
313
|
case 'choice':
|
|
312
314
|
return ((0, jsx_runtime_1.jsx)(TableCellChoice_1.TableCellChoice, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
|
|
313
315
|
}
|
|
316
|
+
if (attribute.type === 'string' && attribute.format === 'phone') {
|
|
317
|
+
const parsedNumber = (0, phone_1.parsePhoneNumber)(value, locale.region);
|
|
318
|
+
if (parsedNumber.isValid && parsedNumber.uri) {
|
|
319
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: parsedNumber.uri }, column.id));
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (attribute.type === 'string' &&
|
|
323
|
+
attribute.format === 'email' &&
|
|
324
|
+
value &&
|
|
325
|
+
typeof value === 'string') {
|
|
326
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: `mailto:${value}` }, column.id));
|
|
327
|
+
}
|
|
314
328
|
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
315
329
|
}
|
|
316
330
|
function renderPrimaryAttribute({ info, column, schema, routeResolver, openRecord, value, }) {
|
|
@@ -15,12 +15,22 @@ interface PromptDialogProps<SA extends SchemaAttributes = SchemaAttributes> {
|
|
|
15
15
|
onDismiss?: PromptDialogOptions<SA>['onDismiss'];
|
|
16
16
|
}
|
|
17
17
|
export declare function PromptDialog(props: PromptDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export declare const formValidator: (<A extends SchemaAttributes = SchemaAttributes>(attributes
|
|
18
|
+
export declare const formValidator: (<A extends SchemaAttributes = SchemaAttributes>({ attributes, language, strings, region, }: {
|
|
19
|
+
attributes: A;
|
|
20
|
+
language: string;
|
|
21
|
+
strings: FormValidationStringSet;
|
|
22
|
+
region: string;
|
|
23
|
+
}) => (values: Record<string, any>, context: any, options: any) => Promise<import("react-hook-form").ResolverResult<{
|
|
19
24
|
[x: string]: any;
|
|
20
25
|
[x: number]: any;
|
|
21
26
|
[x: symbol]: any;
|
|
22
27
|
}>>) & import("lodash").MemoizedFunction;
|
|
23
|
-
export declare const generateValidationSchema: (<A extends SchemaAttributes = SchemaAttributes>(attributes
|
|
28
|
+
export declare const generateValidationSchema: (<A extends SchemaAttributes = SchemaAttributes>({ attributes, language, strings, region, }: {
|
|
29
|
+
attributes: A;
|
|
30
|
+
language: string;
|
|
31
|
+
strings: FormValidationStringSet;
|
|
32
|
+
region: string;
|
|
33
|
+
}) => yup.ObjectSchema<{
|
|
24
34
|
[x: string]: any;
|
|
25
35
|
}, yup.AnyObject, {
|
|
26
36
|
[x: string]: any;
|
|
@@ -37,13 +37,18 @@ const yup = __importStar(require("yup"));
|
|
|
37
37
|
const SectionControl_1 = require("../DataForm/SectionControl");
|
|
38
38
|
const StandardControl_1 = require("../PageEntityForm/StandardControl");
|
|
39
39
|
function PromptDialog(props) {
|
|
40
|
-
const { language } = (0, locale_1.useLocale)();
|
|
40
|
+
const { language, region } = (0, locale_1.useLocale)();
|
|
41
41
|
const formValidationStrings = (0, form_1.useFormValidationStrings)();
|
|
42
42
|
const form = (0, react_hook_form_1.useForm)({
|
|
43
43
|
mode: 'all',
|
|
44
44
|
defaultValues: props.defaultValues,
|
|
45
45
|
shouldUnregister: false,
|
|
46
|
-
resolver: (0, exports.formValidator)(
|
|
46
|
+
resolver: (0, exports.formValidator)({
|
|
47
|
+
attributes: props.attributes,
|
|
48
|
+
language,
|
|
49
|
+
strings: formValidationStrings,
|
|
50
|
+
region,
|
|
51
|
+
}),
|
|
47
52
|
});
|
|
48
53
|
return ((0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: props.open, onOpenChange: () => {
|
|
49
54
|
props.onDismiss?.();
|
|
@@ -60,7 +65,7 @@ function PromptDialog(props) {
|
|
|
60
65
|
const errorMessage = fieldState.isTouched || formState.isSubmitted
|
|
61
66
|
? fieldState.error?.message
|
|
62
67
|
: '';
|
|
63
|
-
return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: attribute.label, labelPosition: "left", required: attribute.required, isError: isError, errorMessage: errorMessage, children: (0, jsx_runtime_1.jsx)(StandardControl_1.StandardControl, { attribute: attribute, name: attributeName, value: field.value, onChange: field.onChange, onBlur: field.onBlur, errorMessage: errorMessage, isError: isError }) }));
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: attribute.label, labelPosition: "left", required: attribute.required, isError: isError, errorMessage: errorMessage, children: (0, jsx_runtime_1.jsx)(StandardControl_1.StandardControl, { attribute: attribute, name: attributeName, value: field.value, onChange: field.onChange, onBlur: field.onBlur, errorMessage: errorMessage, isError: isError, readOnly: attribute.readonly }) }));
|
|
64
69
|
} }, attributeName));
|
|
65
70
|
}) })] }), (0, jsx_runtime_1.jsxs)(react_components_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "secondary", type: "button", onClick: () => {
|
|
66
71
|
props.onCancel?.();
|
|
@@ -70,24 +75,29 @@ function PromptDialog(props) {
|
|
|
70
75
|
})();
|
|
71
76
|
}, children: props.confirmText ?? 'Confirm' })] })] }) }) }));
|
|
72
77
|
}
|
|
73
|
-
exports.formValidator = (0, lodash_1.memoize)(function formValidator(attributes, language, strings) {
|
|
78
|
+
exports.formValidator = (0, lodash_1.memoize)(function formValidator({ attributes, language, strings, region, }) {
|
|
74
79
|
return async (values, context, options) => {
|
|
75
|
-
const validator = (0, exports.generateValidationSchema)(
|
|
80
|
+
const validator = (0, exports.generateValidationSchema)({
|
|
81
|
+
attributes,
|
|
82
|
+
language,
|
|
83
|
+
strings,
|
|
84
|
+
region,
|
|
85
|
+
});
|
|
76
86
|
const resolver = (0, yup_1.yupResolver)(validator);
|
|
77
87
|
const result = await resolver(values, context, options);
|
|
78
88
|
return result;
|
|
79
89
|
};
|
|
80
|
-
}, (
|
|
81
|
-
exports.generateValidationSchema = (0, lodash_1.memoize)(function generateValidationSchema(attributes, language, strings) {
|
|
90
|
+
}, (options) => JSON.stringify(options));
|
|
91
|
+
exports.generateValidationSchema = (0, lodash_1.memoize)(function generateValidationSchema({ attributes, language, strings, region, }) {
|
|
82
92
|
const columns = Object.keys(attributes);
|
|
83
93
|
return yup.object().shape({
|
|
84
94
|
...columns.reduce((acc, column) => {
|
|
85
95
|
const attribute = attributes[column];
|
|
86
|
-
const validationSchema = (0, utils_1.generateAttributeValidationSchema)(attribute, language, strings);
|
|
96
|
+
const validationSchema = (0, utils_1.generateAttributeValidationSchema)(attribute, language, strings, region);
|
|
87
97
|
return {
|
|
88
98
|
...acc,
|
|
89
99
|
[column]: validationSchema,
|
|
90
100
|
};
|
|
91
101
|
}, {}),
|
|
92
102
|
});
|
|
93
|
-
}, (
|
|
103
|
+
}, (options) => JSON.stringify(options));
|
|
@@ -23,6 +23,7 @@ const RecordAvatar = () => {
|
|
|
23
23
|
const dataService = (0, transport_1.useDataService)();
|
|
24
24
|
const refresh = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.refresh);
|
|
25
25
|
const [showAvatarChangeDialog, setShowAvatarChangeDialog] = (0, react_1.useState)(false);
|
|
26
|
+
const fileService = (0, transport_1.useFileService)();
|
|
26
27
|
const { showProgressIndicator, hideProgressIndicator } = (0, progress_indicator_1.useProgressIndicator)();
|
|
27
28
|
const openErrorDialog = (0, dialog_1.useOpenErrorDialog)();
|
|
28
29
|
if (!schema.avatarAttribute) {
|
|
@@ -73,7 +74,10 @@ const RecordAvatar = () => {
|
|
|
73
74
|
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: { width: 36, height: 36 }, name: recordTitle, color: (0, avatar_1.getAvatarColor)(recordTitle), image: {
|
|
74
75
|
src: value?.url,
|
|
75
76
|
}, onClick: () => {
|
|
77
|
+
if (!fileService) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
76
80
|
setShowAvatarChangeDialog(true);
|
|
77
|
-
} }), !!recordId && ((0, jsx_runtime_1.jsx)(UploadImageDialog_1.UploadImageDialog, { recordTitle: recordTitle, currentImage: value, onChange: handleChange, recordId: recordId, open: showAvatarChangeDialog, onOpenChange: (open) => setShowAvatarChangeDialog(open) }))] }));
|
|
81
|
+
} }), !!recordId && !!fileService && ((0, jsx_runtime_1.jsx)(UploadImageDialog_1.UploadImageDialog, { recordTitle: recordTitle, currentImage: value, onChange: handleChange, recordId: recordId, open: showAvatarChangeDialog, onOpenChange: (open) => setShowAvatarChangeDialog(open) }))] }));
|
|
78
82
|
};
|
|
79
83
|
exports.RecordAvatar = RecordAvatar;
|
|
@@ -3,4 +3,4 @@ import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
|
3
3
|
export declare function SectionContainer<S extends SchemaAttributes = SchemaAttributes>({ section }: {
|
|
4
4
|
section: Section<S>;
|
|
5
5
|
readOnly: boolean;
|
|
6
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SectionContainer = SectionContainer;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const dataform_1 = require("@headless-adminapp/app/dataform");
|
|
6
|
+
const constants_1 = require("@headless-adminapp/app/dataform/constants");
|
|
7
|
+
const utils_1 = require("@headless-adminapp/app/dataform/DataFormProvider/utils");
|
|
5
8
|
const hooks_1 = require("@headless-adminapp/app/dataform/hooks");
|
|
9
|
+
const useEventManager_1 = require("@headless-adminapp/app/dataform/hooks/useEventManager");
|
|
6
10
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
7
|
-
const
|
|
11
|
+
const utils_2 = require("@headless-adminapp/app/locale/utils");
|
|
12
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
13
|
+
const react_1 = require("react");
|
|
8
14
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
15
|
const componentStore_1 = require("../componentStore");
|
|
10
16
|
const SectionControl_1 = require("../DataForm/SectionControl");
|
|
@@ -15,9 +21,23 @@ function SectionContainer({ section }) {
|
|
|
15
21
|
const schema = (0, hooks_1.useDataFormSchema)();
|
|
16
22
|
const formInstance = (0, hooks_1.useFormInstance)();
|
|
17
23
|
const recordId = (0, hooks_1.useRecordId)();
|
|
18
|
-
const
|
|
24
|
+
const isFormReadonly = (0, hooks_1.useFormIsReadonly)();
|
|
19
25
|
const { language } = (0, locale_1.useLocale)();
|
|
20
|
-
|
|
26
|
+
const eventManager = (0, useEventManager_1.useEventManager)();
|
|
27
|
+
const disabledControls = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.disabledControls);
|
|
28
|
+
const hiddenControls = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.hiddenControls);
|
|
29
|
+
const requiredFields = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.requiredFields);
|
|
30
|
+
const hiddenSections = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.hiddenSections);
|
|
31
|
+
const visibleControls = (0, react_1.useMemo)(() => section.controls.filter((control) => {
|
|
32
|
+
return !(0, utils_1.getIsControlHidden)({
|
|
33
|
+
control,
|
|
34
|
+
hiddenControls,
|
|
35
|
+
});
|
|
36
|
+
}), [section.controls, hiddenControls]);
|
|
37
|
+
if (hiddenSections[section.name] || visibleControls.length === 0) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(layout_1.FormSection, { title: (0, utils_2.localizedLabel)(language, section), columnCount: section.columnCount, labelPosition: section.labelPosition, noPadding: section.noPadding, hideLabel: section.hideLabel, children: visibleControls.map((control, index) => {
|
|
21
41
|
switch (control.type) {
|
|
22
42
|
case 'standard': {
|
|
23
43
|
const attribute = schema.attributes[control.attributeName];
|
|
@@ -28,6 +48,17 @@ function SectionContainer({ section }) {
|
|
|
28
48
|
Control = OverrideControl;
|
|
29
49
|
}
|
|
30
50
|
}
|
|
51
|
+
const disabled = (0, utils_1.getIsFieldDisabled)({
|
|
52
|
+
isFormReadonly,
|
|
53
|
+
disabledFields: disabledControls,
|
|
54
|
+
attribute,
|
|
55
|
+
control,
|
|
56
|
+
});
|
|
57
|
+
const required = (0, utils_1.getIsFieldRequired)({
|
|
58
|
+
attribute,
|
|
59
|
+
requiredFields,
|
|
60
|
+
control,
|
|
61
|
+
});
|
|
31
62
|
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
32
63
|
gridColumn: control.span
|
|
33
64
|
? `var(--section-item-span-${control.span})`
|
|
@@ -42,7 +73,10 @@ function SectionContainer({ section }) {
|
|
|
42
73
|
attribute.localizedLabels?.[language] ??
|
|
43
74
|
control.label ??
|
|
44
75
|
attribute.label;
|
|
45
|
-
return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: label, labelPosition: section.labelPosition, required:
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: label, labelPosition: section.labelPosition, required: required, isError: isError, errorMessage: errorMessage, children: (0, jsx_runtime_1.jsx)(Control, { attribute: attribute, name: control.attributeName, value: field.value, onChange: (value) => {
|
|
77
|
+
field.onChange(value);
|
|
78
|
+
eventManager.emit(constants_1.EVENT_KEY_ON_FIELD_CHANGE, control.attributeName, value);
|
|
79
|
+
}, onBlur: field.onBlur, errorMessage: errorMessage, isError: isError, readOnly: disabled, label: label, placeholder: label, allowNavigation: true, allowNewRecord: true, fileServiceContext: {
|
|
46
80
|
type: 'entity-form',
|
|
47
81
|
recordId,
|
|
48
82
|
attributeName: control.attributeName,
|
|
@@ -35,12 +35,12 @@ const StandardControl = (props) => {
|
|
|
35
35
|
name, value, onBlur, onChange,
|
|
36
36
|
// dataService,
|
|
37
37
|
// fileService,
|
|
38
|
-
|
|
38
|
+
borderOnFocusOnly, placeholder: _placeholder,
|
|
39
39
|
// hideLabel,
|
|
40
40
|
hidePlaceholder, readOnly,
|
|
41
41
|
// quickViewControl,
|
|
42
42
|
allowNavigation, allowNewRecord, } = props;
|
|
43
|
-
const isDisabled =
|
|
43
|
+
const isDisabled = readOnly;
|
|
44
44
|
// const label = hideLabel ? undefined : _label ?? attribute.label;
|
|
45
45
|
const placeholder = hidePlaceholder
|
|
46
46
|
? undefined
|
|
@@ -51,7 +51,7 @@ const StandardControl = (props) => {
|
|
|
51
51
|
const { schemaStore, experienceStore } = (0, hooks_1.useMetadata)();
|
|
52
52
|
// const { openQuickCreate } = useQuickCreateForm();
|
|
53
53
|
switch (attribute.type) {
|
|
54
|
-
case 'string':
|
|
54
|
+
case 'string': {
|
|
55
55
|
const controlProps = {
|
|
56
56
|
name,
|
|
57
57
|
placeholder,
|
|
@@ -59,7 +59,7 @@ const StandardControl = (props) => {
|
|
|
59
59
|
onChange,
|
|
60
60
|
onBlur,
|
|
61
61
|
error: isError,
|
|
62
|
-
disabled:
|
|
62
|
+
disabled: readOnly,
|
|
63
63
|
readOnly,
|
|
64
64
|
};
|
|
65
65
|
switch (attribute.format) {
|
|
@@ -91,6 +91,7 @@ const StandardControl = (props) => {
|
|
|
91
91
|
default:
|
|
92
92
|
return (0, jsx_runtime_1.jsx)(react_1.Fragment, {});
|
|
93
93
|
}
|
|
94
|
+
}
|
|
94
95
|
case 'number': {
|
|
95
96
|
switch (attribute.format) {
|
|
96
97
|
case 'decimal': {
|
|
@@ -38,6 +38,9 @@ const UploadImageDialog = ({ currentImage, recordTitle, recordId, onChange, open
|
|
|
38
38
|
};
|
|
39
39
|
const { isPending, mutate: handleApply } = (0, react_query_1.useMutation)({
|
|
40
40
|
mutationFn: async () => {
|
|
41
|
+
if (!fileService) {
|
|
42
|
+
throw new Error('File service is not available');
|
|
43
|
+
}
|
|
41
44
|
if (file) {
|
|
42
45
|
const url = await fileService.uploadFile(file, {
|
|
43
46
|
context: {
|
|
@@ -13,12 +13,12 @@ export declare function useAttachmentSelector({ fileService, fileServiceContext,
|
|
|
13
13
|
selectFile: (accept: string) => void;
|
|
14
14
|
};
|
|
15
15
|
export interface AttachmentImageControlProps extends ControlProps<FileObject> {
|
|
16
|
-
fileService: IFileService;
|
|
16
|
+
fileService: IFileService | null;
|
|
17
17
|
fileServiceContext?: Record<string, unknown>;
|
|
18
18
|
location: AttachmentAttribute['location'];
|
|
19
19
|
}
|
|
20
20
|
interface AttachmentControlProps extends ControlProps<FileObject> {
|
|
21
|
-
fileService: IFileService;
|
|
21
|
+
fileService: IFileService | null;
|
|
22
22
|
fileServiceContext?: Record<string, unknown>;
|
|
23
23
|
location: AttachmentAttribute['location'];
|
|
24
24
|
format: AttachmentAttribute['format'];
|
|
@@ -3,4 +3,4 @@ export interface EmailControlProps extends ControlProps<string> {
|
|
|
3
3
|
autoComplete?: string;
|
|
4
4
|
textTransform?: 'capitalize' | 'uppercase' | 'lowercase' | 'none';
|
|
5
5
|
}
|
|
6
|
-
export declare function EmailControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, autoComplete, textTransform, readOnly, }: EmailControlProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function EmailControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, autoComplete, textTransform, readOnly, }: Readonly<EmailControlProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,7 +15,7 @@ function EmailControl({ value, onChange, id, name, onBlur, onFocus, placeholder,
|
|
|
15
15
|
: onChange?.(e.target.value);
|
|
16
16
|
}, onBlur: () => onBlur?.(), onFocus: () => onFocus?.(),
|
|
17
17
|
// invalid={error}
|
|
18
|
-
|
|
18
|
+
readOnly: disabled || readOnly, autoComplete: autoComplete, style: {
|
|
19
19
|
flex: 1,
|
|
20
20
|
paddingRight: react_components_1.tokens.spacingHorizontalXS,
|
|
21
21
|
}, contentAfter: !!value ? ((0, jsx_runtime_1.jsx)(react_components_1.Button, { onClick: () => window.open(`mailto:${value}`, '_blank'), color: "primary", appearance: "transparent", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Mail, {}), size: "small" })) : undefined }));
|
|
@@ -2,4 +2,4 @@ import { ControlProps } from './types';
|
|
|
2
2
|
export interface TelephoneControlProps extends ControlProps<string> {
|
|
3
3
|
autoComplete?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function TelephoneControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, autoComplete, }: TelephoneControlProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function TelephoneControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, autoComplete, }: Readonly<TelephoneControlProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,14 +3,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TelephoneControl = TelephoneControl;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
7
|
+
const phone_1 = require("@headless-adminapp/app/utils/phone");
|
|
6
8
|
const icons_1 = require("@headless-adminapp/icons");
|
|
9
|
+
const react_1 = require("react");
|
|
7
10
|
function TelephoneControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, autoComplete, }) {
|
|
8
|
-
|
|
11
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)('');
|
|
12
|
+
const { region } = (0, locale_1.useLocale)();
|
|
13
|
+
const number = (0, react_1.useMemo)(() => {
|
|
14
|
+
if (!value) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return (0, phone_1.parsePhoneNumber)(value, region);
|
|
18
|
+
}, [value, region]);
|
|
19
|
+
(0, react_1.useEffect)(() => {
|
|
20
|
+
setInternalValue(number?.formattedInternationalValue ?? '');
|
|
21
|
+
}, [number]);
|
|
22
|
+
const handleChange = () => {
|
|
23
|
+
const parsedPhoneNumber = (0, phone_1.parsePhoneNumber)(internalValue, region);
|
|
24
|
+
setInternalValue(parsedPhoneNumber.formattedInternationalValue);
|
|
25
|
+
onChange?.(parsedPhoneNumber.rawValue);
|
|
26
|
+
};
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Input, { type: "tel", placeholder: placeholder, id: id, appearance: "filled-darker", name: name, value: internalValue, onChange: (e) => setInternalValue?.(e.target.value), onBlur: () => {
|
|
28
|
+
handleChange();
|
|
29
|
+
onBlur?.();
|
|
30
|
+
}, onFocus: () => onFocus?.(),
|
|
9
31
|
// invalid={error}
|
|
10
32
|
readOnly: disabled || readOnly, autoComplete: autoComplete, style: {
|
|
11
33
|
width: '100%',
|
|
12
34
|
paddingRight: react_components_1.tokens.spacingHorizontalXS,
|
|
13
35
|
},
|
|
14
36
|
// size="sm"
|
|
15
|
-
contentAfter: !!
|
|
37
|
+
contentAfter: !!number?.uri ? ((0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "transparent", size: "small", onClick: () => window.open(number.uri, '_blank'), title: number.uri, icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Phone, {}) })) : undefined }));
|
|
16
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/fluent",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.61",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"uuid": "11.0.3",
|
|
43
43
|
"yup": "^1.4.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "a7c93843f02223313660e422a21db0c2eefb3296"
|
|
46
46
|
}
|