@alveole/components 1.8.1 → 1.8.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.
Files changed (65) hide show
  1. package/dist/generated/version.d.ts +1 -1
  2. package/dist/generated/version.js +1 -1
  3. package/dist/ui/Autocomplete/Autocomplete.js +1 -1
  4. package/dist/ui/Autocomplete/Autocomplete.stories.d.ts +2 -10
  5. package/dist/ui/Autocomplete/Autocomplete.stories.d.ts.map +1 -1
  6. package/dist/ui/Autocomplete/Autocomplete.styles.d.ts +2 -10
  7. package/dist/ui/Autocomplete/Autocomplete.styles.d.ts.map +1 -1
  8. package/dist/ui/Autocomplete/Autocomplete.styles.js +2 -10
  9. package/dist/ui/Autocomplete/Autocomplete.web.d.ts.map +1 -1
  10. package/dist/ui/Autocomplete/Autocomplete.web.js +15 -9
  11. package/dist/ui/Checkbox/Checkbox.js +1 -1
  12. package/dist/ui/DateInput/DateInput.ios.js +1 -1
  13. package/dist/ui/DateInput/DateInput.js +1 -1
  14. package/dist/ui/DateInput/DateInput.web.js +1 -1
  15. package/dist/ui/DocumentViewer/DocumentViewer.d.ts +1 -0
  16. package/dist/ui/DocumentViewer/DocumentViewer.d.ts.map +1 -1
  17. package/dist/ui/DocumentViewer/DocumentViewer.js +2 -2
  18. package/dist/ui/DocumentViewer/DocumentViewer.stories.d.ts +11 -0
  19. package/dist/ui/DocumentViewer/DocumentViewer.stories.d.ts.map +1 -1
  20. package/dist/ui/DocumentViewer/DocumentViewer.stories.js +3 -2
  21. package/dist/ui/DocumentViewer/DocumentViewer.stories.sources.d.ts +2 -0
  22. package/dist/ui/DocumentViewer/DocumentViewer.stories.sources.d.ts.map +1 -1
  23. package/dist/ui/DocumentViewer/DocumentViewer.stories.sources.js +4 -2
  24. package/dist/ui/DocumentViewer/DocumentViewer.styles.d.ts +10 -0
  25. package/dist/ui/DocumentViewer/DocumentViewer.styles.d.ts.map +1 -1
  26. package/dist/ui/DocumentViewer/DocumentViewer.styles.js +6 -0
  27. package/dist/ui/DocumentViewer/DocumentViewerPDF.d.ts +1 -0
  28. package/dist/ui/DocumentViewer/DocumentViewerPDF.d.ts.map +1 -1
  29. package/dist/ui/DocumentViewer/DocumentViewerPDF.js +20 -13
  30. package/dist/ui/DocumentViewer/DocumentViewerPDF.native.d.ts +1 -0
  31. package/dist/ui/DocumentViewer/DocumentViewerPDF.native.d.ts.map +1 -1
  32. package/dist/ui/DocumentViewer/DocumentViewerPDF.web.d.ts +1 -0
  33. package/dist/ui/DocumentViewer/DocumentViewerPDF.web.d.ts.map +1 -1
  34. package/dist/ui/DocumentViewer/DocumentViewerPDF.web.js +43 -21
  35. package/dist/ui/DurationInput/DurationInput.js +1 -1
  36. package/dist/ui/EmailField/EmailField.js +1 -1
  37. package/dist/ui/FileField/FileField.js +1 -1
  38. package/dist/ui/FormControl/FormControlDateInput.js +1 -1
  39. package/dist/ui/FormControl/FormControlHint.js +1 -1
  40. package/dist/ui/FormControl/FormControlLabel.js +2 -2
  41. package/dist/ui/FormControl/FormControlNumberInput.js +1 -1
  42. package/dist/ui/LucideIcon/LucideIcon.props.d.ts +162 -0
  43. package/dist/ui/LucideIcon/LucideIcon.props.d.ts.map +1 -1
  44. package/dist/ui/LucideIcon/LucideIcon.stories.d.ts +81 -0
  45. package/dist/ui/LucideIcon/LucideIcon.stories.d.ts.map +1 -1
  46. package/dist/ui/NumberField/NumberField.js +1 -1
  47. package/dist/ui/NumberField/NumberField.web.js +1 -1
  48. package/dist/ui/OtpField/OtpField.js +1 -1
  49. package/dist/ui/PasswordField/PasswordField.js +1 -1
  50. package/dist/ui/PhoneField/PhoneField.js +1 -1
  51. package/dist/ui/RadioGroup/RadioGroup.js +1 -1
  52. package/dist/ui/Select/Select.js +1 -1
  53. package/dist/ui/SelectMultiple/SelectMultiple.stories.d.ts +0 -6
  54. package/dist/ui/SelectMultiple/SelectMultiple.stories.d.ts.map +1 -1
  55. package/dist/ui/SelectMultiple/SelectMultiple.styles.d.ts +0 -6
  56. package/dist/ui/SelectMultiple/SelectMultiple.styles.d.ts.map +1 -1
  57. package/dist/ui/SelectMultiple/SelectMultiple.styles.js +0 -6
  58. package/dist/ui/SelectMultiple/SelectMultiple.web.d.ts.map +1 -1
  59. package/dist/ui/SelectMultiple/SelectMultiple.web.js +13 -13
  60. package/dist/ui/Switch/Switch.js +1 -1
  61. package/dist/ui/TextField/TextField.js +1 -1
  62. package/dist/ui/TextareaField/TextareaField.js +1 -1
  63. package/dist/ui/TimeInput/TimeInput.js +1 -1
  64. package/dist/ui/TimeInput/TimeInput.web.js +1 -1
  65. package/package.json +4 -4
