@selfhelp/shared 1.21.3 → 1.21.5
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/CHANGELOG.md +83 -0
- package/README.md +2 -1
- package/dist/index.d.mts +427 -20
- package/dist/index.d.ts +427 -20
- package/dist/index.js +560 -13
- package/dist/index.mjs +518 -13
- package/dist/plugin-sdk/index.d.mts +1 -1
- package/dist/plugin-sdk/index.d.ts +1 -1
- package/dist/plugin-sdk/index.js +2 -1
- package/dist/plugin-sdk/index.mjs +2 -1
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.js +2 -1
- package/dist/registry/index.mjs +2 -1
- package/dist/{styles.registry-DEDEZ8l3.d.ts → styles.registry-DX79oirw.d.ts} +93 -16
- package/dist/{styles.registry-DHM4M77N.d.mts → styles.registry-ffw0MH3r.d.mts} +93 -16
- package/package.json +1 -1
- package/src/content/__tests__/fieldsMapLabels.test.ts +55 -0
- package/src/content/__tests__/optionLabels.test.ts +100 -0
- package/src/content/fieldsMapLabels.ts +103 -0
- package/src/content/index.ts +2 -0
- package/src/content/optionLabels.ts +200 -0
- package/src/navigation/__tests__/navigation.test.ts +296 -6
- package/src/navigation/activeTrail.ts +99 -0
- package/src/navigation/branchNav.ts +155 -6
- package/src/navigation/footerPreset.ts +109 -0
- package/src/navigation/headerLayers.ts +56 -0
- package/src/navigation/headerPreset.ts +9 -2
- package/src/navigation/index.ts +4 -0
- package/src/navigation/menuDepth.ts +73 -37
- package/src/navigation/mobileRoute.ts +25 -0
- package/src/navigation/navLinks.ts +0 -4
- package/src/navigation/navigationBundle.ts +81 -0
- package/src/navigation/navigationPayload.ts +96 -17
- package/src/registry/__tests__/platform.test.ts +11 -10
- package/src/registry/styles.registry.ts +2 -1
- package/src/types/__tests__/preview-bridge.test.ts +7 -0
- package/src/types/auth.ts +4 -0
- package/src/types/cms-app.ts +74 -0
- package/src/types/index.ts +1 -0
- package/src/types/mobile-adapters.ts +1 -0
- package/src/types/pages.ts +6 -0
- package/src/types/preview-bridge.ts +12 -1
- package/src/types/styles/composite.ts +21 -0
- package/src/types/styles/forms.ts +57 -10
- package/src/types/styles/interactive.ts +1 -1
- package/src/types/styles/unknown.ts +2 -2
|
@@ -667,7 +667,7 @@ type TSharedLabelPosition = 'left' | 'right';
|
|
|
667
667
|
type TMobileSelectPresentation = 'bottom-sheet' | 'dialog' | 'popover';
|
|
668
668
|
type TMobileFieldVariant = 'primary' | 'secondary';
|
|
669
669
|
interface IFormStyle extends IStyleWithSpacing {
|
|
670
|
-
style_name: 'form-log' | 'form-record';
|
|
670
|
+
style_name: 'form-log' | 'form-record' | 'entry-record-form';
|
|
671
671
|
/** Optional auto-styled heading rendered above the form when set. */
|
|
672
672
|
title?: IContentField<string>;
|
|
673
673
|
/** Optional sub-heading rendered below the title when set. */
|
|
@@ -710,8 +710,29 @@ interface IFormLogStyle extends IFormStyle {
|
|
|
710
710
|
}
|
|
711
711
|
interface IFormRecordStyle extends IFormStyle {
|
|
712
712
|
style_name: 'form-record';
|
|
713
|
+
/** Human-readable table name slug (runtime table is owned by section id). */
|
|
714
|
+
name?: IContentField<string>;
|
|
715
|
+
btn_update_label?: IContentField<string>;
|
|
716
|
+
btn_update_color?: IContentField<string>;
|
|
717
|
+
/**
|
|
718
|
+
* '1' (default): the form only ever loads/updates the user's own records.
|
|
719
|
+
* '0': shared editing — foreign records can be loaded/updated by users
|
|
720
|
+
* holding UPDATE data access on the form's table (admins always pass).
|
|
721
|
+
*/
|
|
722
|
+
own_entries_only?: IContentField<string>;
|
|
723
|
+
}
|
|
724
|
+
interface IEntryRecordFormStyle extends IFormStyle {
|
|
725
|
+
style_name: 'entry-record-form';
|
|
713
726
|
btn_update_label?: IContentField<string>;
|
|
714
727
|
btn_update_color?: IContentField<string>;
|
|
728
|
+
/** Numeric data_tables.id or empty to use this section's owned table. */
|
|
729
|
+
data_table?: IContentField<string>;
|
|
730
|
+
/**
|
|
731
|
+
* Route parameter carrying the record id (e.g. record_id on /cms/team/{record_id}).
|
|
732
|
+
* When present the form loads that record; when absent the form stays empty (create).
|
|
733
|
+
*/
|
|
734
|
+
load_record_from?: IContentField<string>;
|
|
735
|
+
own_entries_only?: IContentField<string>;
|
|
715
736
|
}
|
|
716
737
|
interface IInputStyle extends IBaseStyle {
|
|
717
738
|
style_name: 'input';
|
|
@@ -796,6 +817,8 @@ interface ISelectStyle extends IBaseStyle {
|
|
|
796
817
|
value?: IContentField<string>;
|
|
797
818
|
placeholder?: IContentField<string>;
|
|
798
819
|
options?: IContentField<string>;
|
|
820
|
+
/** Translatable map: `code -> label` for active language. */
|
|
821
|
+
option_labels?: IContentField<string>;
|
|
799
822
|
is_multiple?: IContentField<string>;
|
|
800
823
|
max?: IContentField<string>;
|
|
801
824
|
searchable?: IContentField<string>;
|
|
@@ -817,6 +840,8 @@ interface IRadioStyle extends IStyleWithSpacing {
|
|
|
817
840
|
size?: IContentField<TSharedSize>;
|
|
818
841
|
color?: IContentField<TMantineColor>;
|
|
819
842
|
radio_options?: IContentField<string>;
|
|
843
|
+
/** Translatable map: `code -> label` for active language. */
|
|
844
|
+
option_labels?: IContentField<string>;
|
|
820
845
|
web_radio_label_position?: IContentField<string>;
|
|
821
846
|
web_radio_variant?: IContentField<string>;
|
|
822
847
|
web_radio_card?: IContentField<string>;
|
|
@@ -937,6 +962,8 @@ interface IComboboxStyle extends IStyleWithSpacing {
|
|
|
937
962
|
style_name: 'combobox';
|
|
938
963
|
placeholder?: IContentField<string>;
|
|
939
964
|
combobox_options?: IContentField<string>;
|
|
965
|
+
/** Translatable map: `code -> label` for active language. */
|
|
966
|
+
option_labels?: IContentField<string>;
|
|
940
967
|
disabled?: IContentField<string>;
|
|
941
968
|
label?: IContentField<string>;
|
|
942
969
|
description?: IContentField<string>;
|
|
@@ -1031,6 +1058,8 @@ interface INumberInputStyle extends IStyleWithSpacing {
|
|
|
1031
1058
|
interface ISegmentedControlStyle extends IStyleWithSpacing {
|
|
1032
1059
|
style_name: 'segmented-control';
|
|
1033
1060
|
segmented_control_data?: IContentField<string>;
|
|
1061
|
+
/** Translatable map: `code -> label` for active language. */
|
|
1062
|
+
option_labels?: IContentField<string>;
|
|
1034
1063
|
orientation?: IContentField<string>;
|
|
1035
1064
|
size?: IContentField<TSharedSize>;
|
|
1036
1065
|
radius?: IContentField<TSharedRadius>;
|
|
@@ -1088,14 +1117,23 @@ interface IProgressSectionStyle extends IBaseStyle {
|
|
|
1088
1117
|
tooltip_label?: IContentField<string>;
|
|
1089
1118
|
web_tooltip_position?: IContentField<string>;
|
|
1090
1119
|
}
|
|
1091
|
-
interface
|
|
1120
|
+
interface IEntryTableEntry {
|
|
1092
1121
|
record_id: number;
|
|
1093
1122
|
id_users: number;
|
|
1123
|
+
/** Per-row delete permission (backend rule `canDeleteOwnedRecord`). */
|
|
1094
1124
|
_can_delete?: boolean;
|
|
1125
|
+
/** Per-row edit permission (backend rule `canUpdateOwnedRecord`). */
|
|
1126
|
+
_can_edit?: boolean;
|
|
1095
1127
|
[key: string]: unknown;
|
|
1096
1128
|
}
|
|
1097
|
-
|
|
1098
|
-
|
|
1129
|
+
/**
|
|
1130
|
+
* The built-in admin CRUD grid (renamed from `show-user-input` in the
|
|
1131
|
+
* CMS-in-CMS polish wave): a data table over a form's records with search /
|
|
1132
|
+
* sort / pagination / CSV, an "Add new" button, a per-row edit action and a
|
|
1133
|
+
* permission-gated per-row delete.
|
|
1134
|
+
*/
|
|
1135
|
+
interface IEntryTableStyle extends IBaseStyle {
|
|
1136
|
+
style_name: 'entry-table';
|
|
1099
1137
|
/** Optional auto-styled heading rendered above the entries when set. */
|
|
1100
1138
|
title?: IContentField<string>;
|
|
1101
1139
|
/** Message shown when there are no entries to display (default "No entries found."). */
|
|
@@ -1113,20 +1151,28 @@ interface IShowUserInputStyle extends IBaseStyle {
|
|
|
1113
1151
|
csv_export?: IContentField<string>;
|
|
1114
1152
|
delete_entry?: IContentField<string>;
|
|
1115
1153
|
fields_map?: IContentField<string>;
|
|
1154
|
+
/** Per-language header labels keyed by field_key. */
|
|
1155
|
+
fields_map_labels?: IContentField<string>;
|
|
1116
1156
|
/**
|
|
1117
1157
|
* Optional URL of a create form. When set, the web table shows an "Add new"
|
|
1118
1158
|
* button above it (e.g. opens the create form modal). Web-only.
|
|
1119
1159
|
*/
|
|
1120
1160
|
add_url?: IContentField<string>;
|
|
1121
1161
|
/**
|
|
1122
|
-
* Optional URL template for opening a row's
|
|
1123
|
-
* `/cms/team/{record_id}`). When set, each row gets an
|
|
1124
|
-
*
|
|
1125
|
-
* the renderer at click time. Web-only.
|
|
1162
|
+
* Optional URL template for opening a row's edit form (e.g.
|
|
1163
|
+
* `/cms/team/{record_id}`). When set, each row with `_can_edit` gets an
|
|
1164
|
+
* edit action with the single-brace `{record_id}` placeholder substituted
|
|
1165
|
+
* by the renderer at click time. Web-only.
|
|
1126
1166
|
*/
|
|
1127
1167
|
edit_url?: IContentField<string>;
|
|
1128
1168
|
delete_modal_title?: IContentField<string>;
|
|
1129
1169
|
delete_modal_body?: IContentField<string>;
|
|
1170
|
+
/**
|
|
1171
|
+
* When `1`, the web table shows a language selector above the grid and
|
|
1172
|
+
* reloads translatable cell values for the chosen locale (CMS app lists).
|
|
1173
|
+
* Default off.
|
|
1174
|
+
*/
|
|
1175
|
+
show_language_preview?: IContentField<string>;
|
|
1130
1176
|
spacing?: IContentField<string>;
|
|
1131
1177
|
web_table_striped?: IContentField<string>;
|
|
1132
1178
|
web_table_highlight_on_hover?: IContentField<string>;
|
|
@@ -1136,10 +1182,10 @@ interface IShowUserInputStyle extends IBaseStyle {
|
|
|
1136
1182
|
web_table_sticky_header?: IContentField<string>;
|
|
1137
1183
|
web_table_caption_side?: IContentField<string>;
|
|
1138
1184
|
/**
|
|
1139
|
-
*
|
|
1185
|
+
* entry-table rows, each keyed by the immutable data-column `field_key`
|
|
1140
1186
|
* (issue #56 v2). Header labels come from {@link field_labels}, not the keys.
|
|
1141
1187
|
*/
|
|
1142
|
-
entries?:
|
|
1188
|
+
entries?: IEntryTableEntry[];
|
|
1143
1189
|
/**
|
|
1144
1190
|
* Header map `field_key => display_name` for {@link entries} (issue #56 v2).
|
|
1145
1191
|
* Lets the table show the human column label while rows stay keyed by the
|
|
@@ -1237,12 +1283,33 @@ interface IListItemStyle extends IStyleWithSpacing {
|
|
|
1237
1283
|
interface IEntryListStyle extends IBaseStyle {
|
|
1238
1284
|
style_name: 'entry-list';
|
|
1239
1285
|
line_clamp?: IContentField<TMantineLineClamp>;
|
|
1286
|
+
data_table?: IContentField<string>;
|
|
1287
|
+
own_entries_only?: IContentField<string>;
|
|
1288
|
+
filter?: IContentField<string>;
|
|
1289
|
+
scope?: IContentField<string>;
|
|
1290
|
+
load_as_table?: IContentField<string>;
|
|
1291
|
+
selected_columns?: IContentField<string>;
|
|
1240
1292
|
}
|
|
1241
1293
|
interface IEntryRecordStyle extends IBaseStyle {
|
|
1242
1294
|
style_name: 'entry-record';
|
|
1295
|
+
data_table?: IContentField<string>;
|
|
1296
|
+
own_entries_only?: IContentField<string>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Route parameter carrying the record id (same contract as
|
|
1299
|
+
* `entry-record-form.load_record_from`, e.g. `record_id` on
|
|
1300
|
+
* `/team-members/{record_id}`). The holder loads that single row.
|
|
1301
|
+
*/
|
|
1302
|
+
load_record_from?: IContentField<string>;
|
|
1303
|
+
scope?: IContentField<string>;
|
|
1243
1304
|
}
|
|
1244
1305
|
interface IEntryRecordDeleteStyle extends IBaseStyle {
|
|
1245
1306
|
style_name: 'entry-record-delete';
|
|
1307
|
+
/** Delete button text (catalog field; the generic `label` field is not linked to this style). */
|
|
1308
|
+
label_delete?: IContentField<string>;
|
|
1309
|
+
confirmation_title?: IContentField<string>;
|
|
1310
|
+
confirmation_message?: IContentField<string>;
|
|
1311
|
+
confirmation_continue?: IContentField<string>;
|
|
1312
|
+
confirmation_cancel?: IContentField<string>;
|
|
1246
1313
|
}
|
|
1247
1314
|
interface ILoopStyle extends IBaseStyle {
|
|
1248
1315
|
style_name: 'loop';
|
|
@@ -1303,7 +1370,7 @@ interface IVersionStyle extends IBaseStyle {
|
|
|
1303
1370
|
* Admin/CMS-only styles are intentionally NOT in this union — the mobile
|
|
1304
1371
|
* app does not render them.
|
|
1305
1372
|
*/
|
|
1306
|
-
type TStyle = ILoginStyle | IRegisterStyle | IValidateStyle | IResetPasswordStyle | ITwoFactorAuthStyle | IProfileStyle | IContainerStyle | IBoxStyle | IFlexStyle | IGroupStyle | IStackStyle | ISimpleGridStyle | IGridStyle | IGridColumnStyle | ISpaceStyle | IDividerStyle | IPaperStyle | ICenterStyle | IScrollAreaStyle | ICardStyle | ICardSegmentStyle | IAspectRatioStyle | IBackgroundImageStyle | ITitleStyle | ITextStyle | ICodeStyle | IHighlightStyle | IBlockquoteStyle | IHtmlTagStyle | IKbdStyle | ITypographyStyle | IFieldsetStyle | ISpoilerStyle | IImageStyle | IVideoStyle | IAudioStyle | IFigureStyle | ICarouselStyle | IButtonStyle | ILinkStyle | IActionIconStyle | IAlertStyle | IBadgeStyle | IAvatarStyle | IChipStyle | IIndicatorStyle | IThemeIconStyle | INotificationStyle | IFormLogStyle | IFormRecordStyle | IInputStyle | ITextInputStyle | ITextareaStyle | IRichTextEditorStyle | ISelectStyle | IRadioStyle | ICheckboxStyle | ISliderStyle | IRangeSliderStyle | IDatePickerStyle | ISwitchStyle | IComboboxStyle | IColorInputStyle | IColorPickerStyle | IFileInputStyle | INumberInputStyle | ISegmentedControlStyle | IRatingStyle | IProgressStyle | IProgressRootStyle | IProgressSectionStyle | IAccordionStyle | IAccordionItemStyle | ITabsStyle | ITabStyle | ITimelineStyle | IListStyle | IListItemStyle | IEntryListStyle | IEntryRecordStyle | IEntryRecordDeleteStyle | ILoopStyle | ITimelineItemStyle | INoAccessStyle | INotFoundStyle | IMissingStyle | IVersionStyle | IRefContainerStyle | IDataContainerStyle |
|
|
1373
|
+
type TStyle = ILoginStyle | IRegisterStyle | IValidateStyle | IResetPasswordStyle | ITwoFactorAuthStyle | IProfileStyle | IContainerStyle | IBoxStyle | IFlexStyle | IGroupStyle | IStackStyle | ISimpleGridStyle | IGridStyle | IGridColumnStyle | ISpaceStyle | IDividerStyle | IPaperStyle | ICenterStyle | IScrollAreaStyle | ICardStyle | ICardSegmentStyle | IAspectRatioStyle | IBackgroundImageStyle | ITitleStyle | ITextStyle | ICodeStyle | IHighlightStyle | IBlockquoteStyle | IHtmlTagStyle | IKbdStyle | ITypographyStyle | IFieldsetStyle | ISpoilerStyle | IImageStyle | IVideoStyle | IAudioStyle | IFigureStyle | ICarouselStyle | IButtonStyle | ILinkStyle | IActionIconStyle | IAlertStyle | IBadgeStyle | IAvatarStyle | IChipStyle | IIndicatorStyle | IThemeIconStyle | INotificationStyle | IFormLogStyle | IFormRecordStyle | IInputStyle | ITextInputStyle | ITextareaStyle | IRichTextEditorStyle | ISelectStyle | IRadioStyle | ICheckboxStyle | ISliderStyle | IRangeSliderStyle | IDatePickerStyle | ISwitchStyle | IComboboxStyle | IColorInputStyle | IColorPickerStyle | IFileInputStyle | INumberInputStyle | ISegmentedControlStyle | IRatingStyle | IProgressStyle | IProgressRootStyle | IProgressSectionStyle | IAccordionStyle | IAccordionItemStyle | ITabsStyle | ITabStyle | ITimelineStyle | IListStyle | IListItemStyle | IEntryListStyle | IEntryRecordStyle | IEntryRecordDeleteStyle | ILoopStyle | ITimelineItemStyle | INoAccessStyle | INotFoundStyle | IMissingStyle | IVersionStyle | IRefContainerStyle | IDataContainerStyle | IEntryTableStyle;
|
|
1307
1374
|
/**
|
|
1308
1375
|
* Discriminator — name of every supported style. Derived from the
|
|
1309
1376
|
* `STYLE_REGISTRY` keys (declared in `src/registry/styles.registry.ts`).
|
|
@@ -1746,6 +1813,11 @@ declare const BASE_STYLE_REGISTRY: {
|
|
|
1746
1813
|
readonly category: "forms";
|
|
1747
1814
|
readonly canHaveChildren: true;
|
|
1748
1815
|
};
|
|
1816
|
+
readonly 'entry-record-form': {
|
|
1817
|
+
readonly description: "Route-aware create/edit form";
|
|
1818
|
+
readonly category: "forms";
|
|
1819
|
+
readonly canHaveChildren: true;
|
|
1820
|
+
};
|
|
1749
1821
|
readonly input: {
|
|
1750
1822
|
readonly description: "Plain HTML input";
|
|
1751
1823
|
readonly category: "forms";
|
|
@@ -1941,8 +2013,8 @@ declare const BASE_STYLE_REGISTRY: {
|
|
|
1941
2013
|
readonly category: "layout";
|
|
1942
2014
|
readonly canHaveChildren: true;
|
|
1943
2015
|
};
|
|
1944
|
-
readonly '
|
|
1945
|
-
readonly description: "
|
|
2016
|
+
readonly 'entry-table': {
|
|
2017
|
+
readonly description: "Built-in admin CRUD grid over a form's records (search/sort/paginate/CSV, add / edit / delete actions)";
|
|
1946
2018
|
readonly category: "forms";
|
|
1947
2019
|
readonly canHaveChildren: false;
|
|
1948
2020
|
};
|
|
@@ -2204,6 +2276,11 @@ declare const STYLE_REGISTRY: {
|
|
|
2204
2276
|
readonly category: "forms";
|
|
2205
2277
|
readonly canHaveChildren: true;
|
|
2206
2278
|
};
|
|
2279
|
+
readonly 'entry-record-form': {
|
|
2280
|
+
readonly description: "Route-aware create/edit form";
|
|
2281
|
+
readonly category: "forms";
|
|
2282
|
+
readonly canHaveChildren: true;
|
|
2283
|
+
};
|
|
2207
2284
|
readonly input: {
|
|
2208
2285
|
readonly description: "Plain HTML input";
|
|
2209
2286
|
readonly category: "forms";
|
|
@@ -2399,8 +2476,8 @@ declare const STYLE_REGISTRY: {
|
|
|
2399
2476
|
readonly category: "layout";
|
|
2400
2477
|
readonly canHaveChildren: true;
|
|
2401
2478
|
};
|
|
2402
|
-
readonly '
|
|
2403
|
-
readonly description: "
|
|
2479
|
+
readonly 'entry-table': {
|
|
2480
|
+
readonly description: "Built-in admin CRUD grid over a form's records (search/sort/paginate/CSV, add / edit / delete actions)";
|
|
2404
2481
|
readonly category: "forms";
|
|
2405
2482
|
readonly canHaveChildren: false;
|
|
2406
2483
|
};
|
|
@@ -2449,4 +2526,4 @@ declare function getPluginStyleRegistry(): Record<string, IPluginStyleRegistryEn
|
|
|
2449
2526
|
*/
|
|
2450
2527
|
declare function _resetPluginStyleRegistry(): void;
|
|
2451
2528
|
|
|
2452
|
-
export { type
|
|
2529
|
+
export { type IFileInputStyle as $, type ICardSegmentStyle as A, BASE_STYLE_REGISTRY as B, type ICardStyle as C, type ICarouselStyle as D, type ICenterStyle as E, type ICheckboxStyle as F, type IChipStyle as G, type ICodeStyle as H, type IStyleRegistryEntry as I, type IColorInputStyle as J, type IColorPickerStyle as K, type IComboboxStyle as L, type IContainerStyle as M, type IDataContainerStyle as N, type IDatePickerStyle as O, type IDividerStyle as P, type IEntryListStyle as Q, type IEntryRecordDeleteStyle as R, STYLE_REGISTRY as S, type TStyleName as T, type IEntryRecordFormStyle as U, type IEntryRecordStyle as V, type IEntryTableEntry as W, type IEntryTableStyle as X, type IFieldsetStyle as Y, type IFigureStyle as Z, type _AssertRegistryMatchesStyleName as _, type IPluginStyleRegistryEntry as a, type TMantineAccordionMultiple as a$, type IFlexStyle as a0, type IFormLogStyle as a1, type IFormRecordStyle as a2, type IFormStyle as a3, type IGridColumnStyle as a4, type IGridStyle as a5, type IGroupStyle as a6, type IHighlightStyle as a7, type IHtmlTagStyle as a8, type IImageStyle as a9, type ISegmentedControlStyle as aA, type ISelectStyle as aB, type ISimpleGridStyle as aC, type ISliderStyle as aD, type ISpaceStyle as aE, type ISpoilerStyle as aF, type IStackStyle as aG, type IStyleWithSpacing as aH, type ISwitchStyle as aI, type ITabStyle as aJ, type ITabsStyle as aK, type ITextInputStyle as aL, type ITextStyle as aM, type ITextareaStyle as aN, type IThemeIconStyle as aO, type ITimelineItemStyle as aP, type ITimelineStyle as aQ, type ITitleStyle as aR, type ITwoFactorAuthStyle as aS, type ITypographyStyle as aT, type IUnknownStyle as aU, type IValidateStyle as aV, type IVersionStyle as aW, type IVideoStyle as aX, type TMantineAccordionChevronPosition as aY, type TMantineAccordionDisableChevronRotation as aZ, type TMantineAccordionLoop as a_, type IIndicatorStyle as aa, type IInputStyle as ab, type IKbdStyle as ac, type ILinkStyle as ad, type IListItemStyle as ae, type IListStyle as af, type ILoginStyle as ag, type ILoopStyle as ah, type IMissingStyle as ai, type INoAccessStyle as aj, type INotFoundStyle as ak, type INotificationStyle as al, type INumberInputStyle as am, type IPaperStyle as an, type IProfileStyle as ao, type IProgressRootStyle as ap, type IProgressSectionStyle as aq, type IProgressStyle as ar, type IRadioStyle as as, type IRangeSliderStyle as at, type IRatingStyle as au, type IRefContainerStyle as av, type IRegisterStyle as aw, type IResetPasswordStyle as ax, type IRichTextEditorStyle as ay, type IScrollAreaStyle as az, type TStylePlacement as b, type TMantineAnchorUnderline as b0, type TMantineBorder as b1, type TMantineCardPadding as b2, type TMantineCardShadow as b3, type TMantineCols as b4, type TMantineDividerVariant as b5, type TMantineGap as b6, type TMantineGridOffset as b7, type TMantineGridOrder as b8, type TMantineHeight as b9, type TMantineTitleTextWrap as bA, type TMantineTranslatable as bB, type TMantineUseInputWrapper as bC, type TMantineWidth as bD, type TSharedBorder as bE, type TSharedCols as bF, type TSharedDimension as bG, type TSharedDividerLabelPosition as bH, type TSharedDividerVariant as bI, type TSharedLabelPosition as bJ, type TStyle as bK, type TMantineIconSize as ba, type TMantineImageFit as bb, type TMantineLineClamp as bc, type TMantineListCenter as bd, type TMantineListStyleType as be, type TMantineListType as bf, type TMantineListWithPadding as bg, type TMantinePaperShadow as bh, type TMantineProgressTransition as bi, type TMantineScrollAreaSize as bj, type TMantineScrollAreaType as bk, type TMantineTextAlign as bl, type TMantineTextDecoration as bm, type TMantineTextFontStyle as bn, type TMantineTextFontWeight as bo, type TMantineTextInherit as bp, type TMantineTextInputVariant as bq, type TMantineTextSpan as br, type TMantineTextTransform as bs, type TMantineTextTruncate as bt, type TMantineTextVariant as bu, type TMantineTextareaAutosize as bv, type TMantineTextareaResize as bw, type TMantineTextareaVariant as bx, type TMantineTimelineAlign as by, type TMantineTitleLineClamp as bz, type TConcretePlatform as c, type TStylePlatform as d, type TStyleRegistryKey as e, _resetPluginStyleRegistry as f, extendStyleRegistry as g, getMergedStyleRegistry as h, getPluginStyleRegistry as i, type IContentField as j, type TMobileButtonFeedback as k, type TMobileFieldVariant as l, type TMobileSelectPresentation as m, type IAccordionItemStyle as n, type IAccordionStyle as o, type IActionIconStyle as p, type IAlertStyle as q, type IAspectRatioStyle as r, type IAudioStyle as s, type IAvatarStyle as t, type IBackgroundImageStyle as u, type IBadgeStyle as v, type IBaseStyle as w, type IBlockquoteStyle as x, type IBoxStyle as y, type IButtonStyle as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selfhelp/shared",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.5",
|
|
4
4
|
"description": "Shared TypeScript package for SelfHelp web frontend and mobile app: style registry, types, API contracts, Mantine theme tokens, condition + interpolation engines, CMS class allow-list.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
import {
|
|
7
|
+
parseFieldsMapCatalog,
|
|
8
|
+
parseFieldsMapLabels,
|
|
9
|
+
resolveFieldsMapLabel,
|
|
10
|
+
serializeFieldsMapCatalog,
|
|
11
|
+
serializeFieldsMapLabels,
|
|
12
|
+
} from '../fieldsMapLabels';
|
|
13
|
+
|
|
14
|
+
describe('fieldsMapLabels helpers', () => {
|
|
15
|
+
it('parses ordered field_key catalog arrays', () => {
|
|
16
|
+
expect(parseFieldsMapCatalog(JSON.stringify(['title', 'body']))).toEqual(['title', 'body']);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('parses legacy {field_name, field_new_name} objects into catalog keys', () => {
|
|
20
|
+
expect(parseFieldsMapCatalog(JSON.stringify([
|
|
21
|
+
{ field_name: 'title', field_new_name: 'Headline' },
|
|
22
|
+
{ field_name: 'body' },
|
|
23
|
+
]))).toEqual(['title', 'body']);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('returns empty catalog for invalid JSON or non-arrays', () => {
|
|
27
|
+
expect(parseFieldsMapCatalog('not-json')).toEqual([]);
|
|
28
|
+
expect(parseFieldsMapCatalog(JSON.stringify({ title: 'x' }))).toEqual([]);
|
|
29
|
+
expect(parseFieldsMapCatalog('')).toEqual([]);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('parses per-language labels and ignores empty or non-string values', () => {
|
|
33
|
+
expect(parseFieldsMapLabels(JSON.stringify({
|
|
34
|
+
title: ' Headline ',
|
|
35
|
+
body: '',
|
|
36
|
+
bad: 12,
|
|
37
|
+
}))).toEqual({ title: 'Headline' });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('resolves labels with fallbacks', () => {
|
|
41
|
+
expect(resolveFieldsMapLabel('title', { title: 'Headline' })).toBe('Headline');
|
|
42
|
+
expect(resolveFieldsMapLabel('title', {}, { title: 'Default' })).toBe('Default');
|
|
43
|
+
expect(resolveFieldsMapLabel('title', {})).toBe('title');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('round-trips catalog and labels serializers', () => {
|
|
47
|
+
const keys = ['title', 'body'];
|
|
48
|
+
expect(parseFieldsMapCatalog(serializeFieldsMapCatalog(keys))).toEqual(keys);
|
|
49
|
+
expect(serializeFieldsMapCatalog([])).toBe('');
|
|
50
|
+
expect(parseFieldsMapLabels(serializeFieldsMapLabels({ title: ' Headline ' }))).toEqual({
|
|
51
|
+
title: 'Headline',
|
|
52
|
+
});
|
|
53
|
+
expect(serializeFieldsMapLabels({})).toBe('');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
import {
|
|
7
|
+
parseOptionCatalog,
|
|
8
|
+
parseOptionCodes,
|
|
9
|
+
parseOptionLabels,
|
|
10
|
+
resolveOptionLabel,
|
|
11
|
+
resolveOptionValueLabels,
|
|
12
|
+
resolveOptions,
|
|
13
|
+
} from '../optionLabels';
|
|
14
|
+
|
|
15
|
+
describe('option labels helpers', () => {
|
|
16
|
+
it('parses language-neutral option catalog and keeps metadata', () => {
|
|
17
|
+
const raw = JSON.stringify([
|
|
18
|
+
{ value: 'release', sort: 1, disabled: false, meta: { color: 'blue' } },
|
|
19
|
+
{ value: 'feature', sort: 2 },
|
|
20
|
+
]);
|
|
21
|
+
expect(parseOptionCatalog(raw)).toEqual([
|
|
22
|
+
{ value: 'release', sort: 1, disabled: false, meta: { color: 'blue' } },
|
|
23
|
+
{ value: 'feature', sort: 2 },
|
|
24
|
+
]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('parses per-language labels map and ignores invalid entries', () => {
|
|
28
|
+
const raw = JSON.stringify({
|
|
29
|
+
release: 'Freigabe',
|
|
30
|
+
feature: ' Funktion ',
|
|
31
|
+
notice: '',
|
|
32
|
+
invalid: 12,
|
|
33
|
+
});
|
|
34
|
+
expect(parseOptionLabels(raw)).toEqual({
|
|
35
|
+
release: 'Freigabe',
|
|
36
|
+
feature: 'Funktion',
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('resolves options with label fallback to code', () => {
|
|
41
|
+
const catalog = JSON.stringify([
|
|
42
|
+
{ value: 'release' },
|
|
43
|
+
{ value: 'feature' },
|
|
44
|
+
]);
|
|
45
|
+
const labels = JSON.stringify({
|
|
46
|
+
release: 'Freigabe',
|
|
47
|
+
});
|
|
48
|
+
expect(resolveOptions(catalog, labels)).toEqual([
|
|
49
|
+
{ value: 'release', label: 'Freigabe' },
|
|
50
|
+
{ value: 'feature', label: 'feature' },
|
|
51
|
+
]);
|
|
52
|
+
expect(resolveOptionLabel('release', { release: 'Release' })).toBe('Release');
|
|
53
|
+
expect(resolveOptionLabel('notice', { release: 'Release' })).toBe('notice');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('supports legacy option array with text/label while labels map is empty', () => {
|
|
57
|
+
const legacy = JSON.stringify([
|
|
58
|
+
{ value: 'release', text: 'Release', description: 'Release notes' },
|
|
59
|
+
{ value: 'feature', label: 'Feature' },
|
|
60
|
+
]);
|
|
61
|
+
expect(resolveOptions(legacy, null)).toEqual([
|
|
62
|
+
{
|
|
63
|
+
value: 'release',
|
|
64
|
+
label: 'Release',
|
|
65
|
+
meta: { description: 'Release notes' },
|
|
66
|
+
},
|
|
67
|
+
{ value: 'feature', label: 'Feature' },
|
|
68
|
+
]);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('uses active language, fallback language, legacy label, then code', () => {
|
|
72
|
+
const catalog = [
|
|
73
|
+
{ value: 'release', text: 'Legacy release' },
|
|
74
|
+
{ value: 'feature', label: 'Legacy feature' },
|
|
75
|
+
{ value: 'notice' },
|
|
76
|
+
{ value: 'other' },
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
expect(resolveOptions(
|
|
80
|
+
catalog,
|
|
81
|
+
{ release: 'Freigabe' },
|
|
82
|
+
{ release: 'Release', feature: 'Feature', notice: 'Notice' },
|
|
83
|
+
)).toEqual([
|
|
84
|
+
{ value: 'release', label: 'Freigabe' },
|
|
85
|
+
{ value: 'feature', label: 'Feature' },
|
|
86
|
+
{ value: 'notice', label: 'Notice' },
|
|
87
|
+
{ value: 'other', label: 'other' },
|
|
88
|
+
]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('resolves stored single and multi codes without persisting labels', () => {
|
|
92
|
+
expect(parseOptionCodes('release, notice')).toEqual(['release', 'notice']);
|
|
93
|
+
expect(parseOptionCodes(['release', '', 'notice'])).toEqual(['release', 'notice']);
|
|
94
|
+
expect(resolveOptionValueLabels(
|
|
95
|
+
'release,notice',
|
|
96
|
+
{ release: 'Freigabe' },
|
|
97
|
+
{ notice: 'Notice' },
|
|
98
|
+
)).toEqual(['Freigabe', 'Notice']);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* entry-table column catalog + per-language header labels (select-style split).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface IFieldsMapStyleConfig {
|
|
10
|
+
catalogField: 'fields_map';
|
|
11
|
+
labelsField: 'fields_map_labels';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const FIELDS_MAP_STYLE_CONFIG: IFieldsMapStyleConfig = {
|
|
15
|
+
catalogField: 'fields_map',
|
|
16
|
+
labelsField: 'fields_map_labels',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function parseJson(raw: unknown): unknown {
|
|
20
|
+
if (typeof raw !== 'string' || raw.trim() === '') {
|
|
21
|
+
return raw;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(raw);
|
|
25
|
+
} catch {
|
|
26
|
+
return raw;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Parse ordered field_key catalog from property `fields_map`. */
|
|
31
|
+
export function parseFieldsMapCatalog(raw: unknown): string[] {
|
|
32
|
+
const parsed = parseJson(raw);
|
|
33
|
+
if (!Array.isArray(parsed)) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const keys: string[] = [];
|
|
38
|
+
for (const item of parsed) {
|
|
39
|
+
if (typeof item === 'string' && item.trim() !== '') {
|
|
40
|
+
keys.push(item.trim());
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (item && typeof item === 'object' && !Array.isArray(item)) {
|
|
44
|
+
const record = item as Record<string, unknown>;
|
|
45
|
+
const legacy = typeof record.field_name === 'string' ? record.field_name.trim() : '';
|
|
46
|
+
if (legacy !== '') {
|
|
47
|
+
keys.push(legacy);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return keys;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function parseFieldsMapLabels(raw: unknown): Record<string, string> {
|
|
56
|
+
const parsed = parseJson(raw);
|
|
57
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const labels: Record<string, string> = {};
|
|
62
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
63
|
+
if (!key || typeof value !== 'string') {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const trimmed = value.trim();
|
|
67
|
+
if (trimmed !== '') {
|
|
68
|
+
labels[key] = trimmed;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return labels;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function resolveFieldsMapLabel(
|
|
76
|
+
fieldKey: string,
|
|
77
|
+
labels: Record<string, string>,
|
|
78
|
+
fallbackLabels: Record<string, string> = {},
|
|
79
|
+
): string {
|
|
80
|
+
return labels[fieldKey] ?? fallbackLabels[fieldKey] ?? fieldKey;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function serializeFieldsMapCatalog(fieldKeys: string[]): string {
|
|
84
|
+
const keys = fieldKeys.map((key) => key.trim()).filter((key) => key !== '');
|
|
85
|
+
if (keys.length === 0) {
|
|
86
|
+
return '';
|
|
87
|
+
}
|
|
88
|
+
return JSON.stringify(keys);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function serializeFieldsMapLabels(labels: Record<string, string>): string {
|
|
92
|
+
const clean: Record<string, string> = {};
|
|
93
|
+
for (const [key, value] of Object.entries(labels)) {
|
|
94
|
+
const trimmed = value.trim();
|
|
95
|
+
if (key && trimmed !== '') {
|
|
96
|
+
clean[key] = trimmed;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (Object.keys(clean).length === 0) {
|
|
100
|
+
return '';
|
|
101
|
+
}
|
|
102
|
+
return JSON.stringify(clean);
|
|
103
|
+
}
|