@ouestfrance/sipa-bms-ui 8.45.0 → 8.47.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 +34 -0
- package/dist/sipa-bms-ui.es.js +57 -8
- package/dist/sipa-bms-ui.es.js.map +1 -1
- package/dist/sipa-bms-ui.umd.js +58 -7
- 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 +33 -0
- package/src/components/form/bms-input-code.linters.ts +83 -8
|
@@ -51,4 +51,38 @@ export declare const cssSyntaxLinter: () => Extension;
|
|
|
51
51
|
* <BmsInputCode type="javascript" :extra-extensions="[lintGutter(), jsSyntaxLinter()]" />
|
|
52
52
|
*/
|
|
53
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
|
+
/**
|
|
74
|
+
* Crée un linter qui exécute `fn` et appelle `onHasErrors` lorsque la présence
|
|
75
|
+
* de diagnostics de la sévérité donnée change. À utiliser pour les linters bloquants
|
|
76
|
+
* (désactiver le bouton de soumission sur `error`, ou avertir sur `warning`).
|
|
77
|
+
* Pour les linters purement informatifs, utiliser `linter()` directement.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const htmlValid = ref(true);
|
|
81
|
+
* const extensions = [
|
|
82
|
+
* lintGutter(),
|
|
83
|
+
* createLinterWithCallback(htmlDiagnostics, (hasErrors) => { htmlValid.value = !hasErrors; }, 'error'),
|
|
84
|
+
* ];
|
|
85
|
+
*/
|
|
86
|
+
export declare const createLinterWithCallback: (fn: (code: string) => Diagnostic[], onHasDiagnostics: (hasDiagnostics: boolean) => void, severity?: Diagnostic['severity']) => Extension;
|
|
87
|
+
export declare const lintValidationListener: (onValidation: (valid: boolean) => void) => Extension;
|
|
54
88
|
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);
|
|
@@ -112744,19 +112751,20 @@ var useDarkMode = () => {
|
|
|
112744
112751
|
//#region src/components/form/bms-input-code.linters.ts
|
|
112745
112752
|
/**
|
|
112746
112753
|
* Retourne les diagnostics HTML pour un code donné.
|
|
112747
|
-
* Parse le contenu comme du XML strict pour détecter les erreurs de structure
|
|
112754
|
+
* Parse le contenu comme du XML strict pour détecter les erreurs de structure,
|
|
112755
|
+
* après normalisation des balises void HTML5 (accepte `<br>` comme `<br/>`).
|
|
112748
112756
|
*
|
|
112749
112757
|
* Comportement attendu :
|
|
112750
112758
|
* - Chaîne vide → aucun diagnostic
|
|
112751
112759
|
* - HTML bien formé (`<div><p>Hello</p></div>`) → aucun diagnostic
|
|
112752
|
-
* - Balises
|
|
112760
|
+
* - Balises void HTML5 (`<br>`, `<meta>`, `<link>`, `<img>`…) → aucun diagnostic
|
|
112753
112761
|
* - Balise non fermée (`<div><p>Hello</div>`) → diagnostic « HTML invalide »
|
|
112754
112762
|
* - Attribut mal formé (`<div class=>`) → diagnostic « HTML invalide »
|
|
112755
|
-
*
|
|
112756
|
-
* Limitation : le parser XML est plus strict que le parser HTML du navigateur.
|
|
112757
|
-
* Les balises void HTML5 non fermées (`<br>`, `<img>`) sont considérées invalides.
|
|
112758
112763
|
*/
|
|
112759
112764
|
var ROOT_TAG = "<root>";
|
|
112765
|
+
var VOID_ELEMENTS = "area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr";
|
|
112766
|
+
var normalizeBooleanAttributes = (code) => code.replace(/<[a-zA-Z][^>]*>/g, (tag) => tag.replace(/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')|(\s+)([a-zA-Z][a-zA-Z0-9-:]*)(?!\s*=)(?=[\s/>]|$)/g, (match, quoted, spaces, attrName) => quoted !== void 0 ? match : `${spaces}${attrName}=""`));
|
|
112767
|
+
var normalizeVoidElements = (code) => code.replace(new RegExp(`<(${VOID_ELEMENTS})(\\s[^>]*)?(?<!/)>`, "gi"), (_, tag, attrs) => `<${tag}${attrs ?? ""}/>`);
|
|
112760
112768
|
var htmlErrorOffset = (errorText, code) => {
|
|
112761
112769
|
const match = errorText.match(/error on line (\d+) at column (\d+)/i);
|
|
112762
112770
|
if (!match) return 0;
|
|
@@ -112769,14 +112777,15 @@ var htmlErrorOffset = (errorText, code) => {
|
|
|
112769
112777
|
};
|
|
112770
112778
|
var htmlDiagnostics = (code) => {
|
|
112771
112779
|
if (!code.trim()) return [];
|
|
112772
|
-
const
|
|
112780
|
+
const normalized = normalizeVoidElements(normalizeBooleanAttributes(code));
|
|
112781
|
+
const parserError = new DOMParser().parseFromString(`${ROOT_TAG}${normalized}</root>`, "text/xml").querySelector("parsererror");
|
|
112773
112782
|
if (!parserError) return [];
|
|
112774
112783
|
const from = htmlErrorOffset(parserError.textContent ?? "", code);
|
|
112775
112784
|
return [{
|
|
112776
112785
|
from,
|
|
112777
112786
|
to: Math.min(from + 1, code.length),
|
|
112778
112787
|
severity: "error",
|
|
112779
|
-
message:
|
|
112788
|
+
message: `HTML invalide : ${parserError.textContent?.split("\n")[0] ?? "balise mal formée ou non fermée"}`
|
|
112780
112789
|
}];
|
|
112781
112790
|
};
|
|
112782
112791
|
/**
|
|
@@ -112857,6 +112866,46 @@ var cssSyntaxLinter = () => linter((view) => cssDiagnostics(view.state.doc.toStr
|
|
|
112857
112866
|
* <BmsInputCode type="javascript" :extra-extensions="[lintGutter(), jsSyntaxLinter()]" />
|
|
112858
112867
|
*/
|
|
112859
112868
|
var jsSyntaxLinter = () => linter((view) => jsDiagnostics(view.state.doc.toString()));
|
|
112869
|
+
/**
|
|
112870
|
+
* Extension CodeMirror qui appelle `onValidation` à chaque fois que le résultat
|
|
112871
|
+
* des linters change, en passant `true` si aucun diagnostic n'est présent.
|
|
112872
|
+
*
|
|
112873
|
+
* Utile pour synchroniser l'état de validation du linter avec un état Vue externe
|
|
112874
|
+
* (ex: désactiver un bouton de soumission).
|
|
112875
|
+
*
|
|
112876
|
+
* Comportement attendu :
|
|
112877
|
+
* - Appelé après chaque cycle de lint (asynchrone, après le debounce du linter)
|
|
112878
|
+
* - `valid: true` → aucun diagnostic actif dans l'éditeur
|
|
112879
|
+
* - `valid: false` → au moins un diagnostic présent
|
|
112880
|
+
*
|
|
112881
|
+
* Note : démarre à `true` (avant le premier lint). Combiner avec une validation
|
|
112882
|
+
* côté formulaire (champ non vide) pour éviter de soumettre avant le premier lint.
|
|
112883
|
+
*
|
|
112884
|
+
* @example
|
|
112885
|
+
* const sourceValid = ref(true);
|
|
112886
|
+
* const extensions = [lintGutter(), htmlSyntaxLinter(), lintValidationListener((v) => { sourceValid.value = v; })];
|
|
112887
|
+
*/
|
|
112888
|
+
/**
|
|
112889
|
+
* Crée un linter qui exécute `fn` et appelle `onHasErrors` lorsque la présence
|
|
112890
|
+
* de diagnostics de la sévérité donnée change. À utiliser pour les linters bloquants
|
|
112891
|
+
* (désactiver le bouton de soumission sur `error`, ou avertir sur `warning`).
|
|
112892
|
+
* Pour les linters purement informatifs, utiliser `linter()` directement.
|
|
112893
|
+
*
|
|
112894
|
+
* @example
|
|
112895
|
+
* const htmlValid = ref(true);
|
|
112896
|
+
* const extensions = [
|
|
112897
|
+
* lintGutter(),
|
|
112898
|
+
* createLinterWithCallback(htmlDiagnostics, (hasErrors) => { htmlValid.value = !hasErrors; }, 'error'),
|
|
112899
|
+
* ];
|
|
112900
|
+
*/
|
|
112901
|
+
var createLinterWithCallback = (fn, onHasDiagnostics, severity = "error") => linter((view) => {
|
|
112902
|
+
const diagnostics = fn(view.state.doc.toString());
|
|
112903
|
+
onHasDiagnostics(diagnostics.some((d) => d.severity === severity));
|
|
112904
|
+
return diagnostics;
|
|
112905
|
+
});
|
|
112906
|
+
var lintValidationListener = (onValidation) => EditorView.updateListener.of((update) => {
|
|
112907
|
+
if (update.transactions.some((t) => t.effects.length > 0) || update.docChanged) onValidation(diagnosticCount(update.state) === 0);
|
|
112908
|
+
});
|
|
112860
112909
|
//#endregion
|
|
112861
112910
|
//#region src/plugins/feature-flipper/featureFlipper.composable.ts
|
|
112862
112911
|
var features = ref({});
|
|
@@ -114644,6 +114693,6 @@ var createBmsUi = () => ({ install: (app) => {
|
|
|
114644
114693
|
app.component("BmsRelativeTime", BmsRelativeTime_default);
|
|
114645
114694
|
} });
|
|
114646
114695
|
//#endregion
|
|
114647
|
-
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 };
|
|
114696
|
+
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, createLinterWithCallback, 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 };
|
|
114648
114697
|
|
|
114649
114698
|
//# sourceMappingURL=sipa-bms-ui.es.js.map
|