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

View File

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

View File

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

View File

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