nurseitaly-components 0.0.11 → 0.0.13

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.
@@ -16,6 +16,8 @@ type Props<TFieldValues extends FieldValues = FieldValues, TContext = any, TTran
16
16
  placeholder?: string;
17
17
  options: SelectItem[];
18
18
  required?: boolean;
19
+ /** When false, the empty/placeholder option is not rendered. Defaults to true. */
20
+ allowEmpty?: boolean;
19
21
  showEndAdornment?: boolean;
20
22
  endAdornment?: ReactNode[];
21
23
  defaultEndAdornments?: DefaultEndAdornmentType[];
@@ -23,5 +25,5 @@ type Props<TFieldValues extends FieldValues = FieldValues, TContext = any, TTran
23
25
  onChange?: (attr: string, value: any) => void;
24
26
  infoText?: string;
25
27
  };
26
- export default function SelectField<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>({ className, attr, label, createdForm, disabled, title, placeholder, options, required, endAdornment, defaultEndAdornments, showEndAdornment, onRemove, onChange, infoText, }: Props<TFieldValues, TContext, TTransformedValues>): import("react").JSX.Element;
28
+ export default function SelectField<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>({ className, attr, label, createdForm, disabled, title, placeholder, options, required, allowEmpty, endAdornment, defaultEndAdornments, showEndAdornment, onRemove, onChange, infoText, }: Props<TFieldValues, TContext, TTransformedValues>): import("react").JSX.Element;
27
29
  export {};
@@ -9,7 +9,7 @@ import Icon from '../Icon';
9
9
  import Tooltip from '../Tooltip';
10
10
  import { selectFieldTheme } from './SelectFieldTheme';
11
11
  import './styles.scss';
12
- export default function SelectField({ className, attr, label, createdForm, disabled, title, placeholder, options = [], required, endAdornment, defaultEndAdornments = ['close'], showEndAdornment = true, onRemove, onChange, infoText, }) {
12
+ export default function SelectField({ className, attr, label, createdForm, disabled, title, placeholder, options = [], required, allowEmpty = true, endAdornment, defaultEndAdornments = ['close'], showEndAdornment = true, onRemove, onChange, infoText, }) {
13
13
  const fieldName = attr;
14
14
  const outerTheme = useTheme();
15
15
  const [active, setActive] = useState(false);
@@ -77,5 +77,5 @@ export default function SelectField({ className, attr, label, createdForm, disab
77
77
  backgroundColor: disabled
78
78
  ? '#BEBFC1!important'
79
79
  : '#FFFFFF!important',
80
- } }), children: [_jsx("option", { value: "", children: placeholder || '\u00a0' }), options.map((option, idx) => (_jsx("option", { value: option.value, children: option.label }, idx.valueOf())))] })] }), title && !hasError() && _jsx("div", { className: "helper", children: title }), hasError() && (_jsx("div", { className: "helper error", children: String(createdForm.formState.errors[attr]?.message) }))] })) }) }));
80
+ } }), children: [allowEmpty && (_jsx("option", { value: "", children: placeholder || '\u00a0' })), options.map((option, idx) => (_jsx("option", { value: option.value, children: option.label }, idx.valueOf())))] })] }), title && !hasError() && _jsx("div", { className: "helper", children: title }), hasError() && (_jsx("div", { className: "helper error", children: String(createdForm.formState.errors[attr]?.message) }))] })) }) }));
81
81
  }
@@ -44,7 +44,7 @@ export default function AppForm({ fields, form, prefix, onChangeFunctions = {},
44
44
  if (field.multiple) {
45
45
  return _jsx(SelectMultipleField, { ...selectProps }, name);
46
46
  }
47
- return _jsx(SelectField, { ...selectProps }, name);
47
+ return (_jsx(SelectField, { ...selectProps, allowEmpty: field.allowEmpty }, name));
48
48
  }
49
49
  if (field.type === "check") {
50
50
  return (_jsx(CheckboxField, { attr: name, label: field.name, createdForm: form, disabled: field.disabled }, name));
@@ -34,6 +34,7 @@ export type AppFormField = {
34
34
  display?: DisplayFunction;
35
35
  copyToClipboard?: boolean;
36
36
  truncate?: number;
37
+ allowEmpty?: boolean;
37
38
  /** Flex-grow weight when sharing a row with adjacent flex fields. Omit for full-width. */
38
39
  flexGrow?: number;
39
40
  /** Optional flex-basis (default: 0 for even ratio distribution). */
@@ -0,0 +1,2 @@
1
+ /** Registers CommonContext.dispatch for non-React callers (e.g. axios interceptors). */
2
+ export default function CommonDispatchBridge(): null;
@@ -0,0 +1,12 @@
1
+ import { useContext, useEffect } from 'react';
2
+ import CommonContext from './CommonContext';
3
+ import { registerCommonDispatch } from './commonDispatch';
4
+ /** Registers CommonContext.dispatch for non-React callers (e.g. axios interceptors). */
5
+ export default function CommonDispatchBridge() {
6
+ const { dispatch } = useContext(CommonContext);
7
+ useEffect(() => {
8
+ registerCommonDispatch(dispatch);
9
+ return () => registerCommonDispatch(() => undefined);
10
+ }, [dispatch]);
11
+ return null;
12
+ }
@@ -0,0 +1,5 @@
1
+ import type { SessionAction } from './sessionTypes';
2
+ type CommonDispatch = (action: SessionAction) => void;
3
+ export declare function registerCommonDispatch(dispatch: CommonDispatch): void;
4
+ export declare function getCommonDispatch(): CommonDispatch | null;
5
+ export {};
@@ -0,0 +1,7 @@
1
+ let commonDispatch = null;
2
+ export function registerCommonDispatch(dispatch) {
3
+ commonDispatch = dispatch;
4
+ }
5
+ export function getCommonDispatch() {
6
+ return commonDispatch;
7
+ }
@@ -1,4 +1,6 @@
1
1
  export { default as CommonContext, CommonProvider } from './CommonContext';
2
+ export { default as CommonDispatchBridge } from './CommonDispatchBridge';
3
+ export { getCommonDispatch, registerCommonDispatch, } from './commonDispatch';
2
4
  export { default as CookieStorage } from './CookieStorage';
3
5
  export { commonLocalization, commonResources, featureResources, mergeResources, } from './Localization';
4
6
  export { default as ProfileService } from './services/ProfileService';
@@ -1,4 +1,6 @@
1
1
  export { default as CommonContext, CommonProvider } from './CommonContext';
2
+ export { default as CommonDispatchBridge } from './CommonDispatchBridge';
3
+ export { getCommonDispatch, registerCommonDispatch, } from './commonDispatch';
2
4
  export { default as CookieStorage } from './CookieStorage';
3
5
  export { commonLocalization, commonResources, featureResources, mergeResources, } from './Localization';
4
6
  export { default as ProfileService } from './services/ProfileService';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nurseitaly-components",
3
3
  "private": false,
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {