( container: HTMLElement, options: SettingGroupOptions, addSettings: (group: SettingGroupLike) => void )
| 113 | * Uses native SettingGroup on Obsidian 1.11.0+, falls back to legacy pattern on older versions |
| 114 | */ |
| 115 | export function createSettingGroup( |
| 116 | container: HTMLElement, |
| 117 | options: SettingGroupOptions, |
| 118 | addSettings: (group: SettingGroupLike) => void |
| 119 | ): SettingGroupLike { |
| 120 | if (supportsSettingGroup()) { |
| 121 | // Use native SettingGroup on Obsidian 1.11.0+ |
| 122 | const group = new SettingGroup(container).setHeading(options.heading); |
| 123 | |
| 124 | if (options.className) { |
| 125 | group.addClass(options.className); |
| 126 | } |
| 127 | |
| 128 | // Add description as help text if provided |
| 129 | if (options.description) { |
| 130 | const description = options.description; |
| 131 | group.addSetting((setting) => { |
| 132 | setting.setDesc(description); |
| 133 | setting.settingEl.addClass("settings-view__group-description"); |
| 134 | }); |
| 135 | } |
| 136 | |
| 137 | addSettings(group); |
| 138 | return group; |
| 139 | } else { |
| 140 | // Fall back to legacy pattern on older Obsidian versions |
| 141 | const group = new LegacySettingGroup(container).setHeading(options.heading); |
| 142 | |
| 143 | if (options.className) { |
| 144 | group.addClass(options.className); |
| 145 | } |
| 146 | |
| 147 | // Add description as help text if provided |
| 148 | if (options.description) { |
| 149 | const description = options.description; |
| 150 | group.addSetting((setting) => { |
| 151 | setting.setDesc(description); |
| 152 | setting.settingEl.addClass("settings-view__group-description"); |
| 153 | }); |
| 154 | } |
| 155 | |
| 156 | addSettings(group); |
| 157 | return group; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Helper for configuring a toggle setting (works with SettingGroup.addSetting) |
no test coverage detected