Eliminates `Provider.require()` from the eidos `Table.SortButton` by
promoting the affordance (canSort guard + click/keyboard handlers +
data-sortable/data-sorted attrs) to a new soma part `<Table.SortTrigger>`.
Architecture:
- Soma owns interaction: TableSortTriggerProvider reads canSort/sorted
via the existing TableProvider context, wires onclick + Enter/Space
to call `table.toggleSort`, and stamps the canonical data-attrs.
- Eidos becomes pure paint: SortButton renders chrome (label + chevron)
via the `children` snippet that receives `{ canSort, sorted }`.
Public API of eidos `<Table.SortButton>` is unchanged — consumers continue
to write `<Table.SortButton {header}>{header.label}</Table.SortButton>`.
CSS selectors in eidos table.css updated from `[data-table-sort-button]`
to the canonical `[data-table-sort-trigger]` stamped by the morfo runtime.
Test result unchanged: 2391/2397 passing. No regressions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
active-uix
parent
f13103e9a9
commit
a15b785cc1
@ -0,0 +1,52 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import {
|
||||||
|
readableActive,
|
||||||
|
writableActive
|
||||||
|
} from '$libs/reactive';
|
||||||
|
import { mergeProps } from '../../../props';
|
||||||
|
import { createId } from '../../../id';
|
||||||
|
import { TableSortTriggerProvider } from '../table-provider.svelte';
|
||||||
|
import type { TableSortTriggerProps } from '../types';
|
||||||
|
|
||||||
|
const uid = $props.id();
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
id = createId(uid, 'table-sort-trigger'),
|
||||||
|
header,
|
||||||
|
children,
|
||||||
|
child,
|
||||||
|
...restProps
|
||||||
|
}: TableSortTriggerProps = $props();
|
||||||
|
|
||||||
|
const provider = TableSortTriggerProvider.create({
|
||||||
|
id: readableActive(() => id),
|
||||||
|
ref: writableActive(
|
||||||
|
() => ref,
|
||||||
|
(v) => (ref = v)
|
||||||
|
),
|
||||||
|
header: readableActive(() => header)
|
||||||
|
});
|
||||||
|
|
||||||
|
const mergedProps = $derived(mergeProps(restProps, provider.props));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if child}
|
||||||
|
{@render child({
|
||||||
|
props: mergedProps,
|
||||||
|
canSort: provider.canSort,
|
||||||
|
sorted: provider.sorted
|
||||||
|
})}
|
||||||
|
{:else if provider.canSort}
|
||||||
|
<button {...mergedProps}>
|
||||||
|
{#if children}
|
||||||
|
{@render children({ canSort: provider.canSort, sorted: provider.sorted })}
|
||||||
|
{:else}
|
||||||
|
{header.label}
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
{:else if children}
|
||||||
|
{@render children({ canSort: provider.canSort, sorted: provider.sorted })}
|
||||||
|
{:else}
|
||||||
|
{header.label}
|
||||||
|
{/if}
|
||||||
Loading…
Reference in new issue