createSingle wraps createSelection and adds singular getters but also duplicates unselect and toggle functions that just call the original:
|
function unselect (id: ID) { |
|
registry.unselect(id) |
|
} |
|
|
|
function toggle (id: ID) { |
|
if (registry.selectedIds.has(id)) unselect(id) |
|
else registry.select(id) |
|
} |
|
function toggle (id: ID) { |
|
if (toValue(model.disabled)) return |
|
|
|
if (model.selectedIds.has(id)) unselect(id) |
|
else select(id) |
|
} |
createSelection wraps createModel adding mandatory, most of its functions are direct copies:
|
function select (id: ID) { |
|
if (toValue(model.disabled)) return |
|
|
|
const item = model.get(id) |
|
if (!item || toValue(item.disabled)) return |
|
|
|
if (!toValue(multiple)) model.selectedIds.clear() |
|
model.selectedIds.add(id) |
|
} |
|
function select (id: ID) { |
|
if (toValue(disabled)) return |
|
|
|
const item = registry.get(id) |
|
if (!item || toValue(item.disabled)) return |
|
|
|
if (!toValue(multiple)) selectedIds.clear() |
|
selectedIds.add(id) |
|
} |
|
function toggle (id: ID) { |
|
if (toValue(model.disabled)) return |
|
|
|
if (model.selectedIds.has(id)) unselect(id) |
|
else select(id) |
|
} |
|
function toggle (id: ID) { |
|
if (toValue(disabled)) return |
|
|
|
if (selected(id)) unselect(id) |
|
else select(id) |
|
} |
createModel apparently supports multiple but has another copy of apply that ignores the multiple option and only uses the first value. createSelection also re-uses the tsdoc description that says "for API compatibility with createSelection. The multiple field is accepted but ignored".
createSingle wraps createSelection and adds singular getters but also duplicates unselect and toggle functions that just call the original:
0/packages/0/src/composables/createSingle/index.ts
Lines 143 to 150 in 20dc0bd
0/packages/0/src/composables/createSelection/index.ts
Lines 236 to 241 in 47cac1a
createSelection wraps createModel adding mandatory, most of its functions are direct copies:
0/packages/0/src/composables/createSelection/index.ts
Lines 219 to 227 in 47cac1a
0/packages/0/src/composables/createModel/index.ts
Lines 375 to 383 in fa5c882
0/packages/0/src/composables/createSelection/index.ts
Lines 236 to 241 in 47cac1a
0/packages/0/src/composables/createModel/index.ts
Lines 391 to 396 in fa5c882
createModel apparently supports multiple but has another copy of apply that ignores the multiple option and only uses the first value. createSelection also re-uses the tsdoc description that says "for API compatibility with createSelection. The
multiplefield is accepted but ignored".