Remove grid checkboxes if not relevant, improve quiet styles, fix issue with default conditions

This commit is contained in:
Andrew Kingston 2025-03-06 16:43:30 +00:00
parent c063cefd7e
commit 2029d6ae59
No known key found for this signature in database
4 changed files with 27 additions and 10 deletions

View File

@ -56,7 +56,7 @@
rowIdx={row?.__idx}
metadata={row?.__metadata?.row}
>
<div class="gutter">
<div class="gutter" class:selectable={$config.canSelectRows}>
{#if $$slots.default}
<slot />
{:else}
@ -116,12 +116,9 @@
margin: 3px 0 0 0;
}
.number {
color: val(--cell-font-color, var(--spectrum-global-color-gray-500));
}
.checkbox.visible,
.number.visible {
display: flex;
color: var(--spectrum-global-color-gray-500);
}
.delete,
.expand {
margin-right: 4px;
@ -137,4 +134,11 @@
.delete:hover :global(.spectrum-Icon) {
color: var(--spectrum-global-color-red-600) !important;
}
/* Visibility of checkbox and number */
.gutter.selectable .checkbox.visible,
.number.visible,
.gutter:not(.selectable) .number {
display: flex;
}
</style>

View File

@ -354,11 +354,16 @@
/* Overrides for quiet */
.grid.quiet :global(.grid-data-content .row > .cell:not(:last-child)),
.grid.quiet :global(.sticky-column .row > .cell),
.grid.quiet :global(.new-row .row > .cell:not(:last-child)) {
.grid.quiet :global(.sticky-column .row .cell),
.grid.quiet :global(.new-row .row > .cell:not(:last-child)),
.grid.quiet :global(.header-cell:not(:last-child) .cell) {
border-right: none;
}
.grid.quiet :global(.sticky-column:before) {
display: none;
}
.grid.quiet :global(.header),
.grid.quiet :global(.header .cell) {
background: var(--grid-background);
}
</style>

View File

@ -7,8 +7,12 @@ type ConfigStore = {
[key in keyof BaseStoreProps]: Readable<BaseStoreProps[key]>
}
interface ConfigState extends BaseStoreProps {
canSelectRows: boolean
}
interface ConfigDerivedStore {
config: Readable<BaseStoreProps>
config: Readable<ConfigState>
}
export type Store = ConfigStore & ConfigDerivedStore
@ -47,7 +51,7 @@ export const deriveStores = (context: StoreContext): ConfigDerivedStore => {
const config = derived(
[props, definition, hasNonAutoColumn],
([$props, $definition, $hasNonAutoColumn]) => {
let config = { ...$props }
let config: ConfigState = { ...$props, canSelectRows: false }
const type = $props.datasource?.type
// Disable some features if we're editing a view
@ -78,6 +82,9 @@ export const deriveStores = (context: StoreContext): ConfigDerivedStore => {
config.canEditColumns = false
}
// Determine if we can select rows
config.canSelectRows = false //!!config.canDeleteRows || !!config.canAddRows
return config
}
)

View File

@ -296,6 +296,7 @@ export function createSampleDataTableScreen(): Screen {
active: true,
conditions: [
{
id: Math.random(),
target: "row",
metadataKey: "backgroundColor",
operator: "contains",