cortex-react-ui 0.1.176 → 0.1.178

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.
@@ -0,0 +1,16 @@
1
+ import { WebcamProps } from 'react-webcam';
2
+ declare const Camera: ({ onCapture, isOffline, mode, isShowOffline, ...props }: CameraProps) => JSX.Element;
3
+ export declare type CameraProps = {
4
+ onCapture: ({ fileStoreName, fileRowId, file }: TfileCapturedProps) => void;
5
+ mode?: 'photo' | 'video';
6
+ isOffline?: boolean;
7
+ isShowOffline?: boolean;
8
+ } & Partial<WebcamProps>;
9
+ export declare type TfileCapturedProps = {
10
+ fileStoreName?: string | null;
11
+ fileRowId?: number | null;
12
+ file?: File | null;
13
+ imageSrc?: string | null;
14
+ videoSrc?: string | null;
15
+ };
16
+ export default Camera;
@@ -0,0 +1,9 @@
1
+ declare class FileStorageDB {
2
+ private dbName;
3
+ private storeName;
4
+ private db;
5
+ openDatabase(): Promise<IDBDatabase>;
6
+ storeFile(file: File): Promise<number>;
7
+ retrieveFile(id: number): Promise<File | null>;
8
+ }
9
+ export default FileStorageDB;
@@ -0,0 +1 @@
1
+ export { default } from './Camera';
@@ -0,0 +1,6 @@
1
+ export declare const useTimer: () => {
2
+ formatTime: (totalSeconds: number) => string;
3
+ startTimer: () => void;
4
+ stopTimer: () => void;
5
+ formatedTime: string;
6
+ };
@@ -5,6 +5,7 @@ export { default as BarLoader } from './BarLoader';
5
5
  export { default as Selected } from './Selected';
6
6
  export { default as Button } from './Button';
7
7
  export { default as Scanner } from './Scanner';
8
+ export { default as Camera } from './Camera';
8
9
  export { default as ToggleButton } from './ToggleButton';
9
10
  export { default as Tooltip } from './Tooltip';
10
11
  export { default as TagInput } from './TagInput';
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import React$1, { CSSProperties } from 'react';
2
2
  import { IDetectedBarcode, IScannerProps } from '@yudiel/react-qr-scanner';
3
+ import { WebcamProps } from 'react-webcam';
3
4
 
