@appius-fr/apx 2.6.0 → 2.6.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/dist/APX.dev.mjs +325 -23
- package/dist/APX.mjs +1 -1
- package/dist/APX.prod.mjs +1 -1
- package/dist/APX.standalone.js +343 -21
- package/dist/APX.standalone.js.map +1 -1
- package/modules/toast/README.md +31 -5
- package/modules/toast/css/toast.css +85 -0
- package/modules/toast/toast.mjs +176 -3
- package/modules/tools/form-packer/README.md +12 -14
- package/modules/tools/form-packer/augment-apx.mjs +4 -2
- package/modules/tools/form-packer/packToJson.mjs +58 -16
- package/package.json +1 -1
package/dist/APX.standalone.js
CHANGED
|
@@ -247,6 +247,91 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.APX-toast-container {
|
|
|
247
247
|
font-size: 16px; line-height: 1; text-align: center;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
/* Progress bar (outside content, flush to toast edges) */
|
|
251
|
+
.APX-toast__progress {
|
|
252
|
+
position: absolute;
|
|
253
|
+
left: 0;
|
|
254
|
+
right: 0;
|
|
255
|
+
height: var(--apx-toast-progress-height, 4px);
|
|
256
|
+
display: flex;
|
|
257
|
+
flex-direction: row;
|
|
258
|
+
align-items: stretch;
|
|
259
|
+
flex-shrink: 0;
|
|
260
|
+
border-radius: inherit;
|
|
261
|
+
overflow: visible;
|
|
262
|
+
}
|
|
263
|
+
.APX-toast__progress--top {
|
|
264
|
+
top: 0;
|
|
265
|
+
border-radius: var(--apx-toast-radius, 6px) var(--apx-toast-radius, 6px) 0 0;
|
|
266
|
+
}
|
|
267
|
+
.APX-toast__progress--bottom {
|
|
268
|
+
bottom: 0;
|
|
269
|
+
border-radius: 0 0 var(--apx-toast-radius, 6px) var(--apx-toast-radius, 6px);
|
|
270
|
+
}
|
|
271
|
+
/* Track contains the bar; no margin (pause button is on the corner, overlapping) */
|
|
272
|
+
.APX-toast__progress-track {
|
|
273
|
+
flex: 1;
|
|
274
|
+
min-width: 0;
|
|
275
|
+
overflow: hidden;
|
|
276
|
+
}
|
|
277
|
+
.APX-toast__progress-bar {
|
|
278
|
+
height: 100%;
|
|
279
|
+
width: 100%;
|
|
280
|
+
max-width: 100%;
|
|
281
|
+
transition: width 80ms linear;
|
|
282
|
+
background: rgba(0, 0, 0, 0.25);
|
|
283
|
+
}
|
|
284
|
+
.APX-toast--info .APX-toast__progress-bar { background: rgba(5, 44, 101, 0.5); }
|
|
285
|
+
.APX-toast--success .APX-toast__progress-bar { background: rgba(0, 0, 0, 0.25); }
|
|
286
|
+
.APX-toast--warning .APX-toast__progress-bar { background: rgba(102, 77, 3, 0.5); }
|
|
287
|
+
.APX-toast--danger .APX-toast__progress-bar { background: rgba(0, 0, 0, 0.25); }
|
|
288
|
+
/* Pause/Resume button: round, center exactly on toast corner (top-left or bottom-left) */
|
|
289
|
+
.APX-toast__progress-pause {
|
|
290
|
+
position: absolute;
|
|
291
|
+
width: var(--apx-toast-progress-pause-size, 18px);
|
|
292
|
+
height: var(--apx-toast-progress-pause-size, 18px);
|
|
293
|
+
left: 0;
|
|
294
|
+
display: inline-flex;
|
|
295
|
+
align-items: center;
|
|
296
|
+
justify-content: center;
|
|
297
|
+
background: #eee;
|
|
298
|
+
color: currentColor;
|
|
299
|
+
border: 1px solid rgba(0, 0, 0, 0.35);
|
|
300
|
+
border-radius: 50%;
|
|
301
|
+
padding: 0;
|
|
302
|
+
margin: 0;
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
line-height: 1;
|
|
305
|
+
opacity: 0.95;
|
|
306
|
+
transition: opacity 120ms ease;
|
|
307
|
+
flex-shrink: 0;
|
|
308
|
+
}
|
|
309
|
+
.APX-toast__progress--top .APX-toast__progress-pause {
|
|
310
|
+
top: 0;
|
|
311
|
+
transform: translate(-50%, -50%);
|
|
312
|
+
}
|
|
313
|
+
.APX-toast__progress--bottom .APX-toast__progress-pause {
|
|
314
|
+
bottom: 0;
|
|
315
|
+
transform: translate(-50%, 50%);
|
|
316
|
+
}
|
|
317
|
+
.APX-toast--info .APX-toast__progress-pause { background: var(--apx-toast-info-bg, #0dcaf0); border-color: rgba(5, 44, 101, 0.55); }
|
|
318
|
+
.APX-toast--success .APX-toast__progress-pause { background: var(--apx-toast-success-bg, #198754); border-color: rgba(0, 0, 0, 0.3); }
|
|
319
|
+
.APX-toast--warning .APX-toast__progress-pause { background: var(--apx-toast-warning-bg, #ffc107); border-color: rgba(102, 77, 3, 0.6); }
|
|
320
|
+
.APX-toast--danger .APX-toast__progress-pause { background: var(--apx-toast-danger-bg, #dc3545); border-color: rgba(0, 0, 0, 0.35); }
|
|
321
|
+
.APX-toast__progress-pause:hover { opacity: 1; }
|
|
322
|
+
.APX-toast__progress-pause:focus { outline: 2px solid rgba(0,0,0,.4); outline-offset: -2px; }
|
|
323
|
+
.APX-toast__progress-pause svg {
|
|
324
|
+
width: 10px;
|
|
325
|
+
height: 10px;
|
|
326
|
+
display: block;
|
|
327
|
+
}
|
|
328
|
+
/* Extra top/bottom padding when progress bar is present (default content padding 10px + bar height) */
|
|
329
|
+
.APX-toast--has-progress-top { padding-top: calc(10px + var(--apx-toast-progress-height, 4px)); }
|
|
330
|
+
.APX-toast--has-progress-bottom { padding-bottom: calc(10px + var(--apx-toast-progress-height, 4px)); }
|
|
331
|
+
/* Reserve space for stacking when pause button is present (button extends outside toast corner) */
|
|
332
|
+
.APX-toast--has-progress-top.APX-toast--has-progress-pause { margin-top: calc(var(--apx-toast-progress-pause-size, 18px) / 2); }
|
|
333
|
+
.APX-toast--has-progress-bottom.APX-toast--has-progress-pause { margin-bottom: calc(var(--apx-toast-progress-pause-size, 18px) / 2); }
|
|
334
|
+
|
|
250
335
|
/* Animations */
|
|
251
336
|
.APX-toast--enter { opacity: 0; transform: translateY(8px); }
|
|
252
337
|
.APX-toast--enter.APX-toast--enter-active { opacity: 1; transform: translateY(0); }
|
|
@@ -254,7 +339,7 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.APX-toast-container {
|
|
|
254
339
|
.APX-toast--exit.APX-toast--exit-active { opacity: 0; transform: translateY(8px); }
|
|
255
340
|
|
|
256
341
|
|
|
257
|
-
`, "",{"version":3,"sources":["webpack://./modules/toast/css/toast.css"],"names":[],"mappings":"AAAA;IACI,eAAe;IACf,aAAa;IACb,sBAAsB;IACtB,8BAA8B;IAC9B,wCAAwC;IACxC,oBAAoB;AACxB;;AAEA,qCAAqC,WAAW,EAAE,YAAY,EAAE,qBAAqB,EAAE;AACvF,oCAAoC,UAAU,EAAE,YAAY,EAAE,uBAAuB,EAAE;AACvF,kCAAkC,WAAW,EAAE,SAAS,EAAE,qBAAqB,EAAE;AACjF,iCAAiC,UAAU,EAAE,SAAS,EAAE,uBAAuB,EAAE;;AAEjF;IACI,4CAA4C;IAC5C,4CAA4C;IAC5C,2CAA2C;IAC3C,2CAA2C;IAC3C,+DAA+D;IAC/D,sDAAsD;IACtD,WAAW;IACX,gBAAgB;IAChB,oBAAoB;IACpB,kBAAkB;IAClB,oDAAoD;AACxD;;AAEA,mBAAmB,6CAA6C,EAAE,wCAAwC,EAAE;AAC5G,sBAAsB,gDAAgD,EAAE,2CAA2C,EAAE;AACrH,sBAAsB,gDAAgD,EAAE,2CAA2C,EAAE;AACrH,qBAAqB,+CAA+C,EAAE,0CAA0C,EAAE;;AAElH,sBAAsB,iBAAiB,EAAE;;AAEzC;IACI,kBAAkB;IAClB,QAAQ,EAAE,WAAW;IACrB,WAAW,EAAE,YAAY;IACzB,2BAA2B;IAC3B,oBAAoB,EAAE,mBAAmB,EAAE,uBAAuB;IAClE,uBAAuB,EAAE,mBAAmB;IAC5C,SAAS,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS;IACpD,eAAe,EAAE,gBAAgB,EAAE,wBAAwB;IAC3D,YAAY,EAAE,8BAA8B;AAChD;AACA,0BAA0B,UAAU,EAAE;AACtC,0BAA0B,iCAAiC,EAAE,mBAAmB,EAAE;AAClF;IACI,YAAY;IACZ,eAAe,EAAE,cAAc,EAAE,kBAAkB;AACvD;;AAEA,eAAe;AACf,oBAAoB,UAAU,EAAE,0BAA0B,EAAE;AAC5D,4CAA4C,UAAU,EAAE,wBAAwB,EAAE;AAClF,mBAAmB,UAAU,EAAE,wBAAwB,EAAE;AACzD,0CAA0C,UAAU,EAAE,0BAA0B,EAAE","sourcesContent":[".APX-toast-container {\r\n position: fixed;\r\n display: flex;\r\n flex-direction: column;\r\n gap: var(--apx-toast-gap, 8px);\r\n z-index: var(--apx-toast-z-index, 11000);\r\n pointer-events: none;\r\n}\r\n\r\n.APX-toast-container--bottom-right { right: 12px; bottom: 12px; align-items: flex-end; }\r\n.APX-toast-container--bottom-left { left: 12px; bottom: 12px; align-items: flex-start; }\r\n.APX-toast-container--top-right { right: 12px; top: 12px; align-items: flex-end; }\r\n.APX-toast-container--top-left { left: 12px; top: 12px; align-items: flex-start; }\r\n\r\n.APX-toast {\r\n min-width: var(--apx-toast-min-width, 260px);\r\n max-width: var(--apx-toast-max-width, 420px);\r\n font-size: var(--apx-toast-font-size, 14px);\r\n border-radius: var(--apx-toast-radius, 6px);\r\n box-shadow: var(--apx-toast-shadow, 0 6px 24px rgba(0,0,0,0.2));\r\n padding: var(--apx-toast-padding, 10px 42px 10px 14px);\r\n color: #111;\r\n background: #eee;\r\n pointer-events: auto;\r\n position: relative;\r\n transition: opacity 180ms ease, transform 180ms ease;\r\n}\r\n\r\n.APX-toast--info { background: var(--apx-toast-info-bg, #0dcaf0); color: var(--apx-toast-info-fg, #052c65); }\r\n.APX-toast--success { background: var(--apx-toast-success-bg, #198754); color: var(--apx-toast-success-fg, #ffffff); }\r\n.APX-toast--warning { background: var(--apx-toast-warning-bg, #ffc107); color: var(--apx-toast-warning-fg, #664d03); }\r\n.APX-toast--danger { background: var(--apx-toast-danger-bg, #dc3545); color: var(--apx-toast-danger-fg, #ffffff); }\r\n\r\n.APX-toast__content { line-height: 1.35; }\r\n\r\n.APX-toast__close {\r\n position: absolute;\r\n top: 50%; right: 10px;\r\n width: 24px; height: 24px;\r\n transform: translateY(-50%);\r\n display: inline-flex; align-items: center; justify-content: center;\r\n background: transparent; color: currentColor;\r\n border: 0; border-radius: 4px; padding: 0; margin: 0;\r\n cursor: pointer; appearance: none; -webkit-appearance: none;\r\n opacity: .75; transition: opacity 120ms ease;\r\n}\r\n.APX-toast__close:hover { opacity: 1; }\r\n.APX-toast__close:focus { outline: 2px solid rgba(0,0,0,.2); outline-offset: 2px; }\r\n.APX-toast__close::before {\r\n content: '×';\r\n font-size: 16px; line-height: 1; text-align: center;\r\n}\r\n\r\n/* Animations */\r\n.APX-toast--enter { opacity: 0; transform: translateY(8px); }\r\n.APX-toast--enter.APX-toast--enter-active { opacity: 1; transform: translateY(0); }\r\n.APX-toast--exit { opacity: 1; transform: translateY(0); }\r\n.APX-toast--exit.APX-toast--exit-active { opacity: 0; transform: translateY(8px); }\r\n\r\n\r\n"],"sourceRoot":""}]);
|
|
342
|
+
`, "",{"version":3,"sources":["webpack://./modules/toast/css/toast.css"],"names":[],"mappings":"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","sourcesContent":[".APX-toast-container {\r\n position: fixed;\r\n display: flex;\r\n flex-direction: column;\r\n gap: var(--apx-toast-gap, 8px);\r\n z-index: var(--apx-toast-z-index, 11000);\r\n pointer-events: none;\r\n}\r\n\r\n.APX-toast-container--bottom-right { right: 12px; bottom: 12px; align-items: flex-end; }\r\n.APX-toast-container--bottom-left { left: 12px; bottom: 12px; align-items: flex-start; }\r\n.APX-toast-container--top-right { right: 12px; top: 12px; align-items: flex-end; }\r\n.APX-toast-container--top-left { left: 12px; top: 12px; align-items: flex-start; }\r\n\r\n.APX-toast {\r\n min-width: var(--apx-toast-min-width, 260px);\r\n max-width: var(--apx-toast-max-width, 420px);\r\n font-size: var(--apx-toast-font-size, 14px);\r\n border-radius: var(--apx-toast-radius, 6px);\r\n box-shadow: var(--apx-toast-shadow, 0 6px 24px rgba(0,0,0,0.2));\r\n padding: var(--apx-toast-padding, 10px 42px 10px 14px);\r\n color: #111;\r\n background: #eee;\r\n pointer-events: auto;\r\n position: relative;\r\n transition: opacity 180ms ease, transform 180ms ease;\r\n}\r\n\r\n.APX-toast--info { background: var(--apx-toast-info-bg, #0dcaf0); color: var(--apx-toast-info-fg, #052c65); }\r\n.APX-toast--success { background: var(--apx-toast-success-bg, #198754); color: var(--apx-toast-success-fg, #ffffff); }\r\n.APX-toast--warning { background: var(--apx-toast-warning-bg, #ffc107); color: var(--apx-toast-warning-fg, #664d03); }\r\n.APX-toast--danger { background: var(--apx-toast-danger-bg, #dc3545); color: var(--apx-toast-danger-fg, #ffffff); }\r\n\r\n.APX-toast__content { line-height: 1.35; }\r\n\r\n.APX-toast__close {\r\n position: absolute;\r\n top: 50%; right: 10px;\r\n width: 24px; height: 24px;\r\n transform: translateY(-50%);\r\n display: inline-flex; align-items: center; justify-content: center;\r\n background: transparent; color: currentColor;\r\n border: 0; border-radius: 4px; padding: 0; margin: 0;\r\n cursor: pointer; appearance: none; -webkit-appearance: none;\r\n opacity: .75; transition: opacity 120ms ease;\r\n}\r\n.APX-toast__close:hover { opacity: 1; }\r\n.APX-toast__close:focus { outline: 2px solid rgba(0,0,0,.2); outline-offset: 2px; }\r\n.APX-toast__close::before {\r\n content: '×';\r\n font-size: 16px; line-height: 1; text-align: center;\r\n}\r\n\r\n/* Progress bar (outside content, flush to toast edges) */\r\n.APX-toast__progress {\r\n position: absolute;\r\n left: 0;\r\n right: 0;\r\n height: var(--apx-toast-progress-height, 4px);\r\n display: flex;\r\n flex-direction: row;\r\n align-items: stretch;\r\n flex-shrink: 0;\r\n border-radius: inherit;\r\n overflow: visible;\r\n}\r\n.APX-toast__progress--top {\r\n top: 0;\r\n border-radius: var(--apx-toast-radius, 6px) var(--apx-toast-radius, 6px) 0 0;\r\n}\r\n.APX-toast__progress--bottom {\r\n bottom: 0;\r\n border-radius: 0 0 var(--apx-toast-radius, 6px) var(--apx-toast-radius, 6px);\r\n}\r\n/* Track contains the bar; no margin (pause button is on the corner, overlapping) */\r\n.APX-toast__progress-track {\r\n flex: 1;\r\n min-width: 0;\r\n overflow: hidden;\r\n}\r\n.APX-toast__progress-bar {\r\n height: 100%;\r\n width: 100%;\r\n max-width: 100%;\r\n transition: width 80ms linear;\r\n background: rgba(0, 0, 0, 0.25);\r\n}\r\n.APX-toast--info .APX-toast__progress-bar { background: rgba(5, 44, 101, 0.5); }\r\n.APX-toast--success .APX-toast__progress-bar { background: rgba(0, 0, 0, 0.25); }\r\n.APX-toast--warning .APX-toast__progress-bar { background: rgba(102, 77, 3, 0.5); }\r\n.APX-toast--danger .APX-toast__progress-bar { background: rgba(0, 0, 0, 0.25); }\r\n/* Pause/Resume button: round, center exactly on toast corner (top-left or bottom-left) */\r\n.APX-toast__progress-pause {\r\n position: absolute;\r\n width: var(--apx-toast-progress-pause-size, 18px);\r\n height: var(--apx-toast-progress-pause-size, 18px);\r\n left: 0;\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n background: #eee;\r\n color: currentColor;\r\n border: 1px solid rgba(0, 0, 0, 0.35);\r\n border-radius: 50%;\r\n padding: 0;\r\n margin: 0;\r\n cursor: pointer;\r\n line-height: 1;\r\n opacity: 0.95;\r\n transition: opacity 120ms ease;\r\n flex-shrink: 0;\r\n}\r\n.APX-toast__progress--top .APX-toast__progress-pause {\r\n top: 0;\r\n transform: translate(-50%, -50%);\r\n}\r\n.APX-toast__progress--bottom .APX-toast__progress-pause {\r\n bottom: 0;\r\n transform: translate(-50%, 50%);\r\n}\r\n.APX-toast--info .APX-toast__progress-pause { background: var(--apx-toast-info-bg, #0dcaf0); border-color: rgba(5, 44, 101, 0.55); }\r\n.APX-toast--success .APX-toast__progress-pause { background: var(--apx-toast-success-bg, #198754); border-color: rgba(0, 0, 0, 0.3); }\r\n.APX-toast--warning .APX-toast__progress-pause { background: var(--apx-toast-warning-bg, #ffc107); border-color: rgba(102, 77, 3, 0.6); }\r\n.APX-toast--danger .APX-toast__progress-pause { background: var(--apx-toast-danger-bg, #dc3545); border-color: rgba(0, 0, 0, 0.35); }\r\n.APX-toast__progress-pause:hover { opacity: 1; }\r\n.APX-toast__progress-pause:focus { outline: 2px solid rgba(0,0,0,.4); outline-offset: -2px; }\r\n.APX-toast__progress-pause svg {\r\n width: 10px;\r\n height: 10px;\r\n display: block;\r\n}\r\n/* Extra top/bottom padding when progress bar is present (default content padding 10px + bar height) */\r\n.APX-toast--has-progress-top { padding-top: calc(10px + var(--apx-toast-progress-height, 4px)); }\r\n.APX-toast--has-progress-bottom { padding-bottom: calc(10px + var(--apx-toast-progress-height, 4px)); }\r\n/* Reserve space for stacking when pause button is present (button extends outside toast corner) */\r\n.APX-toast--has-progress-top.APX-toast--has-progress-pause { margin-top: calc(var(--apx-toast-progress-pause-size, 18px) / 2); }\r\n.APX-toast--has-progress-bottom.APX-toast--has-progress-pause { margin-bottom: calc(var(--apx-toast-progress-pause-size, 18px) / 2); }\r\n\r\n/* Animations */\r\n.APX-toast--enter { opacity: 0; transform: translateY(8px); }\r\n.APX-toast--enter.APX-toast--enter-active { opacity: 1; transform: translateY(0); }\r\n.APX-toast--exit { opacity: 1; transform: translateY(0); }\r\n.APX-toast--exit.APX-toast--exit-active { opacity: 0; transform: translateY(8px); }\r\n\r\n\r\n"],"sourceRoot":""}]);
|
|
258
343
|
// Exports
|
|
259
344
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
|
|
260
345
|
|
|
@@ -1659,6 +1744,11 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
1659
1744
|
* @property {string} [containerClass]
|
|
1660
1745
|
* @property {number} [offset]
|
|
1661
1746
|
* @property {string} [id]
|
|
1747
|
+
* @property {boolean|{enable: boolean, position: 'top'|'bottom'}} [progress] Default: false. Show progress bar when true or { enable: true, position: 'top'|'bottom' }.
|
|
1748
|
+
*/
|
|
1749
|
+
|
|
1750
|
+
/**
|
|
1751
|
+
* @typedef {{enable: boolean, position: 'top'|'bottom', pauseButton: boolean}} ProgressOpt
|
|
1662
1752
|
*/
|
|
1663
1753
|
|
|
1664
1754
|
/**
|
|
@@ -1673,6 +1763,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
1673
1763
|
* @property {string} [className]
|
|
1674
1764
|
* @property {Position} [position]
|
|
1675
1765
|
* @property {'up'|'down'|'auto'} [flow] Flow direction for stacking toasts. 'auto' determines based on position. Default: 'auto'
|
|
1766
|
+
* @property {boolean|{enable: boolean, position: 'top'|'bottom', pauseButton?: boolean}} [progress] Show progress bar: true = top, or { enable, position, pauseButton } (pauseButton default false).
|
|
1676
1767
|
*/
|
|
1677
1768
|
|
|
1678
1769
|
/**
|
|
@@ -1730,7 +1821,8 @@ var DEFAULT_CONFIG = {
|
|
|
1730
1821
|
gap: 8,
|
|
1731
1822
|
dedupe: false,
|
|
1732
1823
|
containerClass: '',
|
|
1733
|
-
offset: 0
|
|
1824
|
+
offset: 0,
|
|
1825
|
+
progress: false
|
|
1734
1826
|
};
|
|
1735
1827
|
|
|
1736
1828
|
/**
|
|
@@ -1746,6 +1838,117 @@ function createEl(tag, classNames) {
|
|
|
1746
1838
|
return el;
|
|
1747
1839
|
}
|
|
1748
1840
|
|
|
1841
|
+
/** Minimal line-based pause (two bars) / resume (triangle right) icon SVG. Uses currentColor. */
|
|
1842
|
+
function getProgressPauseResumeIconSVG(paused) {
|
|
1843
|
+
if (paused) {
|
|
1844
|
+
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\"><path d=\"M8 6L8 18L17 12Z\"/></svg>";
|
|
1845
|
+
}
|
|
1846
|
+
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\"><line x1=\"9\" y1=\"6\" x2=\"9\" y2=\"18\"/><line x1=\"15\" y1=\"6\" x2=\"15\" y2=\"18\"/></svg>";
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
/**
|
|
1850
|
+
* Create and insert progress block (track + bar, optional pause button) into toast. Button is fixed at left via track layout.
|
|
1851
|
+
* @param {HTMLElement} toastEl
|
|
1852
|
+
* @param {HTMLElement} contentEl
|
|
1853
|
+
* @param {HTMLElement|null} closeBtn
|
|
1854
|
+
* @param {ProgressOpt} progressOpt
|
|
1855
|
+
* @returns {{ wrap: HTMLElement, bar: HTMLElement, pauseBtn: HTMLElement|null }}
|
|
1856
|
+
*/
|
|
1857
|
+
function createProgressBlock(toastEl, contentEl, closeBtn, progressOpt) {
|
|
1858
|
+
var pos = progressOpt.position;
|
|
1859
|
+
var showPauseButton = progressOpt.pauseButton === true;
|
|
1860
|
+
var wrap = createEl('div', "APX-toast__progress APX-toast__progress--".concat(pos));
|
|
1861
|
+
var track = createEl('div', 'APX-toast__progress-track');
|
|
1862
|
+
var bar = createEl('div', 'APX-toast__progress-bar');
|
|
1863
|
+
bar.setAttribute('role', 'progressbar');
|
|
1864
|
+
bar.setAttribute('aria-valuemin', '0');
|
|
1865
|
+
bar.setAttribute('aria-valuemax', '100');
|
|
1866
|
+
bar.setAttribute('aria-label', 'Temps restant');
|
|
1867
|
+
bar.setAttribute('aria-valuenow', '100');
|
|
1868
|
+
bar.style.width = '100%';
|
|
1869
|
+
track.appendChild(bar);
|
|
1870
|
+
wrap.appendChild(track);
|
|
1871
|
+
var pauseBtn = null;
|
|
1872
|
+
if (showPauseButton) {
|
|
1873
|
+
pauseBtn = createEl('button', 'APX-toast__progress-pause');
|
|
1874
|
+
pauseBtn.type = 'button';
|
|
1875
|
+
pauseBtn.setAttribute('aria-label', 'Pause');
|
|
1876
|
+
pauseBtn.setAttribute('title', 'Pause');
|
|
1877
|
+
pauseBtn.innerHTML = getProgressPauseResumeIconSVG(false); // running = show pause icon
|
|
1878
|
+
wrap.insertBefore(pauseBtn, track);
|
|
1879
|
+
}
|
|
1880
|
+
if (pos === 'top') {
|
|
1881
|
+
toastEl.insertBefore(wrap, contentEl);
|
|
1882
|
+
toastEl.classList.add('APX-toast--has-progress-top');
|
|
1883
|
+
} else {
|
|
1884
|
+
toastEl.insertBefore(wrap, closeBtn);
|
|
1885
|
+
toastEl.classList.add('APX-toast--has-progress-bottom');
|
|
1886
|
+
}
|
|
1887
|
+
if (showPauseButton) toastEl.classList.add('APX-toast--has-progress-pause');
|
|
1888
|
+
return {
|
|
1889
|
+
wrap: wrap,
|
|
1890
|
+
bar: bar,
|
|
1891
|
+
pauseBtn: pauseBtn
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
/**
|
|
1896
|
+
* Update progress block position (classes + DOM order)
|
|
1897
|
+
* @param {HTMLElement} toastEl
|
|
1898
|
+
* @param {HTMLElement} progressWrap
|
|
1899
|
+
* @param {HTMLElement} contentEl
|
|
1900
|
+
* @param {HTMLElement|null} closeBtn
|
|
1901
|
+
* @param {'top'|'bottom'} pos
|
|
1902
|
+
*/
|
|
1903
|
+
function applyProgressPosition(toastEl, progressWrap, contentEl, closeBtn, pos) {
|
|
1904
|
+
toastEl.classList.remove('APX-toast--has-progress-top', 'APX-toast--has-progress-bottom');
|
|
1905
|
+
toastEl.classList.add(pos === 'top' ? 'APX-toast--has-progress-top' : 'APX-toast--has-progress-bottom');
|
|
1906
|
+
progressWrap.classList.remove('APX-toast__progress--top', 'APX-toast__progress--bottom');
|
|
1907
|
+
progressWrap.classList.add("APX-toast__progress--".concat(pos));
|
|
1908
|
+
var target = pos === 'top' ? contentEl : closeBtn;
|
|
1909
|
+
if (progressWrap.nextElementSibling !== target) toastEl.insertBefore(progressWrap, target);
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
/**
|
|
1913
|
+
* Resolve progress option from per-call option and config default
|
|
1914
|
+
* @param {boolean|{enable: boolean, position: 'top'|'bottom'}|undefined} option
|
|
1915
|
+
* @param {boolean|{enable: boolean, position: 'top'|'bottom'}|undefined} configDefault
|
|
1916
|
+
* @returns {ProgressOpt}
|
|
1917
|
+
*/
|
|
1918
|
+
function resolveProgress(option, configDefault) {
|
|
1919
|
+
var fromConfig = configDefault === true ? {
|
|
1920
|
+
enable: true,
|
|
1921
|
+
position: 'top',
|
|
1922
|
+
pauseButton: false
|
|
1923
|
+
} : configDefault && _typeof(configDefault) === 'object' ? {
|
|
1924
|
+
enable: !!configDefault.enable,
|
|
1925
|
+
position: configDefault.position === 'bottom' ? 'bottom' : 'top',
|
|
1926
|
+
pauseButton: configDefault.pauseButton === true
|
|
1927
|
+
} : {
|
|
1928
|
+
enable: false,
|
|
1929
|
+
position: 'top',
|
|
1930
|
+
pauseButton: false
|
|
1931
|
+
};
|
|
1932
|
+
if (option === undefined || option === null) return fromConfig;
|
|
1933
|
+
if (option === true) return {
|
|
1934
|
+
enable: true,
|
|
1935
|
+
position: 'top',
|
|
1936
|
+
pauseButton: false
|
|
1937
|
+
};
|
|
1938
|
+
if (_typeof(option) === 'object') {
|
|
1939
|
+
return {
|
|
1940
|
+
enable: !!option.enable,
|
|
1941
|
+
position: option.position === 'bottom' ? 'bottom' : 'top',
|
|
1942
|
+
pauseButton: option.pauseButton === true
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
return {
|
|
1946
|
+
enable: false,
|
|
1947
|
+
position: 'top',
|
|
1948
|
+
pauseButton: false
|
|
1949
|
+
};
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1749
1952
|
/**
|
|
1750
1953
|
* Normalize placement synonyms to CSS values
|
|
1751
1954
|
* @param {string} placement
|
|
@@ -2016,6 +2219,15 @@ var ToastManager = /*#__PURE__*/function () {
|
|
|
2016
2219
|
closeBtn.type = 'button';
|
|
2017
2220
|
toastEl.appendChild(closeBtn);
|
|
2018
2221
|
}
|
|
2222
|
+
var progressWrap = null;
|
|
2223
|
+
var progressBarEl = null;
|
|
2224
|
+
var progressPauseBtn = null;
|
|
2225
|
+
if (options.progress.enable && options.durationMs > 0) {
|
|
2226
|
+
var created = createProgressBlock(toastEl, contentEl, closeBtn, options.progress);
|
|
2227
|
+
progressWrap = created.wrap;
|
|
2228
|
+
progressBarEl = created.bar;
|
|
2229
|
+
progressPauseBtn = created.pauseBtn;
|
|
2230
|
+
}
|
|
2019
2231
|
|
|
2020
2232
|
// Get or create container for this specific position
|
|
2021
2233
|
var container = null;
|
|
@@ -2193,6 +2405,8 @@ var ToastManager = /*#__PURE__*/function () {
|
|
|
2193
2405
|
var remaining = options.durationMs;
|
|
2194
2406
|
var timerId = null;
|
|
2195
2407
|
var startTs = null;
|
|
2408
|
+
var userPaused = false;
|
|
2409
|
+
var progressRafId = null;
|
|
2196
2410
|
var handlers = {
|
|
2197
2411
|
click: new Set(),
|
|
2198
2412
|
close: new Set()
|
|
@@ -2203,6 +2417,19 @@ var ToastManager = /*#__PURE__*/function () {
|
|
|
2203
2417
|
timerId = window.setTimeout(function () {
|
|
2204
2418
|
return ref.close('timeout');
|
|
2205
2419
|
}, remaining);
|
|
2420
|
+
if (progressBarEl) {
|
|
2421
|
+
var tick = function tick() {
|
|
2422
|
+
if (timerId == null || startTs == null) return;
|
|
2423
|
+
var elapsed = Date.now() - startTs;
|
|
2424
|
+
var remainingMs = Math.max(0, remaining - elapsed);
|
|
2425
|
+
var durationMs = options.durationMs;
|
|
2426
|
+
var pct = durationMs > 0 ? Math.max(0, Math.min(100, remainingMs / durationMs * 100)) : 0;
|
|
2427
|
+
progressBarEl.style.width = "".concat(pct, "%");
|
|
2428
|
+
progressBarEl.setAttribute('aria-valuenow', String(Math.round(pct)));
|
|
2429
|
+
progressRafId = requestAnimationFrame(tick);
|
|
2430
|
+
};
|
|
2431
|
+
progressRafId = requestAnimationFrame(tick);
|
|
2432
|
+
}
|
|
2206
2433
|
};
|
|
2207
2434
|
var pauseTimer = function pauseTimer() {
|
|
2208
2435
|
if (timerId != null) {
|
|
@@ -2210,6 +2437,21 @@ var ToastManager = /*#__PURE__*/function () {
|
|
|
2210
2437
|
timerId = null;
|
|
2211
2438
|
if (startTs != null) remaining -= Date.now() - startTs;
|
|
2212
2439
|
}
|
|
2440
|
+
if (progressRafId != null) {
|
|
2441
|
+
cancelAnimationFrame(progressRafId);
|
|
2442
|
+
progressRafId = null;
|
|
2443
|
+
}
|
|
2444
|
+
};
|
|
2445
|
+
var attachProgressPauseHandler = function attachProgressPauseHandler(btn) {
|
|
2446
|
+
btn.addEventListener('click', function (ev) {
|
|
2447
|
+
ev.stopPropagation();
|
|
2448
|
+
userPaused = !userPaused;
|
|
2449
|
+
if (userPaused) pauseTimer();else startTimer();
|
|
2450
|
+
var label = userPaused ? 'Reprendre' : 'Pause';
|
|
2451
|
+
btn.setAttribute('aria-label', label);
|
|
2452
|
+
btn.setAttribute('title', label);
|
|
2453
|
+
btn.innerHTML = getProgressPauseResumeIconSVG(userPaused); // paused = resume (triangle)
|
|
2454
|
+
});
|
|
2213
2455
|
};
|
|
2214
2456
|
|
|
2215
2457
|
/** @type {ToastRef} */
|
|
@@ -2239,9 +2481,34 @@ var ToastManager = /*#__PURE__*/function () {
|
|
|
2239
2481
|
if (options.className) (_toastEl$classList = toastEl.classList).remove.apply(_toastEl$classList, _toConsumableArray(options.className.split(' ').filter(Boolean)));
|
|
2240
2482
|
if (merged.className) (_toastEl$classList2 = toastEl.classList).add.apply(_toastEl$classList2, _toConsumableArray(merged.className.split(' ').filter(Boolean)));
|
|
2241
2483
|
}
|
|
2484
|
+
// update progress visibility/position
|
|
2485
|
+
options.progress = merged.progress;
|
|
2486
|
+
if (progressWrap) {
|
|
2487
|
+
if (!merged.progress.enable || merged.durationMs <= 0) {
|
|
2488
|
+
progressWrap.style.display = 'none';
|
|
2489
|
+
} else {
|
|
2490
|
+
progressWrap.style.display = '';
|
|
2491
|
+
applyProgressPosition(toastEl, progressWrap, contentEl, closeBtn, merged.progress.position);
|
|
2492
|
+
}
|
|
2493
|
+
} else if (merged.progress.enable && merged.durationMs > 0) {
|
|
2494
|
+
var _created = createProgressBlock(toastEl, contentEl, closeBtn, merged.progress);
|
|
2495
|
+
progressWrap = _created.wrap;
|
|
2496
|
+
progressBarEl = _created.bar;
|
|
2497
|
+
progressPauseBtn = _created.pauseBtn;
|
|
2498
|
+
if (progressPauseBtn) attachProgressPauseHandler(progressPauseBtn);
|
|
2499
|
+
}
|
|
2500
|
+
if (progressWrap && progressWrap.style.display !== 'none' && merged.progress.pauseButton === true) {
|
|
2501
|
+
toastEl.classList.add('APX-toast--has-progress-pause');
|
|
2502
|
+
} else {
|
|
2503
|
+
toastEl.classList.remove('APX-toast--has-progress-pause');
|
|
2504
|
+
}
|
|
2242
2505
|
// update duration logic
|
|
2243
2506
|
options.durationMs = merged.durationMs;
|
|
2244
2507
|
remaining = merged.durationMs;
|
|
2508
|
+
if (progressBarEl) {
|
|
2509
|
+
progressBarEl.style.width = '100%';
|
|
2510
|
+
progressBarEl.setAttribute('aria-valuenow', '100');
|
|
2511
|
+
}
|
|
2245
2512
|
pauseTimer();
|
|
2246
2513
|
startTimer();
|
|
2247
2514
|
},
|
|
@@ -2278,7 +2545,10 @@ var ToastManager = /*#__PURE__*/function () {
|
|
|
2278
2545
|
var cleanup = function cleanup(reason) {
|
|
2279
2546
|
if (!toastEl) return;
|
|
2280
2547
|
pauseTimer();
|
|
2281
|
-
|
|
2548
|
+
if (progressRafId != null) {
|
|
2549
|
+
cancelAnimationFrame(progressRafId);
|
|
2550
|
+
progressRafId = null;
|
|
2551
|
+
}
|
|
2282
2552
|
// Cleanup position listeners and restore styles
|
|
2283
2553
|
if (positionCleanup) {
|
|
2284
2554
|
positionCleanup();
|
|
@@ -2333,12 +2603,13 @@ var ToastManager = /*#__PURE__*/function () {
|
|
|
2333
2603
|
// Hover pause
|
|
2334
2604
|
toastEl.addEventListener('mouseenter', pauseTimer);
|
|
2335
2605
|
toastEl.addEventListener('mouseleave', function () {
|
|
2336
|
-
|
|
2606
|
+
if (!userPaused) startTimer();
|
|
2337
2607
|
});
|
|
2338
2608
|
if (closeBtn) closeBtn.addEventListener('click', function (ev) {
|
|
2339
2609
|
ev.stopPropagation();
|
|
2340
2610
|
ref.close('close');
|
|
2341
2611
|
});
|
|
2612
|
+
if (progressPauseBtn) attachProgressPauseHandler(progressPauseBtn);
|
|
2342
2613
|
|
|
2343
2614
|
// Track
|
|
2344
2615
|
this.open.push(ref);
|
|
@@ -2410,6 +2681,7 @@ var ToastManager = /*#__PURE__*/function () {
|
|
|
2410
2681
|
if (typeof o.durationMs !== 'number') o.durationMs = this.config.defaultDurationMs;
|
|
2411
2682
|
// Use id from options if provided, otherwise use id from config, otherwise undefined (will be auto-generated)
|
|
2412
2683
|
if (!o.id && this.config.id) o.id = this.config.id;
|
|
2684
|
+
o.progress = resolveProgress(opts.progress, this.config.progress);
|
|
2413
2685
|
return o;
|
|
2414
2686
|
}
|
|
2415
2687
|
|
|
@@ -2784,12 +3056,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2784
3056
|
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(apx) {
|
|
2785
3057
|
/**
|
|
2786
3058
|
* Convertit le premier formulaire sélectionné en objet JSON
|
|
3059
|
+
* @param {Object} [options] - Options passées à packFormToJSON (ex. { numericKeysAlwaysArray: true })
|
|
2787
3060
|
* @returns {Object} L'objet JSON résultant
|
|
2788
3061
|
* @throws {Error} Si aucun formulaire n'est trouvé ou si le premier élément n'est pas un formulaire
|
|
2789
3062
|
* @example
|
|
2790
3063
|
* const data = APX('form.myformclass').pack();
|
|
3064
|
+
* const dataLegacy = APX('form').pack({ numericKeysAlwaysArray: true });
|
|
2791
3065
|
*/
|
|
2792
|
-
apx.pack = function () {
|
|
3066
|
+
apx.pack = function (options) {
|
|
2793
3067
|
var firstElement = this.first();
|
|
2794
3068
|
if (!firstElement) {
|
|
2795
3069
|
throw new Error('No element found');
|
|
@@ -2797,7 +3071,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2797
3071
|
if (firstElement.tagName !== 'FORM') {
|
|
2798
3072
|
throw new Error('Element is not a form');
|
|
2799
3073
|
}
|
|
2800
|
-
return (0,_packToJson_mjs__WEBPACK_IMPORTED_MODULE_0__.packFormToJSON)(firstElement);
|
|
3074
|
+
return (0,_packToJson_mjs__WEBPACK_IMPORTED_MODULE_0__.packFormToJSON)(firstElement, options);
|
|
2801
3075
|
};
|
|
2802
3076
|
return apx;
|
|
2803
3077
|
}
|
|
@@ -2816,6 +3090,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2816
3090
|
/* harmony export */ packFormToJSON: () => (/* binding */ packFormToJSON)
|
|
2817
3091
|
/* harmony export */ });
|
|
2818
3092
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3093
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3094
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3095
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
3096
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
2819
3097
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2820
3098
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
2821
3099
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
@@ -2826,14 +3104,18 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
2826
3104
|
/**
|
|
2827
3105
|
* Convertit un formulaire HTML en objet JSON
|
|
2828
3106
|
* @param {HTMLFormElement} form - Le formulaire à convertir
|
|
3107
|
+
* @param {Object} [options] - Options de conversion
|
|
3108
|
+
* @param {boolean} [options.numericKeysAlwaysArray=false] - Si true, toute clé numérique est traitée comme index de tableau (comportement d'avant 2.6.2). Sinon, heuristique : tableau seulement si indices denses 0,1,2,…,n.
|
|
2829
3109
|
* @returns {Object} L'objet JSON résultant
|
|
2830
3110
|
* @throws {TypeError} Si form n'est pas un HTMLFormElement
|
|
2831
3111
|
*/
|
|
2832
3112
|
var packFormToJSON = function packFormToJSON(form) {
|
|
3113
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2833
3114
|
// Validation de l'entrée
|
|
2834
3115
|
if (!form || !(form instanceof HTMLFormElement)) {
|
|
2835
3116
|
throw new TypeError('packFormToJSON expects an HTMLFormElement');
|
|
2836
3117
|
}
|
|
3118
|
+
var numericKeysAlwaysArray = options.numericKeysAlwaysArray === true;
|
|
2837
3119
|
var formData = new FormData(form);
|
|
2838
3120
|
var jsonData = {};
|
|
2839
3121
|
|
|
@@ -2872,6 +3154,7 @@ var packFormToJSON = function packFormToJSON(form) {
|
|
|
2872
3154
|
|
|
2873
3155
|
var pathUsage = new Map(); // Map<pathString, PathUsage>
|
|
2874
3156
|
var keyAnalysis = new Map(); // Map<basePath, {hasNumeric: boolean, hasString: boolean}>
|
|
3157
|
+
var numericIndicesByPath = new Map(); // Map<pathString, Set<number>> — indices under each parent path
|
|
2875
3158
|
var allEntries = [];
|
|
2876
3159
|
|
|
2877
3160
|
/**
|
|
@@ -2931,6 +3214,13 @@ var packFormToJSON = function packFormToJSON(form) {
|
|
|
2931
3214
|
if (_part.type === 'key') {
|
|
2932
3215
|
currentPath = currentPath ? "".concat(currentPath, "[").concat(_part.name, "]") : _part.name;
|
|
2933
3216
|
} else if (_part.type === 'numeric') {
|
|
3217
|
+
var _parentPath = currentPath;
|
|
3218
|
+
var set = numericIndicesByPath.get(_parentPath);
|
|
3219
|
+
if (!set) {
|
|
3220
|
+
set = new Set();
|
|
3221
|
+
numericIndicesByPath.set(_parentPath, set);
|
|
3222
|
+
}
|
|
3223
|
+
set.add(_part.index);
|
|
2934
3224
|
currentPath = "".concat(currentPath, "[").concat(_part.index, "]");
|
|
2935
3225
|
} else if (_part.type === 'array') {
|
|
2936
3226
|
currentPath = "".concat(currentPath, "[]");
|
|
@@ -3054,6 +3344,36 @@ var packFormToJSON = function packFormToJSON(form) {
|
|
|
3054
3344
|
return (analysis === null || analysis === void 0 ? void 0 : analysis.hasNumeric) && (analysis === null || analysis === void 0 ? void 0 : analysis.hasString);
|
|
3055
3345
|
};
|
|
3056
3346
|
|
|
3347
|
+
/**
|
|
3348
|
+
* True if indices are exactly 0, 1, 2, ..., n (dense, sequential from 0).
|
|
3349
|
+
* @param {number[]} indices - Sorted array of indices
|
|
3350
|
+
* @returns {boolean}
|
|
3351
|
+
*/
|
|
3352
|
+
var isDenseSequential = function isDenseSequential(indices) {
|
|
3353
|
+
if (indices.length === 0) return false;
|
|
3354
|
+
var sorted = _toConsumableArray(indices).sort(function (a, b) {
|
|
3355
|
+
return a - b;
|
|
3356
|
+
});
|
|
3357
|
+
for (var j = 0; j < sorted.length; j++) {
|
|
3358
|
+
if (sorted[j] !== j) return false;
|
|
3359
|
+
}
|
|
3360
|
+
return true;
|
|
3361
|
+
};
|
|
3362
|
+
|
|
3363
|
+
/**
|
|
3364
|
+
* True if numeric keys under this path should be treated as array indices.
|
|
3365
|
+
* With numericKeysAlwaysArray: always true when path has numeric children.
|
|
3366
|
+
* Otherwise: true only when indices are dense 0..n.
|
|
3367
|
+
* @param {string} parentPath - Path to the container that has numeric children
|
|
3368
|
+
* @returns {boolean}
|
|
3369
|
+
*/
|
|
3370
|
+
var useArrayForNumericPath = function useArrayForNumericPath(parentPath) {
|
|
3371
|
+
var set = numericIndicesByPath.get(parentPath);
|
|
3372
|
+
if (!set || set.size === 0) return true;
|
|
3373
|
+
if (numericKeysAlwaysArray) return true;
|
|
3374
|
+
return isDenseSequential(_toConsumableArray(set));
|
|
3375
|
+
};
|
|
3376
|
+
|
|
3057
3377
|
/**
|
|
3058
3378
|
* Convertit un tableau en objet en préservant les indices numériques comme propriétés
|
|
3059
3379
|
* @param {Array} arr - Le tableau à convertir
|
|
@@ -3156,8 +3476,9 @@ var packFormToJSON = function packFormToJSON(form) {
|
|
|
3156
3476
|
* @param {*} value - La valeur à assigner
|
|
3157
3477
|
* @param {Object} parent - Le conteneur parent
|
|
3158
3478
|
* @param {string} basePath - Le chemin de base pour la détection de conflit
|
|
3479
|
+
* @param {string} parentPath - Chemin du conteneur actuel (pour heuristique numeric)
|
|
3159
3480
|
*/
|
|
3160
|
-
var processFinalValue = function processFinalValue(container, part, value, parent, basePath) {
|
|
3481
|
+
var processFinalValue = function processFinalValue(container, part, value, parent, basePath, parentPath) {
|
|
3161
3482
|
if (part.type === 'array') {
|
|
3162
3483
|
var _container, _part$name, _container$_part$name;
|
|
3163
3484
|
// Tableau explicite avec []
|
|
@@ -3168,13 +3489,18 @@ var packFormToJSON = function packFormToJSON(form) {
|
|
|
3168
3489
|
container[part.name] = [container[part.name], value];
|
|
3169
3490
|
}
|
|
3170
3491
|
} else if (part.type === 'numeric') {
|
|
3171
|
-
// Indice numérique final
|
|
3172
3492
|
var index = part.index;
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
container.
|
|
3493
|
+
var useArray = useArrayForNumericPath(parentPath);
|
|
3494
|
+
if (useArray) {
|
|
3495
|
+
container = ensureArray(container, parent.key, parent.container);
|
|
3496
|
+
while (container.length <= index) {
|
|
3497
|
+
container.push(undefined);
|
|
3498
|
+
}
|
|
3499
|
+
container[index] = value;
|
|
3500
|
+
} else {
|
|
3501
|
+
container = ensureObject(container, parent.key, parent.container, true);
|
|
3502
|
+
container[index] = value;
|
|
3176
3503
|
}
|
|
3177
|
-
container[index] = value;
|
|
3178
3504
|
} else {
|
|
3179
3505
|
// Clé simple finale
|
|
3180
3506
|
var conflict = hasConflict(basePath);
|
|
@@ -3218,30 +3544,26 @@ var packFormToJSON = function packFormToJSON(form) {
|
|
|
3218
3544
|
*/
|
|
3219
3545
|
var processIntermediatePart = function processIntermediatePart(container, part, nextPart, parent, basePath, parts, i, key) {
|
|
3220
3546
|
if (part.type === 'numeric') {
|
|
3221
|
-
// Indice numérique : le container doit être un tableau ou un objet (selon conflit)
|
|
3222
3547
|
var index = part.index;
|
|
3223
|
-
var
|
|
3224
|
-
|
|
3548
|
+
var parentPath = buildPathString(parts.slice(0, i));
|
|
3549
|
+
var useArray = useArrayForNumericPath(parentPath) && !hasConflict(basePath);
|
|
3550
|
+
if (!useArray) {
|
|
3225
3551
|
var _container2, _container2$index;
|
|
3226
|
-
// Conflit : utiliser un objet (les indices seront des propriétés)
|
|
3227
3552
|
container = ensureObject(container, parent.key, parent.container, true);
|
|
3228
3553
|
(_container2$index = (_container2 = container)[index]) !== null && _container2$index !== void 0 ? _container2$index : _container2[index] = {};
|
|
3229
3554
|
if (_typeof(container[index]) !== 'object' || container[index] === null) {
|
|
3230
|
-
// Cette erreur ne devrait jamais se produire si la détection fonctionne correctement
|
|
3231
3555
|
var pathParts = parts.slice(0, i + 1);
|
|
3232
3556
|
var currentPath = buildPathString(pathParts);
|
|
3233
3557
|
throw new Error("Cannot access property on primitive value. " + "Key \"".concat(key, "\" tries to access \"").concat(currentPath, "\" but it is already a ").concat(_typeof(container[index]), " value: ").concat(JSON.stringify(container[index]), ". ") + "This should have been detected during conflict detection phase.");
|
|
3234
3558
|
}
|
|
3235
3559
|
} else {
|
|
3236
3560
|
var _container3, _container3$index;
|
|
3237
|
-
// Pas de conflit : utiliser un tableau
|
|
3238
3561
|
container = ensureArray(container, parent.key, parent.container);
|
|
3239
3562
|
while (container.length <= index) {
|
|
3240
3563
|
container.push(undefined);
|
|
3241
3564
|
}
|
|
3242
3565
|
(_container3$index = (_container3 = container)[index]) !== null && _container3$index !== void 0 ? _container3$index : _container3[index] = {};
|
|
3243
3566
|
if (_typeof(container[index]) !== 'object' || container[index] === null) {
|
|
3244
|
-
// Cette erreur ne devrait jamais se produire si la détection fonctionne correctement
|
|
3245
3567
|
var _pathParts = parts.slice(0, i + 1);
|
|
3246
3568
|
var _currentPath = buildPathString(_pathParts);
|
|
3247
3569
|
throw new Error("Cannot access property on primitive value. " + "Key \"".concat(key, "\" tries to access \"").concat(_currentPath, "\" but it is already a ").concat(_typeof(container[index]), " value: ").concat(JSON.stringify(container[index]), ". ") + "This should have been detected during conflict detection phase.");
|
|
@@ -3317,8 +3639,8 @@ var packFormToJSON = function packFormToJSON(form) {
|
|
|
3317
3639
|
var nextPart = i + 1 < parts.length ? parts[i + 1] : null;
|
|
3318
3640
|
var parent = path[path.length - 1];
|
|
3319
3641
|
if (isLast) {
|
|
3320
|
-
|
|
3321
|
-
processFinalValue(container, part, value, parent, basePath);
|
|
3642
|
+
var parentPath = buildPathString(parts.slice(0, i));
|
|
3643
|
+
processFinalValue(container, part, value, parent, basePath, parentPath);
|
|
3322
3644
|
} else {
|
|
3323
3645
|
// Partie intermédiaire : créer la structure
|
|
3324
3646
|
var newContainer = processIntermediatePart(container, part, nextPart, parent, basePath, parts, i, key);
|