@@ -1,11 +1,11 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Box } from '@alveole/components';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Typography } from '@alveole/components';
3
3
  import React from 'react';
4
4
  import { useStyles } from './DocumentViewer.styles';
5
5
  const isPdfCancellationError = (error) => {
6
6
  if (!(error instanceof Error))
7
7
  return false;
8
- return (['RenderingCancelledException', 'AbortException', 'UnknownErrorException'].includes(error.name) ||
8
+ return (['RenderingCancelledException', 'AbortException'].includes(error.name) ||
9
9
  error.message.includes('Worker was terminated') ||
10
10
  error.message.includes("Cannot read properties of null (reading 'sendWithPromise')"));
11
11
  };
@@ -34,14 +34,21 @@ const loadPdfJs = (() => {
34
34
  };
35
35
  })();
36
36
  export const DocumentViewerPDF = (props) => {
37
- const { source, page, rotation, height = '100%', scale = 1, onReady } = props;
37
+ const { source, page, rotation, height = '100%', scale = 1, onReady, errorLabel = 'Le PDF ne peut pas être affiché', } = props;
38
38
  const styles = useStyles();
39
39
  const [pdf, setPdf] = React.useState(null);
40
+ const [hasError, setHasError] = React.useState(false);
41
+ const [prevSource, setPrevSource] = React.useState(source);
42
+ if (prevSource !== source) {
43
+ setPrevSource(source);
44
+ setHasError(false);
45
+ }
40
46
  const [viewerSize, setViewerSize] = React.useState({ width: 0, height: 0 });
41
47
  const [isHovered, setIsHovered] = React.useState(false);
42
48
  const [transformOrigin, setTransformOrigin] = React.useState('50% 50%');
43
49
  const [renderedPageSize, setRenderedPageSize] = React.useState({ width: 0, height: 0 });
44
50
  const canvasRef = React.useRef(null);
51
+ const measureRef = React.useRef(null);
45
52
  const onReadyRef = React.useRef(onReady);
46
53
  const hoveredScale = isHovered ? 2 : 1;
47
54
  React.useEffect(() => {
@@ -60,6 +67,7 @@ export const DocumentViewerPDF = (props) => {
60
67
  if (!active)
61
68
  return;
62
69
  setPdf(null);
70
+ setHasError(true);
63
71
  }, []);
64
72
  const onPageLoadedSuccess = React.useCallback(async (pagePdf, active) => {
65
73
  if (!active || !canvasRef.current)
@@ -85,6 +93,27 @@ export const DocumentViewerPDF = (props) => {
85
93
  transform: pixelRatio === 1 ? undefined : [pixelRatio, 0, 0, pixelRatio, 0, 0],
86
94
  });
87
95
  }, [rotation, scale, viewerSize.height, viewerSize.width]);
96
+ // ResizeObserver pour mesurer le conteneur — onLayout React Native for Web
97
+ // ne fonctionne pas avec les custom HTML tags (tag="document-viewer-pdf").
98
+ React.useEffect(() => {
99
+ const el = measureRef.current;
100
+ if (!el)
101
+ return;
102
+ const update = (width, height) => {
103
+ if (width > 0 && height > 0) {
104
+ setViewerSize({ width, height });
105
+ }
106
+ };
107
+ const observer = new ResizeObserver(entries => {
108
+ const entry = entries[0];
109
+ if (entry)
110
+ update(entry.contentRect.width, entry.contentRect.height);
111
+ });
112
+ observer.observe(el);
113
+ const rect = el.getBoundingClientRect();
114
+ update(rect.width, rect.height);
115
+ return () => observer.disconnect();
116
+ }, []);
88
117
  React.useEffect(() => {
89
118
  let isActive = true;
90
119
  let loadingTask = null;
@@ -92,7 +121,7 @@ export const DocumentViewerPDF = (props) => {
92
121
  .then(pdfjs => {
93
122
  if (!isActive)
94
123
  return;
95
- loadingTask = pdfjs.getDocument(source);
124
+ loadingTask = pdfjs.getDocument({ url: source });
96
125
  return loadingTask.promise
97
126
  .then(nextPdf => onPdfLoadedSuccess(nextPdf, isActive))
98
127
  .catch(error => {
@@ -136,13 +165,6 @@ export const DocumentViewerPDF = (props) => {
136
165
  renderTask?.cancel?.();
137
166
  };
138
167
  }, [pdf, page, rotation, scale, viewerSize, onPageLoadedSuccess, onPdfLoadedError]);
139
- const handleLayout = React.useCallback((event) => {
140
- const nextWidth = event?.nativeEvent?.layout?.width;
141
- const nextHeight = event?.nativeEvent?.layout?.height;
142
- if (typeof nextWidth === 'number' && nextWidth > 0 && typeof nextHeight === 'number' && nextHeight > 0) {
143
- setViewerSize({ width: nextWidth, height: nextHeight });
144
- }
145
- }, []);
146
168
  const handlePointerMove = React.useCallback((event) => {
147
169
  const rect = event.currentTarget?.getBoundingClientRect?.();
148
170
  if (!rect)
@@ -152,13 +174,13 @@ export const DocumentViewerPDF = (props) => {
152
174
  setTransformOrigin(`${Math.max(0, Math.min(100, x))}% ${Math.max(0, Math.min(100, y))}%`);
153
175
  }, []);
154
176
  React.useEffect(() => () => void pdf?.destroy?.(), [pdf]);
155
- return (_jsx(Box, { tag: "document-viewer-pdf", width: '100%', height: height, onLayout: handleLayout, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onPointerEnter: () => setIsHovered(true), onPointerLeave: () => setIsHovered(false), onPointerMove: handlePointerMove, style: styles.viewerPdfContent, children: _jsx(Box, { width: '100%', height: '100%', p: '1V', style: styles.viewerPdfStage, children: _jsx(Box, { style: [
156
- styles.viewerPdfCanvasWrapper,
157
- {
158
- width: renderedPageSize.width,
159
- height: renderedPageSize.height,
160
- transformOrigin,
161
- transform: [{ scale: hoveredScale }],
162
- },
163
- ], children: _jsx("canvas", { ref: canvasRef, style: styles.viewerPdfCanvas }) }) }) }));
177
+ return (_jsxs(Box, { tag: "document-viewer-pdf", width: '100%', height: height, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onPointerEnter: () => setIsHovered(true), onPointerLeave: () => setIsHovered(false), onPointerMove: handlePointerMove, style: [styles.viewerPdfContent, { position: 'relative' }], children: [_jsx("div", { ref: measureRef, style: { position: 'absolute', inset: 0, pointerEvents: 'none' } }), _jsxs(Box, { width: '100%', height: '100%', p: '1V', style: styles.viewerPdfStage, children: [_jsx(Box, { style: [
178
+ styles.viewerPdfCanvasWrapper,
179
+ {
180
+ width: renderedPageSize.width,
181
+ height: renderedPageSize.height,
182
+ transformOrigin,
183
+ transform: [{ scale: hoveredScale }],
184
+ },
185
+ ], children: _jsx("canvas", { ref: canvasRef, style: styles.viewerPdfCanvas }) }), hasError && (_jsx(Box, { style: styles.viewerPdfOverlay, children: _jsx(Typography, { style: styles.viewerPdfErrorLabel, children: errorLabel }) }))] })] }));
164
186
  };
@@ -18,5 +18,5 @@ export const DurationInput = React.forwardRef(function DurationInput({ label, la
18
18
  onChange?.(localValue);
19
19
  onBlur?.();
20
20
  };
21
- return (_jsxs(FormControl, { children: [_jsxs(InputHeading, { children: [label && (_jsx(FormControlLabel, { labelRight: labelRight, label: label, disabled: disabled, error: error, success: success })), hint && _jsx(FormControlHint, { hint: hint, disabled: disabled })] }), _jsx(TextInput, { ref: ref, placeholder: "HH:MM", value: localValue, onChangeText: handleChangeText, onBlur: handleBlur, disabled: disabled, inputMode: "numeric", maxLength: 5 }), (error || success) && _jsx(FormControlCaption, { error: error, success: success })] }));
21
+ return (_jsxs(FormControl, { children: [_jsxs(InputHeading, { children: [!!label && (_jsx(FormControlLabel, { labelRight: labelRight, label: label, disabled: disabled, error: error, success: success })), !!hint && _jsx(FormControlHint, { hint: hint, disabled: disabled })] }), _jsx(TextInput, { ref: ref, placeholder: "HH:MM", value: localValue, onChangeText: handleChangeText, onBlur: handleBlur, disabled: disabled, inputMode: "numeric", maxLength: 5 }), (error || success) && _jsx(FormControlCaption, { error: error, success: success })] }));
22
22
  });
@@ -4,5 +4,5 @@ import React from 'react';
4
4
  import { EmailInput } from '../EmailInput';
5
5
  export const EmailField = React.forwardRef(function EmailField(props, ref) {
6
6
  const { label, labelRight, hint, error, success, disabled, onChange } = props;
7
- return (_jsxs(FormControl, { children: [_jsxs(InputHeading, { children: [label && (_jsx(FormControlLabel, { labelRight: labelRight, label: label, disabled: disabled, error: error, success: success })), hint && _jsx(FormControlHint, { hint: hint, disabled: disabled })] }), _jsx(EmailInput, { ref: ref, onChangeText: onChange, ...props }), (error || success) && _jsx(FormControlCaption, { error: error, success: success })] }));
7
+ return (_jsxs(FormControl, { children: [_jsxs(InputHeading, { children: [!!label && (_jsx(FormControlLabel, { labelRight: labelRight, label: label, disabled: disabled, error: error, success: success })), !!hint && _jsx(FormControlHint, { hint: hint, disabled: disabled })] }), _jsx(EmailInput, { ref: ref, onChangeText: onChange, ...props }), (error || success) && _jsx(FormControlCaption, { error: error, success: success })] }));
8
8
  });
@@ -23,5 +23,5 @@ export const FileField = (props) => {
23
23
  });
24
24
  }
25
25
  };
26
- return (_jsxs(FormControl, { style: styles.fileInput, children: [_jsxs(InputHeading, { children: [label && (_jsx(FormControlLabel, { labelRight: labelRight, label: label, disabled: disabled, error: error, success: success })), hint && _jsx(FormControlHint, { hint: hint, disabled: disabled })] }), _jsx(FormControlFileInput, { ...props, onChange: onValueChange }), (error || success) && _jsx(FormControlCaption, { error: error, success: success })] }));
26
+ return (_jsxs(FormControl, { style: styles.fileInput, children: [_jsxs(InputHeading, { children: [!!label && (_jsx(FormControlLabel, { labelRight: labelRight, label: label, disabled: disabled, error: error, success: success })), !!hint && _jsx(FormControlHint, { hint: hint, disabled: disabled })] }), _jsx(FormControlFileInput, { ...props, onChange: onValueChange }), (error || success) && _jsx(FormControlCaption, { error: error, success: success })] }));
27
27
  };
@@ -34,7 +34,7 @@ export const FormControlDateInput = React.forwardRef(function DateInput(props, r
34
34
  return formatForInput(value, 'month');
35
35
  return value;
36
36
  }, [type, value]);
37
- return (_jsx(Box, { tag: "form-control-text-input", style: styles.inputContainer, children: _jsx(Box, { tag: "form-control-text-input-inner", style: {
37
+ return (_jsx(Box, { tag: "form-control-date-input", style: styles.inputContainer, children: _jsx(Box, { tag: "form-control-date-input-inner", style: {
38
38
  ...styles.inputInner,
39
39
  ...(props.disabled ? styles.inputDisabled : {}),
40
40
  }, children: _jsx("input", { ref: ref, onChange: e => {
@@ -4,5 +4,5 @@ import { useStyles } from './FormControl.styles';
4
4
  export const FormControlHint = (props) => {
5
5
  const { hint, disabled } = props;
6
6
  const styles = useStyles();
7
- return (_jsx(Box, { style: styles.hintContainer, children: _jsx(Typography, { style: { ...styles.hint, ...(disabled ? styles.hintDisabled : {}) }, children: hint }) }));
7
+ return (_jsx(Box, { tag: "form-control-hint", style: styles.hintContainer, children: _jsx(Typography, { style: { ...styles.hint, ...(disabled ? styles.hintDisabled : {}) }, children: hint }) }));
8
8
  };
@@ -4,10 +4,10 @@ import { useStyles } from './FormControl.styles';
4
4
  export const FormControlLabel = (props) => {
5
5
  const { label, labelRight, optional = false, optionalText = '(optionnel)', disabled, error, success } = props;
6
6
  const styles = useStyles();
7
- return (_jsxs(Box, { style: styles.labelContainer, children: [_jsx(Typography, { style: {
7
+ return (_jsxs(Box, { tag: "form-control-label", style: styles.labelContainer, children: [_jsx(Typography, { style: {
8
8
  ...styles.label,
9
9
  ...(error ? styles.errorText : {}),
10
10
  ...(success ? styles.successText : {}),
11
11
  ...(disabled ? styles.labelDisabled : {}),
12
- }, children: label }), optional && _jsx(Typography, { style: styles.optionalText, children: optionalText }), label && (_jsx(Box, { mt: 'auto', mb: 'auto', ml: 'auto', children: labelRight }))] }));
12
+ }, children: label }), !!optional && _jsx(Typography, { style: styles.optionalText, children: optionalText }), !!label && (_jsx(Box, { mt: 'auto', mb: 'auto', ml: 'auto', children: labelRight }))] }));
13
13
  };
@@ -5,7 +5,7 @@ import { useStyles } from './FormControl.styles';
5
5
  export const FormControlNumberInput = React.forwardRef(function DateInput(props, ref) {
6
6
  const { value, onChange, startAdornment, endAdornment, ...inputProps } = props;
7
7
  const styles = useStyles();
8
- return (_jsx(Box, { tag: "form-control-text-input", style: styles.inputContainer, children: _jsxs(Box, { tag: "form-control-text-input-inner", style: {
8
+ return (_jsx(Box, { tag: "form-control-number-input", style: styles.inputContainer, children: _jsxs(Box, { tag: "form-control-number-input-inner", style: {
9
9
  ...styles.inputInner,
10
10
  ...(props.disabled ? styles.inputDisabled : {}),
11
11
  ...(endAdornment ? { paddingRight: 0 } : {}),