@headless-adminapp/fluent 1.1.0 → 1.1.2

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/AppUI.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AppUI = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_components_1 = require("@fluentui/react-components");
5
6
  const hooks_1 = require("@headless-adminapp/app/hooks");
6
7
  const react_1 = require("react");
7
8
  const AppHeaderContianer_1 = require("./AppHeaderContianer");
@@ -18,7 +19,12 @@ const AppUI = ({ children }) => {
18
19
  flexDirection: 'column',
19
20
  position: 'fixed',
20
21
  inset: 0,
21
- }, children: [(0, jsx_runtime_1.jsx)(AppHeaderContianer_1.AppHeaderContainer, { onNavToggle: () => setIsNavOpen(!isNavOpen) }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flex: 1, overflow: 'hidden' }, children: [(0, jsx_runtime_1.jsx)(Navigation_1.NavigationContainer, { open: isNavOpen, type: navType, onOpenChange: (open) => setIsNavOpen(open) }), (0, jsx_runtime_1.jsx)("div", { style: {
22
+ }, children: [(0, jsx_runtime_1.jsx)(AppHeaderContianer_1.AppHeaderContainer, { onNavToggle: () => setIsNavOpen(!isNavOpen) }), (0, jsx_runtime_1.jsxs)("div", { style: {
23
+ display: 'flex',
24
+ flex: 1,
25
+ overflow: 'hidden',
26
+ background: react_components_1.tokens.colorNeutralBackground1,
27
+ }, children: [(0, jsx_runtime_1.jsx)(Navigation_1.NavigationContainer, { open: isNavOpen, type: navType, onOpenChange: (open) => setIsNavOpen(open) }), (0, jsx_runtime_1.jsx)("div", { style: {
22
28
  display: 'flex',
23
29
  flexDirection: 'column',
24
30
  flex: 1,
@@ -2,6 +2,7 @@ import { PropsWithChildren } from 'react';
2
2
  interface SectionControlWrapperProps {
3
3
  label: string;
4
4
  labelPosition?: 'top' | 'left';
5
+ labelHidden?: boolean;
5
6
  required?: boolean;
6
7
  isError?: boolean;
7
8
  errorMessage?: string;
@@ -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, 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
- return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: label, 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) => {
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(getDisplayValue(value));
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(getDisplayValue(newValue));
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.0",
3
+ "version": "1.1.2",
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": "a244ac890d3abda779c8f41c3cd51031381c062c"
53
+ "gitHead": "8d492b1b7266fbb8bba1124a8dc51311f54f8fcb"
54
54
  }