@ouestfrance/sipa-bms-ui 8.44.0 → 8.46.0
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/components/form/bms-input-code.linters.d.ts +20 -14
- package/dist/sipa-bms-ui.es.js +46 -4
- package/dist/sipa-bms-ui.es.js.map +1 -1
- package/dist/sipa-bms-ui.umd.js +46 -3
- package/dist/sipa-bms-ui.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form/bms-input-code.linters.spec.ts +14 -3
- package/src/components/form/bms-input-code.linters.ts +56 -4
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import { Diagnostic } from '@codemirror/lint';
|
|
2
2
|
import { Extension } from '@codemirror/state';
|
|
3
|
-
/**
|
|
4
|
-
* Retourne les diagnostics HTML pour un code donné.
|
|
5
|
-
* Parse le contenu comme du XML strict pour détecter les erreurs de structure.
|
|
6
|
-
*
|
|
7
|
-
* Comportement attendu :
|
|
8
|
-
* - Chaîne vide → aucun diagnostic
|
|
9
|
-
* - HTML bien formé (`<div><p>Hello</p></div>`) → aucun diagnostic
|
|
10
|
-
* - Balises auto-fermantes XHTML (`<br />`, `<img />`) → aucun diagnostic
|
|
11
|
-
* - Balise non fermée (`<div><p>Hello</div>`) → diagnostic « HTML invalide »
|
|
12
|
-
* - Attribut mal formé (`<div class=>`) → diagnostic « HTML invalide »
|
|
13
|
-
*
|
|
14
|
-
* Limitation : le parser XML est plus strict que le parser HTML du navigateur.
|
|
15
|
-
* Les balises void HTML5 non fermées (`<br>`, `<img>`) sont considérées invalides.
|
|
16
|
-
*/
|
|
17
3
|
export declare const htmlDiagnostics: (code: string) => Diagnostic[];
|
|
18
4
|
/**
|
|
19
5
|
* Retourne les diagnostics CSS pour un code donné.
|
|
@@ -65,4 +51,24 @@ export declare const cssSyntaxLinter: () => Extension;
|
|
|
65
51
|
* <BmsInputCode type="javascript" :extra-extensions="[lintGutter(), jsSyntaxLinter()]" />
|
|
66
52
|
*/
|
|
67
53
|
export declare const jsSyntaxLinter: () => Extension;
|
|
54
|
+
/**
|
|
55
|
+
* Extension CodeMirror qui appelle `onValidation` à chaque fois que le résultat
|
|
56
|
+
* des linters change, en passant `true` si aucun diagnostic n'est présent.
|
|
57
|
+
*
|
|
58
|
+
* Utile pour synchroniser l'état de validation du linter avec un état Vue externe
|
|
59
|
+
* (ex: désactiver un bouton de soumission).
|
|
60
|
+
*
|
|
61
|
+
* Comportement attendu :
|
|
62
|
+
* - Appelé après chaque cycle de lint (asynchrone, après le debounce du linter)
|
|
63
|
+
* - `valid: true` → aucun diagnostic actif dans l'éditeur
|
|
64
|
+
* - `valid: false` → au moins un diagnostic présent
|
|
65
|
+
*
|
|
66
|
+
* Note : démarre à `true` (avant le premier lint). Combiner avec une validation
|
|
67
|
+
* côté formulaire (champ non vide) pour éviter de soumettre avant le premier lint.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* const sourceValid = ref(true);
|
|
71
|
+
* const extensions = [lintGutter(), htmlSyntaxLinter(), lintValidationListener((v) => { sourceValid.value = v; })];
|
|
72
|
+
*/
|
|
73
|
+
export declare const lintValidationListener: (onValidation: (valid: boolean) => void) => Extension;
|
|
68
74
|
export { linter, lintGutter } from '@codemirror/lint';
|
package/dist/sipa-bms-ui.es.js
CHANGED
|
@@ -79910,6 +79910,13 @@ var lintState = /* @__PURE__ */ StateField.define({
|
|
|
79910
79910
|
},
|
|
79911
79911
|
provide: (f) => [showPanel.from(f, (val) => val.panel), EditorView.decorations.from(f, (s) => s.diagnostics)]
|
|
79912
79912
|
});
|
|
79913
|
+
/**
|
|
79914
|
+
Returns the number of active lint diagnostics in the given state.
|
|
79915
|
+
*/
|
|
79916
|
+
function diagnosticCount(state) {
|
|
79917
|
+
let lint = state.field(lintState, false);
|
|
79918
|
+
return lint ? lint.diagnostics.size : 0;
|
|
79919
|
+
}
|
|
79913
79920
|
var activeMark = /* @__PURE__ */ Decoration.mark({ class: "cm-lintRange cm-lintRange-active" });
|
|
79914
79921
|
function lintTooltip(view, pos, side) {
|
|
79915
79922
|
let { diagnostics } = view.state.field(lintState);
|
|
@@ -112756,12 +112763,25 @@ var useDarkMode = () => {
|
|
|
112756
112763
|
* Limitation : le parser XML est plus strict que le parser HTML du navigateur.
|
|
112757
112764
|
* Les balises void HTML5 non fermées (`<br>`, `<img>`) sont considérées invalides.
|
|
112758
112765
|
*/
|
|
112766
|
+
var ROOT_TAG = "<root>";
|
|
112767
|
+
var htmlErrorOffset = (errorText, code) => {
|
|
112768
|
+
const match = errorText.match(/error on line (\d+) at column (\d+)/i);
|
|
112769
|
+
if (!match) return 0;
|
|
112770
|
+
const line = parseInt(match[1]);
|
|
112771
|
+
const col = parseInt(match[2]) - (line === 1 ? 6 : 0);
|
|
112772
|
+
const lines = code.split("\n");
|
|
112773
|
+
let offset = 0;
|
|
112774
|
+
for (let i = 0; i < line - 1 && i < lines.length; i++) offset += lines[i].length + 1;
|
|
112775
|
+
return Math.min(Math.max(0, offset + col - 1), code.length);
|
|
112776
|
+
};
|
|
112759
112777
|
var htmlDiagnostics = (code) => {
|
|
112760
112778
|
if (!code.trim()) return [];
|
|
112761
|
-
|
|
112779
|
+
const parserError = new DOMParser().parseFromString(`${ROOT_TAG}${code}</root>`, "text/xml").querySelector("parsererror");
|
|
112780
|
+
if (!parserError) return [];
|
|
112781
|
+
const from = htmlErrorOffset(parserError.textContent ?? "", code);
|
|
112762
112782
|
return [{
|
|
112763
|
-
from
|
|
112764
|
-
to: code.length,
|
|
112783
|
+
from,
|
|
112784
|
+
to: Math.min(from + 1, code.length),
|
|
112765
112785
|
severity: "error",
|
|
112766
112786
|
message: "HTML invalide : balise mal formée ou non fermée"
|
|
112767
112787
|
}];
|
|
@@ -112844,6 +112864,28 @@ var cssSyntaxLinter = () => linter((view) => cssDiagnostics(view.state.doc.toStr
|
|
|
112844
112864
|
* <BmsInputCode type="javascript" :extra-extensions="[lintGutter(), jsSyntaxLinter()]" />
|
|
112845
112865
|
*/
|
|
112846
112866
|
var jsSyntaxLinter = () => linter((view) => jsDiagnostics(view.state.doc.toString()));
|
|
112867
|
+
/**
|
|
112868
|
+
* Extension CodeMirror qui appelle `onValidation` à chaque fois que le résultat
|
|
112869
|
+
* des linters change, en passant `true` si aucun diagnostic n'est présent.
|
|
112870
|
+
*
|
|
112871
|
+
* Utile pour synchroniser l'état de validation du linter avec un état Vue externe
|
|
112872
|
+
* (ex: désactiver un bouton de soumission).
|
|
112873
|
+
*
|
|
112874
|
+
* Comportement attendu :
|
|
112875
|
+
* - Appelé après chaque cycle de lint (asynchrone, après le debounce du linter)
|
|
112876
|
+
* - `valid: true` → aucun diagnostic actif dans l'éditeur
|
|
112877
|
+
* - `valid: false` → au moins un diagnostic présent
|
|
112878
|
+
*
|
|
112879
|
+
* Note : démarre à `true` (avant le premier lint). Combiner avec une validation
|
|
112880
|
+
* côté formulaire (champ non vide) pour éviter de soumettre avant le premier lint.
|
|
112881
|
+
*
|
|
112882
|
+
* @example
|
|
112883
|
+
* const sourceValid = ref(true);
|
|
112884
|
+
* const extensions = [lintGutter(), htmlSyntaxLinter(), lintValidationListener((v) => { sourceValid.value = v; })];
|
|
112885
|
+
*/
|
|
112886
|
+
var lintValidationListener = (onValidation) => EditorView.updateListener.of((update) => {
|
|
112887
|
+
if (update.transactions.some((t) => t.effects.length > 0) || update.docChanged) onValidation(diagnosticCount(update.state) === 0);
|
|
112888
|
+
});
|
|
112847
112889
|
//#endregion
|
|
112848
112890
|
//#region src/plugins/feature-flipper/featureFlipper.composable.ts
|
|
112849
112891
|
var features = ref({});
|
|
@@ -114631,6 +114673,6 @@ var createBmsUi = () => ({ install: (app) => {
|
|
|
114631
114673
|
app.component("BmsRelativeTime", BmsRelativeTime_default);
|
|
114632
114674
|
} });
|
|
114633
114675
|
//#endregion
|
|
114634
|
-
export { BMS_FORM_VALID_URL_REGEX, BmsAlert_default as BmsAlert, BmsAutocomplete_default as BmsAutocomplete, BmsBackButton_default as BmsBackButton, BmsBadge_default as BmsBadge, BmsBetweenInput_default as BmsBetweenInput, BmsBreadcrumb_default as BmsBreadcrumb, BmsButton_default as BmsButton, BmsCaption_default as BmsCaption, BmsCard_default as BmsCard, BmsChip_default as BmsChip, BmsCircularProgress_default as BmsCircularProgress, BmsCocarde_default as BmsCocarde, BmsCombobox_default as BmsCombobox, BmsContentPageLayout_default as BmsContentPageLayout, DraggableList_default as BmsDraggableList, BmsEmptyScreen_default as BmsEmptyScreen, BmsFilePicker_default as BmsFilePicker, BmsFixedMenu_default as BmsFixedMenu, BmsFloatingWindow_default as BmsFloatingWindow, BmsForm_default as BmsForm, BmsGhost_default as BmsGhost, BmsHeader_default as BmsHeader, BmsHeaderTitle_default as BmsHeaderTitle, BmsIconButton_default as BmsIconButton, BmsInputBooleanCheckbox_default as BmsInputBooleanCheckbox, BmsInputCheckboxCaption_default as BmsInputCheckboxCaption, BmsInputCheckboxCaptionGroup_default as BmsInputCheckboxCaptionGroup, BmsInputCheckboxGroup_default as BmsInputCheckboxGroup, BmsInputCode_default as BmsInputCode, BmsInputDateTime_default as BmsInputDateTime, BmsInputFile_default as BmsInputFile, BmsInputNumber_default as BmsInputNumber, BmsInputRadio_default as BmsInputRadio, BmsInputRadioCaption_default as BmsInputRadioCaption, BmsInputRadioCaptionGroup_default as BmsInputRadioCaptionGroup, BmsInputRadioGroup_default as BmsInputRadioGroup, BmsInputText_default as BmsInputText, BmsInputTime_default as BmsInputTime, BmsInputToggle_default as BmsInputToggle, BmsLink_default as BmsLink, BmsLoader_default as BmsLoader, BmsMenu_default as BmsMenu, BmsMenuNav_default as BmsMenuNav, BmsModal_default as BmsModal, BmsMultiSelect_default as BmsMultiSelect, BmsNotificationsInstance, BmsOverlay_default as BmsOverlay, BmsPagination_default as BmsPagination, BmsProblem_default as BmsProblem, BmsRelativeTime_default as BmsRelativeTime, BmsSearch_default as BmsSearch, BmsSection_default as BmsSection, BmsSelect_default as BmsSelect, BmsServerAutocomplete_default as BmsServerAutocomplete, BmsServerTable_default as BmsServerTable, BmsShortLinkMenu_default as BmsShortLinkMenu, BmsSidePanel_default as BmsSidePanel, BmsSlidingPanelShell_default as BmsSlidingPanelShell, BmsSplitWindow_default as BmsSplitWindow, BmsStep_default as BmsStep, BmsStepper_default as BmsStepper, BmsTable_default as BmsTable, BmsTabs_default as BmsTabs, BmsTag_default as BmsTag, BmsTenantSwitcher_default as BmsTenantSwitcher, BmsTextArea_default as BmsTextArea, BmsToggleIcon_default as BmsToggleIcon, BmsTooltip_default as BmsTooltip, ChipColor, CocardeBorder, ColumnType, ConfirmInstance, InputType, KeycloakAuthAdapterInstance, RuntimeEnv, SelectMode, SortValue, StatusType, TableMode, TooltipDirection, bmsDefaultSearchFilterFunction, confirmPlugin, convertStringToCaption, createBmsUi, createRuntimeEnv, cssDiagnostics, cssSyntaxLinter, defaultSortFunction, enforceActionsColumnHeader, featureFlipperPlugin, fetchRuntimeEnv, field, getCurrentHistory, getCurrentLocation, getFiltersAsQueryParams, getHeaderClasses, getImageFromFile, getNumberFromPathQuery, getStringFromPathQuery, getUserPrefFromLocalStorage, getValueByPath, handleValueInSearchParams, htmlDiagnostics, htmlSyntaxLinter, isEmptyStringOrNotDefined, isExternalLink, isFileImage, isProblem, jsDiagnostics, jsSyntaxLinter, keycloakAuthAdapter, keycloakAuthAdapterInit, lintGutter, linter, notifications, readableDate, reflectFiltersToPath, reflectSearchToPath, relativeDate, relativeDateDefaultFormatFunction, routerHistoryPlugin, sanitizeHtml, sanitizeString, saveValuesToPathQuery, searchString, setUserPrefFromLocalStorage, useClipboard, useConfirm, useDarkMode, useFeatureFlipper, useKeycloakAuthAdapter, useNotifications, usePagination, useRouterHistory, useRuntimeEnv, useSearch, useSort, useUserPref, writeLocation };
|
|
114676
|
+
export { BMS_FORM_VALID_URL_REGEX, BmsAlert_default as BmsAlert, BmsAutocomplete_default as BmsAutocomplete, BmsBackButton_default as BmsBackButton, BmsBadge_default as BmsBadge, BmsBetweenInput_default as BmsBetweenInput, BmsBreadcrumb_default as BmsBreadcrumb, BmsButton_default as BmsButton, BmsCaption_default as BmsCaption, BmsCard_default as BmsCard, BmsChip_default as BmsChip, BmsCircularProgress_default as BmsCircularProgress, BmsCocarde_default as BmsCocarde, BmsCombobox_default as BmsCombobox, BmsContentPageLayout_default as BmsContentPageLayout, DraggableList_default as BmsDraggableList, BmsEmptyScreen_default as BmsEmptyScreen, BmsFilePicker_default as BmsFilePicker, BmsFixedMenu_default as BmsFixedMenu, BmsFloatingWindow_default as BmsFloatingWindow, BmsForm_default as BmsForm, BmsGhost_default as BmsGhost, BmsHeader_default as BmsHeader, BmsHeaderTitle_default as BmsHeaderTitle, BmsIconButton_default as BmsIconButton, BmsInputBooleanCheckbox_default as BmsInputBooleanCheckbox, BmsInputCheckboxCaption_default as BmsInputCheckboxCaption, BmsInputCheckboxCaptionGroup_default as BmsInputCheckboxCaptionGroup, BmsInputCheckboxGroup_default as BmsInputCheckboxGroup, BmsInputCode_default as BmsInputCode, BmsInputDateTime_default as BmsInputDateTime, BmsInputFile_default as BmsInputFile, BmsInputNumber_default as BmsInputNumber, BmsInputRadio_default as BmsInputRadio, BmsInputRadioCaption_default as BmsInputRadioCaption, BmsInputRadioCaptionGroup_default as BmsInputRadioCaptionGroup, BmsInputRadioGroup_default as BmsInputRadioGroup, BmsInputText_default as BmsInputText, BmsInputTime_default as BmsInputTime, BmsInputToggle_default as BmsInputToggle, BmsLink_default as BmsLink, BmsLoader_default as BmsLoader, BmsMenu_default as BmsMenu, BmsMenuNav_default as BmsMenuNav, BmsModal_default as BmsModal, BmsMultiSelect_default as BmsMultiSelect, BmsNotificationsInstance, BmsOverlay_default as BmsOverlay, BmsPagination_default as BmsPagination, BmsProblem_default as BmsProblem, BmsRelativeTime_default as BmsRelativeTime, BmsSearch_default as BmsSearch, BmsSection_default as BmsSection, BmsSelect_default as BmsSelect, BmsServerAutocomplete_default as BmsServerAutocomplete, BmsServerTable_default as BmsServerTable, BmsShortLinkMenu_default as BmsShortLinkMenu, BmsSidePanel_default as BmsSidePanel, BmsSlidingPanelShell_default as BmsSlidingPanelShell, BmsSplitWindow_default as BmsSplitWindow, BmsStep_default as BmsStep, BmsStepper_default as BmsStepper, BmsTable_default as BmsTable, BmsTabs_default as BmsTabs, BmsTag_default as BmsTag, BmsTenantSwitcher_default as BmsTenantSwitcher, BmsTextArea_default as BmsTextArea, BmsToggleIcon_default as BmsToggleIcon, BmsTooltip_default as BmsTooltip, ChipColor, CocardeBorder, ColumnType, ConfirmInstance, InputType, KeycloakAuthAdapterInstance, RuntimeEnv, SelectMode, SortValue, StatusType, TableMode, TooltipDirection, bmsDefaultSearchFilterFunction, confirmPlugin, convertStringToCaption, createBmsUi, createRuntimeEnv, cssDiagnostics, cssSyntaxLinter, defaultSortFunction, enforceActionsColumnHeader, featureFlipperPlugin, fetchRuntimeEnv, field, getCurrentHistory, getCurrentLocation, getFiltersAsQueryParams, getHeaderClasses, getImageFromFile, getNumberFromPathQuery, getStringFromPathQuery, getUserPrefFromLocalStorage, getValueByPath, handleValueInSearchParams, htmlDiagnostics, htmlSyntaxLinter, isEmptyStringOrNotDefined, isExternalLink, isFileImage, isProblem, jsDiagnostics, jsSyntaxLinter, keycloakAuthAdapter, keycloakAuthAdapterInit, lintGutter, lintValidationListener, linter, notifications, readableDate, reflectFiltersToPath, reflectSearchToPath, relativeDate, relativeDateDefaultFormatFunction, routerHistoryPlugin, sanitizeHtml, sanitizeString, saveValuesToPathQuery, searchString, setUserPrefFromLocalStorage, useClipboard, useConfirm, useDarkMode, useFeatureFlipper, useKeycloakAuthAdapter, useNotifications, usePagination, useRouterHistory, useRuntimeEnv, useSearch, useSort, useUserPref, writeLocation };
|
|
114635
114677
|
|
|
114636
114678
|
//# sourceMappingURL=sipa-bms-ui.es.js.map
|