4
5
  declare const PopperPlacement: {
5
6
  readonly Center: "center";
@@ -98,6 +99,21 @@ declare type ScannerProps = {
98
99
  onScan?: (detectedCodes: IDetectedBarcode[]) => void;
99
100
  } & IScannerProps;
100
101
 
102
+ declare const Camera: ({ onCapture, isOffline, mode, isShowOffline, ...props }: CameraProps) => JSX.Element;
103
+ declare type CameraProps = {
104
+ onCapture: ({ fileStoreName, fileRowId, file }: TfileCapturedProps) => void;
105
+ mode?: 'photo' | 'video';
106
+ isOffline?: boolean;
107
+ isShowOffline?: boolean;
108
+ } & Partial<WebcamProps>;
109
+ declare type TfileCapturedProps = {
110
+ fileStoreName?: string | null;
111
+ fileRowId?: number | null;
112
+ file?: File | null;
113
+ imageSrc?: string | null;
114
+ videoSrc?: string | null;
115
+ };
116
+
101
117
  interface ToggleButtonProps {
102
118
  selected?: boolean;
103
119
  value?: string;
@@ -307,4 +323,4 @@ interface Props {
307
323
  }
308
324
  declare const CrossIcon: React$1.FC<Props>;
309
325
 
310
- export { AuthDownloadLink, BarLoader, Button, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ConfirmDialog, ContextMenu, CrossIcon, Dialog, DialogActions, DialogContent$1 as DialogContent, DialogFooter, DialogHeader, DialogContent as DialogTitle, Divider, DomContainer, ErrorDialog, Menu, MenuGroup, MenuItem, Popper, PopupMenu, Scanner, Selected, Spinner, TagInput, ToggleButton, Tooltip, WarningDialog };
326
+ export { AuthDownloadLink, BarLoader, Button, Camera, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ConfirmDialog, ContextMenu, CrossIcon, Dialog, DialogActions, DialogContent$1 as DialogContent, DialogFooter, DialogHeader, DialogContent as DialogTitle, Divider, DomContainer, ErrorDialog, Menu, MenuGroup, MenuItem, Popper, PopupMenu, Scanner, Selected, Spinner, TagInput, ToggleButton, Tooltip, WarningDialog };
@@ -0,0 +1,217 @@
1
+ @import "../global.scss";
2
+
3
+ @mixin camera($props: null, $options: null) {
4
+ $internal-props: (
5
+ bgColor: #ffffff,
6
+ fgColor: $color-grey-darker,
7
+ captureButtonBg: #2196f3,
8
+ captureButtonHover: #1976d2,
9
+ recordButtonBg: #f44336,
10
+ recordButtonHover: #d32f2f,
11
+ downloadButtonBg: #4caf50,
12
+ downloadButtonHover: #388e3c,
13
+ resetButtonBg: #9e9e9e,
14
+ resetButtonHover: #757575,
15
+ offlineModeColor: #d32f2f
16
+ );
17
+
18
+ $internal-props: safe-map-merge($internal-props, $props);
19
+
20
+ .camera-container {
21
+ width: 100%;
22
+ height: 100%;
23
+ background-color: #000;
24
+ }
25
+
26
+ .camera-switch-btn {
27
+ all: initial;
28
+ display: flex;
29
+ cursor: pointer;
30
+ }
31
+
32
+ .camera-recording-dot {
33
+ width: 8px;
34
+ height: 8px;
35
+ border-radius: 50%;
36
+ background-color: map-get($internal-props, recordButtonBg);
37
+ animation: clignote 1s infinite;
38
+ }
39
+
40
+ .camera-recording-timer {
41
+ z-index: 99;
42
+ position: absolute;
43
+ top: 1rem;
44
+ left: 20px;
45
+ display: flex;
46
+ align-items: center;
47
+ justify-content: center;
48
+ background: rgba(0, 0, 0, .2);
49
+ border-radius: 4px;
50
+ padding: 3px 7px;
51
+ font-size: 12px;
52
+ color: #fff;
53
+ font-family: sans-serif;
54
+ gap: 6px;
55
+ }
56
+
57
+ .camera-offline-mode {
58
+ position: absolute;
59
+ top: 1rem;
60
+ right: 20px;
61
+ display: flex;
62
+ align-items: center;
63
+ justify-content: center;
64
+ background: rgba(0, 0, 0, .2);
65
+ border-radius: 4px;
66
+ padding: 3px 7px;
67
+ font-size: 12px;
68
+ color: red;
69
+ font-family: sans-serif;
70
+ }
71
+
72
+ .camera-mode {
73
+ z-index: 9999;
74
+ position: absolute;
75
+ bottom: 2rem;
76
+ right: 20px;
77
+ padding: 0.5rem;
78
+ border-radius: 6px;
79
+ color: #ffffff;
80
+ border: none;
81
+ cursor: pointer;
82
+ display: flex;
83
+ justify-content: center;
84
+ align-items: center;
85
+ gap: 7px;
86
+ background-color: map-get($internal-props, captureButtonBg);
87
+ transition: background-color 0.3s ease;
88
+ }
89
+
90
+ .camera-preview {
91
+ position: relative;
92
+ width: 100%;
93
+ height: 100%;
94
+ overflow: hidden;
95
+ }
96
+
97
+ .camera-controls {
98
+ z-index: 999;
99
+ display: flex;
100
+ justify-content: center;
101
+ gap: 1rem;
102
+ margin: 0 auto;
103
+ padding: 1rem;
104
+ }
105
+
106
+ .video-play-btn {
107
+ all: initial;
108
+ position: absolute;
109
+ bottom: 10%;
110
+ left: 50%;
111
+ z-index: 9;
112
+ width: 1em;
113
+ height: 1em;
114
+ min-width: 15px;
115
+ min-height: 15px;
116
+ transform: translate(-50%, -50%);
117
+ display: flex;
118
+ justify-content: center;
119
+ align-items: center;
120
+ border-radius: 50%;
121
+ border: 1px solid;
122
+ padding: 20px 20px;
123
+ background-color: map-get($internal-props, bgColor);
124
+ cursor: pointer;
125
+ }
126
+
127
+ .camera-button {
128
+ padding: 0.5rem;
129
+ border-radius: 6px;
130
+ color: #ffffff;
131
+ border: none;
132
+ cursor: pointer;
133
+ display: flex;
134
+ justify-content: center;
135
+ align-items: center;
136
+ gap: 7px;
137
+ min-width: 50px;
138
+ transition: background-color 0.3s ease;
139
+
140
+ &--capture {
141
+ border-radius: 50%;
142
+ color: initial;
143
+ width: 50px;
144
+ height: 50px;
145
+ border: 1px solid black;
146
+ background-color: map-get($internal-props, bgColor);
147
+ }
148
+
149
+ &--record {
150
+ border-radius: 50%;
151
+ color: red;
152
+ width: 50px;
153
+ height: 50px;
154
+ border: 1px solid black;
155
+ background-color: map-get($internal-props, bgColor);
156
+ }
157
+
158
+ &--download {
159
+ background-color: map-get($internal-props, downloadButtonBg);
160
+ &:hover {
161
+ background-color: map-get($internal-props, downloadButtonHover);
162
+ }
163
+ }
164
+
165
+ &--reset {
166
+ background-color: map-get($internal-props, resetButtonBg);
167
+ &:hover {
168
+ background-color: map-get($internal-props, resetButtonHover);
169
+ }
170
+ }
171
+ }
172
+
173
+ .camera-offline-mode {
174
+ font-size: 0.875rem;
175
+ font-family: sans-serif;
176
+ color: map-get($internal-props, offlineModeColor);
177
+ }
178
+
179
+ .camera-screen-animation {
180
+ animation: fadeIn .3s;
181
+ }
182
+
183
+ @keyframes fadeIn {
184
+ 0% {
185
+ opacity: 0;
186
+ }
187
+ 100% {
188
+ opacity: 1;
189
+ }
190
+ }
191
+
192
+ @keyframes pulse {
193
+ 0% {
194
+ transform: scale(1);
195
+ }
196
+ 50% {
197
+ transform: scale(1.05);
198
+ }
199
+ 100% {
200
+ transform: scale(1);
201
+ }
202
+ }
203
+
204
+ @keyframes clignote {
205
+ 0% {
206
+ opacity: 1;
207
+ }
208
+ 50% {
209
+ opacity: 0;
210
+ }
211
+ 100% {
212
+ opacity: 1;
213
+ }
214
+ }
215
+ }
216
+
217
+ @include camera();
@@ -13,7 +13,7 @@
13
13
  @import "ToggleButton";
14
14
  @import "Selected";
15
15
  @import "BarLoader";
16
-
16
+ @import "Camera";
17
17
 
18
18
  @include icons();
19
19
  @include popper();
@@ -28,6 +28,7 @@
28
28
  @include toggleButton();
29
29
  @include selected();
30
30
  @include barLoader();
31
+ @include camera();
31
32
 
32
33
  // @include popper();
33
34
  // @include popper(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortex-react-ui",
3
- "version": "0.1.176",
3
+ "version": "0.1.178",
4
4
  "description": "React UI",
5
5
  "author": "Anthony",
6
6
  "license": "MIT",
@@ -87,9 +87,12 @@
87
87
  "eslint-plugin-json": "^3.1.0",
88
88
  "eslint-plugin-jsx-a11y": "^6.4.1",
89
89
  "eslint-plugin-react": "^7.26.1",
90
+ "lodash": "^4.17.21",
90
91
  "react": "^18.1.0",
91
92
  "react-dom": "^18.1.0",
93
+ "react-icons": "^5.3.0",
92
94
  "react-scripts": "^4.0.3",
95
+ "react-webcam": "^7.2.0",
93
96
  "rollup": "^2.60.2",
94
97
  "rollup-plugin-copy": "^3.4.0",
95
98
  "rollup-plugin-dts": "^4.0.1",