@headless-adminapp/fluent 1.1.1 → 1.1.3
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/DataForm/SectionControl.d.ts +1 -0
- package/DataForm/SectionControl.js +1 -1
- package/PageEntityForm/SectionContainer.js +2 -1
- package/form/controls/AttachmentControl.d.ts +1 -1
- package/form/controls/AttachmentControl.js +2 -2
- package/form/controls/DurationControl.js +3 -36
- package/package.json +2 -2
|
@@ -4,5 +4,5 @@ exports.SectionControlWrapper = SectionControlWrapper;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
function SectionControlWrapper(props) {
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.Field, { label: props.label, orientation: props.labelPosition === 'top' ? 'vertical' : 'horizontal', required: props.required, validationState: props.isError ? 'error' : undefined, validationMessage: props.errorMessage, validationMessageIcon: null, children: props.children }));
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Field, { label: props.labelHidden ? undefined : props.label, orientation: props.labelPosition === 'top' ? 'vertical' : 'horizontal', required: props.labelHidden ? undefined : props.required, validationState: props.isError ? 'error' : undefined, validationMessage: props.errorMessage, validationMessageIcon: null, style: { paddingLeft: props.labelHidden ? 0 : undefined }, children: props.children }));
|
|
8
8
|
}
|
|
@@ -84,7 +84,8 @@ function SectionContainer({ section }) {
|
|
|
84
84
|
attribute.localizedLabels?.[language] ??
|
|
85
85
|
control.label ??
|
|
86
86
|
attribute.label;
|
|
87
|
-
|
|
87
|
+
const labelHidden = control.labelHidden;
|
|
88
|
+
return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: label, labelHidden: labelHidden, labelPosition: isMobile ? 'top' : 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) => {
|
|
88
89
|
const previousValue = field.value;
|
|
89
90
|
field.onChange(value);
|
|
90
91
|
eventManager.emit(constants_1.EVENT_KEY_ON_FIELD_CHANGE, control.attributeName, value, previousValue);
|
|
@@ -6,7 +6,7 @@ interface UseAttachmentSelectorOptions {
|
|
|
6
6
|
fileService: IFileService | null;
|
|
7
7
|
fileServiceContext?: Record<string, unknown>;
|
|
8
8
|
location: AttachmentAttribute['location'];
|
|
9
|
-
onChange?: (fileObject: FileObject) => void
|
|
9
|
+
onChange?: (fileObject: FileObject) => void | Promise<void>;
|
|
10
10
|
}
|
|
11
11
|
export declare function useAttachmentSelector({ fileService, fileServiceContext, location, onChange, }: UseAttachmentSelectorOptions): {
|
|
12
12
|
isProcessing: boolean;
|
|
@@ -26,8 +26,8 @@ function useAttachmentSelector({ fileService, fileServiceContext, location, onCh
|
|
|
26
26
|
return (0, utils_1.urlToFileObject)(url);
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
onSuccess: (fileObject) => {
|
|
30
|
-
onChange?.(fileObject);
|
|
29
|
+
onSuccess: async (fileObject) => {
|
|
30
|
+
await onChange?.(fileObject);
|
|
31
31
|
},
|
|
32
32
|
onError: (error) => {
|
|
33
33
|
console.error(error);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DurationControl = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const utils_1 = require("@headless-adminapp/app/utils");
|
|
6
7
|
const react_1 = require("react");
|
|
7
8
|
const useStyles = (0, react_components_1.makeStyles)({
|
|
8
9
|
listbox: {
|
|
@@ -105,7 +106,7 @@ const DurationControl = ({ value, onChange, id, name, onBlur, onFocus, placehold
|
|
|
105
106
|
const [filterEnabled, setFilterEnabled] = (0, react_1.useState)(false);
|
|
106
107
|
const styles = useStyles();
|
|
107
108
|
(0, react_1.useEffect)(() => {
|
|
108
|
-
setSearchText(
|
|
109
|
+
setSearchText((0, utils_1.formatDuration)(value));
|
|
109
110
|
}, [value]);
|
|
110
111
|
const filteredItems = (0, react_1.useMemo)(() => {
|
|
111
112
|
if (!filterEnabled) {
|
|
@@ -124,7 +125,7 @@ const DurationControl = ({ value, onChange, id, name, onBlur, onFocus, placehold
|
|
|
124
125
|
if (newValue !== null) {
|
|
125
126
|
onChange?.(newValue);
|
|
126
127
|
}
|
|
127
|
-
setSearchText(
|
|
128
|
+
setSearchText((0, utils_1.formatDuration)(newValue));
|
|
128
129
|
setFilterEnabled(false);
|
|
129
130
|
onBlur?.();
|
|
130
131
|
}, onFocus: onFocus, id: id, autoFocus: autoFocus, onChange: (e) => {
|
|
@@ -141,40 +142,6 @@ const DurationControl = ({ value, onChange, id, name, onBlur, onFocus, placehold
|
|
|
141
142
|
}, children: filteredItems.map((item) => ((0, jsx_runtime_1.jsx)(react_components_1.Option, { value: item.value, children: item.text }, item.value))) }) }));
|
|
142
143
|
};
|
|
143
144
|
exports.DurationControl = DurationControl;
|
|
144
|
-
function getDisplayValue(value) {
|
|
145
|
-
if (!value) {
|
|
146
|
-
return '';
|
|
147
|
-
}
|
|
148
|
-
// No decimal, if value is decimal, round to nearest whole number
|
|
149
|
-
// 1 - 1 minute
|
|
150
|
-
// 2-59 minutes -> 2-59 minutes
|
|
151
|
-
// 90 minutes -> 1.5 hours
|
|
152
|
-
// more than a day -> 1 day, 1.5 days, 2 days, etc.
|
|
153
|
-
// check if value has decimal
|
|
154
|
-
if (value % 1 !== 0) {
|
|
155
|
-
// round to nearest whole number
|
|
156
|
-
value = Math.round(value);
|
|
157
|
-
}
|
|
158
|
-
if (!value) {
|
|
159
|
-
return '';
|
|
160
|
-
}
|
|
161
|
-
if (value === 1) {
|
|
162
|
-
return '1 minute';
|
|
163
|
-
}
|
|
164
|
-
if (value < 60) {
|
|
165
|
-
return `${value} minutes`;
|
|
166
|
-
}
|
|
167
|
-
if (value === 60) {
|
|
168
|
-
return '1 hour';
|
|
169
|
-
}
|
|
170
|
-
if (value < 1440) {
|
|
171
|
-
return `${Number((value / 60).toFixed(2))} hours`;
|
|
172
|
-
}
|
|
173
|
-
if (value === 1440) {
|
|
174
|
-
return '1 day';
|
|
175
|
-
}
|
|
176
|
-
return `${Number((value / 1440).toFixed(2))} days`;
|
|
177
|
-
}
|
|
178
145
|
function resolveValue(value) {
|
|
179
146
|
if (!value) {
|
|
180
147
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/fluent",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"uuid": "11.0.3",
|
|
51
51
|
"yup": "^1.4.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "3a036d597b19d9ef7571b2d206ecb362b74d5228"
|
|
54
54
|
}
|