canvasframework 0.5.16 → 0.5.18
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/dist/canvasframework.js +2 -0
- package/dist/canvasframework.js.LICENSE.txt +1 -0
- package/package.json +18 -17
- package/components/Accordion.js +0 -265
- package/components/AndroidDatePickerDialog.js +0 -406
- package/components/AppBar.js +0 -398
- package/components/AudioPlayer.js +0 -611
- package/components/Avatar.js +0 -202
- package/components/Banner.js +0 -342
- package/components/BottomNavigationBar.js +0 -433
- package/components/BottomSheet.js +0 -234
- package/components/Button.js +0 -360
- package/components/Camera.js +0 -644
- package/components/Card.js +0 -193
- package/components/Chart.js +0 -700
- package/components/Checkbox.js +0 -166
- package/components/Chip.js +0 -212
- package/components/CircularProgress.js +0 -327
- package/components/ContextMenu.js +0 -116
- package/components/DatePicker.js +0 -298
- package/components/Dialog.js +0 -337
- package/components/Divider.js +0 -125
- package/components/Drawer.js +0 -276
- package/components/FAB.js +0 -270
- package/components/FileUpload.js +0 -315
- package/components/FloatedCamera.js +0 -644
- package/components/IOSDatePickerWheel.js +0 -430
- package/components/ImageCarousel.js +0 -219
- package/components/ImageComponent.js +0 -223
- package/components/Input.js +0 -831
- package/components/InputDatalist.js +0 -723
- package/components/InputTags.js +0 -624
- package/components/List.js +0 -95
- package/components/ListItem.js +0 -269
- package/components/Modal.js +0 -364
- package/components/MorphingFAB.js +0 -428
- package/components/MultiSelectDialog.js +0 -206
- package/components/NumberInput.js +0 -271
- package/components/PasswordInput.js +0 -462
- package/components/ProgressBar.js +0 -88
- package/components/QRCodeReader.js +0 -539
- package/components/RadioButton.js +0 -151
- package/components/SearchInput.js +0 -315
- package/components/SegmentedControl.js +0 -357
- package/components/Select.js +0 -199
- package/components/SelectDialog.js +0 -255
- package/components/Slider.js +0 -113
- package/components/SliverAppBar.js +0 -139
- package/components/Snackbar.js +0 -243
- package/components/SpeedDialFAB.js +0 -397
- package/components/Stepper.js +0 -281
- package/components/SwipeableListItem.js +0 -327
- package/components/Switch.js +0 -147
- package/components/Table.js +0 -492
- package/components/Tabs.js +0 -423
- package/components/Text.js +0 -141
- package/components/TextField.js +0 -151
- package/components/TimePicker.js +0 -934
- package/components/Toast.js +0 -236
- package/components/TreeView.js +0 -420
- package/components/Video.js +0 -397
- package/components/View.js +0 -140
- package/components/VirtualList.js +0 -120
- package/core/CanvasFramework.js +0 -3034
- package/core/Component.js +0 -243
- package/core/ThemeManager.js +0 -358
- package/core/UIBuilder.js +0 -267
- package/core/WebGLCanvasAdapter.js +0 -782
- package/features/Column.js +0 -43
- package/features/Grid.js +0 -47
- package/features/LayoutComponent.js +0 -43
- package/features/OpenStreetMap.js +0 -310
- package/features/Positioned.js +0 -33
- package/features/PullToRefresh.js +0 -328
- package/features/Row.js +0 -40
- package/features/SignaturePad.js +0 -257
- package/features/Skeleton.js +0 -193
- package/features/Stack.js +0 -21
- package/index.js +0 -119
- package/manager/AccessibilityManager.js +0 -107
- package/manager/ErrorHandler.js +0 -59
- package/manager/FeatureFlags.js +0 -60
- package/manager/MemoryManager.js +0 -107
- package/manager/PerformanceMonitor.js +0 -84
- package/manager/SecurityManager.js +0 -54
- package/utils/AnimationEngine.js +0 -734
- package/utils/CryptoManager.js +0 -303
- package/utils/DataStore.js +0 -403
- package/utils/DevTools.js +0 -1618
- package/utils/DevToolsConsole.js +0 -201
- package/utils/EventBus.js +0 -407
- package/utils/FetchClient.js +0 -74
- package/utils/FirebaseAuth.js +0 -653
- package/utils/FirebaseCore.js +0 -246
- package/utils/FirebaseFirestore.js +0 -581
- package/utils/FirebaseFunctions.js +0 -97
- package/utils/FirebaseRealtimeDB.js +0 -498
- package/utils/FirebaseStorage.js +0 -612
- package/utils/FormValidator.js +0 -355
- package/utils/GeoLocationService.js +0 -62
- package/utils/I18n.js +0 -207
- package/utils/IndexedDBManager.js +0 -273
- package/utils/InspectionOverlay.js +0 -308
- package/utils/NotificationManager.js +0 -60
- package/utils/OfflineSyncManager.js +0 -342
- package/utils/PayPalPayment.js +0 -678
- package/utils/QueryBuilder.js +0 -478
- package/utils/SafeArea.js +0 -64
- package/utils/SecureStorage.js +0 -289
- package/utils/StateManager.js +0 -207
- package/utils/StripePayment.js +0 -552
- package/utils/WebSocketClient.js +0 -66
package/components/Button.js
DELETED
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import Component from '../core/Component.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Bouton cliquable avec variantes Material et Cupertino
|
|
5
|
-
* @class
|
|
6
|
-
* @extends Component
|
|
7
|
-
*
|
|
8
|
-
* Types Material: 'filled', 'outlined', 'text', 'elevated', 'tonal'
|
|
9
|
-
* Types Cupertino: 'filled', 'gray', 'tinted', 'bordered', 'plain'
|
|
10
|
-
* Shapes: 'rounded', 'square', 'pill' (très arrondi)
|
|
11
|
-
*/
|
|
12
|
-
class Button extends Component {
|
|
13
|
-
/**
|
|
14
|
-
* Crée une instance de Button
|
|
15
|
-
* @param {CanvasFramework} framework - Framework parent
|
|
16
|
-
* @param {Object} [options={}] - Options de configuration
|
|
17
|
-
* @param {string} [options.text='Button'] - Texte
|
|
18
|
-
* @param {number} [options.fontSize=16] - Taille de police
|
|
19
|
-
* @param {string} [options.type] - Type de bouton (auto selon platform)
|
|
20
|
-
* @param {string} [options.shape='rounded'] - Forme: 'rounded', 'square', 'pill'
|
|
21
|
-
* @param {string} [options.bgColor] - Couleur personnalisée
|
|
22
|
-
* @param {string} [options.textColor] - Couleur du texte personnalisée
|
|
23
|
-
* @param {number} [options.elevation=2] - Élévation (Material elevated)
|
|
24
|
-
*/
|
|
25
|
-
constructor(framework, options = {}) {
|
|
26
|
-
super(framework, options);
|
|
27
|
-
this.text = options.text || 'Button';
|
|
28
|
-
this.fontSize = options.fontSize || 16;
|
|
29
|
-
this.platform = framework.platform;
|
|
30
|
-
this.shape = options.shape || 'rounded';
|
|
31
|
-
|
|
32
|
-
// Définir le type de bouton selon la plateforme
|
|
33
|
-
if (this.platform === 'material') {
|
|
34
|
-
this.type = options.type || 'filled';
|
|
35
|
-
this.setupMaterialStyle(options);
|
|
36
|
-
} else {
|
|
37
|
-
this.type = options.type || 'filled';
|
|
38
|
-
this.setupCupertinoStyle(options);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Effets ripple (Material uniquement)
|
|
42
|
-
this.ripples = [];
|
|
43
|
-
|
|
44
|
-
// Bind
|
|
45
|
-
this.onPress = this.handlePress.bind(this);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Configure le style Material Design
|
|
50
|
-
* @private
|
|
51
|
-
*/
|
|
52
|
-
setupMaterialStyle(options) {
|
|
53
|
-
const baseColor = options.bgColor || '#6200EE';
|
|
54
|
-
this.elevation = options.elevation || 2;
|
|
55
|
-
|
|
56
|
-
switch (this.type) {
|
|
57
|
-
case 'filled':
|
|
58
|
-
this.bgColor = baseColor;
|
|
59
|
-
this.textColor = options.textColor || '#FFFFFF';
|
|
60
|
-
this.borderWidth = 0;
|
|
61
|
-
this.rippleColor = 'rgba(255, 255, 255, 0.3)';
|
|
62
|
-
break;
|
|
63
|
-
|
|
64
|
-
case 'outlined':
|
|
65
|
-
this.bgColor = 'transparent';
|
|
66
|
-
this.textColor = options.textColor || baseColor;
|
|
67
|
-
this.borderColor = baseColor;
|
|
68
|
-
this.borderWidth = 1;
|
|
69
|
-
this.rippleColor = this.hexToRgba(baseColor, 0.2);
|
|
70
|
-
this.elevation = 0;
|
|
71
|
-
break;
|
|
72
|
-
|
|
73
|
-
case 'text':
|
|
74
|
-
this.bgColor = 'transparent';
|
|
75
|
-
this.textColor = options.textColor || baseColor;
|
|
76
|
-
this.borderWidth = 0;
|
|
77
|
-
this.rippleColor = this.hexToRgba(baseColor, 0.2);
|
|
78
|
-
this.elevation = 0;
|
|
79
|
-
break;
|
|
80
|
-
|
|
81
|
-
case 'elevated':
|
|
82
|
-
this.bgColor = options.bgColor || '#FFFFFF';
|
|
83
|
-
this.textColor = options.textColor || baseColor;
|
|
84
|
-
this.borderWidth = 0;
|
|
85
|
-
this.rippleColor = this.hexToRgba(baseColor, 0.2);
|
|
86
|
-
this.elevation = options.elevation || 4;
|
|
87
|
-
break;
|
|
88
|
-
|
|
89
|
-
case 'tonal':
|
|
90
|
-
this.bgColor = this.hexToRgba(baseColor, 0.3);
|
|
91
|
-
this.textColor = options.textColor || baseColor;
|
|
92
|
-
this.borderWidth = 0;
|
|
93
|
-
this.rippleColor = this.hexToRgba(baseColor, 0.3);
|
|
94
|
-
this.elevation = 0;
|
|
95
|
-
break;
|
|
96
|
-
|
|
97
|
-
default :
|
|
98
|
-
this.bgColor = options.bgColor || '#FFFFFF';
|
|
99
|
-
this.textColor = options.textColor || baseColor;
|
|
100
|
-
this.borderWidth = 0;
|
|
101
|
-
this.rippleColor = this.hexToRgba(baseColor, 0.2);
|
|
102
|
-
this.elevation = options.elevation || 4;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Configure le style Cupertino (iOS)
|
|
109
|
-
* @private
|
|
110
|
-
*/
|
|
111
|
-
setupCupertinoStyle(options) {
|
|
112
|
-
const baseColor = options.bgColor || '#007AFF';
|
|
113
|
-
|
|
114
|
-
switch (this.type) {
|
|
115
|
-
case 'filled':
|
|
116
|
-
this.bgColor = baseColor;
|
|
117
|
-
this.textColor = options.textColor || '#FFFFFF';
|
|
118
|
-
this.borderWidth = 0;
|
|
119
|
-
break;
|
|
120
|
-
|
|
121
|
-
case 'gray':
|
|
122
|
-
this.bgColor = 'rgba(120, 120, 128, 0.16)';
|
|
123
|
-
this.textColor = options.textColor || baseColor;
|
|
124
|
-
this.borderWidth = 0;
|
|
125
|
-
break;
|
|
126
|
-
|
|
127
|
-
case 'tinted':
|
|
128
|
-
this.bgColor = this.hexToRgba(baseColor, 0.2);
|
|
129
|
-
this.textColor = options.textColor || baseColor;
|
|
130
|
-
this.borderWidth = 0;
|
|
131
|
-
break;
|
|
132
|
-
|
|
133
|
-
case 'plain':
|
|
134
|
-
this.bgColor = 'transparent';
|
|
135
|
-
this.textColor = options.textColor || baseColor;
|
|
136
|
-
this.borderWidth = 0;
|
|
137
|
-
break;
|
|
138
|
-
|
|
139
|
-
default :
|
|
140
|
-
this.bgColor = 'transparent';
|
|
141
|
-
this.textColor = options.textColor || baseColor;
|
|
142
|
-
this.borderWidth = 0;
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Retourne le rayon des coins selon la forme
|
|
149
|
-
* @returns {number} Rayon en pixels
|
|
150
|
-
* @private
|
|
151
|
-
*/
|
|
152
|
-
getBorderRadius() {
|
|
153
|
-
switch (this.shape) {
|
|
154
|
-
case 'square':
|
|
155
|
-
return 0;
|
|
156
|
-
case 'rounded':
|
|
157
|
-
default:
|
|
158
|
-
return this.platform === 'material' ? 4 : 10;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Gère la pression sur le bouton
|
|
164
|
-
* @param {number} x - Coordonnée X
|
|
165
|
-
* @param {number} y - Coordonnée Y
|
|
166
|
-
* @private
|
|
167
|
-
*/
|
|
168
|
-
handlePress(x, y) {
|
|
169
|
-
if (this.platform === 'material') {
|
|
170
|
-
const adjustedY = y - this.framework.scrollOffset;
|
|
171
|
-
this.ripples.push({
|
|
172
|
-
x: x - this.x,
|
|
173
|
-
y: adjustedY - this.y,
|
|
174
|
-
radius: 0,
|
|
175
|
-
maxRadius: Math.max(this.width, this.height) * 1.5,
|
|
176
|
-
opacity: 1
|
|
177
|
-
});
|
|
178
|
-
this.animateRipple();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Anime les effets ripple
|
|
184
|
-
* @private
|
|
185
|
-
*/
|
|
186
|
-
animateRipple() {
|
|
187
|
-
const animate = () => {
|
|
188
|
-
let hasActiveRipples = false;
|
|
189
|
-
|
|
190
|
-
for (let ripple of this.ripples) {
|
|
191
|
-
if (ripple.radius < ripple.maxRadius) {
|
|
192
|
-
ripple.radius += ripple.maxRadius / 15;
|
|
193
|
-
hasActiveRipples = true;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (ripple.radius >= ripple.maxRadius * 0.5) {
|
|
197
|
-
ripple.opacity -= 0.05;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
this.ripples = this.ripples.filter(r => r.opacity > 0);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (hasActiveRipples) {
|
|
205
|
-
requestAnimationFrame(animate);
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
animate();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Dessine le bouton
|
|
214
|
-
* @param {CanvasRenderingContext2D} ctx - Contexte de dessin
|
|
215
|
-
*/
|
|
216
|
-
draw(ctx) {
|
|
217
|
-
ctx.save();
|
|
218
|
-
|
|
219
|
-
const radius = this.getBorderRadius();
|
|
220
|
-
|
|
221
|
-
// Ombre Material (elevated/filled)
|
|
222
|
-
if (this.platform === 'material' && this.elevation > 0 && !this.pressed) {
|
|
223
|
-
ctx.shadowColor = 'rgba(0, 0, 0, 0.3)';
|
|
224
|
-
ctx.shadowBlur = this.elevation * 2;
|
|
225
|
-
ctx.shadowOffsetY = this.elevation;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Background
|
|
229
|
-
if (this.bgColor !== 'transparent') {
|
|
230
|
-
ctx.fillStyle = this.pressed ? this.darkenColor(this.bgColor) : this.bgColor;
|
|
231
|
-
ctx.beginPath();
|
|
232
|
-
this.roundRect(ctx, this.x, this.y, this.width, this.height, radius);
|
|
233
|
-
ctx.fill();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Réinitialiser l'ombre
|
|
237
|
-
ctx.shadowColor = 'transparent';
|
|
238
|
-
ctx.shadowBlur = 0;
|
|
239
|
-
ctx.shadowOffsetY = 0;
|
|
240
|
-
|
|
241
|
-
// Bordure
|
|
242
|
-
if (this.borderWidth > 0) {
|
|
243
|
-
ctx.strokeStyle = this.borderColor;
|
|
244
|
-
ctx.lineWidth = this.borderWidth;
|
|
245
|
-
ctx.beginPath();
|
|
246
|
-
this.roundRect(ctx, this.x, this.y, this.width, this.height, radius);
|
|
247
|
-
ctx.stroke();
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Ripple effect (Material)
|
|
251
|
-
if (this.platform === 'material') {
|
|
252
|
-
ctx.save();
|
|
253
|
-
ctx.beginPath();
|
|
254
|
-
this.roundRect(ctx, this.x, this.y, this.width, this.height, radius);
|
|
255
|
-
ctx.clip();
|
|
256
|
-
|
|
257
|
-
for (let ripple of this.ripples) {
|
|
258
|
-
ctx.globalAlpha = ripple.opacity;
|
|
259
|
-
ctx.fillStyle = this.rippleColor;
|
|
260
|
-
ctx.beginPath();
|
|
261
|
-
ctx.arc(this.x + ripple.x, this.y + ripple.y, ripple.radius, 0, Math.PI * 2);
|
|
262
|
-
ctx.fill();
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
ctx.restore();
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// Effet pressed pour iOS (overlay sombre)
|
|
269
|
-
if (this.platform === 'cupertino' && this.pressed && this.bgColor !== 'transparent') {
|
|
270
|
-
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
|
|
271
|
-
ctx.beginPath();
|
|
272
|
-
this.roundRect(ctx, this.x, this.y, this.width, this.height, radius);
|
|
273
|
-
ctx.fill();
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// Texte
|
|
277
|
-
ctx.fillStyle = this.pressed && this.platform === 'cupertino'
|
|
278
|
-
? this.darkenColor(this.textColor)
|
|
279
|
-
: this.textColor;
|
|
280
|
-
ctx.font = `${this.fontSize}px -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif`;
|
|
281
|
-
ctx.textAlign = 'center';
|
|
282
|
-
ctx.textBaseline = 'middle';
|
|
283
|
-
ctx.fillText(this.text, this.x + this.width / 2, this.y + this.height / 2);
|
|
284
|
-
|
|
285
|
-
ctx.restore();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Dessine un rectangle avec coins arrondis
|
|
290
|
-
* @private
|
|
291
|
-
*/
|
|
292
|
-
roundRect(ctx, x, y, width, height, radius) {
|
|
293
|
-
if (radius === 0) {
|
|
294
|
-
ctx.rect(x, y, width, height);
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
ctx.moveTo(x + radius, y);
|
|
299
|
-
ctx.lineTo(x + width - radius, y);
|
|
300
|
-
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
|
|
301
|
-
ctx.lineTo(x + width, y + height - radius);
|
|
302
|
-
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
|
|
303
|
-
ctx.lineTo(x + radius, y + height);
|
|
304
|
-
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
|
|
305
|
-
ctx.lineTo(x, y + radius);
|
|
306
|
-
ctx.quadraticCurveTo(x, y, x + radius, y);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Assombrit une couleur
|
|
311
|
-
* @private
|
|
312
|
-
*/
|
|
313
|
-
darkenColor(color) {
|
|
314
|
-
if (color === 'transparent') return 'rgba(0, 0, 0, 0.1)';
|
|
315
|
-
|
|
316
|
-
if (color.startsWith('rgba') || color.startsWith('rgb')) {
|
|
317
|
-
return color.replace(/[\d.]+\)$/g, match => {
|
|
318
|
-
const val = parseFloat(match);
|
|
319
|
-
return `${Math.max(0, val - 0.1)})`;
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const rgb = this.hexToRgb(color);
|
|
324
|
-
return `rgb(${Math.max(0, rgb.r - 30)}, ${Math.max(0, rgb.g - 30)}, ${Math.max(0, rgb.b - 30)})`;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Convertit hex en RGB
|
|
329
|
-
* @private
|
|
330
|
-
*/
|
|
331
|
-
hexToRgb(hex) {
|
|
332
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
333
|
-
return result ? {
|
|
334
|
-
r: parseInt(result[1], 16),
|
|
335
|
-
g: parseInt(result[2], 16),
|
|
336
|
-
b: parseInt(result[3], 16)
|
|
337
|
-
} : { r: 0, g: 0, b: 0 };
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Convertit hex en RGBA avec alpha
|
|
342
|
-
* @private
|
|
343
|
-
*/
|
|
344
|
-
hexToRgba(hex, alpha) {
|
|
345
|
-
const rgb = this.hexToRgb(hex);
|
|
346
|
-
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Vérifie si un point est dans les limites
|
|
351
|
-
*/
|
|
352
|
-
isPointInside(x, y) {
|
|
353
|
-
return x >= this.x &&
|
|
354
|
-
x <= this.x + this.width &&
|
|
355
|
-
y >= this.y &&
|
|
356
|
-
y <= this.y + this.height;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
export default Button;
|