mirror of
https://github.com/zadam/trilium.git
synced 2025-12-12 02:14:25 +01:00
feat(options/advanced): add description for experimental
This commit is contained in:
parent
668ee219c6
commit
fc2ab91280
@ -189,6 +189,7 @@ function ExperimentalOptions() {
|
|||||||
values={experimentalFeatures}
|
values={experimentalFeatures}
|
||||||
keyProperty="id"
|
keyProperty="id"
|
||||||
titleProperty="name"
|
titleProperty="name"
|
||||||
|
descriptionProperty="description"
|
||||||
currentValue={enabledExperimentalFeatures} onChange={setEnabledExperimentalFeatures}
|
currentValue={enabledExperimentalFeatures} onChange={setEnabledExperimentalFeatures}
|
||||||
/>
|
/>
|
||||||
</OptionsSection>
|
</OptionsSection>
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
|
import FormCheckbox from "../../../react/FormCheckbox";
|
||||||
|
|
||||||
interface CheckboxListProps<T> {
|
interface CheckboxListProps<T> {
|
||||||
values: T[];
|
values: T[];
|
||||||
keyProperty: keyof T;
|
keyProperty: keyof T;
|
||||||
titleProperty?: keyof T;
|
titleProperty?: keyof T;
|
||||||
disabledProperty?: keyof T;
|
disabledProperty?: keyof T;
|
||||||
|
descriptionProperty?: keyof T;
|
||||||
currentValue: string[];
|
currentValue: string[];
|
||||||
onChange: (newValues: string[]) => void;
|
onChange: (newValues: string[]) => void;
|
||||||
columnWidth?: string;
|
columnWidth?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CheckboxList<T>({ values, keyProperty, titleProperty, disabledProperty, currentValue, onChange, columnWidth }: CheckboxListProps<T>) {
|
export default function CheckboxList<T>({ values, keyProperty, titleProperty, disabledProperty, descriptionProperty, currentValue, onChange, columnWidth }: CheckboxListProps<T>) {
|
||||||
function toggleValue(value: string) {
|
function toggleValue(value: string) {
|
||||||
if (currentValue.includes(value)) {
|
if (currentValue.includes(value)) {
|
||||||
// Already there, needs removing.
|
// Already there, needs removing.
|
||||||
@ -22,20 +25,17 @@ export default function CheckboxList<T>({ values, keyProperty, titleProperty, di
|
|||||||
return (
|
return (
|
||||||
<ul style={{ listStyleType: "none", marginBottom: 0, columnWidth: columnWidth ?? "400px" }}>
|
<ul style={{ listStyleType: "none", marginBottom: 0, columnWidth: columnWidth ?? "400px" }}>
|
||||||
{values.map(value => (
|
{values.map(value => (
|
||||||
<li>
|
<li key={String(value[keyProperty])}>
|
||||||
<label className="tn-checkbox">
|
<FormCheckbox
|
||||||
<input
|
label={String(value[titleProperty ?? keyProperty] ?? value[keyProperty])}
|
||||||
type="checkbox"
|
name={String(value[keyProperty])}
|
||||||
className="form-check-input"
|
currentValue={currentValue.includes(String(value[keyProperty]))}
|
||||||
value={String(value[keyProperty])}
|
disabled={!!(disabledProperty && value[disabledProperty])}
|
||||||
checked={currentValue.includes(String(value[keyProperty]))}
|
hint={value && (descriptionProperty ? String(value[descriptionProperty]) : undefined)}
|
||||||
disabled={!!(disabledProperty && value[disabledProperty])}
|
onChange={() => toggleValue(String(value[keyProperty]))}
|
||||||
onChange={e => toggleValue((e.target as HTMLInputElement).value)}
|
/>
|
||||||
/>
|
|
||||||
{String(value[titleProperty ?? keyProperty] ?? value[keyProperty])}
|
|
||||||
</label>
|
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user